From c83ec00f76d46d41f407df0dd455d3d81eb7dae5 Mon Sep 17 00:00:00 2001 From: “Manuel Buil” Date: Fri, 3 Feb 2017 13:27:28 +0100 Subject: Modification of the ofctl_time counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If ODL is fast and changes the class. flow too quick, this function considers it as coming from an old deployment and thus never detects that the flows changed Change-Id: I0d6d1c27b325fb832d9ed6d4849f830eeea70185 Signed-off-by: “Manuel Buil” --- sfc/lib/utils.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index f4412abf..ef261627 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -352,7 +352,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 @@ -362,6 +362,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] @@ -374,7 +385,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 -- cgit 1.2.3-korg