mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +00:00 
			
		
		
		
	sta_connect.py: passes sta_connect_example.py test
This commit is contained in:
		| @@ -59,8 +59,9 @@ class StaConnect(LFCliBase): | |||||||
|         if sta_name_ is None: |         if sta_name_ is None: | ||||||
|             raise ValueError("get_station_url wants a station name") |             raise ValueError("get_station_url wants a station name") | ||||||
|         if self.sta_url_map is None: |         if self.sta_url_map is None: | ||||||
|  |             self.sta_url_map = {} | ||||||
|             for sta_name in self.station_names: |             for sta_name in self.station_names: | ||||||
|                 self.sta_url_map[sta_name] = "port/1/%s/%s" % (self.resource, self.sta_name) |                 self.sta_url_map[sta_name] = "port/1/%s/%s" % (self.resource, sta_name) | ||||||
|         return self.sta_url_map[sta_name_] |         return self.sta_url_map[sta_name_] | ||||||
|  |  | ||||||
|     def getUpstreamUrl(self): |     def getUpstreamUrl(self): | ||||||
| @@ -97,8 +98,9 @@ class StaConnect(LFCliBase): | |||||||
|             if response is not None: |             if response is not None: | ||||||
|                 if response["interface"] is not None: |                 if response["interface"] is not None: | ||||||
|                     print("removing old station") |                     print("removing old station") | ||||||
|                     LFUtils.removePort(self.resource, self.sta_name, self.lfclient_url) |                     for sta_name in self.station_names: | ||||||
|                     LFUtils.waitUntilPortsDisappear(self.resource, self.lfclient_url, [self.sta_name]) |                         LFUtils.removePort(self.resource, sta_name, self.lfclient_url) | ||||||
|  |                     LFUtils.waitUntilPortsDisappear(self.resource, self.lfclient_url, self.station_names) | ||||||
|  |  | ||||||
|         # Create stations and turn dhcp on |         # Create stations and turn dhcp on | ||||||
|  |  | ||||||
| @@ -119,8 +121,8 @@ class StaConnect(LFCliBase): | |||||||
|             "flags": flags  # verbose, wpa2 |             "flags": flags  # verbose, wpa2 | ||||||
|         } |         } | ||||||
|         for sta_name in self.station_names: |         for sta_name in self.station_names: | ||||||
|             add_sta_data["sta_name"] = sta_name; |             add_sta_data["sta_name"] = sta_name | ||||||
|             print("Adding new station %s " % self.sta_name) |             print("Adding new station %s " % sta_name) | ||||||
|             self.json_post("/cli-json/add_sta", add_sta_data) |             self.json_post("/cli-json/add_sta", add_sta_data) | ||||||
|  |  | ||||||
|         set_port_data = { |         set_port_data = { | ||||||
| @@ -153,7 +155,7 @@ class StaConnect(LFCliBase): | |||||||
|             duration += 2 |             duration += 2 | ||||||
|             time.sleep(2) |             time.sleep(2) | ||||||
|             for sta_name in self.station_names: |             for sta_name in self.station_names: | ||||||
|                 sta_url = self.get_station_urls(sta_name) |                 sta_url = self.get_station_url(sta_name) | ||||||
|                 station_info = self.json_get(sta_url + "?fields=port,ip,ap") |                 station_info = self.json_get(sta_url + "?fields=port,ip,ap") | ||||||
|  |  | ||||||
|                 # LFUtils.debug_printer.pprint(station_info) |                 # LFUtils.debug_printer.pprint(station_info) | ||||||
| @@ -165,11 +167,11 @@ class StaConnect(LFCliBase): | |||||||
|  |  | ||||||
|                 if (ap == "Not-Associated") or (ap == ""): |                 if (ap == "Not-Associated") or (ap == ""): | ||||||
|                     if self.debugOn: |                     if self.debugOn: | ||||||
|                         print("Waiting for %s associate to AP [%s]..." % (self.sta_name, ap)) |                         print("Waiting for %s associate to AP [%s]..." % (sta_name, ap)) | ||||||
|                 else: |                 else: | ||||||
|                     if ip == "0.0.0.0": |                     if ip == "0.0.0.0": | ||||||
|                         if self.debugOn: |                         if self.debugOn: | ||||||
|                             print("Waiting for %s to gain IP ..." % self.sta_name) |                             print("Waiting for %s to gain IP ..." % sta_name) | ||||||
|                     else: |                     else: | ||||||
|                         connected_stations.append(sta_url) |                         connected_stations.append(sta_url) | ||||||
|  |  | ||||||
| @@ -232,7 +234,7 @@ class StaConnect(LFCliBase): | |||||||
|  |  | ||||||
|             # Create CX |             # Create CX | ||||||
|             data = { |             data = { | ||||||
|                 "alias": "testUDP-%" % sta_name, |                 "alias": "testUDP-%s" % sta_name, | ||||||
|                 "test_mgr": "default_tm", |                 "test_mgr": "default_tm", | ||||||
|                 "tx_endp": "testUDP-%s-A" % sta_name, |                 "tx_endp": "testUDP-%s-A" % sta_name, | ||||||
|                 "rx_endp": "testUDP-%s-B" % sta_name, |                 "rx_endp": "testUDP-%s-B" % sta_name, | ||||||
| @@ -268,14 +270,11 @@ class StaConnect(LFCliBase): | |||||||
|             data = { |             data = { | ||||||
|                 "alias": "testTCP-%s" % sta_name, |                 "alias": "testTCP-%s" % sta_name, | ||||||
|                 "test_mgr": "default_tm", |                 "test_mgr": "default_tm", | ||||||
|                 "tx_endp": "testTCP-A" % sta_name, |                 "tx_endp": "testTCP-%s-A" % sta_name, | ||||||
|                 "rx_endp": "testTCP-B" % sta_name, |                 "rx_endp": "testTCP-%s-B" % sta_name, | ||||||
|             } |             } | ||||||
|             self.json_post("/cli-json/add_cx", data) |             self.json_post("/cli-json/add_cx", data) | ||||||
|  |  | ||||||
|             #cxNames = ["testTCP", "testUDP"] |  | ||||||
|             #endpNames = ["testTCP-A", "testTCP-B", "testUDP-A", "testUDP-B"] |  | ||||||
|  |  | ||||||
|         # start cx traffic |         # start cx traffic | ||||||
|         print("\nStarting CX Traffic") |         print("\nStarting CX Traffic") | ||||||
|         for cx_name in cx_names.keys(): |         for cx_name in cx_names.keys(): | ||||||
| @@ -349,7 +348,8 @@ class StaConnect(LFCliBase): | |||||||
|         # print("\n") |         # print("\n") | ||||||
|  |  | ||||||
|         # remove all endpoints and cxs |         # remove all endpoints and cxs | ||||||
|         LFUtils.removePort(self.resource, self.sta_name, self.lfclient_url) |         for sta_name in self.station_names: | ||||||
|  |             LFUtils.removePort(self.resource, sta_name, self.lfclient_url) | ||||||
|         endp_names = [] |         endp_names = [] | ||||||
|         removeCX(self.lfclient_url, cx_names.keys()) |         removeCX(self.lfclient_url, cx_names.keys()) | ||||||
|         for cx_name in cx_names: |         for cx_name in cx_names: | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ if 'py-json' not in sys.path: | |||||||
|     sys.path.append('../py-json') |     sys.path.append('../py-json') | ||||||
|  |  | ||||||
| # if you lack __init__.py in this directory you will not find sta_connect module | # if you lack __init__.py in this directory you will not find sta_connect module | ||||||
|  | import sta_connect | ||||||
| from sta_connect import StaConnect | from sta_connect import StaConnect | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -21,8 +22,10 @@ def main(): | |||||||
|     staConnect.upstream_port = "eth1" |     staConnect.upstream_port = "eth1" | ||||||
|     staConnect.radio = "wiphy0" |     staConnect.radio = "wiphy0" | ||||||
|     staConnect.resource = 1 |     staConnect.resource = 1 | ||||||
|  |     staConnect.dut_security = sta_connect.WPA2 | ||||||
|     staConnect.dut_ssid = "jedway-wpa2-x2048-5-1" |     staConnect.dut_ssid = "jedway-wpa2-x2048-5-1" | ||||||
|     staConnect.dut_passwd = "jedway-wpa2-x2048-5-1" |     staConnect.dut_passwd = "jedway-wpa2-x2048-5-1" | ||||||
|  |     staConnect.station_names = [ "sta000" ] | ||||||
|     staConnect.run() |     staConnect.run() | ||||||
|     is_passing = staConnect.passes() |     is_passing = staConnect.passes() | ||||||
|     if is_passing == False: |     if is_passing == False: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jed Reynolds
					Jed Reynolds