"""
vpp_cmdline = self.create_cmdline(isolated_cpus)
- if vpp_cmdline == '':
- return vpp_cmdline
-
- # Update grub
- # Save the original file
- rootdir = node['rootdir']
- grubcmdline = node['cpu']['grubcmdline']
- ofilename = rootdir + node['cpu']['grub_config_file'] + '.orig'
- filename = rootdir + node['cpu']['grub_config_file']
-
- # Write the output file
- # Does a copy of the original file exist, if not create one
- (ret, stdout, stderr) = VPPUtil.exec_command('ls {}'.format(ofilename))
- if ret != 0:
- if stdout.strip('\n') != ofilename:
- cmd = 'sudo cp {} {}'.format(filename, ofilename)
- (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
- if ret != 0:
- raise RuntimeError('{} failed on node {} {}'.
- format(cmd, self._node['host'], stderr))
-
- # Get the contents of the current grub config file
- cmd = 'cat {}'.format(filename)
- (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
- if ret != 0:
- raise RuntimeError('{} failed on node {} {}'.format(
- cmd,
- self._node['host'],
- stderr))
-
- # Write the new contents
- # Get the Default Linux command line, ignoring commented lines
- content = ""
- lines = stdout.split('\n')
- for line in lines:
- if line == '':
- content += line + '\n'
- continue
- if line[0] == '#':
- content += line + '\n'
- continue
-
- ldefault = re.findall(r'{}=.+'.format(grubcmdline), line)
- if ldefault:
- content += vpp_cmdline + '\n'
- else:
- content += line + '\n'
-
- content = content.replace(r"`", r"\`")
- content = content.rstrip('\n')
- cmd = "sudo cat > {0} << EOF\n{1}\n".format(filename, content)
- (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
- if ret != 0:
- raise RuntimeError('{} failed on node {} {}'.format(
- cmd,
- self._node['host'],
- stderr))
+ if len(vpp_cmdline):
+ # Update grub
+ # Save the original file
+ rootdir = node['rootdir']
+ grubcmdline = node['cpu']['grubcmdline']
+ ofilename = rootdir + node['cpu']['grub_config_file'] + '.orig'
+ filename = rootdir + node['cpu']['grub_config_file']
+
+ # Write the output file
+ # Does a copy of the original file exist, if not create one
+ (ret, stdout, stderr) = VPPUtil.exec_command(
+ 'ls {}'.format(ofilename))
+ if ret != 0:
+ if stdout.strip('\n') != ofilename:
+ cmd = 'sudo cp {} {}'.format(filename, ofilename)
+ (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
+ if ret != 0:
+ raise RuntimeError('{} failed on node {} {}'.
+ format(cmd, self._node['host'],
+ stderr))
+
+ # Get the contents of the current grub config file
+ cmd = 'cat {}'.format(filename)
+ (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
+ if ret != 0:
+ raise RuntimeError('{} failed on node {} {}'.format(
+ cmd,
+ self._node['host'],
+ stderr))
+
+ # Write the new contents
+ # Get the Default Linux command line, ignoring commented lines
+ content = ""
+ lines = stdout.split('\n')
+ for line in lines:
+ if line == '':
+ content += line + '\n'
+ continue
+ if line[0] == '#':
+ content += line + '\n'
+ continue
+
+ ldefault = re.findall(r'{}=.+'.format(grubcmdline), line)
+ if ldefault:
+ content += vpp_cmdline + '\n'
+ else:
+ content += line + '\n'
+
+ content = content.replace(r"`", r"\`")
+ content = content.rstrip('\n')
+ cmd = "sudo cat > {0} << EOF\n{1}\n".format(filename, content)
+ (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
+ if ret != 0:
+ raise RuntimeError('{} failed on node {} {}'.format(
+ cmd,
+ self._node['host'],
+ stderr))
return vpp_cmdline
import unittest
import time
-from socket import inet_pton, inet_ntop, AF_INET6
+import socket
+from socket import inet_pton, inet_ntop
from vpp_object import VppObject
from vpp_papi import VppEnum
-from scapy.packet import Raw
+from scapy.packet import raw
from scapy.layers.l2 import Ether, ARP
from scapy.layers.inet import IP, ICMP, icmptypes
from scapy.layers.inet6 import IPv6, ipv6nh, IPv6ExtHdrHopByHop, \
self.assertEqual(pkt[IPv6].dst, "ff02::1")
# convert addrs to packed format since string versions could differ
- src_addr = inet_pton(AF_INET6, pkt[IPv6].src)
- vr_ll_addr = inet_pton(AF_INET6, vr.interface().local_ip6_ll)
+ src_addr = inet_pton(socket.AF_INET6, pkt[IPv6].src)
+ vr_ll_addr = inet_pton(socket.AF_INET6, vr.interface().local_ip6_ll)
self.assertEqual(src_addr, vr_ll_addr)
self.assertTrue(pkt[ICMPv6ND_NA].tgt in vr.virtual_ips())