mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 11:18:03 +00:00
LFUtils.py: Improves wait_until_ports_disappear error message; Fixes many linter warnings.
Signed-off-by: Jed Reynolds <jed@candelatech.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import ipaddress
|
|||||||
|
|
||||||
seed(int(round(time.time() * 1000)))
|
seed(int(round(time.time() * 1000)))
|
||||||
from random import randint
|
from random import randint
|
||||||
from LANforge import LFRequest
|
import LFRequest
|
||||||
|
|
||||||
debug_printer = pprint.PrettyPrinter(indent=2)
|
debug_printer = pprint.PrettyPrinter(indent=2)
|
||||||
|
|
||||||
@@ -276,10 +276,10 @@ def port_name_series(prefix="sta", start_id=0, end_id=1, padding_number=10000, r
|
|||||||
the padding_number is added to the start and end numbers and the resulting sum
|
the padding_number is added to the start and end numbers and the resulting sum
|
||||||
has the first digit trimmed, so f(0, 1, 10000) => {"0000", "0001"}
|
has the first digit trimmed, so f(0, 1, 10000) => {"0000", "0001"}
|
||||||
@deprecated -- please use port_name_series
|
@deprecated -- please use port_name_series
|
||||||
:param prefix_: defaults to 'sta'
|
:param prefix: defaults to 'sta'
|
||||||
:param start_id_: beginning id
|
:param start_id: beginning id
|
||||||
:param end_id_: ending_id
|
:param end_id: ending_id
|
||||||
:param padding_number_: used for width of resulting station number
|
:param padding_number: used for width of resulting station number
|
||||||
:return: list of stations
|
:return: list of stations
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -478,10 +478,10 @@ def wait_until_ports_admin_up(resource_id=1, base_url="http://localhost:8080", p
|
|||||||
sleep(1)
|
sleep(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def waitUntilPortsDisappear(base_url="http://localhost:8080", port_list=[], debug=False):
|
def waitUntilPortsDisappear(base_url="http://localhost:8080", port_list=(), debug=False):
|
||||||
wait_until_ports_disappear(base_url, port_list, debug)
|
wait_until_ports_disappear(base_url, port_list, debug)
|
||||||
|
|
||||||
def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=[], debug=False):
|
def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=(), debug=False):
|
||||||
if (port_list is None) or (len(port_list) < 1):
|
if (port_list is None) or (len(port_list) < 1):
|
||||||
if debug:
|
if debug:
|
||||||
print("LFUtils: wait_until_ports_disappear: empty list, zipping back")
|
print("LFUtils: wait_until_ports_disappear: empty list, zipping back")
|
||||||
@@ -520,7 +520,7 @@ def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=[], d
|
|||||||
lf_r = LFRequest.LFRequest(base_url, check_url, debug_=debug)
|
lf_r = LFRequest.LFRequest(base_url, check_url, debug_=debug)
|
||||||
json_response = lf_r.get_as_json(debug_=debug, die_on_error_=False)
|
json_response = lf_r.get_as_json(debug_=debug, die_on_error_=False)
|
||||||
if (json_response == None):
|
if (json_response == None):
|
||||||
print("Request returned None")
|
print("LFUtils::wait_until_ports_disappear:: Request returned None: [{}]".format(base_url + check_url))
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
pprint.pprint(("wait_until_ports_disappear json_response:", json_response))
|
pprint.pprint(("wait_until_ports_disappear json_response:", json_response))
|
||||||
@@ -559,7 +559,7 @@ def name_to_eid(input, non_port=False):
|
|||||||
|
|
||||||
info = input.split('.')
|
info = input.split('.')
|
||||||
if len(info) == 1:
|
if len(info) == 1:
|
||||||
rv[2] = info[0]; # just port name
|
rv[2] = info[0] # just port name
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
if (len(info) == 2) and info[0].isnumeric() and not info[1].isnumeric(): # resource.port-name
|
if (len(info) == 2) and info[0].isnumeric() and not info[1].isnumeric(): # resource.port-name
|
||||||
@@ -596,7 +596,7 @@ def name_to_eid(input, non_port=False):
|
|||||||
rv[1] = int(info[1])
|
rv[1] = int(info[1])
|
||||||
rv[2] = info[2]+"."+info[3]
|
rv[2] = info[2]+"."+info[3]
|
||||||
|
|
||||||
return rv;
|
return rv
|
||||||
|
|
||||||
def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debug=False):
|
def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debug=False):
|
||||||
"""
|
"""
|
||||||
@@ -647,7 +647,7 @@ def wait_until_endps(base_url="http://localhost:8080", endp_list=(), debug=False
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
:param base_url:
|
:param base_url:
|
||||||
:param port_list:
|
:param endp_list:
|
||||||
:param debug:
|
:param debug:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
@@ -658,7 +658,7 @@ def wait_until_endps(base_url="http://localhost:8080", endp_list=(), debug=False
|
|||||||
if base_url.endswith('/'):
|
if base_url.endswith('/'):
|
||||||
port_url = port_url[1:]
|
port_url = port_url[1:]
|
||||||
ncshow_url = ncshow_url[1:]
|
ncshow_url = ncshow_url[1:]
|
||||||
|
found_stations = []
|
||||||
while len(found_stations) < len(endp_list):
|
while len(found_stations) < len(endp_list):
|
||||||
found_stations = []
|
found_stations = []
|
||||||
for port_eid in endp_list:
|
for port_eid in endp_list:
|
||||||
|
|||||||
Reference in New Issue
Block a user