mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	jbr_monitor_bssids.py now has logic to load scenario and wait for it to finish loading
This commit is contained in:
		| @@ -44,6 +44,7 @@ if sys.version_info[0] != 3: | |||||||
| import os | import os | ||||||
| import importlib | import importlib | ||||||
| import argparse | import argparse | ||||||
|  | import time | ||||||
| from http.client import HTTPResponse | from http.client import HTTPResponse | ||||||
| from typing import Optional | from typing import Optional | ||||||
| from pprint import pprint, pformat | from pprint import pprint, pformat | ||||||
| @@ -160,6 +161,8 @@ class BssidMonitor(Realm): | |||||||
|                                                           debug=self.debug, |                                                           debug=self.debug, | ||||||
|                                                           errors_warnings=err_warn_list) |                                                           errors_warnings=err_warn_list) | ||||||
|         last_event_id = event_response["id"] |         last_event_id = event_response["id"] | ||||||
|  |         if not self.wait_for_load_to_finish(since_id=last_event_id): | ||||||
|  |             exit(1) | ||||||
|  |  | ||||||
|         # load a database |         # load a database | ||||||
|         response: HTTPResponse = self.lf_command.post_load(name="BLANK", |         response: HTTPResponse = self.lf_command.post_load(name="BLANK", | ||||||
| @@ -171,10 +174,39 @@ class BssidMonitor(Realm): | |||||||
|         if not response: |         if not response: | ||||||
|             raise ConnectionError("lf_command::post_load returned no response") |             raise ConnectionError("lf_command::post_load returned no response") | ||||||
|  |  | ||||||
|  |  | ||||||
|         # create a series of stations |         # create a series of stations | ||||||
|         for bssid in self.bssid_list: |         for bssid in self.bssid_list: | ||||||
|             print("build: bssid: %s" % bssid) |             print("build: bssid: %s" % bssid) | ||||||
|  |  | ||||||
|  |     def wait_for_load_to_finish(self, since_id:int=None): | ||||||
|  |         completed = False | ||||||
|  |         timer = 0 | ||||||
|  |         timeout = 60 | ||||||
|  |         while not completed: | ||||||
|  |             new_events = self.lf_query.events_since(event_id=since_id) | ||||||
|  |             if new_events: | ||||||
|  |                 for event_tup in new_events: | ||||||
|  |                     for event_id in event_tup.keys(): | ||||||
|  |                         event_record = event_tup[event_id] | ||||||
|  |                         # pprint(event_record) | ||||||
|  |                         if event_record['event description'].startswith('LOAD COMPLETED'): | ||||||
|  |                             completed = True | ||||||
|  |                             self.lf_query.logger.warning('Scenario loaded after %s seconds' % timer) | ||||||
|  |                             break | ||||||
|  |             if completed: | ||||||
|  |                 break | ||||||
|  |             else: | ||||||
|  |                 timer += 1 | ||||||
|  |                 time.sleep(1) | ||||||
|  |                 if timer > timeout: | ||||||
|  |                     completed = True | ||||||
|  |                     print('Scenario failed to load after %s seconds' % timeout) | ||||||
|  |                     break | ||||||
|  |                 else: | ||||||
|  |                     print('Waiting %s out of %s seconds to load scenario' % (timer, timeout)) | ||||||
|  |         return completed | ||||||
|  |  | ||||||
|  |  | ||||||
|     def start(self): |     def start(self): | ||||||
|         pass |         pass | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jed Reynolds
					Jed Reynolds