mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-12-24 22:37:03 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -18,6 +18,13 @@ $ pip3 install pexpect-serial
|
||||
./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"
|
||||
|
||||
telnet 172.19.36.168(Pwd:Wnbulab@123), go to the privileged mode and execute the command “clear line 43”.
|
||||
|
||||
Cisco uses 9130 AP
|
||||
show controllers dot11Radio 1 wlan
|
||||
|
||||
AP
|
||||
Command on AP to erase the config:"capwap ap erase all"
|
||||
|
||||
'''
|
||||
|
||||
|
||||
@@ -81,7 +88,7 @@ class FileAdapter(object):
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Cisco AP Control Script")
|
||||
parser.add_argument("-d", "--dest", type=str, help="address of the cisco controller")
|
||||
parser.add_argument("-o", "--port", type=int, help="control port on the controller", default=2043)
|
||||
parser.add_argument("-o", "--port", type=int, help="control port on the controller")
|
||||
parser.add_argument("--prompt", type=str, help="Prompt to expect", default="\(Cisco Controller\) >")
|
||||
parser.add_argument("--series", type=str, help="cisco controller series",default="3504")
|
||||
parser.add_argument("-u", "--user", type=str, help="credential login/username")
|
||||
@@ -95,10 +102,11 @@ def main():
|
||||
parser.add_argument("-a", "--ap", type=str, help="select AP", default="APA453.0E7B.CF9C")
|
||||
parser.add_argument("-b", "--band", type=str, help="Select band (a | b | abgn)",
|
||||
choices=["a", "b", "abgn"])
|
||||
|
||||
parser.add_argument("--action", type=str, help="perform action",
|
||||
choices=["config", "country", "ap_country", "enable", "disable", "summary", "advanced",
|
||||
"cmd", "txPower", "bandwidth", "manual", "auto","no_wlan","show_wlan_summary",
|
||||
"ap_channel", "channel", "show", "wlan", "enable_wlan", "delete_wlan", "wlan_qos",
|
||||
"ap_channel", "channel", "show", "create_wlan", "enable_wlan", "disable_wlan", "wlan_qos",
|
||||
"disable_network_5ghz","disable_network_24ghz","enable_network_5ghz","enable_network_24ghz",
|
||||
"wireless_tag_policy"])
|
||||
parser.add_argument("--value", type=str, help="set value")
|
||||
@@ -180,125 +188,122 @@ def main():
|
||||
#egg.sendline(CR)
|
||||
i = egg.expect_exact(["Escape character is '^]'.","WLC>","WLC#",":","Password:",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
print("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
|
||||
logg.info("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
|
||||
#egg.sendline(CR)
|
||||
found_escape = True
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
j = egg.expect(["WLC>","WLC#","ser\:","ssword\:",pexpect.TIMEOUT],timeout=3)
|
||||
if j == 0:
|
||||
print("9800 found > will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
logg.info("9800 found > will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
egg.sendline("en")
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect(["ssword\:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {}".format(l))
|
||||
logg.info("9800 Successfully received # prompt l {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("9800 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 1:
|
||||
print("9800 found # so logged in can start sending commands j {}".format(j))
|
||||
logg.info("9800 found # so logged in can start sending commands j {}".format(j))
|
||||
logged_in_9800 = True
|
||||
if j == 2:
|
||||
print("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
|
||||
logg.info("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
|
||||
egg.sendline(args.user)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect(["ssword\:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
|
||||
logg.info("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("8900 Successfully received # prompt l: {}".format(l))
|
||||
logg.info("8900 Successfully received # prompt l: {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 3:
|
||||
print("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
|
||||
logg.info("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if k == 0:
|
||||
print("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if k == 1:
|
||||
print("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 4:
|
||||
print("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
logg.info("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
|
||||
if i == 1:
|
||||
print("9800 found > will elevate loging i: {} before {} after {}".format(i,egg.before,egg.after))
|
||||
logg.info("9800 found > will elevate loging i: {} before {} after {}".format(i,egg.before,egg.after))
|
||||
egg.sendline("en")
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
|
||||
if i == 2:
|
||||
print("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
|
||||
if i == 3:
|
||||
print("9800 found User will put in args.user {} i: {} before {} after {}".format(args.user,i, egg.before,egg.after))
|
||||
#egg.sendline(args.user)
|
||||
sleep(1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt after sending User, sending password: {} k: {} before {} after {}".format(args.passwd,k, egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("8900 Successfully received # prompt l: {}".format(l))
|
||||
logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k, egg.before,egg.after))
|
||||
logg.info("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
|
||||
if i == 2:
|
||||
logg.info("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
|
||||
if i == 3:
|
||||
logg.info("9800 found User will put in args.user {} i: {} before {} after {}".format(args.user,i, egg.before,egg.after))
|
||||
#egg.sendline(args.user)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
logg.info("9800 received password prompt after sending User, sending password: {} k: {} before {} after {}".format(args.passwd,k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
logg.info("8900 Successfully received # prompt l: {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
logg.info("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
logg.info("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k, egg.before,egg.after))
|
||||
|
||||
if i == 4:
|
||||
print("9800 received password prompt will send password: {} i: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} i: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
|
||||
#if i == 5:
|
||||
# print("9800 pexpect found end of line i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
# egg.sendline(CR)
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
|
||||
if i == 5:
|
||||
print("9800 Timed out waiting for intial prompt will send carriage return and line feed i: {} before {} after {}".format(i, egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for intial prompt will send carriage return and line feed i: {} before {} after {}".format(i, egg.before,egg.after))
|
||||
egg.sendline(CR)
|
||||
sleep(2)
|
||||
loop_count += 1
|
||||
|
||||
if loop_count >= 3:
|
||||
print("could not log into 9800 exiting")
|
||||
logg.info("could not log into 9800 exiting")
|
||||
exit(1)
|
||||
|
||||
# 3504 series
|
||||
@@ -307,9 +312,11 @@ def main():
|
||||
time.sleep(0.1)
|
||||
if i == 1:
|
||||
egg.sendline('yes')
|
||||
sleep(0.1)
|
||||
egg.expect('ssword:')
|
||||
sleep(0.1)
|
||||
egg.sendline(passwd)
|
||||
sleep(0.1)
|
||||
|
||||
elif (scheme == "telnet"):
|
||||
sleep(1)
|
||||
@@ -325,203 +332,206 @@ def main():
|
||||
found_escape = False
|
||||
if args.series == "9800":
|
||||
while logged_in_9800 == False and loop_count <= 2:
|
||||
#egg.sendline(CR)
|
||||
egg.sendline(CR)
|
||||
sleep(3)
|
||||
try:
|
||||
i = egg.expect_exact(["Escape character is '^]'.","WLC>","WLC#","ser\:","Password:","WLC(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
except pexpect.EOF as e:
|
||||
print('connection failed. or refused')
|
||||
logg.info('connection failed. or refused')
|
||||
exit(1)
|
||||
except:
|
||||
print('unknown exception on initial pexpect after login')
|
||||
logg.info('unknown exception on initial pexpect after login')
|
||||
exit(1)
|
||||
|
||||
if i == 0:
|
||||
print("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
|
||||
logg.info("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
|
||||
#egg.sendline(CR)
|
||||
found_escape = True
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["WLC>","WLC#","ser\:","Password:",pexpect.TIMEOUT],timeout=3)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
if j == 0:
|
||||
print("9800 found WLC> will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
logg.info("9800 found WLC> will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
egg.sendline("en")
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect_exact(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {}".format(l))
|
||||
logg.info("9800 Successfully received # prompt l {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 1:
|
||||
print("9800 found # so logged in can start sending commands j {}".format(j))
|
||||
logg.info("9800 found # so logged in can start sending commands j {}".format(j))
|
||||
logged_in_9800 = True
|
||||
if j == 2:
|
||||
print("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
|
||||
logg.info("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
|
||||
egg.sendline(args.user)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
|
||||
logg.info("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect_exact(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("8900 Successfully received # prompt l: {}".format(l))
|
||||
logg.info("8900 Successfully received # prompt l: {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 3:
|
||||
sleep(1)
|
||||
print("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
|
||||
sleep(0.1)
|
||||
logg.info("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if k == 0:
|
||||
print("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if k == 1:
|
||||
print("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 4:
|
||||
print("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
logg.info("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
|
||||
if i == 1:
|
||||
print("9800 found > will elevate loging i: {} before {} after {}".format(i,egg.before,egg.after))
|
||||
logg.info("9800 found > will elevate loging i: {} before {} after {}".format(i,egg.before,egg.after))
|
||||
egg.sendline("en")
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
|
||||
if i == 2:
|
||||
print("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
|
||||
if i == 3:
|
||||
print("9800 found User will put in args.user {} j: {} before {} after {}".format(args.user,j, egg.before,egg.after))
|
||||
egg.sendline(args.user)
|
||||
sleep(1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt after sending User, sending password: {} k: {} before {} after {}".format(args.passwd,k, egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("8900 Successfully received # prompt l: {}".format(l))
|
||||
logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k, egg.before,egg.after))
|
||||
logg.info("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
|
||||
if i == 2:
|
||||
logg.info("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
|
||||
if i == 3:
|
||||
logg.info("9800 found User will put in args.user {} j: {} before {} after {}".format(args.user,j, egg.before,egg.after))
|
||||
egg.sendline(args.user)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
logg.info("9800 received password prompt after sending User, sending password: {} k: {} before {} after {}".format(args.passwd,k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
logg.info("8900 Successfully received # prompt l: {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
logg.info("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
logg.info("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k, egg.before,egg.after))
|
||||
|
||||
if i == 4:
|
||||
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k, egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
|
||||
#if i == 5:
|
||||
# print("9800 pexpect found end of line i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
# logg.info("9800 pexpect found end of line i {} before {} after {}".format(i,egg.before,egg.after))
|
||||
# egg.sendline(CR)
|
||||
|
||||
if i == 5:
|
||||
print("9800 received WLC(config)# prompt doing some cleanup")
|
||||
logg.info("9800 received WLC(config)# prompt doing some cleanup")
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
j = egg.expect(["WLC>","WLC#","ser\:","ssword\:",pexpect.TIMEOUT],timeout=3)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
if j == 0:
|
||||
print("9800 found WLC> will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
logg.info("9800 found WLC> will elevate loging j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
egg.sendline("en")
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
|
||||
logg.info("9800 received password prompt will send password: {} k: {} before {} after {}".format(args.passwd, k,egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("9800 Successfully received # prompt l {}".format(l))
|
||||
logg.info("9800 Successfully received # prompt l {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("8900 received timeout after looking for password: prompt k {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 1:
|
||||
print("9800 found # so logged in can start sending commands j {}".format(j))
|
||||
logg.info("9800 found # so logged in can start sending commands j {}".format(j))
|
||||
logged_in_9800 = True
|
||||
if j == 2:
|
||||
print("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
|
||||
logg.info("9800 found User\: will put in args.user {} j: {}".format(args.user,j))
|
||||
egg.sendline(args.user)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2)
|
||||
if k == 0:
|
||||
print("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
|
||||
logg.info("9800 received password prompt after sending User, sending password: {} k: {}".format(args.passwd,k))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
l = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if l == 0:
|
||||
print("8900 Successfully received # prompt l: {}".format(l))
|
||||
logg.info("8900 Successfully received # prompt l: {}".format(l))
|
||||
logged_in_9800 = True
|
||||
if l == 1:
|
||||
print("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt l: {} before {} after {}".format(l,egg.before,egg.after))
|
||||
if k == 1:
|
||||
print("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 received timeout after looking for password after sending user k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 3:
|
||||
sleep(1)
|
||||
print("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
|
||||
sleep(0.1)
|
||||
logg.info("9800 received Password prompt will send password {} j: {} before {} after {}".format(args.passwd,j,egg.before,egg.after))
|
||||
egg.sendline(args.passwd)
|
||||
sleep(1)
|
||||
sleep(0.1)
|
||||
k = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if k == 0:
|
||||
print("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logged_in_9800 = True
|
||||
if k == 1:
|
||||
print("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for # prompt k: {} before {} after {}".format(k,egg.before,egg.after))
|
||||
if j == 4:
|
||||
print("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
logg.info("9800 timed out looking for >, #, User, Password j: {} before {} after {}".format(j,egg.before,egg.after))
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
|
||||
|
||||
if i == 6:
|
||||
print("9800 Timed out waiting for intial prompt will send carriage return and line feed i: {} before {} after {}".format(i, egg.before,egg.after))
|
||||
logg.info("9800 Timed out waiting for intial prompt will send carriage return and line feed i: {} before {} after {}".format(i, egg.before,egg.after))
|
||||
egg.sendline(CR)
|
||||
sleep(2)
|
||||
sleep(0.2)
|
||||
|
||||
|
||||
loop_count += 1
|
||||
|
||||
if loop_count >= 3:
|
||||
if found_escape == True:
|
||||
print("9800 there may be another prompt present that not aware of")
|
||||
print("9800 the excape was found see if we can send command")
|
||||
logg.info("9800 there may be another prompt present that not aware of")
|
||||
logg.info("9800 the excape was found see if we can send command")
|
||||
else:
|
||||
print("9800 did not find the initial escape will try the command anyway")
|
||||
logg.info("9800 did not find the initial escape will try the command anyway")
|
||||
|
||||
# 3504 series
|
||||
else:
|
||||
@@ -632,19 +642,22 @@ def main():
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
egg.sendline("ap dot11 5ghz shutdown")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["Are you sure you want to continue? (y/n)[y]:",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
print("did get Are you sure you want to continue? (y/n)[y]:")
|
||||
logg.info("did get Are you sure you want to continue? (y/n)[y]:")
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("did not get Are you sure you want to continue? (y/n)[y]:")
|
||||
logg.info("did not get Are you sure you want to continue? (y/n)[y]:")
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if i == 1:
|
||||
print("timed out on (config)# disable_network_5ghz")
|
||||
logg.info("timed out on (config)# disable_network_5ghz")
|
||||
|
||||
if (args.action == "disable_network_24ghz"):
|
||||
if args.series == "9800":
|
||||
@@ -653,48 +666,58 @@ def main():
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
egg.sendline("ap dot11 24ghz shutdown")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["Are you sure you want to continue? (y/n)[y]:",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
print("did get Are you sure you want to continue? (y/n)[y]:")
|
||||
logg.info("did get Are you sure you want to continue? (y/n)[y]:")
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("did not get Are you sure you want to continue? (y/n)[y]:")
|
||||
logg.info("did not get Are you sure you want to continue? (y/n)[y]:")
|
||||
egg.sendline(CR)
|
||||
sleep(0.1)
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if i == 1:
|
||||
print("timed out on (config)# disable_network_24ghz")
|
||||
logg.info("timed out on (config)# disable_network_24ghz")
|
||||
|
||||
if (args.action == "enable_network_5ghz"):
|
||||
if args.series == "9800":
|
||||
egg.sendline("config t")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
egg.sendline("no ap dot11 5ghz shutdown")
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("timed out on (config)# no ap dot11 5ghz shutdown")
|
||||
logg.info("timed out on (config)# no ap dot11 5ghz shutdown")
|
||||
if i == 1:
|
||||
print("timed out on (config) prompt")
|
||||
logg.info("timed out on (config) prompt")
|
||||
|
||||
if (args.action == "enable_network_24ghz"):
|
||||
if args.series == "9800":
|
||||
egg.sendline("config t")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
egg.sendline("no ap dot11 24ghz shutdown")
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("timed out on (config)# no ap dot11 24ghz shutdown")
|
||||
logg.info("timed out on (config)# no ap dot11 24ghz shutdown")
|
||||
if i == 1:
|
||||
print("timed out on (config) prompt")
|
||||
logg.info("timed out on (config) prompt")
|
||||
|
||||
if (args.action in ["enable", "disable" ] and (args.ap is None)):
|
||||
if (args.action == "enable" and (args.ap is None)):
|
||||
raise Exception("action requires AP name")
|
||||
if (args.action == "enable"):
|
||||
if args.series == "9800":
|
||||
@@ -704,6 +727,9 @@ def main():
|
||||
command = "ap name %s no dot11 24ghz shutdown"%(args.ap)
|
||||
else:
|
||||
command = "config 802.11%s enable %s"%(band, args.ap)
|
||||
|
||||
if (args.action == "disable" and (args.ap is None)):
|
||||
raise Exception("action requires AP name")
|
||||
if (args.action == "disable"):
|
||||
if args.series == "9800":
|
||||
if band == "a":
|
||||
@@ -758,7 +784,7 @@ def main():
|
||||
command = "show ap channel %s"%(args.ap)
|
||||
|
||||
if (args.action == "wireless_tag_policy"):
|
||||
print("send wireless tag policy")
|
||||
logg.info("send wireless tag policy")
|
||||
egg.sendline("config t")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
@@ -766,14 +792,15 @@ def main():
|
||||
for command in ["wireless tag policy default-policy-tag","wlan open-wlan policy default-policy-profile","end"]:
|
||||
egg.sendline(command)
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2)
|
||||
j = egg.expect_exact(["(config-policy-tag)#","(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
print("command sent: {}".format(command))
|
||||
egg.sendline("end")
|
||||
logg.info("command sent: {}".format(command))
|
||||
if j == 1:
|
||||
print("command time out: {}".format(command))
|
||||
logg.info("command sent end: {}".format(command))
|
||||
if j == 2:
|
||||
logg.info("command timed out {}".format(command))
|
||||
if i == 1:
|
||||
print("did not get the (config)# prompt")
|
||||
logg.info("did not get the (config)# prompt")
|
||||
|
||||
if (args.action == "no_wlan" and (args.wlan is None)):
|
||||
raise Exception("wlan is required")
|
||||
@@ -787,34 +814,38 @@ def main():
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
print("command sent: {}".format(command))
|
||||
logg.info("command sent: {}".format(command))
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("command timed out {}".format(command))
|
||||
logg.info("command timed out {}".format(command))
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if i == 1:
|
||||
print("did not get the (config)# prompt")
|
||||
logg.info("did not get the (config)# prompt")
|
||||
|
||||
if (args.action == "show_wlan_summary"):
|
||||
egg.sendline("show wlan summary")
|
||||
sleep(0.1)
|
||||
i = egg.expect(["WLC#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
print("show wlan summary sent")
|
||||
logg.info("show wlan summary sent")
|
||||
if i == 1:
|
||||
print("show wlan summary timed out")
|
||||
logg.info("show wlan summary timed out")
|
||||
|
||||
if (args.action == "wlan" and ((args.wlanID is None) or (args.wlan is None))):
|
||||
if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))):
|
||||
raise Exception("wlan and wlanID is required an")
|
||||
if (args.action == "wlan"):
|
||||
if args.series == "9800":
|
||||
egg.sendline("config t")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
print("elevated to (config)#")
|
||||
logg.info("elevated to (config)#")
|
||||
command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan)
|
||||
print("open network command {}".format(command))
|
||||
logg.info("open network command {}".format(command))
|
||||
egg.sendline(command)
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["WLC(config-wlan)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
for command in ["shutdown","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes",
|
||||
@@ -823,28 +854,60 @@ def main():
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["WLC(config-wlan)#",pexpect.TIMEOUT],timeout=2)
|
||||
if k == 0:
|
||||
print("command sent: {}".format(command))
|
||||
logg.info("command sent: {}".format(command))
|
||||
if k == 1:
|
||||
print("command time out: {}".format(command))
|
||||
logg.info("command time out: {}".format(command))
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("did not get the (config-wlan)# prompt")
|
||||
logg.info("did not get the (config-wlan)# prompt")
|
||||
if i == 0:
|
||||
print("did not get the (config)# prompt")
|
||||
logg.info("did not get the (config)# prompt")
|
||||
else:
|
||||
command = "config wlan create %s %s %s"%(args.wlanID, args.wlan, args.wlan)
|
||||
|
||||
if (args.action == "delete_wlan"):
|
||||
if args.series == "9800":
|
||||
if (args.wlan is None):
|
||||
raise Exception("9800 series wlan is required")
|
||||
else:
|
||||
egg.sendline("config t")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
logg.info("elevated to (config)#")
|
||||
cmd = "no wlan %s"%(args.wlan)
|
||||
egg.sendline(cmd)
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
logg.info("received elevated (config)# after no wlan {}".format(args.wlan))
|
||||
egg.sendline(cmd)
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
logg.info("did not get the (config# prompt")
|
||||
egg.sendline(cmd)
|
||||
sleep(0.1)
|
||||
if i == 1:
|
||||
logg.info("did not get the (config)# prompt")
|
||||
else:
|
||||
if (args.action == "delete_wlan" and (args.wlanID is None)):
|
||||
raise Exception("wlan ID is required")
|
||||
command = "config wlan delete %s"%(args.wlanID)
|
||||
|
||||
if (args.action == ["enable_wlan","disble_wlan"]):
|
||||
if args.series == "9800":
|
||||
if (args.wlan is None):
|
||||
raise Exception("9800 series wlan is required")
|
||||
else:
|
||||
egg.sendline("config t")
|
||||
sleep(0.1)
|
||||
i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2)
|
||||
if i == 0:
|
||||
print("elevated to (config)#")
|
||||
logg.info("elevated to (config)#")
|
||||
cmd = "wlan %s"%(args.wlan)
|
||||
egg.sendline(cmd)
|
||||
sleep(0.1)
|
||||
j = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2)
|
||||
if j == 0:
|
||||
if (args.action == "enable_wlan"):
|
||||
@@ -855,15 +918,17 @@ def main():
|
||||
sleep(0.1)
|
||||
k = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2)
|
||||
if k == 0:
|
||||
print("cmd sent: {}".format(cmd))
|
||||
logg.info("cmd sent: {}".format(cmd))
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if k == 1:
|
||||
print("cmd timed out: {}".format(cmd))
|
||||
logg.info("cmd timed out: {}".format(cmd))
|
||||
egg.sendline("end")
|
||||
sleep(0.1)
|
||||
if j == 1:
|
||||
print("did not get the (config-wlan)# prompt")
|
||||
logg.info("did not get the (config-wlan)# prompt")
|
||||
if i == 1:
|
||||
print("did not get the (config)# prompt")
|
||||
logg.info("did not get the (config)# prompt")
|
||||
else:
|
||||
if (args.action == ["enable_wlan","disable_wlan"] and (args.wlanID is None)):
|
||||
raise Exception("wlan ID is required")
|
||||
@@ -878,49 +943,51 @@ def main():
|
||||
command = "config wlan qos %s %s"%(args.wlanID, args.value)
|
||||
|
||||
if (command is None):
|
||||
sleep(0.5)
|
||||
if args.series == "9800":
|
||||
logg.info("9800 series command completed by earlier logic")
|
||||
logg.info("9800 series command completed by earlier logic: {}".format(command))
|
||||
else:
|
||||
logg.info("No command specified, going to log out.")
|
||||
else:
|
||||
logg.info("Command[%s]"%command)
|
||||
egg.sendline(command)
|
||||
print("command sent {}".format(command))
|
||||
sleep(0.5)
|
||||
logg.info("command sent {}".format(command))
|
||||
|
||||
sleep(1)
|
||||
while True:
|
||||
i = egg.expect(["WLC>","WLC#", "WLC(config)#",AREYOUSURE,'--More-- or',pexpect.TIMEOUT],timeout=3)
|
||||
print (egg.before.decode('utf-8', 'ignore'))
|
||||
if i == 0:
|
||||
print("> prompt received after command sent")
|
||||
logg.info("> prompt received after command sent")
|
||||
break
|
||||
if i == 1:
|
||||
print("WLC# prompt received after command sent")
|
||||
logg.info("WLC# prompt received after command sent")
|
||||
try:
|
||||
print("9800 send exit")
|
||||
logg.info("9800 send exit")
|
||||
egg.sendline("exit")
|
||||
sleep(0.1)
|
||||
except:
|
||||
print("9800 exception on exit")
|
||||
sleep(1)
|
||||
try:
|
||||
print("9800 send carriage return and linefeed")
|
||||
egg.sendline("\r\n")
|
||||
except:
|
||||
print("9800 exception on carriage return and linefeed")
|
||||
logg.info("9800 exception on exit")
|
||||
sleep(0.1)
|
||||
break
|
||||
if i == 2:
|
||||
egg.sendline("end")
|
||||
sleep(0.2)
|
||||
egg.sendline("exit")
|
||||
sleep(0.1)
|
||||
break
|
||||
if i == 3:
|
||||
print("are you sure received after command sent")
|
||||
logg.info("are you sure received after command sent")
|
||||
egg.sendline("y")
|
||||
sleep(0.1)
|
||||
break
|
||||
if i == 4:
|
||||
print("--More-- or received")
|
||||
logg.info("--More-- or received")
|
||||
egg.sendline(NL)
|
||||
sleep(0.1)
|
||||
if i == 5:
|
||||
print("expect timeout")
|
||||
logg.info("expect timeout")
|
||||
break
|
||||
|
||||
|
||||
@@ -928,12 +995,13 @@ def main():
|
||||
pass
|
||||
else:
|
||||
egg.sendline("logout")
|
||||
print("logout")
|
||||
logg.info("logout")
|
||||
i = egg.expect([LOGOUTPROMPT, EXITPROMPT, CLOSEDBYREMOTE, CLOSEDCX,pexpect.TIMEOUT],timeout=3)
|
||||
if i == 0:
|
||||
egg.sendline("y")
|
||||
sleep(0.1)
|
||||
if i == 4:
|
||||
print("pexpect timeout on logout")
|
||||
logg.info("pexpect timeout on logout")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,9 +27,25 @@ The user is responsible for setting up the station oustide of this script, howev
|
||||
|
||||
# Per-channel path-loss example
|
||||
./lf_cisco_power.py -d 192.168.100.112 -u admin -p Cisco123 -s ssh --port 22 -a VC --lfmgr 192.168.100.178 \
|
||||
--station sta00000 --bandwidth "20" --channel "36:64 149:60" --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 64 \
|
||||
--station sta00000 --bandwidth "20 40 80 160" --channel "36:64 149:60" --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 64 \
|
||||
--band a --upstream_port eth2 --lfresource2 2
|
||||
|
||||
# To create a station run test against station create open-wlan
|
||||
./lf_cisco_power.py -d <router IP> -u admin -p Cisco123 -port 2043 --scheme telnet --ap AP6C71.0DE6.45D0 \
|
||||
--station sta2222 --bandwidth "20" --channel "36" --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 54 --band a \
|
||||
--upstream_port eth2 --series 9800 --wlan open-wlan --wlanID 1 --create_station sta2222 --radio wiphy1 --ssid open-wlan \
|
||||
--ssidpw [BLANK] --security open
|
||||
|
||||
# station already present
|
||||
./lf_cisco_power.py -d <router IP> -u admin -p Cisco123 -port 2043 --scheme telnet --ap AP6C71.0DE6.45D0 \
|
||||
--station sta0000 --bandwidth "20" --channel "36" --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 64 --band a \
|
||||
--upstream_port eth2 --series 9800 --wlan open-wlan --wlanID 1
|
||||
|
||||
# to create a station
|
||||
./lf_associate_ap.pl --radio wiphy1 --ssid open-wlan --passphrase [BLANK] ssecurity open --upstream eth1\
|
||||
--first_ip DHCP --first_sta sta0001 --duration 5 --cxtype udp
|
||||
|
||||
|
||||
Changing regulatory domain should happen outside of this script. See cisco_ap_ctl.py
|
||||
|
||||
'''
|
||||
@@ -61,9 +77,9 @@ lfmgr = "127.0.0.1"
|
||||
lfstation = "sta00000"
|
||||
lfresource = "1"
|
||||
lfresource2 = "1"
|
||||
outfile = "cisco_power_results.txt"
|
||||
full_outfile = "full_cisco_power_results.txt"
|
||||
outfile_xlsx = "cisco_power_results.xlsx"
|
||||
outfile = ""
|
||||
full_outfile = ""
|
||||
outfile_xlsx = ""
|
||||
upstream_port = "eth1"
|
||||
pf_dbm = 6
|
||||
# Allow one chain to have a lower signal, since customer's DUT has
|
||||
@@ -86,26 +102,38 @@ def usage():
|
||||
print("-d|--dest: destination host")
|
||||
print("-o|--port: destination port")
|
||||
print("-u|--user: login name")
|
||||
print("-p|--pass: password")
|
||||
print("-p|--passwd: password")
|
||||
print("-s|--scheme (serial|telnet|ssh): connect via serial, ssh or telnet")
|
||||
print("-l|--log file: log messages here")
|
||||
print("-t|--tty tty serial device")
|
||||
print("-l|--log file: log messages here ,stdout means output to console")
|
||||
print("-a|--ap select AP")
|
||||
print("-b|--bandwidth: List of bandwidths to test: 20 40 80 160")
|
||||
print("-c|--channel: List of channels, with optional path-loss to test: 36:64 100:60")
|
||||
print("-n|--nss: List of spatial streams to test: 1 2 3 4")
|
||||
print("-T|--txpower: List of TX power values to test: 1 2 3 4 5 6 7 8")
|
||||
print("--series: 9800 the default is 3504")
|
||||
print("-k|--keep_state keep the state, no configuration change at the end of the test, store true flage present ")
|
||||
print("--outfile: Write results here.")
|
||||
print("--station: LANforge station name (sta00000)")
|
||||
print("--station: LANforge station name for test(sta00000)")
|
||||
print("--upstream_port: LANforge upstream port name (eth1)")
|
||||
print("--lfmgr: LANforge manager IP address")
|
||||
print("--lfresource: LANforge resource ID for station")
|
||||
print("--lfresource2: LANforge resource ID for upstream port")
|
||||
print("--outfile: Output file for csv data")
|
||||
print("--pathloss: Calculated path-loss between LANforge station and AP")
|
||||
print("--band: Select band (a | b | abgn), a means 5Ghz, b means 2.4, abgn means 2.4 on dual-band AP")
|
||||
print("--pf_dbm: Pass/Fail range, default is 6")
|
||||
print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3")
|
||||
print("--wait_forever: Wait forever for station to associate, may aid debugging if STA cannot associate properly")
|
||||
print("--adjust_nf: Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option")
|
||||
print("--wlan: for 9800, wlan identifier defaults to wlan-open")
|
||||
print("--wlanID: wlanID for 9800 , defaults to 1")
|
||||
print("--series: controller series 9800 , defaults to 3504")
|
||||
print("--create_station", "create LANforge station at the beginning of the test")
|
||||
print("--radio", "radio to create LANforge station on at the beginning of the test")
|
||||
print("--ssid", "ssid default open-wlan")
|
||||
print("--ssidpw", "ssidpw default [BLANK]")
|
||||
print("--security", "security default open")
|
||||
print("-h|--help")
|
||||
|
||||
# see https://stackoverflow.com/a/13306095/11014343
|
||||
@@ -136,28 +164,28 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description="Cisco TX Power report Script")
|
||||
parser.add_argument("-d", "--dest", type=str, help="address of the cisco controller")
|
||||
parser.add_argument("-o", "--port", type=int, help="control port on the controller")
|
||||
parser.add_argument("-o", "--port", type=str, help="control port on the controller", default=23)
|
||||
parser.add_argument("-u", "--user", type=str, help="credential login/username")
|
||||
parser.add_argument("-p", "--passwd", type=str, help="credential password")
|
||||
parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet"], help="Connect via serial, ssh or telnet")
|
||||
parser.add_argument("-t", "--tty", type=str, help="tty serial device")
|
||||
parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console")
|
||||
#parser.add_argument("-r", "--radio", type=str, help="select radio")
|
||||
parser.add_argument("-a", "--ap", type=str, help="select AP")
|
||||
parser.add_argument("-b", "--bandwidth", type=str, help="List of bandwidths to test. NA means no change")
|
||||
parser.add_argument("-c", "--channel", type=str, help="List of channels to test, with optional path-loss, 36:64 149:60. NA means no change")
|
||||
parser.add_argument("-a", "--ap", type=str, help="select AP")
|
||||
parser.add_argument("-b", "--bandwidth", type=str, help="List of bandwidths to test. NA means no change")
|
||||
parser.add_argument("-c", "--channel", type=str, help="List of channels to test, with optional path-loss, 36:64 149:60. NA means no change")
|
||||
parser.add_argument("-n", "--nss", type=str, help="List of spatial streams to test. NA means no change")
|
||||
parser.add_argument("-T", "--txpower", type=str, help="List of txpowers to test. NA means no change")
|
||||
parser.add_argument("-T", "--txpower", type=str, help="List of txpowers to test. NA means no change")
|
||||
|
||||
parser.add_argument("-k","--keep_state", help="keep the state, no configuration change at the end of the test",action="store_true")
|
||||
|
||||
parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier defaults to wlan-open",default="wlan-open")
|
||||
parser.add_argument("--wlanID", type=str, help="--series 9800 , defaults to 1",default="1")
|
||||
parser.add_argument("--series", type=str, help="--series 9800 , defaults to 3504",default="3504")
|
||||
parser.add_argument("--upstream_port", type=str, help="LANforge upsteram-port to use (eth1, etc)")
|
||||
parser.add_argument("--station", type=str, help="LANforge station to use (sta0000, etc)")
|
||||
parser.add_argument("--upstream_port", type=str, help="LANforge upsteram-port to use (eth1, etc)")
|
||||
|
||||
parser.add_argument("--lfmgr", type=str, help="LANforge Manager IP address")
|
||||
parser.add_argument("--lfresource", type=str, help="LANforge resource ID for the station")
|
||||
parser.add_argument("--lfresource2", type=str, help="LANforge resource ID for the upstream port system")
|
||||
parser.add_argument("--outfile", type=str, help="Output file for csv data")
|
||||
parser.add_argument("--outfile", type=str, help="Output file for csv data",default="cisco_power_results")
|
||||
parser.add_argument("--pathloss", type=str, help="Calculated pathloss between LANforge Station and AP")
|
||||
parser.add_argument("--band", type=str, help="Select band (a | b), a means 5Ghz, b means 2.4Ghz. Default is a",
|
||||
choices=["a", "b", "abgn"])
|
||||
@@ -165,7 +193,19 @@ def main():
|
||||
parser.add_argument("--pf_a4_dropoff", type=str, help="Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3")
|
||||
parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly")
|
||||
parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option")
|
||||
|
||||
|
||||
parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier defaults to wlan-open",default="wlan-open")
|
||||
parser.add_argument("--wlanID", type=str, help="--wlanID 9800 , defaults to 1",default="1")
|
||||
parser.add_argument("--series", type=str, help="--series 9800 , defaults to 3504",default="3504")
|
||||
parser.add_argument("--slot", type=str, help="--slot 1 , 9800 AP slot defaults to 1",default="1")
|
||||
|
||||
parser.add_argument("--create_station", type=str, help="create LANforge station at the beginning of the test")
|
||||
parser.add_argument("--radio", type=str, help="radio to create LANforge station on at the beginning of the test")
|
||||
parser.add_argument("--ssid", type=str, help="ssid default open-wlan",default="open-wlan")
|
||||
parser.add_argument("--ssidpw", type=str, help="ssidpw default [BLANK]",default="[BLANK]")
|
||||
parser.add_argument("--security", type=str, help="security default open",default="open")
|
||||
|
||||
|
||||
args = None
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
@@ -175,8 +215,13 @@ def main():
|
||||
user = args.user
|
||||
passwd = args.passwd
|
||||
logfile = args.log
|
||||
port = args.port
|
||||
if (args.station != None):
|
||||
lfstation = args.station
|
||||
if (args.create_station != None):
|
||||
lfstation = args.create_station
|
||||
if (args.station != None):
|
||||
print("NOTE: both station: {} and create_station: {} on command line, test will use create_station {} ".format(args.station, args.create_station, args.create_station))
|
||||
if (args.upstream_port != None):
|
||||
upstream_port = args.upstream_port
|
||||
if (args.lfmgr != None):
|
||||
@@ -198,6 +243,15 @@ def main():
|
||||
if (args.pf_a4_dropoff != None):
|
||||
pf_a4_dropoff = args.pf_p4_dropoff
|
||||
|
||||
if args.outfile != None:
|
||||
current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
|
||||
outfile = "{}_{}.txt".format(args.outfile,current_time)
|
||||
full_outfile = "{}_full_{}.txt".format(args.outfile,current_time)
|
||||
outfile_xlsx = "{}_{}.xlsx".format(args.outfile,current_time)
|
||||
print("output file: {}".format(outfile))
|
||||
print("output file full: {}".format(full_outfile))
|
||||
print("output file xlsx: {}".format(outfile_xlsx))
|
||||
|
||||
filehandler = None
|
||||
except Exception as e:
|
||||
logging.exception(e);
|
||||
@@ -356,6 +410,18 @@ def main():
|
||||
channels = args.channel.split()
|
||||
nss = args.nss.split()
|
||||
txpowers = args.txpower.split()
|
||||
|
||||
if (args.create_station != None):
|
||||
if (args.radio == None):
|
||||
print("WARNING --create needs a radio")
|
||||
exit(1)
|
||||
else:
|
||||
print("creating station: {} on radio {}".format(args.create_station,args.radio))
|
||||
subprocess.run(["./lf_associate_ap.pl", "--radio", args.radio, "--ssid", args.ssid , "--passphrase", args.ssidpw,
|
||||
"security", args.security, "--upstream", args.upstream_port, "--first_ip", "DHCP",
|
||||
"--first_sta",args.create_station,"--duration","1","--cxtype","udp","--action","add"], timeout=20, capture_output=True)
|
||||
sleep(3)
|
||||
|
||||
|
||||
# Find LANforge station parent radio
|
||||
parent = None
|
||||
@@ -367,6 +433,7 @@ def main():
|
||||
if (m != None):
|
||||
parent = m.group(1)
|
||||
|
||||
|
||||
# Create downstream connection
|
||||
# First, delete any old one
|
||||
subprocess.run(["./lf_firemod.pl", "--manager", lfmgr, "--resource", lfresource, "--action", "do_cmd",
|
||||
@@ -386,7 +453,7 @@ def main():
|
||||
|
||||
myrd = ""
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "summary","--series",args.series], capture_output=True)
|
||||
"--action", "summary","--series",args.series,"--port",args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore');
|
||||
print(pss)
|
||||
|
||||
@@ -457,106 +524,115 @@ def main():
|
||||
# Disable AP, apply settings, enable AP
|
||||
print("3504/9800 cisco_wifi_ctl.py: disable")
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable","--series",args.series])
|
||||
"--action", "disable","--series",args.series,"--port", args.port])
|
||||
|
||||
if args.series == "9800":
|
||||
# 9800 series need to "Configure radio for manual channel assignment"
|
||||
print("9800 Configure radio for manual channel assignment")
|
||||
print("9800 cisco_wifi_ctl.py: disable_network_5ghz")
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: disable_wlan")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable_network_5ghz","--series",args.series])
|
||||
"--action", "disable_wlan","--series",args.series,"--port", args.port])
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable_network_5ghz","--series",args.series,"--port", args.port])
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: disable_network_24ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable_network_24ghz","--series",args.series])
|
||||
"--action", "disable_network_24ghz","--series",args.series,"--port", args.port])
|
||||
print("9800 cisco_wifi_ctl.py: manual")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "manual","--series",args.series])
|
||||
"--action", "manual","--series",args.series,"--port", args.port])
|
||||
|
||||
else:
|
||||
print("3504 cisco_wifi_ctl.py: onfig 802.11a disable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11a disable network","--series",args.series])
|
||||
"--action", "cmd", "--value", "config 802.11a disable network","--series",args.series,"--port", args.port])
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11b disable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11b disable network"])
|
||||
"--action", "cmd", "--value", "config 802.11b disable network","--port", args.port])
|
||||
|
||||
print("9800 test_parameters_summary: set : tx: {} ch: {} bw: {}".format(tx,ch,bw))
|
||||
if (tx != "NA"):
|
||||
print("9800 / 3504 cisco_wifi_ctl.py: txPower")
|
||||
print("9800 test_parameters: set txPower: {}".format(tx))
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "txPower", "--value", tx, "--series" , args.series])
|
||||
"--action", "txPower", "--value", tx, "--series" , args.series,"--port", args.port])
|
||||
if (bw != "NA"):
|
||||
print("9800 / 3504 cisco_wifi_ctl.py: bandwidth")
|
||||
print("9800 test_parameters bandwidth: set : {}".format(bw))
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "bandwidth", "--value", bw, "--series" , args.series])
|
||||
"--action", "bandwidth", "--value", bw, "--series" , args.series,"--port", args.port])
|
||||
|
||||
# NSS is set on the station earlier...
|
||||
|
||||
if (ch != "NA"):
|
||||
print("9800 / 3504 cisco_wifi_ctl.py: channel")
|
||||
print("9800 test_parameters set channel: {}".format(ch))
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "channel", "--value", ch, "--series" , args.series])
|
||||
"--action", "channel", "--value", ch, "--series" , args.series,"--port", args.port])
|
||||
|
||||
# TODO do not know when to configure open wlan
|
||||
if args.series == "9800":
|
||||
print("9800 cisco_wifi_ctl.py: wlan")
|
||||
#print("9800 cisco_wifi_ctl.py: delete_wlan")
|
||||
#subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
# "--action", "delete_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID])
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: create_wlan")
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID])
|
||||
"--action", "create_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID,"--port", args.port])
|
||||
print("9800 cisco_wifi_ctl.py: wireless_tag_policy")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "wireless_tag_policy","--series",args.series])
|
||||
"--action", "wireless_tag_policy","--series",args.series,"--port", args.port])
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: enable_wlan")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable_wlan","--series",args.series])
|
||||
"--action", "enable_wlan","--series",args.series,"--port", args.port])
|
||||
|
||||
|
||||
# enable transmission for the entier 802.11z network
|
||||
if args.series == "9800":
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: enable_network_5ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable_network_5ghz","--series",args.series])
|
||||
"--action", "enable_network_5ghz","--series",args.series,"--port", args.port])
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: enable_network_24ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable_network_24ghz","--series",args.series])
|
||||
"--action", "enable_network_24ghz","--series",args.series,"--port", args.port])
|
||||
|
||||
else:
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11a enable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11a enable network"])
|
||||
"--action", "cmd", "--value", "config 802.11a enable network","--port", args.port])
|
||||
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11a enable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11b enable network"])
|
||||
"--action", "cmd", "--value", "config 802.11b enable network","--port", args.port])
|
||||
|
||||
print("9800/3504 cisco_wifi_ctl.py: enable")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable", "--series" , args.series])
|
||||
"--action", "enable", "--series" , args.series,"--port", args.port])
|
||||
|
||||
# Wait a bit for AP to come back up
|
||||
time.sleep(1)
|
||||
# TODO figure out equivalent of the advanced command for 9800
|
||||
if args.series == "9800":
|
||||
print("9800 cisco_wifi_ctl.py: advanced")
|
||||
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "advanced","--series" , args.series], capture_output=True)
|
||||
"--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore')
|
||||
print(pss)
|
||||
|
||||
@@ -572,19 +648,29 @@ def main():
|
||||
continue
|
||||
|
||||
if (searchap):
|
||||
pat = "%s\s+(\S+)\s+\S+\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\(\s*(\S+)\s+dBm\)+\s+(\S+)\*+\s"%(args.ap)
|
||||
pat = "%s\s+(\S+)\s+%s\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\(\s*(\S+)\s+dBm\)+\s+(\S+)\*+\s"%(args.ap,args.slot)
|
||||
m = re.search(pat, line)
|
||||
if (m != None):
|
||||
cc_mac = m.group(1)
|
||||
cc_ch = m.group(5); # (132,136,140,144)
|
||||
cc_power = m.group(3)
|
||||
cc_power = cc_power.replace("*/", " of ", 1) # spread-sheets turn 1/8 into a date
|
||||
cc_dbm = m.group(4)
|
||||
cc_mac = m.group(1)
|
||||
cc_slot = args.slot
|
||||
cc_ch = m.group(5); # (132,136,140,144)
|
||||
cc_power = m.group(3)
|
||||
cc_power = cc_power.replace("*/", " of ", 1) # spread-sheets turn 1/8 into a date
|
||||
cc_dbm = m.group(4)
|
||||
|
||||
ch_count = cc_ch.count(",")
|
||||
cc_bw = m.group(2)
|
||||
print("group 1: {} 2: {} 3: {} 4: {} 5: {} ".format(m.group(1),m.group(2),m.group(3),m.group(4),m.group(5)))
|
||||
break
|
||||
cc_ch_count = cc_ch.count(",")
|
||||
cc_bw = m.group(2)
|
||||
print("group 1: {} 2: {} 3: {} 4: {} 5: {} 6: {}".format(m.group(1),m.group(2),m.group(3),m.group(4),m.group(5),m.group(6)))
|
||||
print("9800 test_parameters_summary: read: tx: {} ch: {} bw: {}".format(tx,ch,bw))
|
||||
|
||||
print("9800 test_parameters cc_mac: read : {}".format(cc_mac))
|
||||
print("9800 test_parameters cc_slot: read : {}".format(cc_slot))
|
||||
print("9800 test_parameters cc_count: read : {}".format(cc_ch_count))
|
||||
print("9800 test_parameters cc_bw: read : {}".format(cc_bw))
|
||||
print("9800 test_parameters cc_power: read : {}".format(cc_power))
|
||||
print("9800 test_parameters cc_dbm: read : {}".format(cc_dbm))
|
||||
print("9800 test_parameters cc_ch: read : {}".format(cc_ch))
|
||||
break
|
||||
|
||||
if (cc_dbm == ""):
|
||||
# Could not talk to controller?
|
||||
@@ -592,11 +678,16 @@ def main():
|
||||
print(err)
|
||||
e_tot += err
|
||||
e_tot += " "
|
||||
|
||||
wlan_summary = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "show_wlan_summary","--series" , args.series,"--port", args.port], capture_output=True)
|
||||
pss = wlan_summary.stdout.decode('utf-8', 'ignore')
|
||||
print(pss)
|
||||
else:
|
||||
print("3504 cisco_wifi_ctl.py: advanced")
|
||||
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "advanced"], capture_output=True)
|
||||
"--action", "advanced","--port", args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore')
|
||||
print(pss)
|
||||
|
||||
@@ -625,7 +716,7 @@ def main():
|
||||
cc_bw = 20 * (ch_count + 1)
|
||||
|
||||
break
|
||||
|
||||
|
||||
if (cc_dbm == ""):
|
||||
# Could not talk to controller?
|
||||
err = "ERROR: Could not query dBm from controller, maybe controller died?"
|
||||
@@ -679,6 +770,13 @@ def main():
|
||||
print(err)
|
||||
e_tot += err
|
||||
e_tot += " "
|
||||
if args.series == "9800":
|
||||
print("9800 resending cisco_wifi_ctl.py: advanced")
|
||||
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore')
|
||||
print(pss)
|
||||
if (args.wait_forever):
|
||||
print("Will continue waiting, you may wish to debug the system...")
|
||||
i = 0
|
||||
@@ -1003,43 +1101,58 @@ def main():
|
||||
|
||||
workbook.close()
|
||||
|
||||
# check if keeping the existing state
|
||||
if(args.keep_state):
|
||||
print("9800/3504 flag --keep_state set thus keeping state")
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore')
|
||||
print(pss)
|
||||
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "summary","--series" , args.series,"--port", args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore')
|
||||
print(pss)
|
||||
|
||||
exit(1)
|
||||
|
||||
# Set things back to defaults
|
||||
# Disable AP, apply settings, enable AP
|
||||
print("9800/3504 cisco_wifi_ctl.py: disable")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable", "--series" , args.series])
|
||||
"--action", "disable", "--series" , args.series,"--port", args.port])
|
||||
|
||||
if args.series == "9800":
|
||||
print("9800 cisco_wifi_ctl.py: disable_network_5ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable_network_5ghz","--series",args.series])
|
||||
"--action", "disable_network_5ghz","--series",args.series,"--port", args.port])
|
||||
|
||||
print("9800 cisco_wifi_ctl.py: disable_network_24ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "disable_network_24ghz","--series",args.series])
|
||||
"--action", "disable_network_24ghz","--series",args.series,"--port", args.port])
|
||||
else:
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11a disable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11a disable network"])
|
||||
"--action", "cmd", "--value", "config 802.11a disable network","--port", args.port])
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11b disable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11b disable network"])
|
||||
"--action", "cmd", "--value", "config 802.11b disable network","--port", args.port])
|
||||
|
||||
if (tx != "NA"):
|
||||
print("9800/3504 cisco_wifi_ctl.py: txPower")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "txPower", "--value", "1", "--series" , args.series])
|
||||
"--action", "txPower", "--value", "1", "--series" , args.series,"--port", args.port])
|
||||
if (bw != "NA"):
|
||||
print("9800/3504 cisco_wifi_ctl.py: bandwidth")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "bandwidth", "--value", "20", "--series" , args.series])
|
||||
"--action", "bandwidth", "--value", "20", "--series" , args.series,"--port", args.port])
|
||||
|
||||
# NSS is set on the station earlier...
|
||||
|
||||
@@ -1047,36 +1160,36 @@ def main():
|
||||
print("9800/3504 cisco_wifi_ctl.py: channel")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "channel", "--value", "36", "--series" , args.series])
|
||||
"--action", "channel", "--value", "36", "--series" , args.series,"--port", args.port])
|
||||
|
||||
if args.series == "9800":
|
||||
print("9800 cisco_wifi_ctl.py: enable_network_5ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable_network_5ghz","--series",args.series])
|
||||
"--action", "enable_network_5ghz","--series",args.series,"--port", args.port])
|
||||
print("9800 cisco_wifi_ctl.py: enable_network_24ghz")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable_network_24ghz","--series",args.series])
|
||||
"--action", "enable_network_24ghz","--series",args.series,"--port", args.port])
|
||||
print("9800 cisco_wifi_ctl.py: auto")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "auto","--series",args.series])
|
||||
"--action", "auto","--series",args.series,"--port", args.port])
|
||||
|
||||
else:
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11a enable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11a enable network"])
|
||||
"--action", "cmd", "--value", "config 802.11a enable network","--port", args.port])
|
||||
print("3504 cisco_wifi_ctl.py: config 802.11b enable network")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "cmd", "--value", "config 802.11b enable network"])
|
||||
"--action", "cmd", "--value", "config 802.11b enable network","--port", args.port])
|
||||
|
||||
print("9800/3504 cisco_wifi_ctl.py: enable")
|
||||
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "enable", "--series" , args.series])
|
||||
"--action", "enable", "--series" , args.series,"--port", args.port])
|
||||
|
||||
# Remove LANforge traffic connection
|
||||
subprocess.run(["./lf_firemod.pl", "--manager", lfmgr, "--resource", lfresource, "--action", "do_cmd",
|
||||
@@ -1090,7 +1203,7 @@ def main():
|
||||
print("9800/3504 cisco_wifi_ctl.py: advanced")
|
||||
|
||||
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
|
||||
"--action", "advanced", "--series" , args.series], capture_output=True)
|
||||
"--action", "advanced", "--series" , args.series,"--port", args.port], capture_output=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore');
|
||||
print(pss)
|
||||
|
||||
|
||||
387
py-scripts/lf_dut_sta_vap_test.py
Normal file
387
py-scripts/lf_dut_sta_vap_test.py
Normal file
@@ -0,0 +1,387 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
This Scrip has two classes :
|
||||
1. LoadScenario : It will load the existing saved scenario to the Lanforge (Here used for Loading Bridged VAP)
|
||||
2. CreateSTA_CX : It will create stations and L3 Cross connects and start them
|
||||
3. Login_DUT : This class is specifically used to test the Linux based DUT that has SSH Server. It is used to read the CPU Core temperature during testing
|
||||
In this example, Another Lanforge is used as DUT
|
||||
It also have a function : GenerateReport that generates the report in xlsx format as well as it plots the Graph of throughput over time with temperature
|
||||
|
||||
|
||||
Example
|
||||
.\lf_dut_sta_vap_test.py --lf_host 192.168.200.15 --dut_host 192.168.200.18 --dut_radio wiphy1 --lf_radio wiphy1 --num_sta 1 --sta_id 1 --lf_ssid lanforge_ap --dut_ssid lexusap --security open --dut_upstream eth2 --lf_upstream eth1 --protocol lf_udp --min_bps 1000 --max_bps 10000 --time 1
|
||||
This Script is intended to automate the testing of DUT That has stations as well as AP.
|
||||
To automate the simultaenous testing and check the DUT Temperature
|
||||
'''
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append('../py-json')
|
||||
|
||||
import pexpect
|
||||
import argparse
|
||||
import time
|
||||
from LANforge import LFUtils
|
||||
from LANforge import lfcli_base
|
||||
from LANforge.lfcli_base import LFCliBase
|
||||
from LANforge.LFUtils import *
|
||||
import realm
|
||||
from realm import VRProfile
|
||||
from realm import Realm
|
||||
import logging
|
||||
import paramiko as pm
|
||||
from paramiko.ssh_exception import NoValidConnectionsError as exception
|
||||
import xlsxwriter
|
||||
from bokeh.io import output_file, show
|
||||
from bokeh.plotting import figure
|
||||
from bokeh.models import LinearAxis, Range1d
|
||||
from bokeh.models import HoverTool
|
||||
|
||||
|
||||
|
||||
|
||||
class Login_DUT:
|
||||
|
||||
def __init__(self, threadID, name, HOST):
|
||||
self.threadID = threadID
|
||||
self.name = name
|
||||
self.host=HOST
|
||||
self.USERNAME = "lanforge"
|
||||
self.PASSWORD = "lanforge"
|
||||
self.CLIENT= pm.SSHClient()
|
||||
self.LF1= self.Connect()
|
||||
self.data_core1=[]
|
||||
self.data_core2=[]
|
||||
if self.CLIENT == 0:
|
||||
exit()
|
||||
print("Connected to " +HOST+" DUT to Measure the Core Temperature")
|
||||
def run(self):
|
||||
stdin, stdout, stderr= self.CLIENT.exec_command("sensors")
|
||||
out_lines = stdout.readlines()
|
||||
err_lines = stderr.readlines()
|
||||
print(out_lines[len(out_lines)-3],out_lines[len(out_lines)-2])
|
||||
self.data_core1.append(out_lines[len(out_lines)-3])
|
||||
self.data_core2.append(out_lines[len(out_lines)-2])
|
||||
|
||||
def Connect(self):
|
||||
self.CLIENT.load_system_host_keys()
|
||||
self.CLIENT.set_missing_host_key_policy(pm.AutoAddPolicy())
|
||||
try:
|
||||
self.CLIENT.connect(self.host, username=self.USERNAME, password=self.PASSWORD,timeout=10)
|
||||
return None
|
||||
except exception as error:
|
||||
self.CLIENT = 0;
|
||||
return None
|
||||
|
||||
|
||||
# Class to Load a Scenario that has been Created in Chamber View saved under DB/[Database_Name]
|
||||
class LoadScenario(LFCliBase):
|
||||
def __init__(self, host, port, db_name, security_debug_on=False, _exit_on_error=False,_exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=security_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.json_post("/cli-json/load", { "name": db_name, "action": 'overwrite' })
|
||||
print("Scenario Loaded...")
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
class CreateSTA_CX(LFCliBase):
|
||||
|
||||
def __init__(self, host, port, radio, num_sta, sta_id, ssid, security, password, upstream, protocol, min_bps, max_bps, security_debug_on=True, _exit_on_error=True,_exit_on_fail=True):
|
||||
super().__init__(host, port, _debug=security_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
||||
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.radio = radio
|
||||
|
||||
self.num_sta = num_sta
|
||||
self.sta_id = sta_id
|
||||
|
||||
self.ssid = ssid
|
||||
|
||||
self.security = security
|
||||
self.password = password
|
||||
|
||||
self.upstream = upstream
|
||||
self.protocol = protocol
|
||||
|
||||
self.min_bps =min_bps
|
||||
self.max_bps =max_bps
|
||||
|
||||
#Creating a Realm Object
|
||||
self.local_realm = Realm(lfclient_host=host, lfclient_port=port)
|
||||
|
||||
#Creating Profile Objects
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.cx_profile = self.local_realm.new_l3_cx_profile()
|
||||
|
||||
#Setting CX Name
|
||||
self.cx_profile.name_prefix_="Connection"
|
||||
self.cx_names = []
|
||||
self.sta_list = []
|
||||
self.endp=[]
|
||||
for i in range(sta_id,sta_id+num_sta):
|
||||
self.sta_list.append("sta00")
|
||||
|
||||
#portDhcpUpRequest
|
||||
upstream_dhcp = LFRequest.LFRequest("http://"+str(host)+":"+str(port)+"/"+"/cli-form/set_port")
|
||||
upstream_dhcp.addPostData( LFUtils.portSetDhcpDownRequest(1, upstream))
|
||||
upstream_dhcp.formPost()
|
||||
time.sleep(2)
|
||||
upstream_dhcp.addPostData( LFUtils.portUpRequest(1, upstream))
|
||||
upstream_dhcp.formPost()
|
||||
print(upstream + "Set to DHCP For Cross Connects")
|
||||
|
||||
|
||||
def build(self):
|
||||
|
||||
#Creating Stations of Given Profile Settings
|
||||
self.station_profile.use_security(self.security, self.ssid, passwd=self.password)
|
||||
self.station_profile.create(self.radio,num_stations=self.num_sta, sta_names_=self.sta_list)
|
||||
self.station_profile.admin_up()
|
||||
#Wait for a while
|
||||
time.sleep(15)
|
||||
|
||||
#Setting up the Parameters for CX
|
||||
self.cx_profile.side_a_min_bps = self.min_bps
|
||||
self.cx_profile.side_b_min_bps = self.min_bps
|
||||
self.cx_profile.side_a_max_bps = self.max_bps
|
||||
self.cx_profile.side_b_max_bps = self.max_bps
|
||||
|
||||
self.cx_profile.side_a_min_pdu = 'Auto'
|
||||
self.cx_profile.side_b_min_pdu = 'Auto'
|
||||
self.cx_profile.report_timer = 1000
|
||||
self.cx_profile.side_a_min_pkt='Same'
|
||||
self.cx_profile.side_a_max_pkt='Same'
|
||||
|
||||
#Create Connections of Given Parameters
|
||||
self.cx_profile.create(self.protocol, side_a="1.1."+self.upstream, side_b=list(self.local_realm.find_ports_like("sta0+")))
|
||||
time.sleep(15)
|
||||
|
||||
|
||||
for i in self.cx_profile.get_cx_names():
|
||||
self.cx_names.append(i)
|
||||
for j in self.cx_names:
|
||||
x=self.local_realm.json_get("/cx/"+j)
|
||||
self.endp.append(x.get(j).get('endpoints')[1])
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def start(self):
|
||||
#self.station_profile.admin_up()
|
||||
|
||||
self.cx_profile.start_cx()
|
||||
time.sleep(5)
|
||||
return 0
|
||||
|
||||
def stop(self):
|
||||
self.cx_profile.stop_cx()
|
||||
time.sleep(5)
|
||||
self.lf_stations.admin_down()
|
||||
time.sleep(5)
|
||||
return 0
|
||||
|
||||
def cleanup(self):
|
||||
self.local_realm.cleanup_cxe_prefix(self.cx_profile.name_prefix)
|
||||
station_map = self.local_realm.find_ports_like("sta+")
|
||||
for eid,record in station_map.items():
|
||||
self.local_realm.remove_vlan_by_eid(eid)
|
||||
time.sleep(0.03)
|
||||
del_sta_names = []
|
||||
try:
|
||||
for eid,value in station_map.items():
|
||||
tname = eid[eid.rfind('.'):]
|
||||
del_sta_names.append(tname)
|
||||
except Exception as x:
|
||||
self.local_realm.error(x)
|
||||
try:
|
||||
LFUtils.waitUntilPortsDisappear(base_url=self.local_realm.lfclient_url, port_list=del_sta_names, debug=True)
|
||||
print("Ports Successfully Cleaned up")
|
||||
return 0
|
||||
except:
|
||||
print("Ports Successfully Cleaned up")
|
||||
time.sleep(5)
|
||||
return 0
|
||||
|
||||
def GenerateReport(throughput, core1_temp, core2_temp):
|
||||
workbook = xlsxwriter.Workbook('demo.xlsx')
|
||||
worksheet = workbook.add_worksheet()
|
||||
worksheet.write('A1', 'THROUGHPUT OVER TIME ')
|
||||
worksheet.write('B1', 'CORE 0 TEMP')
|
||||
worksheet.write('C1', 'CORE 1 TEMP')
|
||||
core1=[]
|
||||
core2=[]
|
||||
j=2
|
||||
for i in throughput:
|
||||
worksheet.write('A'+str(j), str(i/1000000)+" MBPS")
|
||||
j=j+1
|
||||
j=2
|
||||
for i in core1_temp:
|
||||
core1.append(int(str(i).split(':')[1].split('(')[0].split('.')[0].split('+')[1]))
|
||||
worksheet.write('B'+str(j),str(i).split(':')[1].split('(')[0] )
|
||||
j=j+1
|
||||
j=2
|
||||
for i in core2_temp:
|
||||
core2.append(int(str(i).split(':')[1].split('(')[0].split('.')[0].split('+')[1]))
|
||||
worksheet.write('C'+str(j), str(i).split(':')[1].split('(')[0])
|
||||
j=j+1
|
||||
workbook.close()
|
||||
|
||||
x=[]
|
||||
for i in range(0,5*len(throughput)):
|
||||
x.append(i)
|
||||
|
||||
'''
|
||||
y = throughput
|
||||
|
||||
TOOLTIPS = [
|
||||
("index", "$index"),
|
||||
("(Throughput,Time)", "($y, $x)"),
|
||||
|
||||
]
|
||||
|
||||
s1 = figure(y_range = (0,15000),tooltips = TOOLTIPS)
|
||||
|
||||
s1.line(y, x, color='#f45666')
|
||||
s1.circle(y, x, color='pink')
|
||||
|
||||
|
||||
s1.extra_y_ranges = {"NumStations":}
|
||||
|
||||
s1.add_layout(LinearAxis(y_range_name="NumStations"), 'right')
|
||||
s1.line(core1,x, y_range_name='NumStations', color='blue')
|
||||
s1.circle(core1, x, y_range_name='NumStations', color='black')
|
||||
|
||||
s1.line(core2,x, y_range_name='NumStations', color='blue')
|
||||
s1.circle(core2, x, y_range_name='NumStations', color='black')
|
||||
show(s1)
|
||||
'''
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description="Test Scenario of DUT Temperature measurement along with simultaneous throughput")
|
||||
|
||||
parser.add_argument("-m", "--lf_host", type=str, help="Enter the address of LF which will test the DUT")
|
||||
parser.add_argument("-d", "--dut_host", type=str, help="Enter the address of LF Which is to be dut")
|
||||
|
||||
parser.add_argument("-lr", "--lf_radio", type=str, help="Enter the radio on which you want to create a station/s on (Lanforge Side)")
|
||||
parser.add_argument("-dr", "--dut_radio", type=str, help="Enter the radio on which you want to create a station/s on (DUT Side)")
|
||||
|
||||
parser.add_argument("-n", "--num_sta", type=int, help="Enter the Number of Stations You want to create")
|
||||
|
||||
parser.add_argument("-st", "--sta_id", type=int, help="Enter Station id [for sta001, enter 1]")
|
||||
|
||||
parser.add_argument("-ls", "--lf_ssid", type=str, help="Enter the ssid, with which you want to associate your stations (Enter the SSID of VAP in Lanforge)")
|
||||
parser.add_argument("-ds", "--dut_ssid", type=str, help="Enter the ssid, with which you want to associate your stations (Enter the SSID of VAP in DUT)")
|
||||
parser.add_argument("-sec", "--security", type=str, help="Enter the security type [open, wep, wpa, wpa2]")
|
||||
parser.add_argument("-p", "--password", type=str, help="Enter the password if security is not open")
|
||||
parser.add_argument("-lu", "--lf_upstream", type=str, help="Enter the upstream ethernet port")
|
||||
parser.add_argument("-du", "--dut_upstream", type=str, help="Enter the upstream ethernet port")
|
||||
parser.add_argument("-pr", "--protocol", type=str, help="Enter the protocol on which you want to run your connections [lf_udp, lf_tcp]")
|
||||
parser.add_argument("-minb", "--min_bps", type=str, help="Enter the Minimum Rate")
|
||||
parser.add_argument("-maxb", "--max_bps", type=str, help="Enter the Maximum Rate")
|
||||
parser.add_argument("-t", "--time", type=int, help="Enter the Time for which you want to run test (In Minutes)")
|
||||
|
||||
args = None
|
||||
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
if (args.lf_host is not None):
|
||||
lf_host = args.lf_host
|
||||
if (args.dut_host is not None):
|
||||
dut_host = args.dut_host
|
||||
if (args.lf_radio is not None):
|
||||
lf_radio = args.lf_radio
|
||||
if (args.dut_radio is not None):
|
||||
dut_radio = args.dut_radio
|
||||
if (args.num_sta is not None):
|
||||
num_sta = args.num_sta
|
||||
if (args.sta_id is not None):
|
||||
sta_id = args.sta_id
|
||||
if (args.dut_ssid is not None):
|
||||
dut_ssid = args.dut_ssid
|
||||
if (args.lf_ssid is not None):
|
||||
lf_ssid = args.lf_ssid
|
||||
if (args.security is not None):
|
||||
security = args.security
|
||||
if (args.password is not None):
|
||||
password = args.password
|
||||
if (args.password is None):
|
||||
password = "[Blank]"
|
||||
if (args.lf_upstream is not None):
|
||||
lf_upstream = args.lf_upstream
|
||||
if (args.dut_upstream is not None):
|
||||
dut_upstream = args.dut_upstream
|
||||
if (args.protocol is not None):
|
||||
protocol = args.protocol
|
||||
if (args.min_bps is not None):
|
||||
min_bps = int(args.min_bps)*1000000
|
||||
if (args.max_bps is not None and args.max_bps is not "same"):
|
||||
max_bps = int(args.max_bps)*1000000
|
||||
if (args.max_bps is not None and args.max_bps is "same"):
|
||||
max_bps = args.min_bps
|
||||
if (args.time is not None):
|
||||
tme = (args.time * 60)/5
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
||||
exit(2)
|
||||
|
||||
DB_Lanforge_1 = "AUTO_CV-2020-09-18-07-41-19"
|
||||
#Loading the Scenario on Lanforge_1 (Here Considered as DUT) [Created VAP With SSID 'lexusap' on wiphy0 with eth1 as backhaul]
|
||||
Scenario_1 = LoadScenario(dut_host,8080,DB_Lanforge_1)
|
||||
|
||||
DB_Lanforge_2 = "AUTO_CV-2020-09-18-08-00-36"
|
||||
#Loading the Scenario on Lanforge_2 (Here Considered as LANFORGE Test) [Created VAP With SSID 'lanforge_ap' on wiphy0 with eth2 as backhaul]
|
||||
Scenario_2 = LoadScenario(lf_host,8080,DB_Lanforge_2)
|
||||
|
||||
#Create Station and cross connects on Lanforge_1 that connects on VAP on Lanforge_2
|
||||
DUT = CreateSTA_CX(dut_host,8080,dut_radio,num_sta, sta_id, lf_ssid, security, password, dut_upstream, protocol, min_bps, max_bps)
|
||||
#DUT.cleanup()
|
||||
DUT.build()
|
||||
DUT.start()
|
||||
|
||||
#Create Station and cross connects on Lanforge_2 that connects on VAP on Lanforge_1 (lexus_ap)
|
||||
LF = CreateSTA_CX(lf_host,8080,lf_radio,num_sta, sta_id, dut_ssid, security, password, lf_upstream, protocol, min_bps, max_bps)
|
||||
#LF.cleanup()
|
||||
LF.build()
|
||||
LF.start()
|
||||
|
||||
print("Collecting Throughput Values...")
|
||||
a = Login_DUT(1, "Thread-1", dut_host)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
csv_data =[]
|
||||
for i in range(0,int(tme)):
|
||||
temp=0
|
||||
for j in LF.endp:
|
||||
x=LF.local_realm.json_get("/endp/"+j).get('endpoint').get('rx rate')
|
||||
temp=temp+x
|
||||
for j in DUT.endp:
|
||||
y=DUT.local_realm.json_get("/endp/"+j).get('endpoint').get('rx rate')
|
||||
temp=temp+y
|
||||
csv_data.append(temp)
|
||||
a.run()
|
||||
print(temp)
|
||||
time.sleep(5)
|
||||
print(csv_data)
|
||||
DUT.cleanup()
|
||||
LF.cleanup()
|
||||
GenerateReport(csv_data,a.data_core1,a.data_core2)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -804,7 +804,7 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr
|
||||
radios = args.radio
|
||||
|
||||
if args.csv_outfile != None:
|
||||
current_time = time.strftime("%m_%d_%Y_%H_%M", time.localtime())
|
||||
current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
|
||||
csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time)
|
||||
print("csv output file : {}".format(csv_outfile))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user