mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 12:18:00 +00:00
create-cx: Add return code checking for cx and endp creation.
Check for false value in create_l3_stations and return error code upon failure. Add configurable timeout to waiting for cx/endp logic. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -415,7 +415,10 @@ class L3CXProfile(LFCliBase):
|
|||||||
self.created_endp.clear()
|
self.created_endp.clear()
|
||||||
|
|
||||||
def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False,
|
def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False,
|
||||||
tos=None):
|
tos=None, timeout=300):
|
||||||
|
# Returns a 2-member array, list of cx, list of endp on success.
|
||||||
|
# If endpoints creation fails, returns False, False
|
||||||
|
# if Endpoints creation is OK, but CX creation fails, returns False, list of endp
|
||||||
if self.debug:
|
if self.debug:
|
||||||
debug_ = True
|
debug_ = True
|
||||||
print('Start L3CXProfile.create')
|
print('Start L3CXProfile.create')
|
||||||
@@ -628,15 +631,24 @@ class L3CXProfile(LFCliBase):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
"side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (
|
"side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (
|
||||||
type(side_a), type(side_b)))
|
type(side_a), type(side_b)))
|
||||||
print("wait_until_endps_appear these_endp: {} debug_ {}".format(these_endp, debug_))
|
if debug_:
|
||||||
self.local_realm.wait_until_endps_appear(these_endp, debug=debug_)
|
print("wait_until_endps_appear these_endp: {} debug_ {}".format(these_endp, debug_))
|
||||||
|
rv = self.local_realm.wait_until_endps_appear(these_endp, debug=debug_, timeout=timeout)
|
||||||
|
if not rv:
|
||||||
|
if debug_:
|
||||||
|
print("ERROR: L3CXProfile::create, Could not create/find endpoints")
|
||||||
|
return False, False
|
||||||
|
|
||||||
for data in cx_post_data:
|
for data in cx_post_data:
|
||||||
url = "/cli-json/add_cx"
|
url = "/cli-json/add_cx"
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
||||||
self.local_realm.wait_until_cxs_appear(these_cx, debug=debug_)
|
rv = self.local_realm.wait_until_cxs_appear(these_cx, debug=debug_, timeout=timeout)
|
||||||
|
if not rv:
|
||||||
|
if debug_:
|
||||||
|
print("ERROR: L3CXProfile::create, Could not create/find connections.")
|
||||||
|
return False, these_endp
|
||||||
|
|
||||||
return these_cx, these_endp
|
return these_cx, these_endp
|
||||||
|
|
||||||
|
|||||||
@@ -384,14 +384,13 @@ class Realm(LFCliBase):
|
|||||||
response = self.json_get("/cx/list")
|
response = self.json_get("/cx/list")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def waitUntilEndpsAppear(self, these_endp, debug=False):
|
def waitUntilEndpsAppear(self, these_endp, debug=False, timeout=300):
|
||||||
return self.wait_until_endps_appear(these_endp, debug=debug)
|
return self.wait_until_endps_appear(these_endp, debug=debug, timeout=timeout)
|
||||||
|
|
||||||
def wait_until_endps_appear(self, these_endp, debug=False):
|
def wait_until_endps_appear(self, these_endp, debug=False, timeout=100):
|
||||||
wait_more = True
|
wait_more = True
|
||||||
count = 0
|
count = 0
|
||||||
while wait_more:
|
while wait_more:
|
||||||
time.sleep(1)
|
|
||||||
wait_more = False
|
wait_more = False
|
||||||
endp_list = self.json_get("/endp/list")
|
endp_list = self.json_get("/endp/list")
|
||||||
found_endps = {}
|
found_endps = {}
|
||||||
@@ -413,19 +412,21 @@ class Realm(LFCliBase):
|
|||||||
print("Waiting on endpoint: %s" % req)
|
print("Waiting on endpoint: %s" % req)
|
||||||
wait_more = True
|
wait_more = True
|
||||||
count += 1
|
count += 1
|
||||||
if count > 100:
|
if count > timeout:
|
||||||
break
|
print("ERROR: Could not find all endpoints: %s" % these_endp)
|
||||||
|
return False
|
||||||
|
if wait_more:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
return not wait_more
|
return True
|
||||||
|
|
||||||
def waitUntilCxsAppear(self, these_cx, debug=False):
|
def waitUntilCxsAppear(self, these_cx, debug=False, timeout=100):
|
||||||
return self.wait_until_cxs_appear(these_cx, debug=debug)
|
return self.wait_until_cxs_appear(these_cx, debug=debug, timeout=timeout)
|
||||||
|
|
||||||
def wait_until_cxs_appear(self, these_cx, debug=False):
|
def wait_until_cxs_appear(self, these_cx, debug=False, timeout=100):
|
||||||
wait_more = True
|
wait_more = True
|
||||||
count = 0
|
count = 0
|
||||||
while wait_more:
|
while wait_more:
|
||||||
time.sleep(1)
|
|
||||||
wait_more = False
|
wait_more = False
|
||||||
found_cxs = {}
|
found_cxs = {}
|
||||||
cx_list = self.cx_list()
|
cx_list = self.cx_list()
|
||||||
@@ -442,10 +443,14 @@ class Realm(LFCliBase):
|
|||||||
print("Waiting on CX: %s" % req)
|
print("Waiting on CX: %s" % req)
|
||||||
wait_more = True
|
wait_more = True
|
||||||
count += 1
|
count += 1
|
||||||
if count > 100:
|
if count > timeout:
|
||||||
break
|
if debug:
|
||||||
|
print("ERROR: Failed to find all cxs: %s" % these_cx)
|
||||||
|
return False
|
||||||
|
if wait_more:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
return not wait_more
|
return True
|
||||||
|
|
||||||
# def wait_until_database_loaded(self):
|
# def wait_until_database_loaded(self):
|
||||||
|
|
||||||
|
|||||||
@@ -118,10 +118,17 @@ class CreateL3(Realm):
|
|||||||
print("ERROR: create_l3_stations: could not create all ports, exiting with error.");
|
print("ERROR: create_l3_stations: could not create all ports, exiting with error.");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
self.cx_profile.create(endp_type="lf_udp",
|
cx_timeout=300
|
||||||
side_a=self.station_profile.station_names,
|
#cx_timeout=0 # expect this to fail
|
||||||
side_b=self.upstream,
|
rv = self.cx_profile.create(endp_type="lf_udp",
|
||||||
sleep_time=0)
|
side_a=self.station_profile.station_names,
|
||||||
|
side_b=self.upstream,
|
||||||
|
sleep_time=0,
|
||||||
|
timeout=cx_timeout)
|
||||||
|
if not rv:
|
||||||
|
print("ERROR: create_l3_stations: could not create all cx/endpoints, exiting with error.");
|
||||||
|
exit(1);
|
||||||
|
|
||||||
self._pass("PASS: Station build finished")
|
self._pass("PASS: Station build finished")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user