ap_ctl.py : initial commit for using mux_serial

lf_tx_power.py: TODO for adding the AP module
ct_9136_tx_power_tests.json : using batch mode.

Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
Chuck SmileyRekiere
2022-03-16 08:00:03 -06:00
committed by shivam
parent f41a92978e
commit 79c774ffe3
3 changed files with 28 additions and 9 deletions

View File

@@ -47,6 +47,13 @@ import argparse
import pexpect import pexpect
import serial import serial
from pexpect_serial import SerialSpawn from pexpect_serial import SerialSpawn
import importlib
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../")))
logger = logging.getLogger(__name__)
lf_logger_config = importlib.import_module("py-scripts.lf_logger_config")
mux_client = importlib.import_module("mux_client")
# pip install pexpect-serial (on Ubuntu) # pip install pexpect-serial (on Ubuntu)
# sudo pip install pexpect-serial (on Ubuntu for everyone) # sudo pip install pexpect-serial (on Ubuntu for everyone)
@@ -55,7 +62,8 @@ default_host = "localhost"
default_ports = { default_ports = {
"serial": None, "serial": None,
"ssh": 22, "ssh": 22,
"telnet": 23 "telnet": 23,
"mux_serial": 23200
} }
NL = "\n" NL = "\n"
CR = "\r\n" CR = "\r\n"
@@ -119,11 +127,13 @@ def main():
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"], help="Connect via serial, ssh or telnet") 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, current action is powercfg")
parser.add_argument("-b", "--baud", type=str, help="action, 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")
args = None args = None
try: try:
@@ -168,7 +178,7 @@ def main():
elif (scheme == "ssh"): elif (scheme == "ssh"):
if (port is None): if (port is None):
port = 22 port = default_ports["ssh"]
cmd = "ssh -p%d %s@%s"%(port, user, host) cmd = "ssh -p%d %s@%s"%(port, user, host)
logg.info("Spawn: "+cmd+NL) logg.info("Spawn: "+cmd+NL)
egg = pexpect.spawn(cmd) egg = pexpect.spawn(cmd)
@@ -176,12 +186,18 @@ def main():
egg.logfile = FileAdapter(logg) egg.logfile = FileAdapter(logg)
elif (scheme == "telnet"): elif (scheme == "telnet"):
if (port is None): if (port is None):
port = 23 port = default_ports["telnet"]
cmd = "telnet {} {}".format(host, port) cmd = "telnet {} {}".format(host, port)
logg.info("Spawn: "+cmd+NL) logg.info("Spawn: "+cmd+NL)
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"):
# sudo ./mux_server.py --device /dev/ttyUSB0 --baud 115200 --port 23200
if port is None:
port = default_ports["mux_serial"]
cmd = "./mux_client.py "
else: else:
usage() usage()
exit(1) exit(1)
@@ -251,6 +267,7 @@ def main():
sleep(1) sleep(1)
# show controllers dot11Radio 2 powerreg
if (args.action == "powercfg"): if (args.action == "powercfg"):
logg.info("execute: show controllers dot11Radio 1 powercfg | g T1") logg.info("execute: show controllers dot11Radio 1 powercfg | g T1")
egg.sendline('show controllers dot11Radio 1 powercfg | g T1') egg.sendline('show controllers dot11Radio 1 powercfg | g T1')

View File

@@ -1730,6 +1730,7 @@ def main():
try: try:
logg.info("ap_ctl.py: read AP power information") logg.info("ap_ctl.py: read AP power information")
# TODO use ap module
ap_info = subprocess.run(["./ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'], "--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], ap_info = subprocess.run(["./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'], "--action", "powercfg"], stdout=subprocess.PIPE) "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'], "--action", "powercfg"], stdout=subprocess.PIPE)
try: try:

View File

@@ -138,8 +138,9 @@
"load_db":"skip", "load_db":"skip",
"timeout":"180", "timeout":"180",
"iterations":"1", "iterations":"1",
"batch_channel":"1", "batch_channel":"1 33 65",
"batch_nss":"2", "batch_nss":"1 2",
"batch_bandwidth":"20 40 80 160",
"command":"lf_tx_power.py", "command":"lf_tx_power.py",
"args":"", "args":"",
"args_list":[ "args_list":[
@@ -148,11 +149,11 @@
" --ap USE_DUT_NAME --ap_slot 4 --ap_band_slot_6g 3 ", " --ap USE_DUT_NAME --ap_slot 4 --ap_band_slot_6g 3 ",
" use_ssid_idx=2 --wlan SSID_USED --wlan_id WLAN_ID_USED --wlan_ssid SSID_USED", " use_ssid_idx=2 --wlan SSID_USED --wlan_id WLAN_ID_USED --wlan_ssid SSID_USED",
" --tag_policy RM204-TB1-AP5 --policy_profile default-policy-profile", " --tag_policy RM204-TB1-AP5 --policy_profile default-policy-profile",
" use_ssid_idx=2 --radio wiphy2 --create_station --station sta0000 --ssid SSID_USED --ssidpw SSID_PW_USED --security SECURITY_USED", " use_ssid_idx=2 --radio wiphy2 --station sta0000 --ssid SSID_USED --ssidpw SSID_PW_USED --security SECURITY_USED",
" --pathloss 59 --antenna_gain 6", " --pathloss 59 --antenna_gain 6",
" --lfmgr LF_MGR_IP --upstream_port UPSTREAM_ALIAS --lfresource 1", " --lfmgr LF_MGR_IP --upstream_port UPSTREAM_ALIAS --lfresource 1",
" --vht160 --ieee80211w required --wifi_mode abgnAX", " --vht160 --ieee80211w required --wifi_mode abgnAX",
" --channel USE_BATCH_CHANNEL --nss USE_BATCH_NSS --bandwidth '20' --txpower '2'", " --channel USE_BATCH_CHANNEL --nss USE_BATCH_NSS --bandwidth USE_BATCH_CHANNEL --txpower '1 2 3 4 5 6 7 8'",
" --outfile tx_power_2B24 --no_cleanup --no_cleanup_station --testbed_id Cisco-WLC1-AP5", " --outfile tx_power_2B24 --no_cleanup --no_cleanup_station --testbed_id Cisco-WLC1-AP5",
" --local_lf_report_dir REPORT_PATH", " --local_lf_report_dir REPORT_PATH",
" --test_tag 'tx_power C9136I-B AP687D.B45C.2B24'", " --test_tag 'tx_power C9136I-B AP687D.B45C.2B24'",