summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Paraskevopoulos <geopar@intracom-telecom.com>2016-10-25 16:14:52 +0300
committerGeorge Paraskevopoulos <geopar@intracom-telecom.com>2016-11-17 15:27:38 +0200
commit667253a486675fa6925854aac3130588b4e674ab (patch)
treef223924c69f68bdba76525cacf7c638e901f63ec
parenta732ebb030930e072b722e8399f6873685d2b326 (diff)
Fix bug in ovs utils
Change-Id: I86995a2fce5199c9267edc0e0596d868cc7d20ab Signed-off-by: George Paraskevopoulos <geopar@intracom-telecom.com>
-rw-r--r--testcases/features/sfc/ovs_utils.py45
1 files changed, 41 insertions, 4 deletions
diff --git a/testcases/features/sfc/ovs_utils.py b/testcases/features/sfc/ovs_utils.py
index 83a36286d..20ab5a7e3 100644
--- a/testcases/features/sfc/ovs_utils.py
+++ b/testcases/features/sfc/ovs_utils.py
@@ -10,21 +10,29 @@
import functest.utils.functest_logger as rl
import os
import time
+import shutil
logger = rl.Logger('ovs_utils').getLogger()
class OVSLogger(object):
- def __init__(self, basedir):
- self.ovs_dir = os.path.join(basedir, 'odl-sfc/ovs')
+ def __init__(self, basedir, ft_resdir):
+ self.ovs_dir = basedir
+ self.ft_resdir = ft_resdir
self.__mkdir_p(self.ovs_dir)
def __mkdir_p(self, dirpath):
if not os.path.exists(dirpath):
os.makedirs(dirpath)
- def __ssh_host(self, ssh_conn):
- return ssh_conn.get_transport().getpeername()[0]
+ def __ssh_host(self, ssh_conn, host_prefix='10.20.0'):
+ try:
+ _, stdout, _ = ssh_conn.exec_command('hostname -I')
+ hosts = stdout.readline().strip().split(' ')
+ found_host = [h for h in hosts if h.startswith(host_prefix)][0]
+ return found_host
+ except Exception, e:
+ logger.error(e)
def __dump_to_file(self, operation, host, text, timestamp=None):
ts = (timestamp if timestamp is not None
@@ -51,6 +59,13 @@ class OVSLogger(object):
.format(cmd, e))
return None
+ def create_artifact_archive(self):
+ shutil.make_archive(self.ovs_dir,
+ 'zip',
+ root_dir=os.path.dirname(self.ovs_dir),
+ base_dir=self.ovs_dir)
+ shutil.copy2('{0}.zip'.format(self.ovs_dir), self.ft_resdir)
+
def ofctl_dump_flows(self, ssh_conn, br='br-int',
choose_table=None, timestamp=None):
try:
@@ -78,3 +93,25 @@ class OVSLogger(object):
except Exception, e:
logger.error('[vsctl_show(ssh_client)]: {0}'.format(e))
return None
+
+ def dump_ovs_logs(self, controller_clients, compute_clients,
+ related_error=None, timestamp=None):
+ if timestamp is None:
+ timestamp = time.strftime("%Y%m%d-%H%M%S")
+
+ for controller_client in controller_clients:
+ self.ofctl_dump_flows(controller_client,
+ timestamp=timestamp)
+ self.vsctl_show(controller_client,
+ timestamp=timestamp)
+
+ for compute_client in compute_clients:
+ self.ofctl_dump_flows(compute_client,
+ timestamp=timestamp)
+ self.vsctl_show(compute_client,
+ timestamp=timestamp)
+
+ if related_error is not None:
+ dumpdir = os.path.join(self.ovs_dir, timestamp)
+ with open(os.path.join(dumpdir, 'error'), 'w') as f:
+ f.write(related_error)