mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
longevity: Fix initial port cleanup.
Quieten some output by default.
This commit is contained in:
@@ -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"
|
||||
'''
|
||||
|
||||
|
||||
|
||||
@@ -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,6 +288,7 @@ class Realm(LFCliBase):
|
||||
|
||||
for req in these_endp:
|
||||
if not req in found_endps:
|
||||
if debug:
|
||||
print("Waiting on endpoint: %s"%(req))
|
||||
wait_more = True
|
||||
count += 1
|
||||
@@ -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,6 +313,7 @@ class Realm(LFCliBase):
|
||||
|
||||
for req in these_cx:
|
||||
if not req in found_cxs:
|
||||
if debug:
|
||||
print("Waiting on CX: %s"%(req))
|
||||
wait_more = True
|
||||
count += 1
|
||||
@@ -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,6 +464,7 @@ class Realm(LFCliBase):
|
||||
wait_more = False
|
||||
|
||||
for sta_eid in station_list:
|
||||
if debug:
|
||||
print("checking sta-eid: %s"%(sta_eid))
|
||||
eid = self.name_to_eid(sta_eid)
|
||||
|
||||
@@ -477,8 +482,10 @@ class Realm(LFCliBase):
|
||||
v = response['interface']
|
||||
if v['ip'] == '0.0.0.0':
|
||||
wait_more = True
|
||||
if debug:
|
||||
print("Waiting for port %s to get IPv4 Address."%(sta_eid))
|
||||
else:
|
||||
if debug:
|
||||
print("Found IP: %s on port: %s"%(v['ip'], sta_eid))
|
||||
|
||||
if ipv6:
|
||||
@@ -486,9 +493,11 @@ class Realm(LFCliBase):
|
||||
print(v)
|
||||
if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \
|
||||
and v['ipv6 address'] != 'AUTO':
|
||||
if debug:
|
||||
print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid))
|
||||
else:
|
||||
wait_more = True
|
||||
if debug:
|
||||
print("Waiting for port %s to get IPv6 Address."%(sta_eid))
|
||||
|
||||
if wait_more:
|
||||
|
||||
@@ -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()
|
||||
@@ -297,6 +351,12 @@ Note: multiple --radio switches may be entered up to the number of radios avai
|
||||
''')
|
||||
|
||||
|
||||
parser.add_argument('--cisco_ctlr', help='--cisco_ctlr <IP of Cisco Controller>',default=None)
|
||||
parser.add_argument('--cisco_user', help='--cisco_user <User-name for Cisco Controller>',default="admin")
|
||||
parser.add_argument('--cisco_passwd', help='--cisco_passwd <Password for Cisco Controller>',default="Cisco123")
|
||||
parser.add_argument('--cisco_prompt', help='--cisco_prompt <Prompt for Cisco Controller>',default="\(Cisco Controller\) >")
|
||||
parser.add_argument('--cisco_ap', help='--cisco_ap <Cisco AP in question>',default="APA453.0E7B.CF9C")
|
||||
|
||||
parser.add_argument('--mgr', help='--mgr <hostname for where LANforge GUI is running>',default='localhost')
|
||||
parser.add_argument('-d','--test_duration', help='--test_duration <how long to run> 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")
|
||||
@@ -371,6 +431,7 @@ Note: multiple --radio switches may be entered up to the number of radios avai
|
||||
|
||||
ip_var_test = L3VariableTimeLongevity(lfjson_host,
|
||||
lfjson_port,
|
||||
args=args,
|
||||
number_template="00",
|
||||
station_lists= station_lists,
|
||||
name_prefix="LT-",
|
||||
|
||||
Reference in New Issue
Block a user