diff --git a/py-json/station_profile.py b/py-json/station_profile.py index fa06a119..3421cbdc 100644 --- a/py-json/station_profile.py +++ b/py-json/station_profile.py @@ -367,7 +367,6 @@ class StationProfile: def admin_up(self): for eid in self.station_names: self.local_realm.admin_up(eid) - time.sleep(0.005) def admin_down(self): for sta_name in self.station_names: @@ -393,6 +392,8 @@ class StationProfile: debug=debug_) # Checks for errors in initialization values and creates specified number of stations using init parameters + # TODO: Add option to check if stations exist already. If they do, then warn user, and set MAC to 'NA' so that is + # is not attempted to be mofidified when submitting the create-station URL request. def create(self, radio, num_stations=0, sta_names_=None, diff --git a/py-scripts/create_station.py b/py-scripts/create_station.py index 78feaa9b..691ddf7f 100755 --- a/py-scripts/create_station.py +++ b/py-scripts/create_station.py @@ -7,9 +7,11 @@ import os import importlib import argparse import pprint +import logging +logger = logging.getLogger(__name__) if sys.version_info[0] != 3: - print("This script requires Python 3") + logger.critical("This script requires Python 3") exit(1) @@ -20,6 +22,7 @@ LFCliBase = lfcli_base.LFCliBase LFUtils = importlib.import_module("py-json.LANforge.LFUtils") realm = importlib.import_module("py-json.realm") Realm = realm.Realm +lf_logger_config = importlib.import_module("py-scripts.lf_logger_config") class CreateStation(Realm): @@ -95,13 +98,20 @@ class CreateStation(Realm): retries=self.set_txo_data["retries"], sgi=self.set_txo_data["sgi"], ) - self.station_profile.create( + + if self.station_profile.create( radio=self.radio, sta_names_=self.sta_list, - debug=self.debug) + debug=self.debug): + self._pass("Stations created.") + else: + self._fail("Stations not properly created.") + if self.up: self.station_profile.admin_up() + # TODO: Add check for whether stations went admin up or not. + self._pass("PASS: Station build finished") @@ -145,6 +155,12 @@ def main(): action='append') args = parser.parse_args() + + logger_config = lf_logger_config.lf_logger_config() + # set the logger level to requested value + logger_config.set_level(level=args.log_level) + logger_config.set_json(json_file=args.lf_logger_config_json) + # if args.debug: # pprint.pprint(args) # time.sleep(5) @@ -182,7 +198,14 @@ def main(): _debug_on=args.debug) create_station.build() - print('Created %s stations' % num_sta) + + # TODO: Add code to clean up the station, unless --noclean was specified. + + if create_station.passes(): + print('Created %s stations' % num_sta) + create_station.exit_success() + else: + create_station.exit_fail() if __name__ == "__main__":