From fa8a1f389c69feeaf0faf299e340cd4525646e14 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 09:59:41 -0600 Subject: [PATCH 01/34] AP taking some time to associate --- lf_cisco_power.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index ee608006..6668aef2 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -461,6 +461,7 @@ def main(): 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") subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band, @@ -679,6 +680,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], 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 From 959398f522c3cc5676a52a13f3acf4574141279b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 10:49:41 -0600 Subject: [PATCH 02/34] Disable the wlan prior to configuration --- cisco_wifi_ctl.py | 5 ++++- lf_cisco_power.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index c3e8ffca..cc623115 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -694,7 +694,7 @@ def main(): if i == 1: print("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 +704,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": diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 6668aef2..5b817e75 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -464,6 +464,11 @@ def main(): 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_wlan","--series",args.series]) + 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]) From 88bb9d114e0cf209a5153da2416dfd4611bcb7f6 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 10:53:31 -0600 Subject: [PATCH 03/34] add disable wlan --- cisco_wifi_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index cc623115..613339d0 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -98,7 +98,7 @@ def main(): 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", "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") From bfc18cb3ed50aa4f7520f2b138ffab8a0f0df0b0 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 11:37:36 -0600 Subject: [PATCH 04/34] added delete_wlan bug fix for enable 5ghz network --- cisco_wifi_ctl.py | 34 ++++++++++++++++++++++++++++------ lf_cisco_power.py | 10 +++++++--- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 613339d0..680981c2 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -98,7 +98,7 @@ def main(): 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", "disable_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") @@ -287,10 +287,6 @@ def main(): 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) - 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)) egg.sendline(CR) @@ -670,6 +666,7 @@ def main(): if (args.action == "enable_network_5ghz"): if args.series == "9800": egg.sendline("config t") + i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: egg.sendline("no ap dot11 5ghz shutdown") j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) @@ -807,7 +804,7 @@ def main(): if i == 1: print("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": @@ -837,6 +834,31 @@ def main(): 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") + i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) + if i == 0: + print("elevated to (config)#") + cmd = "no wlan %s"%(args.wlan) + egg.sendline(cmd) + j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) + if j == 0: + print("received elevated (config)# after no wlan {}".format(args.wlan)) + egg.sendline(cmd) + if j == 1: + print("did not get the (config# prompt") + egg.sendline(cmd) + if i == 1: + print("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): diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 5b817e75..bca4d276 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -510,12 +510,14 @@ def main(): 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]) - # 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]) 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, @@ -529,6 +531,8 @@ def main(): # 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, From ae3a7fff3acc926039ea3cdb59d2a6beb10eb299 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 12:17:14 -0600 Subject: [PATCH 05/34] port updates --- cisco_wifi_ctl.py | 2 +- lf_cisco_power.py | 74 +++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 680981c2..0da204a3 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -81,7 +81,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") diff --git a/lf_cisco_power.py b/lf_cisco_power.py index bca4d276..99a6a839 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -386,7 +386,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,7 +457,7 @@ 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" @@ -467,40 +467,40 @@ def main(): 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_wlan","--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]) + "--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]) 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", 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") 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... @@ -508,7 +508,7 @@ 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", ch, "--series" , args.series]) + "--action", "channel", "--value", ch, "--series" , args.series,"--port", args.port]) if args.series == "9800": #print("9800 cisco_wifi_ctl.py: delete_wlan") @@ -517,16 +517,16 @@ def main(): 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", "create_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 @@ -536,28 +536,28 @@ def main(): 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) @@ -566,7 +566,7 @@ def main(): 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) @@ -606,7 +606,7 @@ def main(): 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) @@ -693,7 +693,7 @@ def main(): 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], capture_output=True) + "--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True) pss = advanced.stdout.decode('utf-8', 'ignore') print(pss) if (args.wait_forever): @@ -1025,38 +1025,38 @@ def main(): 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... @@ -1064,36 +1064,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", @@ -1107,7 +1107,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) From 9473799e59857e8eac8ec1e7de0ea3785968a064 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 12:40:28 -0600 Subject: [PATCH 06/34] type issue on arg --- lf_cisco_power.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 99a6a839..4e201d84 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -136,7 +136,7 @@ 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") @@ -175,6 +175,7 @@ def main(): user = args.user passwd = args.passwd logfile = args.log + port = args.port if (args.station != None): lfstation = args.station if (args.upstream_port != None): @@ -386,7 +387,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,"--port", args.port], capture_output=True) + "--action", "summary","--series",args.series,"--port",args.port], capture_output=True) pss = advanced.stdout.decode('utf-8', 'ignore'); print(pss) From 49cd5cc468933d99fe5d53df4295b464cb425c62 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 12:52:07 -0600 Subject: [PATCH 07/34] modified logging --- cisco_wifi_ctl.py | 262 +++++++++++++++++++++++----------------------- 1 file changed, 131 insertions(+), 131 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 0da204a3..4b3c3edb 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -180,121 +180,121 @@ 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) 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) 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) 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) 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) 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) 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) 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) 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) 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 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 i == 2: - print("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after)) + 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: - print("9800 found User will put in args.user {} i: {} before {} after {}".format(args.user,i, egg.before,egg.after)) + 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(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 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: - 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 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) 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 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 @@ -325,187 +325,187 @@ def main(): 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) j = egg.expect_exact(["WLC>","WLC#","ser\:","Password:",pexpect.TIMEOUT],timeout=3) sleep(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) 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) 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) 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) 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)) + 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) 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) 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) 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) 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 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 i == 2: - print("9800 found # so logged in can start sending commands i {} before {} after {}".format(i,egg.before,egg.after)) + 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: - print("9800 found User will put in args.user {} j: {} before {} after {}".format(args.user,j, egg.before,egg.after)) + 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(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 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: - 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 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) 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) 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) 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) 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) 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) 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)) + 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) 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) 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) @@ -514,10 +514,10 @@ def main(): 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: @@ -630,17 +630,17 @@ def main(): egg.sendline("ap dot11 5ghz shutdown") 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") 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") 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": @@ -651,17 +651,17 @@ def main(): egg.sendline("ap dot11 24ghz shutdown") 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") 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") 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": @@ -673,9 +673,9 @@ def main(): if j == 0: egg.sendline("end") 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": @@ -687,9 +687,9 @@ def main(): if j == 0: egg.sendline("end") 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 == "enable" and (args.ap is None)): raise Exception("action requires AP name") @@ -758,7 +758,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) @@ -768,12 +768,12 @@ def main(): sleep(0.1) j = egg.expect_exact(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) if j == 0: - print("command sent: {}".format(command)) + logg.info("command sent: {}".format(command)) egg.sendline("end") if j == 1: - print("command time out: {}".format(command)) + logg.info("command time 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,22 +787,22 @@ 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") if j == 1: - print("command timed out {}".format(command)) + logg.info("command timed out {}".format(command)) egg.sendline("end") 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 == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): raise Exception("wlan and wlanID is required an") @@ -811,9 +811,9 @@ def main(): egg.sendline("config t") 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) j = egg.expect_exact(["WLC(config-wlan)#",pexpect.TIMEOUT],timeout=2) if j == 0: @@ -823,14 +823,14 @@ 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") 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) @@ -842,18 +842,18 @@ def main(): egg.sendline("config t") i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: - print("elevated to (config)#") + logg.info("elevated to (config)#") cmd = "no wlan %s"%(args.wlan) egg.sendline(cmd) j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if j == 0: - print("received elevated (config)# after no wlan {}".format(args.wlan)) + logg.info("received elevated (config)# after no wlan {}".format(args.wlan)) egg.sendline(cmd) if j == 1: - print("did not get the (config# prompt") + logg.info("did not get the (config# prompt") egg.sendline(cmd) if i == 1: - print("did not get the (config)# prompt") + 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") @@ -867,7 +867,7 @@ def main(): egg.sendline("config t") 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) j = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) @@ -880,15 +880,15 @@ 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") if k == 1: - print("cmd timed out: {}".format(cmd)) + logg.info("cmd timed out: {}".format(cmd)) egg.sendline("end") 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") @@ -910,42 +910,42 @@ def main(): else: logg.info("Command[%s]"%command) egg.sendline(command) - print("command sent {}".format(command)) + 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") except: - print("9800 exception on exit") + logg.info("9800 exception on exit") sleep(1) try: - print("9800 send carriage return and linefeed") + logg.info("9800 send carriage return and linefeed") egg.sendline("\r\n") except: - print("9800 exception on carriage return and linefeed") + logg.info("9800 exception on carriage return and linefeed") break if i == 2: egg.sendline("end") sleep(0.2) egg.sendline("exit") if i == 3: - print("are you sure received after command sent") + logg.info("are you sure received after command sent") egg.sendline("y") break if i == 4: - print("--More-- or received") + logg.info("--More-- or received") egg.sendline(NL) if i == 5: - print("expect timeout") + logg.info("expect timeout") break @@ -953,12 +953,12 @@ 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") if i == 4: - print("pexpect timeout on logout") + logg.info("pexpect timeout on logout") From 00787da7a8add560e3be9935ee01efd3d9f8d778 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 15:31:53 -0600 Subject: [PATCH 08/34] ability to create a station --- lf_cisco_power.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 4e201d84..59d4060d 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -143,12 +143,18 @@ def main(): 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("-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("--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="wlan-open") + parser.add_argument("--ssidpw", type=str, help="ssidpw default [BLANK]",default="[BLANK]") + parser.add_argument("--security", type=str, help="security default open",default="open") + 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") @@ -357,6 +363,19 @@ 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.passwd, + "security", args.security, "--upstream", args.upstream_port, "--first_ip", "DHCP", + "--first_sta",args.create_station,"--duration","1","--cxtype","udp"], capture_output=True) + sleep(3) + exit(1) + # Find LANforge station parent radio parent = None @@ -368,6 +387,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", From 616bdd1e1799d99f59798ce21d490ab80fd0058c Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 06:41:10 -0600 Subject: [PATCH 09/34] update minor name change so all results start with same letter --- lf_cisco_power.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 59d4060d..61af9a4b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -62,7 +62,7 @@ lfstation = "sta00000" lfresource = "1" lfresource2 = "1" outfile = "cisco_power_results.txt" -full_outfile = "full_cisco_power_results.txt" +full_outfile = "cisco_full_power_results.txt" outfile_xlsx = "cisco_power_results.xlsx" upstream_port = "eth1" pf_dbm = 6 @@ -374,7 +374,6 @@ def main(): "security", args.security, "--upstream", args.upstream_port, "--first_ip", "DHCP", "--first_sta",args.create_station,"--duration","1","--cxtype","udp"], capture_output=True) sleep(3) - exit(1) # Find LANforge station parent radio From b380352b10d0d4038b220c20aa843ac2c11bb3e8 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 07:15:24 -0600 Subject: [PATCH 10/34] updated comments --- lf_cisco_power.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 61af9a4b..b427e867 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -30,6 +30,22 @@ The user is responsible for setting up the station oustide of this script, howev --station sta00000 --bandwidth "20" --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 -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 64 --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 -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 ''' From 0297bfa4454b4e79a9d1f0ba5368b1d41a2b129a Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 09:40:34 -0600 Subject: [PATCH 11/34] race condition with 9800 --- cisco_wifi_ctl.py | 100 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 31 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 4b3c3edb..3c21d652 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -183,17 +183,17 @@ def main(): 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: 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: 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: logg.info("9800 Successfully received # prompt l {}".format(l)) @@ -208,12 +208,12 @@ def main(): if j == 2: 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: 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: logg.info("8900 Successfully received # prompt l: {}".format(l)) @@ -225,7 +225,7 @@ def main(): if j == 3: 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: logg.info("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after)) @@ -235,16 +235,17 @@ def main(): if j == 4: 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: 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: 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: logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after)) @@ -261,7 +262,7 @@ def main(): 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(1) + 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)) @@ -279,7 +280,7 @@ def main(): if i == 4: 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: logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after)) @@ -303,9 +304,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) @@ -335,18 +338,18 @@ def main(): 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: 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: 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: logg.info("9800 Successfully received # prompt l {}".format(l)) @@ -361,12 +364,12 @@ def main(): if j == 2: 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: 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: logg.info("8900 Successfully received # prompt l: {}".format(l)) @@ -376,10 +379,10 @@ def main(): 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 j == 3: - sleep(1) + 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: logg.info("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after)) @@ -389,16 +392,17 @@ def main(): if j == 4: 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: 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: 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: logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l, egg.before,egg.after)) @@ -415,7 +419,7 @@ def main(): 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(1) + 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)) @@ -433,7 +437,7 @@ def main(): if i == 4: 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: logg.info("9800 Successfully received # prompt l {} before {} after {}".format(l,egg.before,egg.after)) @@ -450,16 +454,16 @@ def main(): 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: 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: 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: logg.info("9800 Successfully received # prompt l {}".format(l)) @@ -474,12 +478,12 @@ def main(): if j == 2: 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: 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: logg.info("8900 Successfully received # prompt l: {}".format(l)) @@ -489,10 +493,10 @@ def main(): 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 j == 3: - sleep(1) + 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: logg.info("8900 Successfully received # prompt k: {} before {} after {}".format(k,egg.before,egg.after)) @@ -502,12 +506,13 @@ def main(): if j == 4: 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: 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 @@ -628,17 +633,20 @@ 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: 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: 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: logg.info("timed out on (config)# disable_network_5ghz") @@ -649,29 +657,35 @@ 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: 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: 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: 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: logg.info("timed out on (config)# no ap dot11 5ghz shutdown") if i == 1: @@ -680,12 +694,15 @@ def main(): 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: logg.info("timed out on (config)# no ap dot11 24ghz shutdown") if i == 1: @@ -770,6 +787,7 @@ def main(): if j == 0: logg.info("command sent: {}".format(command)) egg.sendline("end") + sleep(0.1) if j == 1: logg.info("command time out: {}".format(command)) if i == 1: @@ -789,9 +807,11 @@ def main(): if j == 0: logg.info("command sent: {}".format(command)) egg.sendline("end") + sleep(0.1) if j == 1: logg.info("command timed out {}".format(command)) egg.sendline("end") + sleep(0.1) if i == 1: logg.info("did not get the (config)# prompt") @@ -809,12 +829,14 @@ def main(): 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: logg.info("elevated to (config)#") command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) 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", @@ -827,6 +849,7 @@ def main(): if k == 1: logg.info("command time out: {}".format(command)) egg.sendline("end") + sleep(0.1) if j == 1: logg.info("did not get the (config-wlan)# prompt") if i == 0: @@ -840,18 +863,22 @@ def main(): 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) + egg.sendline(cmd) + sleep(0.1) if i == 1: logg.info("did not get the (config)# prompt") else: @@ -865,11 +892,13 @@ def main(): 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 = "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"): @@ -882,9 +911,11 @@ def main(): if k == 0: logg.info("cmd sent: {}".format(cmd)) egg.sendline("end") + sleep(0.1) if k == 1: logg.info("cmd timed out: {}".format(cmd)) egg.sendline("end") + sleep(0.1) if j == 1: logg.info("did not get the (config-wlan)# prompt") if i == 1: @@ -910,6 +941,7 @@ def main(): else: logg.info("Command[%s]"%command) egg.sendline(command) + sleep(0.1) logg.info("command sent {}".format(command)) sleep(1) @@ -924,12 +956,14 @@ def main(): try: logg.info("9800 send exit") egg.sendline("exit") + sleep(0.1) except: logg.info("9800 exception on exit") sleep(1) try: logg.info("9800 send carriage return and linefeed") egg.sendline("\r\n") + sleep(0.1) except: logg.info("9800 exception on carriage return and linefeed") break @@ -937,13 +971,16 @@ def main(): egg.sendline("end") sleep(0.2) egg.sendline("exit") + sleep(0.1) if i == 3: logg.info("are you sure received after command sent") egg.sendline("y") + sleep(0.1) break if i == 4: logg.info("--More-- or received") egg.sendline(NL) + sleep(0.1) if i == 5: logg.info("expect timeout") break @@ -957,6 +994,7 @@ def main(): i = egg.expect([LOGOUTPROMPT, EXITPROMPT, CLOSEDBYREMOTE, CLOSEDCX,pexpect.TIMEOUT],timeout=3) if i == 0: egg.sendline("y") + sleep(0.1) if i == 4: logg.info("pexpect timeout on logout") From 9df8c5a507e979da2be5953a06589f1ff5c18efc Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 09:51:23 -0600 Subject: [PATCH 12/34] removed extra end being sent --- cisco_wifi_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 3c21d652..aadc9c42 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -780,7 +780,7 @@ def main(): sleep(0.1) i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: - for command in ["wireless tag policy default-policy-tag","wlan open-wlan policy default-policy-profile","end"]: + for command in ["wireless tag policy default-policy-tag","wlan open-wlan policy default-policy-profile"]: egg.sendline(command) sleep(0.1) j = egg.expect_exact(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) From 3eb751c83d897a5a847b2f6532150b487e309529 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 10:00:09 -0600 Subject: [PATCH 13/34] cleanup logout 9800 --- cisco_wifi_ctl.py | 9 +-------- lf_cisco_power.py | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index aadc9c42..6c8e2e79 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -935,7 +935,7 @@ def main(): if (command is None): 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: @@ -960,13 +960,6 @@ def main(): except: logg.info("9800 exception on exit") sleep(1) - try: - logg.info("9800 send carriage return and linefeed") - egg.sendline("\r\n") - sleep(0.1) - except: - logg.info("9800 exception on carriage return and linefeed") - break if i == 2: egg.sendline("end") sleep(0.2) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b427e867..b252cde7 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -597,7 +597,6 @@ def main(): # 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") From b9ab71db11d65710b1a01d6d2e6aeae9a23fe227 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 10:07:32 -0600 Subject: [PATCH 14/34] cleanup --- cisco_wifi_ctl.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 6c8e2e79..ee034358 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -953,17 +953,8 @@ def main(): break if i == 1: logg.info("WLC# prompt received after command sent") - try: - logg.info("9800 send exit") - egg.sendline("exit") - sleep(0.1) - except: - logg.info("9800 exception on exit") - sleep(1) if i == 2: egg.sendline("end") - sleep(0.2) - egg.sendline("exit") sleep(0.1) if i == 3: logg.info("are you sure received after command sent") From ce28bfd3a4f117cc9f757730b76c5cad0f110c86 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 10:12:36 -0600 Subject: [PATCH 15/34] bug fix on setting policy --- cisco_wifi_ctl.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index ee034358..f9386af0 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -780,14 +780,12 @@ def main(): sleep(0.1) i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: - for command in ["wireless tag policy default-policy-tag","wlan open-wlan policy default-policy-profile"]: + 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) if j == 0: logg.info("command sent: {}".format(command)) - egg.sendline("end") - sleep(0.1) if j == 1: logg.info("command time out: {}".format(command)) if i == 1: From bce01d421892b5e1fd1b380ac6d19657bcbe08f9 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 10:18:43 -0600 Subject: [PATCH 16/34] policy fixes --- cisco_wifi_ctl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index f9386af0..640685c6 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -783,11 +783,13 @@ 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: logg.info("command sent: {}".format(command)) if j == 1: - logg.info("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: logg.info("did not get the (config)# prompt") From cd0fef74193601909be5205d87e159121bceb020 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 10:23:29 -0600 Subject: [PATCH 17/34] logout clean up 9800 --- cisco_wifi_ctl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 640685c6..4bead63f 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -953,9 +953,11 @@ def main(): break if i == 1: logg.info("WLC# prompt received after command sent") + break if i == 2: egg.sendline("end") sleep(0.1) + break if i == 3: logg.info("are you sure received after command sent") egg.sendline("y") @@ -965,6 +967,7 @@ def main(): logg.info("--More-- or received") egg.sendline(NL) sleep(0.1) + break if i == 5: logg.info("expect timeout") break From 5313cbd87069fc5da6cf9d82fde3860006abde9b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 10:31:41 -0600 Subject: [PATCH 18/34] removed break --- cisco_wifi_ctl.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 4bead63f..b88abc5a 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -967,7 +967,6 @@ def main(): logg.info("--More-- or received") egg.sendline(NL) sleep(0.1) - break if i == 5: logg.info("expect timeout") break From 472b83801740908ceab6f79886aed62fc4bed19d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 11:04:16 -0600 Subject: [PATCH 19/34] fix to logout logic --- cisco_wifi_ctl.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index b88abc5a..f914081d 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -953,9 +953,18 @@ def main(): break if i == 1: logg.info("WLC# prompt received after command sent") + try: + logg.info("9800 send exit") + egg.sendline("exit") + sleep(0.1) + except: + 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: From 13327ca70bb943f91888e7c929165747d2c93978 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 18 Sep 2020 13:10:19 -0600 Subject: [PATCH 20/34] debug bandwidth issue --- lf_cisco_power.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b252cde7..5ae9440b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -533,10 +533,17 @@ def main(): 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,"--port", args.port]) if (bw != "NA"): - print("9800 / 3504 cisco_wifi_ctl.py: bandwidth") + print("*********************************************") + print("*********************************************") + print("9800 / 3504 cisco_wifi_ctl.py: bandwidth {}".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,"--port", args.port]) + print("9800 / 3504 cisco_wifi_ctl.py: bandwidth {}".format(bw)) + print("*********************************************") + print("*********************************************") + + # NSS is set on the station earlier... From 0ad8d1af9f62a04ff1dd3a7a11a6fe10cb7ce8e5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Sat, 19 Sep 2020 10:32:23 -0600 Subject: [PATCH 21/34] added keep state, updated timing for allowing commands to settle --- cisco_wifi_ctl.py | 4 ++- lf_cisco_power.py | 75 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index f914081d..37e9e063 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -95,6 +95,7 @@ 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", @@ -934,6 +935,7 @@ 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: {}".format(command)) else: @@ -941,7 +943,7 @@ def main(): else: logg.info("Command[%s]"%command) egg.sendline(command) - sleep(0.1) + sleep(0.5) logg.info("command sent {}".format(command)) sleep(1) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 5ae9440b..c598eaad 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -27,12 +27,12 @@ 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 -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 64 --band a \ +--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 @@ -102,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 @@ -160,22 +172,16 @@ def main(): 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("-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("--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="wlan-open") - parser.add_argument("--ssidpw", type=str, help="ssidpw default [BLANK]",default="[BLANK]") - parser.add_argument("--security", type=str, help="security default open",default="open") + 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") @@ -187,7 +193,18 @@ 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("--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="wlan-open") + 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() @@ -533,16 +550,11 @@ def main(): 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,"--port", args.port]) if (bw != "NA"): - print("*********************************************") - print("*********************************************") print("9800 / 3504 cisco_wifi_ctl.py: bandwidth {}".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,"--port", args.port]) print("9800 / 3504 cisco_wifi_ctl.py: bandwidth {}".format(bw)) - print("*********************************************") - print("*********************************************") - # NSS is set on the station earlier... @@ -677,7 +689,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?" @@ -1062,6 +1074,21 @@ 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") From 4448afa5675e4bbdacf990c876a2867d47eb5bd1 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Sat, 19 Sep 2020 10:44:52 -0600 Subject: [PATCH 22/34] create station bug fixes --- lf_cisco_power.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index c598eaad..b338bd74 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -200,7 +200,7 @@ def main(): 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="wlan-open") + 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") @@ -403,7 +403,7 @@ def main(): 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.passwd, + 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"], capture_output=True) sleep(3) From 34b519b0bc3cac0271e8b5a69a64452a2ce18db6 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Sat, 19 Sep 2020 10:56:43 -0600 Subject: [PATCH 23/34] automatically use the created station --- lf_cisco_power.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b338bd74..b31ef06b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -217,6 +217,10 @@ def main(): 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): From 834c870b2f7029487a7d2238383445d6695c3400 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Sat, 19 Sep 2020 11:54:26 -0600 Subject: [PATCH 24/34] added --action add to the ./lf_associate_ap call prevent hang if no AP --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b31ef06b..4ca62fe4 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -409,7 +409,7 @@ def main(): 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"], capture_output=True) + "--first_sta",args.create_station,"--duration","1","--cxtype","udp","--action","add"], timeout=20, capture_output=True) sleep(3) From 9724b51071527a168a9e4992409d5aa3d00e924b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Sat, 19 Sep 2020 13:14:59 -0600 Subject: [PATCH 25/34] log information to triage bandwith issue --- lf_cisco_power.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 4ca62fe4..f9266350 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -548,23 +548,22 @@ def main(): 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","--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,"--port", args.port]) if (bw != "NA"): - print("9800 / 3504 cisco_wifi_ctl.py: bandwidth {}".format(bw)) + 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,"--port", args.port]) - print("9800 / 3504 cisco_wifi_ctl.py: bandwidth {}".format(bw)) - # 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,"--port", args.port]) @@ -591,7 +590,6 @@ def main(): # 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, @@ -652,6 +650,11 @@ def main(): 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))) + print("9800 test_parameters_summary: read: tx: {} ch: {} bw: {}".format(tx,ch,bw)) + print("9800 test_parameters tx: read : {}".format(cc_power)) + print("9800 test_parameters bandwidth: read : {}".format(cc_bw)) + print("9800 test_parameters channel: read : {}".format(cc_ch)) + break if (cc_dbm == ""): From 2d5328c564780b323c3af07c0f9727ef3dac7c00 Mon Sep 17 00:00:00 2001 From: shivamcandela Date: Tue, 22 Sep 2020 00:25:22 +0530 Subject: [PATCH 26/34] Test including stuff --- py-scripts/lf_dut_sta_vap_test.py | 387 ++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 py-scripts/lf_dut_sta_vap_test.py diff --git a/py-scripts/lf_dut_sta_vap_test.py b/py-scripts/lf_dut_sta_vap_test.py new file mode 100644 index 00000000..79cba8cc --- /dev/null +++ b/py-scripts/lf_dut_sta_vap_test.py @@ -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() + From 0bad97c7a767956a1e803c89927a064a9230c810 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 21 Sep 2020 14:56:45 -0600 Subject: [PATCH 27/34] added time stamp to output files for lf_cisco_power.py , added seconds --- lf_cisco_power.py | 17 +++++++++++++---- py-scripts/test_l3_longevity.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index f9266350..e0ce6bf6 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -77,9 +77,9 @@ lfmgr = "127.0.0.1" lfstation = "sta00000" lfresource = "1" lfresource2 = "1" -outfile = "cisco_power_results.txt" -full_outfile = "cisco_full_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 @@ -185,7 +185,7 @@ def main(): 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"]) @@ -242,6 +242,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); diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 093b6c88..a70238b2 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -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)) From 45b9daaf41c1f15812fb113396691f3658fed1fc Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 07:11:33 -0600 Subject: [PATCH 28/34] clean up login --- cisco_wifi_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 37e9e063..539d2962 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -325,7 +325,7 @@ def main(): found_escape = False if args.series == "9800": while logged_in_9800 == False and loop_count <= 2: - #egg.sendline(CR) + egg.sendline(CR) try: i = egg.expect_exact(["Escape character is '^]'.","WLC>","WLC#","ser\:","Password:","WLC(config)#",pexpect.TIMEOUT],timeout=2) except pexpect.EOF as e: From 2a69d7a1f935408024ccb4f2781127c94f476e6e Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 08:02:16 -0600 Subject: [PATCH 29/34] need additional sleep after 1st prompt --- cisco_wifi_ctl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 539d2962..9fe8711a 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -326,6 +326,7 @@ def main(): if args.series == "9800": while logged_in_9800 == False and loop_count <= 2: egg.sendline(CR) + sleep(1) try: i = egg.expect_exact(["Escape character is '^]'.","WLC>","WLC#","ser\:","Password:","WLC(config)#",pexpect.TIMEOUT],timeout=2) except pexpect.EOF as e: From ec74ab5656b8677aca91b928509dde3a65a28a48 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 08:17:09 -0600 Subject: [PATCH 30/34] increased sleep after prompt, --- cisco_wifi_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 9fe8711a..9ea11234 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -326,7 +326,7 @@ def main(): if args.series == "9800": while logged_in_9800 == False and loop_count <= 2: egg.sendline(CR) - sleep(1) + 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: From 854120dae0ef298142938a2ca75f8e1e550caf61 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 08:35:46 -0600 Subject: [PATCH 31/34] show wlan summary after configure to see SSID --- lf_cisco_power.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index e0ce6bf6..1b5b7528 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -672,6 +672,11 @@ 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") From 14674c2ddbdbb8c03343747aa35f17332d836acf Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 12:04:23 -0600 Subject: [PATCH 32/34] print dbm --- lf_cisco_power.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1b5b7528..04ce790f 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -663,6 +663,8 @@ def main(): print("9800 test_parameters tx: read : {}".format(cc_power)) print("9800 test_parameters bandwidth: read : {}".format(cc_bw)) print("9800 test_parameters channel: read : {}".format(cc_ch)) + print("9800 test_parameters dbm: read : {}".format(cc_dbm)) + break From 9333cb474547ffdf70ccbeddd25151dc53d07610 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 14:06:33 -0600 Subject: [PATCH 33/34] ability to test with specific AP slot defaults to 1 --- lf_cisco_power.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 04ce790f..6e214a96 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -197,6 +197,7 @@ def main(): 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") @@ -647,26 +648,32 @@ 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) 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_slot= m.group(2) + print("cc_slot: {}".format(cc_slot)) + if (args.slot == cc_slot): + cc_mac = m.group(1) + cc_slot = m.group(2) + cc_ch = m.group(6); # (132,136,140,144) + cc_power = m.group(4) + cc_power = cc_power.replace("*/", " of ", 1) # spread-sheets turn 1/8 into a date + cc_dbm = m.group(5) - 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))) - print("9800 test_parameters_summary: read: tx: {} ch: {} bw: {}".format(tx,ch,bw)) - print("9800 test_parameters tx: read : {}".format(cc_power)) - print("9800 test_parameters bandwidth: read : {}".format(cc_bw)) - print("9800 test_parameters channel: read : {}".format(cc_ch)) - print("9800 test_parameters dbm: read : {}".format(cc_dbm)) + cc_ch_count = cc_ch.count(",") + cc_bw = m.group(3) + 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)) - - break + 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? From 276ac894d23e300b36b3ec9df574985d78a1fbc7 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 22 Sep 2020 14:35:34 -0600 Subject: [PATCH 34/34] bug fix, be more specific with slot --- cisco_wifi_ctl.py | 7 +++++++ lf_cisco_power.py | 41 +++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 9ea11234..376af0f2 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -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" + ''' diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 6e214a96..bdc20d0b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -648,32 +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_slot= m.group(2) - print("cc_slot: {}".format(cc_slot)) - if (args.slot == cc_slot): - cc_mac = m.group(1) - cc_slot = m.group(2) - cc_ch = m.group(6); # (132,136,140,144) - cc_power = m.group(4) - cc_power = cc_power.replace("*/", " of ", 1) # spread-sheets turn 1/8 into a date - cc_dbm = m.group(5) + 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) - cc_ch_count = cc_ch.count(",") - cc_bw = m.group(3) - 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)) + 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 + 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?