From 6a964ef2156f93c5dd530f264171ed7e4edacffd Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Tue, 1 Feb 2022 07:12:29 -0800 Subject: [PATCH] lfutils: fix wait-for-ports-admin-up Logic was broken trying to compare json_response['down'] to "true", when instead that object is a Boolean variable. So this method always returned immediately instead of actually waiting until port was admin up. This was seen testing VAP profile. Signed-off-by: Ben Greear --- py-json/LANforge/LFUtils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index bd5bae70..f22f15d0 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -516,9 +516,9 @@ def wait_until_ports_admin_up(resource_id=0, base_url="http://localhost:8080", p down_stations.append(port_name) continue - if json_response['down'] == "true": + if json_response['down']: # This is a boolean object, not a string if debug_: - logger.debug("waiting for port: %s to go admin up." % port_name) + logger.info("waiting for port: %s to go admin up." % port_name) down_stations.append(port_name) else: if debug_: @@ -728,12 +728,18 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu shelf = eid[0] resource_id = eid[1] port_name = eid[2] + # TODO: If port_name happens to be a number, especialy '1', then the request below + # gets a list instead of a single item...and see a few lines down. uri = "%s/%s/%s" % (port_url, resource_id, port_name) #print("port-eid: %s uri: %s" % (port_eid, uri)) lf_r = LFRequest.LFRequest(base_url, uri, debug_=debug) json_response = lf_r.get_as_json() if json_response is not None: #pprint.pprint(json_response) + # TODO: If a list was (accidentally) requested, this code below will blow up. + # This can currently happen if someone manages to name a port 1.1.vap0, ie using + # an EID as a name. + # TODO: Fix name_to_eid to somehow detect this and deal with it. if not json_response['interface']['phantom']: found_stations.add("%s.%s.%s" % (shelf, resource_id, port_name)) else: