summaryrefslogtreecommitdiffstats
path: root/testsuites/vstf/vstf_scripts/vstf/agent/env
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/agent/env')
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/collect.py44
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/commandline.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/device_manager.py13
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/image_manager.py52
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm9pfs.py17
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_manager.py37
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_xml_help.py5
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/builder.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/__init__.py2
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/manager.py4
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/model.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/origin_driver.py4
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/FSMonitor.py62
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/constant.py2
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/utils.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/libvirt_plugin.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/tester_env_plugin.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/bridge_plugin.py5
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/manager.py4
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/model.py2
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/ovs_plugin.py43
24 files changed, 215 insertions, 104 deletions
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/__init__.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/__init__.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/collect.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/collect.py
index 126a7d55..1d39d7b7 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/collect.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/collect.py
@@ -31,11 +31,11 @@ class Collect(object):
"""the base _system info
{'os info':{'_system':'ubuntu', 'kernel': '3.13.3'}}"""
return {const.OS_INFO:
- {
- '_system': open('/etc/issue.net').readline().strip(),
- 'kernel': platform.uname()[2]
- }
- }
+ {
+ '_system': open('/etc/issue.net').readline().strip(),
+ 'kernel': platform.uname()[2]
+ }
+ }
def _memery(self):
""" Return the information in /proc/meminfo
@@ -46,11 +46,11 @@ class Collect(object):
meminfo[line.split(':')[0]] = line.split(':')[1].strip()
return {const.MEMORY_INFO:
- {
- "Mem Total": meminfo['MemTotal'],
- "Mem Swap": meminfo['SwapTotal']
- }
- }
+ {
+ "Mem Total": meminfo['MemTotal'],
+ "Mem Swap": meminfo['SwapTotal']
+ }
+ }
def _lscpu(self):
ret = {}
@@ -68,18 +68,19 @@ class Collect(object):
ret.append(cpuinfo)
cpuinfo = OrderedDict()
elif len(line.split(':')) == 2:
- cpuinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()
+ cpuinfo[line.split(':')[0].strip()] = line.split(':')[
+ 1].strip()
else:
log.error("_cpu info unknow format <%(c)s>", {'c': line})
return {const.CPU_INFO:
- dict(
- {
- "Model Name": ret[0]['model name'],
- "Address sizes": ret[0]['address sizes']
- },
- **(self._lscpu())
- )
- }
+ dict(
+ {
+ "Model Name": ret[0]['model name'],
+ "Address sizes": ret[0]['address sizes']
+ },
+ **(self._lscpu())
+ )
+ }
def _hw_sysinfo(self):
cmdline = "dmidecode | grep -A 2 'System Information' | grep -v 'System Information'"
@@ -90,14 +91,15 @@ class Collect(object):
for tmp in output.strip().split('\n'):
if tmp is None or tmp is "":
continue
- # split the items
+ # split the items
tmp = tmp.split(":")
if len(tmp) >= 2:
# first item as key, and the other as value
result[tmp[0].strip("\t")] = ";".join(tmp[1:])
return {const.HW_INFO: result}
else:
- return {const.HW_INFO: "get hw info failed. check the host by cmd: dmidecode"}
+ return {
+ const.HW_INFO: "get hw info failed. check the host by cmd: dmidecode"}
def collect_host_info(self):
return [self._system, self._cpu, self._memery(), self._hw_sysinfo()]
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/commandline.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/commandline.py
index e4df9b27..29dd2c02 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/commandline.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/commandline.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class CommandLine(object):
+
def __init__(self):
super(CommandLine, self).__init__()
self.proc = None
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/device_manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/device_manager.py
index 8b5387fe..c34f5e06 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/device_manager.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/device_manager.py
@@ -21,6 +21,7 @@ default_drivers = {
class LspciHelper(object):
+
def __init__(self):
self.bdf_desc_map = {}
self.bdf_device_map = {}
@@ -45,7 +46,8 @@ class LspciHelper(object):
for bdf, desc in self.bdf_desc_map.items():
device = get_device_name(bdf)
if device is None:
- LOG.info("cann't find device name for bdf:%s, no driver is available.", bdf)
+ LOG.info(
+ "cann't find device name for bdf:%s, no driver is available.", bdf)
try:
self._load_driver(desc)
except:
@@ -66,13 +68,17 @@ class LspciHelper(object):
def _get_ip_macs(self):
for device, bdf in self.device_bdf_map.items():
buf = check_output("ip addr show dev %s" % device, shell=True)
- macs = re.compile("[A-F0-9]{2}(?::[A-F0-9]{2}){5}", re.IGNORECASE | re.MULTILINE)
+ macs = re.compile(
+ "[A-F0-9]{2}(?::[A-F0-9]{2}){5}",
+ re.IGNORECASE | re.MULTILINE)
for mac in macs.findall(buf):
if mac.lower() in ('00:00:00:00:00:00', 'ff:ff:ff:ff:ff:ff'):
continue
else:
break
- ips = re.compile(r"inet (\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}/\d{1,2})", re.MULTILINE)
+ ips = re.compile(
+ r"inet (\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}/\d{1,2})",
+ re.MULTILINE)
ip = ips.findall(buf)
if ip:
self.bdf_ip_map[bdf] = ip[0]
@@ -93,6 +99,7 @@ class LspciHelper(object):
class DeviceManager(object):
+
def __init__(self):
super(DeviceManager, self).__init__()
mgr = netns.NetnsManager()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/image_manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/image_manager.py
index c3b5c6b3..4bae49d2 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/image_manager.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/image_manager.py
@@ -19,6 +19,7 @@ class _ImageManager(object):
A qemu-img wrapper to create qcow2 child image from a parent image.
"""
+
def __init__(self, parent_image_path, child_image_dir):
"""
:param parent_image_path str: the parent image path.
@@ -31,7 +32,11 @@ class _ImageManager(object):
assert os.path.isfile(self.parent_image_path)
assert os.path.isdir(self.child_image_dir)
- def create_child_image(self, child_name, full_clone=False, image_type='qcow2'):
+ def create_child_image(
+ self,
+ child_name,
+ full_clone=False,
+ image_type='qcow2'):
"""
create a child image and put it in self.child_image_dir.
@@ -39,16 +44,25 @@ class _ImageManager(object):
:return: return the path of child image.
"""
- image_path = os.path.join(self.child_image_dir, child_name) + '.' + image_type
+ image_path = os.path.join(
+ self.child_image_dir,
+ child_name) + '.' + image_type
if full_clone:
- cmd = self._convert_str % {'image_type': image_type, 'child_path': image_path, 'parent_path': self.parent_image_path}
+ cmd = self._convert_str % {
+ 'image_type': image_type,
+ 'child_path': image_path,
+ 'parent_path': self.parent_image_path}
else:
- cmd = self._create_child_str % {'child_path': image_path, 'parent_path': self.parent_image_path, 'image_type':image_type}
+ cmd = self._create_child_str % {
+ 'child_path': image_path,
+ 'parent_path': self.parent_image_path,
+ 'image_type': image_type}
check_call(cmd.split())
return image_path
class ImageManager(object):
+
def __init__(self, cfg):
"""
ImageManager creates images from configuration context.
@@ -74,13 +88,22 @@ class ImageManager(object):
@staticmethod
def _check_cfg(cfg):
- for key in ('parent_image', 'dst_location', 'full_clone', 'type', 'names'):
+ for key in (
+ 'parent_image',
+ 'dst_location',
+ 'full_clone',
+ 'type',
+ 'names'):
if key not in cfg:
raise Exception("does't find %s config" % key)
if cfg['type'] not in ('raw', 'qcow2'):
- raise Exception("type:%s not supported, only support 'raw' and 'qcow2'" % cfg['type'])
+ raise Exception(
+ "type:%s not supported, only support 'raw' and 'qcow2'" %
+ cfg['type'])
if not cfg['full_clone'] and cfg['type'] == 'raw':
- raise Exception("only support 'qcow2' for not full_clone image creation" % cfg['type'])
+ raise Exception(
+ "only support 'qcow2' for not full_clone image creation" %
+ cfg['type'])
return cfg
def create_all(self):
@@ -90,7 +113,8 @@ class ImageManager(object):
:return: True for success, False for failure.
"""
for name in self.names:
- image = self.mgr.create_child_image(name, self.full_clone, self.image_type)
+ image = self.mgr.create_child_image(
+ name, self.full_clone, self.image_type)
LOG.info("image: %s created", image)
return True
@@ -101,7 +125,8 @@ class ImageManager(object):
:return: True for success. Raise exception otherwise.
"""
for name in self.names:
- image_path = os.path.join(self.image_dir, name + '.' + self.image_type)
+ image_path = os.path.join(
+ self.image_dir, name + '.' + self.image_type)
try:
os.unlink(image_path)
LOG.info("remove:%s successfully", image_path)
@@ -114,7 +139,12 @@ if __name__ == '__main__':
import argparse
import json
parser = argparse.ArgumentParser()
- parser.add_argument('action', choices = ('create','clean'), help='action:create|clean')
+ parser.add_argument(
+ 'action',
+ choices=(
+ 'create',
+ 'clean'),
+ help='action:create|clean')
parser.add_argument('--config', help='config file to parse')
args = parser.parse_args()
logging.basicConfig(level=logging.INFO)
@@ -124,5 +154,3 @@ if __name__ == '__main__':
mgr.create_all()
if args.action == 'clean':
mgr.clean_all()
-
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py
index 6edd14ca..5aca5368 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/source_manager.py
@@ -27,6 +27,7 @@ def my_chdir(file_path):
class SourceCodeManager(object):
+
def __init__(self):
super(SourceCodeManager, self).__init__()
self.base_path = '/opt/vstf/'
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm9pfs.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm9pfs.py
index 7364f8b2..4b7b31b1 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm9pfs.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm9pfs.py
@@ -69,7 +69,9 @@ class VMConfigBy9pfs(object):
return ret == constant.VM_CMD_EXCUTE_SUCCES_FLAG_CONTENT
def _wait_command_done(self):
- done = self._wait_flag_file_to_exist(constant.VM_CMD_DONE_FLAG_FILE, constant.VM_COMMON_CMD_EXCUTE_TIME_OUT)
+ done = self._wait_flag_file_to_exist(
+ constant.VM_CMD_DONE_FLAG_FILE,
+ constant.VM_COMMON_CMD_EXCUTE_TIME_OUT)
if done:
return self._get_cmd_return_code()
else:
@@ -86,7 +88,8 @@ class VMConfigBy9pfs(object):
raise Exception("9pfs command failure: timeout.")
def wait_up(self):
- return self._wait_flag_file_to_exist(constant.VM_UP_Flag_FILE, constant.VM_UP_TIME_OUT)
+ return self._wait_flag_file_to_exist(
+ constant.VM_UP_Flag_FILE, constant.VM_UP_TIME_OUT)
def config_ip(self, mac, ip):
cmd = 'config_ip %s %s' % (mac, ip)
@@ -118,7 +121,13 @@ class VMConfigBy9pfs(object):
cmd = 'recover_nic_binding ' + mac_str
return self._set_cmd(cmd)
- def config_amqp(self, identity, server, port=5672, user="guest", passwd="guest"):
+ def config_amqp(
+ self,
+ identity,
+ server,
+ port=5672,
+ user="guest",
+ passwd="guest"):
data = {
'server': server,
'port': port,
@@ -135,7 +144,7 @@ class VMConfigBy9pfs(object):
id=%(id)s''' % data
file_name = "amqp.ini"
dedented_text = textwrap.dedent(content)
- self._write(file_name, header+dedented_text)
+ self._write(file_name, header + dedented_text)
cmd = 'config_amqp %s' % file_name
return self._set_cmd(cmd)
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_manager.py
index 60a3b37b..d0a2060d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_manager.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_manager.py
@@ -93,8 +93,14 @@ class VMControlOperation(object):
@staticmethod
def check_required_options(context):
- for key in ('vm_name', 'vm_memory', 'vm_cpu', 'image_path', 'image_type', 'taps'):
- if not context.has_key(key):
+ for key in (
+ 'vm_name',
+ 'vm_memory',
+ 'vm_cpu',
+ 'image_path',
+ 'image_type',
+ 'taps'):
+ if key not in context:
raise Exception("vm config error, must set %s option" % key)
def set_vm_defaults(self, context):
@@ -117,14 +123,18 @@ class VMControlOperation(object):
context.setdefault(k, v)
def _shutdown_vm(self):
- out = check_output("virsh list | sed 1,2d | awk '{print $2}'", shell=True)
+ out = check_output(
+ "virsh list | sed 1,2d | awk '{print $2}'",
+ shell=True)
vm_set = set(out.split())
for vm in vm_set:
check_call("virsh shutdown %s" % vm, shell=True)
timeout = 60
# wait for gracefully shutdown
while timeout > 0:
- out = check_output("virsh list | sed 1,2d | awk '{print $2}'", shell=True)
+ out = check_output(
+ "virsh list | sed 1,2d | awk '{print $2}'",
+ shell=True)
vm_set = set(out.split())
if len(vm_set) == 0:
break
@@ -135,7 +145,9 @@ class VMControlOperation(object):
for vm in vm_set:
check_call("virsh destroy %s" % vm, shell=True)
# undefine all
- out = check_output("virsh list --all | sed 1,2d | awk '{print $2}'", shell=True)
+ out = check_output(
+ "virsh list --all | sed 1,2d | awk '{print $2}'",
+ shell=True)
vm_set = set(out.split())
for vm in vm_set:
check_call("virsh undefine %s" % vm, shell=True)
@@ -177,7 +189,8 @@ class VMControlOperation(object):
vm9pctrl = self.vm_9p_controllers[vm_name]
ret = vm9pctrl.wait_up()
if ret not in (True,):
- raise Exception('vm running but stuck in boot process, please manully check.')
+ raise Exception(
+ 'vm running but stuck in boot process, please manully check.')
LOG.debug('waitVM %s up ok, ret:%s', vm_name, ret)
return True
@@ -193,12 +206,14 @@ class VMControlOperation(object):
# print self.vm_9p_controllers
init_cfg = vm_cfg['init_config']
if "ctrl_ip_setting" in init_cfg:
- ret = vm9pctrl.config_ip(vm_cfg['ctrl_mac'], init_cfg['ctrl_ip_setting'])
- assert ret == True
+ ret = vm9pctrl.config_ip(
+ vm_cfg['ctrl_mac'],
+ init_cfg['ctrl_ip_setting'])
+ assert ret
LOG.info('initConfigVM config ip ok')
if 'ctrl_gw' in init_cfg:
ret = vm9pctrl.config_gw(init_cfg['ctrl_gw'])
- assert ret == True
+ assert ret
LOG.info('initConfigVM ctrl_gw ok')
if "ctrl_ip_setting" in init_cfg and "amqp_server" in init_cfg:
identity = init_cfg['ctrl_ip_setting'].split('/')[0]
@@ -209,7 +224,7 @@ class VMControlOperation(object):
user = init_cfg['amqp_user']
passwd = init_cfg['amqp_passwd']
ret = vm9pctrl.config_amqp(identity, server, port, user, passwd)
- assert ret == True
+ assert ret
LOG.info('initConfigVM config_amqp ok')
if 'tap_pktloop_config' in init_cfg:
taps = vm_cfg['taps']
@@ -217,6 +232,6 @@ class VMControlOperation(object):
for tap in taps:
macs.append(tap['tap_mac'])
ret = vm9pctrl.set_pktloop_dpdk(macs)
- assert ret == True
+ assert ret
LOG.info('initConfigVM set_pktloop_dpdk ok')
return True
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_xml_help.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_xml_help.py
index 6f9131e7..89c10963 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_xml_help.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/basic/vm_xml_help.py
@@ -38,7 +38,7 @@ xml_disk = '''
<source file='IMAGE_PATH'/>
<target dev='vda' bus='virtio'/>
</disk>'''
-
+
xml_ctrl_br = '''
<interface type='bridge'>
<mac address='CTRL_MAC'/>
@@ -63,7 +63,7 @@ xml_br = '''
<model type='virtio'/>
<target dev='TAP_NAME'/>
</interface>'''
-
+
xml_pci = '''
<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='kvm'/>
@@ -82,4 +82,3 @@ xml_tail = '''
</graphics>
</devices>
</domain>'''
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/builder.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/builder.py
index a66a8873..19bf12f2 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/builder.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/builder.py
@@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__)
class PluginManager(object):
+
def __init__(self):
self.instance = None
self.saved = {}
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/__init__.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/__init__.py
index fc9802be..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/__init__.py
@@ -5,4 +5,4 @@
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
-############################################################################## \ No newline at end of file
+##############################################################################
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/manager.py
index 6f895656..e20b5dd5 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/manager.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/manager.py
@@ -11,9 +11,11 @@ import stevedore
class DriverPluginManager(object):
+
def __init__(self):
self.plugins = {}
- self.mgr = stevedore.extension.ExtensionManager(namespace="drivers.plugins", invoke_on_load=True)
+ self.mgr = stevedore.extension.ExtensionManager(
+ namespace="drivers.plugins", invoke_on_load=True)
def load(self, drivers):
plugin = self.determine_driver_type(drivers)
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/model.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/model.py
index ddc07449..807143f0 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/model.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/model.py
@@ -22,16 +22,16 @@ class DriverPlugin:
@abstractmethod
def clean(self):
"""implement this clean function to clean environment before and after calling any other functions.
-
+
"""
pass
@abstractmethod
def load(self, drivers):
"""load driver modules.
-
+
:param list drivers:list of modules to be inserted. for example:[ixgbe,vhost_net]
-
+
"""
pass
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/origin_driver.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/origin_driver.py
index bf3c15c8..2004b8e8 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/origin_driver.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/driver_plugins/origin_driver.py
@@ -24,7 +24,7 @@ class OriginDriverPlugin(model.DriverPlugin):
def clean(self):
"""clean drivers list in self.origin_drivers.
-
+
"""
for mod in self.origin_drivers:
check_and_rmmod(mod)
@@ -34,7 +34,7 @@ class OriginDriverPlugin(model.DriverPlugin):
def load(self, drivers):
"""insmod drivers
-
+
:param list drivers:list of drivers link ['ixgbe','vhost_net']
"""
# load implicit 'tun' module dependency for vhost_net
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/FSMonitor.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/FSMonitor.py
index e6559362..53cddebb 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/FSMonitor.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/FSMonitor.py
@@ -23,6 +23,7 @@ LOG = logging.getLogger('__name__')
class VMOperation(object):
+
def __init__(self):
self.RTE_SDK = '/home/dpdk-2.0.0'
self.RTE_TARGET = 'x86_64-native-linuxapp-gcc'
@@ -46,7 +47,8 @@ class VMOperation(object):
for mac in tap_macs:
bdf = self.ip_helper.mac_bdf_map[mac]
bdf_str = bdf_str + ' ' + bdf
- cmd = 'python %s/tools/dpdk_nic_bind.py --bind=virtio-pci %s' % (self.RTE_SDK, bdf_str)
+ cmd = 'python %s/tools/dpdk_nic_bind.py --bind=virtio-pci %s' % (
+ self.RTE_SDK, bdf_str)
LOG.debug("recover_nic_binding runs cmd = %s", cmd)
check_call(cmd, shell=True)
@@ -60,15 +62,22 @@ class VMOperation(object):
check_call("mount -t hugetlbfs nodev /mnt/huge", shell=True)
check_call("modprobe uio", shell=True)
check_and_rmmod('igb_uio')
- check_call("insmod %s/%s/kmod/igb_uio.ko" % (RTE_SDK, RTE_TARGET), shell=True)
+ check_call(
+ "insmod %s/%s/kmod/igb_uio.ko" %
+ (RTE_SDK, RTE_TARGET), shell=True)
bdf_str = ''
for mac in tap_macs:
bdf = self.ip_helper.mac_bdf_map[mac]
bdf_str = bdf_str + ' ' + bdf
- check_call('python %s/tools/dpdk_nic_bind.py --bind=igb_uio %s' % (RTE_SDK, bdf_str), shell=True)
- cpu_num = int(check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True))
+ check_call(
+ 'python %s/tools/dpdk_nic_bind.py --bind=igb_uio %s' %
+ (RTE_SDK, bdf_str), shell=True)
+ cpu_num = int(
+ check_output(
+ 'cat /proc/cpuinfo | grep processor | wc -l',
+ shell=True))
cpu_bit_mask = 0
i = cpu_num
while i:
@@ -76,14 +85,7 @@ class VMOperation(object):
i -= 1
cpu_bit_mask = hex(cpu_bit_mask)
cmd = "%s/%s/app/testpmd -c %s -n %d -- --disable-hw-vlan --disable-rss --nb-cores=%d --rxq=%d --txq=%d --rxd=4096 --txd=4096" % (
- RTE_SDK,
- RTE_TARGET,
- cpu_bit_mask,
- cpu_num / 2,
- cpu_num - 1,
- (cpu_num - 1) / 2,
- (cpu_num - 1) / 2
- )
+ RTE_SDK, RTE_TARGET, cpu_bit_mask, cpu_num / 2, cpu_num - 1, (cpu_num - 1) / 2, (cpu_num - 1) / 2)
LOG.info("set_pktloop_dpdk runs cmd = %s", cmd)
p = subprocess.Popen(cmd.split())
if not p.poll():
@@ -105,6 +107,7 @@ class VMOperation(object):
class FSMonitor(object):
+
def __init__(self, pidfile=None, interval=1):
if pidfile:
self.pidfile = pidfile
@@ -121,8 +124,9 @@ class FSMonitor(object):
pass
def kill_old(self):
- out = check_output("ps -ef | grep -v grep | egrep 'python.*%s' | awk '{print $2}'" % sys.argv[0],
- shell=True)
+ out = check_output(
+ "ps -ef | grep -v grep | egrep 'python.*%s' | awk '{print $2}'" %
+ sys.argv[0], shell=True)
if out:
for pid in out.split():
if int(pid) != os.getpid():
@@ -131,7 +135,8 @@ class FSMonitor(object):
def set_fail(self, failed_reason):
with open(constant.VM_CMD_RETURN_CODE_FILE, 'w') as f:
- f.writelines([constant.VM_CMD_EXCUTE_FAILED_FLAG_CONTENT, '\n', failed_reason])
+ f.writelines(
+ [constant.VM_CMD_EXCUTE_FAILED_FLAG_CONTENT, '\n', failed_reason])
with open(constant.VM_CMD_DONE_FLAG_FILE, 'w') as f:
pass
@@ -149,8 +154,10 @@ class FSMonitor(object):
pid = os.fork()
if pid > 0:
sys.exit(0)
- except OSError, e:
- sys.stderr.write('fork #1 failed:%d,(%s)\n' % (e.errno, e.strerror))
+ except OSError as e:
+ sys.stderr.write(
+ 'fork #1 failed:%d,(%s)\n' %
+ (e.errno, e.strerror))
sys.exit(1)
os.setsid()
os.umask(0)
@@ -158,10 +165,17 @@ class FSMonitor(object):
pid = os.fork()
if pid > 0:
sys.exit(0)
- except OSError, e:
- sys.stderr.write('fork #2 failed:%d,(%s)\n' % (e.errno, e.strerror))
+ except OSError as e:
+ sys.stderr.write(
+ 'fork #2 failed:%d,(%s)\n' %
+ (e.errno, e.strerror))
sys.exit(1)
- LOG.debug("pid:%d,ppid:%d,sid:%d", os.getpid(), os.getppid(), os.getsid(os.getpid()))
+ LOG.debug(
+ "pid:%d,ppid:%d,sid:%d",
+ os.getpid(),
+ os.getppid(),
+ os.getsid(
+ os.getpid()))
old = open('/dev/null', 'r')
os.dup2(old.fileno(), sys.stdin.fileno())
old = open('/dev/null', 'a+')
@@ -192,8 +206,9 @@ class FSMonitor(object):
method(*param)
self.set_success()
LOG.debug("cmd sucessfully done")
- except Exception, e:
- LOG.debug('failed to run:%s %s,reason:%s', cmd, param, str(e))
+ except Exception as e:
+ LOG.debug(
+ 'failed to run:%s %s,reason:%s', cmd, param, str(e))
self.set_fail(str(e))
break
else:
@@ -209,7 +224,8 @@ if __name__ == '__main__':
# echo "config_ip 56:6f:44:a5:3f:a2 192.168.188.200/23" > command;touch command_set
# echo "config_gw 192.168.188.1" > command;touch command_set
# echo set_pktloop_dpdk 56:6f:44:a5:3f:a2 56:6f:44:a5:3f:a3 > command;touch command_set
- # echo recover_nic_binding 56:6f:44:a5:3f:a2 56:6f:44:a5:3f:a3 > command;touch command_set
+ # echo recover_nic_binding 56:6f:44:a5:3f:a2 56:6f:44:a5:3f:a3 >
+ # command;touch command_set
import os
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILE, filemode='w')
os.environ['PATH'] = os.environ["PATH"] + ":/usr/local/bin"
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/constant.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/constant.py
index 33b37eb4..3ae80a39 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/constant.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/constant.py
@@ -18,4 +18,4 @@ VM_CMD_EXCUTE_FAILED_FLAG_CONTENT = 'fail'
VM_CMD_NOT_FOUND = 'comamnd_not_found'
VM_UP_TIME_OUT = 120
VM_COMMON_CMD_EXCUTE_TIME_OUT = 10
-FS_MOUNT_POINT = '/mnt/9pfs' \ No newline at end of file
+FS_MOUNT_POINT = '/mnt/9pfs'
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/utils.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/utils.py
index 5bdb4159..c28b6ec6 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/utils.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor/utils.py
@@ -70,6 +70,7 @@ def umount(path):
class IPCommandHelper(object):
+
def __init__(self):
self.devices = []
self.macs = []
@@ -80,7 +81,9 @@ class IPCommandHelper(object):
self.mac_bdf_map = {}
self.bdf_mac_map = {}
buf = check_output("ip link", shell=True)
- macs = re.compile("[A-F0-9]{2}(?::[A-F0-9]{2}){5}", re.IGNORECASE | re.MULTILINE)
+ macs = re.compile(
+ "[A-F0-9]{2}(?::[A-F0-9]{2}){5}",
+ re.IGNORECASE | re.MULTILINE)
for mac in macs.findall(buf):
if mac.lower() in ('00:00:00:00:00:00', 'ff:ff:ff:ff:ff:ff'):
continue
@@ -95,7 +98,10 @@ class IPCommandHelper(object):
self.mac_device_map[mac] = device
for device in self.devices:
buf = check_output("ethtool -i %s" % device, shell=True)
- bdfs = re.findall(r'^bus-info: \d{4}:(\d{2}:\d{2}\.\d*)$', buf, re.MULTILINE)
+ bdfs = re.findall(
+ r'^bus-info: \d{4}:(\d{2}:\d{2}\.\d*)$',
+ buf,
+ re.MULTILINE)
if bdfs:
self.bdf_device_map[bdfs[0]] = device
self.device_bdf_map[device] = bdfs[0]
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/libvirt_plugin.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/libvirt_plugin.py
index 27af8063..2fd7d69a 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/libvirt_plugin.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/libvirt_plugin.py
@@ -20,6 +20,7 @@ LOG = logging.getLogger(__name__)
class Plugin(EnvBuilderPlugin):
+
def __init__(self):
super(Plugin, self).__init__()
self.vm_mgr = VMControlOperation()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/tester_env_plugin.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/tester_env_plugin.py
index 0682aac8..0c994d4e 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/tester_env_plugin.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/plugins/tester_env_plugin.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class Plugin(EnvBuilderPlugin):
+
def __init__(self):
super(Plugin, self).__init__()
self.dr_mgr = DriverPluginManager()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/bridge_plugin.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/bridge_plugin.py
index 21b8f82c..fb6a54ce 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/bridge_plugin.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/bridge_plugin.py
@@ -12,6 +12,7 @@ from vstf.common.utils import check_call, get_eth_by_bdf, check_output
class BridgePlugin(model.VswitchPlugin):
+
def __init__(self):
pass
@@ -19,7 +20,9 @@ class BridgePlugin(model.VswitchPlugin):
"""clean brs created before.
"""
- out = check_output(r"brctl show | grep -v '^\s' | awk '{print $1}'|sed '1,1d'", shell=True)
+ out = check_output(
+ r"brctl show | grep -v '^\s' | awk '{print $1}'|sed '1,1d'",
+ shell=True)
print out
for br in out.split():
if br != 'br0':
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/manager.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/manager.py
index 785a1db8..4890ee11 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/manager.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/manager.py
@@ -11,9 +11,11 @@ import stevedore
class VswitchPluginManager(object):
+
def __init__(self):
self.plugin = None
- self.mgr = stevedore.extension.ExtensionManager(namespace="vswitch.plugins", invoke_on_load=True)
+ self.mgr = stevedore.extension.ExtensionManager(
+ namespace="vswitch.plugins", invoke_on_load=True)
def clean(self):
if self.plugin:
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/model.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/model.py
index 5d700411..8a80e44e 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/model.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/model.py
@@ -64,4 +64,4 @@ class VswitchPlugin:
pass
def set_fastlink(self, br_cfg):
- return True \ No newline at end of file
+ return True
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/ovs_plugin.py b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/ovs_plugin.py
index 7ea56d4a..66943c1c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/ovs_plugin.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/env/vswitch_plugins/ovs_plugin.py
@@ -28,7 +28,8 @@ class OvsPlugin(model.VswitchPlugin):
self.dirs = {'db': "/usr/local/etc/openvswitch"}
self.cmds = []
self.cmds.append("mkdir -p /usr/local/etc/openvswitch")
- self.cmds.append("ovsdb-tool create /usr/local/etc/openvswitch/conf.db")
+ self.cmds.append(
+ "ovsdb-tool create /usr/local/etc/openvswitch/conf.db")
self.cmds.append("ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--private-key=db:Open_vSwitch,SSL,private_key \
@@ -81,8 +82,9 @@ class OvsPlugin(model.VswitchPlugin):
name, uplinks = br_cfg['name'], br_cfg['uplinks']
check_call("ovs-vsctl add-br %s" % (name), shell=True)
- if br_cfg['vtep']: # vxlan supports
- local_ip, remote_ip = br_cfg['vtep']['local_ip'], br_cfg['vtep']['remote_ip']
+ if br_cfg['vtep']: # vxlan supports
+ local_ip, remote_ip = br_cfg['vtep'][
+ 'local_ip'], br_cfg['vtep']['remote_ip']
assert len(uplinks) == 1
uplink = uplinks[0]
device = get_eth_by_bdf(uplink['bdf'])
@@ -90,7 +92,9 @@ class OvsPlugin(model.VswitchPlugin):
vtep = 'vx1'
check_call("ifconfig %s %s up" % (device, local_ip), shell=True)
check_call("ovs-vsctl add-port %s %s" % (name, vtep), shell=True)
- check_call("ovs-vsctl set interface %s type=vxlan options:remote_ip=%s" % (vtep, remote_ip), shell=True)
+ check_call(
+ "ovs-vsctl set interface %s type=vxlan options:remote_ip=%s" %
+ (vtep, remote_ip), shell=True)
for uplink in uplinks:
device = get_eth_by_bdf(uplink['bdf'])
vlan_mode = uplink['vlan_mode']
@@ -99,9 +103,13 @@ class OvsPlugin(model.VswitchPlugin):
call("ethtool -A %s rx off tx off " % device, shell=True)
check_call("ovs-vsctl add-port %s %s" % (name, device), shell=True)
if vlan_mode == 'trunk':
- check_call("ovs-vsctl set port %s trunks=%s" % (device, vlan_id), shell=True)
+ check_call(
+ "ovs-vsctl set port %s trunks=%s" %
+ (device, vlan_id), shell=True)
elif vlan_mode == 'access':
- check_call("ovs-vsctl set port %s tag=%s" % (device, vlan_id), shell=True)
+ check_call(
+ "ovs-vsctl set port %s tag=%s" %
+ (device, vlan_id), shell=True)
else:
raise Exception("unreconized vlan_mode:%s" % vlan_mode)
return True
@@ -118,7 +126,8 @@ class OvsPlugin(model.VswitchPlugin):
}
"""
- port, vlan_mode, vlan = tap_cfg['tap_name'], tap_cfg['vlan_mode'], tap_cfg['vlan_id']
+ port, vlan_mode, vlan = tap_cfg['tap_name'], tap_cfg[
+ 'vlan_mode'], tap_cfg['vlan_id']
assert vlan_mode in ('access', 'vxlan')
if int(vlan) > '4095':
# vxlan setting
@@ -162,15 +171,21 @@ class OvsPlugin(model.VswitchPlugin):
if vlan_mode == 'vxlan':
raise Exception("don't support vxlan setting right now.")
elif vlan_mode == 'trunk':
- check_call("ovs-vsctl set port %s trunks=%s" % (port, vlan_id), shell=True)
+ check_call(
+ "ovs-vsctl set port %s trunks=%s" %
+ (port, vlan_id), shell=True)
else:
- check_call("ovs-vsctl set port %s tag=%s" % (port, vlan_id), shell=True)
+ check_call(
+ "ovs-vsctl set port %s tag=%s" %
+ (port, vlan_id), shell=True)
def __fastlink(self, br, p1, p2):
LOG.info("_fastlink(%s,%s,%s)", br, p1, p2)
p1 = p1.replace(' ', '')
p2 = p2.replace(' ', '')
- bdfs = check_output("lspci |grep Eth | awk '{print $1}'", shell=True).splitlines()
+ bdfs = check_output(
+ "lspci |grep Eth | awk '{print $1}'",
+ shell=True).splitlines()
if p1 in bdfs:
p1 = get_eth_by_bdf(p1)
if p2 in bdfs:
@@ -182,6 +197,10 @@ class OvsPlugin(model.VswitchPlugin):
port_num, interface = s.replace('(', ' ').replace(')', ' ').split()
ovs_port[interface] = port_num
pn1, pn2 = ovs_port[p1], ovs_port[p2]
- check_call("ovs-ofctl add-flow %s in_port=%s,priority=100,action=output:%s" % (br, pn1, pn2), shell=True)
- check_call("ovs-ofctl add-flow %s in_port=%s,priority=100,action=output:%s" % (br, pn2, pn1), shell=True)
+ check_call(
+ "ovs-ofctl add-flow %s in_port=%s,priority=100,action=output:%s" %
+ (br, pn1, pn2), shell=True)
+ check_call(
+ "ovs-ofctl add-flow %s in_port=%s,priority=100,action=output:%s" %
+ (br, pn2, pn1), shell=True)
return True