mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 04:07:52 +00:00
sta_connect2: Cleanup whitespace
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
@@ -15,7 +15,6 @@ if sys.version_info[0] != 3:
|
|||||||
print("This script requires Python 3")
|
print("This script requires Python 3")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||||
|
|
||||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||||
@@ -68,7 +67,7 @@ class StaConnect2(LFCliBase):
|
|||||||
self.upstream_url = None # defer construction
|
self.upstream_url = None # defer construction
|
||||||
self.station_names = []
|
self.station_names = []
|
||||||
if _sta_name is not None:
|
if _sta_name is not None:
|
||||||
self.station_names = [ _sta_name ]
|
self.station_names = [_sta_name]
|
||||||
self.sta_prefix = _sta_prefix
|
self.sta_prefix = _sta_prefix
|
||||||
self.bringup_time_sec = _bringup_time_sec
|
self.bringup_time_sec = _bringup_time_sec
|
||||||
# self.localrealm :Realm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6
|
# self.localrealm :Realm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6
|
||||||
@@ -117,23 +116,23 @@ class StaConnect2(LFCliBase):
|
|||||||
counter = 0
|
counter = 0
|
||||||
# print("there are %d results" % len(self.station_results))
|
# print("there are %d results" % len(self.station_results))
|
||||||
fields = "_links,port,alias,ip,ap,port+type"
|
fields = "_links,port,alias,ip,ap,port+type"
|
||||||
self.station_results = self.localrealm.find_ports_like("%s*"%self.sta_prefix, fields, debug_=False)
|
self.station_results = self.localrealm.find_ports_like("%s*" % self.sta_prefix, fields, debug_=False)
|
||||||
if (self.station_results is None) or (len(self.station_results) < 1):
|
if (self.station_results is None) or (len(self.station_results) < 1):
|
||||||
self.get_failed_result_list()
|
self.get_failed_result_list()
|
||||||
for eid,record in self.station_results.items():
|
for eid, record in self.station_results.items():
|
||||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
# print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||||
#pprint(eid)
|
# pprint(eid)
|
||||||
#pprint(record)
|
# pprint(record)
|
||||||
if record["ap"] == bssid:
|
if record["ap"] == bssid:
|
||||||
counter += 1
|
counter += 1
|
||||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
# print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||||
return counter
|
return counter
|
||||||
|
|
||||||
def clear_test_results(self):
|
def clear_test_results(self):
|
||||||
self.resulting_stations = {}
|
self.resulting_stations = {}
|
||||||
self.resulting_endpoints = {}
|
self.resulting_endpoints = {}
|
||||||
super().clear_test_results()
|
super().clear_test_results()
|
||||||
#super(StaConnect, self).clear_test_results().test_results.clear()
|
# super(StaConnect, self).clear_test_results().test_results.clear()
|
||||||
|
|
||||||
def setup(self, extra_securities=[]):
|
def setup(self, extra_securities=[]):
|
||||||
self.clear_test_results()
|
self.clear_test_results()
|
||||||
@@ -181,7 +180,8 @@ class StaConnect2(LFCliBase):
|
|||||||
for security in extra_securities:
|
for security in extra_securities:
|
||||||
self.station_profile.add_security_extra(security=security)
|
self.station_profile.add_security_extra(security=security)
|
||||||
print("Adding new stations ", end="")
|
print("Adding new stations ", end="")
|
||||||
self.station_profile.create(radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug, suppress_related_commands_=True)
|
self.station_profile.create(radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug,
|
||||||
|
suppress_related_commands_=True)
|
||||||
LFUtils.wait_until_ports_appear(self.lfclient_url, self.station_names, debug=self.debug)
|
LFUtils.wait_until_ports_appear(self.lfclient_url, self.station_names, debug=self.debug)
|
||||||
|
|
||||||
# Create UDP endpoints
|
# Create UDP endpoints
|
||||||
@@ -192,9 +192,9 @@ class StaConnect2(LFCliBase):
|
|||||||
self.l3_udp_profile.side_b_min_pdu = 1500
|
self.l3_udp_profile.side_b_min_pdu = 1500
|
||||||
self.l3_udp_profile.report_timer = 1000
|
self.l3_udp_profile.report_timer = 1000
|
||||||
self.l3_udp_profile.name_prefix = "udp"
|
self.l3_udp_profile.name_prefix = "udp"
|
||||||
port_list = list(self.localrealm.find_ports_like("%s+"%self.sta_prefix))
|
port_list = list(self.localrealm.find_ports_like("%s+" % self.sta_prefix))
|
||||||
if (port_list is None) or (len(port_list) < 1):
|
if (port_list is None) or (len(port_list) < 1):
|
||||||
raise ValueError("Unable to find ports named '%s'+"%self.sta_prefix)
|
raise ValueError("Unable to find ports named '%s'+" % self.sta_prefix)
|
||||||
self.l3_udp_profile.create(endp_type="lf_udp",
|
self.l3_udp_profile.create(endp_type="lf_udp",
|
||||||
side_a=port_list,
|
side_a=port_list,
|
||||||
side_b="%d.%s" % (self.resource, self.upstream_port),
|
side_b="%d.%s" % (self.resource, self.upstream_port),
|
||||||
@@ -207,7 +207,7 @@ class StaConnect2(LFCliBase):
|
|||||||
self.l3_tcp_profile.name_prefix = "tcp"
|
self.l3_tcp_profile.name_prefix = "tcp"
|
||||||
self.l3_tcp_profile.report_timer = 1000
|
self.l3_tcp_profile.report_timer = 1000
|
||||||
self.l3_tcp_profile.create(endp_type="lf_tcp",
|
self.l3_tcp_profile.create(endp_type="lf_tcp",
|
||||||
side_a=list(self.localrealm.find_ports_like("%s+"%self.sta_prefix)),
|
side_a=list(self.localrealm.find_ports_like("%s+" % self.sta_prefix)),
|
||||||
side_b="%d.%s" % (self.resource, self.upstream_port),
|
side_b="%d.%s" % (self.resource, self.upstream_port),
|
||||||
suppress_related_commands=True)
|
suppress_related_commands=True)
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ class StaConnect2(LFCliBase):
|
|||||||
else:
|
else:
|
||||||
connected_stations[sta_name] = sta_url
|
connected_stations[sta_name] = sta_url
|
||||||
data = {
|
data = {
|
||||||
"shelf":1,
|
"shelf": 1,
|
||||||
"resource": self.resource,
|
"resource": self.resource,
|
||||||
"port": "ALL",
|
"port": "ALL",
|
||||||
"probe_flags": 1
|
"probe_flags": 1
|
||||||
@@ -295,13 +295,14 @@ class StaConnect2(LFCliBase):
|
|||||||
print(" %s +AP %s, " % (sta_name, ap), end="")
|
print(" %s +AP %s, " % (sta_name, ap), end="")
|
||||||
if self.dut_bssid != "":
|
if self.dut_bssid != "":
|
||||||
if self.dut_bssid.lower() == ap.lower():
|
if self.dut_bssid.lower() == ap.lower():
|
||||||
self._pass(sta_name+" connected to BSSID: " + ap)
|
self._pass(sta_name + " connected to BSSID: " + ap)
|
||||||
# self.test_results.append("PASSED: )
|
# self.test_results.append("PASSED: )
|
||||||
# print("PASSED: Connected to BSSID: "+ap)
|
# print("PASSED: Connected to BSSID: "+ap)
|
||||||
else:
|
else:
|
||||||
self._fail("%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap))
|
self._fail(
|
||||||
|
"%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap))
|
||||||
else:
|
else:
|
||||||
self._fail(sta_name+" did not connect to AP")
|
self._fail(sta_name + " did not connect to AP")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if ip == "0.0.0.0":
|
if ip == "0.0.0.0":
|
||||||
@@ -326,7 +327,7 @@ class StaConnect2(LFCliBase):
|
|||||||
|
|
||||||
def collect_endp_stats(self, endp_map):
|
def collect_endp_stats(self, endp_map):
|
||||||
print("Collecting Data")
|
print("Collecting Data")
|
||||||
fields="/all"
|
fields = "/all"
|
||||||
for (cx_name, endps) in endp_map.items():
|
for (cx_name, endps) in endp_map.items():
|
||||||
try:
|
try:
|
||||||
endp_url = "/endp/%s%s" % (endps[0], fields)
|
endp_url = "/endp/%s%s" % (endps[0], fields)
|
||||||
@@ -335,7 +336,7 @@ class StaConnect2(LFCliBase):
|
|||||||
ptest_a_tx = endp_json['endpoint']['tx bytes']
|
ptest_a_tx = endp_json['endpoint']['tx bytes']
|
||||||
ptest_a_rx = endp_json['endpoint']['rx bytes']
|
ptest_a_rx = endp_json['endpoint']['rx bytes']
|
||||||
|
|
||||||
#ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"])
|
# ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"])
|
||||||
endp_url = "/endp/%s%s" % (endps[1], fields)
|
endp_url = "/endp/%s%s" % (endps[1], fields)
|
||||||
endp_json = self.json_get(endp_url)
|
endp_json = self.json_get(endp_url)
|
||||||
self.resulting_endpoints[endp_url] = endp_json
|
self.resulting_endpoints[endp_url] = endp_json
|
||||||
@@ -352,7 +353,6 @@ class StaConnect2(LFCliBase):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.error(e)
|
self.error(e)
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
# stop cx traffic
|
# stop cx traffic
|
||||||
print("Stopping CX Traffic")
|
print("Stopping CX Traffic")
|
||||||
@@ -386,7 +386,8 @@ class StaConnect2(LFCliBase):
|
|||||||
for (cx_name, endp_names) in self.l3_tcp_profile.created_cx.items():
|
for (cx_name, endp_names) in self.l3_tcp_profile.created_cx.items():
|
||||||
curr_endp_names.append(endp_names[0])
|
curr_endp_names.append(endp_names[0])
|
||||||
curr_endp_names.append(endp_names[1])
|
curr_endp_names.append(endp_names[1])
|
||||||
removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug)
|
removeEndps(self.lfclient_url, curr_endp_names, debug=self.debug)
|
||||||
|
|
||||||
|
|
||||||
# ~class
|
# ~class
|
||||||
|
|
||||||
@@ -420,11 +421,14 @@ Example:
|
|||||||
parser.add_argument("--dut_bssid", type=str, help="DUT BSSID to which we expect to connect.")
|
parser.add_argument("--dut_bssid", type=str, help="DUT BSSID to which we expect to connect.")
|
||||||
parser.add_argument("--debug", type=str, help="enable debugging")
|
parser.add_argument("--debug", type=str, help="enable debugging")
|
||||||
parser.add_argument("--prefix", type=str, help="Station prefix. Default: 'sta'", default='sta')
|
parser.add_argument("--prefix", type=str, help="Station prefix. Default: 'sta'", default='sta')
|
||||||
parser.add_argument("--bringup_time", type=int, help="Seconds to wait for stations to associate and aquire IP. Default: 300", default=300)
|
parser.add_argument("--bringup_time", type=int,
|
||||||
|
help="Seconds to wait for stations to associate and aquire IP. Default: 300", default=300)
|
||||||
parser.add_argument('--influx_user', help='Username for your Influx database', default=None)
|
parser.add_argument('--influx_user', help='Username for your Influx database', default=None)
|
||||||
parser.add_argument('--influx_passwd', help='Password for your Influx database', default=None)
|
parser.add_argument('--influx_passwd', help='Password for your Influx database', default=None)
|
||||||
parser.add_argument('--influx_db', help='Name of your Influx database', default=None)
|
parser.add_argument('--influx_db', help='Name of your Influx database', default=None)
|
||||||
parser.add_argument('--influx_host', help='Host of your influx database if different from the system you are running on', default='localhost')
|
parser.add_argument('--influx_host',
|
||||||
|
help='Host of your influx database if different from the system you are running on',
|
||||||
|
default='localhost')
|
||||||
parser.add_argument('--monitor_interval', help='How frequently you want to append to your database', default='5s')
|
parser.add_argument('--monitor_interval', help='How frequently you want to append to your database', default='5s')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@@ -433,7 +437,7 @@ Example:
|
|||||||
if args.port is not None:
|
if args.port is not None:
|
||||||
lfjson_port = args.port
|
lfjson_port = args.port
|
||||||
|
|
||||||
on_flags = [ 1, "1", "on", "yes", "true" ]
|
on_flags = [1, "1", "on", "yes", "true"]
|
||||||
debug_v = False
|
debug_v = False
|
||||||
if args.debug is not None:
|
if args.debug is not None:
|
||||||
if args.debug in on_flags:
|
if args.debug in on_flags:
|
||||||
@@ -441,10 +445,10 @@ Example:
|
|||||||
|
|
||||||
staConnect = StaConnect2(lfjson_host, lfjson_port,
|
staConnect = StaConnect2(lfjson_host, lfjson_port,
|
||||||
debug_=True,
|
debug_=True,
|
||||||
_influx_db = args.influx_db,
|
_influx_db=args.influx_db,
|
||||||
_influx_passwd = args.influx_passwd,
|
_influx_passwd=args.influx_passwd,
|
||||||
_influx_user = args.influx_user,
|
_influx_user=args.influx_user,
|
||||||
_influx_host = args.influx_host,
|
_influx_host=args.influx_host,
|
||||||
_exit_on_fail=True,
|
_exit_on_fail=True,
|
||||||
_exit_on_error=False)
|
_exit_on_error=False)
|
||||||
|
|
||||||
@@ -472,7 +476,7 @@ Example:
|
|||||||
staConnect.dut_security = args.dut_security
|
staConnect.dut_security = args.dut_security
|
||||||
if (args.prefix is not None) or (args.prefix != "sta"):
|
if (args.prefix is not None) or (args.prefix != "sta"):
|
||||||
staConnect.sta_prefix = args.prefix
|
staConnect.sta_prefix = args.prefix
|
||||||
staConnect.station_names = [ "%s0000"%args.prefix ]
|
staConnect.station_names = ["%s0000" % args.prefix]
|
||||||
staConnect.bringup_time_sec = args.bringup_time
|
staConnect.bringup_time_sec = args.bringup_time
|
||||||
|
|
||||||
# staConnect.cleanup()
|
# staConnect.cleanup()
|
||||||
@@ -492,6 +496,7 @@ Example:
|
|||||||
|
|
||||||
staConnect.cleanup()
|
staConnect.cleanup()
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user