diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index fe6ca76e..725af2fb 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -15,7 +15,7 @@ $ pip3 install pexpect-serial # For LANforge lab system. ./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action summary --prompt "\(Cisco Controller\) >" - +./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action cmd --value "show ap config general APA453.0E7B.CF9C" ''' diff --git a/py-json/realm.py b/py-json/realm.py index 271f9647..92129667 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -140,6 +140,8 @@ class Realm(LFCliBase): data["resource"] = eid[1] data["port"] = eid[2] self.json_post(req_url, data, debug_=True) #self.debug) + return True + return False def port_exists(self, port_eid): data = {} @@ -271,7 +273,7 @@ class Realm(LFCliBase): response = super().json_get("/cx") return response - def waitUntilEndpsAppear(self, these_endp): + def waitUntilEndpsAppear(self, these_endp, debug=False): wait_more = True; count = 0 while wait_more: @@ -286,7 +288,8 @@ class Realm(LFCliBase): for req in these_endp: if not req in found_endps: - print("Waiting on endpoint: %s"%(req)) + if debug: + print("Waiting on endpoint: %s"%(req)) wait_more = True count += 1 if (count > 100): @@ -294,7 +297,7 @@ class Realm(LFCliBase): return not wait_more - def waitUntilCxsAppear(self, these_cx): + def waitUntilCxsAppear(self, these_cx, debug=False): wait_more = True; count = 0 while wait_more: @@ -310,7 +313,8 @@ class Realm(LFCliBase): for req in these_cx: if not req in found_cxs: - print("Waiting on CX: %s"%(req)) + if debug: + print("Waiting on CX: %s"%(req)) wait_more = True count += 1 if (count > 100): @@ -448,7 +452,7 @@ class Realm(LFCliBase): def name_to_eid(self, eid): return LFUtils.name_to_eid(eid) - def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60): + def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60, debug=False): print("Waiting for ips, timeout: %i..."%(timeout_sec)) #print(station_list) @@ -460,7 +464,8 @@ class Realm(LFCliBase): wait_more = False for sta_eid in station_list: - print("checking sta-eid: %s"%(sta_eid)) + if debug: + print("checking sta-eid: %s"%(sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % @@ -477,19 +482,23 @@ class Realm(LFCliBase): v = response['interface'] if v['ip'] == '0.0.0.0': wait_more = True - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + if debug: + print("Waiting for port %s to get IPv4 Address."%(sta_eid)) else: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + if debug: + print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) if ipv6: v = response['interface'] print(v) if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ and v['ipv6 address'] != 'AUTO': - print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) + if debug: + print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) else: wait_more = True - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + if debug: + print("Waiting for port %s to get IPv6 Address."%(sta_eid)) if wait_more: time.sleep(1) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index e1b29203..70060777 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -16,9 +16,12 @@ from LANforge import LFUtils import realm import time import datetime +import subprocess +import re + class L3VariableTimeLongevity(LFCliBase): - def __init__(self, host, port, endp_types, tos, side_b, radios, radio_name_list, number_of_stations_per_radio_list, + def __init__(self, host, port, endp_types, args, tos, side_b, radios, radio_name_list, number_of_stations_per_radio_list, ssid_list, ssid_password_list, ssid_security_list, station_lists, name_prefix, debug_on, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, @@ -46,6 +49,7 @@ class L3VariableTimeLongevity(LFCliBase): self.multicast_profile = self.local_realm.new_multicast_profile() self.multicast_profile.name_prefix = "MLT-"; self.station_profiles = [] + self.args = args index = 0 for radio in radios: @@ -112,6 +116,38 @@ class L3VariableTimeLongevity(LFCliBase): print("new-list:",old_list) return False + def verify_controller(self): + if self.args == None: + return + + if self.args.cisco_ctlr == None: + return + + advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", "ssh", "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap, "--action", "summary"], capture_output=True) + pss = advanced.stdout.decode('utf-8', 'ignore'); + print(pss) + + # Find our station count + searchap = False + for line in pss.splitlines(): + if (line.startswith("---------")): + searchap = True + continue + + if (searchap): + pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+.* \S+\s+\S+\s+(\S+)\s+\["%(self.args.cisco_ap) + #print("AP line: %s"%(line)) + m = re.search(pat, line) + if (m != None): + sta_count = m.group(1) + print("AP line: %s"%(line)) + print("sta-count: %s"%(sta_count)) + if (sta_count != self.total_stas): + print("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas)) + + def start(self, print_pass=False, print_fail=False): print("Bringing up stations") up_request = self.local_realm.admin_up(self.side_b) @@ -130,6 +166,8 @@ class L3VariableTimeLongevity(LFCliBase): else: print("print failed to get IP's") + self.verify_controller() + print("Starting multicast traffic (if any configured)") self.multicast_profile.start_mc(debug_=self.debug) self.multicast_profile.refresh_mc(debug_=self.debug) @@ -177,9 +215,25 @@ class L3VariableTimeLongevity(LFCliBase): def pre_cleanup(self): self.cx_profile.cleanup_prefix() self.multicast_profile.cleanup_prefix() + self.total_stas = 0 for station_list in self.station_lists: for sta in station_list: self.local_realm.rm_port(sta, check_exists=True) + self.total_stas += 1 + + # Make sure they are gone + count = 0 + while (count < 10): + more = False + for station_list in self.station_lists: + for sta in station_list: + rv = self.local_realm.rm_port(sta, check_exists=True) + if (rv): + more = True + if not more: + break + count += 1 + time.sleep(5) def cleanup(self): self.cx_profile.cleanup() @@ -296,7 +350,13 @@ Note: multiple --radio switches may be entered up to the number of radios avai ''') - + + parser.add_argument('--cisco_ctlr', help='--cisco_ctlr ',default=None) + parser.add_argument('--cisco_user', help='--cisco_user ',default="admin") + parser.add_argument('--cisco_passwd', help='--cisco_passwd ',default="Cisco123") + parser.add_argument('--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") + parser.add_argument('--cisco_ap', help='--cisco_ap ',default="APA453.0E7B.CF9C") + parser.add_argument('--mgr', help='--mgr ',default='localhost') parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') parser.add_argument('--tos', help='--tos: Support different ToS settings: BK | BE | VI | VO | numeric',default="BE") @@ -369,8 +429,9 @@ Note: multiple --radio switches may be entered up to the number of radios avai #print("endp-types: %s"%(endp_types)) - ip_var_test = L3VariableTimeLongevity(lfjson_host, - lfjson_port, + ip_var_test = L3VariableTimeLongevity(lfjson_host, + lfjson_port, + args=args, number_template="00", station_lists= station_lists, name_prefix="LT-",