mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-02 03:37:55 +00:00
sta_connect.py, lfcli_base.py: fixes inheritance mistake, continues refactoring, test now runs
This commit is contained in:
@@ -6,11 +6,14 @@ from LANforge.LFUtils import *
|
||||
|
||||
|
||||
class LFCliBase:
|
||||
def __init__(self, lfjson_host="localhost", lfjson_port=8080, _debug=False):
|
||||
# do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn)
|
||||
# that is py2 era syntax and will force self into the host variable, making you
|
||||
# very confused.
|
||||
def __init__(self, _lfjson_host, _lfjson_port, _debug=False):
|
||||
self.lfjson_host = _lfjson_host
|
||||
self.lfjson_port = _lfjson_port
|
||||
self.debugOn = _debug
|
||||
self.lfjson_host = lfjson_host
|
||||
self.lfjson_port = lfjson_port
|
||||
self.mgr_url = f"http://{self.lfjson_host}:{self.lfjson_port}/"
|
||||
self.mgr_url = "http://%s:%s/" % (self.lfjson_host, self.lfjson_port)
|
||||
|
||||
def jsonPost(self, _req_url, _data):
|
||||
lf_r = LFRequest.LFRequest(self.mgr_url + _req_url)
|
||||
@@ -29,4 +32,18 @@ class LFCliBase:
|
||||
json_response = lf_r.getAsJson(self.debugOn)
|
||||
return json_response
|
||||
|
||||
def checkConnect(self):
|
||||
print(f"Checking for LANforge GUI connection: {self.mgr_url}")
|
||||
response = self.jsonGet("")
|
||||
duration = 0
|
||||
while (response is None) and (duration < 300):
|
||||
print(f"LANforge GUI connection not found sleeping 5 seconds, tried: {self.mgr_url}")
|
||||
duration += 2
|
||||
time.sleep(2)
|
||||
response = self.jsonGet("")
|
||||
|
||||
if duration >= 300:
|
||||
print("Could not connect to LANforge GUI")
|
||||
sys.exit(1)
|
||||
|
||||
# ~class
|
||||
|
||||
Reference in New Issue
Block a user