diff options
Diffstat (limited to 'sfc/lib')
-rw-r--r-- | sfc/lib/utils.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index 14a2cc2c..2f98f6ff 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -27,25 +27,19 @@ FUNCTEST_RESULTS_DIR = os.path.join("home", "opnfv", "functest", "results", "odl-sfc") -def run_cmd(cmd, wdir=None, ignore_stderr=False, ignore_no_output=True): +def run_cmd(cmd): """run given command locally and return commands output if success""" pipe = subprocess.Popen(cmd, shell=True, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, cwd=wdir) + stderr=subprocess.PIPE) (output, errors) = pipe.communicate() if output: output = output.strip() - if pipe.returncode < 0: + if pipe.returncode != 0 or len(errors) > 0: + logger.error('FAILED to execute {0}'.format(cmd)) logger.error(errors) - return False - if errors: - logger.error(errors) - return ignore_stderr - - if ignore_no_output and not output: - return True + return None return output @@ -348,7 +342,7 @@ def check_ssh(ips, retries=100): return False -def ofctl_time_counter(ovs_logger, ssh_conn): +def ofctl_time_counter(ovs_logger, ssh_conn, max_duration=None): try: # We get the flows from table 11 table = 11 @@ -358,6 +352,17 @@ def ofctl_time_counter(ovs_logger, ssh_conn): rsps = [] lines = output.split(",") for line in lines: + if max_duration is not None: + pattern2 = "duration" + is_there2 = re.findall(pattern2, line) + if is_there2: + value = line.split("=")[1].split(".")[0] + value_int = int(value) + if value_int < max_duration: + # The RSP is new, no need to store the RSP in first_RSP + return rsps + else: + continue is_there = re.findall(pattern, line) if is_there: value = line.split(":")[1].split("-")[0] @@ -370,7 +375,11 @@ def ofctl_time_counter(ovs_logger, ssh_conn): @ft_utils.timethis def wait_for_classification_rules(ovs_logger, compute_clients, timeout=200): - rsps = ofctl_time_counter(ovs_logger, compute_clients[0]) + # 10 sec. is the threshold to consider a flow from an old deployment + max_duration = 10 + rsps = ofctl_time_counter(ovs_logger, compute_clients[0], max_duration) + # first_RSP saves a potential RSP from an old deployment. ODL may take + # quite some time to implement the new flow and an old flow may be there first_RSP = rsps[0] if len(rsps) > 0 else '' while not ((len(rsps) > 1) and (first_RSP != rsps[0]) and |