diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index f5d1bd3d..ef9052e7 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -11,6 +11,8 @@ $ sudo yum install python3-pexpect You might need to install pexpect-serial using pip: $ pip3 install pexpect-serial +$ sudo pip install pexpect-serial + ./cisco_ap_ctl.py ''' @@ -20,14 +22,16 @@ if sys.version_info[0] != 3: print("This script requires Python 3") exit() -#import re import logging import time from time import sleep -#import pprint -#import telnetlib import argparse import pexpect +import serial +from pexpect_serial import SerialSpawn + +# pip install pexpect-serial (on Ubuntu) +# sudo pip install pexpect-serial (on Ubuntu for everyone) default_host = "localhost" default_ports = { @@ -73,6 +77,10 @@ class FileAdapter(object): def flush(self): pass # leave it to logging to flush properly +# Test command if lanforge connected ttyUSB0 +# sudo ./cisco_ap_ctl.py -a lanforge -d 0 -o 0 -u "lanforge" -p "lanforge" -s "serial" -t "/dev/ttyUSB0" +# sample for lanforge 192.168.100.178 +# sudo ./cisco_ap_ctl.py -a APA53.0E7B.EF9C -d 0 -o 0 -u "admin" -p "Admin123" -s "serial" -t "/dev/ttyUSB2" -z "show_log" def main(): global logfile @@ -121,9 +129,7 @@ def main(): try: if (scheme == "serial"): #eggspect = pexpect.fdpexpect.fdspan(telcon, logfile=sys.stdout.buffer) - import serial - from pexpect_serial import SerialSpawn - ser = serial.Serial(args.tty, 9600, timeout=5) + ser = serial.Serial(args.tty, 115200, timeout=5) print("Created serial connection on %s, open: %s"%(args.tty, ser.is_open)) egg = SerialSpawn(ser) egg.logfile = FileAdapter(logg) @@ -136,13 +142,6 @@ def main(): egg = pexpect.spawn(cmd) #egg.logfile_read = sys.stdout.buffer egg.logfile = FileAdapter(logg) - i = egg.expect(["password:", "continue connecting (yes/no)?"], timeout=3) - time.sleep(0.1) - if i == 1: - egg.sendline('yes') - egg.expect('password:') - sleep(0.1) - egg.sendline(args.passwd) elif (scheme == "telnet"): if (port is None): port = 23 @@ -165,13 +164,14 @@ def main(): AP_EN = "en" AP_MORE = "--More--" AP_EXIT = "exit" + LF_PROMPT = "$" CR = "\r\n" time.sleep(0.1) logged_in = False loop_count = 0 while (loop_count <= 8 and logged_in == False): loop_count += 1 - i = egg.expect_exact([AP_ESCAPE,AP_PROMPT,AP_HASH,AP_USERNAME,AP_PASSWORD,AP_MORE,pexpect.TIMEOUT],timeout=5) + i = egg.expect_exact([AP_ESCAPE,AP_PROMPT,AP_HASH,AP_USERNAME,AP_PASSWORD,AP_MORE,LF_PROMPT,pexpect.TIMEOUT],timeout=5) if i == 0: logg.info("Expect: {} i: {} before: {} after: {}".format(AP_ESCAPE,i,egg.before,egg.after)) egg.sendline(CR) # Needed after Escape or should just do timeout and then a CR? @@ -196,7 +196,15 @@ def main(): logg.info("Expect: {} i: {} before: {} after: {}".format(AP_MORE,i,egg.before,egg.after)) egg.sendcontrol('c') sleep(0.2) + # for Testing serial connection using Lanforge if i == 6: + logg.info("Expect: {} i: {} before: {} after: {}".format(LF_PROMPT,i,egg.before.decode('utf-8', 'ignore'),egg.after.decode('utf-8', 'ignore'))) + if (loop_count < 3): + egg.send("ls -lrt") + sleep(0.2) + if (loop_count > 4): + logged_in = True # basically a test mode using lanforge serial + if i == 7: logg.info("Expect: {} i: {} before: {} after: {}".format("Timeout",i,egg.before,egg.after)) egg.sendline(CR) sleep(0.2) @@ -223,18 +231,30 @@ def main(): print(egg.before.decode('utf-8', 'ignore')) # do not delete this for it allows for subprocess to see output # allow for normal logout below + elif (args.action == "show_log"): + logg.info("execute: show log") + egg.sendline('show log') + sleep(0.4) + egg.expect([pexpect.TIMEOUT], timeout=2) # do not delete this for it allows for subprocess to see output + print(egg.before.decode('utf-8', 'ignore')) # do not delete this for it allows for subprocess to see output + # allow for normal logout below + # show log | g DOT11_DRV + else: # no other command at this time so send the same power command - logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1") + #logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1") + logg.info("no action so execute: show log") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') egg.expect([pexpect.TIMEOUT], timeout=3) # do not delete this allows for subprocess to see output print(egg.before.decode('utf-8', 'ignore')) # do not delete this allows for subprocess to see output i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5) + # s if i == 0: egg.sendcontrol('c') if i == 1: logg.info("send cntl c anyway, received timeout") egg.sendcontrol('c') + exit(1) i = egg.expect_exact([AP_PROMPT,AP_HASH,pexpect.TIMEOUT],timeout=1) if i == 0: @@ -247,6 +267,105 @@ def main(): logg.info("timed out waiting for {} or {}".format(AP_PROMPT,AP_HASH)) # ctlr.execute(cn_cmd) + +''' NOTES for AP DFS + +Password: [*02/09/2021 14:30:04.2290] Radio [1] Admininstrative state ENABLED change to DISABLED +[*02/09/2021 14:30:04.2300] DOT11_DRV[1]: Stop Radio1 +[*02/09/2021 14:30:04.2520] DOT11_DRV[1]: DFS CAC timer enabled time 60 +[*02/09/2021 14:30:04.2740] DOT11_DRV[1]: DFS CAC timer enabled time 60 +[*02/09/2021 14:30:04.2740] Stopped Radio 1 +[*02/09/2021 14:30:36.2810] Radio [1] Admininstrative state DISABLED change to ENABLED +[*02/09/2021 14:30:36.3160] DOT11_DRV[1]: set_channel Channel set to 52/20 <<<<<< ???? +[*02/09/2021 14:30:36.3390] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:36.4420] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:36.5440] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:36.6490] DOT11_DRV[1]: DFS CAC timer enabled time 60 <<<<<< ???? +[*02/09/2021 14:30:37.2100] wl0: wlc_iovar_ext: vap_amsdu_rx_max: BCME -23 +[*02/09/2021 14:30:37.2100] wl: Unsupported +[*02/09/2021 14:30:37.2100] ERROR: return from vap_amsdu_rx_max was -45 +[*02/09/2021 14:30:37.4100] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:37.5040] DOT11_CFG[1]: Starting radio 1 +[*02/09/2021 14:30:37.5050] DOT11_DRV[1]: Start Radio1 <<<<<<<<< +[*02/09/2021 14:30:37.5120] DOT11_DRV[1]: set_channel Channel set to 52/20 +[*02/09/2021 14:30:37.5340] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:37.6360] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:37.7370] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:37.8410] DOT11_DRV[1]: DFS CAC timer enabled time 60 <<<<<<< +[*02/09/2021 14:30:37.8650] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 14:30:37.9800] changed to DFS channel 52, running CAC for 60 seconds. <<<<< Note use this one +[*02/09/2021 14:30:38.0020] Started Radio 1 <<<<< After start radio +[*02/09/2021 14:31:07.4650] wl0: wlc_iovar_ext: olpc_cal_force: BCME -16 +[*02/09/2021 14:31:38.4210] CAC_EXPIRY_EVT: CAC finished on DFS channel 52 <<<<<< Start with this very unique CAC finished +[*02/09/2021 14:31:48.2850] chatter: client_ip_table :: ClientIPTable no client entry found, dropping packet 04:F0:21:F + +# note lf_hackrf.py begins transmitting immediately... see if that is what is to happen? + +[*02/09/2021 15:20:53.7470] wcp/dfs :: RadarDetection: radar detected <<<<< Radar detected +[*02/09/2021 15:20:53.7470] wcp/dfs :: RadarDetection: sending packet out to capwapd, slotId=1, msgLen=386, chanCnt=1 2 +[*02/09/2021 15:20:53.7720] DOT11_DRV[1]: DFS CAC timer disabled time 0 +[*02/09/2021 15:20:53.7780] Enabling Channel and channel width Switch Announcement on current channel +[*02/09/2021 15:20:53.7870] DOT11_DRV[1]: set_dfs Channel set to 36/20, CSA count 6 <<<<<<< Channel Set +[*02/09/2021 15:20:53.8530] DOT11_DRV[1]: DFS CAC timer enabled time 60 + + +Trying another station +*02/09/2021 15:25:32.6130] Radio [1] Admininstrative state ENABLED change to DISABLED +[*02/09/2021 15:25:32.6450] DOT11_DRV[1]: Stop Radio1 +[*02/09/2021 15:25:32.6590] Stopped Radio 1 +[*02/09/2021 15:25:52.1700] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:04.6640] Radio [1] Admininstrative state DISABLED change to ENABLED +[*02/09/2021 15:26:04.6850] DOT11_DRV[1]: set_channel Channel set to 36/20 +[*02/09/2021 15:26:04.7070] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:04.8090] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:04.9090] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:05.5620] wl0: wlc_iovar_ext: vap_amsdu_rx_max: BCME -23 +[*02/09/2021 15:26:05.5620] wl: Unsupported +[*02/09/2021 15:26:05.5620] ERROR: return from vap_amsdu_rx_max was -45 +[*02/09/2021 15:26:05.7600] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:05.8530] DOT11_CFG[1]: Starting radio 1 +[*02/09/2021 15:26:05.8540] DOT11_DRV[1]: Start Radio1 +[*02/09/2021 15:26:05.8610] DOT11_DRV[1]: set_channel Channel set to 36/20 +[*02/09/2021 15:26:05.8830] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:05.9890] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:06.0900] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:06.2080] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:26:06.5350] Started Radio 1 +[*02/09/2021 15:26:15.9750] chatter: client_ip_table :: ClientIPTable no client entry found, dropping packet 04:F0:21: + + + + +Username: [*02/09/2021 15:33:49.8680] Radio [1] Admininstrative state ENABLED change to DISABLED +[*02/09/2021 15:33:49.9010] DOT11_DRV[1]: Stop Radio1 +[*02/09/2021 15:33:49.9160] Stopped Radio 1 +[*02/09/2021 15:34:14.4150] DOT11_DRV[1]: set_channel Channel set to 56/20 +[*02/09/2021 15:34:14.4370] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:14.5390] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:14.6400] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:14.7450] DOT11_DRV[1]: DFS CAC timer enabled time 60 +[*02/09/2021 15:34:21.9160] Radio [1] Admininstrative state DISABLED change to ENABLED +[*02/09/2021 15:34:21.9370] DOT11_DRV[1]: set_channel Channel set to 56/20 +[*02/09/2021 15:34:21.9590] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:22.0610] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:22.1610] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:22.2650] DOT11_DRV[1]: DFS CAC timer enabled time 60 +[*02/09/2021 15:34:22.8270] wl0: wlc_iovar_ext: vap_amsdu_rx_max: BCME -23 +[*02/09/2021 15:34:22.8270] wl: Unsupported +[*02/09/2021 15:34:22.8270] ERROR: return from vap_amsdu_rx_max was -45 +[*02/09/2021 15:34:23.0280] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:23.1210] DOT11_CFG[1]: Starting radio 1 +[*02/09/2021 15:34:23.1210] DOT11_DRV[1]: Start Radio1 +[*02/09/2021 15:34:23.1280] DOT11_DRV[1]: set_channel Channel set to 56/20 +[*02/09/2021 15:34:23.1510] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:23.2520] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:23.3520] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:23.4560] DOT11_DRV[1]: DFS CAC timer enabled time 60 +[*02/09/2021 15:34:23.4800] wlc_ucode_download: wl0: Loading 129 MU ucode +[*02/09/2021 15:34:23.5960] changed to DFS channel 56, running CAC for 60 seconds. +[*02/09/2021 15:34:23.6180] Started Radio 1 + +''' if __name__ == '__main__': main() diff --git a/py-scripts/lf_cisco_dfs.py b/py-scripts/lf_cisco_dfs.py index 04d97239..41984480 100755 --- a/py-scripts/lf_cisco_dfs.py +++ b/py-scripts/lf_cisco_dfs.py @@ -1420,6 +1420,12 @@ class L3VariableTime(Realm): writer.writerow(row) csv_file.flush() +######################################### +# +# AP helper functions +# +# ####################################### + def valid_endp_types(_endp_type): etypes = _endp_type.split() for endp_type in etypes: @@ -1690,6 +1696,12 @@ Eventual Realm at Cisco 6.wiphy8 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz 6.wiphy9 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz + +Sample script + + ./lf_cisco_dfs.py -cc 192.168.100.112 -cu admin -cpw Cisco123 -cca APA453.0E7B.CF9C -ccf "a" -cwm "auto" -cc5 "52" -ccw "20" -ccd "1" -cs "3504" --endp_type 'lf_udp' --upstream_port eth2 --cisco_wlan "test_candela" --cisco_wlanID 1 --cisco_wlanSSID "test_candela" --cisco_directions "upstream" --cisco_prompt "(Cisco Controller)" --radio "radio==1.wiphy0 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto" --ap_info "ap_scheme==serial ap_prompt==APA53.0E7B.EF9C ap_ip==0 ap_port==0 ap_user==admin ap_pw==Admin123 ap_tty==/dev/ttyUSB2" + + ''') # reorder to follow looping @@ -1756,7 +1768,15 @@ Eventual Realm at Cisco parser.add_argument('-bmp','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default=1518) # AP parameters - parser.add_argument('-api','--ap_info', action='append', nargs=1, type=str, help="--ap_info ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw==") + parser.add_argument('-api','--ap_info', action='append', nargs=1, type=str, \ + help='(enter 0 if does not apply) --ap_info \"ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw== ap_tty==\" ') + #--ap_info "ap_scheme==serial ap_prompt==APA53.0E7B.CF9C ap_ip==0 ap_port==0 ap_user==admin ap_pw==Admin123 ap_tty==/dev/ttyUSB2" + + '''./lf_cisco_dfs.py -cc 192.168.100.112 -cu admin -cpw Cisco123 -cca APA453.0E7B.CF9C -ccf "a" -cwm "auto" -cc5 "36" \ + -ccw "20" -ccd "1" -cs "3504" --endp_type 'lf_udp' --upstream_port eth2 --cisco_wlan "test_candela" --cisco_wlanID 1 \ + --cisco_wlanSSID "test_candela" --cisco_directions "upstream" --cisco_prompt "(Cisco Controller)" \ + --radio "radio==1.wiphy0 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto" \ + --ap_info "ap_scheme==serial ap_prompt--APA53.0E7B.EF9C ap_ip==0 ap_port==0 ap_user==admin ap_pw==Admin123 ap_tty==/dev/ttyUSB2" ''' # Parameters that allow for testing @@ -1840,7 +1860,7 @@ Eventual Realm at Cisco ap_info = args.ap_info for _ap_info in ap_info: print("ap_info {}".format(_ap_info)) - ap_keys = ['ap_scheme','ap_prompt','ap_ip','ap_port','ap_user','ap_pw'] + ap_keys = ['ap_scheme','ap_prompt','ap_ip','ap_port','ap_user','ap_pw', 'ap_tty'] ap_dict = dict(map(lambda x: x.split('=='), str(_ap_info).replace('[','').replace(']','').replace("'","").split())) for key in ap_keys: if key not in ap_dict: @@ -2193,6 +2213,11 @@ Eventual Realm at Cisco __chan_5ghz_set = None __chan_24ghz_set = None __csv_started = False + + __dfs_channel = None + __cac_timer_time = 0 + __dfs_chan_switch_to = None + for cisco_ap in cisco_aps: for cisco_band in cisco_bands: # frequency @@ -2205,6 +2230,8 @@ Eventual Realm at Cisco logg.info("#######################################################################") pass # invalid combination continue else: + # TODO the following + #[(x, y, z) for x in [1,2,3] for y in [4,5,6] for z in [7,8,9] if x != z]: for cisco_tx_power in cisco_tx_powers: for cisco_chan_5ghz in cisco_chan_5ghzs: for cisco_chan_24ghz in cisco_chan_24ghzs: @@ -2293,24 +2320,121 @@ Eventual Realm at Cisco cisco.controller_enable_network_5ghz() else: cisco.controller_enable_network_24ghz() + # clear logs on AP /dev/ttyUSB2 - candelatech + if(bool(ap_dict)): + logg.info("ap_dict {}".format(ap_dict)) + logg.info("Read AP action: {} ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {} ap_tty: {}".format("show_log",ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], + ap_dict['ap_user'],ap_dict['ap_pw'],ap_dict['ap_tty'])) + + # clear log (AP) + try: + logg.info("cisco_ap_ctl.py: clear log") + # TODO remove position dependence if in tree + ap_info= subprocess.run(["./../cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'],"--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--tty", ap_dict['ap_tty'],"--action", "clear_log"],stdout=subprocess.PIPE) + try: + pss = ap_info.stdout.decode('utf-8', 'ignore') + except: + logg.info("ap_info was of type NoneType will set pss empty") + pss = "empty" + except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + logg.info("####################################################################################################") + logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + logg.info(pss) + + # show log (AP) + try: + logg.info("cisco_ap_ctl.py: show log") + # TODO remove position dependence if in tree + ap_info= subprocess.run(["./../cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'],"--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--tty", ap_dict['ap_tty'],"--action", "show_log"],stdout=subprocess.PIPE) + try: + pss = ap_info.stdout.decode('utf-8', 'ignore') + except: + logg.info("ap_info was of type NoneType will set pss empty") + pss = "empty" + except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + logg.info("####################################################################################################") + logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + logg.info(pss) + exit(1) + cisco.controller_enable_ap() # need to actually check the CAC timer - time.sleep(30) + time.sleep(10) # When the AP moves to another DFS channel, the wait time is 60 second # the CAC (Channel Avaiability Check Time) if (int(__chan_5ghz_set) in dfs_channel_bw20_values): logg.info("DFS 5ghz channel {} being set wait CAC time 60, 2.4 ghz: {} : ".format(__chan_5ghz_set, __chan_24ghz_set)) + # read AP to verify CAC timer set # will need to use time to verify CAC from AP - need in results - time.sleep(65) - # will need to verify that timer has timed out on AP - need in results - logg.info("DFS channel 5ghz {} done waiting CAC time, 2.4 ghz: {}") + cac_sleeptime = "65" + logg.info("CAC sleep time start {}".format(cac_sleeptime)) + time.sleep(int(cac_sleeptime)) + logg.info("CAC sleeptime complete: {}".format(cac_sleeptime)) + if(bool(ap_dict)): + # will need to verify that timer has timed out on AP - need in results + logg.info("DFS channel 5ghz {} done waiting CAC time, 2.4 ghz: {}".format(__chan_5ghz_set, __chan_24ghz_set)) + logg.info("####################################################################################################") + logg.info("# READ changed to DFS channel {}, running CAC for 60 seconds.".format(__chan_5ghz_set)) + logg.info("# READ AP CAC_EXPIRY_EVT: CAC finished on DFS channel ") + logg.info("####################################################################################################") + + logg.info("ap_dict {}".format(ap_dict)) + logg.info("Read AP action: {} ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {} ap_tty: {}".format("show_log",ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], + ap_dict['ap_user'],ap_dict['ap_pw'],ap_dict['ap_tty'])) + + try: + logg.info("cisco_ap_ctl.py: read for CAC timer and CAC_EXPIRY_EVT") + # TODO remove position dependence if in tree + ap_info= subprocess.run(["./../cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'],"--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--tty", ap_dict['ap_tty'],"--action", "show_log"],stdout=subprocess.PIPE) + try: + pss = ap_info.stdout.decode('utf-8', 'ignore') + except: + logg.info("ap_info was of type NoneType will set pss empty") + pss = "empty" + + except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + + logg.info("####################################################################################################") + logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + + logg.info(pss) + # find the DFS Channel + for line in pss.splitlines(): + logg.info("ap: {}".format(line)) + pat = 'CAC_EXPIRY_EVT:\s+\S+\s+\S+\s+\S+\s\S+\s\S+\s(\S+)' + m = re.search(pat, line) + if (m != None): + __dfs_channel = m.group(1) + logg.info("__dfs_channel: {}".format(__dfs_channel)) + logg.info("__dfs_channel line: {}".format(line)) + else: + logg.info("__dfs_channel COULD NOT FIND LINE") + + else: logg.info("Non-DFS 5ghz channel {} being set sleep 30, 2.4 ghz: {} ".format(__chan_5ghz_set, __chan_24ghz_set)) time.sleep(30) + ########################################## + # end of cisco controller code + ########################################## + exit(1) - #################################### - # end of cisco controller code - #################################### + else: logg.info("###############################################") logg.info("# NO CHANGE TO CONTROLLER CONFIG") @@ -2322,6 +2446,9 @@ Eventual Realm at Cisco logg.info("cisco_wifi_mode {}".format(cisco_wifimode)) pss = cisco.controller_show_ap_summary() logg.info("pss {}".format(pss)) + ###################################################### + # end of cisco controller code no change to controller + ###################################################### if args.radio: radios = args.radio elif cisco_band == "a":