mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	cisco_wifi_ctl.py, lf_cisco_power.py : need to get to working state.
This commit is contained in:
		| @@ -139,18 +139,19 @@ def main(): | ||||
|    logg = logging.getLogger(__name__) | ||||
|    logg.setLevel(logging.DEBUG) | ||||
|    file_handler = None | ||||
|    if (logfile is not None): | ||||
|        if (logfile != "stdout"): | ||||
|            file_handler = logging.FileHandler(logfile, "w") | ||||
|            file_handler.setLevel(logging.DEBUG) | ||||
|            file_handler.setFormatter(formatter) | ||||
|            logg.addHandler(file_handler) | ||||
|       logging.basicConfig(format=FORMAT, handlers=[console_handler]) | ||||
|            logging.basicConfig(format=FORMAT, handlers=[file_handler]) | ||||
|        else: | ||||
|            # stdout logging | ||||
|            logging.basicConfig(format=FORMAT, handlers=[console_handler]) | ||||
|  | ||||
|    logg.info("cisco series {}".format(args.series)) | ||||
|    logg.info("scheme {}".format(args.scheme)) | ||||
|    print("cisco series {}".format(args.series)) | ||||
|    print("scheme {}".format(args.scheme)) | ||||
|  | ||||
|    try: | ||||
|       if (scheme == "serial"): | ||||
| @@ -160,7 +161,7 @@ def main(): | ||||
|          with serial.Serial('/dev/ttyUSB0', 115200, timeout=5) as ser: | ||||
|             egg = SerialSpawn(ser); | ||||
|             egg.logfile = FileAdapter(logg) | ||||
|             logg.info("logg {}".format(logg)) | ||||
|             print("logg {}".format(logg)) | ||||
|             egg.sendline(NL) | ||||
|             time.sleep(0.1) | ||||
|             egg.expect('login:', timeout=3) | ||||
| @@ -177,7 +178,7 @@ def main(): | ||||
|          egg = pexpect.spawn(cmd) | ||||
|          #egg.logfile_read = sys.stdout.buffer | ||||
|          egg.logfile = FileAdapter(logg) | ||||
|          logg.info("logg {}".format(logg)) | ||||
|          print("logg {}".format(logg)) | ||||
|          time.sleep(0.1) | ||||
|          logged_in_9800 = False | ||||
|          loop_count = 0 | ||||
| @@ -893,7 +894,7 @@ def main(): | ||||
|       egg.expect(">", timeout=3) | ||||
|  | ||||
|    logg.info("Ap[%s] Action[%s] Value[%s] "%(args.ap, args.action, args.value)) | ||||
|    #print("Ap[%s] Action[%s] Value[%s]"%(args.ap, args.action, args.value)) | ||||
|    print("Ap[%s] Action[%s] Value[%s]"%(args.ap, args.action, args.value)) | ||||
|  | ||||
|    if ((args.action == "show") and (args.value is None)): | ||||
|       raise Exception("show requires value, like 'country' or 'ap summary'") | ||||
| @@ -1083,14 +1084,12 @@ def main(): | ||||
|          command = "show ap channel %s"%(args.ap) | ||||
|  | ||||
|    if (args.action == "no_wlan_wireless_tag_policy"): | ||||
|        | ||||
|       logg.info("send wireless tag policy no wlan") | ||||
|       egg.sendline("config t") | ||||
|       sleep(0.1) | ||||
|       i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) | ||||
|       policy = "no wlan {} policy default-policy-profile".format(args.wlan) | ||||
|       if i == 0: | ||||
|          for command in ["wireless tag policy default-policy-tag", policy]: #"no wlan open-wlan policy default-policy-profile" | ||||
|          for command in ["wireless tag policy default-policy-tag","no wlan open-wlan policy default-policy-profile"]: | ||||
|             egg.sendline(command) | ||||
|             sleep(1) | ||||
|             j = egg.expect_exact(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) | ||||
| @@ -1107,9 +1106,9 @@ def main(): | ||||
|       egg.sendline("config t") | ||||
|       sleep(0.1) | ||||
|       i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) | ||||
|       policy = "wlan {} policy default-policy-profile".format(args.wlan) | ||||
|       if i == 0: | ||||
|          for command in ["wireless tag policy default-policy-tag", policy]: #"wlan open-wlan policy default-policy-profile" | ||||
|          for command in ["wireless tag policy default-policy-tag","wlan open-wlan policy default-policy-profile"]: | ||||
|             egg.sendline(command) | ||||
|             sleep(1) | ||||
|             j = egg.expect_exact(["(config-policy-tag)#",pexpect.TIMEOUT],timeout=2) | ||||
|             if j == 0: | ||||
| @@ -1275,7 +1274,7 @@ def main(): | ||||
|       while logged_out_9800 == False and loop_count <= 6: | ||||
|          loop_count += 1 | ||||
|          i = egg.expect_exact(["WLC>","WLC#", "WLC(config)#","(config-wlan)#","(config-policy-tag)#","(config-line)#",pexpect.TIMEOUT],timeout=5) | ||||
|          logg.info(egg.before.decode('utf-8', 'ignore')) | ||||
|          print (egg.before.decode('utf-8', 'ignore')) | ||||
|          if i == 0: | ||||
|             logg.info("WLC> prompt received can send logout") | ||||
|             egg.sendline("logout") | ||||
| @@ -1355,7 +1354,7 @@ def main(): | ||||
|          try: | ||||
|             i = egg.expect_exact([CCPROMPT,LEGACY_PROMPT,AREYOUSURE,'--More-- or','config paging disable',pexpect.TIMEOUT],timeout=2) | ||||
|             logg.info("before {} after {}".format(egg.before.decode('utf-8', 'ignore'),egg.after.decode('utf-8', 'ignore'))) | ||||
|             logg.info(egg.before.decode('utf-8', 'ignore')) | ||||
|             print(egg.before.decode('utf-8', 'ignore')) | ||||
|             if i == 0:  | ||||
|                logg.info("{} prompt received after command sent".format(CCPROMPT)) | ||||
|                # granted the break will exit the loop | ||||
|   | ||||
| @@ -308,10 +308,10 @@ def main(): | ||||
|       if (args.pf_a4_dropoff != None): | ||||
|           pf_a4_dropoff = args.pf_p4_dropoff | ||||
|       if (args.verbose): | ||||
|           cap_ctl_out     = True | ||||
|       else: | ||||
|           # capture the controller output , thus won't got to stdout some output always present | ||||
|           cap_ctl_out = False | ||||
|  | ||||
|       else: | ||||
|           cap_ctl_out = True         | ||||
|       print("cap_ctl_out {}".format(cap_ctl_out))     | ||||
|       # note: there would always be an args.outfile due to the default | ||||
|       current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) | ||||
| @@ -324,10 +324,6 @@ def main(): | ||||
|       if args.log: | ||||
|         outfile_log = "{}_{}_output_log.log".format(args.outfile,current_time) | ||||
|         print("output file log: {}".format(outfile_log)) | ||||
|       else: | ||||
|         outfile_log = "stdout" | ||||
|         print("output file log: {}".format(outfile_log))     | ||||
|  | ||||
|       email_dicts = [] | ||||
|       if args.email: | ||||
|         emails = args.email | ||||
| @@ -360,8 +356,8 @@ def main(): | ||||
|        file_handler.setLevel(logging.DEBUG) | ||||
|        file_handler.setFormatter(formatter) | ||||
|        logg.addHandler(file_handler) | ||||
|        #logg.addHandler(logging.StreamHandler(sys.stdout)) # allows to logging to file and stderr | ||||
|        logging.basicConfig(format=FORMAT, handlers=[console_handler]) | ||||
|        logg.addHandler(logging.StreamHandler(sys.stdout)) # allows to logging to file and stderr | ||||
|        #logging.basicConfig(format=FORMAT, handlers=[console_handler]) | ||||
|  | ||||
|    else: | ||||
|        #pass | ||||
| @@ -850,7 +846,7 @@ def main(): | ||||
|                           try: | ||||
|                               logg.info("9800 cisco_wifi_ctl.py: wireless_tag_policy") | ||||
|                               ctl_output =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", "--wlan", args.wlan, "--series", args.series, "--wlanID", args.wlanID, "--series",args.series,"--port", args.port  ], capture_output=cap_ctl_out, check=True)  | ||||
|                                       "--action", "wireless_tag_policy","--series",args.series,"--port", args.port], capture_output=cap_ctl_out, check=True)  | ||||
|                               if cap_ctl_out:    | ||||
|                                  pss = ctl_output.stdout.decode('utf-8', 'ignore') | ||||
|                                  logg.info(pss)  | ||||
| @@ -861,7 +857,7 @@ def main(): | ||||
|                        try: | ||||
|                           logg.info("9800 cisco_wifi_ctl.py: enable_wlan") | ||||
|                           ctl_output = 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", "--wlan", args.wlan, "--wlanID", args.wlanID, "--series",args.series,"--port", args.port  ], capture_output=cap_ctl_out, check=True)                  | ||||
|                                    "--action", "enable_wlan","--series",args.series,"--port", args.port], capture_output=cap_ctl_out, check=True)                  | ||||
|                           if cap_ctl_out:    | ||||
|                               pss = ctl_output.stdout.decode('utf-8', 'ignore') | ||||
|                               logg.info(pss)  | ||||
| @@ -1590,7 +1586,7 @@ def main(): | ||||
|        try: | ||||
|           logg.info("9800 cisco_wifi_ctl.py: no_wlan_wireless_tag_policy") | ||||
|           ctl_output = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band, | ||||
|                           "--action", "no_wlan_wireless_tag_policy", "--wlan", args.wlan, "--series", "--wlanID", args.wlanID, args.series,"--port", args.port  ], capture_output=cap_ctl_out, check=True)  | ||||
|                           "--action", "no_wlan_wireless_tag_policy","--series",args.series,"--port", args.port], capture_output=cap_ctl_out, check=True)  | ||||
|           if cap_ctl_out: | ||||
|              pss = ctl_output.stdout.decode('utf-8', 'ignore') | ||||
|              logg.info(pss) | ||||
| @@ -1677,7 +1673,7 @@ def main(): | ||||
|    if (ch != "NA"): | ||||
|        try: | ||||
|           logg.info("9800/3504 cisco_wifi_ctl.py: channel 36") | ||||
|           ctl_output = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band, | ||||
|           ctl_out = 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,"--port", args.port],capture_output=cap_ctl_out, check=True) | ||||
|           if cap_ctl_out: | ||||
|              pss = ctl_output.stdout.decode('utf-8', 'ignore') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Chuck SmileyRekiere
					Chuck SmileyRekiere