mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-02 03:37:55 +00:00
ap_ctl.py : updates to use mux_client
lf_report.py : added traceback for exceptions Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
committed by
shivam
parent
1da36b43cf
commit
a9d258d41a
28
ap_ctl.py
28
ap_ctl.py
@@ -48,6 +48,7 @@ import pexpect
|
|||||||
import serial
|
import serial
|
||||||
from pexpect_serial import SerialSpawn
|
from pexpect_serial import SerialSpawn
|
||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../")))
|
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../")))
|
||||||
@@ -63,7 +64,7 @@ default_ports = {
|
|||||||
"serial": None,
|
"serial": None,
|
||||||
"ssh": 22,
|
"ssh": 22,
|
||||||
"telnet": 23,
|
"telnet": 23,
|
||||||
"mux_serial": 23200
|
"mux_client": 23200
|
||||||
}
|
}
|
||||||
NL = "\n"
|
NL = "\n"
|
||||||
CR = "\r\n"
|
CR = "\r\n"
|
||||||
@@ -124,13 +125,15 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(description="Cisco AP Control Script")
|
parser = argparse.ArgumentParser(description="Cisco AP Control Script")
|
||||||
parser.add_argument("-a", "--prompt", type=str, help="ap prompt")
|
parser.add_argument("-a", "--prompt", type=str, help="ap prompt")
|
||||||
parser.add_argument("-d", "--dest", type=str, help="address of the AP 172.19.27.55")
|
parser.add_argument("-d", "--dest", type=str, help="address of the AP 172.19.27.55")
|
||||||
|
parser.add_argument("-m", "--host", type=str, help="address of the mux_serial server 192.168.100.239")
|
||||||
parser.add_argument("-o", "--port", type=int, help="control port on the AP, 2008")
|
parser.add_argument("-o", "--port", type=int, help="control port on the AP, 2008")
|
||||||
parser.add_argument("-u", "--user", type=str, help="credential login/username, admin")
|
parser.add_argument("-u", "--user", type=str, help="credential login/username, admin")
|
||||||
parser.add_argument("-p", "--passwd", type=str, help="credential password Wnbulab@123")
|
parser.add_argument("-p", "--passwd", type=str, help="credential password Wnbulab@123")
|
||||||
parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet", "mux_client"], help="Connect via serial, ssh, telnet, mux_client")
|
parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet", "mux_client"], help="Connect via serial, ssh, telnet, mux_client")
|
||||||
parser.add_argument("-t", "--tty", type=str, help="tty serial device for connecting to AP")
|
parser.add_argument("-t", "--tty", type=str, help="tty serial device for connecting to AP")
|
||||||
parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console",default="stdout")
|
parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console",default="stdout")
|
||||||
parser.add_argument("-z", "--action", type=str, help="action, current action is powercfg")
|
parser.add_argument("-z", "--action", type=str, help="action, cmd, powercfg, clear_log, show_log, cac_expiry_evt, ds_data_5ghz, ds_data_24ghz ")
|
||||||
|
parser.add_argument("-v", "--value", type=str, help="value, cmd value")
|
||||||
parser.add_argument("-b", "--baud", type=str, help="baud, baud rate lanforge: 115200 cisco: 9600")
|
parser.add_argument("-b", "--baud", type=str, help="baud, baud rate lanforge: 115200 cisco: 9600")
|
||||||
parser.add_argument("--mux_client_module", type=str, help="mux client module")
|
parser.add_argument("--mux_client_module", type=str, help="mux client module")
|
||||||
|
|
||||||
@@ -192,20 +195,29 @@ def main():
|
|||||||
egg = pexpect.spawn(cmd)
|
egg = pexpect.spawn(cmd)
|
||||||
egg.logfile = FileAdapter(logg)
|
egg.logfile = FileAdapter(logg)
|
||||||
# Will login below as needed.
|
# Will login below as needed.
|
||||||
elif (scheme == "mux_serial"):
|
elif (scheme == "mux_client"):
|
||||||
# sudo ./mux_server.py --device /dev/ttyUSB0 --baud 115200 --port 23200
|
# sudo ./mux_server.py --device /dev/ttyUSB0 --baud 115200 --port 23200
|
||||||
if port is None:
|
if port is None:
|
||||||
port = default_ports["mux_serial"]
|
port = default_ports["mux_client"]
|
||||||
cmd = "./mux_client.py "
|
# for client
|
||||||
|
cmd = "./mux_client.py --host {host} --port {port}".format(host=args.host,port=args.port)
|
||||||
|
logg.info("Spawn: "+cmd+NL)
|
||||||
|
egg = pexpect.spawn(cmd)
|
||||||
|
egg.logfile = FileAdapter(logg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
usage()
|
usage()
|
||||||
exit(1)
|
exit(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
if args.scheme == 'mux_client' or args.prompt is None:
|
||||||
AP_PROMPT = "{}>".format(args.prompt)
|
AP_PROMPT = ">"
|
||||||
AP_HASH = "{}#".format(args.prompt)
|
AP_HASH = "#"
|
||||||
|
MUX_PROMPT = "MUX>"
|
||||||
|
else:
|
||||||
|
AP_PROMPT = "{}>".format(args.prompt)
|
||||||
|
AP_HASH = "{}#".format(args.prompt)
|
||||||
|
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
logged_in = False
|
logged_in = False
|
||||||
loop_count = 0
|
loop_count = 0
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import datetime
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pdfkit
|
import pdfkit
|
||||||
import argparse
|
import argparse
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
# internal candela references included during intial phases, to be deleted at future date
|
# internal candela references included during intial phases, to be deleted at future date
|
||||||
@@ -185,7 +186,8 @@ class lf_report:
|
|||||||
try:
|
try:
|
||||||
if not os.path.exists(self.path_date_time):
|
if not os.path.exists(self.path_date_time):
|
||||||
os.mkdir(self.path_date_time)
|
os.mkdir(self.path_date_time)
|
||||||
except:
|
except Exception as x:
|
||||||
|
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
|
||||||
self.path_date_time = os.path.join(self.current_path, self.date_time_directory)
|
self.path_date_time = os.path.join(self.current_path, self.date_time_directory)
|
||||||
if not os.path.exists(self.path_date_time):
|
if not os.path.exists(self.path_date_time):
|
||||||
os.mkdir(self.path_date_time)
|
os.mkdir(self.path_date_time)
|
||||||
@@ -197,7 +199,8 @@ class lf_report:
|
|||||||
try:
|
try:
|
||||||
if not os.path.exists(self.log_directory):
|
if not os.path.exists(self.log_directory):
|
||||||
os.mkdir(self.log_directory)
|
os.mkdir(self.log_directory)
|
||||||
except:
|
except Exception as x:
|
||||||
|
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
|
||||||
print("exception making {}".format(self.log_directory))
|
print("exception making {}".format(self.log_directory))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
@@ -277,7 +280,8 @@ class lf_report:
|
|||||||
test_file = open(self.write_output_html, "w")
|
test_file = open(self.write_output_html, "w")
|
||||||
test_file.write(self.html)
|
test_file.write(self.html)
|
||||||
test_file.close()
|
test_file.close()
|
||||||
except:
|
except Exception as x:
|
||||||
|
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
|
||||||
print("write_html failed")
|
print("write_html failed")
|
||||||
return self.write_output_html
|
return self.write_output_html
|
||||||
|
|
||||||
@@ -288,7 +292,8 @@ class lf_report:
|
|||||||
test_file = open(self.write_output_index_html, "w")
|
test_file = open(self.write_output_index_html, "w")
|
||||||
test_file.write(self.html)
|
test_file.write(self.html)
|
||||||
test_file.close()
|
test_file.close()
|
||||||
except:
|
except Exception as x:
|
||||||
|
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
|
||||||
print("write_index_html failed")
|
print("write_index_html failed")
|
||||||
return self.write_output_index_html
|
return self.write_output_index_html
|
||||||
|
|
||||||
@@ -299,7 +304,8 @@ class lf_report:
|
|||||||
test_file = open(self.write_output_html, "w")
|
test_file = open(self.write_output_html, "w")
|
||||||
test_file.write(self.html)
|
test_file.write(self.html)
|
||||||
test_file.close()
|
test_file.close()
|
||||||
except:
|
except Exception as x:
|
||||||
|
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
|
||||||
print("write_html failed")
|
print("write_html failed")
|
||||||
return self.write_output_html
|
return self.write_output_html
|
||||||
|
|
||||||
@@ -456,7 +462,8 @@ class lf_report:
|
|||||||
try:
|
try:
|
||||||
self.path_date_time = os.path.join(self.path, self.date_time)
|
self.path_date_time = os.path.join(self.path, self.date_time)
|
||||||
os.mkdir(self.path_date_time)
|
os.mkdir(self.path_date_time)
|
||||||
except:
|
except Exception as x:
|
||||||
|
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
|
||||||
curr_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
curr_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
self.path_date_time = os.path.join(curr_dir_path, self.date_time)
|
self.path_date_time = os.path.join(curr_dir_path, self.date_time)
|
||||||
os.mkdir(self.path_date_time)
|
os.mkdir(self.path_date_time)
|
||||||
|
|||||||
Reference in New Issue
Block a user