From 636df56d28ccbec4f24c597d245b51e79002c9bf Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 10 Sep 2020 14:20:54 -0600 Subject: [PATCH 1/3] configuration for 9800 wlan open-wlan 1 open-wlan --- cisco_wifi_ctl.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 701879da..56ff5574 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -95,7 +95,7 @@ def main(): 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","ap_channel", "channel", "show", "wlan", "enable_wlan", "delete_wlan", "wlan_qos" ]) + "cmd", "txPower", "bandwidth", "manual", "auto", "open_wlan","ap_channel", "channel", "show", "wlan", "enable_wlan", "delete_wlan", "wlan_qos" ]) parser.add_argument("--value", type=str, help="set value") args = None @@ -475,6 +475,71 @@ def main(): else: command = "show ap channel %s"%(args.ap) + + if (args.action == "open_wlan"): + print("Configure a open wlan 9800 series") + egg.sendline("config t") + i = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + if i == 0: + print("elevated to (config)#") + egg.sendline("wlan open-wlan 1 open-wlan") + j = egg.expect(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) + if j == 0: + for command in ["no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", + "no security wpa akm dot1x","no shutdown","end"]: + egg.sendline(command) + sleep(0.1) + k = egg.expect(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) + if k == 0: + print("command sent: {}".format(command)) + if k == 1: + if command == "end": + pass + else: + print("command time out: {}".format(command)) + if j == 1: + print("did not get the (config-wlan)# prompt") + if i == 0: + print("did not get the (config)# prompt") + + print("send wireless tag policy") + egg.sendline("config t") + sleep(0.1) + i = egg.expect(["(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"]: + egg.sendline(command) + sleep(0.1) + j = egg.expect(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) + if j == 0: + print("command sent: {}".format(command)) + if j == 1: + if command == "end": + pass + else: + print("command time out: {}".format(command)) + if i == 1: + print("did not get the (config)# prompt") + + if (args.action == "no_open_wlan"): + egg.sendline("config t") + sleep(0.1) + i = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + if i == 0: + for command in ["no wlan open-wlan","end"]: + egg.sendline(command) + sleep(0.1) + j = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + if j == 0: + print("command sent: {}".format(command)) + if j == 1: + if command == "end": + pass + else: + print("command time out: {}".format(command)) + if i == 1: + print("did not get the (config)# prompt") + if (args.action == "wlan" and (args.wlanID is None)): raise Exception("wlan ID is required") if (args.action == "wlan"): From aff27021538ed5ed1ed6e7afb4d909d1270e8014 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 10 Sep 2020 14:27:09 -0600 Subject: [PATCH 2/3] added show wlan summary for 9800 series --- cisco_wifi_ctl.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 56ff5574..b7134e0e 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -95,7 +95,7 @@ def main(): 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", "open_wlan","ap_channel", "channel", "show", "wlan", "enable_wlan", "delete_wlan", "wlan_qos" ]) + "cmd", "txPower", "bandwidth", "manual", "auto", "open_wlan","no_open_wlan","show_wlan_summary","ap_channel", "channel", "show", "wlan", "enable_wlan", "delete_wlan", "wlan_qos" ]) parser.add_argument("--value", type=str, help="set value") args = None @@ -540,6 +540,15 @@ def main(): if i == 1: print("did not get the (config)# prompt") + if (args.action == "show_wlan_summary"): + egg.sendline("show wlan summary") + sleep(0.1) + i = egg.expect(["#",pexpect.TIMEOUT],timeout=2) + if i == 0: + print("show wlan summary sent") + if i == 1: + print("show wlan summary timed out") + if (args.action == "wlan" and (args.wlanID is None)): raise Exception("wlan ID is required") if (args.action == "wlan"): From fe46eb3316835d27da26e30f90a33417ce1a4fa3 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 10 Sep 2020 14:43:51 -0600 Subject: [PATCH 3/3] look for exact prompt --- cisco_wifi_ctl.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index b7134e0e..3e775eca 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -479,17 +479,17 @@ def main(): if (args.action == "open_wlan"): print("Configure a open wlan 9800 series") egg.sendline("config t") - i = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: print("elevated to (config)#") egg.sendline("wlan open-wlan 1 open-wlan") - j = egg.expect(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) + j = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) if j == 0: for command in ["no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", "no security wpa akm dot1x","no shutdown","end"]: egg.sendline(command) sleep(0.1) - k = egg.expect(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) + k = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) if k == 0: print("command sent: {}".format(command)) if k == 1: @@ -505,12 +505,12 @@ def main(): print("send wireless tag policy") egg.sendline("config t") sleep(0.1) - i = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + 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"]: egg.sendline(command) sleep(0.1) - j = egg.expect(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) + j = egg.expect_exact(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) if j == 0: print("command sent: {}".format(command)) if j == 1: @@ -524,12 +524,12 @@ def main(): if (args.action == "no_open_wlan"): egg.sendline("config t") sleep(0.1) - i = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: for command in ["no wlan open-wlan","end"]: egg.sendline(command) sleep(0.1) - j = egg.expect(["(config)#",pexpect.TIMEOUT],timeout=2) + j = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if j == 0: print("command sent: {}".format(command)) if j == 1: