summaryrefslogtreecommitdiffstats
path: root/testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/agent/env/fsmonitor')
-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
3 files changed, 48 insertions, 26 deletions
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]