mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 04:07:52 +00:00
cisco_wifi_ctl.py : suppress logging flag to reduce logging chatter
lf_cisco_power.py : intial sample of use there will be a subsequent commit
This commit is contained in:
@@ -100,6 +100,7 @@ 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",default="stdout")
|
||||
parser.add_argument("--append", action='store_true', help="--append append to logfile file")
|
||||
parser.add_argument("--suppress", type=str, help="--suppress output when logging to a file",default="False")
|
||||
#parser.add_argument("-r", "--radio", type=str, help="select radio")
|
||||
parser.add_argument("-w", "--wlan", type=str, help="wlan name")
|
||||
parser.add_argument("-i", "--wlanID", type=str, help="wlan ID")
|
||||
@@ -126,6 +127,7 @@ def main():
|
||||
passwd = args.passwd
|
||||
logfile = args.log
|
||||
append = args.append
|
||||
suppress = args.suppress
|
||||
if (args.band != None):
|
||||
band = args.band
|
||||
if (band == "abgn"):
|
||||
@@ -150,13 +152,15 @@ def main():
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(formatter)
|
||||
logg.addHandler(file_handler)
|
||||
if suppress == "False":
|
||||
print("suppress {}".format(suppress))
|
||||
logg.addHandler(logging.StreamHandler(sys.stdout))
|
||||
else:
|
||||
# stdout logging
|
||||
logging.basicConfig(format=FORMAT, handlers=[console_handler])
|
||||
|
||||
print("cisco series {}".format(args.series))
|
||||
print("scheme {}".format(args.scheme))
|
||||
logg.info("cisco series {}".format(args.series))
|
||||
logg.info("scheme {}".format(args.scheme))
|
||||
|
||||
try:
|
||||
if (scheme == "serial"):
|
||||
@@ -166,7 +170,7 @@ def main():
|
||||
with serial.Serial('/dev/ttyUSB0', 115200, timeout=5) as ser:
|
||||
egg = SerialSpawn(ser);
|
||||
egg.logfile = FileAdapter(logg)
|
||||
print("logg {}".format(logg))
|
||||
logg.info("logg {}".format(logg))
|
||||
egg.sendline(NL)
|
||||
time.sleep(0.1)
|
||||
egg.expect('login:', timeout=3)
|
||||
@@ -183,7 +187,7 @@ def main():
|
||||
egg = pexpect.spawn(cmd)
|
||||
#egg.logfile_read = sys.stdout.buffer
|
||||
egg.logfile = FileAdapter(logg)
|
||||
print("logg {}".format(logg))
|
||||
logg.info("logg {}".format(logg))
|
||||
time.sleep(0.1)
|
||||
logged_in_9800 = False
|
||||
loop_count = 0
|
||||
@@ -899,7 +903,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'")
|
||||
@@ -1279,7 +1283,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)
|
||||
print (egg.before.decode('utf-8', 'ignore'))
|
||||
logg.info(egg.before.decode('utf-8', 'ignore'))
|
||||
if i == 0:
|
||||
logg.info("WLC> prompt received can send logout")
|
||||
egg.sendline("logout")
|
||||
@@ -1359,7 +1363,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')))
|
||||
print(egg.before.decode('utf-8', 'ignore'))
|
||||
logg.info(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
|
||||
|
||||
@@ -309,9 +309,12 @@ def main():
|
||||
pf_a4_dropoff = args.pf_p4_dropoff
|
||||
if (args.verbose):
|
||||
# capture the controller output , thus won't got to stdout some output always present
|
||||
cap_ctl_out = False
|
||||
else:
|
||||
cap_ctl_out = True
|
||||
suppress_output = "False"
|
||||
else:
|
||||
cap_ctl_out = False
|
||||
suppress_output = "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())
|
||||
@@ -614,12 +617,13 @@ def main():
|
||||
try:
|
||||
logg.info("9800/3504 cisco_wifi_ctl.py: summary")
|
||||
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,"--log", outfile_log, "--append"], capture_output=True, check=True)
|
||||
"--action", "summary","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=True, check=True)
|
||||
pss = advanced.stdout.decode('utf-8', 'ignore');
|
||||
logg.info(pss)
|
||||
except subprocess.CalledProcessError as process_error:
|
||||
logg.info("Controller unable to commicate to AP or unable to communicate to controller error code {} output {}".format(process_error.returncode, process_error.output))
|
||||
exit_test(workbook)
|
||||
|
||||
# Find our current regulatory domain so we can report it properly
|
||||
searchap = False
|
||||
for line in pss.splitlines():
|
||||
|
||||
Reference in New Issue
Block a user