diff --git a/connectTest.py b/connectTest.py index 31e29d72..9ffe92ff 100755 --- a/connectTest.py +++ b/connectTest.py @@ -20,7 +20,7 @@ staNameUri = "port/1/1/" + staName class ConnectTest(LFCliBase): def __init__(self, lfhost, lfport): super().__init__(lfhost, lfport, True) - super().checkConnect() + super().check_connect() # compare pre-test values to post-test values @staticmethod @@ -34,7 +34,7 @@ class ConnectTest(LFCliBase): def run(self): print("See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test") - eth1IP = super().jsonGet("port/1/1/eth1") + eth1IP = super().json_get("port/1/1/eth1") if eth1IP['interface']['ip'] == "0.0.0.0": print("Warning: Eth1 lacks ip address") exit(1) @@ -42,7 +42,7 @@ class ConnectTest(LFCliBase): # Create stations and turn dhcp on print("Creating station and turning on dhcp") - response = super().jsonGet(staNameUri) + response = super().json_get(staNameUri) if response is not None: if response["interface"] is not None: print("removing old station") @@ -62,7 +62,7 @@ class ConnectTest(LFCliBase): "mac": "xx:xx:xx:xx:*:xx", "flags": (0x400 + 0x20000 + 0x1000000000) # create admin down } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(0.05) reqURL = "cli-json/set_port" data = { @@ -72,16 +72,16 @@ class ConnectTest(LFCliBase): "current_flags": (0x1 + 0x80000000), "interest": (0x2 + 0x4000 + 0x800000) # current, dhcp, down, } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) time.sleep(0.5) - super().jsonPost("cli-json/set_port", portUpRequest(1, staName)) + super().json_post("cli-json/set_port", portUpRequest(1, staName)) reqURL = "cli-json/nc_show_ports" data = {"shelf": 1, "resource": 1, "port": staName, "probe_flags": 1} - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) time.sleep(0.5) waitUntilPortsAdminUp(1, mgrURL, [staName]) @@ -89,7 +89,7 @@ class ConnectTest(LFCliBase): maxTime = 300 ip = "0.0.0.0" while (ip == "0.0.0.0") and (duration < maxTime): - station_info = super().jsonGet(staNameUri + "?fields=port,ip") + station_info = super().json_get(staNameUri + "?fields=port,ip") LFUtils.debug_printer.pprint(station_info) if (station_info is not None) and ("interface" in station_info) and ("ip" in station_info["interface"]): ip = station_info["interface"]["ip"] @@ -127,7 +127,7 @@ class ConnectTest(LFCliBase): "url_rate": 600, "url": "dl http://10.40.0.1/ /dev/null" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create cx for l4_endp @@ -138,7 +138,7 @@ class ConnectTest(LFCliBase): "tx_endp": "l4Test", "rx_endp": "NA" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create fileio endpoint @@ -151,7 +151,7 @@ class ConnectTest(LFCliBase): "type": "fe_nfs", "directory": "/mnt/fe-test" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create fileio cx @@ -162,7 +162,7 @@ class ConnectTest(LFCliBase): "tx_endp": "fioTest", "rx_endp": "NA" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create generic endpoints @@ -183,7 +183,7 @@ class ConnectTest(LFCliBase): "tx_endp": "genTest1", "rx_endp": "genTest2" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create redirects for wanlink @@ -194,7 +194,7 @@ class ConnectTest(LFCliBase): "port": "rdd0", "peer_ifname": "rdd1" } - super().jsonPost(url, data) + super().json_post(url, data) url = "cli-json/add_rdd" data = { @@ -203,7 +203,7 @@ class ConnectTest(LFCliBase): "port": "rdd1", "peer_ifname": "rdd0" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # reset redirect ports @@ -213,7 +213,7 @@ class ConnectTest(LFCliBase): "resource": 1, "port": "rdd0" } - super().jsonPost(url, data) + super().json_post(url, data) url = "cli-json/reset_port" data = { @@ -221,7 +221,7 @@ class ConnectTest(LFCliBase): "resource": 1, "port": "rdd1" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create wanlink endpoints @@ -234,7 +234,7 @@ class ConnectTest(LFCliBase): "latency": 20, "max_rate": 1544000 } - super().jsonPost(url, data) + super().json_post(url, data) url = "cli-json/add_wl_endp" data = { @@ -245,7 +245,7 @@ class ConnectTest(LFCliBase): "latency": 30, "max_rate": 1544000 } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.05) # create wanlink cx @@ -256,7 +256,7 @@ class ConnectTest(LFCliBase): "tx_endp": "wlan0", "rx_endp": "wlan1" } - super().jsonPost(url, data) + super().json_post(url, data) time.sleep(.5) cxNames = ["testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlan0"] @@ -264,14 +264,14 @@ class ConnectTest(LFCliBase): # get data before running traffic try: get_info = {} - get_info['testTCPA'] = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes") - get_info['testTCPB'] = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes") - get_info['testUDPA'] = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes") - get_info['testUDPB'] = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes") - get_info['l4Test'] = super().jsonGet("layer4/l4Test?fields=bytes-rd") - get_info['genTest1'] = super().jsonGet("generic/genTest1?fields=last+results") - get_info['wlan0'] = super().jsonGet("wl_ep/wlan0") - get_info['wlan1'] = super().jsonGet("wl_ep/wlan1") + get_info['testTCPA'] = super().json_get("endp/testTCP-A?fields=tx+bytes,rx+bytes") + get_info['testTCPB'] = super().json_get("endp/testTCP-B?fields=tx+bytes,rx+bytes") + get_info['testUDPA'] = super().json_get("endp/testUDP-A?fields=tx+bytes,rx+bytes") + get_info['testUDPB'] = super().json_get("endp/testUDP-B?fields=tx+bytes,rx+bytes") + get_info['l4Test'] = super().json_get("layer4/l4Test?fields=bytes-rd") + get_info['genTest1'] = super().json_get("generic/genTest1?fields=last+results") + get_info['wlan0'] = super().json_get("wl_ep/wlan0") + get_info['wlan1'] = super().json_get("wl_ep/wlan1") for name in get_info: if 'endpoint' not in name: @@ -383,32 +383,32 @@ class ConnectTest(LFCliBase): print("Collecting Data") try: - ptestTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes") + ptestTCPA = super().json_get("endp/testTCP-A?fields=tx+bytes,rx+bytes") ptestTCPATX = ptestTCPA['endpoint']['tx bytes'] ptestTCPARX = ptestTCPA['endpoint']['rx bytes'] - ptestTCPB = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes") + ptestTCPB = super().json_get("endp/testTCP-B?fields=tx+bytes,rx+bytes") ptestTCPBTX = ptestTCPB['endpoint']['tx bytes'] ptestTCPBRX = ptestTCPB['endpoint']['rx bytes'] - ptestUDPA = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes") + ptestUDPA = super().json_get("endp/testUDP-A?fields=tx+bytes,rx+bytes") ptestUDPATX = ptestUDPA['endpoint']['tx bytes'] ptestUDPARX = ptestUDPA['endpoint']['rx bytes'] - ptestUDPB = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes") + ptestUDPB = super().json_get("endp/testUDP-B?fields=tx+bytes,rx+bytes") ptestUDPBTX = ptestUDPB['endpoint']['tx bytes'] ptestUDPBRX = ptestUDPB['endpoint']['rx bytes'] - pl4Test = super().jsonGet("layer4/l4Test?fields=bytes-rd") + pl4Test = super().json_get("layer4/l4Test?fields=bytes-rd") pl4TestBR = pl4Test['endpoint']['bytes-rd'] - pgenTest1 = super().jsonGet("generic/genTest1?fields=last+results") + pgenTest1 = super().json_get("generic/genTest1?fields=last+results") pgenTest1LR = pgenTest1['endpoint']['last results'] - pwlan0 = super().jsonGet("wl_ep/wlan0") + pwlan0 = super().json_get("wl_ep/wlan0") pwlan0TXB = pwlan0['endpoint']['tx bytes'] pwlan0RXP = pwlan0['endpoint']['rx pkts'] - pwlan1 = super().jsonGet("wl_ep/wlan1") + pwlan1 = super().json_get("wl_ep/wlan1") pwlan1TXB = pwlan1['endpoint']['tx bytes'] pwlan1RXP = pwlan1['endpoint']['rx pkts'] except Exception as e: @@ -421,7 +421,7 @@ class ConnectTest(LFCliBase): "resource": 1, "port": staName } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) endpNames = ["testTCP-A", "testTCP-B", "testUDP-A", "testUDP-B", diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 5b4b89be..a2e8c9a7 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -19,7 +19,7 @@ class LFCliBase: self.haltOnError = _halt_on_error self.mgr_url = "http://%s:%s/" % (self.lfjson_host, self.lfjson_port) - def jsonPost(self, _req_url, _data): + def json_post(self, _req_url, _data): json_response = None if self.mgr_url.endswith('/') and _req_url.startswith('/'): _req_url = _req_url[1:] @@ -42,7 +42,7 @@ class LFCliBase: return json_response - def jsonGet(self, _req_url): + def json_get(self, _req_url): json_response = None if self.mgr_url.endswith('/') and _req_url.startswith('/'): _req_url = _req_url[1:] @@ -71,15 +71,15 @@ class LFCliBase: #else: # print("continuing...") - def checkConnect(self): + def check_connect(self): print(f"Checking for LANforge GUI connection: {self.mgr_url}") - response = self.jsonGet("/") + response = self.json_get("/") 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("") + response = self.json_get("") if duration >= 300: print("Could not connect to LANforge GUI") diff --git a/py-json/generic_cx.py b/py-json/generic_cx.py index ca64aa04..7bd57928 100755 --- a/py-json/generic_cx.py +++ b/py-json/generic_cx.py @@ -21,7 +21,7 @@ class GenericCx(LFCliBase): "port": port, "type": type } - super().jsonPost("cli-json/add_gen_endp", data) + super().json_post("cli-json/add_gen_endp", data) def setFlags(self, endpName, flagName, val): data = { @@ -29,11 +29,11 @@ class GenericCx(LFCliBase): "flag": flagName, "val": val } - super().jsonPost("cli-json/set_endp_flag", data) + super().json_post("cli-json/set_endp_flag", data) def setCmd(self, endpName, cmd): data = { "name": endpName, "command": cmd } - super().jsonPost("cli-json/set_gen_cmd", data) + super().json_post("cli-json/set_gen_cmd", data) diff --git a/py-scripts/sta_connect.py b/py-scripts/sta_connect.py index 5fd9d352..a237e776 100755 --- a/py-scripts/sta_connect.py +++ b/py-scripts/sta_connect.py @@ -67,8 +67,8 @@ class StaConnect(LFCliBase): print("FAILED: %s did not report traffic: %s" % (name, postVal)) def run(self): - self.checkConnect() - eth1IP = self.jsonGet(self.getUpstreamUrl()) + self.check_connect() + eth1IP = self.json_get(self.getUpstreamUrl()) if eth1IP is None: print("Unable to query "+self.upstream_port+", bye") sys.exit(1) @@ -76,7 +76,7 @@ class StaConnect(LFCliBase): print(f"Warning: {self.getUpstreamUrl()} lacks ip address") url = self.getStaUrl() - response = super().jsonGet(url) + response = super().json_get(url) if response is not None: if response["interface"] is not None: print("removing old station") @@ -101,7 +101,7 @@ class StaConnect(LFCliBase): "flags": flags # verbose, wpa2 } print("Adding new station %s " % self.sta_name) - super().jsonPost(url, data) + super().json_post(url, data) reqURL = "cli-json/set_port" data = { @@ -112,14 +112,14 @@ class StaConnect(LFCliBase): "interest": 0x4002 # set dhcp, current flags } print("Configuring %s..." % self.sta_name) - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) reqURL = "cli-json/nc_show_ports" data = {"shelf": 1, "resource": self.resource, "port": self.sta_name, "probe_flags": 1} - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) LFUtils.waitUntilPortsAdminUp(self.resource, self.mgr_url, [self.sta_name]) # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) @@ -130,7 +130,7 @@ class StaConnect(LFCliBase): while (ip == "0.0.0.0") and (duration < maxTime): duration += 2 time.sleep(2) - station_info = super().jsonGet(f"{self.getStaUrl()}?fields=port,ip,ap") + station_info = super().json_get(f"{self.getStaUrl()}?fields=port,ip,ap") # LFUtils.debug_printer.pprint(station_info) if (station_info is not None) and ("interface" in station_info): @@ -176,7 +176,7 @@ class StaConnect(LFCliBase): "ip_port": "-1", "min_rate": 1000000 } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) reqURL = "cli-json/add_endp" data = { @@ -188,7 +188,7 @@ class StaConnect(LFCliBase): "ip_port": "-1", "min_rate": 1000000 } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # Create CX reqURL = "cli-json/add_cx" @@ -198,7 +198,7 @@ class StaConnect(LFCliBase): "tx_endp": "testUDP-A", "rx_endp": "testUDP-B", } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # Create TCP endpoints reqURL = "cli-json/add_endp" @@ -211,7 +211,7 @@ class StaConnect(LFCliBase): "ip_port": "0", "min_rate": 1000000 } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) reqURL = "cli-json/add_endp" data = { @@ -223,7 +223,7 @@ class StaConnect(LFCliBase): "ip_port": "-1", "min_rate": 1000000 } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # Create CX reqURL = "cli-json/add_cx" @@ -233,7 +233,7 @@ class StaConnect(LFCliBase): "tx_endp": "testTCP-A", "rx_endp": "testTCP-B", } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) cxNames = ["testTCP", "testUDP"] endpNames = ["testTCP-A", "testTCP-B", @@ -248,7 +248,7 @@ class StaConnect(LFCliBase): "cx_name": cxNames[name], "cx_state": "RUNNING" } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # Refresh stats print("\nRefresh CX stats") @@ -258,7 +258,7 @@ class StaConnect(LFCliBase): "test_mgr": "ALL", "cross_connect": cxNames[name] } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # print("Sleeping for 15 seconds") time.sleep(15) @@ -272,7 +272,7 @@ class StaConnect(LFCliBase): "cx_name": cxNames[name], "cx_state": "STOPPED" } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # Refresh stats print("\nRefresh CX stats") @@ -282,7 +282,7 @@ class StaConnect(LFCliBase): "test_mgr": "ALL", "cross_connect": cxNames[name] } - super().jsonPost(reqURL, data) + super().json_post(reqURL, data) # print("Sleeping for 5 seconds") time.sleep(5) @@ -290,19 +290,19 @@ class StaConnect(LFCliBase): # get data for endpoints JSON print("Collecting Data") try: - ptestTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes") + ptestTCPA = super().json_get("endp/testTCP-A?fields=tx+bytes,rx+bytes") ptestTCPATX = ptestTCPA['endpoint']['tx bytes'] ptestTCPARX = ptestTCPA['endpoint']['rx bytes'] - ptestTCPB = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes") + ptestTCPB = super().json_get("endp/testTCP-B?fields=tx+bytes,rx+bytes") ptestTCPBTX = ptestTCPB['endpoint']['tx bytes'] ptestTCPBRX = ptestTCPB['endpoint']['rx bytes'] - ptestUDPA = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes") + ptestUDPA = super().json_get("endp/testUDP-A?fields=tx+bytes,rx+bytes") ptestUDPATX = ptestUDPA['endpoint']['tx bytes'] ptestUDPARX = ptestUDPA['endpoint']['rx bytes'] - ptestUDPB = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes") + ptestUDPB = super().json_get("endp/testUDP-B?fields=tx+bytes,rx+bytes") ptestUDPBTX = ptestUDPB['endpoint']['tx bytes'] ptestUDPBRX = ptestUDPB['endpoint']['rx bytes'] except Exception as e: @@ -316,7 +316,7 @@ class StaConnect(LFCliBase): "port": self.sta_name } - self.jsonPost(reqURL, data) + self.json_post(reqURL, data) removeCX(self.mgr_url, cxNames) removeEndps(self.mgr_url, endpNames)