l3-stations: error checking for station creation.

In station_profile create method, pay attention to result of
wait_until_ports_appear.  If it returns False, we know creation
has failed somehow, so we do not need to do the extra checking
that was in the create() method.

create_l3_stations adds logic to check return code of station
create logic, and exit with error code if it could not
create them as expected.

Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
Ben Greear
2022-01-26 16:06:26 -08:00
committed by shivam
parent 12add4503a
commit 4bb9cb4b82
3 changed files with 23 additions and 25 deletions

View File

@@ -666,13 +666,11 @@ def name_to_eid(eid_input, non_port=False):
def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debug=False, timeout=300): def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debug=False, timeout=300):
""" """
Use this method to pause until the LANforge system has caught up and implemented the Wait until ports are found and non phantom, or if timeout expires.
ports you have requested to create. This determines the presence of interfaces, it Returns True if all are found and non phantom, returns False if timeout expires first.
does not inspect their state. It is appropriate to use when creating stations in
the admin-down state.
:param timeout: :param timeout:
:param base_url: :param base_url:
:param port_list: list or str. Pass a list of multiple port EIDs. If you pass a single port EID a string, that is also valid. :param port_list: list or str. Pass a list of multiple port EIDs, or a single EID string.
:param debug: :param debug:
:return: :return:
""" """
@@ -722,6 +720,7 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu
if debug: if debug:
print("These stations appeared: " + ", ".join(found_stations)) print("These stations appeared: " + ", ".join(found_stations))
print("These stations did not appear: " + ",".join(set(port_list) - set(found_stations))) print("These stations did not appear: " + ",".join(set(port_list) - set(found_stations)))
# TODO: This probably needs some pprint logic
print(LFRequest.LFRequest("%s/ports" % base_url)) print(LFRequest.LFRequest("%s/ports" % base_url))
return False return False

View File

@@ -391,7 +391,8 @@ class StationProfile:
suppress_related_commands_=True, suppress_related_commands_=True,
use_radius=False, use_radius=False,
hs20_enable=False, hs20_enable=False,
sleep_time=0.02): sleep_time=0.02,
timeout=300):
if debug: if debug:
print('Start station_profile.create') print('Start station_profile.create')
pprint('Current ports: %s' % LFRequest.LFRequest(self.lfclient_url + '/ports', debug_=debug)) pprint('Current ports: %s' % LFRequest.LFRequest(self.lfclient_url + '/ports', debug_=debug))
@@ -561,25 +562,14 @@ class StationProfile:
if debug: if debug:
print('StationProfile.create debug: %s' % self.local_realm.json_get('/port/')) print('StationProfile.create debug: %s' % self.local_realm.json_get('/port/'))
print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - ") print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - ")
LFUtils.wait_until_ports_appear(self.lfclient_url, my_sta_eids, debug=debug)
# query the LANforge for all available ports rv = LFUtils.wait_until_ports_appear(self.lfclient_url, my_sta_eids, debug=debug, timeout=timeout)
port_list_1 = self.local_realm.json_get("/port/%s/%s" % (radio_shelf, radio_resource)) if not rv:
# Filter port_list to include only ports which are the stations we are creating # port creation failed somehow.
port_list = list() print('ERROR: Failed to create all ports, Desired stations: %s' % my_sta_eids)
for port in port_list_1['interfaces']:
if list(port.keys())[0] in my_sta_eids:
port_list.append(list(port.keys())[0])
# If a requested port doesn't appear on the LANforge, raise an error and print debug
if len(port_list) != len(my_sta_eids):
print('Desired stations: %s' % my_sta_eids)
print("Existing stations: %s" % port_list)
print('full port list')
pprint(port_list_1)
print('events') print('events')
pprint(self.local_realm.find_new_events(starting_event)) pprint(self.local_realm.find_new_events(starting_event))
raise ValueError("Unable to find ports: %s" % (set(my_sta_eids) - set(port_list))) return False;
# and set ports up # and set ports up
if dry_run: if dry_run:
@@ -594,6 +584,7 @@ class StationProfile:
# time.sleep(0.03) # time.sleep(0.03)
if self.debug: if self.debug:
print("created %s stations" % num) print("created %s stations" % num)
return True
def modify(self, radio): def modify(self, radio):
for station in self.station_names: for station in self.station_names:

View File

@@ -107,9 +107,17 @@ class CreateL3(Realm):
self.station_profile.set_command_param( self.station_profile.set_command_param(
"set_port", "report_timer", 1500) "set_port", "report_timer", 1500)
self.station_profile.set_command_flag("set_port", "rpt_timer", 1) self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
self.station_profile.create(radio=self.radio,
sta_names_=self.sta_list, sta_timeout=300
debug=self.debug) #sta_timeout=3 # expect this to fail
rv = self.station_profile.create(radio=self.radio,
sta_names_=self.sta_list,
debug=self.debug,
timeout=sta_timeout)
if not rv:
print("ERROR: create_l3_stations: could not create all ports, exiting with error.");
exit(1);
self.cx_profile.create(endp_type="lf_udp", self.cx_profile.create(endp_type="lf_udp",
side_a=self.station_profile.station_names, side_a=self.station_profile.station_names,
side_b=self.upstream, side_b=self.upstream,