From bfc18cb3ed50aa4f7520f2b138ffab8a0f0df0b0 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 17 Sep 2020 11:37:36 -0600 Subject: [PATCH] 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,