summaryrefslogtreecommitdiffstats
path: root/testsuites/vstf/vstf_scripts/vstf/agent
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/agent')
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/agent.py24
-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
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/equalizer/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/equalizer/equalizer.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/equalizer/get_info.py19
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/equalizer/optimize.py13
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py1
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py16
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py16
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py16
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py15
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py16
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py10
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py4
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py5
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py6
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/softagent.py14
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/spirent/spirent.py267
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/spirent/tools.py424
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/agent/spirentagent.py1
45 files changed, 775 insertions, 429 deletions
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/agent.py b/testsuites/vstf/vstf_scripts/vstf/agent/agent.py
index b5745995..4d92c510 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/agent.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/agent.py
@@ -40,17 +40,17 @@ stc_opts = [
class Client(daemon.Daemon):
"""This is a consumer of vstf-agent which will create two channel to the
rabbitmq-server, one for direct call, one for fan call.
-
+
agent start with a config file which record rabbitmq's ip, port and user passwd
also each agent has its own id.
-
+
"""
def __init__(self, agent, config_file):
"""Record the config file, init the daemon.
-
+
:param str config_file: the config of a VSTF agent.
-
+
"""
super(Client, self).__init__('/tmp/esp_rpc_client.pid')
self.config_file = config_file
@@ -61,7 +61,7 @@ class Client(daemon.Daemon):
def init_config(self):
"""Use olso.config to analyse the config file
-
+
"""
parser = CfgParser(self.config_file)
parser.register_my_opts(server_opts, "rabbit")
@@ -80,7 +80,7 @@ class Client(daemon.Daemon):
def run(self):
"""Run the rabbitmq consumers as a daemon.
-
+
"""
signal.signal(signal.SIGTERM, self.process_exit)
self.loop_thread()
@@ -90,7 +90,7 @@ class Client(daemon.Daemon):
"""This function try to stop the agent after running agent stop.
When we call vstf-agent stop which will send a signal SIGTERM to agent
When the agent catch the SIGTERM signal will call this function.
-
+
"""
LOG.info("daemon catch the signalterm, start to stop the process.")
self.run_flag = False
@@ -104,7 +104,7 @@ class Client(daemon.Daemon):
def stop_agent(self):
"""Notice that: this function just kill the agent by pid file, it has
none vars of the agent.
-
+
"""
LOG.info("call daemon stop.")
# kill the main thread
@@ -120,9 +120,11 @@ def main():
default="soft",
choices=["soft", "spirent"],
help="the agent type, as now, just soft and spirent")
- parser.add_argument('--config_file', action='store',
- default="/etc/vstf/amqp/amqp.ini",
- help="some env_build params recorded in the config file")
+ parser.add_argument(
+ '--config_file',
+ action='store',
+ default="/etc/vstf/amqp/amqp.ini",
+ help="some env_build params recorded in the config file")
args = parser.parse_args()
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
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/__init__.py b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/__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/equalizer/equalizer.py b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/equalizer.py
index 30e1de1f..2fd20db1 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/equalizer.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/equalizer.py
@@ -24,6 +24,7 @@ def run_cmd(cmd, shell=True):
class Resource(object):
+
def __init__(self):
super(Resource, self).__init__()
self.sysfs = "/sys/devices/system/node"
@@ -35,16 +36,18 @@ class Resource(object):
for process_index in xrange(0, len(bin(process_mapping)) - 2):
if process_mapping & 1 << process_index != 0:
core = self._get_core_id(node, process_index)
- if not self.mapping[node].has_key(core):
+ if core not in self.mapping[node]:
self.mapping[node][core] = []
self.mapping[node][core].append(process_index)
def _get_process_mapping(self, numa_node):
- ret = run_cmd("cat " + self.sysfs + '/' + numa_node + '/cpumap').replace(',', '').lstrip('0')
+ ret = run_cmd("cat " + self.sysfs + '/' + numa_node +
+ '/cpumap').replace(',', '').lstrip('0')
return int(ret, 16)
def _get_core_id(self, numa_node, process_index):
- cmd = "cat " + self.sysfs + '/' + numa_node + '/cpu' + str(process_index) + '/topology/core_id'
+ cmd = "cat " + self.sysfs + '/' + numa_node + \
+ '/cpu' + str(process_index) + '/topology/core_id'
return run_cmd(cmd).strip('\n')
def _init_numa(self):
@@ -63,6 +66,7 @@ class Resource(object):
class Equalizer(Resource):
+
def __init__(self):
super(Equalizer, self).__init__()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/get_info.py b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/get_info.py
index 0c92f979..8a01dfc6 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/get_info.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/get_info.py
@@ -16,6 +16,7 @@ except ImportError:
class GetPhyInfo(object):
+
def __init__(self):
pass
@@ -46,7 +47,9 @@ class GetPhyInfo(object):
numa = {}
num = self._get_numa_num()
for numa_id in range(0, int(num)):
- flag, temp = commands.getstatusoutput('lscpu | grep "NUMA node%s"' % (str(numa_id)))
+ flag, temp = commands.getstatusoutput(
+ 'lscpu | grep "NUMA node%s"' %
+ (str(numa_id)))
try:
temp = temp.split(':')[1].split()[0]
except:
@@ -58,7 +61,9 @@ class GetPhyInfo(object):
def get_nic_numa(self, nic):
result = {}
try:
- flag, id = commands.getstatusoutput('cat /sys/class/net/%s/device/numa_node' % (nic))
+ flag, id = commands.getstatusoutput(
+ 'cat /sys/class/net/%s/device/numa_node' %
+ (nic))
except:
print('get nic numa id failed.')
return id
@@ -102,7 +107,9 @@ class GetPhyInfo(object):
# get vhost info
proc_name = 'vhost-' + _main_pid
- flag, temp = commands.getstatusoutput('ps -ef | grep %s | grep -v grep' % (proc_name))
+ flag, temp = commands.getstatusoutput(
+ 'ps -ef | grep %s | grep -v grep' %
+ (proc_name))
for line in temp.split('\n'):
try:
vhost = line.split()[1]
@@ -134,7 +141,8 @@ class GetPhyInfo(object):
def _get_proc_by_irq(self, irq):
try:
- flag, info = commands.getstatusoutput('ps -ef | grep irq/%s | grep -v grep ' % (irq))
+ flag, info = commands.getstatusoutput(
+ 'ps -ef | grep irq/%s | grep -v grep ' % (irq))
proc_id = info.split('\n')[0].split()[1]
except:
print("[ERROR]grep process id failed.")
@@ -142,7 +150,8 @@ class GetPhyInfo(object):
def get_nic_interrupt_proc(self, nic):
_phy_nic_thread = []
- flag, info = commands.getstatusoutput('cat /proc/interrupts | grep %s' % (nic))
+ flag, info = commands.getstatusoutput(
+ 'cat /proc/interrupts | grep %s' % (nic))
for line in info.split('\n'):
try:
irq_num = line.split(':')[0].split()[0]
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/optimize.py b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/optimize.py
index 5a09900d..4579c506 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/optimize.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/equalizer/optimize.py
@@ -15,17 +15,24 @@ import re
# pdb.set_trace()
class Optimize(object):
+
def __init__(self):
pass
def bind_cpu(self, cpu_range, thread):
- flag, num = commands.getstatusoutput('taskset -pc %s %s' % (cpu_range, thread))
+ flag, num = commands.getstatusoutput(
+ 'taskset -pc %s %s' %
+ (cpu_range, thread))
return flag
def catch_thread_info(self):
- thread_info = {'fwd_vhost': None, 'src_recv_irq': None, 'dst_send_irq': None}
+ thread_info = {
+ 'fwd_vhost': None,
+ 'src_recv_irq': None,
+ 'dst_send_irq': None}
# top -H get the usage info
- flag, threads_usages = commands.getstatusoutput('top -bH -n1 -c -w 2000')
+ flag, threads_usages = commands.getstatusoutput(
+ 'top -bH -n1 -c -w 2000')
line_array = threads_usages.split('\n')
# get highest vhost line
for line in line_array:
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py
index df7d24d0..83b8d15d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/__init__.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/__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/perf/affctl.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py
index 5b203632..316cbab8 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/affctl.py
@@ -18,4 +18,3 @@ def affctl_load(policy):
def affctl_list():
cmd = "affctl list"
return check_output(cmd, shell=True)
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py
index 3105be4b..8eca165c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/iperf.py
@@ -21,6 +21,7 @@ LOG = logging.getLogger(__name__)
class Iperf(object):
+
def __init__(self):
self._send_processes = []
self._receive_processes = []
@@ -40,7 +41,10 @@ class Iperf(object):
cmd = self.format_send_start(**kwargs)
LOG.debug("cmd:%s", cmd)
- process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = subprocess.Popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(1)
ret = process.poll()
if ret is None:
@@ -90,7 +94,10 @@ class Iperf(object):
cmd = self.format_receive_start(**kwargs)
LOG.debug("cmd:%s", cmd)
- process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = subprocess.Popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(1)
ret = process.poll()
if ret is None:
@@ -151,5 +158,8 @@ def unit_test():
if __name__ == "__main__":
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf-iperf.log", clevel=logging.DEBUG)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf-iperf.log",
+ clevel=logging.DEBUG)
unit_test()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py
index 88a25444..bd9cc97f 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netmap.py
@@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__)
class Netmap(object):
+
def __init__(self):
self._send_processes = []
self._receive_processes = []
@@ -33,7 +34,10 @@ class Netmap(object):
cmd = self.format_send_start(**kwargs)
LOG.info("cmd:%s", cmd)
- process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
self._send_processes.append(process)
time.sleep(0.5)
@@ -89,7 +93,10 @@ class Netmap(object):
cmd = self.format_receive_start(**kwargs)
LOG.info("cmd:%s", cmd)
- process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
self._receive_processes.append(process)
time.sleep(0.5)
@@ -164,5 +171,8 @@ def unit_test():
if __name__ == "__main__":
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-netmap.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-netmap.log",
+ clevel=logging.INFO)
unit_test()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py
index c3b73860..9aaaf58f 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netns.py
@@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__)
class Netns(object):
+
def __init__(self):
super(Netns, self).__init__()
self.netns_add_str = "ip netns add %s"
@@ -74,13 +75,14 @@ class Netns(object):
class NetnsManager(object):
+
def __init__(self):
super(NetnsManager, self).__init__()
self._netns = Netns()
def config_dev(self, netdev):
- ns, device, ip = netdev["namespace"], netdev["iface"], netdev['ip_setting'] if "ip_setting" in netdev else \
- netdev['ip']
+ ns, device, ip = netdev["namespace"], netdev["iface"], netdev[
+ 'ip_setting'] if "ip_setting" in netdev else netdev['ip']
self._netns.create_namespace(ns)
self._netns.add_device(ns, device)
self._netns.config_ip(ns, device, ip)
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py
index 99f1c904..dac7d649 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/netperf.py
@@ -20,6 +20,7 @@ LOG = logging.getLogger(__name__)
class Netperf(object):
+
def __init__(self):
self._send_processes = []
self._islat = False
@@ -48,7 +49,10 @@ class Netperf(object):
LOG.info("cmd:%s", cmd)
for _ in range(threads):
- process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
self._send_processes.append(process)
time.sleep(0.5)
for process in self._send_processes:
@@ -119,7 +123,10 @@ class Netperf(object):
cmd = self.format_receive_start(**kwargs)
LOG.info("cmd:%s", cmd)
- process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(0.5)
ret = process.poll()
if ret:
@@ -177,5 +184,8 @@ def unit_test():
if __name__ == "__main__":
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-netperf.log", clevel=logging.DEBUG)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-netperf.log",
+ clevel=logging.DEBUG)
unit_test()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py
index 671e1aa7..9aff0a0c 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/pktgen.py
@@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__)
class Pktgen(object):
+
def __init__(self):
utils.modprobe_pktgen()
self._send_processes = []
@@ -33,7 +34,11 @@ class Pktgen(object):
def _start(self):
cmd = 'echo start > /proc/net/pktgen/pgctrl'
- process = my_popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd,
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
LOG.info('running pid:%s', process.pid)
time.sleep(0.5)
ret = process.poll()
@@ -42,7 +47,8 @@ class Pktgen(object):
self._send_processes.append(process)
error_str = "start pktgen send success"
else:
- error_str = "start pktgen send failed, stdout:%s,stderr:%s" % (process.stdout.read(), process.stderr.read())
+ error_str = "start pktgen send failed, stdout:%s,stderr:%s" % (
+ process.stdout.read(), process.stderr.read())
LOG.info(error_str)
return ret, error_str
@@ -149,5 +155,8 @@ def unit_test():
if __name__ == "__main__":
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-pktgen.log", clevel=logging.DEBUG)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-pktgen.log",
+ clevel=logging.DEBUG)
unit_test()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py
index afdf44d7..25272d89 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/qperf.py
@@ -18,6 +18,7 @@ LOG = logging.getLogger(__name__)
class Qperf(object):
+
def __init__(self):
self._send_processes = []
self._receive_processes = []
@@ -30,7 +31,10 @@ class Qperf(object):
def send_start(self, **kwargs):
cmd = self.format_send_start(**kwargs)
LOG.info("cmd:%s", cmd)
- process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(0.5)
ret = process.poll()
if ret is None:
@@ -76,7 +80,10 @@ class Qperf(object):
cmd = self.format_receive_start(**kwargs)
LOG.info("cmd:%s", cmd)
- process = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(0.5)
ret = process.poll()
if ret is None:
@@ -163,5 +170,8 @@ def unit_test():
if __name__ == "__main__":
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-qperf.log", clevel=logging.DEBUG)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-qperf.log",
+ clevel=logging.DEBUG)
unit_test()
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py
index 0231d5c1..72d0082d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/sar.py
@@ -20,13 +20,17 @@ LOG = logging.getLogger(__name__)
class Sar(object):
+
def __init__(self):
self.sar_cmd_str = "sar -u %(interval)s"
self.child_process = {}
def start(self, interval=2):
cmd = self.sar_cmd_str % {'interval': interval}
- child = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ child = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(1)
if child.poll() is not None:
print child.poll()
@@ -55,7 +59,9 @@ class Sar(object):
data = {}
for h, d in zip(head, average):
data[h.strip('%')] = float(d)
- cpu_num = check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True).strip()
+ cpu_num = check_output(
+ 'cat /proc/cpuinfo | grep processor | wc -l',
+ shell=True).strip()
data.update({'cpu_num': int(cpu_num)})
return data
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py
index 4f7ddb6a..f9ca46cd 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/utils.py
@@ -26,7 +26,9 @@ def get_pid_by_name(process_name):
def get_cpu_num():
- cpu_num = check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True).strip()
+ cpu_num = check_output(
+ 'cat /proc/cpuinfo | grep processor | wc -l',
+ shell=True).strip()
cpu_num = int(cpu_num)
return cpu_num
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py
index b12ac1af..49e4f0c1 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vnstat.py
@@ -19,6 +19,7 @@ LOG = logging.getLogger(__name__)
class VnStat(object):
+
def __init__(self):
self.netns_exec_str = "ip netns exec %s "
self.vnstat_cmd_str = "vnstat -l -i %s"
@@ -63,7 +64,9 @@ class VnStat(object):
m = {}
digits = re.compile(r"\d+\.?\d*")
- units = re.compile("(?:gib|mib|kib|kbit/s|gbits/s|mbit/s|p/s)", re.IGNORECASE | re.MULTILINE)
+ units = re.compile(
+ "(?:gib|mib|kib|kbit/s|gbits/s|mbit/s|p/s)",
+ re.IGNORECASE | re.MULTILINE)
units_arr = units.findall(buf)
LOG.debug(units_arr)
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py
index 8be3c4e5..939b12ef 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/perf/vstfperf.py
@@ -40,6 +40,7 @@ LOG = logging.getLogger(__name__)
class Vstfperf(object):
+
def __init__(self):
for tool in cst.TOOLS:
obj_name = 'vstf_' + tool
@@ -75,7 +76,10 @@ class Vstfperf(object):
def unit_test():
from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-vstfperf.log", clevel=logging.INFO)
+ setup_logging(
+ level=logging.DEBUG,
+ log_file="/var/log/vstf/vstf-vstfperf.log",
+ clevel=logging.INFO)
perf = Vstfperf()
start = {
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/softagent.py b/testsuites/vstf/vstf_scripts/vstf/agent/softagent.py
index 6271a097..9ba1e126 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/softagent.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/softagent.py
@@ -25,6 +25,7 @@ LOG = logging.getLogger(__name__)
class ENV(object):
+
def __init__(self):
super(ENV, self).__init__()
self.builder = builder.PluginManager()
@@ -45,6 +46,7 @@ class ENV(object):
class Drivers(object):
+
def __init__(self):
super(Drivers, self).__init__()
self.dr_mgr = DriverPluginManager()
@@ -69,6 +71,7 @@ class Drivers(object):
class Cpu(object):
+
def affctl_load(self, policy):
return affctl.affctl_load(policy)
@@ -77,12 +80,13 @@ class Cpu(object):
class Perf(object):
+
def __init__(self):
super(Perf, self).__init__()
self._vnstat = vnstat.VnStat()
self._vstfperf = vstfperf.Vstfperf()
self._sar = sar.Sar()
-
+
def run_vnstat(self, device, namespace=None):
return self._vnstat.run_vnstat(device, namespace)
@@ -92,7 +96,7 @@ class Perf(object):
def perf_run(self, **kwargs):
return self._vstfperf.run(**kwargs)
- def run_cpuwatch(self, interval = 2):
+ def run_cpuwatch(self, interval=2):
return self._sar.start(interval)
def kill_cpuwatch(self, pid):
@@ -106,6 +110,7 @@ class Perf(object):
class EqualizerOps(GetPhyInfo, Optimize):
+
def __init__(self):
super(EqualizerOps, self).__init__()
@@ -115,19 +120,20 @@ class BaseAgent(coll.Collect,
Cpu,
Drivers,
DeviceManager,
- commandline.CommandLine,
+ commandline.CommandLine,
netns.NetnsManager,
SourceCodeManager
):
+
def __init__(self):
super(BaseAgent, self).__init__()
class softAgent(BaseAgent, Perf, EqualizerOps):
+
def __init__(self):
super(softAgent, self).__init__()
if __name__ == '__main__':
softAgent()
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/spirent/spirent.py b/testsuites/vstf/vstf_scripts/vstf/agent/spirent/spirent.py
index 904de736..ff2af1f8 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/spirent/spirent.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/spirent/spirent.py
@@ -14,23 +14,26 @@ import Tkinter
def build_cmd(*args):
cmd = ''
for arg in args:
- cmd = cmd+str(arg)+' '
+ cmd = cmd + str(arg) + ' '
#import pdb
- #pdb.set_trace()
+ # pdb.set_trace()
return cmd
class stcPython():
+
def __init__(self):
self.tclsh = Tkinter.Tcl()
self.stcpkg = '/home/Spirent_TestCenter_4.46/Spirent_TestCenter_Application_Linux'
- self.tclsh.eval("set auto_path [ linsert $auto_path 0 %s ]" %(self.stcpkg))
+ self.tclsh.eval(
+ "set auto_path [ linsert $auto_path 0 %s ]" %
+ (self.stcpkg))
self.tclsh.eval("package require SpirentTestCenter")
def build_cmd(self, *args):
cmd = ''
for arg in args:
- cmd = cmd+str(arg)+' '
+ cmd = cmd + str(arg) + ' '
return cmd
# [ stc base interface ]
@@ -38,206 +41,294 @@ class stcPython():
cmd = build_cmd('stc::init', *args)
return self.tclsh.eval(cmd)
# stc connect
- def stc_connect(self,*args):
+
+ def stc_connect(self, *args):
cmd = build_cmd('stc::connect', *args)
return self.tclsh.eval(cmd)
# stc disconnect
- def stc_disconnect(self,*args):
+
+ def stc_disconnect(self, *args):
cmd = build_cmd('stc::disconnect', *args)
return self.tclsh.eval(cmd)
# stc create
- def stc_create(self,*args):
+
+ def stc_create(self, *args):
cmd = build_cmd('stc::create', *args)
return self.tclsh.eval(cmd)
# stc delete
- def stc_delete(self,*args):
+
+ def stc_delete(self, *args):
cmd = build_cmd('stc::delete', *args)
return self.tclsh.eval(cmd)
# stc config
- def stc_config(self,*args):
+
+ def stc_config(self, *args):
cmd = build_cmd('stc::config', *args)
return self.tclsh.eval(cmd)
# stc get
- def stc_get(self,*args):
+
+ def stc_get(self, *args):
cmd = build_cmd('stc::get', *args)
return self.tclsh.eval(cmd)
# stc apply
- def stc_apply(self,*args):
+
+ def stc_apply(self, *args):
cmd = build_cmd('stc::apply', *args)
return self.tclsh.eval(cmd)
# stc perform
- def stc_perform(self,*args):
+
+ def stc_perform(self, *args):
cmd = build_cmd('stc::perform', *args)
return self.tclsh.eval(cmd)
# stc reserve
- def stc_reserve(self,*args):
+
+ def stc_reserve(self, *args):
cmd = build_cmd('stc::reserve', *args)
return self.tclsh.eval(cmd)
# stc release
- def stc_release(self,*args):
+
+ def stc_release(self, *args):
cmd = build_cmd('stc::release', *args)
return self.tclsh.eval(cmd)
# stc subscribe
- def stc_subscribe(self,*args):
- cmd = build_cmd('stc::subscribe',*args)
+
+ def stc_subscribe(self, *args):
+ cmd = build_cmd('stc::subscribe', *args)
return self.tclsh.eval(cmd)
# stc unsubscribe
- def stc_unsubscribe(self,*args):
+
+ def stc_unsubscribe(self, *args):
cmd = build_cmd('stc::unsubscribe', *args)
return self.tclsh.eval(cmd)
# stc wait until sequencer complete
- def stc_waituntilcomplete(self,*args):
+
+ def stc_waituntilcomplete(self, *args):
cmd = build_cmd('stc::waituntilcomplete', *args)
return self.tclsh.eval(cmd)
# stc help
+
def stc_help(self, *args):
- cmd = build_cmd('stc::help',*args)
+ cmd = build_cmd('stc::help', *args)
return self.tclsh.eval(cmd)
# [ stc expand interface ]
# get one dict-key's value
# return value
- def stc_get_value(self,stc_dict,stc_key):
- cmd = stc_dict+' -'+stc_key
+ def stc_get_value(self, stc_dict, stc_key):
+ cmd = stc_dict + ' -' + stc_key
return self.stc_get(cmd)
# create project
# return: project_name
+
def stc_create_project(self):
return self.stc_create('project')
# create port under project
# return: port name
- def stc_create_port(self,project_name):
- cmd = 'port -under '+project_name
+
+ def stc_create_port(self, project_name):
+ cmd = 'port -under ' + project_name
return self.stc_create(cmd)
# config port location
# return: None
- def stc_config_port_location(self,port_name,chassisAddress,slot,port):
+
+ def stc_config_port_location(self, port_name, chassisAddress, slot, port):
#import pdb
- #pdb.set_trace()
- cmd = port_name+' -location //'+chassisAddress+'/'+slot+'/'+port+' -UseDefaultHost False'
+ # pdb.set_trace()
+ cmd = port_name + ' -location //' + chassisAddress + \
+ '/' + slot + '/' + port + ' -UseDefaultHost False'
return self.stc_config(cmd)
# create streamblock under port
# return: streamblock name
- def stc_create_streamblock(self,port_name,vlan_tag,ExpectedRxPort,srcMac,dstMac,sourceAddr,destAddr):
+
+ def stc_create_streamblock(
+ self,
+ port_name,
+ vlan_tag,
+ ExpectedRxPort,
+ srcMac,
+ dstMac,
+ sourceAddr,
+ destAddr):
#import pdb
- #pdb.set_trace()
- if vlan_tag == None or vlan_tag == 'None':
+ # pdb.set_trace()
+ if vlan_tag is None or vlan_tag == 'None':
frameStruc = '"EthernetII IPv4 Udp"'
- if ExpectedRxPort == '' :
- return self.stc_create( 'streamBlock -under ',port_name,
- '-frameConfig ',frameStruc,
- '-frame "EthernetII.srcMac',srcMac,'EthernetII.dstMac',dstMac,
- 'IPv4.1.sourceAddr',sourceAddr,'IPv4.1.destAddr',destAddr,'"')
- else :
- return self.stc_create( 'streamBlock -under ',port_name,
- '-ExpectedRxPort',ExpectedRxPort,
- '-frameConfig ',frameStruc,
- '-frame "EthernetII.srcMac',srcMac,'EthernetII.dstMac',dstMac,
- 'IPv4.1.sourceAddr',sourceAddr,'IPv4.1.destAddr',destAddr,'"')
- else :
+ if ExpectedRxPort == '':
+ return self.stc_create(
+ 'streamBlock -under ',
+ port_name,
+ '-frameConfig ',
+ frameStruc,
+ '-frame "EthernetII.srcMac',
+ srcMac,
+ 'EthernetII.dstMac',
+ dstMac,
+ 'IPv4.1.sourceAddr',
+ sourceAddr,
+ 'IPv4.1.destAddr',
+ destAddr,
+ '"')
+ else:
+ return self.stc_create(
+ 'streamBlock -under ',
+ port_name,
+ '-ExpectedRxPort',
+ ExpectedRxPort,
+ '-frameConfig ',
+ frameStruc,
+ '-frame "EthernetII.srcMac',
+ srcMac,
+ 'EthernetII.dstMac',
+ dstMac,
+ 'IPv4.1.sourceAddr',
+ sourceAddr,
+ 'IPv4.1.destAddr',
+ destAddr,
+ '"')
+ else:
frameStruc = '"EthernetII Vlan IPv4 Udp"'
- if ExpectedRxPort == '' :
- return self.stc_create( 'streamBlock -under ',port_name,
- '-frameConfig '+frameStruc,
- '-frame "EthernetII.srcMac',srcMac,'EthernetII.dstMac',dstMac,
- 'Vlan.1.id',vlan_tag,
- 'IPv4.1.sourceAddr',sourceAddr,'IPv4.1.destAddr',destAddr,'"')
- else :
- return self.stc_create( 'streamBlock -under ',port_name,
- '-ExpectedRxPort',ExpectedRxPort,
- '-frameConfig '+frameStruc,
- '-frame "EthernetII.srcMac',srcMac,'EthernetII.dstMac',dstMac,
- 'Vlan.1.id',vlan_tag,
- 'IPv4.1.sourceAddr',sourceAddr,'IPv4.1.destAddr',destAddr,'"')
+ if ExpectedRxPort == '':
+ return self.stc_create(
+ 'streamBlock -under ',
+ port_name,
+ '-frameConfig ' +
+ frameStruc,
+ '-frame "EthernetII.srcMac',
+ srcMac,
+ 'EthernetII.dstMac',
+ dstMac,
+ 'Vlan.1.id',
+ vlan_tag,
+ 'IPv4.1.sourceAddr',
+ sourceAddr,
+ 'IPv4.1.destAddr',
+ destAddr,
+ '"')
+ else:
+ return self.stc_create(
+ 'streamBlock -under ',
+ port_name,
+ '-ExpectedRxPort',
+ ExpectedRxPort,
+ '-frameConfig ' +
+ frameStruc,
+ '-frame "EthernetII.srcMac',
+ srcMac,
+ 'EthernetII.dstMac',
+ dstMac,
+ 'Vlan.1.id',
+ vlan_tag,
+ 'IPv4.1.sourceAddr',
+ sourceAddr,
+ 'IPv4.1.destAddr',
+ destAddr,
+ '"')
# config streamblock with part arguments
# argument list use args dictionary
- def stc_config_streamblock(self,streamblock_name,args_dict):
+
+ def stc_config_streamblock(self, streamblock_name, args_dict):
cmd = ''
- for key in args_dict.keys() :
- temp_cmd = '-'+key+' '+str(args_dict[key])
+ for key in args_dict.keys():
+ temp_cmd = '-' + key + ' ' + str(args_dict[key])
cmd = cmd + temp_cmd
- return self.stc_config(streamblock_name,cmd)
+ return self.stc_config(streamblock_name, cmd)
# get generator name from port name
# return: generator name
- def stc_get_generator(self,port_name):
- cmd = port_name+' -children-generator'
+
+ def stc_get_generator(self, port_name):
+ cmd = port_name + ' -children-generator'
return self.stc_get(cmd)
# config generator with part arguments
# argument list use args dictionary
# return none
- def stc_config_generator(self,generator_name,args_dict):
+
+ def stc_config_generator(self, generator_name, args_dict):
cmd = ''
- for key in args_dict.keys() :
- temp_cmd = '-'+key+' '+str(args_dict[key])
+ for key in args_dict.keys():
+ temp_cmd = '-' + key + ' ' + str(args_dict[key])
cmd = cmd + temp_cmd
- return self.stc_config(generator_name,cmd)
+ return self.stc_config(generator_name, cmd)
# attach port
# return: port's parent project info
- def stc_attach_ports(self,portList):
+
+ def stc_attach_ports(self, portList):
cmd = 'AttachPorts -portList {'
- for port in portList :
- cmd = cmd+' '+port
- cmd = cmd+'} -autoConnect TRUE'
+ for port in portList:
+ cmd = cmd + ' ' + port
+ cmd = cmd + '} -autoConnect TRUE'
return self.stc_perform(cmd)
# config src mac and dst mac
# return: none
- def stc_config_ethII(self,ethII,src_mac,dst_mac):
- cmd = ethII+' -srcMac '+src_mac+' -dstMac '+dst_mac
+
+ def stc_config_ethII(self, ethII, src_mac, dst_mac):
+ cmd = ethII + ' -srcMac ' + src_mac + ' -dstMac ' + dst_mac
return self.stc_config(cmd)
# config src ip and dst ip
# return: none
- def stc_config_ethIII(self,ethIII,src_ip,dst_ip):
- cmd = ethIII+' -sourceAddr '+src_ip+' -destAddr '+dst_ip
+
+ def stc_config_ethIII(self, ethIII, src_ip, dst_ip):
+ cmd = ethIII + ' -sourceAddr ' + src_ip + ' -destAddr ' + dst_ip
return self.stc_config(cmd)
# start streamblock
# return: none
- def stc_streamblock_start(self,streamblock_list):
+
+ def stc_streamblock_start(self, streamblock_list):
cmd = 'StreamBlockStart -StreamBlockList {'
- for streamblock in streamblock_list :
- cmd = cmd+' '+streamblock
- cmd = cmd+' } -ExecuteSynchronous TRUE'
+ for streamblock in streamblock_list:
+ cmd = cmd + ' ' + streamblock
+ cmd = cmd + ' } -ExecuteSynchronous TRUE'
return self.stc_perform(cmd)
# stop streamblock
- def stc_streamblock_stop(self,streamblock_list):
+
+ def stc_streamblock_stop(self, streamblock_list):
cmd = 'StreamBlockStop -StreamBlockList {'
- for streamblock in streamblock_list :
- cmd = cmd+' '+streamblock
- cmd = cmd+' } -ExecuteSynchronous TRUE'
+ for streamblock in streamblock_list:
+ cmd = cmd + ' ' + streamblock
+ cmd = cmd + ' } -ExecuteSynchronous TRUE'
return self.stc_perform(cmd)
# start generator
# return: none
- def stc_generator_start(self,generator_List):
+
+ def stc_generator_start(self, generator_List):
cmd = 'GeneratorStart -generatorList {'
- for generator in generator_List :
- cmd = cmd+' '+generator
- cmd = cmd+' }'
+ for generator in generator_List:
+ cmd = cmd + ' ' + generator
+ cmd = cmd + ' }'
return self.stc_perform(cmd)
# stop generator
# return: none
- def stc_generator_stop(self,generator_List):
+
+ def stc_generator_stop(self, generator_List):
cmd = 'GeneratorStop -generatorList {'
- for generator in generator_List :
- cmd = cmd+' '+generator
- cmd = cmd+' }'
+ for generator in generator_List:
+ cmd = cmd + ' ' + generator
+ cmd = cmd + ' }'
return self.stc_perform(cmd)
# create rfc2544 throughput test
+
def stc_setup_rfc2544_throughput(self):
pass
# create rfc2544 frameloss test
+
def stc_setup_rfc2544_frameloss(self):
pass
# create rfc2544 latency test
+
def stc_setup_rfc2544_latency(self):
pass
# start Sequence start
+
def stc_sequence_start(self):
return self.stc_perform('SequencerStart')
# output rfc2544 throughput result
+
def stc_get_rfc2544_throughput_result(self):
pass
# output rfc2544 frameloss result
+
def stc_get_rfc2544_frameloss_result(self):
pass
# output rfc2544 latency result
+
def stc_get_rfc2544_latency_result(self):
pass
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/spirent/tools.py b/testsuites/vstf/vstf_scripts/vstf/agent/spirent/tools.py
index 088a7b13..0936d39d 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/spirent/tools.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/spirent/tools.py
@@ -11,324 +11,376 @@
import time
from spirent import stcPython
+
class Spirent_Tools(object):
baseAPI = stcPython()
+
def __init__(self):
"""This class provide API of Spirent
-
+
"""
super(Spirent_Tools, self).__init__()
-
- def send_packet(self,flow):
+
+ def send_packet(self, flow):
try:
#import pdb
- #pdb.set_trace()
+ # pdb.set_trace()
flow = eval(flow)
- #stc init action
+ # stc init action
self.baseAPI.stc_perform(' ResetConfig -config system1')
self.baseAPI.stc_init()
- #create project
+ # create project
project = self.baseAPI.stc_create_project()
- #create port
+ # create port
port_handle = self.baseAPI.stc_create_port(project)
- #config port
+ # config port
slot = flow['send_port'].split('/')[0]
port = flow['send_port'].split('/')[1]
- self.baseAPI.stc_config_port_location(port_handle,flow['tester_ip'],slot,port)
- #create streamblock
+ self.baseAPI.stc_config_port_location(
+ port_handle, flow['tester_ip'], slot, port)
+ # create streamblock
streamblock_handle = self.baseAPI.stc_create_streamblock(
- port_name = port_handle,
- ExpectedRxPort = '',
- vlan_tag = flow['vlan'],
- srcMac = flow['src_mac'],
- dstMac = flow['dst_mac'],
- sourceAddr = flow['src_ip'],
- destAddr =flow['dst_ip']
- )
+ port_name=port_handle,
+ ExpectedRxPort='',
+ vlan_tag=flow['vlan'],
+ srcMac=flow['src_mac'],
+ dstMac=flow['dst_mac'],
+ sourceAddr=flow['src_ip'],
+ destAddr=flow['dst_ip']
+ )
# attach port
port_list = [port_handle]
self.baseAPI.stc_attach_ports(port_list)
- #start streamblock
+ # start streamblock
streamblock_list = [streamblock_handle]
flag = self.baseAPI.stc_streamblock_start(streamblock_list)
return str(streamblock_list).strip('[]')
- except :
+ except:
print("[ERROR]create stream block and send packet failed.")
return False
- def mac_learning(self,flowA,flowB):
+ def mac_learning(self, flowA, flowB):
try:
#import pdb
- #pdb.set_trace()
+ # pdb.set_trace()
flowA = eval(flowA)
flowB = eval(flowB)
port_list = []
streamblock_list = []
- #stc init action
+ # stc init action
self.baseAPI.stc_perform(' ResetConfig -config system1')
self.baseAPI.stc_init()
- #create project
+ # create project
project = self.baseAPI.stc_create_project()
- #create port and config port
- for flow in [ flowA,flowB ]:
+ # create port and config port
+ for flow in [flowA, flowB]:
flow['port_handle'] = self.baseAPI.stc_create_port(project)
tmp_test_ip = flow['tester_ip']
tmp_slot = flow['send_port'].split('/')[0]
tmp_port = flow['send_port'].split('/')[1]
- self.baseAPI.stc_config_port_location(flow['port_handle'],tmp_test_ip,tmp_slot,tmp_port)
- #create streamblock
- flow['streamblock'] = self.baseAPI.stc_create_streamblock(port_name = flow['port_handle'],
- ExpectedRxPort = '',
- vlan_tag = flow['vlan'],
- srcMac = flow['src_mac'],
- dstMac = flow['dst_mac'],
- sourceAddr = flow['src_ip'],
- destAddr =flow['dst_ip'])
- #create port and stream block list
+ self.baseAPI.stc_config_port_location(
+ flow['port_handle'], tmp_test_ip, tmp_slot, tmp_port)
+ # create streamblock
+ flow['streamblock'] = self.baseAPI.stc_create_streamblock(
+ port_name=flow['port_handle'],
+ ExpectedRxPort='',
+ vlan_tag=flow['vlan'],
+ srcMac=flow['src_mac'],
+ dstMac=flow['dst_mac'],
+ sourceAddr=flow['src_ip'],
+ destAddr=flow['dst_ip'])
+ # create port and stream block list
port_list.append(flow['port_handle'])
streamblock_list.append(flow['streamblock'])
- #attach port
+ # attach port
self.baseAPI.stc_attach_ports(port_list)
- #start streamblock
+ # start streamblock
flag = self.baseAPI.stc_streamblock_start(streamblock_list)
# mac learning
time.sleep(2)
# stop stream block
self.baseAPI.stc_streamblock_stop(streamblock_list)
# delete streamblock and release port
- for flow in [ flowA,flowB ]:
+ for flow in [flowA, flowB]:
tmp_test_ip = flow['tester_ip']
tmp_slot = flow['send_port'].split('/')[0]
tmp_port = flow['send_port'].split('/')[1]
self.baseAPI.stc_delete(flow['streamblock'])
- self.baseAPI.stc_release('%s/%s/%s' %(tmp_test_ip,tmp_slot,tmp_port))
+ self.baseAPI.stc_release(
+ '%s/%s/%s' %
+ (tmp_test_ip, tmp_slot, tmp_port))
# delete project
self.baseAPI.stc_delete('project1')
ret = self.baseAPI.stc_perform('ResetConfig -config system1')
return True
- except :
+ except:
print("[ERROR]mac learning failed")
return False
- def stop_flow(self,streamblock_list,flow):
+ def stop_flow(self, streamblock_list, flow):
flow = eval(flow)
streamblock_list = streamblock_list.strip('\'').split(',')
- #stop streamblock list
- try :
+ # stop streamblock list
+ try:
ret = self.baseAPI.stc_streamblock_stop(streamblock_list)
- except :
+ except:
print("[ERROR]Stop the streamblock list failed.")
return False
- #delete streamblock
- try :
- for streamblock in streamblock_list :
+ # delete streamblock
+ try:
+ for streamblock in streamblock_list:
ret = self.baseAPI.stc_delete(streamblock)
- except :
+ except:
print("[ERROR]delete stream block.")
return False
- #release port
- try :
+ # release port
+ try:
slot = flow['send_port'].split('/')[0]
port = flow['send_port'].split('/')[1]
- ret = self.baseAPI.stc_release('%s/%s/%s' %(flow['tester_ip'],slot,port))
- except :
+ ret = self.baseAPI.stc_release(
+ '%s/%s/%s' %
+ (flow['tester_ip'], slot, port))
+ except:
print("[ERROR]Release port failed")
return False
- ##delete project
- try :
+ # delete project
+ try:
ret = self.baseAPI.stc_delete('project1')
ret = self.baseAPI.stc_perform('ResetConfig -config system1')
return True
- except :
+ except:
print("[ERROR]Delete project1 failed.")
return False
-
- def run_rfc2544_throughput(self,forward_init_flows,reverse_init_flows):
+
+ def run_rfc2544_throughput(self, forward_init_flows, reverse_init_flows):
#import pdb
- #pdb.set_trace()
- #rebuild the flows
+ # pdb.set_trace()
+ # rebuild the flows
forward_init_flows = eval(forward_init_flows)
reverse_init_flows = eval(reverse_init_flows)
- #stc init action
+ # stc init action
self.baseAPI.stc_perform(' ResetConfig -config system1')
self.baseAPI.stc_init()
- #create project
+ # create project
project = self.baseAPI.stc_create_project()
- #create sequencer
- seq_handle = self.baseAPI.stc_create('Sequencer -under %s' %(project))
- #create port handle
+ # create sequencer
+ seq_handle = self.baseAPI.stc_create('Sequencer -under %s' % (project))
+ # create port handle
forward_port_handle = self.baseAPI.stc_create_port(project)
reverse_port_handle = self.baseAPI.stc_create_port(project)
- #create forward flow streamblock
+ # create forward flow streamblock
for key in forward_init_flows.keys():
forward_init_flows[key]['port_handle'] = forward_port_handle
tmp_test_ip = forward_init_flows[key]['tester_ip']
- tmp_slot = forward_init_flows[key]['send_port'].split('/')[0]
- tmp_port = forward_init_flows[key]['send_port'].split('/')[1]
- self.baseAPI.stc_config_port_location(forward_init_flows[key]['port_handle'],tmp_test_ip,tmp_slot,tmp_port)
- #create streamblock
- forward_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(port_name = forward_init_flows[key]['port_handle'],
- vlan_tag = forward_init_flows[key]['vlan'],
- ExpectedRxPort = reverse_port_handle,
- srcMac = forward_init_flows[key]['src_mac'],
- dstMac = forward_init_flows[key]['dst_mac'],
- sourceAddr = forward_init_flows[key]['src_ip'],
- destAddr = forward_init_flows[key]['dst_ip'])
- #create reverse flow streamblock
+ tmp_slot = forward_init_flows[key]['send_port'].split('/')[0]
+ tmp_port = forward_init_flows[key]['send_port'].split('/')[1]
+ self.baseAPI.stc_config_port_location(
+ forward_init_flows[key]['port_handle'], tmp_test_ip, tmp_slot, tmp_port)
+ # create streamblock
+ forward_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(
+ port_name=forward_init_flows[key]['port_handle'],
+ vlan_tag=forward_init_flows[key]['vlan'],
+ ExpectedRxPort=reverse_port_handle,
+ srcMac=forward_init_flows[key]['src_mac'],
+ dstMac=forward_init_flows[key]['dst_mac'],
+ sourceAddr=forward_init_flows[key]['src_ip'],
+ destAddr=forward_init_flows[key]['dst_ip'])
+ # create reverse flow streamblock
for key in reverse_init_flows.keys():
reverse_init_flows[key]['port_handle'] = reverse_port_handle
tmp_test_ip = reverse_init_flows[key]['tester_ip']
- tmp_slot = reverse_init_flows[key]['send_port'].split('/')[0]
- tmp_port = reverse_init_flows[key]['send_port'].split('/')[1]
- self.baseAPI.stc_config_port_location(reverse_init_flows[key]['port_handle'],tmp_test_ip,tmp_slot,tmp_port)
- #create streamblock
- reverse_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(port_name = reverse_init_flows[key]['port_handle'],
- vlan_tag = reverse_init_flows[key]['vlan'],
- ExpectedRxPort = forward_port_handle,
- srcMac = reverse_init_flows[key]['src_mac'],
- dstMac = reverse_init_flows[key]['dst_mac'],
- sourceAddr = reverse_init_flows[key]['src_ip'],
- destAddr = reverse_init_flows[key]['dst_ip'])
- #Create the RFC 2544 throughput test
- throughput_config = self.baseAPI.stc_create('Rfc2544ThroughputConfig -under ',project,
- '-AcceptableFrameLoss 0.01',
- '-NumOfTrials 1',
- '-DurationSeconds 60',
- '-SearchMode BINARY',
- '-RateLowerLimit 1',
- '-RateUpperLimit 100',
- '-RateInitial 10',
- '-UseExistingStreamBlocks True',
- '-EnableLearning False',
- '-FrameSizeIterationMode CUSTOM',
- '-CustomFrameSizeList "70 128 256 512 1024 1280 1518"',
- '-LatencyType LIFO',
- '-EnableJitterMeasurement TRUE'
- )
+ tmp_slot = reverse_init_flows[key]['send_port'].split('/')[0]
+ tmp_port = reverse_init_flows[key]['send_port'].split('/')[1]
+ self.baseAPI.stc_config_port_location(
+ reverse_init_flows[key]['port_handle'], tmp_test_ip, tmp_slot, tmp_port)
+ # create streamblock
+ reverse_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(
+ port_name=reverse_init_flows[key]['port_handle'],
+ vlan_tag=reverse_init_flows[key]['vlan'],
+ ExpectedRxPort=forward_port_handle,
+ srcMac=reverse_init_flows[key]['src_mac'],
+ dstMac=reverse_init_flows[key]['dst_mac'],
+ sourceAddr=reverse_init_flows[key]['src_ip'],
+ destAddr=reverse_init_flows[key]['dst_ip'])
+ # Create the RFC 2544 throughput test
+ throughput_config = self.baseAPI.stc_create(
+ 'Rfc2544ThroughputConfig -under ',
+ project,
+ '-AcceptableFrameLoss 0.01',
+ '-NumOfTrials 1',
+ '-DurationSeconds 60',
+ '-SearchMode BINARY',
+ '-RateLowerLimit 1',
+ '-RateUpperLimit 100',
+ '-RateInitial 10',
+ '-UseExistingStreamBlocks True',
+ '-EnableLearning False',
+ '-FrameSizeIterationMode CUSTOM',
+ '-CustomFrameSizeList "70 128 256 512 1024 1280 1518"',
+ '-LatencyType LIFO',
+ '-EnableJitterMeasurement TRUE')
#import pdb
- #pdb.set_trace()
+ # pdb.set_trace()
# list streamblocks
streamblock_list = '" '
for key in forward_init_flows.keys():
- streamblock_list = streamblock_list+forward_init_flows[key]['streamblock']+' '
+ streamblock_list = streamblock_list + \
+ forward_init_flows[key]['streamblock'] + ' '
for key in reverse_init_flows.keys():
- streamblock_list = streamblock_list+reverse_init_flows[key]['streamblock']+' '
- streamblock_list = streamblock_list+'"'
+ streamblock_list = streamblock_list + \
+ reverse_init_flows[key]['streamblock'] + ' '
+ streamblock_list = streamblock_list + '"'
- throughput_sbProfile= self.baseAPI.stc_create('Rfc2544StreamBlockProfile -under '+throughput_config+' -Active TRUE -LocalActive TRUE')
- self.baseAPI.stc_config(throughput_sbProfile,'-StreamBlockList '+streamblock_list)
- self.baseAPI.stc_perform('ExpandBenchmarkConfigCommand','-config ',throughput_config)
+ throughput_sbProfile = self.baseAPI.stc_create(
+ 'Rfc2544StreamBlockProfile -under ' +
+ throughput_config +
+ ' -Active TRUE -LocalActive TRUE')
+ self.baseAPI.stc_config(
+ throughput_sbProfile,
+ '-StreamBlockList ' +
+ streamblock_list)
+ self.baseAPI.stc_perform(
+ 'ExpandBenchmarkConfigCommand',
+ '-config ',
+ throughput_config)
- #attach the port before testing
- port_list = [ forward_port_handle,reverse_port_handle]
+ # attach the port before testing
+ port_list = [forward_port_handle, reverse_port_handle]
self.baseAPI.stc_attach_ports(port_list)
- #stc apply and begin to sequence test
+ # stc apply and begin to sequence test
self.baseAPI.stc_apply()
self.baseAPI.stc_perform("SequencerStart")
- #wait until complete
+ # wait until complete
self.baseAPI.stc_waituntilcomplete()
-
- #get result db
- resultsdb = self.baseAPI.stc_get("system1.project.TestResultSetting", "-CurrentResultFileName")
- results_dict = self.baseAPI.stc_perform('QueryResult','-DatabaseConnectionString',resultsdb,'-ResultPath RFC2544ThroughputTestResultDetailedSummaryView')
- #print results_dict
- return True,results_dict
- def run_rfc2544_frameloss(self,forward_init_flows,reverse_init_flows):
+ # get result db
+ resultsdb = self.baseAPI.stc_get(
+ "system1.project.TestResultSetting",
+ "-CurrentResultFileName")
+ results_dict = self.baseAPI.stc_perform(
+ 'QueryResult',
+ '-DatabaseConnectionString',
+ resultsdb,
+ '-ResultPath RFC2544ThroughputTestResultDetailedSummaryView')
+ # print results_dict
+ return True, results_dict
+
+ def run_rfc2544_frameloss(self, forward_init_flows, reverse_init_flows):
#import pdb
- #pdb.set_trace()
- #rebuild the flows
+ # pdb.set_trace()
+ # rebuild the flows
forward_init_flows = eval(forward_init_flows)
reverse_init_flows = eval(reverse_init_flows)
- #stc init action
+ # stc init action
self.baseAPI.stc_perform(' ResetConfig -config system1')
self.baseAPI.stc_init()
- #create project
+ # create project
project = self.baseAPI.stc_create_project()
- #create sequencer
- seq_handle = self.baseAPI.stc_create('Sequencer -under %s' %(project))
- #create port handle
+ # create sequencer
+ seq_handle = self.baseAPI.stc_create('Sequencer -under %s' % (project))
+ # create port handle
forward_port_handle = self.baseAPI.stc_create_port(project)
reverse_port_handle = self.baseAPI.stc_create_port(project)
- #create forward flow streamblock
+ # create forward flow streamblock
for key in forward_init_flows.keys():
forward_init_flows[key]['port_handle'] = forward_port_handle
tmp_test_ip = forward_init_flows[key]['tester_ip']
- tmp_slot = forward_init_flows[key]['send_port'].split('/')[0]
- tmp_port = forward_init_flows[key]['send_port'].split('/')[1]
- self.baseAPI.stc_config_port_location(forward_init_flows[key]['port_handle'],tmp_test_ip,tmp_slot,tmp_port)
- #create streamblock
- forward_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(port_name = forward_init_flows[key]['port_handle'],
- vlan_tag = forward_init_flows[key]['vlan'],
- ExpectedRxPort = reverse_port_handle,
- srcMac = forward_init_flows[key]['src_mac'],
- dstMac = forward_init_flows[key]['dst_mac'],
- sourceAddr = forward_init_flows[key]['src_ip'],
- destAddr = forward_init_flows[key]['dst_ip'])
- #create reverse flow streamblock
+ tmp_slot = forward_init_flows[key]['send_port'].split('/')[0]
+ tmp_port = forward_init_flows[key]['send_port'].split('/')[1]
+ self.baseAPI.stc_config_port_location(
+ forward_init_flows[key]['port_handle'], tmp_test_ip, tmp_slot, tmp_port)
+ # create streamblock
+ forward_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(
+ port_name=forward_init_flows[key]['port_handle'],
+ vlan_tag=forward_init_flows[key]['vlan'],
+ ExpectedRxPort=reverse_port_handle,
+ srcMac=forward_init_flows[key]['src_mac'],
+ dstMac=forward_init_flows[key]['dst_mac'],
+ sourceAddr=forward_init_flows[key]['src_ip'],
+ destAddr=forward_init_flows[key]['dst_ip'])
+ # create reverse flow streamblock
for key in reverse_init_flows.keys():
reverse_init_flows[key]['port_handle'] = reverse_port_handle
tmp_test_ip = reverse_init_flows[key]['tester_ip']
- tmp_slot = reverse_init_flows[key]['send_port'].split('/')[0]
- tmp_port = reverse_init_flows[key]['send_port'].split('/')[1]
- self.baseAPI.stc_config_port_location(reverse_init_flows[key]['port_handle'],tmp_test_ip,tmp_slot,tmp_port)
- #create streamblock
- reverse_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(port_name = reverse_init_flows[key]['port_handle'],
- vlan_tag = reverse_init_flows[key]['vlan'],
- ExpectedRxPort = forward_port_handle,
- srcMac = reverse_init_flows[key]['src_mac'],
- dstMac = reverse_init_flows[key]['dst_mac'],
- sourceAddr = reverse_init_flows[key]['src_ip'],
- destAddr = reverse_init_flows[key]['dst_ip'])
- #Create the RFC 2544 frameloss test
- frameloss_config = self.baseAPI.stc_create('Rfc2544FrameLossConfig -under ',project,
- '-NumOfTrials 1 ',
- '-DurationSeconds 60 ',
- '-LoadUnits PERCENT_LINE_RATE ',
- '-LoadType CUSTOM '
- '-CustomLoadList 100 '
- '-UseExistingStreamBlocks True ',
- '-EnableLearning False ',
- '-FrameSizeIterationMode CUSTOM ',
- '-CustomFrameSizeList "70 128 256 512 1024 1280 1518"',
- '-LatencyType LIFO',
- '-EnableJitterMeasurement TRUE'
- )
+ tmp_slot = reverse_init_flows[key]['send_port'].split('/')[0]
+ tmp_port = reverse_init_flows[key]['send_port'].split('/')[1]
+ self.baseAPI.stc_config_port_location(
+ reverse_init_flows[key]['port_handle'], tmp_test_ip, tmp_slot, tmp_port)
+ # create streamblock
+ reverse_init_flows[key]['streamblock'] = self.baseAPI.stc_create_streamblock(
+ port_name=reverse_init_flows[key]['port_handle'],
+ vlan_tag=reverse_init_flows[key]['vlan'],
+ ExpectedRxPort=forward_port_handle,
+ srcMac=reverse_init_flows[key]['src_mac'],
+ dstMac=reverse_init_flows[key]['dst_mac'],
+ sourceAddr=reverse_init_flows[key]['src_ip'],
+ destAddr=reverse_init_flows[key]['dst_ip'])
+ # Create the RFC 2544 frameloss test
+ frameloss_config = self.baseAPI.stc_create(
+ 'Rfc2544FrameLossConfig -under ',
+ project,
+ '-NumOfTrials 1 ',
+ '-DurationSeconds 60 ',
+ '-LoadUnits PERCENT_LINE_RATE ',
+ '-LoadType CUSTOM '
+ '-CustomLoadList 100 '
+ '-UseExistingStreamBlocks True ',
+ '-EnableLearning False ',
+ '-FrameSizeIterationMode CUSTOM ',
+ '-CustomFrameSizeList "70 128 256 512 1024 1280 1518"',
+ '-LatencyType LIFO',
+ '-EnableJitterMeasurement TRUE')
#import pdb
- #pdb.set_trace()
+ # pdb.set_trace()
# list streamblocks
streamblock_list = '" '
for key in forward_init_flows.keys():
- streamblock_list = streamblock_list+forward_init_flows[key]['streamblock']+' '
+ streamblock_list = streamblock_list + \
+ forward_init_flows[key]['streamblock'] + ' '
for key in reverse_init_flows.keys():
- streamblock_list = streamblock_list+reverse_init_flows[key]['streamblock']+' '
- streamblock_list = streamblock_list+'"'
+ streamblock_list = streamblock_list + \
+ reverse_init_flows[key]['streamblock'] + ' '
+ streamblock_list = streamblock_list + '"'
- frameloss_sbProfile= self.baseAPI.stc_create('Rfc2544StreamBlockProfile -under '+frameloss_config+' -Active TRUE -LocalActive TRUE')
- self.baseAPI.stc_config(frameloss_sbProfile,'-StreamBlockList '+streamblock_list)
- self.baseAPI.stc_perform('ExpandBenchmarkConfigCommand','-config ',frameloss_config)
+ frameloss_sbProfile = self.baseAPI.stc_create(
+ 'Rfc2544StreamBlockProfile -under ' +
+ frameloss_config +
+ ' -Active TRUE -LocalActive TRUE')
+ self.baseAPI.stc_config(
+ frameloss_sbProfile,
+ '-StreamBlockList ' +
+ streamblock_list)
+ self.baseAPI.stc_perform(
+ 'ExpandBenchmarkConfigCommand',
+ '-config ',
+ frameloss_config)
- #attach the port before testing
- port_list = [ forward_port_handle,reverse_port_handle]
+ # attach the port before testing
+ port_list = [forward_port_handle, reverse_port_handle]
self.baseAPI.stc_attach_ports(port_list)
- #stc apply and begin to sequence test
+ # stc apply and begin to sequence test
self.baseAPI.stc_apply()
self.baseAPI.stc_perform("SequencerStart")
- #wait until complete
+ # wait until complete
self.baseAPI.stc_waituntilcomplete()
- #get result db
- resultsdb = self.baseAPI.stc_get("system1.project.TestResultSetting", "-CurrentResultFileName")
- results_dict = self.baseAPI.stc_perform('QueryResult','-DatabaseConnectionString',resultsdb,'-ResultPath RFC2544FrameLossTestResultDetailedSummaryView')
+ # get result db
+ resultsdb = self.baseAPI.stc_get(
+ "system1.project.TestResultSetting",
+ "-CurrentResultFileName")
+ results_dict = self.baseAPI.stc_perform(
+ 'QueryResult',
+ '-DatabaseConnectionString',
+ resultsdb,
+ '-ResultPath RFC2544FrameLossTestResultDetailedSummaryView')
#import pdb
- #pdb.set_trace()
- return True,results_dict
+ # pdb.set_trace()
+ return True, results_dict
- def run_rfc2544_latency(self,forward_init_flows,reverse_init_flows):
+ def run_rfc2544_latency(self, forward_init_flows, reverse_init_flows):
pass
-
diff --git a/testsuites/vstf/vstf_scripts/vstf/agent/spirentagent.py b/testsuites/vstf/vstf_scripts/vstf/agent/spirentagent.py
index 8951f96d..46583dfe 100644
--- a/testsuites/vstf/vstf_scripts/vstf/agent/spirentagent.py
+++ b/testsuites/vstf/vstf_scripts/vstf/agent/spirentagent.py
@@ -12,5 +12,6 @@ from vstf.agent.spirent.tools import Spirent_Tools as Spirent
class agentSpirent(Spirent):
+
def __init__(self):
super(agentSpirent, self).__init__()