Merge /home/greearb/btbits/x64_btbits/server/lf_scripts

This commit is contained in:
Ben Greear
2020-11-20 08:32:55 -08:00
13 changed files with 352 additions and 131 deletions

View File

@@ -99,8 +99,6 @@ def main():
parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet"], help="Connect via serial, ssh or telnet")
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,8 +124,6 @@ def main():
user = args.user
passwd = args.passwd
logfile = args.log
append = args.append
suppress = args.suppress
if (args.band != None):
band = args.band
if (band == "abgn"):
@@ -145,22 +141,17 @@ def main():
file_handler = None
if (logfile is not None):
if (logfile != "stdout"):
if append:
file_handler = logging.FileHandler(logfile, "a")
else:
file_handler = logging.FileHandler(logfile, "w")
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))
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"):
@@ -170,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)
@@ -187,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
@@ -903,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'")
@@ -1093,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)
@@ -1117,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:
@@ -1285,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")
@@ -1365,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

View File

@@ -309,12 +309,9 @@ 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 = True
suppress_output = "False"
else:
cap_ctl_out = False
suppress_output = "True"
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())
@@ -327,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
@@ -617,7 +610,7 @@ 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], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore');
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -702,7 +695,7 @@ def main():
try:
logg.info("3504/9800 cisco_wifi_ctl.py: disable AP {}".format(args.ap))
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", "disable","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "disable","--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)
@@ -717,7 +710,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: disable_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", "disable_wlan","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "disable_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)
@@ -728,7 +721,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: disable_network_5ghz")
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", "disable_network_5ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "disable_network_5ghz","--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)
@@ -740,7 +733,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: disable_network_24ghz")
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", "disable_network_24ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "disable_network_24ghz","--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)
@@ -752,7 +745,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: manual")
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", "manual","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "manual","--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)
@@ -764,7 +757,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11a disable network")
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", "cmd", "--value", "config 802.11a disable network","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11a disable network","--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)
@@ -776,7 +769,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11b disable network")
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", "cmd", "--value", "config 802.11b disable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11b disable network","--port", args.port], capture_output=cap_ctl_out, check=True)
if cap_ctl_out:
pss = ctl_output.stdout.decode('utf-8', 'ignore')
@@ -792,7 +785,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: txPower {}".format(tx))
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", "txPower", "--value", tx, "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "txPower", "--value", tx, "--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)
@@ -808,7 +801,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: channel {}".format(ch))
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", "channel", "--value", ch, "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "channel", "--value", ch, "--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)
@@ -822,7 +815,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: bandwidth {}".format(bw))
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", "bandwidth", "--value", bw, "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "bandwidth", "--value", bw, "--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)
@@ -841,7 +834,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: create_wlan wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port))
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", "create_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "create_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID,"--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)
@@ -853,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", "--wlanID", args.wlanID, "--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], 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)
@@ -864,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,"--log", outfile_log, "--append", "--suppress", suppress_output], 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)
@@ -878,7 +871,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: enable_network_5ghz")
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_network_5ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "enable_network_5ghz","--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)
@@ -890,7 +883,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: enable_network_24ghz")
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_network_24ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "enable_network_24ghz","--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)
@@ -902,7 +895,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11a enable network")
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", "cmd", "--value", "config 802.11a enable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11a enable network","--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)
@@ -914,7 +907,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11a enable network")
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", "cmd", "--value", "config 802.11b enable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11b enable network","--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)
@@ -926,7 +919,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: enable")
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", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "enable", "--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)
@@ -947,7 +940,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: advanced")
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
"--action", "advanced","--series" , args.series,"--port", args.port,"--log", outfile_log, "--append"], capture_output=True, check=True)
"--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -1007,7 +1000,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: show_wlan_summary")
wlan_summary = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
"--action", "show_wlan_summary","--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=True, check=True)
"--action", "show_wlan_summary","--series" , args.series,"--port", args.port], capture_output=True, check=True)
pss = wlan_summary.stdout.decode('utf-8', 'ignore')
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -1016,7 +1009,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: advanced")
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
"--action", "advanced","--port", args.port,"--log", outfile_log, "--append"], capture_output=True, check=True)
"--action", "advanced","--port", args.port], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -1115,7 +1108,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: advanced")
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
"--action", "advanced","--series" , args.series,"--port", args.port,"--log", outfile_log, "--append"], capture_output=True, check=True)
"--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -1551,7 +1544,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: advanced")
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
"--action", "advanced","--series" , args.series,"--port", args.port,"--log", outfile_log, "--append"], capture_output=True, check=True)
"--action", "advanced","--series" , args.series,"--port", args.port], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -1560,7 +1553,7 @@ 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], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore')
logg.info(pss)
except subprocess.CalledProcessError as process_error:
@@ -1579,7 +1572,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: disable AP {}".format(args.ap))
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", "disable", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "disable", "--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)
@@ -1593,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,"--log", outfile_log, "--append", "--suppress", suppress_output], 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)
@@ -1605,7 +1598,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: delete_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", "delete_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output], capture_output=cap_ctl_out, check=True)
"--action", "delete_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID,"--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)
@@ -1617,7 +1610,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: disable_network_5ghz")
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", "disable_network_5ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "disable_network_5ghz","--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)
@@ -1629,7 +1622,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: disable_network_24ghz")
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", "disable_network_24ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "disable_network_24ghz","--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)
@@ -1642,7 +1635,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11a disable network")
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", "cmd", "--value", "config 802.11a disable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11a disable network","--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)
@@ -1654,7 +1647,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11b disable network")
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", "cmd", "--value", "config 802.11b disable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11b disable network","--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)
@@ -1667,7 +1660,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: txPower tx 1")
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", "txPower", "--value", "1", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "txPower", "--value", "1", "--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)
@@ -1680,8 +1673,8 @@ 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,
"--action", "channel", "--value", "36", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
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')
logg.info(pss)
@@ -1694,7 +1687,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: bandwidth 20")
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", "bandwidth", "--value", "20", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "bandwidth", "--value", "20", "--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)
@@ -1707,7 +1700,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: enable_network_5ghz")
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_network_5ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "enable_network_5ghz","--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)
@@ -1719,7 +1712,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: enable_network_24ghz")
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_network_24ghz","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "enable_network_24ghz","--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)
@@ -1731,7 +1724,7 @@ def main():
try:
logg.info("9800 cisco_wifi_ctl.py: auto")
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", "auto","--series",args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "auto","--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)
@@ -1744,7 +1737,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11a enable network")
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", "cmd", "--value", "config 802.11a enable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11a enable network","--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)
@@ -1756,7 +1749,7 @@ def main():
try:
logg.info("3504 cisco_wifi_ctl.py: config 802.11b enable network")
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", "cmd", "--value", "config 802.11b enable network","--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "cmd", "--value", "config 802.11b enable network","--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)
@@ -1768,7 +1761,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: enable")
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", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append", "--suppress", suppress_output],capture_output=cap_ctl_out, check=True)
"--action", "enable", "--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)
@@ -1789,7 +1782,7 @@ def main():
try:
logg.info("9800/3504 cisco_wifi_ctl.py: advanced")
advanced = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band,
"--action", "advanced", "--series" , args.series,"--port", args.port,"--log", outfile_log, "--append"], capture_output=True, check=True)
"--action", "advanced", "--series" , args.series,"--port", args.port], capture_output=True, check=True)
pss = advanced.stdout.decode('utf-8', 'ignore');
logg.info(pss)
except subprocess.CalledProcessError as process_error:

View File

@@ -251,6 +251,7 @@ class LFCliBase:
parser.add_argument('--ssid', help='SSID for stations to associate to', default=None)
parser.add_argument('--passwd', '--passphrase', '--password', '--pwd', help='WiFi passphrase', default=None)
parser.add_argument('--num_stations', help='Number of stations to create', default=0)
parser.add_argument('--test_id', help='Test ID (intended to use for ws events)', default="webconsole")
parser.add_argument('--debug', help='Enable debugging', default=False, action="store_true")

View File

@@ -0,0 +1,25 @@
"""
pip install websocket_client
https://pypi.org/project/websocket_client/
WS_Listener has three arguments in general : lfclient_host, _scriptname, _callback
1. Enter the LF Client Host address on which you want to monitor events (by Default is localhost)
2. Enter the _scriptname that should be present in the event triggered by your script,
refer add_event() in lfcli_base.add_event()
_scriptname can be any string that you want to monitor in your websocket message
3. Enter the Callback function that you wanna see your messages in everytime your event will trigger up.
refer py-scripts/ws_generic_monitor_test.py to see an example
"""
class WS_Listener():
def __init__(self, lfclient_host="localhost", _scriptname=None, _callback=None):
import websocket
self.scriptname = _scriptname
websocket.enableTrace(True)
self.ws = websocket.WebSocketApp("ws://"+lfclient_host+":8081", on_message=_callback)
self.ws.run_forever()

View File

@@ -18,12 +18,13 @@ import pprint
class IPv4Test(LFCliBase):
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False,
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", radio = "wiphy0",_debug_on=False,
_exit_on_error=False,
_exit_on_fail=False):
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
self.host = host
self.port = port
self.radio = radio
self.ssid = ssid
self.security = security
self.password = password
@@ -49,7 +50,7 @@ class IPv4Test(LFCliBase):
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
self.station_profile.set_command_param("set_port", "report_timer", 1500)
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
self._pass("PASS: Station build finished")
def cleanup(self, sta_list):
@@ -70,17 +71,17 @@ def main():
''',
description='''\
example_wpa_connection.py
example_wep_connection.py
--------------------
Generic command example:
python3 ./example_wpa_connection.py \\
python3 ./example_wep_connection.py \\
--host localhost (optional) \\
--port 8080 (optional) \\
--num_stations 3 \\
--security {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear-wep \\
--passwd admin123-wep \\
--ssid jedway-wep-48 \\
--passwd jedway-wep-48 \\
--debug
Note: multiple --radio switches may be entered up to the number of radios available:
@@ -99,7 +100,7 @@ def main():
end_id_=num_sta-1,
padding_number_=10000)
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd,
security=args.security, sta_list=station_list)
security=args.security, radio=args.radio, sta_list=station_list)
ip_test.cleanup(station_list)
ip_test.timeout = 60
ip_test.build()

View File

@@ -75,7 +75,7 @@ def main():
--------------------
Generic command example:
python3 ./example_wpa_connection.py \\
python3 ./example_wpa2_connection.py \\
--host localhost (optional) \\
--port 8080 (optional) \\
--num_stations 3 \\

View File

@@ -619,12 +619,15 @@ class cisco_():
class L3VariableTime(LFCliBase):
def __init__(self, host, port, endp_types, args, tos, side_b, radio_name_list, number_of_stations_per_radio_list,
ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile,test_keys,test_config,
ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile,
test_keys,test_config,
reset_port_enable_list,
reset_port_time_min_list,
reset_port_time_max_list,
side_a_min_rate=560000, side_a_max_rate=0,
side_a_min_pdu=1518,side_a_max_pdu=0,
side_b_min_rate=560000, side_b_max_rate=0,
side_b_min_pdu=1518,side_b_max_pdu=0,
number_template="00", test_duration="256s",
polling_interval="60s",
_exit_on_error=False,
@@ -652,7 +655,7 @@ class L3VariableTime(LFCliBase):
self.polling_interval_seconds = self.local_realm.duration_time_to_seconds(polling_interval)
self.cx_profile = self.local_realm.new_l3_cx_profile()
self.multicast_profile = self.local_realm.new_multicast_profile()
self.multicast_profile.name_prefix = "MLT-";
self.multicast_profile.name_prefix = "MLT-"
self.station_profiles = []
self.args = args
self.outfile = outfile
@@ -702,8 +705,12 @@ class L3VariableTime(LFCliBase):
self.cx_profile.name_prefix = self.name_prefix
self.cx_profile.side_a_min_bps = side_a_min_rate
self.cx_profile.side_a_max_bps = side_a_max_rate
self.cx_profile.side_a_min_pdu = side_a_min_pdu
self.cx_profile.side_a_max_pdu = side_a_max_pdu
self.cx_profile.side_b_min_bps = side_b_min_rate
self.cx_profile.side_b_max_bps = side_b_max_rate
self.cx_profile.side_b_min_pdu = side_b_min_pdu
self.cx_profile.side_b_max_pdu = side_b_max_pdu
def __get_rx_values(self):
endp_list = self.json_get("endp?fields=name,rx+bytes,rx+drop+%25", debug_=False)
@@ -711,9 +718,9 @@ class L3VariableTime(LFCliBase):
endp_rx_map = {}
our_endps = {}
for e in self.multicast_profile.get_mc_names():
our_endps[e] = e;
our_endps[e] = e
for e in self.cx_profile.created_endp.keys():
our_endps[e] = e;
our_endps[e] = e
for endp_name in endp_list['endpoint']:
if endp_name != 'uri' and endp_name != 'handler':
for item, value in endp_name.items():
@@ -1056,7 +1063,7 @@ class L3VariableTime(LFCliBase):
for station_profile in self.station_profiles:
temp_stations_list.extend(station_profile.station_names.copy())
# need algorithm for setting time default
if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=600, debug=self.debug):
if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120, debug=self.debug):
logg.info("ip's acquired")
else:
logg.info("print failed to get IP's")
@@ -1451,8 +1458,10 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
parser.add_argument('-r','--radio', action='append', nargs=1, help='--radio \
\"radio==<number_of_wiphy stations=<=number of stations> ssid==<ssid> ssid_pw==<ssid password> security==<security> wifimode==<wifimode>\" '\
, required=False)
parser.add_argument('-amr','--side_a_min_rate', help='--side_a_min_rate, station transfer rate default 256000', default=256000)
parser.add_argument('-amr','--side_a_min_rate', help='--side_a_min_rate, station min tx rate default 256000', default=256000)
#parser.add_argument('-bmr','--side_a_min_pdu', help='--side_a_min_pdu , station ipdu size default 1518', default=1518)
parser.add_argument('-bmr','--side_b_min_rate', help='--side_b_min_rate , upstream min tx rate default 256000', default=256000)
#parser.add_argument('-bmr','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default=1518)
# Parameters that allow for testing
parser.add_argument('-noc','--no_controller', help='--no_controller no configuration of the controller', action='store_true')
@@ -1518,6 +1527,36 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
logging.basicConfig(format=FORMAT, handlers=[console_handler])
####################################################
#
# Static Configuration Cisco Realm one lanforge
#
####################################################
radio_AX200_abgn_ax_list_001_one = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radio_AX200_abgn_ax_list_010_one = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'],
['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radio_AX200_abgn_ax_dict_one = {'1' : radio_AX200_abgn_ax_list_001_one,
'8' : radio_AX200_abgn_ax_list_010_one}
radio_ath10K_9984_an_AC_list_001_one = [['radio==1.wiphy8 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radio_ath10K_9984_an_AC_list_010_one = [['radio==1.wiphy8 stations==10 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radio_ath10K_9984_an_AC_list_020_one = [['radio==1.wiphy8 stations==20 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radio_ath10K_9984_an_AC_dict_one = {'1' : radio_ath10K_9984_an_AC_list_001_one,
'10' : radio_ath10K_9984_an_AC_list_010_one,
'20' : radio_ath10K_9984_an_AC_list_020_one}
####################################################
#
@@ -1676,18 +1715,25 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
if args.cisco_all:
cisco_aps = "APA453.0E7B.CF9C".split()
cisco_bands = "a b".split()
cisco_wifimodes = "an anAX anAC abgn bg".split()
# cisco_bands = "a b".split()
cisco_bands = "a ".split()
# cisco_wifimodes = "an anAX anAC abgn bg".split()
cisco_wifimodes = "an".split()
cisco_tx_power = "3"
cisco_chan_5ghz = "36".split()
cisco_chan_24ghz = "1".split()
cisco_chan_widths = "20".split()
cisco_ap_modes = "local flex".split()
# cisco_ap_modes = "local flex".split()
cisco_ap_modes = "local".split()
cisco_data_encryptions = "disable".split()
endp_types = "lf_udp lf_tcp"
cisco_packet_sizes = "1518".split()
cisco_client_densities = "1".split()
cisco_data_encryptions = "disable".split()
radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_one
radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_one
elif args.cisco_test:
cisco_aps = "APA453.0E7B.CF9C".split()
cisco_bands = "a".split()
@@ -1700,8 +1746,8 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
cisco_ap_modes = "local".split()
cisco_data_encryptions = "disable".split()
endp_types = "lf_udp lf_tcp"
cisco_packet_sizes = "1518".split()
cisco_client_densities = "1 10 50".split()
cisco_packet_sizes = "88 512 1370 1518".split()
cisco_client_densities = "1".split()
cisco_data_encryptions = "disable".split()
radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_test
@@ -1892,7 +1938,9 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
reset_port_time_min_list=reset_port_time_min_list,
reset_port_time_max_list=reset_port_time_max_list,
side_a_min_rate=args.side_a_min_rate,
side_a_min_pdu =args.cisco_packet_size,
side_b_min_rate=args.side_b_min_rate,
side_b_min_pdu =args.cisco_packet_size,
debug_on=debug_on,
outfile=csv_outfile,
test_keys=test_keys,

View File

@@ -22,13 +22,13 @@ parser = LFCliBase.create_bare_argparse(
description='''scenario.py
--------------------
Generic command example:
python3 scenario.py --load db1 --action overwrite --clean_dut --clean_chambers
scenario.py --load db1 --action overwrite --clean_dut --clean_chambers
python3 scenario.py --start test_group1
scenario.py --start test_group1
python3 scenario.py --quiesce test_group1
scenario.py --quiesce test_group1
python3 scenario.py --stop test_group1
scenario.py --stop test_group1
''')
group = parser.add_mutually_exclusive_group()

79
py-scripts/test_all_scripts.sh Executable file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
#Security connection examples#########################################
echo "Beginning example_wpa_connection.py test..."
chmod +x example_wpa2_connection.py
./example_wpa2_connection.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0
chmod +x scenario.py
./scenario.py --load BLANK
chmod +x example_wep_connection.py
./example_wep_connection.py --ssid jedway-wep-48 --passwd jedway-wep-48 --radio wiphy1
./scenario.py --load BLANK
chmod +x example_wpa3_connection.py
./example_wpa3_connection.py
./scenario.py --load BLANK
chmod +x example_wpa_connection.py
./example_wpa_connection.py --radio wiphy1
./scenario.py --load BLANK
#test generic and test fileio######################################################
#chmod +x test_fileio.py
#./test_fileio.py
chmod +x test_generic.py
#lfping
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0
#lfcurl
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0
#generic
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0
#speedtest
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0
#iperf3
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0
#Ipv4 connection tests##########################################
chmod +x test_ipv4_connection.py
./test_ipv4_connection.py
chmod +x test_ipv4_l4_ftp_upload.py
./test_ipv4_l4_ftp_upload.py
chmod +x test_ipv4_l4_ftp_urls_per_ten.py
./test_ipv4_l4_ftp_urls_per_ten.py
chmod +x test_ipv4_l4_ftp_wifi.py
./test_ipv4_l4_ftp_wifi.py
chmod +x test_ipv4_l4_urls_per_ten.py
./test_ipv4_l4_urls_per_ten.py
chmod +x test_ipv4_l4_wifi.py
./test_ipv4_l4_wifi.py
chmod +x test_ipv4_l4
./test_ipv4_l4.py
chmod +x test_ipv4_ps.py
./test_ipv4_l4_ps.py
chmod +x test_ipv4_ttls.py
./test_ipv4_l4_ttls.py
chmod +x test_ipv4_variable_time.py
./test_ipv4_variable_time.py
#Layer 3 tests################################################
chmod +x test_l3_longevity.py
./test_l3_longevity.py
chmod +x test_l3_powersave_traffic
./test_l3_powersave_traffic.py
chmod +x test_l3_scenario_traffic.py
./test_l3_scenario_traffic.py
chmod +x test_l3_unicast_traffic_gen.py
./test_l3_unicast_traffic_gen.py
chmod +x test_l3_WAN_LAN.py
./test_l3_WAN_LAN.py
#WANlink######################################################
chmod +x test_wanlink.py
./test_wanlink.py
#IPv6 connection tests########################################
chmod +x test_ipv6_connection.py
./test_ipv6_variable_connection.py
chmod +x test_ipv6_variable_time.py
./test_ipv6_variable_time.py
#STA Connect examples#########################################
chmod +x sta_connect_example.py
./sta_connect_example.py
chmod +x sta_connect_multi_example.py
./sta_connect_multi_example.py
chmod +x sta_connect.py
./sta_connect.py
chmod +x sta_connect2.py
./sta_connect2.py

View File

@@ -1,7 +1,6 @@
#!/usr/bin/env python3
import sys
# import re
if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)

View File

@@ -123,7 +123,7 @@ def main():
test_ipv4_connection.py
--------------------
Generic command example:
python3 ./test_ipv4_connection.py --upstream_port eth1 \\
./test_ipv4_connection.py --upstream_port eth1 \\
--radio wiphy0 \\
--num_stations 3 \\
--security {open|wep|wpa|wpa2|wpa3} \\
@@ -142,6 +142,8 @@ python3 ./test_ipv4_connection.py --upstream_port eth1 \\
num_stations_converted = int(args.num_stations)
num_sta = num_stations_converted
ws_event = LFCliBase("192.168.200.15", 8080)
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000)
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd,
security=args.security, sta_list=station_list, radio=args.radio)
@@ -150,17 +152,19 @@ python3 ./test_ipv4_connection.py --upstream_port eth1 \\
ip_test.build()
if not ip_test.passes():
print(ip_test.get_fail_message())
ws_event.add_event(name="test_ipv4_connection.py", message=ip_test.get_fail_message())
exit(1)
ip_test.start(station_list, False, False)
ip_test.stop()
if not ip_test.passes():
print(ip_test.get_fail_message())
ws_event.add_event(name="test_ipv4_connection.py", message=ip_test.get_fail_message())
exit(1)
time.sleep(30)
ip_test.cleanup(station_list)
if ip_test.passes():
print("Full test passed, all stations associated and got IP")
ws_event.add_event(name="test_ipv4_connection.py", message="Full test passed, all stations associated and got IP")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,28 @@
"""
This example is to demonstrate ws_generic_monitor to monitor events triggered by scripts,
This script when running, will monitor the events triggered by test_ipv4_connection.py
"""
import sys
import json
if 'py-json' not in sys.path:
sys.path.append('../py-json')
from ws_generic_monitor import WS_Listener
reference = "test_ipv4_connection.py"
def main():
WS_Listener(lfclient_host="localhost", _scriptname=reference, _callback=TestRun)
def TestRun(ws, message):
if (str(message).__contains__(reference)):
#print(message)
temp = json.loads(message)
event_message = str(temp['name']) + "/" + str(temp['details']) + "/" + str(temp['timestamp'])
print(event_message)
if __name__ == "__main__":
main()

View File

@@ -1,5 +1,9 @@
#!/bin/bash
export DISPLAY=:1
# check for log file
LOCKFILE="/tmp/update-test.lock"
[ -f $LOCKFILE ] && echo "lockfile $LOCKFILE found, bye" && exit 0
export DISPLAY=":1"
[ ! -z "$DEBUG" ] && set -x
IP="192.168.95.239"
HL="/home/lanforge"
@@ -14,43 +18,86 @@ GUIDIR="${HL}/LANforgeGUI_${verNum}"
ST="/tmp/summary.txt"
DM_FLAG="${HL}/LANforgeGUI_${verNum}/DAEMON_MODE"
output=/tmp/gui_update_test
NO_AUTO="${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART"
D_MODE="${HL}/LANforgeGUI_${verNum}/DAEMON_MODE"
trap do_sigint HUP
trap do_sigint ABRT
trap do_sigint INT
trap do_sigint KILL
trap do_sigint PIPE
trap do_sigint QUIT
trap do_sigint SEGV
trap do_sigint TERM
function do_sigint() {
[ -f $LOCKFILE ] && echo "removing lockfile" && rm -f $LOCKFILE
for f in $GUILog $GUIUpdate $CTLGUI $CTLH $LOCKFILE $NO_AUTO /tmp/\+.*; do
rm -f "$f"
done
}
function start_gui() {
daemon_mode=""
[ -f $GUIDIR/DAEMON_MODE ] && daemon_mode="-daemon"
[ -f "$D_MODE" ] && daemon_mode="-daemon"
( cd $GUIDIR; nohup env RESTARTS=999999 ./lfclient.bash $daemon_mode -s localhost &> $GUILog & )
connect_fail=0
wait_8080 || connect_fail=1
if [[ $connect_fail = 1 ]]; then
if (( $connect_fail == 1 )); then
set -x
echo "" > $output
[ -s $GUIUpdate ] && cat $GUIUpdate >> $output
cat $GUILog >> $output
mail -s 'GUI connect failure' "test.notice@candelatech.com" < $output
# cat $GUILog >> $output
echo "------------------------------------------" >> $output
mail -q $output -s 'GUI connect failure' "test.notice@candelatech.com" < $GUILog
[ ! -z "$DEBUG" ] && cat $GUILog
do_sigint
exit 1
else
echo "start_gui: connection found"
fi
return 0
}
function wait_8080() {
set +x
local connected=0
local limit_sec=30
local limit_sec=90
echo "Testing for 8080 connection "
lastpid=''
zpid=''
while (( connected == 0 )); do
(( limit_sec <= 0)) && break
curl -so /dev/null http://localhost:8080/ && connected=1
(( connected >= 1 )) && break;
limit_sec=$(( limit_sec - 1 ))
echo -n "."
lastpid=$zpid
zpid=`pgrep java`
if [ -z "$zpid" ]; then
if [[ x"$zpid" = x ]] && [[ "$lastpid" != "" ]]; then
echo "GUI crashed while starting, bye."
return 1
fi
[ ! -z "$DEBUG" ] && echo -n "-$zpid/$lastpid "
else
[ ! -z "$DEBUG" ] && echo -n "+$zpid/$lastpid "
fi
sleep 1
done
if [[ $connected = 0 ]]; then
echo "Unable to connect, bye"
return 1
else
echo "Connection established"
fi
[ ! -z "$DEBUG" ] && set -x
return 0
}
touch $LOCKFILE
if [ -f ${GUIDIR}/down-check ]; then
numFound=`find ${GUIDIR} -name down-check -mmin +59 | grep -c down-check`
@@ -61,6 +108,7 @@ if [ -f ${GUIDIR}/down-check ]; then
else
touch "${GUIDIR}/down-check"
echo "Could not connect to ${IP}"
do_sigint
exit 1
fi
else
@@ -68,6 +116,7 @@ if [ -f ${GUIDIR}/down-check ]; then
if (( 0 != $? )); then
touch "${GUIDIR}/down-check"
echo "Could not connect to ${IP}"
do_sigint
exit 1
fi
fi
@@ -76,52 +125,56 @@ fi
sudo rm -f /tmp/*.txt
sudo rm -f $GUILog $GUIUpdate $CTLGUI $CTLH $ST
touch "${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART"
touch "$NO_AUTO"
pgrep java &>/dev/null && killall -9 java
touch $GUIUpdate
touch $ST
if [ ! -z "SKIP_INSTALL" ] && [ x$SKIP_INSTALL = x1 ]; then
echo "skipping installation"
sleep 4
echo "skipping installation" | tee -a $GUIUpdate
else
echo "doing installation"
sleep 4
set -x
python3 ${scripts}/auto-install-gui.py --versionNumber $verNum &> $GUIUpdate
[ -s $GUIUpdate ] && grep -q "Current GUI version up to date" $GUIUpdate && exit
echo "===============================================" > $ST
head $GUILog >> $ST
echo "===============================================" >> $ST
if [ -s $GUIUpdate ]; then
grep -q "Current GUI version up to date, not testing" $GUIUpdate
do_sigint
exit 0
fi
[ -s $GUIUpdate ] && head $GUIUpdate >> $ST
if grep -q -i "fail" $GUIUpdate; then
cat $ST | mail -s 'GUI Update Test Failure' -a $GUILog -a $GUIUpdate "test.notice@candelatech.com"
mail -s 'GUI Update Test Failure' -q $GUILog -a $GUIUpdate "test.notice@candelatech.com" < $ST
do_sigint
exit 1
fi
set +x
fi
sleep 1
rm -f "${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART"
rm -f "$NO_AUTO"
start_gui
echo "Doing connectTest.py > $CTLGUI"
python3 ${scripts}/connectTest.py &> $CTLGUI
echo "== GUI =============================================" >> $ST
head $CTLGUI >> $ST
echo "===============================================" >> $ST
pgrep java &>/dev/null && killall -9 java
sleep 1
#-daemon
touch "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE"
touch "$D_MODE"
start_gui
python3 ${scripts}/connectTest.py &> $CTLH
echo "===============================================" >> $ST
head $CTLGUI >> $ST
echo "===============================================" >> $ST
echo "== HEADLESS =============================================" >> $ST
head $CTLH >> $ST
echo "===============================================" >> $ST
rm -f "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE"
rm -f "$D_MODE"
pgrep java &>/dev/null && killall -9 java
start_gui
connect_fail=0
wait_8080 || connect_fail=1
cat $ST > $output
echo "===============================================" >> $output
echo "=== FULL LOGS ============================================" >> $output
[ -s $GUILog ] && cat $GUILog >> $output
echo "===============================================" >> $output
[ -s $GUIUpdate ] && cat $GUIUpdate >> $output
@@ -133,6 +186,7 @@ echo "===============================================" >> $output
echo -e "--\n.\n" >> $output
mail -s 'GUI Update Test' "test.notice@candelatech.com" < $output
#cat $ST | mail -s 'GUI Update Test' -a $GUILog -a $GUIUpdate -a $CTLGUI -a $CTLH "test.notice@candelatech.com"
do_sigint
#eof