mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
lf_cleanup.py iterates over the individual cxs, endp, and stations
test_l3_longevity.py : comment on channel width Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
@@ -29,20 +29,88 @@ Realm = realm.Realm
|
|||||||
class lf_clean(Realm):
|
class lf_clean(Realm):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
host="localhost",
|
host="localhost",
|
||||||
port=8080):
|
port=8080,
|
||||||
|
clean_cxs=None,
|
||||||
|
clean_endp=None,
|
||||||
|
clean_sta=None):
|
||||||
super().__init__(lfclient_host=host,
|
super().__init__(lfclient_host=host,
|
||||||
lfclient_port=port),
|
lfclient_port=port),
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
|
self.clean_cxs = clean_cxs
|
||||||
|
self.clean_endp = clean_endp
|
||||||
|
self.clean_sta = clean_sta
|
||||||
|
self.cxs_done = False
|
||||||
|
self.endp_done = False
|
||||||
|
self.sta_done = False
|
||||||
|
|
||||||
def cleanup(self):
|
def cxs_clean(self):
|
||||||
|
still_looking_cxs = True
|
||||||
|
iterations_cxs = 1
|
||||||
|
while still_looking_cxs and iterations_cxs <= 10:
|
||||||
|
iterations_cxs += 1
|
||||||
|
print("cxs_clean: iterations_cxs: {iterations_cxs}".format(iterations_cxs=iterations_cxs))
|
||||||
|
cx_json = super().json_get("cx")
|
||||||
|
if cx_json is not None:
|
||||||
|
print("Removing old cross connects")
|
||||||
|
for name in list(cx_json):
|
||||||
|
if name != 'handler' and name != 'uri':
|
||||||
|
# print(name)
|
||||||
|
req_url = "cli-json/rm_cx"
|
||||||
|
data = {
|
||||||
|
"test_mgr": "default_tm",
|
||||||
|
"cx_name": name
|
||||||
|
}
|
||||||
|
super().json_post(req_url, data)
|
||||||
|
time.sleep(.5)
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
print("No cross connects found to cleanup")
|
||||||
|
still_looking_cxs = False
|
||||||
|
print("clean_cxs still_looking_cxs {cxs_looking}".format(cxs_looking=still_looking_cxs))
|
||||||
|
if not still_looking_cxs:
|
||||||
|
self.cxs_done = True
|
||||||
|
return still_looking_cxs
|
||||||
|
|
||||||
|
def endp_clean(self):
|
||||||
|
still_looking_endp = True
|
||||||
|
iterations_endp = 0
|
||||||
|
while still_looking_endp and iterations_endp <= 10:
|
||||||
|
iterations_endp += 1
|
||||||
|
print("endp_clean: iterations_endp: {iterations_endp}".format(iterations_endp=iterations_endp))
|
||||||
|
# get and remove current endps
|
||||||
|
endp_json = super().json_get("endp")
|
||||||
|
if endp_json is not None:
|
||||||
|
print("Removing old endpoints")
|
||||||
|
for name in list(endp_json['endpoint']):
|
||||||
|
# print(list(name)[0])
|
||||||
|
req_url = "cli-json/rm_endp"
|
||||||
|
data = {
|
||||||
|
"endp_name": list(name)[0]
|
||||||
|
}
|
||||||
|
# print(data)
|
||||||
|
super().json_post(req_url, data)
|
||||||
|
time.sleep(.5)
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
print("No endpoints found to cleanup")
|
||||||
|
still_looking_endp = False
|
||||||
|
print("clean_endp still_looking_endp {ednp_looking}".format(ednp_looking=still_looking_endp))
|
||||||
|
if not still_looking_endp:
|
||||||
|
self.endp_done = True
|
||||||
|
return still_looking_endp
|
||||||
|
|
||||||
|
def sta_clean(self):
|
||||||
|
still_looking_sta = True
|
||||||
|
iterations_sta = 0
|
||||||
|
while still_looking_sta and iterations_sta <= 10:
|
||||||
|
iterations_sta += 1
|
||||||
|
print("sta_clean: iterations_sta: {iterations_sta}".format(iterations_sta=iterations_sta))
|
||||||
try:
|
try:
|
||||||
sta_json = super().json_get(
|
sta_json = super().json_get(
|
||||||
"port/1/1/list?field=alias")['interfaces']
|
"port/1/1/list?field=alias")['interfaces']
|
||||||
except TypeError:
|
except TypeError:
|
||||||
sta_json = None
|
sta_json = None
|
||||||
cx_json = super().json_get("cx")
|
|
||||||
endp_json = super().json_get("endp")
|
|
||||||
|
|
||||||
# get and remove current stations
|
# get and remove current stations
|
||||||
if sta_json is not None:
|
if sta_json is not None:
|
||||||
@@ -83,41 +151,37 @@ class lf_clean(Realm):
|
|||||||
# print(data)
|
# print(data)
|
||||||
super().json_post(req_url, data)
|
super().json_post(req_url, data)
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("No stations found to cleanup")
|
print("No stations found to cleanup")
|
||||||
|
still_looking_sta = False
|
||||||
|
print("clean_sta still_looking_sta {sta_looking}".format(sta_looking=still_looking_sta))
|
||||||
|
if not still_looking_sta:
|
||||||
|
self.sta_done = True
|
||||||
|
return still_looking_sta
|
||||||
|
|
||||||
# get and remove current cxs
|
|
||||||
if cx_json is not None:
|
|
||||||
print("Removing old cross connects")
|
|
||||||
for name in list(cx_json):
|
|
||||||
if name != 'handler' and name != 'uri':
|
|
||||||
# print(name)
|
|
||||||
req_url = "cli-json/rm_cx"
|
|
||||||
data = {
|
|
||||||
"test_mgr": "default_tm",
|
|
||||||
"cx_name": name
|
|
||||||
}
|
|
||||||
super().json_post(req_url, data)
|
|
||||||
time.sleep(.5)
|
|
||||||
else:
|
|
||||||
print("No cross connects found to cleanup")
|
|
||||||
|
|
||||||
# get and remove current endps
|
'''
|
||||||
if endp_json is not None:
|
1: delete cx
|
||||||
print("Removing old endpoints")
|
2: delete endp
|
||||||
for name in list(endp_json['endpoint']):
|
3: delete sta
|
||||||
# print(list(name)[0])
|
when deleting sta first, you will end up with phantom CX
|
||||||
req_url = "cli-json/rm_endp"
|
'''
|
||||||
data = {
|
def cleanup(self):
|
||||||
"endp_name": list(name)[0]
|
if self.clean_cxs:
|
||||||
}
|
# also clean the endp when cleaning cxs
|
||||||
# print(data)
|
still_looking_cxs = self.cxs_clean()
|
||||||
super().json_post(req_url, data)
|
still_looking_endp = self.endp_clean()
|
||||||
time.sleep(.5)
|
print("clean_cxs: still_looking_cxs {looking_cxs} still_looking_endp {looking_endp}"\
|
||||||
else:
|
.format(looking_cxs=still_looking_cxs,looking_endp=still_looking_endp))
|
||||||
print("No endpoints found to cleanup")
|
if self.clean_endp and not clean_cxs:
|
||||||
|
still_looking_endp = self.endp_clean()
|
||||||
|
print("clean_endp: still_looking_endp {looking_endp}".format(looking_endp=still_looking_endp))
|
||||||
|
|
||||||
|
if self.clean_sta:
|
||||||
|
still_looking_sta = self.sta_clean()
|
||||||
|
print("clean_sta: still_looking_sta {looking_sta}".format(looking_sta=still_looking_sta))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
@@ -145,15 +209,36 @@ python3 ./lf_clean.py --mgr MGR
|
|||||||
'--lfmgr',
|
'--lfmgr',
|
||||||
help='--mgr <hostname for where LANforge GUI is running>',
|
help='--mgr <hostname for where LANforge GUI is running>',
|
||||||
default='localhost')
|
default='localhost')
|
||||||
|
parser.add_argument(
|
||||||
|
'--cxs',
|
||||||
|
help="--cxs, this will clear all the endps and cxs",
|
||||||
|
action='store_true')
|
||||||
|
parser.add_argument(
|
||||||
|
'--endp',
|
||||||
|
help="--endp, this will clear all the endps",
|
||||||
|
action='store_true')
|
||||||
|
parser.add_argument(
|
||||||
|
'--sta',
|
||||||
|
help="--sta, this will clear all the stations",
|
||||||
|
action='store_true')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
if args.cxs or args.endp or args.sta:
|
||||||
clean = lf_clean(host=args.mgr)
|
clean = lf_clean(host=args.mgr,clean_cxs=args.cxs,clean_endp=args.endp,clean_sta=args.sta )
|
||||||
print("cleaning up stations, cxs and endpoints: start")
|
print("cleaning cxs: {cxs} endpoints: {endp} stations: {sta} start".format(cxs=args.cxs,endp=args.endp,sta=args.sta))
|
||||||
clean.cleanup()
|
if args.cxs:
|
||||||
print("cleaning up stations, cxs and endpoints:\
|
print("cleaning cxs will also clean endp")
|
||||||
done with current pass may need to iterate multiple times")
|
clean.cxs_clean()
|
||||||
|
clean.endp_clean()
|
||||||
|
if args.endp and not args.cxs:
|
||||||
|
clean.endp_clean()
|
||||||
|
if args.sta:
|
||||||
|
clean.sta_clean()
|
||||||
|
print("Clean done")
|
||||||
|
# print("Clean cxs_done {cxs_done} endp_done {endp_done} sta_done {sta_done}"
|
||||||
|
# .format(cxs_done=clean.cxs_done,endp_done=clean.endp_done,sta_done=clean.sta_done))
|
||||||
|
else:
|
||||||
|
print("please add option of --cxs ,--endp, or --sta to clean")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -274,6 +274,9 @@ class L3VariableTime(Realm):
|
|||||||
self.station_profile.security = ssid_security_
|
self.station_profile.security = ssid_security_
|
||||||
self.station_profile.number_template = self.number_template
|
self.station_profile.number_template = self.number_template
|
||||||
self.station_profile.mode = 0
|
self.station_profile.mode = 0
|
||||||
|
# place the enable and disable flags
|
||||||
|
# self.station_profile.desired_add_sta_flags = self.enable_flags
|
||||||
|
# self.station_profile.desired_add_sta_flags_mask = self.enable_flags + self.disable_flags
|
||||||
self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,
|
self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,
|
||||||
test_duration=self.duration_time_to_seconds(self.test_duration),
|
test_duration=self.duration_time_to_seconds(self.test_duration),
|
||||||
reset_port_min_time=self.duration_time_to_seconds(reset_port_time_min_),
|
reset_port_min_time=self.duration_time_to_seconds(reset_port_time_min_),
|
||||||
|
|||||||
Reference in New Issue
Block a user