diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index ebf89c83..f950f2a9 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -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): """ - Use this method to pause until the LANforge system has caught up and implemented the - ports you have requested to create. This determines the presence of interfaces, it - does not inspect their state. It is appropriate to use when creating stations in - the admin-down state. + Wait until ports are found and non phantom, or if timeout expires. + Returns True if all are found and non phantom, returns False if timeout expires first. :param timeout: :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: :return: """ @@ -722,6 +720,7 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu if debug: print("These stations appeared: " + ", ".join(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)) return False diff --git a/py-json/station_profile.py b/py-json/station_profile.py index fffc83f0..935d2589 100644 --- a/py-json/station_profile.py +++ b/py-json/station_profile.py @@ -391,7 +391,8 @@ class StationProfile: suppress_related_commands_=True, use_radius=False, hs20_enable=False, - sleep_time=0.02): + sleep_time=0.02, + timeout=300): if debug: print('Start station_profile.create') pprint('Current ports: %s' % LFRequest.LFRequest(self.lfclient_url + '/ports', debug_=debug)) @@ -561,25 +562,14 @@ class StationProfile: if debug: print('StationProfile.create debug: %s' % self.local_realm.json_get('/port/')) print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - ") - LFUtils.wait_until_ports_appear(self.lfclient_url, my_sta_eids, debug=debug) - # query the LANforge for all available ports - port_list_1 = self.local_realm.json_get("/port/%s/%s" % (radio_shelf, radio_resource)) - # Filter port_list to include only ports which are the stations we are creating - port_list = list() - 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) + rv = LFUtils.wait_until_ports_appear(self.lfclient_url, my_sta_eids, debug=debug, timeout=timeout) + if not rv: + # port creation failed somehow. + print('ERROR: Failed to create all ports, Desired stations: %s' % my_sta_eids) print('events') 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 if dry_run: @@ -594,6 +584,7 @@ class StationProfile: # time.sleep(0.03) if self.debug: print("created %s stations" % num) + return True def modify(self, radio): for station in self.station_names: diff --git a/py-scripts/create_l3_stations.py b/py-scripts/create_l3_stations.py index e88c0e73..85b15ae0 100755 --- a/py-scripts/create_l3_stations.py +++ b/py-scripts/create_l3_stations.py @@ -107,9 +107,17 @@ class CreateL3(Realm): self.station_profile.set_command_param( "set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio=self.radio, - sta_names_=self.sta_list, - debug=self.debug) + + sta_timeout=300 + #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", side_a=self.station_profile.station_names, side_b=self.upstream,