From f12992ef9ea691a72d42f8bd613a0ff7e9124d9c Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 13 Jan 2021 12:51:08 -0700 Subject: [PATCH 001/848] cisco_wifi_ctl.py : controller has delay in enabling the 5ghz network --- cisco_wifi_ctl.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 9666aaa3..f206c138 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1301,13 +1301,13 @@ def main(): i = egg.expect_exact([CCP,CCP_EN, CCP_CONFIG,CCP_CONFIG_WLAN,CCP_POLICY_TAG,CCP_CONFIG_LINE,pexpect.TIMEOUT],timeout=5) print (egg.before.decode('utf-8', 'ignore')) if i == 0: - logg.info("{} prompt received can send logout".format(CCP)) + logg.info("{} prompt received can send logout, loop_count: {}".format(CCP,loop_count)) egg.sendline("logout") sleep(0.1) logged_out_9800 = True break if i == 1: - logg.info("{} prompt received will send logout".format(CCP_EN)) + logg.info("{} prompt received will send logout, loop_count: {}".format(CCP_EN,loop_count)) try: egg.sendline("logout") sleep(0.1) @@ -1317,7 +1317,7 @@ def main(): sleep(0.1) break if i == 2: - logg.info("{} prompt received will send exit".format(CCP_CONFIG)) + logg.info("{} prompt received will send exit, loop_count: {}".format(CCP_CONFIG, loop_count)) try: egg.sendline("exit") sleep(0.2) @@ -1326,7 +1326,7 @@ def main(): logg.info("9800 exception on end") sleep(0.1) if i == 3: - logg.info("{} prompt received will send end".format(CCP_CONFIG_WLAN)) + logg.info("{} prompt received will send end, loop_count: {}".format(CCP_CONFIG_WLAN, loop_count)) try: egg.sendline("end") sleep(0.2) @@ -1334,7 +1334,7 @@ def main(): logg.info("9800 exception on end") sleep(0.1) if i == 4: - logg.info("(config-policy-tag)# prompt received will send end") + logg.info("(config-policy-tag)# prompt received will send end, loop_count: {}".format(loop_count)) try: egg.sendline("end") sleep(0.2) @@ -1342,7 +1342,7 @@ def main(): logg.info("9800 exception on end") sleep(0.1) if i == 5: - logg.info("{} prompt received will send end".format(CCP_CONFIG_LINE)) + logg.info("{} prompt received will send end, loop_count: {}".format(CCP_CONFIG_LINE,loop_count)) try: egg.sendline("end") sleep(0.2) @@ -1350,11 +1350,14 @@ def main(): logg.info("9800 exception on end") sleep(0.1) if i == 6: - logg.info("9800 expect timeout send end") + logg.info("9800 expect timeout loop_count: {}".format(loop_count)) egg.sendline("end") - break + if( logged_out_9800 == False): + logg.info("######################################################################################") logg.info("9800 did not send logout at end of command processing this could tie up the connection") + logg.info("######################################################################################") + if( scheme == "telnet"): egg.sendline("\x1b\r") logg.info("send escape to exit connection") From 58100047009125dace58df063de4ef36ec339690 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 13 Jan 2021 13:16:19 -0700 Subject: [PATCH 002/848] cisco_wifi_ctl.py : debug for enable_wlan --- cisco_wifi_ctl.py | 60 ++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index f206c138..1794ebd4 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -222,29 +222,29 @@ def main(): exit(1) if i == 0: - logg.info("9800 found Escape character is '^] i:{} before: {} after: {}".format(i,egg.before,egg.after)) + logg.info("9800 SSH found Escape character is '^] i:{} before: {} after: {}".format(i,egg.before,egg.after)) #egg.sendline(CR) found_escape = True sleep(0.1) j = egg.expect_exact([CCP,CCP_EN,"User:","Password:",CCP_CONFIG,pexpect.TIMEOUT],timeout=3) sleep(0.1) if j == 0: - logg.info("9800 found {} will elevate loging i:{} j:{} before {} after {}".format(CCP,i,j,egg.before,egg.after)) + logg.info("9800 SSH found {} will elevate loging i:{} j:{} before {} after {}".format(CCP,i,j,egg.before,egg.after)) egg.sendline("en") sleep(0.1) k = egg.expect_exact(["Password:",pexpect.TIMEOUT], timeout=2) if k == 0: - logg.info("9800 received password prompt will send password: {} i:{} j:{} k:{} before {} after {}".format(args.passwd,i,j,k,egg.before,egg.after)) + logg.info("9800 SSH received password prompt will send password: {} i:{} j:{} k:{} before {} after {}".format(args.passwd,i,j,k,egg.before,egg.after)) egg.sendline(args.passwd) sleep(0.1) l = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) if k == 1: - logg.info("8900 received timeout after looking for password: prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) + logg.info("9800 SSH received timeout after looking for password: prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) if j == 1: logg.info("9800 found # so logged in can start sending commands i:{} j:{}".format(i,j)) logged_in_9800 = True @@ -259,7 +259,7 @@ def main(): sleep(0.1) l = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("8900 SSH Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -272,7 +272,7 @@ def main(): sleep(0.1) k = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) + logg.info("8900 SSH Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -293,7 +293,7 @@ def main(): sleep(0.1) m = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if m == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) logged_in_9800 = True if m == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} m:{} before {} after {}".format(i,j,k,l,m,egg.before,egg.after)) @@ -313,7 +313,7 @@ def main(): sleep(0.1) m = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if m == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) logged_in_9800 = True if m == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} m:{} before {} after {}".format(i,j,k,l,m,egg.before,egg.after)) @@ -326,7 +326,7 @@ def main(): sleep(0.1) l = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) + logg.info("8900 SSH Successfully received # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -376,7 +376,7 @@ def main(): sleep(0.1) k = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k, egg.before,egg.after)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k, egg.before,egg.after)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -398,7 +398,7 @@ def main(): sleep(0.1) l = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{}".format(i,j,k)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{}".format(i,j,k)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -411,7 +411,7 @@ def main(): sleep(0.1) j = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if j == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after)) logged_in_9800 = True if j == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after)) @@ -433,7 +433,7 @@ def main(): sleep(0.1) l = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -453,7 +453,7 @@ def main(): sleep(0.1) l = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("9800 SSH Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -466,7 +466,7 @@ def main(): sleep(0.1) k = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) + logg.info("8900 SSH Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -583,7 +583,7 @@ def main(): sleep(0.1) l = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("9800 Successfully received {} prompt i:{} j:{} k:{} l:{}".format(CCP_EN,i,j,k,l)) + logg.info("9800 TELNET Successfully received {} prompt i:{} j:{} k:{} l:{}".format(CCP_EN,i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -603,7 +603,7 @@ def main(): sleep(0.1) l = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -616,7 +616,7 @@ def main(): sleep(0.1) k = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -637,7 +637,7 @@ def main(): sleep(0.1) m = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if m == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) logged_in_9800 = True if m == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} m:{} before {} after {}".format(i,j,k,l,m,egg.before,egg.after)) @@ -657,7 +657,7 @@ def main(): sleep(0.1) m = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if m == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} l:{} m:{}".format(i,j,k,l,m)) logged_in_9800 = True if m == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} m:{} before {} after {}".format(i,j,k,l,m,egg.before,egg.after)) @@ -670,7 +670,7 @@ def main(): sleep(0.1) l = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -720,7 +720,7 @@ def main(): sleep(0.1) k = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k, egg.before,egg.after)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k, egg.before,egg.after)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -742,7 +742,7 @@ def main(): sleep(0.1) l = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{}".format(i,j,k)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{}".format(i,j,k)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -755,7 +755,7 @@ def main(): sleep(0.1) j = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if j == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after)) logged_in_9800 = True if j == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} before {} after {}".format(i,j,egg.before,egg.after)) @@ -777,7 +777,7 @@ def main(): sleep(0.1) l = egg.expect_exact([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("9800 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -797,7 +797,7 @@ def main(): sleep(0.1) l = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if l == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} l:{}".format(i,j,k,l)) logged_in_9800 = True if l == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} l:{} before {} after {}".format(i,j,k,l,egg.before,egg.after)) @@ -810,7 +810,7 @@ def main(): sleep(0.1) k = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) if k == 0: - logg.info("8900 Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) + logg.info("9800 TELNET Successfully received # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) logged_in_9800 = True if k == 1: logg.info("9800 Timed out waiting for # prompt i:{} j:{} k:{} before {} after {}".format(i,j,k,egg.before,egg.after)) @@ -1246,13 +1246,15 @@ def main(): raise Exception("wlan ID is required") command = "config wlan delete %s"%(args.wlanID) + logg.info("action {} series {}".format(args.action,args.series)) if (args.action == ["enable_wlan","disble_wlan"]): if args.series == "9800": if (args.wlan is None): raise Exception("9800 series wlan is required") else: + logg.info("sendline config t") egg.sendline("config t") - sleep(0.1) + sleep(0.3) i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: logg.info("elevated to (config)#") From 5c7769c01a14b206848429308b9a4915cc72e49d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 13 Jan 2021 13:31:38 -0700 Subject: [PATCH 003/848] cisco_wifi_ctl.py : separate out enable and disable for wlan --- cisco_wifi_ctl.py | 49 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 1794ebd4..94a1dde6 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -918,7 +918,7 @@ def main(): logg.info("waiting for prompt: {}".format(CCPROMPT)) egg.expect(">", timeout=3) - logg.info("Ap[%s] Action[%s] Value[%s] "%(args.ap, args.action, args.value)) + logg.info("Command to Process :: 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)): @@ -1247,7 +1247,7 @@ def main(): command = "config wlan delete %s"%(args.wlanID) logg.info("action {} series {}".format(args.action,args.series)) - if (args.action == ["enable_wlan","disble_wlan"]): + if (args.action == "enable_wlan"): if args.series == "9800": if (args.wlan is None): raise Exception("9800 series wlan is required") @@ -1263,10 +1263,8 @@ def main(): sleep(0.1) j = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) if j == 0: - if (args.action == "enable_wlan"): - cmd = "no shutdown" - else: - cmd = "shutdown" + logg.info("enable_wlan send no shutdown") + cmd = "no shutdown" egg.sendline(cmd) sleep(0.1) if j == 1: @@ -1274,12 +1272,41 @@ def main(): if i == 1: logg.info("did not get the (config)# prompt") else: - if (args.action == ["enable_wlan","disable_wlan"] and (args.wlanID is None)): + if (args.action == "enable_wlan" and (args.wlanID is None)): raise Exception("wlan ID is required") - if (args.action == "enable_wlan"): - command = "config wlan enable %s"%(args.wlanID) - else: - command = "config wlan disable %s"%(args.wlanID) + logg.info("send: config wlan enable {}".format(args.wlanID)) + command = "config wlan enable %s"%(args.wlanID) + + if (args.action == "disable_wlan"): + if args.series == "9800": + if (args.wlan is None): + raise Exception("9800 series wlan is required") + else: + logg.info("sendline config t") + egg.sendline("config t") + sleep(0.3) + i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) + if i == 0: + logg.info("elevated to (config)#") + cmd = "wlan %s"%(args.wlan) + egg.sendline(cmd) + sleep(0.1) + j = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) + if j == 0: + logg.info("disable_wlan send shutdown") + cmd = "shutdown" + egg.sendline(cmd) + sleep(0.1) + if j == 1: + logg.info("did not get the (config-wlan)# prompt") + if i == 1: + logg.info("did not get the (config)# prompt") + else: + if (args.action == "disable_wlan" and (args.wlanID is None)): + raise Exception("wlan ID is required") + logg.info("send: config wlan disable {}".format(args.wlanID)) + command = "config wlan disable %s"%(args.wlanID) + if (args.action == "wlan_qos" and (args.wlanID is None)): raise Exception("wlan ID is required") From a67a12783db242e28b391dd9c4ef8b7cb93874ef Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 13 Jan 2021 13:48:14 -0700 Subject: [PATCH 004/848] lf_cisco_power.py cisco_wifi_ctl.py : make parameters required --- cisco_wifi_ctl.py | 14 +++++++------- lf_cisco_power.py | 32 +++++++++++++++++++------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 94a1dde6..57bcbb69 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1272,10 +1272,10 @@ def main(): if i == 1: logg.info("did not get the (config)# prompt") else: - if (args.action == "enable_wlan" and (args.wlanID is None)): + if (args.wlan is None): raise Exception("wlan ID is required") - logg.info("send: config wlan enable {}".format(args.wlanID)) - command = "config wlan enable %s"%(args.wlanID) + logg.info("send: config wlan enable {}".format(args.wlan)) + command = "config wlan enable %s"%(args.wlan) if (args.action == "disable_wlan"): if args.series == "9800": @@ -1302,13 +1302,13 @@ def main(): if i == 1: logg.info("did not get the (config)# prompt") else: - if (args.action == "disable_wlan" and (args.wlanID is None)): + if (args.wlan is None): raise Exception("wlan ID is required") - logg.info("send: config wlan disable {}".format(args.wlanID)) - command = "config wlan disable %s"%(args.wlanID) + logg.info("send: config wlan disable {}".format(args.wlan)) + command = "config wlan disable %s"%(args.wlan) - if (args.action == "wlan_qos" and (args.wlanID is None)): + if (args.action == "wlan_qos" and (args.wlan is None)): raise Exception("wlan ID is required") if (args.action == "wlan_qos"): command = "config wlan qos %s %s"%(args.wlanID, args.value) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 69dd0865..d1cdd39e 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -40,7 +40,7 @@ NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme --series "3504" --prompt "(Cisco Controler)" ############################################################################################## -# Long duration test +# Long duration test -- need to create the --wlan open-wlan --wlanID - need to put in the notes ############################################################################################## ./lf_cisco_power.py -d 172.19.36.168 -u admin -p Wnbulab@123 --port 23 --scheme telnet --ap "APA453.0E7B.CF60" \ @@ -257,10 +257,10 @@ def main(): parser = argparse.ArgumentParser(description="Cisco TX Power report Script",epilog=EPILOG, formatter_class=argparse.RawTextHelpFormatter) - parser.add_argument("-d", "--dest", type=str, help="address of the cisco controller") - parser.add_argument("-o", "--port", type=str, help="control port on the controller", default=23) - parser.add_argument("-u", "--user", type=str, help="credential login/username") - parser.add_argument("-p", "--passwd", type=str, help="credential password") + parser.add_argument("-d", "--dest", type=str, help="address of the cisco controller",required=True) + parser.add_argument("-o", "--port", type=str, help="control port on the controller",required=True) + parser.add_argument("-u", "--user", type=str, help="credential login/username",required=True) + parser.add_argument("-p", "--passwd", type=str, help="credential password",required=True) 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", action='store_true', help="create logfile for messages, default stdout") @@ -285,22 +285,22 @@ def main(): parser.add_argument("--pf_a4_dropoff", type=str, help="Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") - parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier default wlan-open",default="wlan-open") - parser.add_argument("--wlanID", type=str, help="--wlanID 9800 , defaults to 1",default="1") + parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier default wlan-open",required=True) + parser.add_argument("--wlanID", type=str, help="--wlanID 9800 , defaults to 1",default="1",required=True) parser.add_argument("--series", type=str, help="--series 9800 or 3504, defaults to 9800",default="9800") parser.add_argument("--slot", type=str, help="--slot 1 , 9800 AP slot defaults to 1",default="1") parser.add_argument("--create_station", type=str, help="create LANforge station at the beginning of the test") parser.add_argument("--radio", type=str, help="radio to create LANforge station on at the beginning of the test") - parser.add_argument("--ssid", type=str, help="ssid default open-wlan",default="open-wlan") - parser.add_argument("--ssidpw", type=str, help="ssidpw default [BLANK]",default="[BLANK]") - parser.add_argument("--security", type=str, help="security default open",default="open") + parser.add_argument("--ssid", type=str, help="ssid",required=True) + parser.add_argument("--ssidpw", type=str, help="ssidpw",required=True) + parser.add_argument("--security", type=str, help="security",required=True) parser.add_argument("--cleanup", action='store_true',help="--cleanup , Clean up stations after test completes ") parser.add_argument("--vht160", action='store_true',help="--vht160 , Enable VHT160 in lanforge ") parser.add_argument('--verbose', action='store_true',help='--verbose , switch the cisco controller output will be captured') parser.add_argument("--exit_on_fail", action='store_true',help="--exit_on_fail, exit on test failure") parser.add_argument("--exit_on_error", action='store_true',help="--exit_on_error, exit on test error, test mechanics failed") parser.add_argument('-e','--email', action='append', nargs=1, type=str, help="--email user== passwd== to== smtp== port== 465 (SSL)") - parser.add_argument('-ccp','--prompt', type=str,help="controller prompt default WLC",default="WLC") + parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] @@ -744,7 +744,13 @@ def main(): pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + logg.info("####################################################################################################") + logg.info("#CHECK IF CONTROLLER HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + exit_test(workbook) if args.series == "9800": @@ -754,7 +760,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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "disable_wlan","--wlan", args.wlan, "--wlanID", args.wlanID,"--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) @@ -900,7 +906,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","--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "enable_wlan","--wlan", args.wlan, "--wlanID", args.wlanID,"--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) From 832a06a24832ec0c3993fc84f189c3e98fcd93e6 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 13 Jan 2021 14:28:41 -0700 Subject: [PATCH 005/848] lf_cisco_power.py : logs for creating wlan --- lf_cisco_power.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index d1cdd39e..5d66f05e 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -880,6 +880,7 @@ def main(): pass else: wlan_created = True + logg.info("create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) 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, From 877faafc790bb307e60066e5711b02cd8fc46d84 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 13 Jan 2021 14:36:22 -0700 Subject: [PATCH 006/848] cisco_wifi_ctl.py : create_wlan --- cisco_wifi_ctl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 57bcbb69..58c09c37 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1198,6 +1198,7 @@ def main(): if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): raise Exception("wlan and wlanID is required an") if (args.action == "create_wlan"): + logg.info("create_wlan wlanID {} wlan {}".format(args.wlanID, args.wlan)) if args.series == "9800": egg.sendline("config t") sleep(0.4) From 5de806509e17d2ba53d05b445cbee5f6bacaaea3 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 13 Jan 2021 19:25:32 -0800 Subject: [PATCH 007/848] create_wanlink.py: make ports a variable --- py-json/create_wanlink.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/py-json/create_wanlink.py b/py-json/create_wanlink.py index 3e1f00e8..74d0d9cc 100755 --- a/py-json/create_wanlink.py +++ b/py-json/create_wanlink.py @@ -30,6 +30,9 @@ def main(): num_wanlinks = -1 # see if there are old wanlinks to remove lf_r = LFRequest.LFRequest(base_url+"/wl/list") + + port_a ="rd0a" + port_b ="rd1a" try: json_response = lf_r.getAsJson() LFUtils.debug_printer.pprint(json_response) @@ -69,7 +72,7 @@ def main(): 'alias': 'wl_eg1-A', 'shelf': 1, 'resource': '1', - 'port': 'eth3', + 'port': port_a, 'latency': '75', 'max_rate': '128000', 'description': 'cookbook-example' @@ -83,7 +86,7 @@ def main(): 'alias': 'wl_eg1-B', 'shelf': 1, 'resource': '1', - 'port': 'eth5', + 'port': port_b, 'latency': '95', 'max_rate': '256000', 'description': 'cookbook-example' From 06cb15c98656cf91d698265abc4dcd246cda6bb5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 14 Jan 2021 14:42:53 -0700 Subject: [PATCH 008/848] cisco_wifi_ctl.py : command updates for creating wlan --- cisco_wifi_ctl.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 58c09c37..cb782560 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1205,14 +1205,27 @@ def main(): i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: logg.info("elevated to (config)#") - command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) + command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) # should the last one be ssid not wlan logg.info("open network command {}".format(command)) egg.sendline(command) sleep(0.4) j = egg.expect_exact([CCP_CONFIG_WLAN,pexpect.TIMEOUT],timeout=2) if j == 0: - for command in ["shutdown","no security ft","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", - "no security wpa akm dot1x","no shutdown"]: + # previous commands for command in ["shutdown","no security ft","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", + # "no security wpa akm dot1x","no shutdown"]: + + # 1/14/2021 - Gaurav suggestion + # We are basically disabling all the possible security parameters for Authentication + for command in [ + "no security ft", + "no security ft adaptive", + "no security wpa", + "no security wpa wpa2", + "no security wpa wpa1", + "no security wpa wpa2 ciphers aes" + "no security dot1x authentication-list", + "no security wpa akm dot1x", + "no shutdown"]: egg.sendline(command) sleep(1) k = egg.expect_exact([CCP_CONFIG_WLAN,pexpect.TIMEOUT],timeout=2) From cbdf077e09c8bd41f5e3b3dbb8ec0946b306f4c5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 14 Jan 2021 15:18:36 -0700 Subject: [PATCH 009/848] cisco_wifi_ctl.py : debugging show wlan summary, for controller --- cisco_wifi_ctl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index cb782560..d1c5f77b 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1189,10 +1189,12 @@ def main(): if (args.action == "show_wlan_summary"): egg.sendline("show wlan summary") sleep(0.1) - i = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) + i = egg.expect([CCP,CCP_EN,pexpect.TIMEOUT],timeout=2) if i == 0: - logg.info("show wlan summary sent") + logg.info("show wlan summary sent prompt {}".format(CCP)) if i == 1: + logg.info("show wlan summary sent prompt {}".format(CCP_EN)) + if i == 2: logg.info("show wlan summary timed out") if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): @@ -1214,7 +1216,7 @@ def main(): # previous commands for command in ["shutdown","no security ft","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", # "no security wpa akm dot1x","no shutdown"]: - # 1/14/2021 - Gaurav suggestion + # 1/14/2021 - Cisco suggestion # We are basically disabling all the possible security parameters for Authentication for command in [ "no security ft", From 140da5e12b9bc8ad8332449c290bd0c56b6011cb Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 14 Jan 2021 15:43:09 -0700 Subject: [PATCH 010/848] cisco_wifi_ctl.py : additional debug on show wlan summary --- cisco_wifi_ctl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index d1c5f77b..9f3a4357 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1187,9 +1187,10 @@ def main(): logg.info("did not get the (config)# prompt") if (args.action == "show_wlan_summary"): + logg.info("show wlan summary command to send") egg.sendline("show wlan summary") sleep(0.1) - i = egg.expect([CCP,CCP_EN,pexpect.TIMEOUT],timeout=2) + i = egg.expect([CCP,CCP_EN,pexpect.TIMEOUT],timeout=1) if i == 0: logg.info("show wlan summary sent prompt {}".format(CCP)) if i == 1: From c76cb3f43f12f347761a701735b3bdd742b274cc Mon Sep 17 00:00:00 2001 From: DiptiDhond-Candela <67250295+DiptiDhond-Candela@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:47:30 -0800 Subject: [PATCH 011/848] Delete example_wep_connection.py --- py-scripts/example_wep_connection.py | 109 --------------------------- 1 file changed, 109 deletions(-) delete mode 100755 py-scripts/example_wep_connection.py diff --git a/py-scripts/example_wep_connection.py b/py-scripts/example_wep_connection.py deleted file mode 100755 index 9eaaf607..00000000 --- a/py-scripts/example_wep_connection.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None, number_template="00000", radio = "wiphy0",_debug_on=False, host="locahost", port=8080, - _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 - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - - parser = LFCliBase.create_basic_argparse( - prog='example_wep_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WEP security. - ''', - - description='''\ - example_wep_connection.py - -------------------- - - Generic command example: - python3 ./example_wep_connection.py - --host localhost - --port 8080 - --num_stations 3 - --radio wiphy1 - --ssid jedway-wep-48 - --passwd jedway-wep-48 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000) - ip_test = IPv4Test(host=args.mgr,port=args.mgr_port, ssid=args.ssid, password=args.passwd, - security="wep", radio=args.radio, sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() From a87a8bba2a7a5f9fa8237aef2913959af1d4a337 Mon Sep 17 00:00:00 2001 From: DiptiDhond-Candela <67250295+DiptiDhond-Candela@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:47:41 -0800 Subject: [PATCH 012/848] Delete example_wpa2_connection.py --- py-scripts/example_wpa2_connection.py | 109 -------------------------- 1 file changed, 109 deletions(-) delete mode 100755 py-scripts/example_wpa2_connection.py diff --git a/py-scripts/example_wpa2_connection.py b/py-scripts/example_wpa2_connection.py deleted file mode 100755 index db8bcaf6..00000000 --- a/py-scripts/example_wpa2_connection.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None,host="localhost", port=8080, 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.ssid = ssid - self.radio = radio - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - parser = LFCliBase.create_basic_argparse( - prog='example_wpa2_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WPA2 security. - ''', - - description='''\ - example_wpa2_connection.py - -------------------- - - Generic command example - python3 ./example_wpa2_connection.py - --host localhost - --port 8080 - --num_stations 3 - --ssid netgear-wpa2 - --passwd admin123-wpa2 - --radio wiphy1 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000, - radio=args.radio) - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, - security="wpa2", sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() From 2d0dae4681d6d141859b4bf13357f8b8fdfe4285 Mon Sep 17 00:00:00 2001 From: DiptiDhond-Candela <67250295+DiptiDhond-Candela@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:47:49 -0800 Subject: [PATCH 013/848] Delete example_wpa3_connection.py --- py-scripts/example_wpa3_connection.py | 110 -------------------------- 1 file changed, 110 deletions(-) delete mode 100755 py-scripts/example_wpa3_connection.py diff --git a/py-scripts/example_wpa3_connection.py b/py-scripts/example_wpa3_connection.py deleted file mode 100755 index a9e49286..00000000 --- a/py-scripts/example_wpa3_connection.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, host="localhost", port=8080,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.ssid = ssid - self.radio = radio - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - #print("We've gotten into the build stations function") - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - parser = LFCliBase.create_basic_argparse( - prog='example_wpa3_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WPA3 security. - ''', - - description='''\ - example_wpa3_connection.py - -------------------- - - Generic command example: - python3 ./example_wpa3_connection.py - --host localhost - --port 8080 - --num_stations 3 - --ssid netgear-wpa3 - --passwd admin123-wpa3 - --radio wiphy1 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000, - radio=args.radio) - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, - security="wpa3", sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() From 54762b8a068dca7f2b0807b8cbc2e0f266469277 Mon Sep 17 00:00:00 2001 From: DiptiDhond-Candela <67250295+DiptiDhond-Candela@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:47:57 -0800 Subject: [PATCH 014/848] Delete example_wpa_connection.py --- py-scripts/example_wpa_connection.py | 114 --------------------------- 1 file changed, 114 deletions(-) delete mode 100755 py-scripts/example_wpa_connection.py diff --git a/py-scripts/example_wpa_connection.py b/py-scripts/example_wpa_connection.py deleted file mode 100755 index db8fcf1a..00000000 --- a/py-scripts/example_wpa_connection.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import argparse -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None, host="locahost", port=8080, 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.ssid = ssid - self.radio= radio - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - - - -def main(): - parser = LFCliBase.create_basic_argparse( - prog='example_wpa_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WPA security. - ''', - - description='''\ - example_wpa_connection.py - -------------------- - - Generic command example: - python3 ./example_wpa_connection.py - --host localhost - --port 8080 - --num_stations 3 - --ssid netgear-wpa - --passwd admin123-wpa - --radio wiphy1 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000, - radio=args.radio) - - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, - security="wpa", sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() From 0e8dec5ddec52389f4857e4a10f01d08771d987b Mon Sep 17 00:00:00 2001 From: DiptiDhond-Candela <67250295+DiptiDhond-Candela@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:49:15 -0800 Subject: [PATCH 015/848] Delete example_open_connection.py --- py-scripts/example_open_connection.py | 109 -------------------------- 1 file changed, 109 deletions(-) delete mode 100755 py-scripts/example_open_connection.py diff --git a/py-scripts/example_open_connection.py b/py-scripts/example_open_connection.py deleted file mode 100755 index 4d5308f5..00000000 --- a/py-scripts/example_open_connection.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None, number_template="00000", host="localhost", port=8080, 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.ssid = ssid - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.radio=radio - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - - parser = LFCliBase.create_basic_argparse( - prog='example_open_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using Open security. - ''', - - description='''\ - example_open_connection.py - -------------------- - - Generic command example: - python3 ./example_open_connection.py - --mgr localhost - --mgr_port 8080 - --num_stations 3 - --radio wiphy1 - --ssid netgear-open - --passwd [BLANK] - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_sta = int(args.num_stations) - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000) - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, - security="open", radio=args.radio, sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() From 05ade5bb2be1769ef70dd1ae7cdcd6ede2d7613e Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Fri, 15 Jan 2021 10:12:58 +0530 Subject: [PATCH 016/848] netgear_dfs update --- py-scripts/Netgear_dfs.py | 991 +++++++++++++++----------------------- 1 file changed, 393 insertions(+), 598 deletions(-) diff --git a/py-scripts/Netgear_dfs.py b/py-scripts/Netgear_dfs.py index adefeafb..8e790463 100644 --- a/py-scripts/Netgear_dfs.py +++ b/py-scripts/Netgear_dfs.py @@ -1,665 +1,460 @@ -""" file under progress not ffor testing - -""" - - - - - -import time - -import threading +"""need to be modified not for testing """ import os - import paramiko - +import time +from subprocess import Popen, PIPE, STDOUT +import threading from queue import Queue - from cx_time import IPv4Test - - - - - - - class DFS_TESTING: - - - - - def __init__(self): - pass - - - - - def set_dfs_channel_in_ap(self): - - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - - ssh.connect('192.168.200.190', port=22, username='root', password='Lanforge12345!xzsawq@!') - - stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52') - - output = stdout.readlines() - - print('\n'.join(output)) - - time.sleep(1) - - exit(0) - - - - def create_station_on_GUI(self,y1,y2): - - global var1 - - self.y1 = y1 - - self.y2 = y2 - - cmd = "python3 sta_cx.py --mgr 192.168.200.13 --num_stations 1 --ssid TestAP95 --passwd lanforge --security wpa2 --radio wiphy0" - - print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/home/lanforge/lanforge-scripts/py-scripts') - - print("Current working directory: {0}".format(os.getcwd())) - - x = os.popen(cmd).read() - - print("station created") - - y1 ='station created' - - - - with open("data.txt", "w")as f: - - f.write(x) - - f.close() - - - - file = open("data.txt", "r") - - for i in file: - - if "channel associated is " in i: - - my_list = list(i.split(" ")) - - print(my_list[3]) - - print(type(my_list[3])) - - var1 = my_list[3] - - - - print(var1) - - var = var1.replace("\n", "") - - - - if var == "52" or var == "56" or var == "60" or var == "64" or var == "100" or var == "104" or var == "108" or var == "112" or var == "116" or var == "120" or var == "124" or var == "128" or var == "132" or var == "136" or var == "140": - - print('Station is on DFS Channel') - - self.y2 = 'station is on DFS Channel' - - else: - - print('Station is on Non DFS channel') - - self.y2 = 'Station is on Non DFS channel' - - - - return (self.y1 , self.y2) - - - - - - - - - - ''' ########### HACKRF ####################### ''' - - - - - - def generate_radar_at_ch52(self, r): - - self.r = r - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - #print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - self.r = "Radar detected" - - return self.r - - - - def generate_radar_at_ch56(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch60(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch64(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch100(self,r): - - self.r = r - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - self.r = "Radar received" - - return self.r - - - - def generate_radar_at_ch104(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch108(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch112(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch116(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch120(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" - - #print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch124(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch128(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch132(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch136(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - - def generate_radar_at_ch140(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" - - # print("Current working directory: {0}".format(os.getcwd())) - - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - - os.system(cmd) - - - def hackrf_status_off(self): cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" - # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + def check_radio_on_off(self, x): + self.x = x + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('conf_get system:wlanSettings:wlanSettingTable:wlan0:radioStatus') + output = stdout.readlines() + print('\n'.join(output)) + self.x = output + time.sleep(1) + return self.x + + def check_for_channels(self, q): + self.q = q + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('iwlist channel') + output = stdout.readlines() + # print('\n'.join(output)) + self.q = output + time.sleep(1) + return self.q + + def set_channel_in_ap(self, w): + self.w = w + cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command(cmd) + output = stdout.readlines() + print('\n'.join(output)) + self.w = output + time.sleep(1) + return self.w + + def create_station_on_GUI(self, w): + self.w = w + obj = IPv4Test(_host="localhost", + _port=8080, + _ssid="TestAP22", + _password="[BLANK]", + _security="open", + _radio="wiphy0") + obj.cleanup(obj.sta_list) + obj.build() + obj.station_profile.admin_up() + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(5) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + self.w = var_1 + return self.w + + def generate_radar_at_ch52(self, r): + self.r = r + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.r = "Radar detected" + return self.r + + def generate_radar_at_ch56(self,q): + self.q =q + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" + # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.q = "Radar detected" + return self.q + def generate_radar_at_ch60(self,w): + self.w = w + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.w = "Radar detected" + return self.w + def generate_radar_at_ch64(self,e): + self.e = e + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.e = "Radar detected" + return self.e + + def generate_radar_at_ch100(self,f): + self.f = f + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.f = "Radar received" + return self.f + + def generate_radar_at_ch104(self,t): + self.t = t + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.t = "Radar detected" + return self.t + + def generate_radar_at_ch108(self,u): + self.u=u + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.u = "Radar detected" + return self.u + + def generate_radar_at_ch112(self,i): + self.i=i + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.i = "Radar detected" + return self.i + + def generate_radar_at_ch116(self,o): + self.o =o + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.o = "Radar detected" + return self.o + + def generate_radar_at_ch120(self,p): + self.p=p + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" + #print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.p = "Radar detected" + return self.p + + def generate_radar_at_ch124(self,a): + self.a=a + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.a = "Radar detected" + return self.a + + def generate_radar_at_ch128(self,s): + self.s=s + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.s = "Radar detected" + return self.s + + def generate_radar_at_ch132(self,d): + self.d = d + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.d = "Radar detected" + return self.d + + def generate_radar_at_ch136(self,h): + self.h=h + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.h = "Radar detected" + return self.h + + def generate_radar_at_ch140(self,j): + self.j = j + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.j = "Radar detected" + return self.j def monitor_station_channel(self,m): - self.m = m - - obj = IPv4Test(_host="192.168.200.13", - + obj = IPv4Test(_host="localhost", _port=8080, - - _ssid="TestAP95", - - _password="lanforge", - - _security="wpa2", - + _ssid="TestAP22", + _password="[BLANK]", + _security="open", _radio="wiphy0") - obj.cleanup(obj.sta_list) - - obj.build() - - obj.station_profile.admin_up() - - obj.local_realm.wait_for_ip(obj.sta_list) - - time.sleep(30) - - var = obj.json_get("/port/1/1/sta0000?fields=channel") - - var_1 = var['interface']['channel'] - + var_1 = "station cleaned" self.m = var_1 - return self.m - - - - - def aps_radio_off(self): - - pass - - - - def aps_not_switch_automatically(self): - - pass - - - - def check_ap_channel_switching_time(self): - - pass - - - - + def check_log(self, r): + self.r = r + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep Radar') + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(1) + self.r = output + return self.r def main(): - - - - - - - - - + que = Queue() dfs = DFS_TESTING() - - - que = Queue() - - - - - - - - ''' algorithm and sequence to be followed ''' - - - + print("checking hackrf is oN/OFF") print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - dfs.hackrf_status_off() print("Now hackrf is OFF") - - - #set channel on ap //netgear - - - threads_list = [] - - t1 = threading.Thread(target=lambda q, arg1, arg2: q.put(dfs.create_station_on_GUI(arg1, arg2)), args=(que, "", "")) - + print("checking if all radios is ON/OFF") + t1 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_radio_on_off(arg1)), args=(que, "")) t1.start() - threads_list.append(t1) - t1.join() + x = que.get() + # print("result", x) + new_list = [] + new_list_1 = [] + for element in x: + new_list.append(element.strip()) + # print(new_list[0]) + new_list_1 = new_list[0].split() + # print("elements", new_list_1) - - - # Check thread's return value - - global my_var - - - - result = que.get() - - print("hi i reached", result) - - my_var = result - - - - list_1 = list(my_var) - - print("my list", list_1) - - - - if any("station is on DFS Channel" in s for s in list_1): - - t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - - t2.start() - - threads_list.append(t2) - - t2.join() - - x = que.get() - - print("result", x) - + if (new_list_1[1] == "1"): + print("Radio is ON") else: + print("Radio is OFF") - print("radar unreachable") - - - - t3=threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) - - t3.start() - - threads_list.append(t3) - - t3.join() - - y = que.get() - - print("channel after radar is ", y) - - - - if (y != "52"): - - print("station is on Non DFS Channel") - - else: - - print("station is on DFS Channel") - - - - - - - - - - - - - - - - - - """t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - + t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_channels(arg1)), args=(que, "")) t2.start() - threads_list.append(t2) - - t2.join()""" - - - - - - - - - - # Join all the threads - - """for t in threads_list: - - t.join()""" - - - - - - - - """print("my var", my_var) - - empty_list = [] - - list = empty_list.append(my_var) - - print("list", list)""" - - - - - - '''t2 = threading.Thread(target=dfs.generate_radar_at_ch100()) - - t2.start() - t2.join() + y = que.get() + print("Channel available are", y) + copy_y = y[:] + del copy_y[21:len(copy_y)] + # print("hi*********************" ,copy_y) + a_list = [] + for i in copy_y: + a_list.append(i.strip()) + # print("hi", a_list) + """['wifi1vap8 109 channels in total; available frequencies :', 'Channel 36 : 5.18 GHz', + 'Channel 40 : 5.2 GHz', 'Channel 44 : 5.22 GHz', 'Channel 48 : 5.24 GHz', 'Channel 52 : 5.26 GHz', + 'Channel 56 : 5.28 GHz', 'Channel 60 : 5.3 GHz', 'Channel 64 : 5.32 GHz', 'Channel 100 : 5.5 GHz', + 'Channel 104 : 5.52 GHz', 'Channel 108 : 5.54 GHz', 'Channel 112 : 5.56 GHz', 'Channel 116 : 5.58 GHz', + 'Channel 120 : 5.6 GHz', 'Channel 124 : 5.62 GHz', 'Channel 128 : 5.64 GHz', 'Channel 132 : 5.66 GHz', + 'Channel 136 : 5.68 GHz', 'Channel 140 : 5.7 GHz', 'Current Frequency:5.22 GHz (Channel 44)']""" + if any("Channel 52 : 5.26 GHz" in s for s in a_list): + print("set channel to 52") + t3 = threading.Thread(target=lambda q, arg1: q.put(dfs.set_channel_in_ap(arg1)), args=(que, "")) + t3.start() + t3.join() + print("channel set hogya") - print("radar received") - - - - t3 = threading.Thread(target=dfs.create_station_on_GUI()) - - t3.start() - - t3.join() - - print("station reassociated")''' - - - - - - - - - - '''dfs.hackrf_status_off() - - dfs.aps_radio_off() - - dfs.aps_not_switch_automatically() - - #generate radar and check for all dfs channels - - dfs.check_ap_channel_switching_time() - - #after testing turn off hackrf''' + t4 = threading.Thread(target=lambda q, arg1: q.put(dfs.create_station_on_GUI(arg1)), args=(que, "")) + t4.start() + t4.join() + print("station created") + + t5 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t5.start() + t5.join() + print("radar generated") + print("checking hackrf is oN/OFF") + print("Hackrf is ON") + print("press s --> enter --> q to stop hackrf") + t6 = threading.Thread(dfs.hackrf_status_off()) + t6.start() + t6.join() + print("Now hackrf is OFF") + t7 =threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) + t7.start() + threads_list.append(t7) + t7.join() + f = que.get() + print("station cleaned ", f) + time.sleep(60) + t8 = threading.Thread(target=lambda q, arg1: q.put(dfs.create_station_on_GUI(arg1)), args=(que, "")) + t8.start() + threads_list.append(t8) + t8.join() + b = que.get() + print("station at channel ", b) + if b == "52": + print("station is on DFS Channel") + t9 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t9.start() + t9.join() + elif b == "56": + print("station is on DFS Channel 56") + t10 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch56(arg1)), args=(que, "")) + t10.start() + t10.join() + elif b == "60": + print("station is on DFS Channel 60") + t11 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch60(arg1)), args=(que, "")) + t11.start() + t11.join() + elif b == "64": + print("station is on DFS Channel 64") + t12 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch64(arg1)), args=(que, "")) + t12.start() + t12.join() + elif b == "100": + print("station is on DFS Channel 100") + t13 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) + t13.start() + t13.join() + elif b == "104": + print("station is on DFS Channel 104") + t14 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch104(arg1)), args=(que, "")) + t14.start() + t14.join() + elif b == "108": + print("station is on DFS Channel 108") + t15 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch108(arg1)), args=(que, "")) + t15.start() + t15.join() + elif b == "112": + print("station is on DFS Channel 112") + t16 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch112(arg1)), args=(que, "")) + t16.start() + t16.join() + elif b == "116": + print("station is on DFS Channel 116") + t17 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) + t17.start() + t17.join() + elif b == "120": + print("station is on DFS Channel 120") + t18 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch120(arg1)), args=(que, "")) + t18.start() + t18.join() + elif b == "124": + print("station is on DFS Channel 124") + t19 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch124(arg1)), args=(que, "")) + t19.start() + t19.join() + elif b == "128": + print("station is on DFS Channel 128") + t20 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch128(arg1)), args=(que, "")) + t20.start() + t20.join() + elif b == "132": + print("station is on DFS Channel 132") + t21 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch132(arg1)), args=(que, "")) + t21.start() + t21.join() + elif b == "136": + print("station is on DFS Channel 136") + t22 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) + t22.start() + t22.join() + elif b == "140": + print("station is on DFS Channel 140") + t23 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch140(arg1)), args=(que, "")) + t23.start() + t23.join() + else: + print("station is on NON DFS Channel") + print("checking hackrf is oN/OFF") + print("Hackrf is ON") + print("press s --> enter --> q to stop hackrf") + t6 = threading.Thread(dfs.hackrf_status_off()) + t6.start() + t6.join() + print("Now hackrf is OFF") + t24 = threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) + t24.start() + threads_list.append(t24) + t24.join() + f = que.get() + print("station cleaned ", f) + time.sleep(60) + t25 = threading.Thread(target=lambda q, arg1: q.put(dfs.create_station_on_GUI(arg1)), args=(que, "")) + t25.start() + threads_list.append(t25) + t25.join() + b = que.get() + print("station at channel ", b) + t26 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_log(arg1)), args=(que, "")) + t26.start() + threads_list.append(t26) + t26.join() + v = que.get() + print(v) if __name__ == '__main__': - main() - - +Displaying netgear_dfs_15.txt. From 61a74b35859a9e243d8f4ec972ecd7660c3a924a Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 15 Jan 2021 12:42:10 -0800 Subject: [PATCH 017/848] monitor inheriting from lfcli base --- py-json/realm.py | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a7753052..ccc616ab 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -817,6 +817,16 @@ class Realm(LFCliBase): def new_test_group_profile(self): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) +class BaseProfile(LFCliBase): + def __init__(self,local_realm): + self.parent_realm=local_realm + self.halt_on_error = False + self.exit_on_error = False + + def json_get(self, target): + self.debug_ = False + return self.parent_realm.json_get(self,target) + class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): @@ -994,7 +1004,7 @@ class MULTICASTProfile(LFCliBase): -class L3CXProfile(LFCliBase): +class L3CXProfile(BaseProfile): def __init__(self, lfclient_host, lfclient_port, local_realm, side_a_min_bps=None, side_b_min_bps=None, side_a_max_bps=0, side_b_max_bps=0, @@ -1017,7 +1027,7 @@ class L3CXProfile(LFCliBase): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) + super().__init__(local_realm) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm @@ -1045,7 +1055,7 @@ class L3CXProfile(LFCliBase): return self.data def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) + cx_list = self.json_get("endp?fields=name,rx+bytes") if self.debug: print(self.created_cx.values()) print("==============\n", cx_list, "\n==============") @@ -1079,13 +1089,13 @@ class L3CXProfile(LFCliBase): monitor_interval=1, col_names=None, created_cx=None, - show=False, + show=True, report_file=None, output_format=None, script_name=None, arguments=None): try: - duration_sec=local_realm.parse_time(duration_sec).seconds + duration_sec=self.local_realm.parse_time(duration_sec).seconds except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") @@ -1108,17 +1118,20 @@ class L3CXProfile(LFCliBase): #Step 1, column names fields=",".join(col_names) + print(fields) #Step 2, monitor columns start_time = datetime.datetime.now() - iterations=duration_sec/monitor_interval + end_time = start_time + datetime.timedelta(seconds=duration_sec) + print(end_time) value_map = dict() passes = 0 expected_passes = 0 old_cx_rx_values = self.__get_rx_values() timestamps=[] - for x in range(0,int(round(iterations,0))): - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields), debug_=self.debug) + #for x in range(0,int(round(iterations,0))): + while datetime.datetime.now() < end_time: + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1141,10 +1154,10 @@ class L3CXProfile(LFCliBase): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - #print(value_map) + print(value_map) - if passes == expected_passes: - self._pass("PASS: All tests passed") + #if passes == expected_passes: + #self._pass("PASS: All tests passed") #step 3 organize data endpoints=list() for endpoint in value_map.values(): @@ -1159,6 +1172,7 @@ class L3CXProfile(LFCliBase): endpoints2[point].insert(0, timestamps2[point]) #step 4 save and close header_row=col_names + print(header_row) header_row.insert(0,'Timestamp') if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': report_fh = open(report_file, "w+") @@ -1211,10 +1225,9 @@ class L3CXProfile(LFCliBase): else: pass - def refresh_cx(self): for cx_name in self.created_cx.keys(): - self.json_post("/cli-json/show_cxe", { + self.local_realm.json_post("/cli-json/show_cxe", { "test_mgr": "ALL", "cross_connect": cx_name }, debug_=self.debug) @@ -1225,7 +1238,7 @@ class L3CXProfile(LFCliBase): for cx_name in self.created_cx.keys(): if self.debug: print("cx-name: %s"%(cx_name)) - self.json_post("/cli-json/set_cx_state", { + self.local_realm.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", "cx_name": cx_name, "cx_state": "RUNNING" From 6fc1f3458664faf97c8a34e479b0c6b8b1039fce Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 15 Jan 2021 12:42:42 -0800 Subject: [PATCH 018/848] test ipv4 variable time --- py-scripts/test_ipv4_variable_time.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 7c3aacda..e52ce374 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -204,6 +204,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--ap',help='Used to force a connection to a particular AP') optional_args.add_argument('--report_file',help='where you want to store results') optional_args.add_argument('--output_format', help='choose either csv or xlsx') + optional_args.add_argument('--show', help='display results of test in terminal',default=True) args = parser.parse_args() num_sta = 2 @@ -251,13 +252,17 @@ python3 ./test_ipv4_variable_time.py else: output=args.output_format - layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) - ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], + try: + layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) + except: + raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') + ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs','Rx Drop % A', 'Rx Drop % B', 'Bps Rx A', 'Bps Rx B', 'Rx Rate', 'Cx Estab'], report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds, created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', + show=show, arguments=args) ip_var_test.stop() if not ip_var_test.passes(): From a73f911f5aaca31348e9f8856307f532fa911ef6 Mon Sep 17 00:00:00 2001 From: shivam Date: Sun, 17 Jan 2021 02:28:50 +0530 Subject: [PATCH 019/848] Adding Cleanup Delay in Station Profile --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index ccc616ab..c9a38271 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -3395,7 +3395,7 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: self.local_realm.rm_port(port_eid, check_exists=True, debug_=debug_) - + time.sleep(delay) # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) From f596d2f3379fd1297288405baa4ae7bfbbc0d099 Mon Sep 17 00:00:00 2001 From: shivam Date: Sun, 17 Jan 2021 22:11:31 +0530 Subject: [PATCH 020/848] status-msg updates --- py-scripts/connection_test.py | 150 ++++++++++++++++------------------ py-scripts/test_utility.py | 49 +++++++---- 2 files changed, 103 insertions(+), 96 deletions(-) diff --git a/py-scripts/connection_test.py b/py-scripts/connection_test.py index ef52e6f9..1719bd6d 100644 --- a/py-scripts/connection_test.py +++ b/py-scripts/connection_test.py @@ -1,9 +1,7 @@ """ Candela Technologies Inc. -Info : Standard Script for Connection Testing -Date : -Author : Shivam Thakur +Info : Standard Script for Connection Testing - Creates HTML and pdf report as a result (Used for web-console) """ @@ -22,7 +20,8 @@ import datetime import time import os from test_utility import CreateHTML -from test_utility import RuntimeUpdates +# from test_utility import RuntimeUpdates +from test_utility import StatusMsg import pdfkit webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) @@ -31,12 +30,11 @@ class ConnectionTest(LFCliBase): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio="wiphy1", sta_prefix="sta", start_id=0, num_sta=2, - dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="eth1", _test_update=None, name_prefix="L3Test", + dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="eth1", name_prefix="L3Test", session_id="Layer3Test", test_name="Client/s Connectivity Test", pass_criteria=20, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - print("Test is about to start") self.host = lfclient_host self.port = lfclient_port self.radio = radio @@ -53,37 +51,34 @@ class ConnectionTest(LFCliBase): self.session_id = session_id self.test_name = test_name self.test_duration = 1 - self.test_update = _test_update self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) self.station_profile = self.local_realm.new_station_profile() self.pass_fail = "" - + self.status_msg = StatusMsg(lfclient_host=self.host, lfclient_port=self.port, session_id=self.session_id) station_list = [] for i in range(0, self.num_sta): station_list.append(self.sta_prefix + str(i).zfill(4)) - print(station_list) self.station_data = dict.fromkeys(station_list) for i in station_list: self.station_data[i] = "None" - print(self.station_data) - - self.test_update.send_update({"test_status": '1', "data": 'None', "data": [], "label": "Client Connectivity Time"}) + try: + self.status_msg.update('1', {"data": 'Initializing...', "data": [], "label": "Client Connectivity Time"}) + except: + pass self.reports_path = webconsole_dir+"/reports/" + self.test_name + "_" + self.session_id + '/' - print(self.reports_path) if not os.path.exists(self.reports_path): os.makedirs(self.reports_path) - print("Test is Initialized") self.station_list = LFUtils.portNameSeries(prefix_=self.sta_prefix, start_id_=self.sta_start_id, end_id_=self.num_sta - 1, padding_number_=10000, radio=self.radio) - print(self.station_profile.station_names) - self.test_update.send_update({"test_status": '2', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('2', {"data": 'Initialized...', "data": [], "label": "Client Connectivity Time"}) + except: + pass def precleanup(self): - print("precleanup started") sta_list = [] for i in self.local_realm.station_list(): if (list(i.keys())[0] == '1.1.wlan0'): @@ -92,19 +87,18 @@ class ConnectionTest(LFCliBase): pass else: sta_list.append(list(i.keys())[0]) - print(sta_list) for sta in sta_list: self.local_realm.rm_port(sta, check_exists=True) time.sleep(1) LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) - print("precleanup done") - self.test_update.send_update({"test_status": '3', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('3', {"data": 'Building...', "data": [], "label": "Client Connectivity Time"}) + except: + pass def build(self): - print("Building Test Configuration") self.station_profile.use_security(self.security, self.ssid, self.password) self.station_profile.set_number_template("00") self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) @@ -113,18 +107,19 @@ class ConnectionTest(LFCliBase): self.station_profile.create(radio=self.radio, sta_names_=self.station_list, debug=self.debug) self.local_realm.wait_until_ports_appear(sta_list=self.station_list) self.update(status="build complete") - print("Test Build done") - self.test_update.send_update({"test_status": '4', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('4', {"data": 'Starting...', "data": [], "label": "Client Connectivity Time"}) + except: + pass def update(self, status="None"): for i in self.station_list: - print(self.json_get("port/1/1/" + i + "/?fields=ip,ap,down")) self.station_data[i.split(".")[2]] = \ self.json_get("port/1/1/" + i.split(".")[2] + "/?fields=ip,ap,down,phantom&cx%20time%20(us)")['interface'] - self.test_update.send_update({"test_status": '5', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - - def start(self, print_pass=False, print_fail=False): - print("Test is starting") + try: + self.status_msg.update('5', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass + def start(self): self.station_profile.admin_up() associated_map = {} self.ip_map = {} @@ -134,7 +129,7 @@ class ConnectionTest(LFCliBase): for sta_name in self.station_profile.station_names: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=port,alias,ip,ap", debug_=self.debug) - print(sta_status) + if (sta_status is None or sta_status['interface'] is None) or (sta_status['interface']['ap'] is None): continue if (len(sta_status['interface']['ap']) == 17) and (sta_status['interface']['ap'][-3] == ':'): @@ -147,65 +142,50 @@ class ConnectionTest(LFCliBase): else: time.sleep(1) - if self.debug: - print("sta_list", len(self.station_profile.station_names), self.station_profile.station_names) - print("ip_map", len(self.ip_map), self.ip_map) - print("associated_map", len(associated_map), associated_map) + if (len(self.station_profile.station_names) == len(self.ip_map)) and ( len(self.station_profile.station_names) == len(associated_map)): - self._pass("PASS: All stations associated with IP", print_pass) - print("Test Passed") + + #("Test Passed") for sta_name in self.station_profile.station_names: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) + #(sta_status) while sta_status['interface']['cx time (us)'] == 0: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) + # #(sta_status) continue cx_time[sta_name] = sta_status['interface']['cx time (us)'] else: - self._fail("FAIL: Not all stations able to associate/get IP", print_fail) - print("sta_list", self.station_profile.station_names) - print("ip_map", self.ip_map) for sta_name in self.ip_map.keys(): sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) while sta_status['interface']['cx time (us)'] == 0: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) + # #(sta_status) continue cx_time[sta_name] = sta_status['interface']['cx time (us)'] - print("associated_map", associated_map) - print("Test Failed") - print(self.ip_map) - print(associated_map) - print("cx time:", cx_time) self.test_result_data = [] self.keys = ["Client Name", "BSSID", "Channel", "Connection Time (ms)", "DHCP (ms)", "IPv4 Address", "MAC Address", "Mode", "Result"] for sta_name in self.station_profile.station_names: sta_status = self.json_get( "port/1/1/" + str(sta_name).split(".")[2] + "?fields=alias,ap,channel,cx%20time%20(us),ip,mac,mode,dhcp%20(ms)", debug_=self.debug) - print("ironman") - print(sta_status['interface']) self.test_result_data.append(sta_status['interface']) - print(self.test_result_data) offset = 0 self.chart_data = {} for data in self.test_result_data: - if (data["cx time (us)"]/1000 <= self.pass_criteria) and (data["cx time (us)"]/1000 > 0): - self.chart_data[data['alias']] = data["cx time (us)"]/1000 + if (int(data["cx time (us)"])/1000 <= self.pass_criteria) and (int(data["cx time (us)"])/1000 > 0): + self.chart_data[data['alias']] = float(data["cx time (us)"])/1000 data['Result'] = "PASS" else: - self.chart_data[data['alias']] = data["cx time (us)"] / 1000 + self.chart_data[data['alias']] = float(data["cx time (us)"]) / 1000 offset +=1 data['Result'] = "FAIL" - data["cx time (us)"] = str(data["cx time (us)"]/1000)+" / "+str(self.pass_criteria)+"ms" + data["cx time (us)"] = str(float(data["cx time (us)"])/1000)+" / "+str(self.pass_criteria)+"ms" objective = 'The Client Connectivity Test is designed to test the Performance of the Access Point. It will tell the Average Connection time that station takes to connect to Wifi Access Point. It will tell you Pass/Fail Criteria and detailed Report for Client Connection' @@ -223,26 +203,31 @@ class ConnectionTest(LFCliBase): chart_params={"chart_head": "Client Connection Time", "xlabel": "Clients", "ylabel": "Connection Time"}) self.html.write(self.html_data.report) self.html.close() + options = { + "enable-local-file-access": None + } + pdfkit.from_file(self.reports_path + self.test_name + "_" + self.session_id + ".html", + self.reports_path + self.test_name + "_" + self.session_id + '_report.pdf', options=options) - self.test_update.send_update({"test_status": '6', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('6', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass def stop(self): - print("Stopping Test") self.station_profile.admin_down() LFUtils.wait_until_ports_admin_down(port_list=self.station_profile.station_names) - self.test_update.send_update({"test_status": '7', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('7', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass def postcleanup(self): - self.station_profile.cleanup() - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, - port_list=self.station_profile.station_names, - debug=self.debug) - print("Test Completed") - self.test_update.send_update({"test_status": '8', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + self.station_profile.cleanup(delay=1) + try: + self.status_msg.update('8', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass def main(): - # This has --mgr, --mgr_port and --debug parser = LFCliBase.create_bare_argparse(prog="connection_test.py", formatter_class=argparse.RawTextHelpFormatter, epilog="About This Script") @@ -251,27 +236,34 @@ def main(): parser.add_argument('--passwd', help='--passwd of dut', default="[BLANK]") parser.add_argument('--radio', help='--radio to use on LANforge', default="wiphy1") parser.add_argument('--security', help='--security of dut', default="open") - parser.add_argument('--session_id', help='--session_id is for websocket', default="local") + parser.add_argument('--session_id', help='--session_id is for websocket', default=getSessionID()) parser.add_argument('--test_name', help='--test_name is for webconsole reports', default="Client Connectivity Test") parser.add_argument('--num_clients', type=int, help='--num_sta is number of stations you want to create', default=2) - parser.add_argument('--pass_criteria', type=int, help='--pass_criteria is pass criteria for connection Time', default=50) + parser.add_argument('--pass_criteria', type=int, help='--pass_criteria is pass criteria for connection Time', default=300) args = parser.parse_args() - # args.session_id = "local"; - print(args) - update = RuntimeUpdates(args.session_id, {"test_status": '0', "data": 'None', "data": [], "label": "Client Connectivity Time"}) + # Start Test - obj = ConnectionTest(lfclient_host="192.168.200.12", lfclient_port=args.mgr_port, + obj = ConnectionTest(lfclient_host=args.mgr, lfclient_port=args.mgr_port, session_id=args.session_id, test_name=args.test_name, dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, - num_sta=args.num_clients, radio=args.radio, pass_criteria=args.pass_criteria, _test_update=update) + num_sta=args.num_clients, radio=args.radio, pass_criteria=args.pass_criteria) obj.precleanup() obj.build() obj.start() obj.stop() obj.postcleanup() - print(obj.chart_data) - update.send_update({"test_status": '10', "data": obj.chart_data, "label": ["Client Names","Client Connectivity Time (ms)"], "result": obj.pass_fail}) + # #(obj.chart_data) + try: + obj.status_msg.update('10', {"data": 'done...', "data": [], "label": "Client Connectivity Time"}) + except: + pass + +def getSessionID(): + x = datetime.datetime.now() + id = x.strftime("%x").replace("/","_")+"_"+x.strftime("%x") + "_" + x.strftime("%X").split(":")[0] + "_" + x.strftime("%X").split(":")[1] + "_" + x.strftime("%X").split(":")[2]+str(x).split(".")[1] + id = str(id).replace("/", "_") + return id if __name__ == '__main__': main() diff --git a/py-scripts/test_utility.py b/py-scripts/test_utility.py index 2f9ae5fd..f684528b 100644 --- a/py-scripts/test_utility.py +++ b/py-scripts/test_utility.py @@ -9,6 +9,9 @@ Date : """ import sys +from pprint import pprint +from uuid import uuid1 + if 'py-json' not in sys.path: sys.path.append('../py-json') from LANforge import LFUtils @@ -282,21 +285,33 @@ class RuntimeUpdates(): f.close() -if __name__ == "__main__": - thread1 = ClientVisualization(lfclient_host="192.168.200.15", thread_id=1) - thread1.start() - for i in range(0, 100): - time.sleep(1) - #print(thread1.client_data) - thread1.stop() - # obj = RuntimeUpdates("1", {"test_status": 1, "data": "None"}) - # for i in range(0, 10): - # time.sleep(3) - # print(i) - # obj.send_update({"test_status": i, "data": "None"}) - # thread1 = ClientVisualization(lfclient_host="192.168.200.15", thread_id=1) - # thread1.start() - # for i in range(30): - # print(thread1.client_data) - # thread1.stop() +class StatusMsg(LFCliBase): + def __init__(self, lfclient_host="localhost", lfclient_port=8080, + _deep_clean=False, + session_id="0", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.deep_clean = _deep_clean + self.session_id = session_id + self.json_put("/status-msg/" + self.session_id, {}) + + def update(self, key, message): + self.json_post("/status-msg/" + self.session_id, { + "key": key, + "content-type": "text/plain", + "message": message + }) + pass + + + + + + +if __name__ == "__main__": + obj = StatusMsg(lfclient_host="192.168.200.15", lfclient_port=8080, session_id="Connection Test") + obj.update() + From ae059322d1c41fe959611469c7a3d4b4dc18a089 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Sun, 17 Jan 2021 22:20:59 -0800 Subject: [PATCH 021/848] setting up base profile --- py-json/realm.py | 105 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 34 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a7753052..b86ed26c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -817,6 +817,45 @@ class Realm(LFCliBase): def new_test_group_profile(self): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) +class BaseProfile(LFCliBase): + def __init__(self,local_realm): + self.parent_realm=local_realm + self.halt_on_error = False + self.exit_on_error = False + + def json_get(self, target): + return self.json_get(target) + + def json_post(self, url,data,debug_,suppress_related_commands_=None): + return self.json_post(url,data,debug_=False,suppress_related_commands_=suppress_related_commands_) + + def parse_time(self,target): + return self.parent_realm.parse_time(target) + + def stop_cx(self, target): + return self.parent_realm.stop_cx(target) + + def cleanup_cxe_prefix(self,prefix): + return self.parent_realm.cleanup_cxe_prefix(prefix) + + def rm_cx(self,target): + return self.parent_realm.rm_cx(target) + + def created_cx(self,target): + return self.parent_realm.created_cx(target) + + def name_to_eid(self,target): + return self.parent_realm.name_to_eid(target) + + def set_endp_tos(self,target): + return self.parent_realm.set_endp_tos(target) + + def wait_until_endps_appear(self,target,debug=False): + return self.parent_realm.wait_until_endps_appear(target,debug=False) + + def wait_until_cxs_appear(self,target,debug=False): + return self.parent_realm.wait_until_cxs_appear(target,debug=False) + class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): @@ -829,7 +868,7 @@ class MULTICASTProfile(LFCliBase): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) + super().__init__(local_realm) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm @@ -864,7 +903,6 @@ class MULTICASTProfile(LFCliBase): def stop_mc(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True - for endp_name in self.get_mc_names(): json_data = { "endp_name":endp_name @@ -874,9 +912,6 @@ class MULTICASTProfile(LFCliBase): pass - def cleanup_prefix(self): - self.local_realm.cleanup_cxe_prefix(self.name_prefix) - def cleanup(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True @@ -994,8 +1029,8 @@ class MULTICASTProfile(LFCliBase): -class L3CXProfile(LFCliBase): - def __init__(self, lfclient_host, lfclient_port, local_realm, +class L3CXProfile(BaseProfile): + def __init__(self, lfclient_host, lfclient_port,local_realm, side_a_min_bps=None, side_b_min_bps=None, side_a_max_bps=0, side_b_max_bps=0, side_a_min_pdu=-1, side_b_min_pdu=-1, @@ -1004,7 +1039,6 @@ class L3CXProfile(LFCliBase): """ :param lfclient_host: :param lfclient_port: - :param local_realm: :param side_a_min_bps: :param side_b_min_bps: :param side_a_max_bps: @@ -1017,7 +1051,7 @@ class L3CXProfile(LFCliBase): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) + super().__init__(local_realm) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm @@ -1045,7 +1079,7 @@ class L3CXProfile(LFCliBase): return self.data def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) + cx_list = self.json_get("endp?fields=name,rx+bytes") if self.debug: print(self.created_cx.values()) print("==============\n", cx_list, "\n==============") @@ -1079,13 +1113,13 @@ class L3CXProfile(LFCliBase): monitor_interval=1, col_names=None, created_cx=None, - show=False, + show=True, report_file=None, output_format=None, script_name=None, arguments=None): try: - duration_sec=local_realm.parse_time(duration_sec).seconds + duration_sec=self.parse_time(duration_sec).seconds except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") @@ -1108,17 +1142,20 @@ class L3CXProfile(LFCliBase): #Step 1, column names fields=",".join(col_names) + print(fields) #Step 2, monitor columns start_time = datetime.datetime.now() - iterations=duration_sec/monitor_interval + end_time = start_time + datetime.timedelta(seconds=duration_sec) + print(end_time) value_map = dict() passes = 0 expected_passes = 0 old_cx_rx_values = self.__get_rx_values() timestamps=[] - for x in range(0,int(round(iterations,0))): - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields), debug_=self.debug) + #for x in range(0,int(round(iterations,0))): + while datetime.datetime.now() < end_time: + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1141,10 +1178,10 @@ class L3CXProfile(LFCliBase): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - #print(value_map) + print(value_map) - if passes == expected_passes: - self._pass("PASS: All tests passed") + #if passes == expected_passes: + #self._pass("PASS: All tests passed") #step 3 organize data endpoints=list() for endpoint in value_map.values(): @@ -1160,6 +1197,7 @@ class L3CXProfile(LFCliBase): #step 4 save and close header_row=col_names header_row.insert(0,'Timestamp') + print(header_row) if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) @@ -1211,10 +1249,9 @@ class L3CXProfile(LFCliBase): else: pass - def refresh_cx(self): for cx_name in self.created_cx.keys(): - self.json_post("/cli-json/show_cxe", { + self.local_realm.json_post("/cli-json/show_cxe", { "test_mgr": "ALL", "cross_connect": cx_name }, debug_=self.debug) @@ -1225,7 +1262,7 @@ class L3CXProfile(LFCliBase): for cx_name in self.created_cx.keys(): if self.debug: print("cx-name: %s"%(cx_name)) - self.json_post("/cli-json/set_cx_state", { + self.local_realm.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", "cx_name": cx_name, "cx_state": "RUNNING" @@ -1236,7 +1273,7 @@ class L3CXProfile(LFCliBase): def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): - self.local_realm.stop_cx(cx_name) + self.stop_cx(cx_name) print(".", end='') print("") @@ -1249,13 +1286,13 @@ class L3CXProfile(LFCliBase): for cx_name in self.created_cx.keys(): if self.debug: print("Cleaning cx: %s"%(cx_name)) - self.local_realm.rm_cx(cx_name) + self.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): ename = self.created_cx[cx_name][side] if self.debug: print("Cleaning endpoint: %s"%(ename)) - self.local_realm.rm_endp(self.created_cx[cx_name][side]) + self.rm_endp(self.created_cx[cx_name][side]) def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): if self.debug: @@ -1275,12 +1312,12 @@ class L3CXProfile(LFCliBase): raise ValueError("side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") if type(side_a) == list and type(side_b) != list: - side_b_info = self.local_realm.name_to_eid(side_b) + side_b_info = self.name_to_eid(side_b) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] for port_name in side_a: - side_a_info = self.local_realm.name_to_eid(port_name) + side_a_info = self.name_to_eid(port_name) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] if port_name.find('.') < 0: @@ -1345,8 +1382,8 @@ class L3CXProfile(LFCliBase): self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) if tos != None: - self.local_realm.set_endp_tos(endp_a_name, tos) - self.local_realm.set_endp_tos(endp_b_name, tos) + self.set_endp_tos(endp_a_name, tos) + self.set_endp_tos(endp_b_name, tos) data = { "alias": cx_name, @@ -1363,14 +1400,14 @@ class L3CXProfile(LFCliBase): }) elif type(side_b) == list and type(side_a) != list: - side_a_info = self.local_realm.name_to_eid(side_a) + side_a_info = self.name_to_eid(side_a) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] #side_a_name = side_a_info[2] for port_name in side_b: print(side_b) - side_b_info = self.local_realm.name_to_eid(port_name) + side_b_info = self.name_to_eid(port_name) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] side_b_name = side_b_info[2] @@ -1421,7 +1458,7 @@ class L3CXProfile(LFCliBase): "flag": "autohelper", "val": 1 } - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) url = "cli-json/set_endp_flag" data = { @@ -1429,7 +1466,7 @@ class L3CXProfile(LFCliBase): "flag": "autohelper", "val": 1 } - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) #print("CXNAME451: %s" % cx_name) data = { "alias": cx_name, @@ -1446,14 +1483,14 @@ class L3CXProfile(LFCliBase): else: raise ValueError("side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (type(side_a), type(side_b))) - self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) + self.wait_until_endps_appear(these_endp, debug=debug_) for data in cx_post_data: url = "/cli-json/add_cx" self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) time.sleep(0.01) - self.local_realm.wait_until_cxs_appear(these_cx, debug=debug_) + self.wait_until_cxs_appear(these_cx, debug=debug_) def to_string(self): pprint.pprint(self) From 10cc23c433c3b1f502b84131f6356f56c373a071 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 18 Jan 2021 14:05:21 -0700 Subject: [PATCH 022/848] lf_cisco_dfs.py : cisco controller update lf_cisco_snp.py : comments updates --- py-scripts/lf_cisco_dfs.py | 2057 +++++++++++++++++++++++++++++++++--- py-scripts/lf_cisco_snp.py | 3 +- 2 files changed, 1924 insertions(+), 136 deletions(-) diff --git a/py-scripts/lf_cisco_dfs.py b/py-scripts/lf_cisco_dfs.py index 2d74a086..ac191d0f 100644 --- a/py-scripts/lf_cisco_dfs.py +++ b/py-scripts/lf_cisco_dfs.py @@ -11,42 +11,1260 @@ if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) import argparse +from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils +import realm import time -import test_l3_longevity as DFS +import datetime +import subprocess +import re +import csv +import random +import logging +# Check for the logs channel switching time and radar detected + + +FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s' + +# see https://stackoverflow.com/a/13306095/11014343 +class FileAdapter(object): + def __init__(self, logger): + self.logger = logger + def write(self, data): + # NOTE: data can be a partial line, multiple lines + data = data.strip() # ignore leading/trailing whitespace + if data: # non-blank + self.logger.info(data) + def flush(self): + pass # leave it to logging to flush properly + + +class hack_rf_(): + def __init__(self, args): + self.args = args + + def lf_hackrf_enable(self): + pass + + def lf_hackrf_disable(self): + pass + + + + + + +################################################################################ +# cisco controller class :This class will be left in this file to allow for the +# Scaling and Performance to be self contained and not impact other tests +################################################################################ +class cisco_(): + def __init__(self, args): + self.args = args + + #show summary (to get AP) (3400/9800) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action summary --series 9800 --log stdout + def controller_show_summary(self): + try: + self.args.cisco + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "summary"], + capture_output=self.args.cap_ctl_out, check=True) + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #show ap dot11 5ghz summary (band defaults to 5ghz) --band a + #show ap dot11 24ghz summary use --band b for 2.4 ghz + #action advanced (3400/9800) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action advanced --series 9800 --log stdout + def controller_show_ap_summary(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"advanced")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "advanced"], + capture_output=self.args.cap_ctl_out, check=True) + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + #show wlan summary + def controller_show_wlan_summary(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"show wlan summary")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "show_wlan_summary"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + #disable AP + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable --series 9800 + def controller_disable_ap(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #disable wlan + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_wlan --series 9800 + def controller_disable_wlan(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_wlan")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_wlan"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #disable network 5ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_network_5ghz --series 9800 + def controller_disable_network_5ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_5ghz")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_network_5ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11a disable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11a disable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #disable network 24ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_network_24ghz --series 9800 + def controller_disable_network_24ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_24ghz")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_network_24ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11b disable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11b disable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + + #set manual mode - Series 9800 must be set to manual mode + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action manual --series 9800 + # ap name dot11 5ghz radio role manual client-serving + def controller_role_manual(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"manual")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "manual"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + #set manual mode - Series 9800 must be set to auto mode + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action auto --series 9800 + # ap name dot11 5ghz radio role manual client-serving + def controller_role_auto(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"auto")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "auto"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + #test parameters summary (txPower 1-8) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action txPower --value 5 --series 9800 + def controller_set_tx_power(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"txPower", self.args.cisco_tx_power )) # TODO fix txPower to tx_power in cisco_wifi_ctl.py + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "txPower","--value", self.args.cisco_tx_power], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #set channel [36, 64, 100] + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action channel --value 36 --series 9800 + # 9800 : ap name dot11 [5ghz | 24ghz] channel + # 3504 : (Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 52 + def controller_set_channel(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"channel", self.args.cisco_channel )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "channel","--value", self.args.cisco_channel], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #set bandwidth [20 40 80 160] + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action bandwidth --value 40 --series 9800 + def controller_set_bandwidth(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"channel", self.args.cisco_chan_width )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "channel","--value", self.args.cisco_chan_width], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #create wlan + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action create_wlan --wlan "open-wlan" --wlanID 1 --series 9800 + def controller_create_wlan(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "create_wlan","--wlan", self.args.cisco_wlan, "--wlanID", self.args.cisco_wlanID], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + #create wireless tag policy --9800 series needs to have wireless tag policy set + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action wireless_tag_policy --series 9800 + def controller_set_wireless_tag_policy(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme {} ctlr {} user {} passwd {} AP {} series {} band {} action {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"wireless_tag_policy" )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "wireless_tag_policy"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + + #enable wlan + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_wlan --series 9800 + def controller_enable_wlan(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable_wlan")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable_wlan"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #enable 5ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_network_5ghz --series 9800 + def controller_enable_network_5ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable_network_5ghz")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable_network_5ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11a enable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11a enable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + + #enable 24ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_network_24ghz --series 9800 + def controller_enable_network_24ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable_network_24ghz")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable_network_24ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11b enable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11b enable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + + #enable (band a) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable --series 9800 + def controller_enable_ap(self): + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, + self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + #advanced (showes summary) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action advanced --series 9800 + def controller_show_ap_channel(self): + advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "ap_channel"], capture_output=True) + + pss = advanced.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + if self.args.cisco_series == "9800": + for line in pss.splitlines(): + search_str = self.args.cisco_ap + logg.info("line {}".format(line)) + element_list = line.lstrip().split() + logg.info("element_list {}".format(element_list)) + if (line.lstrip().startswith(search_str)): + logg.info("line {}".format(line)) + element_list = line.lstrip().split() + logg.info("element_list {}".format(element_list)) + # AP Name (0) mac (1) slot (2) Admin State [enable/disable] (3) Oper State [Up/Down] (4) Width (5) Txpwr (6,7) channel (8) mode (9) + logg.info("ap: {} slof {} channel {} chan_width {}".format(element_list[0],element_list[2],element_list[8],element_list[5])) + if (str(self.args.cisco_channel) in str(element_list[8])) and (str(self.args.cisco_chan_width) in str(element_list[5])): + logg.info("ap {} configuration successful: channel {} in expected {} chan_width {} in expected {}" + .format(element_list[0],self.args.cisco_channel,element_list[8],self.args.cisco_chan_width,element_list[5])) + else: + logg.info("WARNING ap {} configuration: channel {} in expected {} chan_width {} in expected {}" + .format(element_list[0],self.args.cisco_channel,element_list[8],self.args.cisco_chan_width,element_list[5])) + break + else: + logg.info("checking for 802.11{}".format(self.args.cisco_band)) + + for line in pss.splitlines(): + #logg.info("line {}".format(line)) + search_str = "802.11{}".format(self.args.cisco_band) + if (line.lstrip().startswith(search_str)): + logg.info("line {}".format(line)) + element_list = line.lstrip().split() + logg.info("element_list {}".format(element_list)) + logg.info("ap: {} channel {} chan_width {}".format(self.args.cisco_ap,element_list[4],element_list[5])) + if (str(self.args.cisco_channel) in str(element_list[4])) and (str(self.args.cisco_chan_width) in str(element_list[5])): + logg.info("ap configuration successful: channel {} in expected {} chan_width {} in expected {}" + .format(self.args.cisco_channel,element_list[4],self.args.cisco_chan_width,element_list[5])) + else: + logg.info("AP WARNING: channel {} expected {} chan_width {} expected {}" + .format(element_list[4],self.cisco_channel,element_list[5],self.args.cisco_chan_width)) + break + + logg.info("configure ap {} channel {} chan_width {}".format(self.args.cisco_ap,self.args.cisco_channel,self.args.cisco_chan_width)) + # Verify channel and channel width. +########################################## +# End of cisco controller class +########################################## + + +########################################## +# Traffic Generation +########################################## +class L3VariableTime(LFCliBase): + def __init__(self, host, port, endp_type, 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, results, + test_keys,test_config, + reset_port_enable_list, + reset_port_time_min_list, + reset_port_time_max_list, + csv_started=False, + side_a_min_bps=560000, side_a_max_bps=0, + side_a_min_pdu=1518,side_a_max_pdu=0, + side_b_min_bps=560000, side_b_max_bps=0, + side_b_min_pdu=1518,side_b_max_pdu=0, + number_template="00", test_duration="256s", + polling_interval="60s", + _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.tos = tos.split() + self.endp_type = endp_type + self.side_b = side_b + self.ssid_list = ssid_list + self.ssid_password_list = ssid_password_list + self.station_lists = station_lists + self.ssid_security_list = ssid_security_list + self.wifimode_list = wifimode_list + self.reset_port_enable_list = reset_port_enable_list + self.reset_port_time_min_list = reset_port_time_min_list + self.reset_port_time_max_list = reset_port_time_max_list + self.number_template = number_template + self.name_prefix = name_prefix + self.test_duration = test_duration + self.radio_name_list = radio_name_list + self.number_of_stations_per_radio_list = number_of_stations_per_radio_list + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) + 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.station_profiles = [] + self.args = args + self.outfile = outfile + self.results = results + self.csv_started = csv_started + self.epoch_time = int(time.time()) + self.debug = debug_on + self.test_keys = test_keys + self.test_config = test_config + + self.test_config_dict = dict(map(lambda x: x.split('=='), str(self.test_config).replace('[','').replace(']','').replace("'","").split())) + + + # Full spread-sheet data + if self.outfile is not None: + self.csv_file = open(self.outfile, "a+") + self.csv_writer = csv.writer(self.csv_file, delimiter=",") + + if self.results is not None: + self.csv_results = open(self.results, "a+") + self.csv_results_writer = csv.writer(self.csv_results, delimiter=",") + + for (radio_, ssid_, ssid_password_, ssid_security_, wifimode_,\ + reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \ + in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list, wifimode_list,\ + reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list): + self.station_profile = self.local_realm.new_station_profile() + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = ssid_ + self.station_profile.ssid_pass = ssid_password_ + self.station_profile.security = ssid_security_ + self.station_profile.mode = wifimode_ + self.station_profile.number_template = self.number_template + self.station_profile.mode = wifimode_ + self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,\ + test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ + reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ + reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) + self.station_profiles.append(self.station_profile) + + self.multicast_profile.host = self.host + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = side_a_min_bps + self.cx_profile.side_a_max_bps = side_a_min_bps + 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_bps + self.cx_profile.side_b_max_bps = side_b_min_bps + 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) + endp_rx_drop_map = {} + endp_rx_map = {} + our_endps = {} + for e in self.multicast_profile.get_mc_names(): + our_endps[e] = e + for e in self.cx_profile.created_endp.keys(): + 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(): + if item in our_endps: + for value_name, value_rx in value.items(): + if value_name == 'rx bytes': + endp_rx_map[item] = value_rx + for value_name, value_rx_drop in value.items(): + if value_name == 'rx drop %': + endp_rx_drop_map[item] = value_rx_drop + + return endp_rx_map, endp_rx_drop_map + + def time_stamp(self): + return time.strftime('%Y-%m-%d %H %M %S', time.localtime(self.epoch_time)) + + def __record_rx_dropped_percent(self,rx_drop_percent): + csv_rx_drop_percent_data = [] + print("test_keys {}".format(self.test_keys)) + print("self.test_config_dict {}".format(self.test_config_dict)) + for key in self.test_keys: + csv_rx_drop_percent_data.append(self.test_config_dict[key]) + + csv_rx_drop_percent_data.extend([self.epoch_time, self.time_stamp(),'rx_drop_percent']) + # remove multi cast since downstream only if selected + for key in [key for key in rx_drop_percent if "mtx" in key]: del rx_drop_percent[key] + + if "upstream" in self.test_config_dict.values(): + for key in [key for key in rx_drop_percent if "-A" in key]: del rx_drop_percent[key] + elif "downstream" in self.test_config_dict.values(): + for key in [key for key in rx_drop_percent if "-B" in key]: del rx_drop_percent[key] + + + filtered_values = [v for _, v in rx_drop_percent.items() if v !=0] + average_rx_drop_percent = sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 + + csv_performance_rx_drop_percent_values=sorted(rx_drop_percent.items(), key=lambda x: (x[1],x[0]), reverse=False) + csv_performance_rx_drop_percent_values=self.csv_validate_list(csv_performance_rx_drop_percent_values,5) + for i in range(5): + csv_rx_drop_percent_data.append(str(csv_performance_rx_drop_percent_values[i]).replace(',',';')) + for i in range(-1,-6,-1): + csv_rx_drop_percent_data.append(str(csv_performance_rx_drop_percent_values[i]).replace(',',';')) + + csv_rx_drop_percent_data.append(average_rx_drop_percent) + + for item, value in rx_drop_percent.items(): + #logg.info(item, "rx drop percent: ", rx_drop_percent[item]) + csv_rx_drop_percent_data.append(rx_drop_percent[item]) + + self.csv_add_row(csv_rx_drop_percent_data,self.csv_writer,self.csv_file) + self.csv_add_row(csv_rx_drop_percent_data,self.csv_results_writer,self.csv_results) + + def __compare_vals(self, old_list, new_list): + passes = 0 + expected_passes = 0 + csv_performance_values = [] + csv_rx_headers = [] + csv_rx_row_data = [] + csv_result_row_data = [] + csv_rx_delta_row_data = [] + csv_rx_delta_dict = {} + test_id = "" + + #for key in self.test_keys: + # csv_rx_row_data.append(self.test_config_dict[key]) + # csv_rx_delta_row_data.append(self.test_config_dict[key]) + + + for key in [key for key in old_list if "mtx" in key]: del old_list[key] + for key in [key for key in new_list if "mtx" in key]: del new_list[key] + + filtered_values = [v for _, v in new_list.items() if v !=0] + average_rx= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 + + # only evaluate upstream or downstream + new_evaluate_list = new_list.copy() + print("new_evaluate_list before",new_evaluate_list) + if "upstream" in self.test_config_dict.values(): + for key in [key for key in new_evaluate_list if "-A" in key]: del new_evaluate_list[key] + print("upstream in dictionary values") + elif "downstream" in self.test_config_dict.values(): + for key in [key for key in new_evaluate_list if "-B" in key]: del new_evaluate_list[key] + print("downstream in dictionary values") + #follow code left in for now, provides the best 5 worst 5 + '''print("new_evaluate_list after",new_evaluate_list) + csv_performance_values=sorted(new_evaluate_list.items(), key=lambda x: (x[1],x[0]), reverse=False) + csv_performance_values=self.csv_validate_list(csv_performance_values,5) + for i in range(5): + csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';')) + for i in range(-1,-6,-1): + csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';')) + + csv_rx_row_data.append(average_rx)''' + + old_evaluate_list = old_list.copy() + if "upstream" in self.test_config_dict.values(): + for key in [key for key in old_evaluate_list if "-A" in key]: del old_evaluate_list[key] + print("upstream in dictionary values") + elif "downstream" in self.test_config_dict.values(): + for key in [key for key in old_evaluate_list if "-B" in key]: del old_evaluate_list[key] + print("downstream in dictionary values") + + if len(old_evaluate_list) == len(new_evaluate_list): + for item, value in old_evaluate_list.items(): + expected_passes +=1 + print("ITEM: {} VALUE: {}".format(item, value)) + if new_evaluate_list[item] > old_evaluate_list[item]: + passes += 1 + #if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + print(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + else: + print("Failed to increase rx data: ", item, new_evaluate_list[item], old_evaluate_list[item]) + if not self.csv_started: + csv_rx_headers.append(item) + csv_rx_delta_dict.update({item:(new_evaluate_list[item] - old_evaluate_list[item])}) + + + if not self.csv_started: + csv_header = self.csv_generate_column_headers() + csv_header += csv_rx_headers + logg.info(csv_header) + self.csv_add_column_headers(csv_header) + csv_results = self.csv_generate_column_results_headers() + #csv_results += csv_rx_headers + self.csv_add_column_headers_results(csv_results) + print("###################################") + print(csv_results) + print("###################################") + + self.csv_started = True + + # need to generate list first to determine worst and best + filtered_values = [v for _, v in csv_rx_delta_dict.items() if v !=0] + #average_rx_delta= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 + for key in self.test_keys: + csv_rx_row_data.append(self.test_config_dict[key]) + csv_result_row_data.append(self.test_config_dict[key]) + csv_rx_delta_row_data.append(self.test_config_dict[key]) + + max_tp_mbps = sum(filtered_values) + csv_rx_row_data.append(max_tp_mbps) + csv_result_row_data.append(max_tp_mbps) + + #To do needs to be read or passed in based on test type + expected_tp_mbps = max_tp_mbps + csv_rx_row_data.append(expected_tp_mbps) + csv_result_row_data.append(expected_tp_mbps) + + + #Generate TestID + for key in self.test_keys: + test_id = test_id + "_" + self.test_config_dict[key] + + print("test_id: {}".format(test_id)) + csv_rx_row_data.append(test_id) + csv_result_row_data.append(test_id) + + # Todo pass or fail + if max_tp_mbps == expected_tp_mbps: + csv_rx_row_data.append("pass") + csv_result_row_data.append("pass") + else: + csv_rx_row_data.append("fail") + csv_result_row_data.append("fail") + + csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta']) + csv_result_row_data.extend([self.epoch_time, self.time_stamp()]) + + print("csv_rx_row_data {}".format(csv_rx_row_data)) + #TODO: may want to pass in the information that needs to be in the csv file into the class + ''' + csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx']) + csv_rx_delta_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta']) + + csv_performance_delta_values=sorted(csv_rx_delta_dict.items(), key=lambda x: (x[1],x[0]), reverse=False) + csv_performance_delta_values=self.csv_validate_list(csv_performance_delta_values,5) + for i in range(5): + csv_rx_delta_row_data.append(str(csv_performance_delta_values[i]).replace(',',';')) + for i in range(-1,-6,-1): + csv_rx_delta_row_data.append(str(csv_performance_delta_values[i]).replace(',',';')) + + csv_rx_delta_row_data.append(average_rx_delta)''' + + for item, value in old_evaluate_list.items(): + expected_passes +=1 + if new_evaluate_list[item] > old_evaluate_list[item]: + passes += 1 + #if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + print(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + else: + print("Failed to increase rx data: ", item, new_evaluate_list[item], old_evaluate_list[item]) + if not self.csv_started: + csv_rx_headers.append(item) + # note need to have all upstream and downstream in the csv table thus new_list and old_list + #csv_rx_row_data.append(new_list[item]) + # provide delta + csv_rx_row_data.append(new_list[item] - old_list[item]) + + self.csv_add_row(csv_rx_row_data,self.csv_writer,self.csv_file) + #self.csv_add_row(csv_rx_row_data,self.csv_results_writer,self.csv_results) + + #self.csv_add_row(csv_rx_delta_row_data,self.csv_writer,self.csv_file) + + if passes == expected_passes: + return True, max_tp_mbps, csv_result_row_data + else: + return False, max_tp_mbps, csv_result_row_data + else: + print("Old-list length: %i new: %i does not match in compare-vals."%(len(old_list), len(new_list))) + print("old-list:",old_list) + print("new-list:",new_list) + return False, None, None # check to see if this is valid + + def verify_controller(self): + if self.args == None: + return + + if self.args.cisco_ctlr == None: + return + + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series,"--action", "summary"], capture_output=True) + pss = ctl_output.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)) + time.sleep(1) + exit(1) + + + # Find our station count + searchap = False + for line in pss.splitlines(): + if (line.startswith("---------")): + searchap = True + continue + #TODO need to test with 9800 series to chelck the values + if (searchap): + pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+.* \S+\s+\S+\s+(\S+)\s+\["%(self.args.cisco_ap) + #logg.info("AP line: %s"%(line)) + m = re.search(pat, line) + if (m != None): + sta_count = m.group(1) + logg.info("AP line: %s"%(line)) + logg.info("sta-count: %s"%(sta_count)) + if (int(sta_count) != int(self.total_stas)): + logg.info("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas)) + + def reset_port_check(self): + for station_profile in self.station_profiles: + if station_profile.reset_port_extra_data['reset_port_enable']: + if station_profile.reset_port_extra_data['reset_port_timer_started'] == False: + logg.info("reset_port_time_min: {}".format(station_profile.reset_port_extra_data['reset_port_time_min'])) + logg.info("reset_port_time_max: {}".format(station_profile.reset_port_extra_data['reset_port_time_max'])) + station_profile.reset_port_extra_data['seconds_till_reset'] = \ + random.randint(station_profile.reset_port_extra_data['reset_port_time_min'],\ + station_profile.reset_port_extra_data['reset_port_time_max']) + station_profile.reset_port_extra_data['reset_port_timer_started'] = True + logg.info("on radio {} seconds_till_reset {}".format(station_profile.add_sta_data['radio'],station_profile.reset_port_extra_data['seconds_till_reset'])) + else: + station_profile.reset_port_extra_data['seconds_till_reset'] = station_profile.reset_port_extra_data['seconds_till_reset'] - 1 + if self.debug: logg.info("radio: {} countdown seconds_till_reset {}".format(station_profile.add_sta_data['radio'] ,station_profile.reset_port_extra_data['seconds_till_reset'])) + if ((station_profile.reset_port_extra_data['seconds_till_reset'] <= 0)): + station_profile.reset_port_extra_data['reset_port_timer_started'] = False + port_to_reset = random.randint(0,len(station_profile.station_names)-1) + logg.info("reset on radio {} station: {}".format(station_profile.add_sta_data['radio'],station_profile.station_names[port_to_reset])) + self.local_realm.reset_port(station_profile.station_names[port_to_reset]) + + def pre_cleanup(self): + self.cx_profile.cleanup_prefix() + self.multicast_profile.cleanup_prefix() + self.total_stas = 0 + for station_list in self.station_lists: + for sta in station_list: + self.local_realm.rm_port(sta, check_exists=True) + self.total_stas += 1 + + # Make sure they are gone + count = 0 + while (count < 10): + more = False + for station_list in self.station_lists: + for sta in station_list: + rv = self.local_realm.rm_port(sta, check_exists=True) + if (rv): + more = True + if not more: + break + count += 1 + time.sleep(5) + + def build(self): + index = 0 + for station_profile in self.station_profiles: + station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) + station_profile.set_number_template(station_profile.number_template) + logg.info("Creating stations") + + station_profile.create(radio=self.radio_name_list[index], sta_names_=self.station_lists[index], debug=self.debug, sleep_time=0) + index += 1 + + # 12/4/2020 put back in multi cast + #for etype in self.endp_types: + # if etype == "mc_udp" or etype == "mc_udp6": + # logg.info("Creating Multicast connections for endpoint type: %s"%(etype)) + # self.multicast_profile.create_mc_tx(etype, self.side_b, etype) + # self.multicast_profile.create_mc_rx(etype, side_rx=station_profile.station_names) + + for _tos in self.tos: + logg.info("Creating connections for endpoint type: {} TOS: {} stations_names {}".format(self.endp_type, _tos, station_profile.station_names)) + self.cx_profile.create(endp_type=self.endp_type, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0, tos=_tos) + self._pass("PASS: Stations build finished") + + def start(self, print_pass=False, print_fail=False): + best_max_tp_mbps = 0 + best_csv_rx_row_data = " " + max_tp_mbps = 0 + csv_rx_row_data = " " + Result = False + logg.info("Bringing up stations") + self.local_realm.admin_up(self.side_b) + for station_profile in self.station_profiles: + for sta in station_profile.station_names: + logg.info("Bringing up station %s"%(sta)) + self.local_realm.admin_up(sta) + + temp_stations_list = [] + temp_stations_list.append(self.side_b) + 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=120, debug=self.debug): + logg.info("ip's acquired") + else: + logg.info("print failed to get IP's") + exit(1) # why continue + time.sleep(30) + self.verify_controller() + # Multi cast may not be needed for scaling and performance + logg.info("Starting multicast traffic (if any configured)") + self.multicast_profile.start_mc(debug_=self.debug) + self.multicast_profile.refresh_mc(debug_=self.debug) + logg.info("Starting layer-3 traffic (if any configured)") + self.cx_profile.start_cx() + self.cx_profile.refresh_cx() + + cur_time = datetime.datetime.now() + logg.info("Getting initial values.") + old_rx_values, rx_drop_percent = self.__get_rx_values() + + end_time = self.local_realm.parse_time(self.test_duration) + cur_time + + logg.info("Monitoring throughput for duration: %s"%(self.test_duration)) + + passes = 0 + expected_passes = 0 + logg.info("polling_interval_seconds {}".format(self.polling_interval_seconds)) + + while cur_time < end_time: + interval_time = cur_time + datetime.timedelta(seconds=self.polling_interval_seconds) + while cur_time < interval_time: + cur_time = datetime.datetime.now() + self.reset_port_check() + time.sleep(1) + + self.epoch_time = int(time.time()) + new_rx_values, rx_drop_percent = self.__get_rx_values() + + expected_passes += 1 + ''' + #self.csv_add_row(csv_rx_row_data,self.csv_results_writer,self.csv_results) + + + if passes == expected_passes: + return True, max_tp_mbps, csv_rx_row_data + else: + return False, max_tp_mbps, csv_rx_row_data + ''' + # __compare_vals - does the calculations + Result, max_tp_mbps, csv_rx_row_data = self.__compare_vals(old_rx_values, new_rx_values) + if max_tp_mbps > best_max_tp_mbps: + best_max_tp_mbps = max_tp_mbps + best_csv_rx_row_data = csv_rx_row_data + + # need to check the expected max_tp_mbps + if Result: + passes += 1 + else: + self._fail("FAIL: Not all stations increased traffic", print_fail) + old_rx_values = new_rx_values + + #percentage dropped not needed for scaling and performance , needed for longevity + #self.__record_rx_dropped_percent(rx_drop_percent) + + cur_time = datetime.datetime.now() + self.csv_add_row(best_csv_rx_row_data,self.csv_results_writer,self.csv_results) + if passes == expected_passes: + self._pass("PASS: All tests passed", print_pass) + + def stop(self): + self.cx_profile.stop_cx() + self.multicast_profile.stop_mc() + for station_list in self.station_lists: + for station_name in station_list: + self.local_realm.admin_down(station_name) + + def cleanup(self): + self.cx_profile.cleanup() + self.multicast_profile.cleanup() + for station_profile in self.station_profiles: + station_profile.cleanup() + + + def csv_generate_column_headers(self): + csv_rx_headers = self.test_keys.copy() + csv_rx_headers.extend + csv_rx_headers.extend(['max_tp_mbps','expected_tp','test_id','pass_fail','epoch_time','time','monitor']) + '''for i in range(1,6): + csv_rx_headers.append("least_rx_data {}".format(i)) + for i in range(1,6): + csv_rx_headers.append("most_rx_data_{}".format(i)) + csv_rx_headers.append("average_rx_data")''' + return csv_rx_headers + + def csv_generate_column_results_headers(self): + csv_rx_headers = self.test_keys.copy() + csv_rx_headers.extend + csv_rx_headers.extend(['max_tp_mbps','expected_tp','test_id','pass_fail','epoch_time','time']) + '''for i in range(1,6): + csv_rx_headers.append("least_rx_data {}".format(i)) + for i in range(1,6): + csv_rx_headers.append("most_rx_data_{}".format(i)) + csv_rx_headers.append("average_rx_data")''' + return csv_rx_headers + + + def csv_add_column_headers(self,headers): + if self.csv_file is not None: + self.csv_writer.writerow(headers) + self.csv_file.flush() + + def csv_add_column_headers_results(self,headers): + if self.csv_results is not None: + self.csv_results_writer.writerow(headers) + self.csv_results.flush() + + def csv_validate_list(self, csv_list, length): + if len(csv_list) < length: + csv_list = csv_list + [('no data','no data')] * (length - len(csv_list)) + return csv_list + + def csv_add_row(self,row,writer,csv_file): # can make two calls eventually + if csv_file is not None: + writer.writerow(row) + csv_file.flush() def valid_endp_types(_endp_type): etypes = _endp_type.split() for endp_type in etypes: valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] if not (str(endp_type) in valid_endp_type): - print('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) + logg.info('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) exit(1) return _endp_type +########################################## +# Traffic Generation +########################################## + + def main(): + global logg lfjson_host = "localhost" lfjson_port = 8080 endp_types = "lf_udp" debug_on = False parser = argparse.ArgumentParser( - prog='lf_cisco_dfs.py', + prog='lf_cisco_snp.py', #formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ - Useful Information: - 1. Polling interval for checking traffic is fixed at 1 minute - 2. The test will generate csv file - 3. The tx/rx rates are fixed at 256000 bits per second - 4. Maximum stations per radio is 64 + Scaling and Performance ''', description='''\ lf_cisco_dfs.py: -------------------- +################################################################################## +Task Description: +################################################################################## +----------------- + +DFS Testing can do multiple clients at once and various radios + +Our ultimate aim is to achieve the following things: + +1. 1 to 200 client SNP on 11ac (1, 50 and 200 client count tests) + 1. 5 Ghz with different channel widths + 2. Data encryption enabled/disabled + 3. Local/central switching and authentication combinations +2. 1 to 37 client SNP on 11ax (1, 10 and 37 client count tests) eventually 200 clients + 1. Different channel widths + 2. Data encryption enabled/disabled + 3. Local/central switching and authentication combinations + 4. MU-MIMO and OFDMA enabled/disabled combination +3. CI/CD implementation + 1. Download latest WLC images and upload them to the controller + 2. Start the test suite + 3. Generate a report per release + 4. Display and graph all result data according to each release along with each testcase historical graph + 5. Review overall AP performance across multiple AP platforms + + Summary : ---------- create stations, create traffic between upstream port and stations, run traffic. @@ -55,17 +1273,21 @@ and recieved. Generic command layout: ----------------------- -python .\\lf_cisco_dfs.py --test_duration --endp_type --upstream_port - --radio "radio== stations== ssid== ssid_pw== security==" --debug +python .\\lf_cisco_snp.py --test_duration --endp_type --upstream_port + --radio "radio== stations== ssid== ssid_pw== security== wifimode==AUTO" --debug + Multiple radios may be entered with individual --radio switches -generiic command with controller setting channel and channel width test duration 5 min -python3 lf_cisco_dfs.py --cisco_ctlr --cisco_dfs True/False --mgr +generiic command with controller setting channel and channel width test duration 30 sec +python3 lf_cisco_snp.py --cisco_ctlr --cisco_dfs True/False --mgr --cisco_channel --cisco_chan_width <20,40,80,120> --endp_type 'lf_udp lf_tcp mc_udp' --upstream_port <1.ethX> - --radio "radio== stations== ssid== ssid_pw== security==" - --radio "radio== stations== ssid== ssid_pw== security==" + --radio "radio== stations== ssid== ssid_pw== security== wifimode==" + --radio "radio== stations== ssid== ssid_pw== security== wifimode==" --duration 5m +wifimode: + : number followed by one of the following d - days @@ -105,7 +1327,7 @@ BK, BE, VI, VO: Optional wifi related Tos Settings. Or, use your preferred num -t / --endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', default='lf_udp', type=valid_endp_types -u / --upstream_port example: --upstream_port eth1',default='eth1') --o / --outfile ", default='longevity_results' +-o / --outfile ", default='snp' ######################################### # Examples @@ -119,7 +1341,7 @@ Example #1 running traffic with two radios 6. Create connections with TOS of BK and VI Command: (remove carriage returns) -python3 .\\lf_cisco_dfs.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --tos \"BK VI\" --upstream_port eth1 +python3 .\\lf_cisco_snp.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --tos \"BK VI\" --upstream_port eth1 --radio "radio==wiphy0 stations==32 ssid==candelaTech-wpa2-x2048-4-1 ssid_pw==candelaTech-wpa2-x2048-4-1 security==wpa2" --radio "radio==wiphy1 stations==64 ssid==candelaTech-wpa2-x2048-5-3 ssid_pw==candelaTech-wpa2-x2048-5-3 security==wpa2" @@ -136,60 +1358,200 @@ Example #2 using cisco controller 10. duration 5m Command: -python3 lf_cisco_dfs.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192.168.100.178 +python3 lf_cisco_snp.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192.168.100.178 --cisco_channel 52 --cisco_chan_width 20 --endp_type 'lf_udp lf_tcp mc_udp' --upstream_port 1.eth3 --radio "radio==1.wiphy0 stations==3 ssid==test_candela ssid_pw==[BLANK] security==open" --radio "radio==1.wiphy1 stations==16 ssid==test_candela ssid_pw==[BLANK] security==open" --test_duration 5m +############################################################################## +Detailed test loop description 10/9/2020 - Karthik Recommendation +############################################################################## +Script logic loops: + +AP {Axel, Vanc} Dynamic + frequency {24ghz, 5ghz} Common (band) : 24ghz == b , 5ghz == a + wifimode{11ax (2.4 ghz or 5 ghz), 11ac (5 ghz only), 11n (2.4 ghz or 5ghz), 11bg(2.4 ghz)} Common (an anAX anAC abgn bg) + Bandwidth {20, 40, 80, 160} + data-encryption {enable/disable} Common + AP-mode {local/flexconnect} Common + client-density {1, 10, 20, 50, 100, 200} Dynamic + Packet-type {TCP, UDP} Common + Direction {Downstream, Upstream} + Packet-size { 88, 512, 1370, 1518} Common + Time (4 iterations of 30 sec and get the best average TP out of it) + +Notes: +############################################# +CandelaTech Radios and what supports +############################################# + +Radio descriptions: +ax200: so if AP is /n, then ax200 will connect at /n. But if AP is /AX, we have no way to force ax200 to act like /n +ax200: is dual band, supporting at least /b/g/n/AX on 2.4Ghz, and /a/n/ac/AX on 5Ghz. 2.4Ghz doesn't officially support /AC, but often chips will do /AC there anyway + +ath10K: if they want /AC or /n or /abg stations, then our ath10k radios can support that need (and ath9k if they have any, can do /n and /abg) +ath10K(998x) - wave -1 , dual band card it can be ac, n , a/b/g modes, up to 3x3 spacial streams +ath10K(9884) - wave-2 supports 4x4 802.11an-AC 5ghz (can act as ac , an) + +Note: wave-2 radios can act as ac, an, (802.11an-AC) or legacy a/b/g (802.11bgn-AC) + +############################################# +wifimodes needed to support +############################################# +11ax (2.4 ghz or 5 ghz), 11ac (5 ghz only), 11n (2.4ghz or 5 ghz), 11bg (2.4 ghz) (Cisco) + +############################################# +5 Ghz +############################################# +Wifi mode: 11ax - 5ghz +Radios : ax200 : 802.11 /a/n/ac/AX + +Wifi mode: 11ac - 5ghz +Radios : ath10K(9984) 802.11an-AC (9984 are single band) + +Wifi mode: 11n - 5ghz +Radios : ath10K(9984) 802.11an-AC (9984 are single band) + +############################################# +24 Ghz +############################################# +Wifi mode: 11ax - 24ghz +Radios : ax200 - 802.11 /b/g/n/AX + +Wifi mode: 11ac - 24ghz +Radios : ax200 802.11 /b/g/n/AX (2.4Ghz doesn't officially support /AC, but often chips will do /AC there anyway) (invalid) + +Wifi mode: 11n - 24ghz +Radios : ax200 802.11 /b/g/n/AX + +Wifi mode: 11bg - 24ghz +Radios : ax200 802.11 /b/g/n/AX + +############################################ +Radio support for specific Modes +############################################ +cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg": + radios = radio_AX200_abgn_ax_dict[cisco_client_density] + +cisco_wifimode == "an" or cisco_wifimode == "anAC": + radios = radio_ath10K_9984_an_AC_dict[cisco_client_density] + + +############################################ +Eventual Realm at Cisco +############################################ + +1.wiphy0 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy1 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy2 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy3 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy4 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy5 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy6 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy7 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy8 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz +1.wiphy9 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz + +2.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +2.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +3.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +3.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +4.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +4.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +5.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +5.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +6.wiphy0 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy1 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy2 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy3 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy4 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy5 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy6 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy7 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy8 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz +6.wiphy9 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz ''') + # reorder to follow looping - parser.add_argument('--cisco_ctlr', help='--cisco_ctlr ',default=None) - parser.add_argument('--cisco_user', help='--cisco_user ',default="admin") - parser.add_argument('--cisco_passwd', help='--cisco_passwd ',default="Cisco123") - parser.add_argument('--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") - parser.add_argument('--cisco_ap', help='--cisco_ap ',default="APA453.0E7B.CF9C") - - parser.add_argument('--cisco_dfs', help='--cisco_dfs ',default=False) + parser.add_argument('-ca','--cisco_all', help='--cisco_all flag present default to all tests',action="store_true") + parser.add_argument('-ct','--cisco_test', help='--cisco_test flag present default to subset tests',action="store_true") + parser.add_argument('-cca','--cisco_ap', help='--cisco_ap List of APs to test default: Axel',default="APA453.0E7B.CF9C") + parser.add_argument('-ccf','--cisco_band', help='--cisco_band ',default="a b") + # cisco wanted 11ax , 11ac, 11n, 11gb + parser.add_argument('-cwm','--cisco_wifimode', help='List of of wifi mode to test default: 11ax 11ac 11n 11gb',default="an anAX anAC abgn bg", + choices=[ "auto", "a", "b", "g", "abg", "abgn", "bgn", "bg", "abgnAC", "anAC", "an", "bgnAC", "abgnAX", "bgnAX", "anAX"]) - parser.add_argument('--cisco_channel', help='--cisco_channel ',default=None) - parser.add_argument('--cisco_chan_width', help='--cisco_chan_width <20 40 80 160>',default="20",choices=["20","40","80","160"]) - parser.add_argument('--cisco_band', help='--cisco_band ',default="a",choices=["a", "b", "abgn"]) - parser.add_argument('--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) - parser.add_argument('--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"]) + parser.add_argument('-ccc','--cisco_channel', help='--cisco_channel default 36',default="36") + parser.add_argument('-ccw','--cisco_chan_width', help='--cisco_chan_width <20 40 80 160> default: \"20 40 80 160\"',default="20 40 80") + parser.add_argument('-cam','--cisco_ap_mode', help='--cisco_ap_mode ',default="local flexconnect") + parser.add_argument('-cps','--cisco_packet_size', help='--cisco_packet_size List of packet sizes default \"88 512 1370 1518\"',default="88 512 1370 1518" ) + parser.add_argument('-ccd','--cisco_client_density', help='--cisco_client_density List of client densities defaults 1 10 20 50 100 200 ', + default="1 10 20 50 100 200" ) - parser.add_argument('--cisco_wlan', help='--cisco_wlan default: NA, NA means no change',default="NA") - parser.add_argument('--cisco_wlanID', help='--cisco_wlanID default: NA , NA means not change',default="NA") - parser.add_argument('--cisco_tx_power', help='--cisco_tx_power <1 | 2 | 3 | 4 | 5 | 6 | 7 | 8> 1 is highest power default NA NA means no change',default="NA" + parser.add_argument('-cde','--cisco_data_encryption', help='--cisco_data_encryption \"enable disable\"',default="disable" ) + parser.add_argument('-cs','--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) + parser.add_argument('-ccp','--prompt', type=str,help="controller prompt default WLC",default="WLC") + + parser.add_argument('-cc','--cisco_ctlr', help='--cisco_ctlr default 192.168.100.178',default="192.168.100.178") + parser.add_argument('-cp','--cisco_port', help='--cisco_port ssh default 22',default="22") + parser.add_argument('-cu','--cisco_user', help='--cisco_user ',default="admin") + parser.add_argument('-cpw','--cisco_passwd', help='--cisco_passwd ',default="Cisco123") + parser.add_argument('-ccp','--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") + parser.add_argument('-cd','--cisco_dfs', help='--cisco_dfs ',default=False) + parser.add_argument('-ccs','--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"]) + parser.add_argument('-cw','--cisco_wlan', help='--cisco_wlan default: NA, NA means no change',default="NA") + parser.add_argument('-cwi','--cisco_wlanID', help='--cisco_wlanID default: NA , NA means not change',default="NA") + parser.add_argument('-ctp','--cisco_tx_power', help='--cisco_tx_power <1 | 2 | 3 | 4 | 5 | 6 | 7 | 8> 1 is highest power default NA NA means no change',default="NA" ,choices=["1","2","3","4","5","6","7","8","NA"]) + parser.add_argument('-cco','--cap_ctl_out', help='--cap_ctl_out , switch the cisco controller output will be captured', action='store_true') + + parser.add_argument('-apr','--amount_ports_to_reset', help='--amount_ports_to_reset \" \" ', default=None) + parser.add_argument('-prs','--port_reset_seconds', help='--ports_reset_seconds \" \" ', default="10 30") - - parser.add_argument('--amount_ports_to_reset', help='--amount_ports_to_reset \" \" ', default=None) - parser.add_argument('--port_reset_seconds', help='--ports_reset_seconds \" \" ', default="10 30") - - parser.add_argument('--mgr', help='--mgr ',default='localhost') - parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') + parser.add_argument('-lm','--mgr', help='--mgr ',default='localhost') + parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 2m options: number followed by d, h, m or s',default='2m') parser.add_argument('--tos', help='--tos: Support different ToS settings: BK | BE | VI | VO | numeric',default="BE") - parser.add_argument('--debug', help='--debug: Enable debugging',default=False) - parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', - default='lf_udp', type=valid_endp_types) + parser.add_argument('-db','--debug', help='--debug: Enable debugging',action='store_true') + parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp lf_tcp, options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', + default='lf_udp lf_tcp', type=valid_endp_types) parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') - parser.add_argument('-o','--csv_outfile', help="--csv_outfile ", default='longevity_results') - parser.add_argument('--polling_interval', help="--polling_interval ", default='60s') + parser.add_argument('-o','--csv_outfile', help="--csv_outfile ", default='snp') + parser.add_argument("-l", "--log", action='store_true', help="create logfile for messages, default stdout") + parser.add_argument('-pi','--polling_interval', help="--polling_interval ", default='10s') #parser.add_argument('-c','--csv_output', help="Generate csv output", default=False) + parser.add_argument('-c','--csv_output', help="Generate csv output", default=True) + #to do add wifimode parser.add_argument('-r','--radio', action='append', nargs=1, help='--radio \ - \"radio== ssid== ssid_pw== security==\" '\ - , required=True) - parser.add_argument("--cap_ctl_out", help="--cap_ctl_out , switch the cisco controller output will be captured", action='store_true') + \"radio== ssid== ssid_pw== security== wifimode==\" '\ + , required=False) + parser.add_argument('-amr','--side_a_min_bps', help='--side_a_min_bps, station min tx bits per second default 256000', default=256000) + parser.add_argument('-amp','--side_a_min_pdu', help='--side_a_min_pdu , station ipdu size default 1518', default=1518) + parser.add_argument('-bmr','--side_b_min_bps', help='--side_b_min_bps , upstream min tx rate default 256000', default=256000) + parser.add_argument('-bmp','--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') + parser.add_argument('-nos','--no_stations', help='--no_stations , no stations', action='store_true') args = parser.parse_args() - #print("args: {}".format(args)) + cisco_args = args + + #logg.info("args: {}".format(args)) debug_on = args.debug + + ################################################################## + # Gather Test Data + ################################################################# if args.test_duration: test_duration = args.test_duration @@ -212,116 +1574,541 @@ python3 lf_cisco_dfs.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192. if args.csv_outfile != None: current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time) + csv_results = "results_{}_{}.csv".format(args.csv_outfile,current_time) print("csv output file : {}".format(csv_outfile)) - + + 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)) - MAX_NUMBER_OF_STATIONS = 64 + console_handler = logging.StreamHandler() + formatter = logging.Formatter(FORMAT) + logg = logging.getLogger(__name__) + logg.setLevel(logging.DEBUG) + file_handler = None + if (args.log): + file_handler = logging.FileHandler(outfile_log, "w") + + 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 + # if loggin.basicConfig is called this will result in duplicating log entries + # logging.basicConfig(format=FORMAT, handlers=[file_handler]) + else: + # stdout logging + 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} + + + #################################################### + # + # Static Configuration Cisco Realm + # + #################################################### + radio_AX200_abgn_ax_list_001 = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_AX200_abgn_ax_list_010 = [['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==2.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + + radio_AX200_abgn_ax_list_020 = [['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==2.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ] + + radio_AX200_abgn_ax_list_024 = [['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==2.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ] + + + radio_AX200_abgn_ax_dict = {'1' : radio_AX200_abgn_ax_list_001, + '10' : radio_AX200_abgn_ax_list_010, + '24' : radio_AX200_abgn_ax_list_024} + + + radio_ath10K_9984_an_AC_list_001 = [['radio==1.wiphy8 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_010 = [['radio==1.wiphy8 stations==10 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_020 = [['radio==1.wiphy8 stations==20 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_050 = [['radio==1.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_100 = [['radio==1.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy9 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_200 = [['radio==1.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy9 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy9 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_ath10K_9984_an_AC_dict = {'1' : radio_ath10K_9984_an_AC_list_001, + '50' : radio_ath10K_9984_an_AC_list_050, + '200': radio_ath10K_9984_an_AC_list_200} + + #################################################### + # + # Static dictionaries for radios on 191.168.100.178 + # Static Configuration Candela Tech Realm () + # + #################################################### + #iwlwifi(AX200) 521 + radio_AX200_abgn_ax_list_001 = [['radio==1.wiphy3 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_AX200_abgn_ax_list_004 = [['radio==1.wiphy3 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy4 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy5 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_AX200_abgn_ax_dict_test = {'1' : radio_AX200_abgn_ax_list_001, + '4': radio_AX200_abgn_ax_list_004} + + radio_ath10K_9984_an_AC_list_001 = [['radio==1.wiphy1 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_010 = [['radio==1.wiphy1 stations==10 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_020 = [['radio==1.wiphy1 stations==20 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_050 = [['radio==1.wiphy1 stations==50 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath9K_9984_an_AC_list_200 = [['radio==1.wiphy0 stations==200 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_ath10K_9984_an_AC_dict_test = {'1' : radio_ath10K_9984_an_AC_list_001, + '10' : radio_ath10K_9984_an_AC_list_010, + '50' : radio_ath10K_9984_an_AC_list_050, + '200' : radio_ath9K_9984_an_AC_list_200} + + MAX_NUMBER_OF_STATIONS = 200 radio_name_list = [] number_of_stations_per_radio_list = [] ssid_list = [] ssid_password_list = [] ssid_security_list = [] + wifimode_list = [] #optional radio configuration reset_port_enable_list = [] reset_port_time_min_list = [] reset_port_time_max_list = [] - print("radios {}".format(radios)) - for radio_ in radios: - radio_keys = ['radio','stations','ssid','ssid_pw','security'] - radio_info_dict = dict(map(lambda x: x.split('=='), str(radio_).replace('[','').replace(']','').replace("'","").split())) - print("radio_dict {}".format(radio_info_dict)) + wifi_mode_dict = { + "auto" : "0", + "a" : "1", + "b" : "2", + "g" : "3", + "abg" : "4", + "abgn" : "5", + "bgn" : "6", + "bg" : "7", + "abgnAC" : "8", + "anAC" : "9", + "an" : "10", + "bgnAC" : "11", + "abgnAX" : "12", + "bgnAX" : "13", + "anAX" : "14" + } - for key in radio_keys: - if key not in radio_info_dict: - print("missing config, for the {}, all of the following need to be present {} ".format(key,radio_keys)) + if args.cisco_all: + cisco_aps = "APA453.0E7B.CF9C".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".split() + cisco_data_encryptions = "disable".split() + cisco_packet_types = "lf_udp lf_tcp".split() + cisco_directions = "upstream downstream".split() + cisco_packet_sizes = "1518".split() + cisco_client_densities = "1".split() + cisco_data_encryptions = "disable".split() + + cisco_side_a_min_bps = 500000000 + cisco_side_b_min_bps = 500000000 + + 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: + # Note the local system only supports 802.11-abgn , 802.11a + cisco_aps = "APA453.0E7B.CF9C".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".split() + cisco_data_encryptions = "disable".split() + #cisco_packet_types = "lf_udp lf_tcp".split() + cisco_packet_types = "lf_udp".split() + #cisco_directions = "upstream downstream".split() + cisco_directions = "upstream downstream".split() + #cisco_packet_sizes = "88 512 1370 1518".split() + cisco_packet_sizes = "1518".split() + cisco_client_densities = "10".split() + cisco_data_encryptions = "disable".split() + + cisco_side_a_min_bps = 500000000 + cisco_side_b_min_bps = 500000000 + + radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_test + radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_test + + else: + cisco_aps = args.cisco_ap.split() + cisco_bands = args.cisco_band.split() + cisco_wifimodes = args.cisco_wifimode.split() + for mode in cisco_wifimodes: + if mode in wifi_mode_dict.keys(): + pass + else: + logg.info("wifimode [{}] not recognised. Please use: auto, a, b, g, abg, abgn, bgn, bg, abgnAC, anAC, an, bgnAC, abgnAX, bgnAX, anAX".format(mode)) exit(1) - - radio_name_list.append(radio_info_dict['radio']) - number_of_stations_per_radio_list.append(radio_info_dict['stations']) - ssid_list.append(radio_info_dict['ssid']) - ssid_password_list.append(radio_info_dict['ssid_pw']) - ssid_security_list.append(radio_info_dict['security']) + cisco_tx_power = "3" + cisco_chan_5ghz = "36".split() + cisco_chan_24ghz = "1".split() + cisco_chan_widths = args.cisco_chan_width.split() + cisco_ap_modes = args.cisco_ap_mode.split() + cisco_client_densities = args.cisco_client_density.split() + cisco_packet_types = args.endp_type.split() + cisco_directions = "upstream downstream".split() + cisco_packet_sizes = args.cisco_packet_size.split() + cisco_client_densities = args.cisco_client_density.split() + cisco_data_encryptions = args.cisco_data_encryption.split() - optional_radio_reset_keys = ['reset_port_enable'] - radio_reset_found = True - for key in optional_radio_reset_keys: - if key not in radio_info_dict: - #print("port reset test not enabled") - radio_reset_found = False - break + cisco_side_a_min_bps = args.side_a_min_bps + cisco_side_a_min_bps = args.side_b_min_bps - if radio_reset_found: - reset_port_enable_list.append(True) - reset_port_time_min_list.append(radio_info_dict['reset_port_time_min']) - reset_port_time_max_list.append(radio_info_dict['reset_port_time_max']) - else: - reset_port_enable_list.append(False) - reset_port_time_min_list.append('0s') - reset_port_time_max_list.append('0s') + + logg.info(cisco_aps) + logg.info(cisco_bands) + logg.info(cisco_wifimodes) + logg.info(cisco_chan_widths) + logg.info(cisco_chan_widths) + logg.info(cisco_ap_modes) + logg.info(cisco_client_densities) + logg.info(cisco_packet_types) + logg.info(cisco_packet_sizes) + logg.info(cisco_client_densities) + logg.info(cisco_data_encryptions) + __ap_set = None + __band_set = None + __chan_width_set = None + __ap_mode_set = None + __tx_power_set = None + __csv_started = False + + for cisco_ap in cisco_aps: + for cisco_band in cisco_bands: # frequency + for cisco_wifimode in cisco_wifimodes: + # check for valid frequency and wifi_mode combination put here to simplify logic since all radios do not support all modes + # "an anAX anAC abgn bg" + if((cisco_band == "a" and cisco_wifimode == "bg") or (cisco_band == "b" and cisco_wifimode == "anAC")): + pass # invalid combination continue + else: + for cisco_chan_width in cisco_chan_widths: #bandwidth + for cisco_data_encryption in cisco_data_encryptions: + for cisco_ap_mode in cisco_ap_modes: + for cisco_client_density in cisco_client_densities: + for cisco_packet_type in cisco_packet_types: + for cisco_direction in cisco_directions: + for cisco_packet_size in cisco_packet_sizes: + logg.info("#####################################################") + logg.info("# TEST RUNNING , TEST RUNNING ######################") + logg.info("#####################################################") + test_config = "AP=={} Band=={} wifi_mode=={} BW=={} encryption=={} ap_mode=={} clients=={} packet_type=={} direction=={} packet_size=={}".format(cisco_ap, + cisco_band,cisco_wifimode,cisco_chan_width,cisco_data_encryption,cisco_ap_mode,cisco_client_density, + cisco_packet_type,cisco_direction,cisco_packet_size) + test_keys = ['AP','Band','wifi_mode','BW','encryption','ap_mode','clients','packet_type','direction','packet_size'] + logg.info("# Cisco run settings: {}".format(test_config)) + if(args.no_controller): + logg.info("################################################") + logg.info("# NO CONTROLLER SET , TEST MODE") + logg.info("################################################") + else: + if( cisco_ap != __ap_set or + cisco_band != __band_set or + cisco_chan_width != __chan_width_set or + cisco_ap_mode != __ap_mode_set or + cisco_tx_power != __tx_power_set + ): + logg.info("###############################################") + logg.info("# NEW CONTROLLER CONFIG") + logg.info("###############################################") + __ap_set = cisco_ap + __band_set = cisco_band + __chan_width_set = cisco_chan_width + __ap_mode_set = cisco_ap_mode + __tx_power_set = cisco_tx_power + ############################################# + # configure cisco controller + ############################################# + cisco_args.cisco_ap = cisco_ap + cisco_args.cisco_band = cisco_band + if cisco_band == "a": + cisco_args.cisco_chan = cisco_chan_5ghz + else: + cisco_args.cisco_chan = cisco_chan_24ghz + cisco_args.cisco_chan_width = cisco_chan_width + cisco_args.cisco_ap_mode = cisco_ap_mode + cisco_args.cisco_tx_power = cisco_tx_power + logg.info(cisco_args) + cisco = cisco_(cisco_args) # << is there a way to make a structure as compared to passing all args + #Disable AP + cisco.controller_disable_ap() + if cisco_args.cisco_series == "9800": + cisco.controller_disable_wlan() + cisco.controller_disable_network_5ghz() + cisco.controller_disable_network_24ghz() + cisco.controller_role_manual() + else: + cisco.controller_disable_network_5ghz() + cisco.controller_disable_network_24ghz() + cisco.controller_set_tx_power() + cisco.controller_set_channel() + cisco.controller_set_bandwidth() + if cisco_args.cisco_series == "9800": + cisco.controller_create_wlan() + cisco.controller_set_wireless_tag_policy() + cisco.controller_enable_wlan() + if cisco_band == "a": + cisco.controller_enable_network_5ghz() + else: + cisco.controller_enable_network_24ghz() + cisco.controller_enable_ap() + # need to actually check the CAC timer + time.sleep(30) + #################################### + # end of cisco controller code + #################################### + else: + logg.info("###############################################") + logg.info("# NO CHANGE TO CONTROLLER CONFIG") + logg.info("###############################################") + logg.info("cisco_wifi_mode {}".format(cisco_wifimode)) + if args.radio: + radios = args.radio + elif cisco_band == "a": + if cisco_wifimode == "anAX" or cisco_wifimode == "abgn": + #AX200 dual band + radios = radio_AX200_abgn_ax_dict[cisco_client_density] + elif cisco_wifimode == "an" or cisco_wifimode == "anAC" or cisco_wifimode =="auto": + #ath10K only supports 5Ghz + radios = radio_ath10K_9984_an_AC_dict[cisco_client_density] + else: + logg.info("##################################") + logg.info("# INVALID COMBINATION 5ghz") + logg.info("# Cisco run settings: {}".format(test_config)) + logg.info("##################################") + exit(1) - index = 0 - station_lists = [] - for (radio_name_, number_of_stations_per_radio_) in zip(radio_name_list,number_of_stations_per_radio_list): - number_of_stations = int(number_of_stations_per_radio_) - if number_of_stations > MAX_NUMBER_OF_STATIONS: - print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) - quit(1) - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, - padding_number_=10000, radio=radio_name_) - station_lists.append(station_list) - index += 1 + else: # cisco_band == "b" + if cisco_wifimode == "an" or cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg" or cisco_wifimode == "auto": + #AX200 dual band + radios = radio_AX200_abgn_ax_dict[cisco_client_density] + else: + logg.info("##################################") + logg.info("# INVALID COMBINATION 24 ghz") + logg.info("# Cisco run settings: {}".format(test_config)) + logg.info("##################################") + exit(1) - #print("endp-types: %s"%(endp_types)) - - dfs = DFS.L3VariableTime( - lfjson_host, - lfjson_port, - args=args, - number_template="00", - station_lists= station_lists, - name_prefix="LT-", - endp_types=endp_types, - tos=args.tos, - side_b=side_b, - radio_name_list=radio_name_list, - number_of_stations_per_radio_list=number_of_stations_per_radio_list, - ssid_list=ssid_list, - ssid_password_list=ssid_password_list, - ssid_security_list=ssid_security_list, - test_duration=test_duration, - polling_interval= polling_interval, - reset_port_enable_list=reset_port_enable_list, - reset_port_time_min_list=reset_port_time_min_list, - reset_port_time_max_list=reset_port_time_max_list, - side_a_min_rate=256000, - side_b_min_rate=256000, - debug_on=debug_on, - outfile=csv_outfile) - - dfs.pre_cleanup() - - dfs.build() - if not dfs.passes(): - print("build step failed.") - print(dfs.get_fail_message()) - exit(1) - dfs.start(False, False) - dfs.stop() - if not dfs.passes(): - print("stop test failed") - print(dfs.get_fail_message()) - - - print("Pausing 30 seconds after run for manual inspection before we clean up.") - time.sleep(30) - dfs.cleanup() - if dfs.passes(): - print("Full test passed, all connections increased rx bytes") + logg.info("radios {}".format(radios)) + for radio_ in radios: + radio_keys = ['radio','stations','ssid','ssid_pw','security','wifimode'] + radio_info_dict = dict(map(lambda x: x.split('=='), str(radio_).replace('[','').replace(']','').replace("'","").split())) + logg.info("radio_dict {}".format(radio_info_dict)) + for key in radio_keys: + if key not in radio_info_dict: + logg.info("missing config, for the {}, all of the following need to be present {} ".format(key,radio_keys)) + exit(1) + radio_name_list.append(radio_info_dict['radio']) + ssid_list.append(radio_info_dict['ssid']) + ssid_password_list.append(radio_info_dict['ssid_pw']) + ssid_security_list.append(radio_info_dict['security']) + if args.radio: + number_of_stations_per_radio_list.append(radio_info_dict['stations']) + wifimode_list.append(int(wifi_mode_dict[radio_info_dict['wifimode']])) + else: + number_of_stations_per_radio_list.append(radio_info_dict['stations']) + wifimode_list.append(int(wifi_mode_dict[radio_info_dict['wifimode']])) + optional_radio_reset_keys = ['reset_port_enable'] + radio_reset_found = True + for key in optional_radio_reset_keys: + if key not in radio_info_dict: + #logg.info("port reset test not enabled") + radio_reset_found = False + break + + if radio_reset_found: + reset_port_enable_list.append(True) + reset_port_time_min_list.append(radio_info_dict['reset_port_time_min']) + reset_port_time_max_list.append(radio_info_dict['reset_port_time_max']) + else: + reset_port_enable_list.append(False) + reset_port_time_min_list.append('0s') + reset_port_time_max_list.append('0s') + # no stations for testing reconfiguration of the controller - + if(args.no_stations): + logg.info("##################################") + logg.info("# NO STATIONS") + logg.info("##################################") + else: + index = 0 + station_lists = [] + for (radio_name_, number_of_stations_per_radio_) in zip(radio_name_list,number_of_stations_per_radio_list): + number_of_stations = int(number_of_stations_per_radio_) + if number_of_stations > MAX_NUMBER_OF_STATIONS: + logg.info("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) + quit(1) + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, + padding_number_=10000, radio=radio_name_) + station_lists.append(station_list) + index += 1 + # Run Traffic Upstream (STA to AP) + if(cisco_direction == "upstream"): + side_a_min_bps = cisco_side_a_min_bps + side_b_min_bps = 0 + # Run Traffic Downstream (AP to STA) + else: + side_a_min_bps = 0 + side_b_min_bps = cisco_side_b_min_bps + # current default is to have a values + ip_var_test = L3VariableTime( + lfjson_host, + lfjson_port, + args=args, + number_template="00", + station_lists= station_lists, + name_prefix="LT-", + endp_type=cisco_packet_type, + tos=args.tos, + side_b=side_b, + radio_name_list=radio_name_list, + number_of_stations_per_radio_list=number_of_stations_per_radio_list, + ssid_list=ssid_list, + ssid_password_list=ssid_password_list, + ssid_security_list=ssid_security_list, + wifimode_list=wifimode_list, + test_duration=test_duration, + polling_interval= polling_interval, + reset_port_enable_list=reset_port_enable_list, + reset_port_time_min_list=reset_port_time_min_list, + reset_port_time_max_list=reset_port_time_max_list, + side_a_min_bps=side_a_min_bps, + side_a_min_pdu =cisco_packet_size, + side_b_min_bps=side_b_min_bps, + side_b_min_pdu =cisco_packet_size, + debug_on=debug_on, + outfile=csv_outfile, + results=csv_results, + test_keys=test_keys, + test_config=test_config, + csv_started=__csv_started ) + __csv_started = True + ip_var_test.pre_cleanup() + ip_var_test.build() + if not ip_var_test.passes(): + logg.info("build step failed.") + logg.info(ip_var_test.get_fail_message()) + exit(1) + ip_var_test.start(False, False) + ip_var_test.stop() + if not ip_var_test.passes(): + logg.info("stop test failed") + logg.info(ip_var_test.get_fail_message()) + # clean up + radio_name_list = [] + number_of_stations_per_radio_list = [] + ssid_list = [] + ssid_password_list = [] + ssid_security_list = [] + wifimode_list = [] + ip_var_test.cleanup() + if ( args.no_stations): + pass + else: + ip_var_test.passes() + logg.info("Full test passed, all connections increased rx bytes") if __name__ == "__main__": main() diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index 94d5daf7..30bc481a 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -38,7 +38,8 @@ class FileAdapter(object): pass # leave it to logging to flush properly ################################################################################ -# cisco controller class :This class in the future will be moved to its own file +# cisco controller class :This class will be left in this file to allow for the +# Scaling and Performance to be self contained and not impact other tests ################################################################################ class cisco_(): From fbce00e98840e6c55377c56f470a195a02b81fed Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 18 Jan 2021 13:12:27 -0800 Subject: [PATCH 023/848] inheritance fixes --- py-json/realm.py | 825 ++++++++++++++------------ py-scripts/test_ipv4_variable_time.py | 1 + 2 files changed, 447 insertions(+), 379 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index b86ed26c..bb9acf93 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -20,6 +20,7 @@ import base64 import xlsxwriter import pandas as pd + def wpa_ent_list(): return [ "DEFAULT", @@ -45,6 +46,7 @@ def wpa_ent_list(): "OWE" ] + class Realm(LFCliBase): def __init__(self, lfclient_host="localhost", @@ -67,13 +69,13 @@ class Realm(LFCliBase): # self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) super().__init__(lfclient_host, lfclient_port, - _debug=debug_, - _halt_on_error=halt_on_error_, - _exit_on_error=_exit_on_error, - _exit_on_fail=_exit_on_fail, - #_local_realm=self, - _proxy_str=_proxy_str, - _capture_signal_list=_capture_signal_list) + _debug=debug_, + _halt_on_error=halt_on_error_, + _exit_on_error=_exit_on_error, + _exit_on_fail=_exit_on_fail, + # _local_realm=self, + _proxy_str=_proxy_str, + _capture_signal_list=_capture_signal_list) self.debug = debug_ # if debug_: @@ -84,7 +86,7 @@ class Realm(LFCliBase): self.freq_to_chan = {} freq = 0 chan = 1 - for freq in range( 2412, 2472, 5): + for freq in range(2412, 2472, 5): self.freq_to_chan[freq] = chan self.chan_to_freq[chan] = freq chan += 1 @@ -245,14 +247,14 @@ class Realm(LFCliBase): data = { "test_mgr": "ALL", "cx_name": cx_name - } + } self.json_post(req_url, data) def rm_endp(self, ename, debug_=False, suppress_related_commands_=True): req_url = "cli-json/rm_endp" data = { "endp_name": ename - } + } self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) def set_endp_tos(self, ename, _tos, debug_=False, suppress_related_commands_=True): @@ -270,7 +272,7 @@ class Realm(LFCliBase): data = { "name": ename, "tos": tos - } + } self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) def stop_cx(self, cx_name): @@ -278,7 +280,7 @@ class Realm(LFCliBase): "test_mgr": "ALL", "cx_name": cx_name, "cx_state": "STOPPED" - }, debug_=self.debug) + }, debug_=self.debug) def cleanup_cxe_prefix(self, prefix): cx_list = self.cx_list() @@ -297,7 +299,7 @@ class Realm(LFCliBase): self.rm_endp(endp_name) else: if self.debug: - print("cleanup_cxe_prefix no endpoints: endp_list{}".format(endp_list) ) + print("cleanup_cxe_prefix no endpoints: endp_list{}".format(endp_list)) def channel_freq(self, channel_=0): return self.chan_to_freq[channel_] @@ -307,7 +309,7 @@ class Realm(LFCliBase): # checks for OK or BUSY when querying cli-json/cv+is_built def wait_while_building(self, debug_=False): - response_json=[] + response_json = [] data = { "cmd": "cv is_built" } @@ -317,8 +319,9 @@ class Realm(LFCliBase): dbg_param = "?__debug=1" while (last_response != "YES"): - response = self.json_post("/gui-json/cmd%s" % dbg_param, data, debug_=debug_, response_json_list_=response_json) - #LFUtils.debug_printer.pprint(response_json) + response = self.json_post("/gui-json/cmd%s" % dbg_param, data, debug_=debug_, + response_json_list_=response_json) + # LFUtils.debug_printer.pprint(response_json) last_response = response_json[0]["LAST"]["response"] if (last_response != "YES"): last_response = None @@ -331,12 +334,13 @@ class Realm(LFCliBase): # loads a database def load(self, name): if (name is None) or (name == ""): - raise ValueError("Realm::load: wants a test scenario database name, please find one in the Status tab of the GUI") + raise ValueError( + "Realm::load: wants a test scenario database name, please find one in the Status tab of the GUI") data = { "name": name, - "action":"overwrite", - "clean_dut":"yes", + "action": "overwrite", + "clean_dut": "yes", "clean_chambers": "yes" } self.json_post("/cli-json/load", _data=data, debug_=self.debug) @@ -367,7 +371,7 @@ class Realm(LFCliBase): for req in these_endp: if not req in found_endps: if debug: - print("Waiting on endpoint: %s"%(req)) + print("Waiting on endpoint: %s" % (req)) wait_more = True count += 1 if (count > 100): @@ -396,7 +400,7 @@ class Realm(LFCliBase): for req in these_cx: if not req in found_cxs: if debug: - print("Waiting on CX: %s"%(req)) + print("Waiting on CX: %s" % (req)) wait_more = True count += 1 if (count > 100): @@ -536,8 +540,8 @@ class Realm(LFCliBase): return LFUtils.name_to_eid(eid) def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60, debug=False): - print("Waiting for ips, timeout: %i..."%(timeout_sec)) - #print(station_list) + print("Waiting for ips, timeout: %i..." % (timeout_sec)) + # print(station_list) waiting_states = ["0.0.0.0", "NA", ""] if (station_list is None) or (len(station_list) < 1): @@ -549,12 +553,12 @@ class Realm(LFCliBase): for sta_eid in station_list: if debug: - print("checking sta-eid: %s"%(sta_eid)) + print("checking sta-eid: %s" % (sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % (eid[0], eid[1], eid[2])) - #pprint(response) + # pprint(response) if (response is None) or ("interface" not in response): print("station_list: incomplete response:") @@ -567,22 +571,22 @@ class Realm(LFCliBase): if (v['ip'] in waiting_states): wait_more = True if debug: - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + print("Waiting for port %s to get IPv4 Address." % (sta_eid)) else: if debug: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) if ipv6: v = response['interface'] - #print(v) + # print(v) if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ - and v['ipv6 address'] != 'AUTO': + and v['ipv6 address'] != 'AUTO': if debug: print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) else: wait_more = True if debug: - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + print("Waiting for port %s to get IPv6 Address." % (sta_eid)) if wait_more: time.sleep(1) @@ -590,7 +594,7 @@ class Realm(LFCliBase): return not wait_more - def get_curr_num_ips(self,num_sta_with_ips=0,station_list=None, ipv4=True, ipv6=False, debug=False): + def get_curr_num_ips(self, num_sta_with_ips=0, station_list=None, ipv4=True, ipv6=False, debug=False): if debug: print("checking number of stations with ips...") waiting_states = ["0.0.0.0", "NA", ""] @@ -598,45 +602,44 @@ class Realm(LFCliBase): raise ValueError("check for num curr ips expects non-empty list of ports") for sta_eid in station_list: if debug: - print("checking sta-eid: %s"%(sta_eid)) + print("checking sta-eid: %s" % (sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % - (eid[0], eid[1], eid[2])) + (eid[0], eid[1], eid[2])) if debug: pprint(response) if (response is None) or ("interface" not in response): print("station_list: incomplete response:") pprint(response) - #wait_more = True + # wait_more = True break if ipv4: v = response['interface'] if (v['ip'] in waiting_states): if debug: - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + print("Waiting for port %s to get IPv4 Address." % (sta_eid)) else: if debug: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) print("Incrementing stations with IP addresses found") - num_sta_with_ips+=1 + num_sta_with_ips += 1 else: - num_sta_with_ips+=1 + num_sta_with_ips += 1 if ipv6: v = response['interface'] if (v['ip'] in waiting_states): if debug: - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + print("Waiting for port %s to get IPv6 Address." % (sta_eid)) else: if debug: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) print("Incrementing stations with IP addresses found") - num_sta_with_ips+=1 + num_sta_with_ips += 1 else: - num_sta_with_ips+=1 + num_sta_with_ips += 1 return num_sta_with_ips - def duration_time_to_seconds(self, time_string): if isinstance(time_string, str): pattern = re.compile("^(\d+)([dhms]$)") @@ -701,7 +704,7 @@ class Realm(LFCliBase): endp_list = self.json_get("/endp/list") if "items" in endp_list or "empty" in endp_list: return - if endp_list is not None or endp_list : + if endp_list is not None or endp_list: print("Removing all endps") endp_list = list(endp_list['endpoint']) for endp_name in range(len(endp_list)): @@ -712,7 +715,7 @@ class Realm(LFCliBase): } self.json_post(req_url, data) - def remove_all_cxs(self,remove_all_endpoints=False): + def remove_all_cxs(self, remove_all_endpoints=False): # remove cross connects # remove endpoints # nc show endpoints @@ -738,13 +741,13 @@ class Realm(LFCliBase): self.remove_all_endps() req_url = "cli-json/nc_show_endpoints" data = { - "endpoint":"all" + "endpoint": "all" } self.json_post(req_url, data) req_url = "cli-json/show_cx" - data ={ - "test_mgr":"all", - "cross_connect":"all" + data = { + "test_mgr": "all", + "cross_connect": "all" } def parse_link(self, link): @@ -757,7 +760,7 @@ class Realm(LFCliBase): def new_multicast_profile(self): multi_prof = MULTICASTProfile(self.lfclient_host, self.lfclient_port, - local_realm=self, debug_=self.debug, report_timer_=3000) + local_realm=self, debug_=self.debug, report_timer_=3000) return multi_prof def new_wifi_monitor_profile(self, resource_=1, debug_=False, up_=False): @@ -793,11 +796,13 @@ class Realm(LFCliBase): return cx_prof def new_vap_profile(self): - vap_prof = VAPProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, debug_=self.debug) + vap_prof = VAPProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, + debug_=self.debug) return vap_prof def new_vr_profile(self): - vap_prof = VRProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, debug_=self.debug) + vap_prof = VRProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, + debug_=self.debug) return vap_prof def new_http_profile(self): @@ -817,44 +822,52 @@ class Realm(LFCliBase): def new_test_group_profile(self): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) + class BaseProfile(LFCliBase): - def __init__(self,local_realm): - self.parent_realm=local_realm + def __init__(self, local_realm): + self.parent_realm = local_realm self.halt_on_error = False self.exit_on_error = False def json_get(self, target): - return self.json_get(target) + return self.parent_realm.json_get(target) - def json_post(self, url,data,debug_,suppress_related_commands_=None): - return self.json_post(url,data,debug_=False,suppress_related_commands_=suppress_related_commands_) + def json_post(self, req_url, data, debug_=False, suppress_related_commands_=None): + return self.parent_realm.json_post(req_url, + data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) - def parse_time(self,target): + def parse_time(self, target): return self.parent_realm.parse_time(target) - def stop_cx(self, target): - return self.parent_realm.stop_cx(target) + def stopping_cx(self, name): + return self.parent_realm.stop_cx(name) - def cleanup_cxe_prefix(self,prefix): + def cleanup_cxe_prefix(self, prefix): return self.parent_realm.cleanup_cxe_prefix(prefix) - def rm_cx(self,target): + def rm_cx(self, target): return self.parent_realm.rm_cx(target) - def created_cx(self,target): + def rm_endp(self, ename): + self.parent_realm.rm_endp(ename) + + def created_cx(self, target): return self.parent_realm.created_cx(target) - def name_to_eid(self,target): + def name_to_eid(self, target): return self.parent_realm.name_to_eid(target) - def set_endp_tos(self,target): + def set_endp_tos(self, target): return self.parent_realm.set_endp_tos(target) - def wait_until_endps_appear(self,target,debug=False): - return self.parent_realm.wait_until_endps_appear(target,debug=False) + def wait_until_endps_appear(self, target, debug=False): + return self.parent_realm.wait_until_endps_appear(target, debug=False) + + def wait_until_cxs_appear(self, target, debug=False): + return self.parent_realm.wait_until_cxs_appear(target, debug=False) - def wait_until_cxs_appear(self,target,debug=False): - return self.parent_realm.wait_until_cxs_appear(target,debug=False) class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -883,86 +896,88 @@ class MULTICASTProfile(LFCliBase): def refresh_mc(self, debug_=False): for endp_name in self.get_mc_names(): self.json_post("/cli-json/show_endpoints", { - "endpoint": endp_name + "endpoint": endp_name }, debug_=debug_) - def start_mc(self, suppress_related_commands=None, debug_ = False): + def start_mc(self, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True for endp_name in self.get_mc_names(): - print("Starting mcast endpoint: %s"%(endp_name)) + print("Starting mcast endpoint: %s" % (endp_name)) json_data = { - "endp_name":endp_name + "endp_name": endp_name } url = "cli-json/start_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) pass - def stop_mc(self, suppress_related_commands=None, debug_ = False): + def stop_mc(self, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True for endp_name in self.get_mc_names(): json_data = { - "endp_name":endp_name + "endp_name": endp_name } url = "cli-json/stop_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) pass - def cleanup(self, suppress_related_commands=None, debug_ = False): + def cleanup(self, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True for endp_name in self.get_mc_names(): self.local_realm.rm_endp(endp_name, debug_=debug_, suppress_related_commands_=suppress_related_commands) def create_mc_tx(self, endp_type, side_tx, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True side_tx_info = self.local_realm.name_to_eid(side_tx) side_tx_shelf = side_tx_info[0] side_tx_resource = side_tx_info[1] side_tx_port = side_tx_info[2] - side_tx_name = "%smtx-%s-%i"%(self.name_prefix, side_tx_port, len(self.created_mc)) + side_tx_name = "%smtx-%s-%i" % (self.name_prefix, side_tx_port, len(self.created_mc)) json_data = [] - #add_endp mcast-xmit-sta 1 1 side_tx mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 + # add_endp mcast-xmit-sta 1 1 side_tx mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':side_tx_name, - 'shelf':side_tx_shelf, - 'resource':side_tx_resource, - 'port':side_tx_port, - 'type':endp_type, - 'ip_port':-1, - 'is_rate_bursty': - 'NO','min_rate':256000, - 'max_rate':0, - 'is_pkt_sz_random':'NO', - 'min_pkt':1472, - 'max_pkt':0, - 'payload_pattern':'INCREASING', - 'use_checksum':'NO', - 'ttl':32, - 'send_bad_crc_per_million':0, - 'multi_conn':0 - } + 'alias': side_tx_name, + 'shelf': side_tx_shelf, + 'resource': side_tx_resource, + 'port': side_tx_port, + 'type': endp_type, + 'ip_port': -1, + 'is_rate_bursty': + 'NO', 'min_rate': 256000, + 'max_rate': 0, + 'is_pkt_sz_random': 'NO', + 'min_pkt': 1472, + 'max_pkt': 0, + 'payload_pattern': 'INCREASING', + 'use_checksum': 'NO', + 'ttl': 32, + 'send_bad_crc_per_million': 0, + 'multi_conn': 0 + } url = "/cli-json/add_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical + # set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical json_data = { - 'name':side_tx_name, - 'ttl':32, - 'mcast_group':'224.9.9.9', - 'mcast_dest_port':9999, - 'rcv_mcast':'No' - } + 'name': side_tx_name, + 'ttl': 32, + 'mcast_group': '224.9.9.9', + 'mcast_dest_port': 9999, + 'rcv_mcast': 'No' + } url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) @@ -972,10 +987,9 @@ class MULTICASTProfile(LFCliBase): these_endp = [side_tx_name] self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) - - def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_ = False): + def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True these_endp = [] @@ -984,40 +998,42 @@ class MULTICASTProfile(LFCliBase): side_rx_shelf = side_rx_info[0] side_rx_resource = side_rx_info[1] side_rx_port = side_rx_info[2] - side_rx_name = "%smrx-%s-%i"%(self.name_prefix, side_rx_port, len(self.created_mc)) + side_rx_name = "%smrx-%s-%i" % (self.name_prefix, side_rx_port, len(self.created_mc)) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':side_rx_name, - 'shelf':side_rx_shelf, - 'resource':side_rx_resource, - 'port':side_rx_port, - 'type':endp_type, - 'ip_port':9999, - 'is_rate_bursty':'NO', - 'min_rate':0, - 'max_rate':0, - 'is_pkt_sz_random':'NO', - 'min_pkt':1472, - 'max_pkt':0, - 'payload_pattern':'INCREASING', - 'use_checksum':'NO', - 'ttl':32, - 'send_bad_crc_per_million':0, - 'multi_conn':0 - } + 'alias': side_rx_name, + 'shelf': side_rx_shelf, + 'resource': side_rx_resource, + 'port': side_rx_port, + 'type': endp_type, + 'ip_port': 9999, + 'is_rate_bursty': 'NO', + 'min_rate': 0, + 'max_rate': 0, + 'is_pkt_sz_random': 'NO', + 'min_pkt': 1472, + 'max_pkt': 0, + 'payload_pattern': 'INCREASING', + 'use_checksum': 'NO', + 'ttl': 32, + 'send_bad_crc_per_million': 0, + 'multi_conn': 0 + } url = "cli-json/add_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) json_data = { - 'name':side_rx_name, - 'ttl':32, - 'mcast_group':'224.9.9.9', - 'mcast_dest_port':9999, - 'rcv_mcast':'Yes' - } + 'name': side_rx_name, + 'ttl': 32, + 'mcast_group': '224.9.9.9', + 'mcast_dest_port': 9999, + 'rcv_mcast': 'Yes' + } url = "cli-json/set_mc_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) self.created_mc[side_rx_name] = side_rx_name these_endp.append(side_rx_name) @@ -1028,14 +1044,23 @@ class MULTICASTProfile(LFCliBase): pprint.pprint(self) - class L3CXProfile(BaseProfile): - def __init__(self, lfclient_host, lfclient_port,local_realm, - side_a_min_bps=None, side_b_min_bps=None, - side_a_max_bps=0, side_b_max_bps=0, - side_a_min_pdu=-1, side_b_min_pdu=-1, - side_a_max_pdu=0, side_b_max_pdu=0, - report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): + def __init__(self, + lfclient_host, + lfclient_port, + local_realm, + side_a_min_bps=None, + side_b_min_bps=None, + side_a_max_bps=0, + side_b_max_bps=0, + side_a_min_pdu=-1, + side_b_min_pdu=-1, + side_a_max_pdu=0, + side_b_max_pdu=0, + report_timer_=3000, + name_prefix_="Unset", + number_template_="00000", + debug_=False): """ :param lfclient_host: :param lfclient_port: @@ -1054,7 +1079,6 @@ class L3CXProfile(BaseProfile): super().__init__(local_realm) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ - self.local_realm = local_realm self.side_a_min_pdu = side_a_min_pdu self.side_b_min_pdu = side_b_min_pdu self.side_a_max_pdu = side_a_max_pdu @@ -1088,8 +1112,8 @@ class L3CXProfile(BaseProfile): if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.created_cx.values(): - cx_rx_map[item] = value_rx + if value_name == 'rx bytes' and item in self.created_cx.values(): + cx_rx_map[item] = value_rx return cx_rx_map def __compare_vals(self, old_list, new_list): @@ -1119,11 +1143,11 @@ class L3CXProfile(BaseProfile): script_name=None, arguments=None): try: - duration_sec=self.parse_time(duration_sec).seconds + duration_sec = self.parse_time(duration_sec).seconds except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") - if (duration_sec <= monitor_interval ): + if (duration_sec <= monitor_interval): raise ValueError("L3CXProfile::monitor wants duration_sec > monitor_interval") if report_file == None: raise ValueError("Monitor requires an output file to be defined") @@ -1140,10 +1164,10 @@ class L3CXProfile(BaseProfile): else: output_format = report_file.split('.')[-1] - #Step 1, column names - fields=",".join(col_names) + # Step 1, column names + fields = ",".join(col_names) print(fields) - #Step 2, monitor columns + # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) print(end_time) @@ -1152,8 +1176,8 @@ class L3CXProfile(BaseProfile): passes = 0 expected_passes = 0 old_cx_rx_values = self.__get_rx_values() - timestamps=[] - #for x in range(0,int(round(iterations,0))): + timestamps = [] + # for x in range(0,int(round(iterations,0))): while datetime.datetime.now() < end_time: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: @@ -1161,9 +1185,9 @@ class L3CXProfile(BaseProfile): raise ValueError("no endpoint?") if show: print(response) - t=datetime.datetime.now() + t = datetime.datetime.now() timestamps.append(t) - value_map[t]=response + value_map[t] = response new_cx_rx_values = self.__get_rx_values() if self.debug: print(old_cx_rx_values, new_cx_rx_values) @@ -1180,80 +1204,84 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) - #if passes == expected_passes: - #self._pass("PASS: All tests passed") - #step 3 organize data - endpoints=list() + # if passes == expected_passes: + # self._pass("PASS: All tests passed") + # step 3 organize data + endpoints = list() for endpoint in value_map.values(): endpoints.append(endpoint['endpoint']) - endpoints2=[] + endpoints2 = [] for y in range(0, len(endpoints)): for x in range(0, len(endpoints[0])): endpoints2.append(list(list(endpoints[y][x].values())[0].values())) import itertools - timestamps2=list(itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) + timestamps2 = list( + itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) - #step 4 save and close - header_row=col_names - header_row.insert(0,'Timestamp') + # step 4 save and close + header_row = col_names + header_row.insert(0, 'Timestamp') print(header_row) - if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': + if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) worksheet = workbook.add_worksheet() - for col_num,data in enumerate(header_row): - worksheet.write(0, col_num,data) + for col_num, data in enumerate(header_row): + worksheet.write(0, col_num, data) row_num = 1 for x in endpoints2: for col_num, data in enumerate(x): - worksheet.write(row_num, col_num, str(data)) - row_num+=1 + worksheet.write(row_num, col_num, str(data)) + row_num += 1 workbook.close() else: - df=pd.DataFrame(endpoints2) - df.columns=header_row + df = pd.DataFrame(endpoints2) + df.columns = header_row import requests import ast - systeminfo=ast.literal_eval(requests.get('http://localhost:8080').text) + try: + systeminfo = ast.literal_eval(requests.get('http://localhost:8080').text) + except: + systeminfo = ast.literal_eval(requests.get('http://192.168.1.3:8080').text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments - for x in ['LFGUI Release','Script Name','Arguments']: + for x in ['LFGUI Release', 'Script Name', 'Arguments']: df[x][1:] = '' if output_format == 'pdf': import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages - fig, ax = plt.subplots(figsize=(12,4)) + fig, ax = plt.subplots(figsize=(12, 4)) ax.axis('tight') ax.axis('off') the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') pp = PdfPages(report_file) - pp.savefig(fig, bbox_inches = 'tight') + pp.savefig(fig, bbox_inches='tight') pp.close() if output_format == 'hdf': - df.to_hdf(report_file,'table', append=True) + df.to_hdf(report_file, 'table', append=True) if output_format == 'parquet': - df.to_parquet(report_file,engine='pyarrow') + df.to_parquet(report_file, engine='pyarrow') if output_format == 'png': - fig=df.plot().get_figure() + fig = df.plot().get_figure() fig.savefig(report_file) if output_format == 'html': print('Shivams function') if output_format == 'df': return df - supported_formats = ['csv','json','stata','pickle'] + supported_formats = ['csv', 'json', 'stata', 'pickle'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: - exec('df.to_'+x+'("'+report_file+'")') + exec('df.to_' + x + '("' + report_file + '")') else: pass def refresh_cx(self): for cx_name in self.created_cx.keys(): - self.local_realm.json_post("/cli-json/show_cxe", { - "test_mgr": "ALL", - "cross_connect": cx_name + self.json_post("/cli-json/show_cxe", { + "test_mgr": "ALL", + "cross_connect": cx_name }, debug_=self.debug) print(".", end='') @@ -1261,8 +1289,8 @@ class L3CXProfile(BaseProfile): print("Starting CXs...") for cx_name in self.created_cx.keys(): if self.debug: - print("cx-name: %s"%(cx_name)) - self.local_realm.json_post("/cli-json/set_cx_state", { + print("cx-name: %s" % (cx_name)) + self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", "cx_name": cx_name, "cx_state": "RUNNING" @@ -1273,30 +1301,31 @@ class L3CXProfile(BaseProfile): def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): - self.stop_cx(cx_name) + self.stopping_cx(cx_name) print(".", end='') print("") def cleanup_prefix(self): - self.local_realm.cleanup_cxe_prefix(self.name_prefix) + self.cleanup_cxe_prefix(self.name_prefix) def cleanup(self): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: for cx_name in self.created_cx.keys(): if self.debug: - print("Cleaning cx: %s"%(cx_name)) + print("Cleaning cx: %s" % (cx_name)) self.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): ename = self.created_cx[cx_name][side] if self.debug: - print("Cleaning endpoint: %s"%(ename)) + print("Cleaning endpoint: %s" % (ename)) self.rm_endp(self.created_cx[cx_name][side]) - def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): + def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, + tos=None): if self.debug: - debug_=True + debug_ = True cx_post_data = [] timer_post_data = [] @@ -1309,7 +1338,8 @@ class L3CXProfile(BaseProfile): or (self.side_a_max_bps is None) \ or (self.side_b_min_bps is None) \ or (self.side_b_max_bps is None): - raise ValueError("side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") + raise ValueError( + "side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") if type(side_a) == list and type(side_b) != list: side_b_info = self.name_to_eid(side_b) @@ -1323,11 +1353,11 @@ class L3CXProfile(BaseProfile): if port_name.find('.') < 0: port_name = "%d.%s" % (side_a_info[1], port_name) - cx_name = "%s%s-%i"%(self.name_prefix, side_a_info[2], len(self.created_cx)) + cx_name = "%s%s-%i" % (self.name_prefix, side_a_info[2], len(self.created_cx)) endp_a_name = cx_name + "-A" endp_b_name = cx_name + "-B" - self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] + self.created_cx[cx_name] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name self.created_endp[endp_b_name] = endp_b_name these_cx.append(cx_name) @@ -1359,9 +1389,11 @@ class L3CXProfile(BaseProfile): } url = "/cli-json/add_endp" - self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands) - self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print("napping %f sec"%sleep_time) + self.json_post(url, endp_side_a, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + self.json_post(url, endp_side_b, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + # print("napping %f sec"%sleep_time) time.sleep(sleep_time) url = "cli-json/set_endp_flag" @@ -1370,16 +1402,20 @@ class L3CXProfile(BaseProfile): "flag": "AutoHelper", "val": 1 } - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) data["name"] = endp_b_name - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) if (endp_type == "lf_udp") or (endp_type == "udp") or (endp_type == "lf_udp6") or (endp_type == "udp6"): data["name"] = endp_a_name data["flag"] = "UseAutoNAT" - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) data["name"] = endp_b_name - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) if tos != None: self.set_endp_tos(endp_a_name, tos) @@ -1391,19 +1427,19 @@ class L3CXProfile(BaseProfile): "tx_endp": endp_a_name, "rx_endp": endp_b_name, } - #pprint(data) + # pprint(data) cx_post_data.append(data) timer_post_data.append({ - "test_mgr":"default_tm", - "cx_name":cx_name, - "milliseconds":self.report_timer + "test_mgr": "default_tm", + "cx_name": cx_name, + "milliseconds": self.report_timer }) elif type(side_b) == list and type(side_a) != list: side_a_info = self.name_to_eid(side_a) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] - #side_a_name = side_a_info[2] + # side_a_name = side_a_info[2] for port_name in side_b: print(side_b) @@ -1415,7 +1451,7 @@ class L3CXProfile(BaseProfile): cx_name = "%s%s-%i" % (self.name_prefix, port_name, len(self.created_cx)) endp_a_name = cx_name + "-A" endp_b_name = cx_name + "-B" - self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] + self.created_cx[cx_name] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name self.created_endp[endp_b_name] = endp_b_name these_cx.append(cx_name) @@ -1447,9 +1483,11 @@ class L3CXProfile(BaseProfile): } url = "/cli-json/add_endp" - self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands) - self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print("napping %f sec" %sleep_time ) + self.json_post(url, endp_side_a, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + self.json_post(url, endp_side_b, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + # print("napping %f sec" %sleep_time ) time.sleep(sleep_time) url = "cli-json/set_endp_flag" @@ -1467,7 +1505,7 @@ class L3CXProfile(BaseProfile): "val": 1 } self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print("CXNAME451: %s" % cx_name) + # print("CXNAME451: %s" % cx_name) data = { "alias": cx_name, "test_mgr": "default_tm", @@ -1476,18 +1514,20 @@ class L3CXProfile(BaseProfile): } cx_post_data.append(data) timer_post_data.append({ - "test_mgr":"default_tm", - "cx_name":cx_name, - "milliseconds":self.report_timer + "test_mgr": "default_tm", + "cx_name": cx_name, + "milliseconds": self.report_timer }) else: - raise ValueError("side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (type(side_a), type(side_b))) + raise ValueError( + "side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % ( + type(side_a), type(side_b))) self.wait_until_endps_appear(these_endp, debug=debug_) for data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) time.sleep(0.01) self.wait_until_cxs_appear(these_cx, debug=debug_) @@ -1562,13 +1602,13 @@ class L4CXProfile(LFCliBase): "cx_name": self.created_cx[cx_name] } self.json_post(req_url, data) - #pprint(data) + # pprint(data) req_url = "cli-json/rm_endp" data = { "endp_name": cx_name } self.json_post(req_url, data) - #pprint(data) + # pprint(data) def create(self, ports=[], sleep_time=.5, debug_=False, suppress_related_commands_=None): cx_post_data = [] @@ -1591,7 +1631,8 @@ class L4CXProfile(LFCliBase): "proxy_auth_type": 0x200 } url = "cli-json/add_l4_endp" - self.local_realm.json_post(url, endp_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, endp_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) endp_data = { @@ -1605,7 +1646,8 @@ class L4CXProfile(LFCliBase): for cx_data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, cx_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) @@ -1629,7 +1671,7 @@ class GenCXProfile(LFCliBase): if self.type == "lfping": if ((self.dest is not None) or (self.dest != "")) and ((self.interval is not None) or (self.interval > 0)): self.cmd = "%s -i %s -I %s %s" % (self.type, self.interval, sta_name, self.dest) - #print(self.cmd) + # print(self.cmd) else: raise ValueError("Please ensure dest and interval have been set correctly") elif self.type == "generic": @@ -1645,8 +1687,8 @@ class GenCXProfile(LFCliBase): def start_cx(self): print("Starting CXs...") - #print(self.created_cx) - #print(self.created_endp) + # print(self.created_cx) + # print(self.created_endp) for cx_name in self.created_cx: self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", @@ -1704,15 +1746,15 @@ class GenCXProfile(LFCliBase): # this naming convention follows what you see when you use # lf_firemod.pl --action list_endp after creating a generic endpoint - gen_name_a = "%s-%s"%(self.name_prefix, name) - gen_name_b = "D_%s-%s"%(self.name_prefix, name) - endp_tpls.append( (resource, name, gen_name_a, gen_name_b)) + gen_name_a = "%s-%s" % (self.name_prefix, name) + gen_name_b = "D_%s-%s" % (self.name_prefix, name) + endp_tpls.append((resource, name, gen_name_a, gen_name_b)) for endp_tpl in endp_tpls: - resource = endp_tpl[0] - name = endp_tpl[1] - gen_name_a = endp_tpl[2] - #gen_name_b = endp_tpl[3] + resource = endp_tpl[0] + name = endp_tpl[1] + gen_name_a = endp_tpl[2] + # gen_name_b = endp_tpl[3] genl = GenericCx(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, debug_=self.debug) # (self, alias=None, shelf=1, resource=1, port=None, type=None): genl.create_gen_endp(alias=gen_name_a, shelf=shelf, resource=resource, port=name) @@ -1722,26 +1764,26 @@ class GenCXProfile(LFCliBase): time.sleep(sleep_time) for endp_tpl in endp_tpls: - gen_name_a = endp_tpl[2] - gen_name_b = endp_tpl[3] + gen_name_a = endp_tpl[2] + gen_name_b = endp_tpl[3] genl.set_flags(gen_name_a, "ClearPortOnStart", 1) # genl.set_flags(gen_name_b, "ClearPortOnStart", 1) # genl.set_flags(gen_name_b, "Unmanaged", 1) time.sleep(sleep_time) for endp_tpl in endp_tpls: - name = endp_tpl[1] - gen_name_a = endp_tpl[2] + name = endp_tpl[1] + gen_name_a = endp_tpl[2] # gen_name_b = endp_tpl[3] self.parse_command(name) genl.set_cmd(gen_name_a, self.cmd) time.sleep(sleep_time) for endp_tpl in endp_tpls: - name = endp_tpl[1] - gen_name_a = endp_tpl[2] - gen_name_b = endp_tpl[3] - cx_name = "CX_%s-%s"%(self.name_prefix, name) + name = endp_tpl[1] + gen_name_a = endp_tpl[2] + gen_name_b = endp_tpl[3] + cx_name = "CX_%s-%s" % (self.name_prefix, name) data = { "alias": cx_name, "test_mgr": "default_tm", @@ -1764,11 +1806,12 @@ class GenCXProfile(LFCliBase): time.sleep(sleep_time) for data in post_data: self.local_realm.json_post("/cli-json/show_cx", { - "test_mgr":"default_tm", + "test_mgr": "default_tm", "cross_connect": data["alias"] }) time.sleep(sleep_time) + class WifiMonitor: def __init__(self, lfclient_url, local_realm, up=True, debug_=False, resource_=1): self.debug = debug_ @@ -1780,10 +1823,10 @@ class WifiMonitor: self.flag_names = [] self.flag_mask_names = [] self.flags_mask = add_monitor.default_flags_mask - self.aid = "NA" # used when sniffing /ax radios - self.bsssid = "00:00:00:00:00:00" # used when sniffing on /ax radios + self.aid = "NA" # used when sniffing /ax radios + self.bsssid = "00:00:00:00:00:00" # used when sniffing on /ax radios - def create(self, resource_=1, channel=None, radio_="wiphy0", name_="moni0" ): + def create(self, resource_=1, channel=None, radio_="wiphy0", name_="moni0"): print("Creating monitor " + name_) self.monitor_name = name_ computed_flags = 0 @@ -1793,11 +1836,12 @@ class WifiMonitor: # we want to query the existing country code of the radio # there's no reason to change it but we get hollering from server # if we don't provide a value for the parameter - jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country"%(resource_, radio_), debug_=self.debug) + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource_, radio_), + debug_=self.debug) if jr is None: - raise ValueError("No radio %s.%s found"%(resource_, radio_)) + raise ValueError("No radio %s.%s found" % (resource_, radio_)) - eid = "1.%s.%s"%(resource_, radio_) + eid = "1.%s.%s" % (resource_, radio_) frequency = 0 country = 0 if eid in jr: @@ -1807,7 +1851,7 @@ class WifiMonitor: "shelf": 1, "resource": resource_, "radio": radio_, - "mode": 0, #"NA", #0 for AUTO or "NA" + "mode": 0, # "NA", #0 for AUTO or "NA" "channel": channel, "country": country, "frequency": self.local_realm.channel_freq(channel_=channel) @@ -1844,25 +1888,23 @@ class WifiMonitor: debug=self.debug) else: names = ",".join(desired_ports) - existing_ports = self.local_realm.json_get("/port/1/%d/%s?fields=alias"%(resource_, names), debug_=False) + existing_ports = self.local_realm.json_get("/port/1/%d/%s?fields=alias" % (resource_, names), debug_=False) if (existing_ports is None) or ("interfaces" not in existing_ports) or ("interface" not in existing_ports): print("No monitor names found to delete") return if ("interfaces" in existing_ports): - for eid,info in existing_ports["interfaces"].items(): + for eid, info in existing_ports["interfaces"].items(): LFUtils.removePort(resource=resource_, port_name=info["alias"], baseurl=self.lfclient_url, debug=self.debug) if ("interface" in existing_ports): - for eid,info in existing_ports["interface"].items(): + for eid, info in existing_ports["interface"].items(): LFUtils.removePort(resource=resource_, port_name=info["alias"], baseurl=self.lfclient_url, debug=self.debug) - - def admin_up(self): up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.monitor_name) self.local_realm.json_post("/cli-json/set_port", up_request) @@ -1875,18 +1917,18 @@ class WifiMonitor: if capname is None: raise ValueError("Need a capture file name") data = { - "shelf": 1, - "resource": 1, - "port": self.monitor_name, - "display": "NA", - "flags": 0x2, - "outfile": capname, - "duration": duration_sec - } - self.local_realm.json_post("/cli-json/sniff_port", _data= data) + "shelf": 1, + "resource": 1, + "port": self.monitor_name, + "display": "NA", + "flags": 0x2, + "outfile": capname, + "duration": duration_sec + } + self.local_realm.json_post("/cli-json/sniff_port", _data=data) + # "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur)) - # "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur)) class VAPProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -1897,7 +1939,7 @@ class VAPProfile(LFCliBase): debug_=False): super().__init__(_lfjson_host=lfclient_host, _lfjson_port=lfclient_port, _debug=debug_) self.debug = debug_ - #self.lfclient_url = lfclient_url # done in super() + # self.lfclient_url = lfclient_url # done in super() self.ssid = ssid self.ssid_pass = ssid_pass self.mode = mode @@ -2026,7 +2068,9 @@ class VAPProfile(LFCliBase): self.desired_add_vap_flags_mask.append(param_name) elif command_name == "set_port": - if (param_name not in set_port.set_port_current_flags) and (param_name not in set_port.set_port_cmd_flags) and (param_name not in set_port.set_port_interest_flags): + if (param_name not in set_port.set_port_current_flags) and ( + param_name not in set_port.set_port_cmd_flags) and ( + param_name not in set_port.set_port_interest_flags): print("Parameter name [%s] not defined in set_port.py" % param_name) if self.debug: pprint(set_port.set_port_cmd_flags) @@ -2082,18 +2126,19 @@ class VAPProfile(LFCliBase): if self.debug: pprint(command_ref) raise ValueError("flag %s not in map" % name) - #print("add-named-flags: %s %i"%(name, command_ref[name])) + # print("add-named-flags: %s %i"%(name, command_ref[name])) result |= command_ref[name] return result - def create(self, resource, radio, channel=None, up_=None, debug=False, use_ht40=True, use_ht80=True, use_ht160=False, + def create(self, resource, radio, channel=None, up_=None, debug=False, use_ht40=True, use_ht80=True, + use_ht160=False, suppress_related_commands_=True, use_radius=False, hs20_enable=False): port_list = self.local_realm.json_get("port/1/1/list") if port_list is not None: port_list = port_list['interfaces'] for port in port_list: - for k,v in port.items(): + for k, v in port.items(): if v['alias'] == self.vap_name: self.local_realm.rm_port(k, check_exists=True) if use_ht160: @@ -2116,9 +2161,10 @@ class VAPProfile(LFCliBase): self.desired_add_vap_flags.append("hs20_enable") self.desired_add_vap_flags_mask.append("hs20_enable") - #print("MODE ========= ", self.mode) + # print("MODE ========= ", self.mode) - jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource, radio), debug_=self.debug) + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource, radio), + debug_=self.debug) if jr is None: raise ValueError("No radio %s.%s found" % (resource, radio)) @@ -2132,7 +2178,7 @@ class VAPProfile(LFCliBase): "shelf": 1, "resource": resource, "radio": radio, - "mode": self.mode, #"NA", #0 for AUTO or "NA" + "mode": self.mode, # "NA", #0 for AUTO or "NA" "channel": channel, "country": country, "frequency": self.local_realm.channel_freq(channel_=channel) @@ -2193,12 +2239,11 @@ class VAPProfile(LFCliBase): wifi_extra_r.addPostData(self.wifi_extra_data) json_response = wifi_extra_r.jsonPost(debug) - port_list = self.local_realm.json_get("port/1/1/list") if port_list is not None: port_list = port_list['interfaces'] for port in port_list: - for k,v in port.items(): + for k, v in port.items(): if v['alias'] == 'br0': self.local_realm.rm_port(k, check_exists=True) time.sleep(5) @@ -2221,8 +2266,6 @@ class VAPProfile(LFCliBase): } self.local_realm.json_post("cli-json/set_port", bridge_set_port) - - if (self.up): self.admin_up(1) @@ -2239,10 +2282,11 @@ class VAPProfile(LFCliBase): # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_ports) + class VRProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, ssid="NA", ssid_pass="NA", mode=0, debug_=False): super().__init__(_lfjson_host=lfclient_host, _lfjson_port=lfclient_port, _debug=debug_) - #self.debug = debug_ + # self.debug = debug_ # self.lfclient_url = lfclient_url self.ssid = ssid self.ssid_pass = ssid_pass @@ -2268,8 +2312,8 @@ class VRProfile(LFCliBase): 'shelf': 1, 'resource': 1, 'vr-name': None, - 'local_dev': None, # outer rdd - 'remote_dev': None, # inner rdd + 'local_dev': None, # outer rdd + 'remote_dev': None, # inner rdd "x": 0, "y": 0, "width": 10, @@ -2297,7 +2341,8 @@ class VRProfile(LFCliBase): "peer_ifname": "rdd1" } # print("creating rdd0") - self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, + debug_=debug_) rdd_data = { "shelf": 1, @@ -2306,24 +2351,28 @@ class VRProfile(LFCliBase): "peer_ifname": "rdd0" } # print("creating rdd1") - self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, + debug_=debug_) self.set_port_data["port"] = "rdd0" self.set_port_data["ip_addr"] = gateway self.set_port_data["netmask"] = netmask self.set_port_data["gateway"] = gateway - self.local_realm.json_post("set_port", self.set_port_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("set_port", self.set_port_data, + suppress_related_commands_=suppress_related_commands_, debug_=debug_) self.set_port_data["port"] = "rdd1" self.set_port_data["ip_addr"] = ip_addr self.set_port_data["netmask"] = netmask self.set_port_data["gateway"] = gateway - self.local_realm.json_post("set_port", self.set_port_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("set_port", self.set_port_data, + suppress_related_commands_=suppress_related_commands_, debug_=debug_) self.created_rdds.append("rdd0") self.created_rdds.append("rdd1") - def create_vrcx(self, resource, local_dev, remote_dev, subnets, nexthop, flags, suppress_related_commands_=True, debug_=False): + def create_vrcx(self, resource, local_dev, remote_dev, subnets, nexthop, flags, suppress_related_commands_=True, + debug_=False): if self.vr_name is not None: self.vrcx_data["resource"] = resource self.vrcx_data["vr_name"] = self.vr_name @@ -2332,11 +2381,11 @@ class VRProfile(LFCliBase): self.vrcx_data["subnets"] = subnets self.vrcx_data["nexthop"] = nexthop self.vrcx_data["flags"] = flags - self.local_realm.json_post("add_vrcx", self.vrcx_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("add_vrcx", self.vrcx_data, + suppress_related_commands_=suppress_related_commands_, debug_=debug_) else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - def create(self, resource, upstream_port="eth1", debug=False, upstream_subnets="20.20.20.0/24", upstream_nexthop="20.20.20.1", local_subnets="10.40.0.0/24", local_nexthop="10.40.3.198", @@ -2350,53 +2399,57 @@ class VRProfile(LFCliBase): else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) # Create 1 rdd pair - self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network + self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, + netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network # connect rdds and upstream - self.create_vrcx(resource=resource, local_dev=upstream_port, remote_dev="NA", subnets=upstream_subnets, nexthop=upstream_nexthop, + self.create_vrcx(resource=resource, local_dev=upstream_port, remote_dev="NA", subnets=upstream_subnets, + nexthop=upstream_nexthop, flags=257, suppress_related_commands_=suppress_related_commands_, debug_=debug) - self.create_vrcx(resource=resource, local_dev="rdd0", remote_dev="rdd1", subnets=local_subnets, nexthop=local_nexthop, + self.create_vrcx(resource=resource, local_dev="rdd0", remote_dev="rdd1", subnets=local_subnets, + nexthop=local_nexthop, flags=1, suppress_related_commands_=suppress_related_commands_, debug_=debug) def cleanup(self, resource, delay=0.03): # TODO: Cleanup for VRProfile pass + class DUTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True, _local_realm=local_realm) - self.name = "NA" - self.flags = "NA" - self.img_file = "NA" - self.sw_version = "NA" - self.hw_version = "NA" - self.model_num = "NA" - self.serial_num = "NA" - self.serial_port = "NA" - self.wan_port = "NA" - self.lan_port = "NA" - self.ssid1 = "NA" - self.ssid2 = "NA" - self.ssid3 = "NA" - self.passwd1 = "NA" - self.passwd2 = "NA" - self.passwd3 = "NA" - self.mgt_ip = "NA" - self.api_id = "NA" - self.flags_mask = "NA" - self.antenna_count1 = "NA" - self.antenna_count2 = "NA" - self.antenna_count3 = "NA" - self.bssid1 = "NA" - self.bssid2 = "NA" - self.bssid3 = "NA" - self.top_left_x = "NA" - self.top_left_y = "NA" - self.eap_id = "NA" - self.flags = 0 - self.flags_mask = 0 - self.notes = [] - self.append = [] + self.name = "NA" + self.flags = "NA" + self.img_file = "NA" + self.sw_version = "NA" + self.hw_version = "NA" + self.model_num = "NA" + self.serial_num = "NA" + self.serial_port = "NA" + self.wan_port = "NA" + self.lan_port = "NA" + self.ssid1 = "NA" + self.ssid2 = "NA" + self.ssid3 = "NA" + self.passwd1 = "NA" + self.passwd2 = "NA" + self.passwd3 = "NA" + self.mgt_ip = "NA" + self.api_id = "NA" + self.flags_mask = "NA" + self.antenna_count1 = "NA" + self.antenna_count2 = "NA" + self.antenna_count3 = "NA" + self.bssid1 = "NA" + self.bssid2 = "NA" + self.bssid3 = "NA" + self.top_left_x = "NA" + self.top_left_y = "NA" + self.eap_id = "NA" + self.flags = 0 + self.flags_mask = 0 + self.notes = [] + self.append = [] def set_param(self, name, value): if (name in self.__dict__): @@ -2414,13 +2467,13 @@ class DUTProfile(LFCliBase): for param in add_dut.dut_params: if (param.name in self.__dict__): if (self.__dict__[param.name] is not None) \ - and (self.__dict__[param.name] != "NA"): + and (self.__dict__[param.name] != "NA"): data[param.name] = self.__dict__[param.name] else: print("---------------------------------------------------------") pprint(self.__dict__[param.name]) print("---------------------------------------------------------") - raise ValueError("parameter %s not in dut_profile"%param) + raise ValueError("parameter %s not in dut_profile" % param) if (flags is not None) and (int(flags) > -1): data["flags"] = flags @@ -2441,7 +2494,7 @@ class DUTProfile(LFCliBase): print("---------------------------------------------------------") self.json_post(url, data, debug_=self.debug) - if (self.notes is not None) and (len(self.notes)>0): + if (self.notes is not None) and (len(self.notes) > 0): self.json_post("/cli-json/add_dut_notes", { "dut": self.name, "text": "[BLANK]" @@ -2458,7 +2511,7 @@ class DUTProfile(LFCliBase): "dut": self.name, "text-64": notebytes.decode('ascii') }, self.debug) - if (self.append is not None) and (len(self.append)>0): + if (self.append is not None) and (len(self.append) > 0): notebytes = None for line in self.append: notebytes = base64.b64encode(line.encode('ascii')) @@ -2472,6 +2525,7 @@ class DUTProfile(LFCliBase): "text-64": notebytes.decode('ascii') }, self.debug) + class TestGroupProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, test_group_name=None, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) @@ -2487,7 +2541,7 @@ class TestGroupProfile(LFCliBase): def quiesce_group(self): if self.group_name is not None: - self.local_realm.json_post("/cli-json/quiesce_group", {"name": self.group_name}) + self.local_realm.json_post("/cli-json/quiesce_group", {"name": self.group_name}) else: raise ValueError("test_group name must be set.") @@ -2520,7 +2574,7 @@ class TestGroupProfile(LFCliBase): if test_groups is not None and "groups" in test_groups: test_groups = test_groups["groups"] for group in test_groups: - for k,v in group.items(): + for k, v in group.items(): if v['name'] == self.group_name: return True else: @@ -2541,7 +2595,7 @@ class TestGroupProfile(LFCliBase): if test_groups is not None: test_groups = test_groups["groups"] for group in test_groups: - for k,v in group.items(): + for k, v in group.items(): if v['name'] == self.group_name: return v['cross connects'] @@ -2554,6 +2608,7 @@ class FIOEndpProfile(LFCliBase): Very often you will create the FileIO writer profile first so that it creates the data that a reader profile will subsequently use. """ + def __init__(self, lfclient_host, lfclient_port, local_realm, io_direction="write", debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) self.local_realm = local_realm @@ -2568,8 +2623,8 @@ class FIOEndpProfile(LFCliBase): self.min_write_rate_bps = 1000 * 1000 * 1000 self.max_write_rate_bps = 1000 * 1000 * 1000 - self.file_num = 10 # number of files to write - self.directory = None # directory like /mnt/lf/$endp_name + self.file_num = 10 # number of files to write + self.directory = None # directory like /mnt/lf/$endp_name # this refers to locally mounted directories presently used for writing # you would set this when doing read tests simultaneously to write tests @@ -2578,14 +2633,14 @@ class FIOEndpProfile(LFCliBase): # /mnt/lf/ro_300GB_001, this overwrites a readers directory name to wo_300GB_001 self.mount_dir = "AUTO" - self.server_mount = None # like cifs://10.0.0.1/bashful or 192.168.1.1:/var/tmp + self.server_mount = None # like cifs://10.0.0.1/bashful or 192.168.1.1:/var/tmp self.mount_options = None self.iscsi_vol = None self.retry_timer_ms = 2000 - self.io_direction = io_direction # read / write + self.io_direction = io_direction # read / write self.quiesce_ms = 3000 self.pattern = "increasing" - self.file_prefix = "AUTO" # defaults to endp_name + self.file_prefix = "AUTO" # defaults to endp_name self.cx_prefix = "wo_" self.created_cx = {} @@ -2646,13 +2701,13 @@ class FIOEndpProfile(LFCliBase): "cx_name": self.created_cx[cx_name] } self.json_post(req_url, data) - #pprint(data) + # pprint(data) req_url = "cli-json/rm_endp" data = { "endp_name": cx_name } self.json_post(req_url, data) - #pprint(data) + # pprint(data) def create(self, ports=[], connections_per_port=1, sleep_time=.5, debug_=False, suppress_related_commands_=None): cx_post_data = [] @@ -2665,9 +2720,10 @@ class FIOEndpProfile(LFCliBase): else: raise ValueError("Unexpected name for port_name %s" % port_name) if self.directory is None or self.server_mount is None or self.fs_type is None: - raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % (self.directory, self.server_mount, self.fs_type)) + raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % ( + self.directory, self.server_mount, self.fs_type)) endp_data = { - "alias": self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "alias": self.cx_prefix + name + "_" + str(num_connection) + "_fio", "shelf": shelf, "resource": resource, "port": name, @@ -2689,11 +2745,12 @@ class FIOEndpProfile(LFCliBase): endp_data["directory"] = "/mnt/lf/wo_" + name + "_" + str(num_connection) + "_fio" url = "cli-json/add_file_endp" - self.local_realm.json_post(url, endp_data, debug_=False, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, endp_data, debug_=False, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) data = { - "name": self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "name": self.cx_prefix + name + "_" + str(num_connection) + "_fio", "io_direction": self.io_direction, "num_files": 5 } @@ -2709,17 +2766,19 @@ class FIOEndpProfile(LFCliBase): name = self.local_realm.name_to_eid(port_name)[2] endp_data = { - "alias": "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "alias": "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio", "test_mgr": "default_tm", - "tx_endp": self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "tx_endp": self.cx_prefix + name + "_" + str(num_connection) + "_fio", "rx_endp": "NA" } cx_post_data.append(endp_data) - self.created_cx[self.cx_prefix + name + "_" + str(num_connection) + "_fio" ] = "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" + self.created_cx[self.cx_prefix + name + "_" + str( + num_connection) + "_fio"] = "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" for cx_data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, cx_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) @@ -2746,8 +2805,8 @@ class MACVLANProfile(LFCliBase): self.ip_list = [] self.COMMANDS = ["set_port"] self.desired_set_port_cmd_flags = [] - self.desired_set_port_current_flags = [] # do not default down, "if_down" - self.desired_set_port_interest_flags = ["current_flags"] # do not default down, "ifdown" + self.desired_set_port_current_flags = [] # do not default down, "if_down" + self.desired_set_port_interest_flags = ["current_flags"] # do not default down, "ifdown" self.set_port_data = { "shelf": 1, "resource": 1, @@ -2835,7 +2894,8 @@ class MACVLANProfile(LFCliBase): self.desired_set_port_interest_flags.append("ip_address") self.desired_set_port_interest_flags.append("ip_Mask") self.desired_set_port_interest_flags.append("ip_gateway") - self.ip_list = LFUtils.gen_ip_series(ip_addr=self.first_ip_addr, netmask=self.netmask, num_ips=self.num_macvlans) + self.ip_list = LFUtils.gen_ip_series(ip_addr=self.first_ip_addr, netmask=self.netmask, + num_ips=self.num_macvlans) self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags, set_port.set_port_current_flags) @@ -2854,7 +2914,7 @@ class MACVLANProfile(LFCliBase): "resource": self.resource, "mac": "xx:xx:xx:*:*:xx", "port": self.local_realm.name_to_eid(self.macvlan_parent)[2], - "index": int(self.desired_macvlans[i][self.desired_macvlans[i].index('#')+1:]), + "index": int(self.desired_macvlans[i][self.desired_macvlans[i].index('#') + 1:]), "flags": None } if admin_down: @@ -2862,11 +2922,12 @@ class MACVLANProfile(LFCliBase): else: data["flags"] = 0 self.created_macvlans.append("%s.%s.%s#%d" % (self.shelf, self.resource, - self.macvlan_parent, int(self.desired_macvlans[i][self.desired_macvlans[i].index('#')+1:]))) + self.macvlan_parent, int( + self.desired_macvlans[i][self.desired_macvlans[i].index('#') + 1:]))) self.local_realm.json_post(req_url, data) time.sleep(sleep_time) - LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=self.created_macvlans) + LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=self.created_macvlans) print(self.created_macvlans) time.sleep(5) @@ -2893,7 +2954,6 @@ class MACVLANProfile(LFCliBase): # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.created_macvlans) - def admin_up(self): for macvlan in self.created_macvlans: self.local_realm.admin_up(macvlan) @@ -2902,6 +2962,7 @@ class MACVLANProfile(LFCliBase): for macvlan in self.created_macvlans: self.local_realm.admin_down(macvlan) + class PacketFilter(): def get_filter_wlan_assoc_packets(self, ap_mac, sta_mac): @@ -2926,6 +2987,7 @@ class PacketFilter(): return lines + class PortUtils(): def __init__(self, local_realm): self.local_realm = local_realm @@ -2970,6 +3032,7 @@ class PortUtils(): else: raise ValueError("Port name required") + class HTTPProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) @@ -3004,7 +3067,7 @@ class HTTPProfile(LFCliBase): if passes == expected_passes: return True else: - print(list(debug_info), " Endps in this list showed errors getting to its URL") # %s") % self.url) + print(list(debug_info), " Endps in this list showed errors getting to its URL") # %s") % self.url) return False def start_cx(self): @@ -3039,19 +3102,19 @@ class HTTPProfile(LFCliBase): "cx_name": self.created_cx[cx_name] } self.json_post(req_url, data) - #pprint(data) + # pprint(data) req_url = "cli-json/rm_endp" data = { "endp_name": cx_name } self.json_post(req_url, data) - #pprint(data) + # pprint(data) def map_sta_ips(self, sta_list=[]): for sta_eid in sta_list: eid = self.local_realm.name_to_eid(sta_eid) sta_list = self.json_get("/port/%s/%s/%s?fields=alias,ip" % - (eid[0], eid[1], eid[2])) + (eid[0], eid[1], eid[2])) if sta_list['interface'] is not None: self.ip_map[sta_list['interface']['alias']] = sta_list['interface']['ip'] @@ -3063,7 +3126,7 @@ class HTTPProfile(LFCliBase): url = None if i != len(list(self.ip_map)) - 1: port_name = list(self.ip_map)[i] - ip_addr = self.ip_map[list(self.ip_map)[i+1]] + ip_addr = self.ip_map[list(self.ip_map)[i + 1]] else: port_name = list(self.ip_map)[i] ip_addr = self.ip_map[list(self.ip_map)[0]] @@ -3084,7 +3147,7 @@ class HTTPProfile(LFCliBase): if ftp: self.port_util.set_ftp(port_name=name, resource=resource, on=True) if user is not None and passwd is not None and source is not None: - url = "%s ftp://%s:%s@%s%s %s" % (self.direction, user, passwd, ip_addr, source, self.dest) + url = "%s ftp://%s:%s@%s%s %s" % (self.direction, user, passwd, ip_addr, source, self.dest) else: raise ValueError("user: %s, passwd: %s, and source: %s must all be set" % (user, passwd, source)) if not http and not ftp: @@ -3105,7 +3168,8 @@ class HTTPProfile(LFCliBase): "proxy_auth_type": 0x200 } url = "cli-json/add_l4_endp" - self.local_realm.json_post(url, endp_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, endp_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) endp_data = { @@ -3119,7 +3183,8 @@ class HTTPProfile(LFCliBase): for cx_data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, cx_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) @@ -3152,14 +3217,14 @@ class StationProfile: self.ssid_pass = ssid_pass self.mode = mode self.up = up - self.resource=resource - self.shelf=shelf + self.resource = resource + self.shelf = shelf self.dhcp = dhcp self.security = security self.local_realm = local_realm self.use_ht160 = use_ht160 self.COMMANDS = ["add_sta", "set_port"] - self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] + self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.desired_add_sta_flags_mask = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.number_template = number_template_ self.station_names = [] # eids, these are created station names @@ -3219,7 +3284,7 @@ class StationProfile: pairwise="CCMP TKIP", group="CCMP TKIP", psk="[BLANK]", - wep_key="[BLANK]", #wep key + wep_key="[BLANK]", # wep key ca_cert="[BLANK]", eap="TTLS", identity="testuser", @@ -3295,7 +3360,7 @@ class StationProfile: self.desired_add_sta_flags_mask.remove(name) if security_type != "open": self.desired_add_sta_flags.append(types[security_type]) - #self.set_command_flag("add_sta", types[security_type], 1) + # self.set_command_flag("add_sta", types[security_type], 1) self.desired_add_sta_flags_mask.append(types[security_type]) else: passwd = "[BLANK]" @@ -3305,7 +3370,7 @@ class StationProfile: if security_type == "wpa3": self.set_command_param("add_sta", "ieee80211w", 2) - #self.add_sta_data["key"] = passwd + # self.add_sta_data["key"] = passwd def set_command_param(self, command_name, param_name, param_value): # we have to check what the param name is @@ -3344,7 +3409,9 @@ class StationProfile: self.desired_add_sta_flags_mask.append(param_name) elif command_name == "set_port": - if (param_name not in set_port.set_port_current_flags) and (param_name not in set_port.set_port_cmd_flags) and (param_name not in set_port.set_port_interest_flags): + if (param_name not in set_port.set_port_current_flags) and ( + param_name not in set_port.set_port_cmd_flags) and ( + param_name not in set_port.set_port_interest_flags): print("Parameter name [%s] not defined in set_port.py" % param_name) if self.debug: pprint(set_port.set_port_cmd_flags) @@ -3367,7 +3434,8 @@ class StationProfile: elif value == 0: self.desired_set_port_interest_flags.remove(param_name) else: - raise ValueError("Unknown param name: "+param_name) + raise ValueError("Unknown param name: " + param_name) + # use this for hinting station name; stations begin with 'sta', the # stations created with a prefix '0100' indicate value 10100 + n with # resulting substring(1,) applied; station 900 becomes 'sta1000' @@ -3421,8 +3489,7 @@ class StationProfile: self.local_realm.rm_port(port_eid, check_exists=True, debug_=debug_) # And now see if they are gone - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) - + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) # Checks for errors in initialization values and creates specified number of stations using init parameters def create(self, radio, @@ -3466,7 +3533,7 @@ class StationProfile: self.desired_add_sta_flags.append("create_admin_down") # create stations down, do set_port on them, then set stations up - self.add_sta_data["flags"] = self.add_named_flags(self.desired_add_sta_flags, add_sta.add_sta_flags) + self.add_sta_data["flags"] = self.add_named_flags(self.desired_add_sta_flags, add_sta.add_sta_flags) self.add_sta_data["flags_mask"] = self.add_named_flags(self.desired_add_sta_flags_mask, add_sta.add_sta_flags) self.add_sta_data["radio"] = radio_port @@ -3486,14 +3553,14 @@ class StationProfile: # these are unactivated LFRequest objects that we can modify and # re-use inside a loop, reducing the number of object creations add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta", debug_=debug) - set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port",debug_=debug) - wifi_extra_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_wifi_extra",debug_=debug) + set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port", debug_=debug) + wifi_extra_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_wifi_extra", debug_=debug) my_sta_names = [] - #add radio here + # add radio here if (num_stations > 0) and (len(sta_names_) < 1): - #print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") + # print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") my_sta_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template)) - #print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") + # print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") else: my_sta_names = sta_names_ @@ -3533,7 +3600,7 @@ class StationProfile: self.add_sta_data["shelf"] = radio_shelf self.add_sta_data["resource"] = radio_resource self.add_sta_data["radio"] = radio_port - self.add_sta_data["sta_name"] = name # for create station calls + self.add_sta_data["sta_name"] = name # for create station calls self.set_port_data["port"] = name # for set_port calls. self.set_port_data["shelf"] = radio_shelf self.set_port_data["resource"] = radio_resource @@ -3547,7 +3614,7 @@ class StationProfile: pprint(self.set_port_data) print("- ~3254 - - - - - - - - - - - - - - - - - - - ") if dry_run: - print("dry run: not creating "+eidn) + print("dry run: not creating " + eidn) continue # print("- 3264 - ## %s ## add_sta_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) @@ -3556,9 +3623,9 @@ class StationProfile: # print("- ~3264 - %s - add_sta_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) time.sleep(0.01) set_port_r.addPostData(self.set_port_data) - #print("- 3270 -- %s -- set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) + # print("- 3270 -- %s -- set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) json_response = set_port_r.jsonPost(debug) - #print("- ~3270 - %s - set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) + # print("- ~3270 - %s - set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) time.sleep(0.01) self.wifi_extra_data["resource"] = radio_resource @@ -3571,7 +3638,7 @@ class StationProfile: self.station_names.append("%s.%s.%s" % (radio_shelf, radio_resource, name)) time.sleep(sleep_time) - #print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - "%eidn) + # print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - "%eidn) LFUtils.wait_until_ports_appear(self.lfclient_url, my_sta_names) # and set ports up diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 7c3aacda..fa48d365 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -259,6 +259,7 @@ python3 ./test_ipv4_variable_time.py output_format=output, script_name='test_ipv4_variable_time', arguments=args) + print(ip_var_test.cx_profile.create()) ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From 47d5e09c3114b99cd2a5e67c09850ecd8386897a Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 18 Jan 2021 14:02:06 -0800 Subject: [PATCH 024/848] rename show to monitor --- py-json/realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index bb9acf93..a2ed7dcb 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1137,7 +1137,7 @@ class L3CXProfile(BaseProfile): monitor_interval=1, col_names=None, created_cx=None, - show=True, + monitor=True, report_file=None, output_format=None, script_name=None, @@ -1183,7 +1183,7 @@ class L3CXProfile(BaseProfile): if "endpoint" not in response: print(response) raise ValueError("no endpoint?") - if show: + if monitor: print(response) t = datetime.datetime.now() timestamps.append(t) From 5e3b54aece82d7160baa04c41182eb7f65e92d8a Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 18 Jan 2021 14:35:25 -0800 Subject: [PATCH 025/848] small fix to variable_time --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index fa48d365..677bcf1b 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -259,7 +259,7 @@ python3 ./test_ipv4_variable_time.py output_format=output, script_name='test_ipv4_variable_time', arguments=args) - print(ip_var_test.cx_profile.create()) + ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From e02304e60e31ed988133d5643b05a94500a941b5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 18 Jan 2021 17:38:35 -0700 Subject: [PATCH 026/848] cisco_wifi_ctl.py : temporary timing fix for controller lf_cisco_power.py : loggin for calc_dbm_beacon --- cisco_wifi_ctl.py | 6 +++--- lf_cisco_power.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 9f3a4357..083a5c5d 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -349,7 +349,7 @@ def main(): found_escape = False if j == 5: - logg.info("9800 timed out looking for CCP,CCP_EN,User:,Password:,CCP_CONFIG loop_count {} i {} j {} before {} after {}".format(CCP,CCP_EN,CCP_CONFIG,loop_count,i,j,egg.before,egg.after)) + logg.info("9800 timed out looking for CCP :{},CCP_EN: {},CCP_CONFIG: {} loop_count {} i {} j {} before {} after {}".format(CCP,CCP_EN,CCP_CONFIG,loop_count,i,j,egg.before,egg.after)) logg.info("9800 Closing the connection and try to re-establish loop_count {} i {} j {}".format(loop_count,i,j)) egg.close(force = True) sleep(1) @@ -567,9 +567,9 @@ def main(): if i == 0: logg.info("9800 found Escape character is '^] i:{} before: {} after: {}".format(i,egg.before,egg.after)) - #egg.sendline(CR) + egg.sendline(CR) # 1/18/2021 - may need a bit more logic found_escape = True - sleep(0.1) + sleep(0.2) j = egg.expect_exact([CCP,CCP_EN,"User:","Password:",CCP_CONFIG,pexpect.TIMEOUT],timeout=3) sleep(0.1) if j == 0: diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 5d66f05e..a45741c9 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1339,7 +1339,7 @@ def main(): pi = int(pathloss) ag = int(antenna_gain) calc_dbm_beacon = int(beacon_sig) + pi + rssi_adj + ag - logg.info("calc_dbm_beacon".format(calc_dbm_beacon)) + logg.info("calc_dbm_beacon {}".format(calc_dbm_beacon)) logg.info("sig: %s"%sig) calc_dbm = int(sig) + pi + rssi_adj + ag From 1ed4cc95777d24a73d2d92da2c5021e875164dbc Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Mon, 18 Jan 2021 14:12:24 -0800 Subject: [PATCH 027/848] test_status_msg.py: adds processing for --key --- py-scripts/test_status_msg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py-scripts/test_status_msg.py b/py-scripts/test_status_msg.py index a055d726..d76c5022 100755 --- a/py-scripts/test_status_msg.py +++ b/py-scripts/test_status_msg.py @@ -310,7 +310,10 @@ Actions can be: if args.session is None: print("requires --session") return - response_o = status_messages.json_get("/status-msg/"+args.session) + if args.key is None: + print("requires --key") + return + response_o = status_messages.json_get("/status-msg/%s/%s"%(args.session, args.key)) pprint(response_o) return From f2de08b5959fe73c4d08712ad797a552445317f5 Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Tue, 19 Jan 2021 15:14:07 +0530 Subject: [PATCH 028/848] updated file --- py-scripts/netgear_dfs.py | 519 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 519 insertions(+) create mode 100644 py-scripts/netgear_dfs.py diff --git a/py-scripts/netgear_dfs.py b/py-scripts/netgear_dfs.py new file mode 100644 index 00000000..f022513c --- /dev/null +++ b/py-scripts/netgear_dfs.py @@ -0,0 +1,519 @@ +"""under progress""" + +import os +import paramiko +import time +import threading +from queue import Queue +from cx_time import IPv4Test +import datetime + + +class DFS_TESTING: + def _init_(self): + pass + + def hackrf_status_off(self): + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + + def check_radio_on_off(self, x): + self.x = x + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('conf_get system:wlanSettings:wlanSettingTable:wlan0:radioStatus') + output = stdout.readlines() + print('\n'.join(output)) + self.x = output + time.sleep(1) + return self.x + + def exit_from_ap(self): + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('exit') + time.sleep(1) + + def check_for_channels(self, q): + self.q = q + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel ') + output = stdout.readlines() + # print('\n'.join(output)) + self.q = output + time.sleep(1) + return self.q + + def set_channel_in_ap_at_52(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def set_channel_in_ap_at_100(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def set_channel_in_ap_at_116(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 116") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def set_channel_in_ap_at_136(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 136") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def create_station_on_GUI_1(self): + obj = IPv4Test(_host="localhost", + _port=8080, + _ssid="TestAP22", + _password="[BLANK]", + _security="open", + _radio="wiphy0") + obj.cleanup(obj.sta_list) + obj.build() + obj.station_profile.admin_up() + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(5) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + print(var_1) + + + def generate_radar_at_ch52(self, r): + self.r = r + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.r = "Radar detected" + return self.r + + def generate_radar_at_ch56(self, q): + self.q = q + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.q = "Radar detected" + return self.q + + def generate_radar_at_ch60(self, w): + self.w = w + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.w = "Radar detected" + return self.w + + def generate_radar_at_ch64(self, e): + self.e = e + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.e = "Radar detected" + return self.e + + def generate_radar_at_ch100(self, f): + self.f = f + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.f = "Radar received" + return self.f + + def generate_radar_at_ch104(self, t): + self.t = t + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.t = "Radar detected" + return self.t + + def generate_radar_at_ch108(self, u): + self.u = u + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.u = "Radar detected" + return self.u + + def generate_radar_at_ch112(self, i): + self.i = i + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.i = "Radar detected" + return self.i + + def generate_radar_at_ch116(self, o): + self.o = o + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5580000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.o = "Radar detected" + return self.o + + def generate_radar_at_ch120(self, p): + self.p = p + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.p = "Radar detected" + return self.p + + def generate_radar_at_ch124(self, a): + self.a = a + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.a = "Radar detected" + return self.a + + def generate_radar_at_ch128(self, s): + self.s = s + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.s = "Radar detected" + return self.s + + def generate_radar_at_ch132(self, d): + self.d = d + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.d = "Radar detected" + return self.d + + def generate_radar_at_ch136(self, h): + self.h = h + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.h = "Radar detected" + return self.h + + def generate_radar_at_ch140(self, j): + self.j = j + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.j = "Radar detected" + return self.j + + def station_clean(self): + obj = IPv4Test(_host="localhost", + _port=8080, + _ssid="TestAP22", + _password="[BLANK]", + _security="open", + _radio="wiphy0") + obj.cleanup(obj.sta_list) + var_1 = "station cleaned" + print(var_1) + + def wait_for_ip(self): + obj = IPv4Test(_host="localhost", + _port=8080, + _ssid="TestAP22", + _password="[BLANK]", + _security="open", + _radio="wiphy0") + + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(5) + + def check_log_channel(self, r): + self.r = r + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(1) + self.r = output + return self.r + + def check_for_all_logs(self, r): + self.r = r + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(1) + self.r = output + return self.r + + + +def main(): + que = Queue() + threads_list = [] + dfs = DFS_TESTING() + + print("checking hackrf is oN/OFF") + print("Hackrf is ON") + print("press s --> enter --> q to stop hackrf") + dfs.hackrf_status_off() + + print("Now hackrf is OFF") + + time.sleep(2) + + print("checking if all radios is ON/OFF") + t1 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_radio_on_off(arg1)), args=(que, "")) + t1.start() + threads_list.append(t1) + t1.join() + x = que.get() + # print("result", x) + new_list = [] + new_list_1 = [] + for element in x: + new_list.append(element.strip()) + # print(new_list[0]) + new_list_1 = new_list[0].split() + # print("elements", new_list_1) + + if (new_list_1[1] == "1"): + print("Radio is ON") + else: + print("Radio is OFF") + + time.sleep(2) + + thr_1 = threading.Thread(target=dfs.exit_from_ap()) + thr_1.start() + thr_1.join() + print("exit") + + time.sleep(10) + + t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_channels(arg1)), args=(que, "")) + t2.start() + threads_list.append(t2) + t2.join() + y = que.get() + # print("Channel available are", y) + # print(type(y)) + a_list = [] + for i in y: + a_list.append(i.strip()) + print("hi", a_list) + + if any("Channel 52 : 5.26 GHz" in s for s in a_list): + print("set channel to 52") + else: + print("check for some another channel") + + time.sleep(2) + + thr_2 = threading.Thread(target=dfs.exit_from_ap()) + thr_2.start() + thr_2.join() + print("exit") + + time.sleep(20) + + t3 = threading.Thread(target=dfs.set_channel_in_ap_at_52()) + t3.start() + t3.join() + print("channel set to 52") + + time.sleep(10) + + thr_3 = threading.Thread(target=dfs.exit_from_ap()) + thr_3.start() + thr_3.join() + print("exit") + + time.sleep(10) + + t4 = threading.Thread(target=dfs.create_station_on_GUI_1()) + t4.start() + t4.join() + print("station created") + + time.sleep(30) + + t5 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t5.start() + t5.join() + print("radar generated") + + time.sleep(60) + + t10 = threading.Thread(target=dfs.wait_for_ip()) + t10.start() + t10.join() + + print("checking hackrf is oN/OFF") + print("Hackrf is ON") + print("press s --> enter --> q to stop hackrf") + t6 = threading.Thread(dfs.hackrf_status_off()) + t6.start() + t6.join() + print("Now hackrf is OFF") + + print("setting channel to 100") + + t7 = threading.Thread(target=dfs.set_channel_in_ap_at_100()) + t7.start() + t7.join() + print("channel set at 100") + + time.sleep(30) + + t8 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) + t8.start() + t8.join() + print("radar generated") + + time.sleep(60) + + t11 = threading.Thread(target=dfs.wait_for_ip()) + t11.start() + t11.join() + + print("done") + + t12 = threading.Thread(target=dfs.set_channel_in_ap_at_116()) + t12.start() + t12.join() + print("channel set hogya at 116") + + time.sleep(30) + + t13 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) + t13.start() + t13.join() + print("radar generated") + + time.sleep(60) + + t14 = threading.Thread(target=dfs.wait_for_ip()) + t14.start() + t14.join() + + print("done") + + t15 = threading.Thread(target=dfs.set_channel_in_ap_at_136()) + t15.start() + t15.join() + + time.sleep(30) + + t16 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) + t16.start() + t16.join() + print("radar generated") + + time.sleep(60) + + t17 = threading.Thread(target=dfs.wait_for_ip()) + t17.start() + t17.join() + + print("done") + + t18 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_log_channel(arg1)), args=(que, "")) + t18.start() + threads_list.append(t18) + t18.join() + var = que.get() + print(type(var)) + for i in range(len(var)): + var[i] = var[i] + "
" + #print(var[i]) + print(var) + + listToStr = ' '.join([str(elem) for elem in var]) + print(listToStr) + + t19 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_all_logs(arg1)), args=(que, "")) + t19.start() + threads_list.append(t19) + t19.join() + var_4 = que.get() + + for i in range(len(var_4)): + var_4[i] = var_4[i] + "
" + + all_log = ' '.join([str(elem) for elem in var_4]) + + now = datetime.datetime.now() + print("Current date and time : ") + date = now.strftime("%Y-%m-%d %H:%M:%S") + + html_content = "DFS TEST

Dynamic Frequency Selection

" + date + "



Objective

The DFS Test is designed to test the Performance of the Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1

Testing Results

" + all_log + "

" + listToStr + "

" + + + file = open("sample.html", "w") + file.write(html_content) + file.close() + + print("Test Finished") + +if __name__ == '__main__': + main() From 9fc30c816e9c07423365298b214797d831b32a4b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 07:05:16 -0700 Subject: [PATCH 029/848] lf_cisco_power.py: arg to allow print of output lf_portmod.pl to read command syntax and output of lf_portmod.pl --- lf_cisco_power.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index a45741c9..c1e7cfcb 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -220,6 +220,8 @@ def usage(): print('-e','--email', "--email user== passwd== to== smtp== port== 465 (SSL)") print('-ccp','--prompt', "--prompt controller prompt default WLC") print('--beacon_dbm_diff', "--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured") + print('--show_lf_portmod'," show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") + print("-h|--help") @@ -302,6 +304,8 @@ def main(): parser.add_argument('-e','--email', action='append', nargs=1, type=str, help="--email user== passwd== to== smtp== port== 465 (SSL)") parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") + parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") + #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] #print(current_time) @@ -1194,8 +1198,10 @@ def main(): port_stats = subprocess.run(["./lf_portmod.pl", "--manager", lfmgr, "--card", lfresource, "--port_name", lfstation, "--cli_cmd", "probe_port 1 %s %s"%(lfresource, lfstation)],capture_output=True, check=True) pss = port_stats.stdout.decode('utf-8', 'ignore') - logg.info("./lf_portmod.pl --manager {} --card {} --port_name {} --cli_cmd probe_port 1 {} {}".format(lfmgr, lfresource, lfstation,lfresource,lfstation)) - logg.info(pss) + # for debug: print the output of lf_portmod.pl and the command used + if (args.show_lf_portmod): + logg.info("./lf_portmod.pl --manager {} --card {} --port_name {} --cli_cmd probe_port 1 {} {}".format(lfmgr, lfresource, lfstation,lfresource,lfstation)) + logg.info(pss) foundit = False for line in pss.splitlines(): From fc70cf6ab007094dc169206a8c5f2dc8faa28789 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 07:12:12 -0700 Subject: [PATCH 030/848] Netgear_dfs.py : this was pulled on git pull --rebase and showed un-committed will push and it may be reverted if needed. --- py-scripts/Netgear_dfs.py | 417 ++++++++++++++++++++++---------------- 1 file changed, 238 insertions(+), 179 deletions(-) diff --git a/py-scripts/Netgear_dfs.py b/py-scripts/Netgear_dfs.py index 8e790463..f022513c 100644 --- a/py-scripts/Netgear_dfs.py +++ b/py-scripts/Netgear_dfs.py @@ -1,18 +1,19 @@ -"""need to be modified not for testing """ +"""under progress""" import os import paramiko import time -from subprocess import Popen, PIPE, STDOUT import threading from queue import Queue from cx_time import IPv4Test +import datetime + + class DFS_TESTING: - def __init__(self): + def _init_(self): pass def hackrf_status_off(self): - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -31,33 +32,66 @@ class DFS_TESTING: time.sleep(1) return self.x + def exit_from_ap(self): + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('exit') + time.sleep(1) + def check_for_channels(self, q): self.q = q ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('iwlist channel') + stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel ') output = stdout.readlines() # print('\n'.join(output)) self.q = output time.sleep(1) return self.q - def set_channel_in_ap(self, w): - self.w = w - cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52;conf_save" + def set_channel_in_ap_at_52(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command(cmd) + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52") output = stdout.readlines() print('\n'.join(output)) - self.w = output - time.sleep(1) - return self.w + time.sleep(20) - def create_station_on_GUI(self, w): - self.w = w + def set_channel_in_ap_at_100(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def set_channel_in_ap_at_116(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 116") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def set_channel_in_ap_at_136(self): + # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 136") + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(20) + + def create_station_on_GUI_1(self): obj = IPv4Test(_host="localhost", _port=8080, _ssid="TestAP22", @@ -71,8 +105,8 @@ class DFS_TESTING: time.sleep(5) var = obj.json_get("/port/1/1/sta0000?fields=channel") var_1 = (var['interface']['channel']) - self.w = var_1 - return self.w + print(var_1) + def generate_radar_at_ch52(self, r): self.r = r @@ -84,8 +118,8 @@ class DFS_TESTING: self.r = "Radar detected" return self.r - def generate_radar_at_ch56(self,q): - self.q =q + def generate_radar_at_ch56(self, q): + self.q = q cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -95,7 +129,7 @@ class DFS_TESTING: self.q = "Radar detected" return self.q - def generate_radar_at_ch60(self,w): + def generate_radar_at_ch60(self, w): self.w = w cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" # print("Current working directory: {0}".format(os.getcwd())) @@ -105,7 +139,7 @@ class DFS_TESTING: self.w = "Radar detected" return self.w - def generate_radar_at_ch64(self,e): + def generate_radar_at_ch64(self, e): self.e = e cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" # print("Current working directory: {0}".format(os.getcwd())) @@ -115,7 +149,7 @@ class DFS_TESTING: self.e = "Radar detected" return self.e - def generate_radar_at_ch100(self,f): + def generate_radar_at_ch100(self, f): self.f = f cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" # print("Current working directory: {0}".format(os.getcwd())) @@ -125,7 +159,7 @@ class DFS_TESTING: self.f = "Radar received" return self.f - def generate_radar_at_ch104(self,t): + def generate_radar_at_ch104(self, t): self.t = t cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" # print("Current working directory: {0}".format(os.getcwd())) @@ -135,8 +169,8 @@ class DFS_TESTING: self.t = "Radar detected" return self.t - def generate_radar_at_ch108(self,u): - self.u=u + def generate_radar_at_ch108(self, u): + self.u = u cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -145,8 +179,8 @@ class DFS_TESTING: self.u = "Radar detected" return self.u - def generate_radar_at_ch112(self,i): - self.i=i + def generate_radar_at_ch112(self, i): + self.i = i cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -155,9 +189,9 @@ class DFS_TESTING: self.i = "Radar detected" return self.i - def generate_radar_at_ch116(self,o): - self.o =o - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" + def generate_radar_at_ch116(self, o): + self.o = o + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5580000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') # print("Current working directory: {0}".format(os.getcwd())) @@ -165,18 +199,18 @@ class DFS_TESTING: self.o = "Radar detected" return self.o - def generate_radar_at_ch120(self,p): - self.p=p + def generate_radar_at_ch120(self, p): + self.p = p cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" - #print("Current working directory: {0}".format(os.getcwd())) + # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') # print("Current working directory: {0}".format(os.getcwd())) os.system(cmd) self.p = "Radar detected" return self.p - def generate_radar_at_ch124(self,a): - self.a=a + def generate_radar_at_ch124(self, a): + self.a = a cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -185,8 +219,8 @@ class DFS_TESTING: self.a = "Radar detected" return self.a - def generate_radar_at_ch128(self,s): - self.s=s + def generate_radar_at_ch128(self, s): + self.s = s cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -195,7 +229,7 @@ class DFS_TESTING: self.s = "Radar detected" return self.s - def generate_radar_at_ch132(self,d): + def generate_radar_at_ch132(self, d): self.d = d cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" # print("Current working directory: {0}".format(os.getcwd())) @@ -205,8 +239,8 @@ class DFS_TESTING: self.d = "Radar detected" return self.d - def generate_radar_at_ch136(self,h): - self.h=h + def generate_radar_at_ch136(self, h): + self.h = h cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" # print("Current working directory: {0}".format(os.getcwd())) os.chdir('/usr/lib64/python2.7/site-packages/') @@ -215,7 +249,7 @@ class DFS_TESTING: self.h = "Radar detected" return self.h - def generate_radar_at_ch140(self,j): + def generate_radar_at_ch140(self, j): self.j = j cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" # print("Current working directory: {0}".format(os.getcwd())) @@ -225,8 +259,7 @@ class DFS_TESTING: self.j = "Radar detected" return self.j - def monitor_station_channel(self,m): - self.m = m + def station_clean(self): obj = IPv4Test(_host="localhost", _port=8080, _ssid="TestAP22", @@ -235,15 +268,37 @@ class DFS_TESTING: _radio="wiphy0") obj.cleanup(obj.sta_list) var_1 = "station cleaned" - self.m = var_1 - return self.m + print(var_1) - def check_log(self, r): + def wait_for_ip(self): + obj = IPv4Test(_host="localhost", + _port=8080, + _ssid="TestAP22", + _password="[BLANK]", + _security="open", + _radio="wiphy0") + + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(5) + + def check_log_channel(self, r): self.r = r ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep Radar') + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(1) + self.r = output + return self.r + + def check_for_all_logs(self, r): + self.r = r + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') output = stdout.readlines() print('\n'.join(output)) time.sleep(1) @@ -254,6 +309,7 @@ class DFS_TESTING: def main(): que = Queue() + threads_list = [] dfs = DFS_TESTING() print("checking hackrf is oN/OFF") @@ -263,7 +319,8 @@ def main(): print("Now hackrf is OFF") - threads_list = [] + time.sleep(2) + print("checking if all radios is ON/OFF") t1 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_radio_on_off(arg1)), args=(que, "")) t1.start() @@ -284,43 +341,72 @@ def main(): else: print("Radio is OFF") + time.sleep(2) + + thr_1 = threading.Thread(target=dfs.exit_from_ap()) + thr_1.start() + thr_1.join() + print("exit") + + time.sleep(10) + t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_channels(arg1)), args=(que, "")) t2.start() threads_list.append(t2) t2.join() y = que.get() - print("Channel available are", y) - copy_y = y[:] - del copy_y[21:len(copy_y)] - # print("hi*********************" ,copy_y) + # print("Channel available are", y) + # print(type(y)) a_list = [] - for i in copy_y: + for i in y: a_list.append(i.strip()) - # print("hi", a_list) - """['wifi1vap8 109 channels in total; available frequencies :', 'Channel 36 : 5.18 GHz', - 'Channel 40 : 5.2 GHz', 'Channel 44 : 5.22 GHz', 'Channel 48 : 5.24 GHz', 'Channel 52 : 5.26 GHz', - 'Channel 56 : 5.28 GHz', 'Channel 60 : 5.3 GHz', 'Channel 64 : 5.32 GHz', 'Channel 100 : 5.5 GHz', - 'Channel 104 : 5.52 GHz', 'Channel 108 : 5.54 GHz', 'Channel 112 : 5.56 GHz', 'Channel 116 : 5.58 GHz', - 'Channel 120 : 5.6 GHz', 'Channel 124 : 5.62 GHz', 'Channel 128 : 5.64 GHz', 'Channel 132 : 5.66 GHz', - 'Channel 136 : 5.68 GHz', 'Channel 140 : 5.7 GHz', 'Current Frequency:5.22 GHz (Channel 44)']""" + print("hi", a_list) + if any("Channel 52 : 5.26 GHz" in s for s in a_list): print("set channel to 52") - t3 = threading.Thread(target=lambda q, arg1: q.put(dfs.set_channel_in_ap(arg1)), args=(que, "")) - t3.start() - t3.join() - print("channel set hogya") + else: + print("check for some another channel") - t4 = threading.Thread(target=lambda q, arg1: q.put(dfs.create_station_on_GUI(arg1)), args=(que, "")) + time.sleep(2) + + thr_2 = threading.Thread(target=dfs.exit_from_ap()) + thr_2.start() + thr_2.join() + print("exit") + + time.sleep(20) + + t3 = threading.Thread(target=dfs.set_channel_in_ap_at_52()) + t3.start() + t3.join() + print("channel set to 52") + + time.sleep(10) + + thr_3 = threading.Thread(target=dfs.exit_from_ap()) + thr_3.start() + thr_3.join() + print("exit") + + time.sleep(10) + + t4 = threading.Thread(target=dfs.create_station_on_GUI_1()) t4.start() t4.join() print("station created") + time.sleep(30) + t5 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) t5.start() t5.join() print("radar generated") + time.sleep(60) + t10 = threading.Thread(target=dfs.wait_for_ip()) + t10.start() + t10.join() print("checking hackrf is oN/OFF") print("Hackrf is ON") @@ -330,131 +416,104 @@ def main(): t6.join() print("Now hackrf is OFF") - t7 =threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) + print("setting channel to 100") + + t7 = threading.Thread(target=dfs.set_channel_in_ap_at_100()) t7.start() - threads_list.append(t7) t7.join() - f = que.get() - print("station cleaned ", f) + print("channel set at 100") - time.sleep(60) + time.sleep(30) - t8 = threading.Thread(target=lambda q, arg1: q.put(dfs.create_station_on_GUI(arg1)), args=(que, "")) + t8 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) t8.start() - threads_list.append(t8) t8.join() - b = que.get() - print("station at channel ", b) - - if b == "52": - print("station is on DFS Channel") - t9 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - t9.start() - t9.join() - elif b == "56": - print("station is on DFS Channel 56") - t10 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch56(arg1)), args=(que, "")) - t10.start() - t10.join() - elif b == "60": - print("station is on DFS Channel 60") - t11 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch60(arg1)), args=(que, "")) - t11.start() - t11.join() - elif b == "64": - print("station is on DFS Channel 64") - t12 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch64(arg1)), args=(que, "")) - t12.start() - t12.join() - elif b == "100": - print("station is on DFS Channel 100") - t13 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) - t13.start() - t13.join() - elif b == "104": - print("station is on DFS Channel 104") - t14 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch104(arg1)), args=(que, "")) - t14.start() - t14.join() - elif b == "108": - print("station is on DFS Channel 108") - t15 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch108(arg1)), args=(que, "")) - t15.start() - t15.join() - elif b == "112": - print("station is on DFS Channel 112") - t16 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch112(arg1)), args=(que, "")) - t16.start() - t16.join() - elif b == "116": - print("station is on DFS Channel 116") - t17 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) - t17.start() - t17.join() - elif b == "120": - print("station is on DFS Channel 120") - t18 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch120(arg1)), args=(que, "")) - t18.start() - t18.join() - elif b == "124": - print("station is on DFS Channel 124") - t19 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch124(arg1)), args=(que, "")) - t19.start() - t19.join() - elif b == "128": - print("station is on DFS Channel 128") - t20 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch128(arg1)), args=(que, "")) - t20.start() - t20.join() - elif b == "132": - print("station is on DFS Channel 132") - t21 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch132(arg1)), args=(que, "")) - t21.start() - t21.join() - elif b == "136": - print("station is on DFS Channel 136") - t22 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) - t22.start() - t22.join() - elif b == "140": - print("station is on DFS Channel 140") - t23 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch140(arg1)), args=(que, "")) - t23.start() - t23.join() - else: - print("station is on NON DFS Channel") - - print("checking hackrf is oN/OFF") - print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - t6 = threading.Thread(dfs.hackrf_status_off()) - t6.start() - t6.join() - print("Now hackrf is OFF") - - t24 = threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) - t24.start() - threads_list.append(t24) - t24.join() - f = que.get() - print("station cleaned ", f) + print("radar generated") time.sleep(60) - t25 = threading.Thread(target=lambda q, arg1: q.put(dfs.create_station_on_GUI(arg1)), args=(que, "")) - t25.start() - threads_list.append(t25) - t25.join() - b = que.get() - print("station at channel ", b) + t11 = threading.Thread(target=dfs.wait_for_ip()) + t11.start() + t11.join() - t26 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_log(arg1)), args=(que, "")) - t26.start() - threads_list.append(t26) - t26.join() - v = que.get() - print(v) + print("done") + + t12 = threading.Thread(target=dfs.set_channel_in_ap_at_116()) + t12.start() + t12.join() + print("channel set hogya at 116") + + time.sleep(30) + + t13 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) + t13.start() + t13.join() + print("radar generated") + + time.sleep(60) + + t14 = threading.Thread(target=dfs.wait_for_ip()) + t14.start() + t14.join() + + print("done") + + t15 = threading.Thread(target=dfs.set_channel_in_ap_at_136()) + t15.start() + t15.join() + + time.sleep(30) + + t16 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) + t16.start() + t16.join() + print("radar generated") + + time.sleep(60) + + t17 = threading.Thread(target=dfs.wait_for_ip()) + t17.start() + t17.join() + + print("done") + + t18 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_log_channel(arg1)), args=(que, "")) + t18.start() + threads_list.append(t18) + t18.join() + var = que.get() + print(type(var)) + for i in range(len(var)): + var[i] = var[i] + "
" + #print(var[i]) + print(var) + + listToStr = ' '.join([str(elem) for elem in var]) + print(listToStr) + + t19 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_all_logs(arg1)), args=(que, "")) + t19.start() + threads_list.append(t19) + t19.join() + var_4 = que.get() + + for i in range(len(var_4)): + var_4[i] = var_4[i] + "
" + + all_log = ' '.join([str(elem) for elem in var_4]) + + now = datetime.datetime.now() + print("Current date and time : ") + date = now.strftime("%Y-%m-%d %H:%M:%S") + + html_content = "DFS TEST

Dynamic Frequency Selection

" + date + "



Objective

The DFS Test is designed to test the Performance of the Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1

Testing Results

" + all_log + "

" + listToStr + "

" + + + file = open("sample.html", "w") + file.write(html_content) + file.close() + + print("Test Finished") if __name__ == '__main__': main() -Displaying netgear_dfs_15.txt. From 86d679c7e09bfc5a5d9afe078203cfc6f5a9bcc4 Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Tue, 19 Jan 2021 20:25:34 +0530 Subject: [PATCH 031/848] 'Moved Netgear_dfs.py to test_netgear_dfs.py --- py-scripts/test_netgear_dfs.py | 447 +++++++++++++++++++++++++++++++++ 1 file changed, 447 insertions(+) create mode 100644 py-scripts/test_netgear_dfs.py diff --git a/py-scripts/test_netgear_dfs.py b/py-scripts/test_netgear_dfs.py new file mode 100644 index 00000000..e8a99ebf --- /dev/null +++ b/py-scripts/test_netgear_dfs.py @@ -0,0 +1,447 @@ +""" file under progress not ffor testing - AP R7800 +""" + + +import time +import threading +import os +import paramiko +from queue import Queue +from cx_time import IPv4Test + + + +class DFS_TESTING: + + + def _init_(self): + pass + + + def set_dfs_channel_in_ap(self): + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect('192.168.200.190', port=22, username='root', password='Lanforge12345!xzsawq@!') + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52') + output = stdout.readlines() + print('\n'.join(output)) + time.sleep(1) + exit(0) + + def create_station_on_GUI(self,y1,y2): + global var1 + self.y1 = y1 + self.y2 = y2 + cmd = "python3 sta_cx.py --mgr 192.168.200.13 --num_stations 1 --ssid TestAP95 --passwd lanforge --security wpa2 --radio wiphy0" + print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/home/lanforge/lanforge-scripts/py-scripts') + print("Current working directory: {0}".format(os.getcwd())) + x = os.popen(cmd).read() + print("station created") + y1 ='station created' + + with open("data.txt", "w")as f: + f.write(x) + f.close() + + file = open("data.txt", "r") + for i in file: + if "channel associated is " in i: + my_list = list(i.split(" ")) + print(my_list[3]) + print(type(my_list[3])) + var1 = my_list[3] + + print(var1) + var = var1.replace("\n", "") + + if var == "52" or var == "56" or var == "60" or var == "64" or var == "100" or var == "104" or var == "108" or var == "112" or var == "116" or var == "120" or var == "124" or var == "128" or var == "132" or var == "136" or var == "140": + print('Station is on DFS Channel') + self.y2 = 'station is on DFS Channel' + else: + print('Station is on Non DFS channel') + self.y2 = 'Station is on Non DFS channel' + + return (self.y1 , self.y2) + + + + + ''' ########### HACKRF ####################### ''' + + + def generate_radar_at_ch52(self, r): + self.r = r + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + #print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.r = "Radar detected" + return self.r + + def generate_radar_at_ch56(self,q): + self.q =q + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.q = "Radar detected" + return self.q + + def generate_radar_at_ch60(self,w): + self.w = w + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.w = "Radar detected" + return self.w + + def generate_radar_at_ch64(self,e): + self.e = e + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.e = "Radar detected" + return self.e + + def generate_radar_at_ch100(self,f): + self.f = f + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.f = "Radar received" + return self.f + + def generate_radar_at_ch104(self,t): + self.t = t + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.t = "Radar detected" + return self.t + + def generate_radar_at_ch108(self,u): + self.u=u + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.u = "Radar detected" + return self.u + + def generate_radar_at_ch112(self,i): + self.i=i + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.i = "Radar detected" + return self.i + + def generate_radar_at_ch116(self,o): + self.o =o + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.o = "Radar detected" + return self.o + + def generate_radar_at_ch120(self,p): + self.p=p + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" + #print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.p = "Radar detected" + return self.p + + def generate_radar_at_ch124(self,a): + self.a=a + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.a = "Radar detected" + return self.a + + def generate_radar_at_ch128(self,s): + self.s=s + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.s = "Radar detected" + return self.s + + def generate_radar_at_ch132(self,d): + self.d = d + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.d = "Radar detected" + return self.d + + def generate_radar_at_ch136(self,h): + self.h=h + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.h = "Radar detected" + return self.h + + def generate_radar_at_ch140(self,j): + self.j = j + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + self.j = "Radar detected" + return self.j + + def hackrf_status_off(self): + + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + + + def monitor_station_channel(self,m): + self.m = m + obj = IPv4Test(_host="192.168.200.13", + _port=8080, + _ssid="TestAP95", + _password="lanforge", + _security="wpa2", + _radio="wiphy0") + obj.cleanup(obj.sta_list) + obj.build() + obj.station_profile.admin_up() + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(30) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + self.m = var_1 + return self.m + + + def aps_radio_off(self): + pass + + def aps_not_switch_automatically(self): + pass + + def check_ap_channel_switching_time(self): + pass + + + +def main(): + + + + + dfs = DFS_TESTING() + + que = Queue() + + + + ''' algorithm and sequence to be followed ''' + + print("Hackrf is ON") + print("press s --> enter --> q to stop hackrf") + dfs.hackrf_status_off() + print("Now hackrf is OFF") + + #set channel on ap //netgear + + threads_list = [] + t1 = threading.Thread(target=lambda q, arg1, arg2: q.put(dfs.create_station_on_GUI(arg1, arg2)), args=(que, "", "")) + t1.start() + threads_list.append(t1) + t1.join() + + # Check thread's return value + global my_var + + result = que.get() + print("hi i reached", result) + my_var = result + + list_1 = list(my_var) + print("my list", list_1) + + if any("station is on DFS Channel" in s for s in list_1): + t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t2.start() + threads_list.append(t2) + t2.join() + x = que.get() + print("result", x) + else: + print("radar unreachable") + + t3=threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) + t3.start() + threads_list.append(t3) + t3.join() + y = que.get() + print("channel after radar is ", y) + + if y == "52": + print("station is on DFS Channel") + t4 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t4.start() + t4.join() + elif y == "56": + print("station is on DFS Channel 56") + t5 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch56(arg1)), args=(que, "")) + t5.start() + t5.join() + elif y == "60": + print("station is on DFS Channel 60") + t6 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch60(arg1)), args=(que, "")) + t6.start() + t6.join() + elif y == "64": + print("station is on DFS Channel 64") + t7 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch64(arg1)), args=(que, "")) + t7.start() + t7.join() + elif y == "100": + print("station is on DFS Channel 100") + t8 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) + t8.start() + t8.join() + elif y == "104": + print("station is on DFS Channel 104") + t9 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch104(arg1)), args=(que, "")) + t9.start() + t9.join() + elif y == "108": + print("station is on DFS Channel 108") + t10 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch108(arg1)), args=(que, "")) + t10.start() + t10.join() + elif y == "112": + print("station is on DFS Channel 112") + t11 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch112(arg1)), args=(que, "")) + t11.start() + t11.join() + elif y == "116": + print("station is on DFS Channel 116") + t12 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) + t12.start() + t12.join() + elif y == "120": + print("station is on DFS Channel 120") + t13 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch120(arg1)), args=(que, "")) + t13.start() + t13.join() + elif y == "124": + print("station is on DFS Channel 124") + t14 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch124(arg1)), args=(que, "")) + t14.start() + t14.join() + elif y == "128": + print("station is on DFS Channel 128") + t15 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch128(arg1)), args=(que, "")) + t15.start() + t15.join() + elif y == "132": + print("station is on DFS Channel 132") + t16 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch132(arg1)), args=(que, "")) + t16.start() + t16.join() + elif y == "136": + print("station is on DFS Channel 136") + t17 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) + t17.start() + t17.join() + elif y == "140": + print("station is on DFS Channel 140") + t18 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch140(arg1)), args=(que, "")) + t18.start() + t18.join() + else: + print("station is on NON DFS Channel") + + + + + + + + + """t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t2.start() + threads_list.append(t2) + t2.join()""" + + + + + # Join all the threads + """for t in threads_list: + t.join()""" + + + + """print("my var", my_var) + empty_list = [] + list = empty_list.append(my_var) + print("list", list)""" + + + '''t2 = threading.Thread(target=dfs.generate_radar_at_ch100()) + t2.start() + t2.join() + print("radar received") + + t3 = threading.Thread(target=dfs.create_station_on_GUI()) + t3.start() + t3.join() + print("station reassociated")''' + + + + + '''dfs.hackrf_status_off() + dfs.aps_radio_off() + dfs.aps_not_switch_automatically() + #generate radar and check for all dfs channels + dfs.check_ap_channel_switching_time() + #after testing turn off hackrf''' + + + + + + +if __name__ == '__main__': + main() From 41177e6f6826056d08ab7c4dee7516c827001efb Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Tue, 19 Jan 2021 20:29:18 +0530 Subject: [PATCH 032/848] delete Netgear_dfs.py from repo --- py-scripts/Netgear_dfs.py | 519 -------------------------------------- 1 file changed, 519 deletions(-) delete mode 100644 py-scripts/Netgear_dfs.py diff --git a/py-scripts/Netgear_dfs.py b/py-scripts/Netgear_dfs.py deleted file mode 100644 index f022513c..00000000 --- a/py-scripts/Netgear_dfs.py +++ /dev/null @@ -1,519 +0,0 @@ -"""under progress""" - -import os -import paramiko -import time -import threading -from queue import Queue -from cx_time import IPv4Test -import datetime - - -class DFS_TESTING: - def _init_(self): - pass - - def hackrf_status_off(self): - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - - def check_radio_on_off(self, x): - self.x = x - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('conf_get system:wlanSettings:wlanSettingTable:wlan0:radioStatus') - output = stdout.readlines() - print('\n'.join(output)) - self.x = output - time.sleep(1) - return self.x - - def exit_from_ap(self): - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('exit') - time.sleep(1) - - def check_for_channels(self, q): - self.q = q - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel ') - output = stdout.readlines() - # print('\n'.join(output)) - self.q = output - time.sleep(1) - return self.q - - def set_channel_in_ap_at_52(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def set_channel_in_ap_at_100(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def set_channel_in_ap_at_116(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 116") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def set_channel_in_ap_at_136(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 136") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def create_station_on_GUI_1(self): - obj = IPv4Test(_host="localhost", - _port=8080, - _ssid="TestAP22", - _password="[BLANK]", - _security="open", - _radio="wiphy0") - obj.cleanup(obj.sta_list) - obj.build() - obj.station_profile.admin_up() - obj.local_realm.wait_for_ip(obj.sta_list) - time.sleep(5) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - print(var_1) - - - def generate_radar_at_ch52(self, r): - self.r = r - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.r = "Radar detected" - return self.r - - def generate_radar_at_ch56(self, q): - self.q = q - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.q = "Radar detected" - return self.q - - def generate_radar_at_ch60(self, w): - self.w = w - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.w = "Radar detected" - return self.w - - def generate_radar_at_ch64(self, e): - self.e = e - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.e = "Radar detected" - return self.e - - def generate_radar_at_ch100(self, f): - self.f = f - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.f = "Radar received" - return self.f - - def generate_radar_at_ch104(self, t): - self.t = t - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.t = "Radar detected" - return self.t - - def generate_radar_at_ch108(self, u): - self.u = u - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.u = "Radar detected" - return self.u - - def generate_radar_at_ch112(self, i): - self.i = i - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.i = "Radar detected" - return self.i - - def generate_radar_at_ch116(self, o): - self.o = o - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5580000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.o = "Radar detected" - return self.o - - def generate_radar_at_ch120(self, p): - self.p = p - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.p = "Radar detected" - return self.p - - def generate_radar_at_ch124(self, a): - self.a = a - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.a = "Radar detected" - return self.a - - def generate_radar_at_ch128(self, s): - self.s = s - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.s = "Radar detected" - return self.s - - def generate_radar_at_ch132(self, d): - self.d = d - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.d = "Radar detected" - return self.d - - def generate_radar_at_ch136(self, h): - self.h = h - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.h = "Radar detected" - return self.h - - def generate_radar_at_ch140(self, j): - self.j = j - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.j = "Radar detected" - return self.j - - def station_clean(self): - obj = IPv4Test(_host="localhost", - _port=8080, - _ssid="TestAP22", - _password="[BLANK]", - _security="open", - _radio="wiphy0") - obj.cleanup(obj.sta_list) - var_1 = "station cleaned" - print(var_1) - - def wait_for_ip(self): - obj = IPv4Test(_host="localhost", - _port=8080, - _ssid="TestAP22", - _password="[BLANK]", - _security="open", - _radio="wiphy0") - - obj.local_realm.wait_for_ip(obj.sta_list) - time.sleep(5) - - def check_log_channel(self, r): - self.r = r - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(1) - self.r = output - return self.r - - def check_for_all_logs(self, r): - self.r = r - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(1) - self.r = output - return self.r - - - -def main(): - que = Queue() - threads_list = [] - dfs = DFS_TESTING() - - print("checking hackrf is oN/OFF") - print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - dfs.hackrf_status_off() - - print("Now hackrf is OFF") - - time.sleep(2) - - print("checking if all radios is ON/OFF") - t1 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_radio_on_off(arg1)), args=(que, "")) - t1.start() - threads_list.append(t1) - t1.join() - x = que.get() - # print("result", x) - new_list = [] - new_list_1 = [] - for element in x: - new_list.append(element.strip()) - # print(new_list[0]) - new_list_1 = new_list[0].split() - # print("elements", new_list_1) - - if (new_list_1[1] == "1"): - print("Radio is ON") - else: - print("Radio is OFF") - - time.sleep(2) - - thr_1 = threading.Thread(target=dfs.exit_from_ap()) - thr_1.start() - thr_1.join() - print("exit") - - time.sleep(10) - - t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_channels(arg1)), args=(que, "")) - t2.start() - threads_list.append(t2) - t2.join() - y = que.get() - # print("Channel available are", y) - # print(type(y)) - a_list = [] - for i in y: - a_list.append(i.strip()) - print("hi", a_list) - - if any("Channel 52 : 5.26 GHz" in s for s in a_list): - print("set channel to 52") - else: - print("check for some another channel") - - time.sleep(2) - - thr_2 = threading.Thread(target=dfs.exit_from_ap()) - thr_2.start() - thr_2.join() - print("exit") - - time.sleep(20) - - t3 = threading.Thread(target=dfs.set_channel_in_ap_at_52()) - t3.start() - t3.join() - print("channel set to 52") - - time.sleep(10) - - thr_3 = threading.Thread(target=dfs.exit_from_ap()) - thr_3.start() - thr_3.join() - print("exit") - - time.sleep(10) - - t4 = threading.Thread(target=dfs.create_station_on_GUI_1()) - t4.start() - t4.join() - print("station created") - - time.sleep(30) - - t5 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - t5.start() - t5.join() - print("radar generated") - - time.sleep(60) - - t10 = threading.Thread(target=dfs.wait_for_ip()) - t10.start() - t10.join() - - print("checking hackrf is oN/OFF") - print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - t6 = threading.Thread(dfs.hackrf_status_off()) - t6.start() - t6.join() - print("Now hackrf is OFF") - - print("setting channel to 100") - - t7 = threading.Thread(target=dfs.set_channel_in_ap_at_100()) - t7.start() - t7.join() - print("channel set at 100") - - time.sleep(30) - - t8 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) - t8.start() - t8.join() - print("radar generated") - - time.sleep(60) - - t11 = threading.Thread(target=dfs.wait_for_ip()) - t11.start() - t11.join() - - print("done") - - t12 = threading.Thread(target=dfs.set_channel_in_ap_at_116()) - t12.start() - t12.join() - print("channel set hogya at 116") - - time.sleep(30) - - t13 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) - t13.start() - t13.join() - print("radar generated") - - time.sleep(60) - - t14 = threading.Thread(target=dfs.wait_for_ip()) - t14.start() - t14.join() - - print("done") - - t15 = threading.Thread(target=dfs.set_channel_in_ap_at_136()) - t15.start() - t15.join() - - time.sleep(30) - - t16 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) - t16.start() - t16.join() - print("radar generated") - - time.sleep(60) - - t17 = threading.Thread(target=dfs.wait_for_ip()) - t17.start() - t17.join() - - print("done") - - t18 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_log_channel(arg1)), args=(que, "")) - t18.start() - threads_list.append(t18) - t18.join() - var = que.get() - print(type(var)) - for i in range(len(var)): - var[i] = var[i] + "
" - #print(var[i]) - print(var) - - listToStr = ' '.join([str(elem) for elem in var]) - print(listToStr) - - t19 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_all_logs(arg1)), args=(que, "")) - t19.start() - threads_list.append(t19) - t19.join() - var_4 = que.get() - - for i in range(len(var_4)): - var_4[i] = var_4[i] + "
" - - all_log = ' '.join([str(elem) for elem in var_4]) - - now = datetime.datetime.now() - print("Current date and time : ") - date = now.strftime("%Y-%m-%d %H:%M:%S") - - html_content = "DFS TEST

Dynamic Frequency Selection

" + date + "



Objective

The DFS Test is designed to test the Performance of the Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1

Testing Results

" + all_log + "

" + listToStr + "

" - - - file = open("sample.html", "w") - file.write(html_content) - file.close() - - print("Test Finished") - -if __name__ == '__main__': - main() From 2becc53020976d404a42897719b0951d2728f855 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 08:09:39 -0700 Subject: [PATCH 033/848] netgear_dfs.py: remove file --- py-scripts/netgear_dfs.py | 519 -------------------------------------- 1 file changed, 519 deletions(-) delete mode 100644 py-scripts/netgear_dfs.py diff --git a/py-scripts/netgear_dfs.py b/py-scripts/netgear_dfs.py deleted file mode 100644 index f022513c..00000000 --- a/py-scripts/netgear_dfs.py +++ /dev/null @@ -1,519 +0,0 @@ -"""under progress""" - -import os -import paramiko -import time -import threading -from queue import Queue -from cx_time import IPv4Test -import datetime - - -class DFS_TESTING: - def _init_(self): - pass - - def hackrf_status_off(self): - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - - def check_radio_on_off(self, x): - self.x = x - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('conf_get system:wlanSettings:wlanSettingTable:wlan0:radioStatus') - output = stdout.readlines() - print('\n'.join(output)) - self.x = output - time.sleep(1) - return self.x - - def exit_from_ap(self): - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('exit') - time.sleep(1) - - def check_for_channels(self, q): - self.q = q - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel ') - output = stdout.readlines() - # print('\n'.join(output)) - self.q = output - time.sleep(1) - return self.q - - def set_channel_in_ap_at_52(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def set_channel_in_ap_at_100(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def set_channel_in_ap_at_116(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 116") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def set_channel_in_ap_at_136(self): - # cmd = "conf_set system:wlanSettings:wlanSettingTable:wlan1:channel ;conf_save" - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command("conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 136") - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(20) - - def create_station_on_GUI_1(self): - obj = IPv4Test(_host="localhost", - _port=8080, - _ssid="TestAP22", - _password="[BLANK]", - _security="open", - _radio="wiphy0") - obj.cleanup(obj.sta_list) - obj.build() - obj.station_profile.admin_up() - obj.local_realm.wait_for_ip(obj.sta_list) - time.sleep(5) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - print(var_1) - - - def generate_radar_at_ch52(self, r): - self.r = r - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.r = "Radar detected" - return self.r - - def generate_radar_at_ch56(self, q): - self.q = q - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.q = "Radar detected" - return self.q - - def generate_radar_at_ch60(self, w): - self.w = w - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.w = "Radar detected" - return self.w - - def generate_radar_at_ch64(self, e): - self.e = e - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.e = "Radar detected" - return self.e - - def generate_radar_at_ch100(self, f): - self.f = f - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.f = "Radar received" - return self.f - - def generate_radar_at_ch104(self, t): - self.t = t - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.t = "Radar detected" - return self.t - - def generate_radar_at_ch108(self, u): - self.u = u - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.u = "Radar detected" - return self.u - - def generate_radar_at_ch112(self, i): - self.i = i - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.i = "Radar detected" - return self.i - - def generate_radar_at_ch116(self, o): - self.o = o - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5580000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.o = "Radar detected" - return self.o - - def generate_radar_at_ch120(self, p): - self.p = p - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.p = "Radar detected" - return self.p - - def generate_radar_at_ch124(self, a): - self.a = a - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.a = "Radar detected" - return self.a - - def generate_radar_at_ch128(self, s): - self.s = s - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.s = "Radar detected" - return self.s - - def generate_radar_at_ch132(self, d): - self.d = d - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.d = "Radar detected" - return self.d - - def generate_radar_at_ch136(self, h): - self.h = h - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.h = "Radar detected" - return self.h - - def generate_radar_at_ch140(self, j): - self.j = j - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.j = "Radar detected" - return self.j - - def station_clean(self): - obj = IPv4Test(_host="localhost", - _port=8080, - _ssid="TestAP22", - _password="[BLANK]", - _security="open", - _radio="wiphy0") - obj.cleanup(obj.sta_list) - var_1 = "station cleaned" - print(var_1) - - def wait_for_ip(self): - obj = IPv4Test(_host="localhost", - _port=8080, - _ssid="TestAP22", - _password="[BLANK]", - _security="open", - _radio="wiphy0") - - obj.local_realm.wait_for_ip(obj.sta_list) - time.sleep(5) - - def check_log_channel(self, r): - self.r = r - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(1) - self.r = output - return self.r - - def check_for_all_logs(self, r): - self.r = r - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.143', port=22, username='root', password='Netgear@123xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(1) - self.r = output - return self.r - - - -def main(): - que = Queue() - threads_list = [] - dfs = DFS_TESTING() - - print("checking hackrf is oN/OFF") - print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - dfs.hackrf_status_off() - - print("Now hackrf is OFF") - - time.sleep(2) - - print("checking if all radios is ON/OFF") - t1 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_radio_on_off(arg1)), args=(que, "")) - t1.start() - threads_list.append(t1) - t1.join() - x = que.get() - # print("result", x) - new_list = [] - new_list_1 = [] - for element in x: - new_list.append(element.strip()) - # print(new_list[0]) - new_list_1 = new_list[0].split() - # print("elements", new_list_1) - - if (new_list_1[1] == "1"): - print("Radio is ON") - else: - print("Radio is OFF") - - time.sleep(2) - - thr_1 = threading.Thread(target=dfs.exit_from_ap()) - thr_1.start() - thr_1.join() - print("exit") - - time.sleep(10) - - t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_channels(arg1)), args=(que, "")) - t2.start() - threads_list.append(t2) - t2.join() - y = que.get() - # print("Channel available are", y) - # print(type(y)) - a_list = [] - for i in y: - a_list.append(i.strip()) - print("hi", a_list) - - if any("Channel 52 : 5.26 GHz" in s for s in a_list): - print("set channel to 52") - else: - print("check for some another channel") - - time.sleep(2) - - thr_2 = threading.Thread(target=dfs.exit_from_ap()) - thr_2.start() - thr_2.join() - print("exit") - - time.sleep(20) - - t3 = threading.Thread(target=dfs.set_channel_in_ap_at_52()) - t3.start() - t3.join() - print("channel set to 52") - - time.sleep(10) - - thr_3 = threading.Thread(target=dfs.exit_from_ap()) - thr_3.start() - thr_3.join() - print("exit") - - time.sleep(10) - - t4 = threading.Thread(target=dfs.create_station_on_GUI_1()) - t4.start() - t4.join() - print("station created") - - time.sleep(30) - - t5 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - t5.start() - t5.join() - print("radar generated") - - time.sleep(60) - - t10 = threading.Thread(target=dfs.wait_for_ip()) - t10.start() - t10.join() - - print("checking hackrf is oN/OFF") - print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - t6 = threading.Thread(dfs.hackrf_status_off()) - t6.start() - t6.join() - print("Now hackrf is OFF") - - print("setting channel to 100") - - t7 = threading.Thread(target=dfs.set_channel_in_ap_at_100()) - t7.start() - t7.join() - print("channel set at 100") - - time.sleep(30) - - t8 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) - t8.start() - t8.join() - print("radar generated") - - time.sleep(60) - - t11 = threading.Thread(target=dfs.wait_for_ip()) - t11.start() - t11.join() - - print("done") - - t12 = threading.Thread(target=dfs.set_channel_in_ap_at_116()) - t12.start() - t12.join() - print("channel set hogya at 116") - - time.sleep(30) - - t13 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) - t13.start() - t13.join() - print("radar generated") - - time.sleep(60) - - t14 = threading.Thread(target=dfs.wait_for_ip()) - t14.start() - t14.join() - - print("done") - - t15 = threading.Thread(target=dfs.set_channel_in_ap_at_136()) - t15.start() - t15.join() - - time.sleep(30) - - t16 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) - t16.start() - t16.join() - print("radar generated") - - time.sleep(60) - - t17 = threading.Thread(target=dfs.wait_for_ip()) - t17.start() - t17.join() - - print("done") - - t18 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_log_channel(arg1)), args=(que, "")) - t18.start() - threads_list.append(t18) - t18.join() - var = que.get() - print(type(var)) - for i in range(len(var)): - var[i] = var[i] + "
" - #print(var[i]) - print(var) - - listToStr = ' '.join([str(elem) for elem in var]) - print(listToStr) - - t19 = threading.Thread(target=lambda q, arg1: q.put(dfs.check_for_all_logs(arg1)), args=(que, "")) - t19.start() - threads_list.append(t19) - t19.join() - var_4 = que.get() - - for i in range(len(var_4)): - var_4[i] = var_4[i] + "
" - - all_log = ' '.join([str(elem) for elem in var_4]) - - now = datetime.datetime.now() - print("Current date and time : ") - date = now.strftime("%Y-%m-%d %H:%M:%S") - - html_content = "DFS TEST

Dynamic Frequency Selection

" + date + "



Objective

The DFS Test is designed to test the Performance of the Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1

Testing Results

" + all_log + "

" + listToStr + "

" - - - file = open("sample.html", "w") - file.write(html_content) - file.close() - - print("Test Finished") - -if __name__ == '__main__': - main() From f76e16191cce1b77f9107d167429710c48758af8 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 08:40:57 -0700 Subject: [PATCH 034/848] cisco_wifi_ctl.py : LCS-34 Tx-power: WLAN update controller configuration for open security --- cisco_wifi_ctl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 083a5c5d..7d0c8fdc 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1108,13 +1108,16 @@ def main(): else: command = "show ap channel %s"%(args.ap) + if (args.action == "no_wlan_wireless_tag_policy" and (args.wlan is None)): + raise Exception("wlan is required") if (args.action == "no_wlan_wireless_tag_policy"): logg.info("send wireless tag policy no wlan") + logg.info("send wireless tag policy no wlan , for wlan {}".format(args.wlan)) egg.sendline("config t") sleep(0.1) i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: - for command in ["wireless tag policy default-policy-tag","no wlan open-wlan policy default-policy-profile"]: + for command in ["wireless tag policy default-policy-tag","no wlan {} policy default-policy-profile".format(args.wlan)]: egg.sendline(command) sleep(1) j = egg.expect_exact([CCP_POLICY_TAG,pexpect.TIMEOUT],timeout=2) From 671b5750f7379d8ecf01af91103fef7419d14d5c Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 08:55:34 -0700 Subject: [PATCH 035/848] lf_cisco_power.py : LCS-38 : Verify wlan(SSID) matches the SSID for the station: this is a common error when running tx_power --- lf_cisco_power.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index c1e7cfcb..77cff752 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -287,13 +287,13 @@ def main(): parser.add_argument("--pf_a4_dropoff", type=str, help="Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") - parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier default wlan-open",required=True) + parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier, this must match the -ssid",required=True) parser.add_argument("--wlanID", type=str, help="--wlanID 9800 , defaults to 1",default="1",required=True) parser.add_argument("--series", type=str, help="--series 9800 or 3504, defaults to 9800",default="9800") parser.add_argument("--slot", type=str, help="--slot 1 , 9800 AP slot defaults to 1",default="1") parser.add_argument("--create_station", type=str, help="create LANforge station at the beginning of the test") parser.add_argument("--radio", type=str, help="radio to create LANforge station on at the beginning of the test") - parser.add_argument("--ssid", type=str, help="ssid",required=True) + parser.add_argument("--ssid", type=str, help="ssid, this must patch the wlan",required=True) parser.add_argument("--ssidpw", type=str, help="ssidpw",required=True) parser.add_argument("--security", type=str, help="security",required=True) parser.add_argument("--cleanup", action='store_true',help="--cleanup , Clean up stations after test completes ") @@ -347,7 +347,10 @@ def main(): # capture the controller output , thus won't got to stdout some output always present cap_ctl_out = False else: - cap_ctl_out = True + cap_ctl_out = True + if (args.wlan != args.ssid): + print("wlan {} must equial the station ssid {}".format(args.wlan,args.ssid)) + exit(1) # note: there would always be an args.outfile due to the default current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) outfile = "{}_{}.txt".format(args.outfile,current_time) From bfb1fd2069cc2c3de381d21db8f0b79f4c1ecf20 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 09:00:24 -0700 Subject: [PATCH 036/848] lf_cisco_power.py : LCS-38 : Verify wlan(SSID) matches the SSID for the station: this is a common error when running tx_power --- lf_cisco_power.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 77cff752..195deb38 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -349,7 +349,9 @@ def main(): else: cap_ctl_out = True if (args.wlan != args.ssid): - print("wlan {} must equial the station ssid {}".format(args.wlan,args.ssid)) + print("####### ERROR ################################") + print("wlan: {} must equial the station ssid: {}".format(args.wlan,args.ssid)) + print("####### ERROR ################################") exit(1) # note: there would always be an args.outfile due to the default current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) From 4c487f1e70a56919b3644abd88c9dd28159b3f09 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 19 Jan 2021 11:32:16 -0800 Subject: [PATCH 037/848] python update script --- py-scripts/update_deps.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 py-scripts/update_deps.sh diff --git a/py-scripts/update_deps.sh b/py-scripts/update_deps.sh new file mode 100755 index 00000000..3d6ffe6c --- /dev/null +++ b/py-scripts/update_deps.sh @@ -0,0 +1 @@ +pip install pandas seaborn plotly numpy --upgrade From 01400965d6c3497750d5bc9422e9009bc10d113a Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 12:36:52 -0700 Subject: [PATCH 038/848] lf_cisco_power.py: LCS-38 9800 series: Before creating a wlan on specific wlanID remove existing wlan if one already created. If delete fails exit script with Error for user intervention --- lf_cisco_power.py | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 195deb38..b625e025 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -672,7 +672,8 @@ def main(): continue # the summaries are different between the 9800 series controller and the 3504 series # if the output changes then the following pattern/regular expression parcing needs to be changed - # this site may help: https://regex101.com/ + # this site may help: https://regex101.com/ + # when using https://regex101.com/ for tool beginning of string begins with ^ if (searchap): if args.series == "9800": pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)"%(args.ap) @@ -887,7 +888,49 @@ def main(): if wlan_created: logg.info("wlan already present, no need to create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) pass - else: + else: + # Verify that a wlan does not exist on wlanID + # delete the wlan if already exists + try: + logg.info("9800 cisco_wifi_ctl.py: show_wlan_summary") + wlan_info = 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,"--prompt",args.prompt], capture_output=True, check=True) + pss = wlan_info.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) + + # "number of WLANs:\s+(\S+)" + for line in pss.splitlines(): + logg.info(line) + if (line.startswith("---------")): + search_wlan = True + continue + if (search_wlan): + pat = "{}\s+(\S+)\s+\(\S+)".format(args.wlanID) + m = re.search(pat, line) + if (m != None): + cc_wlan = m.group(1) + cc_wlan_ssid = m.group(2) + # wlanID is in use + logg.info("###############################################################################") + logg.info("Need to remove wlan: {} wlanID: {} wlan ssid {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + logg.info("###############################################################################") + try: + logg.info("9800 cisco_wifi_ctl.py: delete_wlan one was present wlan: {} wlanID: {} wlan_ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + 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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + if cap_ctl_out: + pss = ctl_output.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) + + + # Create wlan wlan_created = True logg.info("create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) try: From 79769d3314e02fe62349a69ff80ccd4d4560719b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 12:46:04 -0700 Subject: [PATCH 039/848] lf_cisco_power.py : on first controller command, updated error to check if telnet is already active --- lf_cisco_power.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b625e025..272893e8 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -640,7 +640,13 @@ def main(): 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)) + logg.info("####################################################################################################") + logg.info("# CHECK IF CONTROLLER HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + + logg.info("####################################################################################################") + logg.info("# Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") exit_test(workbook) try: @@ -929,7 +935,6 @@ def main(): 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) - # Create wlan wlan_created = True logg.info("create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) From cb2dcb499e93067fd7102c14e681920972be0526 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 12:51:20 -0700 Subject: [PATCH 040/848] lf_cisco_power.py : LCS-38 9800 series: Before creating a wlan on specific wlanID remove existing wlan if one already created. If delete fails exit script with Error for user intervention --- lf_cisco_power.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 272893e8..dc53fbb4 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -908,6 +908,7 @@ def main(): exit_test(workbook) # "number of WLANs:\s+(\S+)" + search_wlan = False for line in pss.splitlines(): logg.info(line) if (line.startswith("---------")): From d264307a836a82a5c6aabbb335d78c539a57d4ae Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 13:11:46 -0700 Subject: [PATCH 041/848] cisco_wifi_ctl.py: debug for commands --- cisco_wifi_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 7d0c8fdc..ace661bc 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1188,7 +1188,7 @@ def main(): sleep(0.1) if i == 1: logg.info("did not get the (config)# prompt") - + print("args.action {}".format(args.action)) if (args.action == "show_wlan_summary"): logg.info("show wlan summary command to send") egg.sendline("show wlan summary") From bf46b57730758b2f21a5afc07747a637c6004ad4 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 13:31:28 -0700 Subject: [PATCH 042/848] cisco_wifi_ctl.py: debug for show_wlan_summary --- cisco_wifi_ctl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index ace661bc..5dd9e76f 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1189,11 +1189,16 @@ def main(): if i == 1: logg.info("did not get the (config)# prompt") print("args.action {}".format(args.action)) + if (args.action == "show_wlan_summary"): + print("First check on show_wlan_summary {}".format(args.action)) + logg.info("show_wlan_summary: {}".format(args.action)) if (args.action == "show_wlan_summary"): logg.info("show wlan summary command to send") + print("show wlan summary command to send 2") egg.sendline("show wlan summary") sleep(0.1) i = egg.expect([CCP,CCP_EN,pexpect.TIMEOUT],timeout=1) + print("CCP: {} CCP_EN: {} ".format(CCP,CCP_EN)) if i == 0: logg.info("show wlan summary sent prompt {}".format(CCP)) if i == 1: From 1a00556d0ba3bcc31ae13d66baaa69d57f1a154f Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 13:39:37 -0700 Subject: [PATCH 043/848] cisco_wifi_clt.py: debug --- cisco_wifi_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 5dd9e76f..ff50e9b1 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1197,7 +1197,7 @@ def main(): print("show wlan summary command to send 2") egg.sendline("show wlan summary") sleep(0.1) - i = egg.expect([CCP,CCP_EN,pexpect.TIMEOUT],timeout=1) + i = egg.expect_exact([CCP,CCP_EN,pexpect.TIMEOUT],timeout=2) print("CCP: {} CCP_EN: {} ".format(CCP,CCP_EN)) if i == 0: logg.info("show wlan summary sent prompt {}".format(CCP)) From f2a59f8c6f05da8c560b7de2e14e7bd779368bb7 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 14:18:29 -0700 Subject: [PATCH 044/848] cisco_wifi_ctl.py : show_wlan_summary --- cisco_wifi_ctl.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index ff50e9b1..25393d6a 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1188,23 +1188,10 @@ def main(): sleep(0.1) if i == 1: logg.info("did not get the (config)# prompt") - print("args.action {}".format(args.action)) + if (args.action == "show_wlan_summary"): - print("First check on show_wlan_summary {}".format(args.action)) - logg.info("show_wlan_summary: {}".format(args.action)) - if (args.action == "show_wlan_summary"): - logg.info("show wlan summary command to send") - print("show wlan summary command to send 2") - egg.sendline("show wlan summary") - sleep(0.1) - i = egg.expect_exact([CCP,CCP_EN,pexpect.TIMEOUT],timeout=2) - print("CCP: {} CCP_EN: {} ".format(CCP,CCP_EN)) - if i == 0: - logg.info("show wlan summary sent prompt {}".format(CCP)) - if i == 1: - logg.info("show wlan summary sent prompt {}".format(CCP_EN)) - if i == 2: - logg.info("show wlan summary timed out") + print("command show wlan summary ") + command = "show wlan summary" if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): raise Exception("wlan and wlanID is required an") From b7c66ebe48a27698aa44d04c2ac90f5e46c0ec9a Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 19 Jan 2021 13:26:52 -0800 Subject: [PATCH 045/848] help and debug changes --- py-json/realm.py | 12 +++++--- py-scripts/test_ipv4_variable_time.py | 40 +++++++++++++++------------ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a2ed7dcb..ff85a8fa 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1295,15 +1295,19 @@ class L3CXProfile(BaseProfile): "cx_name": cx_name, "cx_state": "RUNNING" }, debug_=self.debug) - print(".", end='') - print("") + if self.debug: + print(".", end='') + if self.debug: + print("") def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): self.stopping_cx(cx_name) - print(".", end='') - print("") + if self.debug: + print(".", end='') + if self.debug: + print("") def cleanup_prefix(self): self.cleanup_cxe_prefix(self.name_prefix) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 677bcf1b..570f77c0 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -182,6 +182,8 @@ python3 ./test_ipv4_variable_time.py --a_min 1000 --b_min 1000 --ap "00:0e:8e:78:e1:76" + --output_format csv + --report_file ~/Documents/results.csv (if csv file - please use another extension for other files) --debug ''') @@ -190,10 +192,8 @@ python3 ./test_ipv4_variable_time.py if group.title == "required arguments": required_args=group break - if required_args is not None: - required_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) - required_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) - required_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") + #if required_args is not None: + optional_args=None for group in parser._action_groups: if group.title == "optional arguments": @@ -204,12 +204,30 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--ap',help='Used to force a connection to a particular AP') optional_args.add_argument('--report_file',help='where you want to store results') optional_args.add_argument('--output_format', help='choose either csv or xlsx') + optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) + optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) + optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) + if args.report_file is None: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: + report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format + output=args.output_format + else: + print('Defaulting to Excel') + report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' + output='excel' + else: + report_f=args.report_file + if args.output_format is None: + output=str(args.report_file).split('.')[-1] + else: + output=args.output_format + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_var_test = IPV4VariableTime(host=args.mgr, port=args.mgr_port, @@ -236,20 +254,6 @@ python3 ./test_ipv4_variable_time.py ip_var_test.exit_fail() ip_var_test.start(False, False) - if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format - output=args.output_format - else: - print('Defaulting to Excel') - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' - output='excel' - else: - report_f=args.report_file - if args.output_format is None: - output=str(args.report_file).split('.')[-1] - else: - output=args.output_format layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], From b513b79557e5893e8f4c970c0196948c33491e4c Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 19 Jan 2021 13:30:23 -0800 Subject: [PATCH 046/848] debug --- py-json/realm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index ff85a8fa..5df91dd9 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1184,7 +1184,8 @@ class L3CXProfile(BaseProfile): print(response) raise ValueError("no endpoint?") if monitor: - print(response) + if self.debug: + print(response) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response From fc8c5e7737af8c5df03109bbaebbdb44ec73776d Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 03:38:34 +0530 Subject: [PATCH 047/848] test_utility update --- py-json/LANforge/lfcli_base.py | 1 + py-scripts/connection_test.py | 11 +- py-scripts/test_utility.py | 317 --------------------------------- 3 files changed, 10 insertions(+), 319 deletions(-) delete mode 100644 py-scripts/test_utility.py diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index a280adcc..85ce3201 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -293,6 +293,7 @@ class LFCliBase: debug_=debug_, die_on_error_=self.exit_on_error) json_response = lf_r.json_delete(debug=debug_, die_on_error_=self.halt_on_error) + print(json_response) #debug_printer.pprint(json_response) if (json_response is None) and debug_: print("LFCliBase.json_delete: no entity/response, probabily status 404") diff --git a/py-scripts/connection_test.py b/py-scripts/connection_test.py index 1719bd6d..525b4fa6 100644 --- a/py-scripts/connection_test.py +++ b/py-scripts/connection_test.py @@ -24,6 +24,7 @@ from test_utility import CreateHTML from test_utility import StatusMsg import pdfkit + webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) class ConnectionTest(LFCliBase): @@ -97,6 +98,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('3', {"data": 'Building...', "data": [], "label": "Client Connectivity Time"}) except: pass + def build(self): self.station_profile.use_security(self.security, self.ssid, self.password) @@ -111,6 +113,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('4', {"data": 'Starting...', "data": [], "label": "Client Connectivity Time"}) except: pass + def update(self, status="None"): for i in self.station_list: self.station_data[i.split(".")[2]] = \ @@ -119,6 +122,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('5', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) except: pass + def start(self): self.station_profile.admin_up() associated_map = {} @@ -213,6 +217,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('6', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) except: pass + def stop(self): self.station_profile.admin_down() LFUtils.wait_until_ports_admin_down(port_list=self.station_profile.station_names) @@ -258,12 +263,14 @@ def main(): obj.status_msg.update('10', {"data": 'done...', "data": [], "label": "Client Connectivity Time"}) except: pass - + for i in obj.status_msg.read()['messages']: + print(i) def getSessionID(): x = datetime.datetime.now() id = x.strftime("%x").replace("/","_")+"_"+x.strftime("%x") + "_" + x.strftime("%X").split(":")[0] + "_" + x.strftime("%X").split(":")[1] + "_" + x.strftime("%X").split(":")[2]+str(x).split(".")[1] - id = str(id).replace("/", "_") + id = str(id).replace("/", "_").split("P")[0].replace(" ","") return id + if __name__ == '__main__': main() diff --git a/py-scripts/test_utility.py b/py-scripts/test_utility.py deleted file mode 100644 index f684528b..00000000 --- a/py-scripts/test_utility.py +++ /dev/null @@ -1,317 +0,0 @@ - -""" -Candela Technologies Inc. - -Info : Standard Script for Webconsole Test Utility -Date : - - -""" - -import sys -from pprint import pprint -from uuid import uuid1 - -if 'py-json' not in sys.path: - sys.path.append('../py-json') -from LANforge import LFUtils -from LANforge import lfcli_base -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -import realm -from realm import PortUtils -import argparse -import datetime -import time -import matplotlib.pyplot as plt -import threading -import re -import json -import os -webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) -updates_path = webconsole_dir + "/web_json/updates.js" - - -class ClientVisualization(LFCliBase, threading.Thread): - def __init__(self, lfclient_host="localhost", lfclient_port=8080, num_clients= 64, max_data= 120, thread_id=None, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): - super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, - _exit_on_fail=_exit_on_fail) - threading.Thread.__init__(self) - self.num_clients = num_clients - self.max_data = max_data - self._stop_event = threading.Event() - self.client_data = {"down":[], "phantom":[], "ip":[], "scanning":[]} - - def stop(self): - self._stop_event.set() - - def stopped(self): - return self._stop_event.is_set() - - def run(self): - self.start_thread() - - def start_thread(self): - while True: - self.scanning = 0 - self.ip = 0 - self.down = 0 - self.phantom = 0 - for i in self.json_get("/port/list?fields=port,alias,parent%20dev,down,phantom,ip,port%20type")['interfaces']: - - for j in i: - print(i[j]['port type']) - if i[j]['port type'] == "WIFI-STA" and i[j]['parent dev'] == "wiphy1" and i[j]['alias'] != 'wlan1': - #print(j) - if i[j]['down'] == False and i[j]['phantom'] == False and i[j]['ip'] == '0.0.0.0': - self.scanning += 1 - elif i[j]['down'] == False and i[j]['phantom'] == True: - self.phantom += 1 - elif i[j]['down'] == True and i[j]['phantom'] == True: - self.phantom += 1 - self.client_data['phantom'].append(self.phantom) - elif i[j]['down'] == True and i[j]['phantom'] == False: - self.down += 1 - elif i[j]['ip'] != "0.0.0.0": - self.ip += 1 - else: - continue - self.client_data['scanning'].append(self.scanning) - self.client_data['phantom'].append(self.phantom) - self.client_data['down'].append(self.down) - self.client_data['ip'].append(self.ip) - - - for i in self.client_data: - if len(self.client_data[i]) >= self.max_data: - self.client_data[i].pop(0) - time.sleep(1) - if self.stopped(): - break - - -class CreateHTML(): - def __init__(self, path="", test_name="", time_snap="", dut_ssid="", test_conf_data={}, objective="", test_results={}, chart_data={}, chart_params={}): - self.head = """ - - - """+test_name+""" - - -
- -
-
-

"""+test_name+"""

-

"""+time_snap+"""

-
-
-
- """ - self.test_conf = """ - - - - - - - - -
- Test Setup Information -
- Device Under Test - - - - - - - """ - - for i in test_conf_data: - self.test_conf = self.test_conf + """ - - - - """ - - self.test_conf = self.test_conf + """
- SSID - """+dut_ssid+""" -
"""+str(i)+""" - """+test_conf_data[i]+""" -
-
- """ - - self.objective = """ -

Objective

- """+objective+""" -

-
- """ - - if str(test_results['summary']).__contains__("PASS"): - self.summary_results =""" -
- - - - - - - -
- Summary Results -
- """ + test_results['summary'] + """ -
-
- """ - else: - self.summary_results = """ -
- - - - - - - -
- Summary Results -
- """ + test_results['summary'] + """ -
-
- """ - chart_d =[] - chart_label =[] - for i in chart_data: - chart_label.append(i) - chart_d.append(chart_data[i]) - - - - - self.detail_result = """ - -
Detailed Results
- - """ - for index in test_results['detail']['keys']: - self.detail_result = self.detail_result+"" - self.detail_result = self.detail_result +"" - - for data in test_results['detail']['data']: - self.detail_result = self.detail_result + "" - print("shivam") - print(data) - for i in data: - print(data[i]) - if str(data[i]).__contains__("PASS"): - self.detail_result = self.detail_result + "" - elif str(data[i]).__contains__("FAIL"): - self.detail_result = self.detail_result + "" - else: - self.detail_result = self.detail_result + "" - self.detail_result = self.detail_result +"" - - self.chart_data = chart_data - chart_values = [] - for i in self.chart_data: - chart_values.append(self.chart_data[i]) - plt.bar(list(self.chart_data.keys()), chart_values, tick_label=list(self.chart_data.keys())) - - plt.xlabel(chart_params['xlabel']) - # naming the y-axis - plt.ylabel(chart_params['ylabel']) - # plot title - plt.title(chart_params['chart_head']) - plt.xticks(rotation=90, fontsize=8) - plt.tight_layout() - # function to show the plot - plt.savefig(fname=path + "plot.png") - plt.close() - - self.chart = """""" - - - self.end = """
"+index+"
" + str(data[i]) + "" + str(data[i]) + "" + str(data[i]) + "
- - - - """ - self.report = self.head + self.test_conf + self.objective + self.summary_results + self.chart +self.detail_result + self.end - - - -class RuntimeUpdates(): - def __init__(self, session_id, init_data): - self.session_id = session_id - self.init_data = init_data - f = open(updates_path, 'r+') - data = f.read() - f.close() - obj = data[data.find('{'): data.rfind('}') + 1] - obj = re.sub('[\']', '"', obj) - data = json.loads(obj) - print(data) - data["web_updates"].append({"ID": self.session_id, "data": self.init_data}) - print(data) - f = open(updates_path, 'r+') - f.seek(0) - f.truncate() - f.write("var updates = " + str(data) + ";") - f.close() - - def send_update(self, update_data): - f = open(updates_path, 'r+') - data = f.read() - f.close() - obj = data[data.find('{'): data.rfind('}') + 1] - obj = re.sub('[\']', '"', obj) - data = json.loads(obj) - - for update in data["web_updates"]: - if update["ID"] == self.session_id: - update["data"] = update_data - print(data) - f = open(updates_path, 'r+') - f.seek(0) - f.truncate() - f.write("var updates = " + str(data) + ";") - f.close() - - -class StatusMsg(LFCliBase): - def __init__(self, lfclient_host="localhost", lfclient_port=8080, - _deep_clean=False, - session_id="0", - _debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.deep_clean = _deep_clean - self.session_id = session_id - self.json_put("/status-msg/" + self.session_id, {}) - - def update(self, key, message): - self.json_post("/status-msg/" + self.session_id, { - "key": key, - "content-type": "text/plain", - "message": message - }) - pass - - - - - - -if __name__ == "__main__": - obj = StatusMsg(lfclient_host="192.168.200.15", lfclient_port=8080, session_id="Connection Test") - obj.update() - - From 0789f545e552252e233462007426ecdd5a29d1eb Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 03:55:06 +0530 Subject: [PATCH 048/848] basic arg parse update --- py-json/LANforge/lfcli_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 85ce3201..85f7b4e4 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -510,9 +510,9 @@ class LFCliBase: help='Connection proxy like http://proxy.localnet:80 or https://user:pass@proxy.localnet:3128') #Required Args required.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') - required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >') + required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', default="open") required.add_argument('--ssid', help='WiFi SSID for script objects to associate to') - required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key') + required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key', default="[BLANK]") return parser From f4185de693687c91dcc9c4c375f05a89b808720e Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 05:17:44 +0530 Subject: [PATCH 049/848] some work --- py-json/realm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 5df91dd9..4d46e1c7 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1132,6 +1132,9 @@ class L3CXProfile(BaseProfile): else: return False + """ + coloumn names + """ def monitor(self, duration_sec=60, monitor_interval=1, @@ -1242,9 +1245,9 @@ class L3CXProfile(BaseProfile): import requests import ast try: - systeminfo = ast.literal_eval(requests.get('http://localhost:8080').text) + systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) except: - systeminfo = ast.literal_eval(requests.get('http://192.168.1.3:8080').text) + systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments From 5d0b2ee2a6c84560f5f1145e13295bd574cbc1a1 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 16:56:00 -0700 Subject: [PATCH 050/848] lf_cisco_power.py: fixing regular expression --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index dc53fbb4..327035c0 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -915,7 +915,7 @@ def main(): search_wlan = True continue if (search_wlan): - pat = "{}\s+(\S+)\s+\(\S+)".format(args.wlanID) + pat = "%s\s+(\S+)\s+\(\S+)"%(args.wlanID) m = re.search(pat, line) if (m != None): cc_wlan = m.group(1) From 250d00a9f056f3d3c87581c76f18466f4b2e407a Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 17:20:12 -0700 Subject: [PATCH 051/848] lf_cisco_power.py: fixed reg expression --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 327035c0..576ddce9 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -915,7 +915,7 @@ def main(): search_wlan = True continue if (search_wlan): - pat = "%s\s+(\S+)\s+\(\S+)"%(args.wlanID) + pat = "{}\s+(\S+)\s+(\S+)".format(args.wlanID) m = re.search(pat, line) if (m != None): cc_wlan = m.group(1) From 0890722ddbd2d073eff72581dc7de9128b529617 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 19 Jan 2021 17:25:25 -0700 Subject: [PATCH 052/848] lf_cisco_power.py : update comments LCS-38 9800 series: Before creating a wlan on specific wlanID remove existing wlan if one already created. If delete fails exit script with Error for user intervention --- lf_cisco_power.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 576ddce9..bb208a26 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -922,10 +922,10 @@ def main(): cc_wlan_ssid = m.group(2) # wlanID is in use logg.info("###############################################################################") - logg.info("Need to remove wlan: {} wlanID: {} wlan ssid {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + logg.info("Need to remove wlan: {} wlanID: {} wlan ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) logg.info("###############################################################################") try: - logg.info("9800 cisco_wifi_ctl.py: delete_wlan one was present wlan: {} wlanID: {} wlan_ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + logg.info("9800 cisco_wifi_ctl.py: delete_wlan, wlan present at start of test: wlan: {} wlanID: {} wlan_ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) 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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: From 2451dcbc871644aec3c030aaba28a395a04c43c1 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 19 Jan 2021 16:44:02 -0800 Subject: [PATCH 053/848] install dash on machines --- py-scripts/update_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/update_deps.sh b/py-scripts/update_deps.sh index 3d6ffe6c..0ff68504 100755 --- a/py-scripts/update_deps.sh +++ b/py-scripts/update_deps.sh @@ -1 +1 @@ -pip install pandas seaborn plotly numpy --upgrade +pip install pandas seaborn plotly numpy dash --upgrade From 407c7994e3246c6a6281ed907c6d06aa3c153a00 Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 19:40:14 +0530 Subject: [PATCH 054/848] StatusSession Uodates --- py-json/test_utility.py | 333 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 py-json/test_utility.py diff --git a/py-json/test_utility.py b/py-json/test_utility.py new file mode 100644 index 00000000..68235da9 --- /dev/null +++ b/py-json/test_utility.py @@ -0,0 +1,333 @@ + +""" +Candela Technologies Inc. + +Info : Standard Script for Webconsole Test Utility +Date : + + +""" + +import sys +from pprint import pprint +from uuid import uuid1 + +if 'py-json' not in sys.path: + sys.path.append('../py-json') +from LANforge import LFUtils +from LANforge import lfcli_base +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +import realm +from realm import PortUtils +import argparse +import datetime +import time +import matplotlib.pyplot as plt +import threading +import re +import json +import os +webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) +updates_path = webconsole_dir + "/web_json/updates.js" + + +class ClientVisualization(LFCliBase, threading.Thread): + def __init__(self, lfclient_host="localhost", lfclient_port=8080, num_clients= 64, max_data= 120, thread_id=None, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): + super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, + _exit_on_fail=_exit_on_fail) + threading.Thread.__init__(self) + self.num_clients = num_clients + self.max_data = max_data + self._stop_event = threading.Event() + self.client_data = {"down":[], "phantom":[], "ip":[], "scanning":[]} + + def stop(self): + self._stop_event.set() + + def stopped(self): + return self._stop_event.is_set() + + def run(self): + self.start_thread() + + def start_thread(self): + while True: + self.scanning = 0 + self.ip = 0 + self.down = 0 + self.phantom = 0 + for i in self.json_get("/port/list?fields=port,alias,parent%20dev,down,phantom,ip,port%20type")['interfaces']: + + for j in i: + print(i[j]['port type']) + if i[j]['port type'] == "WIFI-STA" and i[j]['parent dev'] == "wiphy1" and i[j]['alias'] != 'wlan1': + #print(j) + if i[j]['down'] == False and i[j]['phantom'] == False and i[j]['ip'] == '0.0.0.0': + self.scanning += 1 + elif i[j]['down'] == False and i[j]['phantom'] == True: + self.phantom += 1 + elif i[j]['down'] == True and i[j]['phantom'] == True: + self.phantom += 1 + self.client_data['phantom'].append(self.phantom) + elif i[j]['down'] == True and i[j]['phantom'] == False: + self.down += 1 + elif i[j]['ip'] != "0.0.0.0": + self.ip += 1 + else: + continue + self.client_data['scanning'].append(self.scanning) + self.client_data['phantom'].append(self.phantom) + self.client_data['down'].append(self.down) + self.client_data['ip'].append(self.ip) + + + for i in self.client_data: + if len(self.client_data[i]) >= self.max_data: + self.client_data[i].pop(0) + time.sleep(1) + if self.stopped(): + break + + +class CreateHTML(): + def __init__(self, path="", test_name="", time_snap="", dut_ssid="", test_conf_data={}, objective="", test_results={}, chart_data={}, chart_params={}): + self.head = """ + + + """+test_name+""" + + +
+ +
+
+

"""+test_name+"""

+

"""+time_snap+"""

+
+
+
+ """ + self.test_conf = """ + + + + + + + + +
+ Test Setup Information +
+ Device Under Test + + + + + + + """ + + for i in test_conf_data: + self.test_conf = self.test_conf + """ + + + + """ + + self.test_conf = self.test_conf + """
+ SSID + """+dut_ssid+""" +
"""+str(i)+""" + """+test_conf_data[i]+""" +
+
+ """ + + self.objective = """ +

Objective

+ """+objective+""" +

+
+ """ + + if str(test_results['summary']).__contains__("PASS"): + self.summary_results =""" +
+ + + + + + + +
+ Summary Results +
+ """ + test_results['summary'] + """ +
+
+ """ + else: + self.summary_results = """ +
+ + + + + + + +
+ Summary Results +
+ """ + test_results['summary'] + """ +
+
+ """ + chart_d =[] + chart_label =[] + for i in chart_data: + chart_label.append(i) + chart_d.append(chart_data[i]) + + + + + self.detail_result = """ + +
Detailed Results
+ + """ + for index in test_results['detail']['keys']: + self.detail_result = self.detail_result+"" + self.detail_result = self.detail_result +"" + + for data in test_results['detail']['data']: + self.detail_result = self.detail_result + "" + print("shivam") + print(data) + for i in data: + print(data[i]) + if str(data[i]).__contains__("PASS"): + self.detail_result = self.detail_result + "" + elif str(data[i]).__contains__("FAIL"): + self.detail_result = self.detail_result + "" + else: + self.detail_result = self.detail_result + "" + self.detail_result = self.detail_result +"" + + self.chart_data = chart_data + chart_values = [] + for i in self.chart_data: + chart_values.append(self.chart_data[i]) + plt.bar(list(self.chart_data.keys()), chart_values, tick_label=list(self.chart_data.keys())) + + plt.xlabel(chart_params['xlabel']) + # naming the y-axis + plt.ylabel(chart_params['ylabel']) + # plot title + plt.title(chart_params['chart_head']) + plt.xticks(rotation=90, fontsize=8) + plt.tight_layout() + # function to show the plot + plt.savefig(fname=path + "plot.png") + plt.close() + + self.chart = """""" + + + self.end = """
"+index+"
" + str(data[i]) + "" + str(data[i]) + "" + str(data[i]) + "
+ + + + """ + self.report = self.head + self.test_conf + self.objective + self.summary_results + self.chart +self.detail_result + self.end + + + +class RuntimeUpdates(): + def __init__(self, session_id, init_data): + self.session_id = session_id + self.init_data = init_data + f = open(updates_path, 'r+') + data = f.read() + f.close() + obj = data[data.find('{'): data.rfind('}') + 1] + obj = re.sub('[\']', '"', obj) + data = json.loads(obj) + print(data) + data["web_updates"].append({"ID": self.session_id, "data": self.init_data}) + print(data) + f = open(updates_path, 'r+') + f.seek(0) + f.truncate() + f.write("var updates = " + str(data) + ";") + f.close() + + def send_update(self, update_data): + f = open(updates_path, 'r+') + data = f.read() + f.close() + obj = data[data.find('{'): data.rfind('}') + 1] + obj = re.sub('[\']', '"', obj) + data = json.loads(obj) + + for update in data["web_updates"]: + if update["ID"] == self.session_id: + update["data"] = update_data + print(data) + f = open(updates_path, 'r+') + f.seek(0) + f.truncate() + f.write("var updates = " + str(data) + ";") + f.close() + + +class StatusSession(LFCliBase): + def __init__(self, lfclient_host="localhost", lfclient_port=8080, + _deep_clean=False, + session_id="0", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.deep_clean = _deep_clean + self.session_id = session_id + self.json_put("/status-msg/" + self.session_id, {}) + + def update(self, key, message): + """ + Method to add new Message into a session + """ + self.json_post("/status-msg/" + self.session_id, { + "key": key, + "content-type": "text/plain", + "message": message + }) + + def read(self): + """ + Method to read all the messages for a particular session + """ + keys = [] + for i in self.json_get("/status-msg/"+self.session_id)['messages']: + keys.append(i['key']) + json_uri = "/status-msg/"+self.session_id + "/" + for i in keys: + json_uri = json_uri + i + "," + return self.json_get(json_uri)['messages'] + + + + + + + + +if __name__ == "__main__": + obj = StatusMsg(lfclient_host="localhost", lfclient_port=8090, session_id="01_18_21_20_04_20") + print(obj.read()) + + From 5b28c6ab107d54ba21a3b5eed4ce9ed834f95f2d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 20 Jan 2021 07:46:40 -0700 Subject: [PATCH 055/848] lf_cisco_dfs.py , lf_cisco_snp.py : LCS-42 Update Cisco Controller class for variable prompt --- py-scripts/lf_cisco_dfs.py | 108 +++++++++++++++++++------------------ py-scripts/lf_cisco_snp.py | 106 +++++++++++++++++++----------------- 2 files changed, 115 insertions(+), 99 deletions(-) diff --git a/py-scripts/lf_cisco_dfs.py b/py-scripts/lf_cisco_dfs.py index ac191d0f..cf8a8b2a 100644 --- a/py-scripts/lf_cisco_dfs.py +++ b/py-scripts/lf_cisco_dfs.py @@ -51,14 +51,11 @@ class hack_rf_(): pass - - - - ################################################################################ # cisco controller class :This class will be left in this file to allow for the # Scaling and Performance to be self contained and not impact other tests ################################################################################ + class cisco_(): def __init__(self, args): self.args = args @@ -67,9 +64,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action summary --series 9800 --log stdout def controller_show_summary(self): try: - self.args.cisco - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -92,8 +89,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action advanced --series 9800 --log stdout def controller_show_ap_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"advanced")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"advanced")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -112,8 +110,9 @@ class cisco_(): #show wlan summary def controller_show_wlan_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"show wlan summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"show wlan summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -134,11 +133,12 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable --series 9800 def controller_disable_ap(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", - self.args.cisco_user, "-p", self.args.cisco_passwd, + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", + self.args.cisco_ctlr, "-u",self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable"], capture_output=self.args.cap_ctl_out, check=True) @@ -157,8 +157,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_wlan --series 9800 def controller_disable_wlan(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_wlan")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -181,8 +182,9 @@ class cisco_(): def controller_disable_network_5ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_5ghz")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_5ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -200,8 +202,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a disable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -225,8 +227,9 @@ class cisco_(): def controller_disable_network_24ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_24ghz")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_24ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -244,8 +247,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b disable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -271,8 +274,9 @@ class cisco_(): def controller_role_manual(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"manual")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"manual")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -297,8 +301,9 @@ class cisco_(): def controller_role_auto(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"auto")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"auto")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -321,8 +326,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action txPower --value 5 --series 9800 def controller_set_tx_power(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"txPower", self.args.cisco_tx_power )) # TODO fix txPower to tx_power in cisco_wifi_ctl.py ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -347,8 +352,8 @@ class cisco_(): # 3504 : (Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 52 def controller_set_channel(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_channel )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -371,8 +376,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action bandwidth --value 40 --series 9800 def controller_set_bandwidth(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_chan_width )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -396,8 +401,8 @@ class cisco_(): def controller_create_wlan(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -422,8 +427,8 @@ class cisco_(): def controller_set_wireless_tag_policy(self): if self.args.cisco_series == "9800": try: - logg.info("scheme {} ctlr {} user {} passwd {} AP {} series {} band {} action {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"wireless_tag_policy" )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -448,8 +453,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_wlan --series 9800 def controller_enable_wlan(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -473,8 +478,8 @@ class cisco_(): def controller_enable_network_5ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_5ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -493,8 +498,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a enable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -519,8 +524,8 @@ class cisco_(): def controller_enable_network_24ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_24ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -539,8 +544,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b enable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -564,8 +569,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable --series 9800 def controller_enable_ap(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -639,6 +644,7 @@ class cisco_(): ########################################## + ########################################## # Traffic Generation ########################################## diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index 30bc481a..087af28b 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -50,8 +50,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action summary --series 9800 --log stdout def controller_show_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -74,8 +75,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action advanced --series 9800 --log stdout def controller_show_ap_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"advanced")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"advanced")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -94,8 +96,9 @@ class cisco_(): #show wlan summary def controller_show_wlan_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"show wlan summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"show wlan summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -116,11 +119,12 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable --series 9800 def controller_disable_ap(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", - self.args.cisco_user, "-p", self.args.cisco_passwd, + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", + self.args.cisco_ctlr, "-u",self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable"], capture_output=self.args.cap_ctl_out, check=True) @@ -139,8 +143,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_wlan --series 9800 def controller_disable_wlan(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_wlan")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -163,8 +168,9 @@ class cisco_(): def controller_disable_network_5ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_5ghz")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_5ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -182,8 +188,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a disable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -207,8 +213,9 @@ class cisco_(): def controller_disable_network_24ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_24ghz")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_24ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -226,8 +233,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b disable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -253,8 +260,9 @@ class cisco_(): def controller_role_manual(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"manual")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"manual")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -279,8 +287,9 @@ class cisco_(): def controller_role_auto(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"auto")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"auto")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -303,8 +312,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action txPower --value 5 --series 9800 def controller_set_tx_power(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"txPower", self.args.cisco_tx_power )) # TODO fix txPower to tx_power in cisco_wifi_ctl.py ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -329,8 +338,8 @@ class cisco_(): # 3504 : (Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 52 def controller_set_channel(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_channel )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -353,8 +362,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action bandwidth --value 40 --series 9800 def controller_set_bandwidth(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_chan_width )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -378,8 +387,8 @@ class cisco_(): def controller_create_wlan(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -404,8 +413,8 @@ class cisco_(): def controller_set_wireless_tag_policy(self): if self.args.cisco_series == "9800": try: - logg.info("scheme {} ctlr {} user {} passwd {} AP {} series {} band {} action {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"wireless_tag_policy" )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -430,8 +439,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_wlan --series 9800 def controller_enable_wlan(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -455,8 +464,8 @@ class cisco_(): def controller_enable_network_5ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_5ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -475,8 +484,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a enable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -501,8 +510,8 @@ class cisco_(): def controller_enable_network_24ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_24ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -521,8 +530,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b enable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -546,8 +555,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable --series 9800 def controller_enable_ap(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -943,8 +952,9 @@ class L3VariableTime(LFCliBase): return try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, From a80f2d68def733165c78d0adad5efe972c0f3d1b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 20 Jan 2021 12:47:06 -0700 Subject: [PATCH 056/848] lf_cisco_power.py : LCS-43 Put Controller Channel in the spread sheet --- lf_cisco_power.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index bb208a26..1a08c7fe 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -528,6 +528,7 @@ def main(): col = 0 row = 0 worksheet.write(row, col, 'Regulatory\nDomain', dblue_bold); col += 1 + worksheet.write(row, col, 'Controller\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'AP\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'NSS', dblue_bold); col += 1 worksheet.set_column(col, col, 10) # Set width @@ -1573,6 +1574,7 @@ def main(): col = 0 worksheet.write(row, col, myrd, center_blue); col += 1 + worksheet.write(row, col, cc_ch, center_blue); col += 1 worksheet.write(row, col, _ch, center_blue); col += 1 worksheet.write(row, col, _nss, center_blue); col += 1 worksheet.write(row, col, cc_bw, center_blue); col += 1 From f3f913d6e4b8ae43547222f7f7793dc0755d923f Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 20 Jan 2021 13:03:49 -0700 Subject: [PATCH 057/848] lf_cisco_power.py : LCS-43 changed column width --- lf_cisco_power.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1a08c7fe..06fb4949 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -528,6 +528,7 @@ def main(): col = 0 row = 0 worksheet.write(row, col, 'Regulatory\nDomain', dblue_bold); col += 1 + worksheet.set_column(col, col, 10) # Set width worksheet.write(row, col, 'Controller\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'AP\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'NSS', dblue_bold); col += 1 From f575441f1e032d5d5c0643525f0e385964be99ef Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 20 Jan 2021 14:08:00 -0700 Subject: [PATCH 058/848] lf_cisco_power.py: LCS-44 Some channels do not support BW greater then 20, need to set BW to 20 then channel then new BW --- lf_cisco_power.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 06fb4949..0893c9ff 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -862,6 +862,20 @@ def main(): 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) + if (bw != "NA"): + try: + logg.info("9800/3504 cisco_wifi_ctl.py: bandwidth 20 prior to setting channel, some channels only support 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,"--prompt",args.prompt],capture_output=cap_ctl_out, check=True) + if cap_ctl_out: + pss = ctl_output.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) + + # NSS is set on the station earlier... if (ch != "NA"): logg.info("9800/3504 test_parameters set channel: {}".format(ch)) From ca9938acacff761652936be9fffb2f33bda8357d Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 20 Jan 2021 16:08:46 -0800 Subject: [PATCH 059/848] ws-sta-monitor.py: adds --port switch, fixes --host switch logic, improved indentation --- py-json/ws-sta-monitor.py | 156 +++++++++++++++++++++----------------- 1 file changed, 87 insertions(+), 69 deletions(-) diff --git a/py-json/ws-sta-monitor.py b/py-json/ws-sta-monitor.py index de72ca3d..e5a9a5eb 100755 --- a/py-json/ws-sta-monitor.py +++ b/py-json/ws-sta-monitor.py @@ -16,6 +16,7 @@ if sys.version_info[0] != 3: import argparse import json import logging +import pprint import traceback import time from time import sleep @@ -25,11 +26,7 @@ try: import thread except ImportError: import _thread as thread -import pprint -import LANforge -from LANforge import LFRequest from LANforge import LFUtils -from LANforge.LFUtils import NA cre={ "phy": re.compile(r'^(1\.\d+):\s+(\S+)\s+\(phy', re.I), @@ -69,29 +66,46 @@ rebank = { "ifname" : re.compile("IFNAME=(\S+)") } websock = None +host = "localhost" +base_url = None +port = 8081 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def usage(): + print("""Example: __file__ --host 192.168.1.101 --port 8081\n""") + + def main(): global websock - host = "localhost" - base_url = "ws://%s:8081"%host - resource_id = 1 # typically you're using resource 1 in stand alone realm + # global host + # global base_url + # resource_id = 1 # typically you're using resource 1 in stand alone realm parser = argparse.ArgumentParser(description="test creating a station") - parser.add_argument("-m", "--host", type=str, help="json host to connect to") + parser.add_argument("-m", "--host", type=str, help="websocket host to connect to") + parser.add_argument("-p", "--port", type=str, help="websoket port") - args = None + host = "unset" + base_url = "unset" try: - args = parser.parse_args() - if (args.host is not None): - host = args.host, - baseurl = base_url = "ws://%s:8081"%host + args = parser.parse_args() + if (args.host is None): + host = "localhost" + elif (type(args) is tuple) or (type(args) is list): + host = args.host[0] + else: + host = args.host + + base_url = "ws://%s:%s" % (host, port) + except Exception as e: - logging.exception(e) - usage() - exit(2) + print("Exception: "+e) + logging.exception(e) + usage() + exit(2) # open websocket + # print("Main: base_url: %s, host:%s, port:%s" % (base_url, host, port)) websock = start_websocket(base_url, websock) @@ -125,16 +139,16 @@ def sock_filter(wsock, text): if (test in message["details"]): return; except KeyError: - print ("Message lacks key 'details'") + print("Message lacks key 'details'") try: if ("wifi-event" in message.keys()): for test in ignore: - #print (" is ",test, " in ", message["wifi-event"]) + # print (" is ",test, " in ", message["wifi-event"]) if (test in message["wifi-event"]): return; except KeyError: - print("Message lacks key 'wifi-event'" ) + print("Message lacks key 'wifi-event'") if (("time" in message.keys()) and ("timestamp" in message.keys())): return @@ -150,27 +164,28 @@ def sock_filter(wsock, text): station_name = match_result.group(1) if (message["is_alert"]): - print ("alert: ", message["details"]) - #LFUtils.debug_printer.pprint(message) + print("alert: ", message["details"]) + # LFUtils.debug_printer.pprint(message) return else: - #LFUtils.debug_printer.pprint(message) + # LFUtils.debug_printer.pprint(message) if (" IP change from " in message["details"]): if (" to 0.0.0.0" in messsage["details"]): - print ("e: %s.%s lost IP address",[resource,station_name]) + print("e: %s.%s lost IP address", [resource, station_name]) else: - print ("e: %s.%s gained IP address",[resource,station_name]) + print("e: %s.%s gained IP address", [resource, station_name]) if ("Link DOWN" in message["details"]): - return # duplicates alert + return # duplicates alert - print ("event: ", message["details"]) + print("event: ", message["details"]) return if ("wifi-event" in message.keys()): if ("CTRL-EVENT-CONNECTED" in message["wifi-event"]): # redunant return - if (("CTRL-EVENT-CONNECTED - Connection to " in message["wifi-event"]) and (" complete" in message["wifi-event"])): + if (("CTRL-EVENT-CONNECTED - Connection to " in message["wifi-event"]) and ( + " complete" in message["wifi-event"])): return; if ((": assoc " in message["wifi-event"]) and ("status: 0: Successful" in message["wifi-event"])): return @@ -178,61 +193,61 @@ def sock_filter(wsock, text): try: match_result = cre["phy"].match(message["wifi-event"]) if (match_result is not None): - #LFUtils.debug_printer.pprint(match_result) - #LFUtils.debug_printer.pprint(match_result.groups()) + # LFUtils.debug_printer.pprint(match_result) + # LFUtils.debug_printer.pprint(match_result.groups()) resource = match_result.group(1) station_name = match_result.group(2) else: match_result = cre["ifname"].match(message["wifi-event"]) - #LFUtils.debug_printer.pprint(match_result) - #LFUtils.debug_printer.pprint(match_result.groups()) + # LFUtils.debug_printer.pprint(match_result) + # LFUtils.debug_printer.pprint(match_result.groups()) if (match_result is not None): resource = match_result.group(1) station_name = match_result.group(2) else: - print ("Is there some other combination??? :", message["wifi-event"]) + print("Is there some other combination??? :", message["wifi-event"]) station_name = 'no-sta' resource_name = 'no-resource' - print ("bleh!") + print("bleh!") except Exception as ex2: - print ("No regex match:") + print("No regex match:") print(repr(ex2)) traceback.print_exc() sleep(1) - #print ("Determined station name: as %s.%s"%(resource, station_name)) + # print ("Determined station name: as %s.%s"%(resource, station_name)) if ((": auth ") and ("status: 0: Successful" in message["wifi-event"])): match_result = cre["auth"].match(message["wifi-event"]) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s auth with %s"%(resource,station_name,bssid)) + print("station %s.%s auth with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s auth with ??"%(resource,station_name)) + print("station %s.%s auth with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("Associated with " in message["wifi-event"]): match_result = cre["associated"].match(message["wifi-event"]) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s assocated with %s"%(resource,station_name,bssid)) + print("station %s.%s assocated with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s assocated with ??"%(resource,station_name)) + print("station %s.%s assocated with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if (" - Connection to " in message["wifi-event"]): match_result = cre["connected"].match(message["wifi-event"]) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s connected to %s"%(resource,station_name,bssid)) + print("station %s.%s connected to %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s connected to ??"%(resource,station_name)) + print("station %s.%s connected to ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("disconnected" in message["wifi-event"]): - print ("Station %s.%s down"%(resource,station_name)) + print("Station %s.%s down" % (resource, station_name)) return if ("Trying to associate with " in message["wifi-event"]): @@ -240,10 +255,10 @@ def sock_filter(wsock, text): if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s associating with %s"%(resource,station_name,bssid)) + print("station %s.%s associating with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s associating with ??"%(resource,station_name)) + print("station %s.%s associating with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("Trying to authenticate" in message["wifi-event"]): @@ -251,10 +266,10 @@ def sock_filter(wsock, text): if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s authenticating with %s"%(resource,station_name,bssid)) + print("station %s.%s authenticating with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s authenticating with ??"%(resource,station_name)) + print("station %s.%s authenticating with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("Authenticated" in message["wifi-event"]): @@ -262,67 +277,70 @@ def sock_filter(wsock, text): LFUtils.debug_printer.pprint(match_result) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s authenticated with %s"%(resource,station_name,bssid)) + print("station %s.%s authenticated with %s" % (resource, station_name, bssid)) else: - print ("station %s.%s authenticated with ??"%(resource,station_name)) + print("station %s.%s authenticated with ??" % (resource, station_name)) - print ("w: ", message["wifi-event"]) + print("w: ", message["wifi-event"]) else: - print ("\nUnhandled: ") + print("\nUnhandled: ") LFUtils.debug_printer.pprint(message) except KeyError as kerr: - print ("# ----- Bad Key: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") - print ("input: ",text) - print (repr(kerr)) + print("# ----- Bad Key: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("input: ", text) + print(repr(kerr)) traceback.print_exc() - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") sleep(1) return except json.JSONDecodeError as derr: - print ("# ----- Decode err: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") - print ("input: ",text) - print (repr(derr)) + print("# ----- Decode err: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("input: ", text) + print(repr(derr)) traceback.print_exc() - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") sleep(1) return except Exception as ex: - print ("# ----- Exception: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- Exception: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") print(repr(ex)) - print ("input: ",text) + print("input: ", text) LFUtils.debug_printer.pprint(message) traceback.print_exc() - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") sleep(1) return # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def m_error(wsock, err): - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") + print("# ----- Error: ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") LFUtils.debug_printer.pprint(err) - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def m_open(wsock): def run(*args): time.sleep(0.1) - #ping = json.loads(); + # ping = json.loads(); wsock.send('{"text":"ping"}') + thread.start_new_thread(run, ()) - print ("started websocket client") + print("Connected...") + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def m_close(wsock): LFUtils.debug_printer.pprint(wsock) + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def start_websocket(uri, websock): - #websocket.enableTrace(True) websock = websocket.WebSocketApp(uri, - on_message = sock_filter, - on_error = m_error, - on_close = m_close) + on_message=sock_filter, + on_error=m_error, + on_close=m_close) websock.on_open = m_open websock.run_forever() return websock From 09b4ee74c0d4743f9a32d6bf001d179a54b2e6be Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 20 Jan 2021 17:46:58 -0700 Subject: [PATCH 060/848] cisco_ap_ctl.py : LSC-45 Read AP for Power related values --- cisco_ap_ctl.py | 280 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 cisco_ap_ctl.py diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py new file mode 100644 index 00000000..73a8f4d1 --- /dev/null +++ b/cisco_ap_ctl.py @@ -0,0 +1,280 @@ +#!/usr/bin/python3 +''' +LANforge 192.168.100.178 +Controller at 192.168.100.112 admin/Cisco123 +Controller is 192.1.0.10 +AP is on serial port /dev/ttyUSB1 9600 8 n 1 + +make sure pexpect is installed: +$ sudo yum install python3-pexpect + +You might need to install pexpect-serial using pip: +$ pip3 install pexpect-serial + +./cisco_ap_ctl.py +''' + + +import sys +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +import re +import logging +import time +from time import sleep +import pprint +import telnetlib +import argparse +import pexpect + +default_host = "localhost" +default_ports = { + "serial": None, + "ssh": 22, + "telnet": 23 +} +NL = "\n" +CR = "\r\n" +Q = '"' +A = "'" +FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s' +band = "a" +logfile = "stdout" + +# regex101.com , +# this will be in the tx_power script +# ^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+) + +def usage(): + print("$0 used connect to Cisco AP:") + print("-a|--ap: AP to act upon") + print("-d|--dest: destination host") + print("-o|--port: destination port") + print("-u|--user: AP login name") + print("-p|--pass: AP password") + print("-s|--scheme (serial|telnet|ssh): connect to controller via serial, ssh or telnet") + print("--tty Serial port for accessing AP") + print("-l|--log file: log messages here") + print("-b|--band: a (5Ghz) or b (2.4Ghz) or abgn for dual-band 2.4Ghz AP") + print("-h|--help") + +# see https://stackoverflow.com/a/13306095/11014343 +class FileAdapter(object): + def __init__(self, logger): + self.logger = logger + def write(self, data): + # NOTE: data can be a partial line, multiple lines + data = data.strip() # ignore leading/trailing whitespace + if data: # non-blank + self.logger.info(data) + def flush(self): + pass # leave it to logging to flush properly + +def main(): + + global logfile + + parser = argparse.ArgumentParser(description="Cisco AP Control Script") + parser.add_argument("-a", "--ap", type=str, help="select AP") + parser.add_argument("-d", "--dest", type=str, help="address of the AP 172.19.27.55") + 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("-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("-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") + + args = None + try: + args = parser.parse_args() + host = args.dest + scheme = args.scheme + port = (default_ports[scheme], args.port)[args.port != None] + user = args.user + passwd = args.passwd + if (args.log != None): + logfile = args.log + filehandler = None + except Exception as e: + logging.exception(e) + usage() + exit(2) + + console_handler = logging.StreamHandler() + formatter = logging.Formatter(FORMAT) + 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=[file_handler]) + else: + # stdout logging + logging.basicConfig(format=FORMAT, handlers=[console_handler]) + + egg = None # think "eggpect" + ser = None + try: + if (scheme == "serial"): + #eggspect = pexpect.fdpexpect.fdspan(telcon, logfile=sys.stdout.buffer) + import serial + from pexpect_serial import SerialSpawn + ser = serial.Serial(args.tty, 9600, timeout=5) + print("Created serial connection on %s, open: %s"%(args.tty, ser.is_open)) + egg = SerialSpawn(ser); + egg.logfile = FileAdapter(logg) + time.sleep(1) + + elif (scheme == "ssh"): + if (port is None): + port = 22 + cmd = "ssh -p%d %s@%s"%(port, user, host) + logg.info("Spawn: "+cmd+NL) + egg = pexpect.spawn(cmd) + #egg.logfile_read = sys.stdout.buffer + egg.logfile = FileAdapter(logg) + i = egg.expect(["password:", "continue connecting (yes/no)?"], timeout=3) + time.sleep(0.1) + if i == 1: + egg.sendline('yes') + egg.expect('password:') + sleep(0.1) + egg.sendline(args.passwd) + + elif (scheme == "telnet"): + if (port is None): + port = 23 + cmd = "telnet %s %d"%(host, port) + logg.info("Spawn: "+cmd+NL) + egg = pexpect.spawn(cmd) + egg.logfile = FileAdapter(logg) + # Will login below as needed. + else: + usage() + exit(1) + except Exception as e: + logging.exception(e); + + ap_prompt = "%s>"%(args.ap) + ap_hash = "%s#"%(args.ap) + egg.sendline() + + i = egg.expect(['Password:', 'Username:', ap_prompt, 'u-boot>', ap_hash], timeout=3) + j = 0 + if i == 0: + egg.sendline() + i = egg.expect(['Password:', 'Username:', ap_prompt, 'u-boot>', ap_hash], timeout=10) + + i -= 1 + + if i == 0: + time.sleep(1) + egg.sendline(args.user) + time.sleep(1) + egg.expect('Password:') + egg.sendline(args.passwd) + + if (i <= 1): + egg.expect(ap_prompt) + egg.sendline("en") + egg.expect("Password:") + egg.sendline(args.passwd) + egg.expect("#") + + # Seems this cannot work on factory images, so comment it out. It is one-time + # thing, user must do it manually. + #logg.info('Login to Devshell and issue the updt command') + #egg.sendline('devshell') + #egg.expect("#", timeout=5) + #egg.sendline("updt_util -i /lib/firmware/%s uboot"%(args.binfile)) + # if updt_util is not available, we must already be in the netbooted cookie shell + #egg.expect("#") + #egg.sendline('exit') + #egg.expect("#", timeout=5) + + logg.info("Reload the AP and bring it to u-boot") + egg.sendline('reload') + egg.expect(r"confirm") + egg.sendline('yes') + time.sleep(10) + egg.expect(r'Hit ESC key to stop autoboot:', timeout=100) + egg.sendline('\x1b') + egg.expect(r"u-boot>") + egg.sendline('printenv') + time.sleep(5) + egg.expect(r"u-boot>") + + if (i <= 2): + logg.info("Set the env variable and download bcm.bin from TFTP server") + time.sleep(1) + egg.sendline("setenv ipaddr %s"%(args.ip)) + time.sleep(1) + egg.expect(r"u-boot>") + egg.sendline("setenv netmask %s"%(args.mask)) + time.sleep(1) + egg.expect(r"u-boot>") + egg.sendline("setenv serverip %s"%(args.tftp_server)) + time.sleep(2) + egg.expect(r"u-boot>") + egg.sendline("setenv gatewayip %s"%(args.gw)) + time.sleep(2) + egg.expect(r"u-boot>") + egg.sendline('setenv tftpdir /') + time.sleep(2) + egg.expect(r"u-boot>") + egg.sendline('saveenv') + time.sleep(10) + egg.expect("u-boot>", timeout=5) + egg.sendline('printenv') + time.sleep(10) + egg.expect("u-boot>", timeout=15) + + egg.sendline("netboot %s"%(args.netboot_binfile)) + while True: + time.sleep(10) + k = egg.expect(["Username:", "Unable to download image"], timeout=240) + if (k == 0): + break + if (k == 1): + egg.sendline("netboot %s"%(args.netboot_binfile)) + continue + break + + + logg.info("Setting up the cookie from devshell and rebooting the AP") + + # Log in again + egg.sendline() + time.sleep(0.1) + egg.expect('Username:', timeout=3) + time.sleep(0.1) + egg.sendline(args.user) + time.sleep(0.1) + egg.expect('Password:') + egg.sendline(args.passwd) + + egg.expect(ap_prompt) + egg.sendline("en") + egg.expect("Password:") + egg.sendline(args.passwd) + egg.expect("#") + + + egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect("#", timeout=5) + # ctlr.execute(cn_cmd) + + +# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- +if __name__ == '__main__': + main() + +#### +#### +#### From 926e746cd895d1880da6e1204379d8c52af8715e Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 20 Jan 2021 23:25:37 -0800 Subject: [PATCH 061/848] wct-example.py is out-dated --- py-json/wct-example.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py-json/wct-example.py b/py-json/wct-example.py index 59e03302..0d1e1410 100755 --- a/py-json/wct-example.py +++ b/py-json/wct-example.py @@ -2,7 +2,8 @@ ''' # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - -# Example of how to operate a WCT instance using cli-socket - +# Example of how to operate a WCT instance using cli-socket. - +# This script is out-dated. Please refer to py-scripts/run_cv_scenario.py - # - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make sure pexpect is installed: @@ -156,4 +157,4 @@ if __name__ == '__main__': #### #### -#### \ No newline at end of file +#### From 437f86b96f6a5507b5b30170c7c6b5c1944b1028 Mon Sep 17 00:00:00 2001 From: Dipti Date: Wed, 20 Jan 2021 23:32:11 -0800 Subject: [PATCH 062/848] deletion of excess func - 'get rx values' , indication of if IP address is present --- py-scripts/test_ipv4_variable_time.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 570f77c0..7d4e9264 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -89,23 +89,9 @@ class IPV4VariableTime(LFCliBase): self.cx_profile.side_b_min_bps = side_b_min_rate self.cx_profile.side_b_max_bps = side_b_max_rate - - def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) - if self.debug: - print(self.cx_profile.created_cx.values()) - print("==============\n", cx_list, "\n==============") - cx_rx_map = {} - for cx_name in cx_list['endpoint']: - if cx_name != 'uri' and cx_name != 'handler': - for item, value in cx_name.items(): - for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): - cx_rx_map[item] = value_rx - return cx_rx_map - def start(self, print_pass=False, print_fail=False): self.station_profile.admin_up() + #to-do- check here if upstream port got IP temp_stas = self.station_profile.station_names.copy() if self.local_realm.wait_for_ip(temp_stas): @@ -253,8 +239,6 @@ python3 ./test_ipv4_variable_time.py print(ip_var_test.get_fail_message()) ip_var_test.exit_fail() ip_var_test.start(False, False) - - layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], report_file=report_f, From 2512aff66c1706f6003cf0b381b368189a507b77 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 20 Jan 2021 23:49:29 -0800 Subject: [PATCH 063/848] Marked as outdated --- py-scripts/vap_stations_example.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py-scripts/vap_stations_example.py b/py-scripts/vap_stations_example.py index ba658f38..c6366ae9 100755 --- a/py-scripts/vap_stations_example.py +++ b/py-scripts/vap_stations_example.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" +This is an outdated example. Please see modern py-scripts/test_X example scripts. +""" import sys if sys.version_info[0] != 3: print("This script requires Python 3") From 1ccbe6ffb21413dd3ba326c142827ffcd02ace72 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 20 Jan 2021 23:55:27 -0800 Subject: [PATCH 064/848] marked as out of date --- py-json/generic_cx.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py-json/generic_cx.py b/py-json/generic_cx.py index de0e77b1..1db36b8b 100755 --- a/py-json/generic_cx.py +++ b/py-json/generic_cx.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" +This script is out-dated, please see py-scripts/test_ipv4_variable_time.py +""" import sys import pprint from pprint import pprint From b0ed3170861be2c6802fa8bf75764f119ee90f1c Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Wed, 20 Jan 2021 23:56:25 -0800 Subject: [PATCH 065/848] moving old things to the geriatric ward --- py-json/{ => old-examples}/create_sta.py | 0 py-json/{ => old-examples}/generic_cx.py | 0 py-json/{ => old-examples}/test_l4.py | 0 py-json/{ => old-examples}/wct-example.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename py-json/{ => old-examples}/create_sta.py (100%) rename py-json/{ => old-examples}/generic_cx.py (100%) rename py-json/{ => old-examples}/test_l4.py (100%) rename py-json/{ => old-examples}/wct-example.py (100%) diff --git a/py-json/create_sta.py b/py-json/old-examples/create_sta.py similarity index 100% rename from py-json/create_sta.py rename to py-json/old-examples/create_sta.py diff --git a/py-json/generic_cx.py b/py-json/old-examples/generic_cx.py similarity index 100% rename from py-json/generic_cx.py rename to py-json/old-examples/generic_cx.py diff --git a/py-json/test_l4.py b/py-json/old-examples/test_l4.py similarity index 100% rename from py-json/test_l4.py rename to py-json/old-examples/test_l4.py diff --git a/py-json/wct-example.py b/py-json/old-examples/wct-example.py similarity index 100% rename from py-json/wct-example.py rename to py-json/old-examples/wct-example.py From 7613b2bb1a9f4c2fc3ce259ba76965e378255f36 Mon Sep 17 00:00:00 2001 From: anjali Date: Thu, 21 Jan 2021 14:05:28 +0530 Subject: [PATCH 066/848] renamed wlan_test.py to wlan_theoretical_sta.py --- py-json/{wlan_test.py => wlan_theoretical_sta.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename py-json/{wlan_test.py => wlan_theoretical_sta.py} (100%) diff --git a/py-json/wlan_test.py b/py-json/wlan_theoretical_sta.py similarity index 100% rename from py-json/wlan_test.py rename to py-json/wlan_theoretical_sta.py From 9f6dffdd554ae48ee84c5cfe888eb002e78a5479 Mon Sep 17 00:00:00 2001 From: anjali Date: Thu, 21 Jan 2021 14:20:11 +0530 Subject: [PATCH 067/848] Modify Wlan Capacity Claculator Script --- py-json/wlan_theoretical_sta.py | 394 +++++++++++++++---------- py-scripts/wlan_capacity_calculator.py | 105 +++---- 2 files changed, 284 insertions(+), 215 deletions(-) diff --git a/py-json/wlan_theoretical_sta.py b/py-json/wlan_theoretical_sta.py index 10506e67..33da6451 100644 --- a/py-json/wlan_theoretical_sta.py +++ b/py-json/wlan_theoretical_sta.py @@ -1,5 +1,10 @@ ''' +Candela Technologies Inc. +Info : Standard Script for WLAN Capaity Calculator +Date : +Author : Anjali Rahamatkar + This Script has three classes : 1. abg11_calculator : It will take all the user input of 802.11a/b/g station,calculate Intermediate values and Theoretical values. 2. n11_calculator : It will take all the user input of 802.11n station,calculate Intermediate values and Theoretical values. @@ -15,7 +20,8 @@ import json # Class to take all user input (802.11a/b/g Standard) -class abg11_calculator: + +class abg11_calculator(): def __init__(self, Traffic_Type, PHY_Bit_Rate, Encryption, QoS, MAC_Frame_802_11, Basic_Rate_Set, Preamble, slot_name, Codec_Type, RTS_CTS_Handshake, CTS_to_self): @@ -31,9 +37,77 @@ class abg11_calculator: self.RTS_CTS_Handshake = RTS_CTS_Handshake self.CTS_to_self = CTS_to_self + + + # This function is for calculate intermediate values and Theoretical values - def input_parameter(self): + @staticmethod + def create_argparse(prog=None, formatter_class=None, epilog=None, description=None): + if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None): + ap = argparse.ArgumentParser(prog=prog, + formatter_class=formatter_class, + allow_abbrev=True, + epilog=epilog, + description=description) + else: + ap = argparse.ArgumentParser() + + # Station : 11abg + + ap.add_argument("-sta", "--station", help="Enter Station Name : [11abg,11n,11ac](by Default 11abg)") + ap.add_argument("-t", "--traffic", help="Enter the Traffic Type : [Data,Voice](by Default Data)") + ap.add_argument("-p", "--phy", + help="Enter the PHY Bit Rate of Data Flow : [1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54](by Default 54)") + ap.add_argument("-e", "--encryption", + help="Enter the Encryption : [None, WEP , TKIP, CCMP](by Default None)") + ap.add_argument("-q", "--qos", help="Enter the QoS = : [No, Yes](by Default [No for 11abg] and [Yes for 11n])") + ap.add_argument("-m", "--mac", + help="Enter the 802.11 MAC Frame : [Any Value](by Default [106 for 11abg] and [1538 for 11n])") + ap.add_argument("-b", "--basic", nargs='+', + help="Enter the Basic Rate Set : [1,2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54]" + " (by Default [1 2 5.5 11 6 12] for 11abg, [6 12 24] for 11n/11ac])") + ap.add_argument("-pre", "--preamble", help="Enter Preamble value : [ Short, Long, N/A](by Default Short)") + ap.add_argument("-s", "--slot", help="Enter the Slot Time : [Short, Long, N/A](by Default Short)") + ap.add_argument("-co", "--codec", help="Enter the Codec Type (Voice Traffic): {[ G.711 , G.723 , G.729]" + "by Default G.723 for 11abg, G.711 for 11n} and" + "{['Mixed','Greenfield'] by Default Mixed for 11ac}") + ap.add_argument("-r", "--rts", help="Enter the RTS/CTS Handshake : [No, Yes](by Default No)") + ap.add_argument("-c", "--cts", help="Enter the CTS-to-self (protection) : [No, Yes](by Default No)") + + # Station : 11n and 11ac + + ap.add_argument("-d", "--data", + help="Enter the Data/Voice MCS Index : ['0','1','2','3','4','5','6','7','8','9','10'," + "'11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26'," + "'27','28','29','30','31']by Default 7") + ap.add_argument("-ch", "--channel", + help="Enter the Channel Bandwidth = : ['20','40'] by Default 40 for 11n and " + "['20','40','80'] by Default 80 for 11ac") + ap.add_argument("-gu", "--guard", help="Enter the Guard Interval = : ['400','800'] (by Default 400)") + ap.add_argument("-high", "--highest", + help="Enter the Highest Basic MCS = : ['0','1','2','3','4','5','6','7','8','9'," + "'10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'," + "'25','26','27','28','29','30','31'](by Default 1)") + ap.add_argument("-pl", "--plcp", + help="Enter the PLCP Configuration = : ['Mixed','Greenfield'] (by Default Mixed) for 11n") + ap.add_argument("-ip", "--ip", + help="Enter the IP Packets per A-MSDU = : ['0','1','2','3','4','5','6','7','8','9'," + "'10','11','12','13','14','15','16','17','18','19','20'] (by Default 0)") + ap.add_argument("-mc", "--mc", + help="Enter the MAC Frames per A-MPDU = : ['0','1','2','3','4','5','6','7','8'," + "'9','10','11','12','13','14','15','16','17','18','19','20','21','22','23'," + "'24','25','26','27','28','29','30','31','32','33','34','35','36','37','38'," + "'39','40','41','42','43','44','45','46','47','48','49','50','51','52','53'," + "'54','55','56','57','58','59','60','61','62','63','64'](by Default [42 for 11n] and [64 for 11ac])") + ap.add_argument("-cw", "--cwin", + help="Enter the CWmin (leave alone for default) = : [Any Value] (by Default 15)") + ap.add_argument("-spa", "--spatial", help="Enter the Spatial Streams = [1,2,3,4] (by Default 4)") + ap.add_argument("-rc", "--rtscts", help="Enter the RTS/CTS Handshake and CTS-to-self " + " = ['No','Yes'] (by Default No for 11ac)") + return ap + + def calculate(self): PHY_Bit_Rate_float = float(self.PHY_Bit_Rate) PHY_Bit_Rate_int = int(PHY_Bit_Rate_float) @@ -419,7 +493,7 @@ class abg11_calculator: Client_5 = Ttxframe_data + SIFS_value + Ttxframe + DIFS_value + RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake + MeanBackoff_value / 20 Client_6 = Ttxframe_data + SIFS_value + Ttxframe + DIFS_value + RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake + MeanBackoff_value / 50 Client_7 = Ttxframe_data + SIFS_value + Ttxframe + DIFS_value + RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake + MeanBackoff_value / 100 - Client_1_new = format(Client_1, '.2f') + self.Client_1_new = format(Client_1, '.2f') Client_2_new = format(Client_2, '.4f') Client_3_new = format(Client_3, '.4f') Client_4_new = format(Client_4, '.4f') @@ -430,7 +504,7 @@ class abg11_calculator: # Max Frame Rate Max_Frame_Rate_C1 = 1000000 / Client_1 - Max_Frame_Rate_C1_round = round(Max_Frame_Rate_C1) + self.Max_Frame_Rate_C1_round = round(Max_Frame_Rate_C1) Max_Frame_Rate_C2 = 1000000 / Client_2 Max_Frame_Rate_C2_round = round(Max_Frame_Rate_C2) Max_Frame_Rate_C3 = 1000000 / Client_3 @@ -447,7 +521,7 @@ class abg11_calculator: # Max. Offered Load (802.11) Max_Offered_Load_C1 = Max_Frame_Rate_C1 * Nbits_value / 1000000 - Max_Offered_Load_C1_new = format(Max_Offered_Load_C1, '.3f') + self.Max_Offered_Load_C1_new = format(Max_Offered_Load_C1, '.3f') Max_Offered_Load_C2 = Max_Frame_Rate_C2 * Nbits_value / 1000000 Max_Offered_Load_C2_new = format(Max_Offered_Load_C2, '.3f') Max_Offered_Load_C3 = Max_Frame_Rate_C3 * Nbits_value / 1000000 @@ -464,7 +538,7 @@ class abg11_calculator: # Offered Load Per 802.11 Client Offered_Load_Per_Client1 = Max_Offered_Load_C1 / 1 - Offered_Load_Per_Client1_new = format(Offered_Load_Per_Client1, '.3f') + self.Offered_Load_Per_Client1_new = format(Offered_Load_Per_Client1, '.3f') Offered_Load_Per_Client2 = Max_Offered_Load_C2 / 2 Offered_Load_Per_Client2_new = format(Offered_Load_Per_Client2, '.3f') Offered_Load_Per_Client3 = Max_Offered_Load_C3 / 5 @@ -481,7 +555,7 @@ class abg11_calculator: # Offered Load (802.3 Side) Offered_Load_C1 = Max_Frame_Rate_C1 * Ethernet_MAC_Frame_int * 8 / 1000000 - Offered_Load_C1_new = format(Offered_Load_C1, '.3f') + self.Offered_Load_C1_new = format(Offered_Load_C1, '.3f') Offered_Load_C2 = Max_Frame_Rate_C2 * Ethernet_MAC_Frame_int * 8 / 1000000 Offered_Load_C2_new = format(Offered_Load_C2, '.3f') Offered_Load_C3 = Max_Frame_Rate_C3 * Ethernet_MAC_Frame_int * 8 / 1000000 @@ -499,7 +573,7 @@ class abg11_calculator: if ip == 1: IP_Throughput_C1 = Max_Frame_Rate_C1 * ip_packet * 8 / 1000000 - IP_Throughput_C1_new = format(IP_Throughput_C1, '.3f') + self.IP_Throughput_C1_new = format(IP_Throughput_C1, '.3f') IP_Throughput_C2 = Max_Frame_Rate_C2 * ip_packet * 8 / 1000000 IP_Throughput_C2_new = format(IP_Throughput_C2, '.3f') IP_Throughput_C3 = Max_Frame_Rate_C3 * ip_packet * 8 / 1000000 @@ -513,7 +587,7 @@ class abg11_calculator: IP_Throughput_C7 = Max_Frame_Rate_C7 * ip_packet * 8 / 1000000 IP_Throughput_C7_new = format(IP_Throughput_C7, '.3f') else: - IP_Throughput_C1_new = "N/A" + self.IP_Throughput_C1_new = "N/A" IP_Throughput_C2_new = "N/A" IP_Throughput_C3_new = "N/A" IP_Throughput_C4_new = "N/A" @@ -521,102 +595,104 @@ class abg11_calculator: IP_Throughput_C6_new = "N/A" IP_Throughput_C7_new = "N/A" - print("\n" + "******************Station : 11abgCalculator*****************************" + "\n") - print("Theoretical Maximum Offered Load" + "\n") - print("1 Client:") - All_theoretical_output = {'Packet Interval(usec)': Client_1_new, 'Max Frame Rate(fps)': Max_Frame_Rate_C1_round, - 'Max. Offered Load (802.11)(Mb/s)': Max_Offered_Load_C1_new, - 'Offered Load Per 802.11 Client(Mb/s)': Offered_Load_Per_Client1_new, - 'Offered Load (802.3 Side)(Mb/s)': Offered_Load_C1_new, - 'IP Throughput (802.11 -> 802.3)(Mb/s)': IP_Throughput_C1_new} - print(json.dumps(All_theoretical_output, indent=4)) + Voice_Call = Max_Frame_Rate_C1 / Codec_Frame_rate Voice_Call_value = round(Voice_Call) if "Data" in self.Traffic_Type: - Maximum_Theoretical_R_value = "N/A" + self.Maximum_Theoretical_R_value = "N/A" else: if "G.711" in self.Codec_Type: - Maximum_Theoretical_R_value = 85.9 + self.Maximum_Theoretical_R_value = 85.9 else: if "G.723" in self.Codec_Type: - Maximum_Theoretical_R_value = 72.9 + self.Maximum_Theoretical_R_value = 72.9 else: if "G.729" in self.Codec_Type: - Maximum_Theoretical_R_value = 81.7 + self.Maximum_Theoretical_R_value = 81.7 else: - Maximum_Theoretical_R_value = 93.2 + self.Maximum_Theoretical_R_value = 93.2 if "Data" in self.Traffic_Type: - Estimated_MOS_Score = "N/A" - Maximum_Bidirectional = "N/A" + self.Estimated_MOS_Score = "N/A" + self.Maximum_Bidirectional_Voice_Calls = "N/A" else: if (Voice_Call_value <= 1): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C1_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = self.Max_Frame_Rate_C1_round / Codec_Frame_rate elif (Voice_Call_value <= 2): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C2_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C2_round / Codec_Frame_rate elif (Voice_Call_value <= 5): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C3_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C3_round / Codec_Frame_rate elif (Voice_Call_value <= 10): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C4_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C4_round / Codec_Frame_rate elif (Voice_Call_value <= 20): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C5_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C5_round / Codec_Frame_rate elif (Voice_Call_value <= 50): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C6_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C6_round / Codec_Frame_rate else: - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C7_round / Codec_Frame_rate - Maximum_Bidirectional = round(Maximum_Bidirectional_Voice_Calls, 2) - if Maximum_Theoretical_R_value < 0: - Estimated_MOS_Score = 1 + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C7_round / Codec_Frame_rate + self.Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional_Voice_Calls1, 2) + if self.Maximum_Theoretical_R_value < 0: + self.Estimated_MOS_Score = 1 else: - if Maximum_Theoretical_R_value > 100: - Estimated_MOS_Score = 4.5 + if self.Maximum_Theoretical_R_value > 100: + self.Estimated_MOS_Score = 4.5 else: - Estimated_MOS_Score_1 = 1 + 0.035 * Maximum_Theoretical_R_value + Maximum_Theoretical_R_value * ( - Maximum_Theoretical_R_value - 60) * ( - 100 - Maximum_Theoretical_R_value) * 7 * 0.000001 - Estimated_MOS_Score = round(Estimated_MOS_Score_1, 2) + Estimated_MOS_Score_1 = 1 + 0.035 * self.Maximum_Theoretical_R_value + self.Maximum_Theoretical_R_value * ( + self.Maximum_Theoretical_R_value - 60) * ( + 100 - self.Maximum_Theoretical_R_value) * 7 * 0.000001 + self.Estimated_MOS_Score = round(Estimated_MOS_Score_1, 2) + + + + def get_result(self): + + print("\n" + "******************Station : 11abgCalculator*****************************" + "\n") + print("Theoretical Maximum Offered Load" + "\n") + print("1 Client:") + All_theoretical_output = {'Packet Interval(usec)': self.Client_1_new, 'Max Frame Rate(fps)': self.Max_Frame_Rate_C1_round, + 'Max. Offered Load (802.11)(Mb/s)': self.Max_Offered_Load_C1_new, + 'Offered Load Per 802.11 Client(Mb/s)': self.Offered_Load_Per_Client1_new, + 'Offered Load (802.3 Side)(Mb/s)': self.Offered_Load_C1_new, + 'IP Throughput (802.11 -> 802.3)(Mb/s)': self.IP_Throughput_C1_new} + print(json.dumps(All_theoretical_output, indent=4)) print("\n" + "Theroretical Voice Call Capacity" + "\n") - All_theoretical_voice = {'Maximum Theoretical R-value': Maximum_Theoretical_R_value, - 'Estimated MOS Score': Estimated_MOS_Score, - 'Maximum Bidirectional Voice Calls(calls)': Maximum_Bidirectional} + All_theoretical_voice = {'Maximum Theoretical R-value': self.Maximum_Theoretical_R_value, + 'Estimated MOS Score': self.Estimated_MOS_Score, + 'Maximum Bidirectional Voice Calls(calls)': self.Maximum_Bidirectional_Voice_Calls} print(json.dumps(All_theoretical_voice, indent=4)) ##Class to take all user input (802.11n Standard) -class n11_calculator(): +class n11_calculator(abg11_calculator): def __init__(self, Traffic_Type, Data_Voice_MCS, Channel_Bandwidth, Guard_Interval_value, Highest_Basic_str, Encryption, QoS, IP_Packets_MSDU_str, MAC_Frames_per_A_MPDU_str, BSS_Basic_Rate, MAC_MPDU_Size_Data_Traffic, - Codec_Type_Voice_Traffic, PLCP, CWmin, RTS_CTS_Handshake, CTS_to_self_protection): - self.Traffic_Type = Traffic_Type + Codec_Type, PLCP, CWmin, RTS_CTS_Handshake, CTS_to_self,PHY_Bit_Rate=None,MAC_Frame_802_11=None,Basic_Rate_Set=None,Preamble=None,slot_name=None): + super().__init__(Traffic_Type, PHY_Bit_Rate, Encryption, QoS, MAC_Frame_802_11, Basic_Rate_Set, Preamble, + slot_name, Codec_Type, RTS_CTS_Handshake, CTS_to_self) self.Data_Voice_MCS = Data_Voice_MCS self.Channel_Bandwidth = Channel_Bandwidth self.Guard_Interval_value = Guard_Interval_value self.Highest_Basic_str = Highest_Basic_str - self.Encryption = Encryption - self.QoS = QoS self.IP_Packets_MSDU_str = IP_Packets_MSDU_str self.MAC_Frames_per_A_MPDU_str = MAC_Frames_per_A_MPDU_str self.BSS_Basic_Rate = BSS_Basic_Rate self.MAC_MPDU_Size_Data_Traffic = MAC_MPDU_Size_Data_Traffic - self.Codec_Type_Voice_Traffic = Codec_Type_Voice_Traffic self.PLCP = PLCP self.CWmin = CWmin - self.RTS_CTS_Handshake = RTS_CTS_Handshake - self.CTS_to_self_protection = CTS_to_self_protection + # This function is for calculate intermediate values and Theoretical values - def input_parameter(self): - + def calculate(self): global HT_data_temp global temp_value SIFS = 16.00 @@ -773,17 +849,17 @@ class n11_calculator(): Encrypt_Hdr = 16 # c36 Codec IP Packet Size - if "G.711" in self.Codec_Type_Voice_Traffic: + if "G.711" in self.Codec_Type: Codec_IP_Packet_Size = 200 Codec_Frame_Rate = 100 else: - if "G.723" in self.Codec_Type_Voice_Traffic: + if "G.723" in self.Codec_Type: Codec_IP_Packet_Size = 60 Codec_Frame_Rate = 67 else: - if "G.729" in self.Codec_Type_Voice_Traffic: + if "G.729" in self.Codec_Type: Codec_IP_Packet_Size = 60 Codec_Frame_Rate = 100 @@ -1096,7 +1172,7 @@ class n11_calculator(): CTS_to_self_Handshake_Overhead = 0 else: - if "Yes" in self.CTS_to_self_protection: + if "Yes" in self.CTS_to_self: if "20" in self.Channel_Bandwidth: CTS_to_self_Handshake_Overhead = 20 + 4 * int((22 + 14 * 8 + 24 * 4 - 1) / (24 * 4)) + SIFS @@ -1112,7 +1188,7 @@ class n11_calculator(): MAC_PPDU_Interval_1 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 1) - Client_1_new = format(MAC_PPDU_Interval_1, '.2f') + self.Client_1_new = format(MAC_PPDU_Interval_1, '.2f') MAC_PPDU_Interval_2 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 2) Client_2_new = format(MAC_PPDU_Interval_2, '.2f') @@ -1135,7 +1211,7 @@ class n11_calculator(): # Max PPDU Rate Max_PPDU_Rate_1 = 1000000 / MAC_PPDU_Interval_1 - Client_8_new = format(Max_PPDU_Rate_1, '.2f') + self.Client_8_new = format(Max_PPDU_Rate_1, '.2f') Max_PPDU_Rate_2 = 1000000 / MAC_PPDU_Interval_2 Client_9_new = format(Max_PPDU_Rate_2, '.2f') Max_PPDU_Rate_3 = 1000000 / MAC_PPDU_Interval_3 @@ -1167,7 +1243,7 @@ class n11_calculator(): Max_MAC_MPDU_Rate_6 = Max_PPDU_Rate_6 Max_MAC_MPDU_Rate_7 = Max_PPDU_Rate_7 - Client_15_new = round(Max_MAC_MPDU_Rate_1) + self.Client_15_new = round(Max_MAC_MPDU_Rate_1) Client_16_new = round(Max_MAC_MPDU_Rate_2) Client_17_new = round(Max_MAC_MPDU_Rate_3) Client_18_new = round(Max_MAC_MPDU_Rate_4) @@ -1195,7 +1271,7 @@ class n11_calculator(): Max_MAC_MSDU_Rate_6 = Max_MAC_MPDU_Rate_6 Max_MAC_MSDU_Rate_7 = Max_MAC_MPDU_Rate_7 - Client_22_new = round(Max_MAC_MSDU_Rate_1) + self.Client_22_new = round(Max_MAC_MSDU_Rate_1) Client_23_new = round(Max_MAC_MSDU_Rate_2) Client_24_new = round(Max_MAC_MSDU_Rate_3) Client_25_new = round(Max_MAC_MSDU_Rate_4) @@ -1212,7 +1288,7 @@ class n11_calculator(): Max_802_11_MAC_Frame_Data_Rate_6 = Max_MAC_MPDU_Rate_6 * MAC_MPDU_Size * 8 / 1000000 Max_802_11_MAC_Frame_Data_Rate_7 = Max_MAC_MPDU_Rate_7 * MAC_MPDU_Size * 8 / 1000000 - Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') + self.Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') Client_30_new = format(Max_802_11_MAC_Frame_Data_Rate_2, '.3f') Client_31_new = format(Max_802_11_MAC_Frame_Data_Rate_3, '.3f') Client_32_new = format(Max_802_11_MAC_Frame_Data_Rate_4, '.3f') @@ -1230,7 +1306,7 @@ class n11_calculator(): Max_802_11_MAC_Payload_Goodput_6 = MSDU * 8 * Max_MAC_MSDU_Rate_6 / 1000000 Max_802_11_MAC_Payload_Goodput_7 = MSDU * 8 * Max_MAC_MSDU_Rate_7 / 1000000 - Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') + self.Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') Client_37_new = format(Max_802_11_MAC_Payload_Goodput_2, '.3f') Client_38_new = format(Max_802_11_MAC_Payload_Goodput_3, '.3f') Client_39_new = format(Max_802_11_MAC_Payload_Goodput_4, '.3f') @@ -1248,7 +1324,7 @@ class n11_calculator(): MAC_Goodput_Per_802_11_Client_6 = Max_802_11_MAC_Payload_Goodput_6 / 50 MAC_Goodput_Per_802_11_Client_7 = Max_802_11_MAC_Payload_Goodput_7 / 100 - Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') + self.Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') Client_44_new = format(MAC_Goodput_Per_802_11_Client_2, '.3f') Client_45_new = format(MAC_Goodput_Per_802_11_Client_3, '.3f') Client_46_new = format(MAC_Goodput_Per_802_11_Client_4, '.3f') @@ -1268,7 +1344,7 @@ class n11_calculator(): Offered_Load_8023_Side_5 = Max_MAC_MSDU_Rate_5 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_6 = Max_MAC_MSDU_Rate_6 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_7 = Max_MAC_MSDU_Rate_7 * Ethernet_value * 8 / 1000000 - Client_50_new = format(Offered_Load_8023_Side_1, '.3f') + self.Client_50_new = format(Offered_Load_8023_Side_1, '.3f') Client_51_new = format(Offered_Load_8023_Side_2, '.3f') Client_52_new = format(Offered_Load_8023_Side_3, '.3f') Client_53_new = format(Offered_Load_8023_Side_4, '.3f') @@ -1277,7 +1353,7 @@ class n11_calculator(): Client_56_new = format(Offered_Load_8023_Side_7, '.3f') else: - Client_50_new = "N/A" + self.Client_50_new = "N/A" Client_51_new = "N/A" Client_52_new = "N/A" Client_53_new = "N/A" @@ -1294,7 +1370,7 @@ class n11_calculator(): IP_Goodput_802_11_8023_5 = Max_MAC_MSDU_Rate_5 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_6 = Max_MAC_MSDU_Rate_6 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_7 = Max_MAC_MSDU_Rate_7 * ip_1 * 8 / 1000000 - Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') + self.Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') Client_58_new = format(IP_Goodput_802_11_8023_2, '.3f') Client_59_new = format(IP_Goodput_802_11_8023_3, '.3f') Client_60_new = format(IP_Goodput_802_11_8023_4, '.3f') @@ -1303,7 +1379,7 @@ class n11_calculator(): Client_63_new = format(IP_Goodput_802_11_8023_7, '.3f') else: - Client_57_new = "N/A" + self.Client_57_new = "N/A" Client_58_new = "N/A" Client_59_new = "N/A" Client_60_new = "N/A" @@ -1315,31 +1391,31 @@ class n11_calculator(): # c53 if "Data" in self.Traffic_Type: - Maximum_Theoretical_R_value = "N/A" - Estimated_MOS_Score = "N/A" + self.Maximum_Theoretical_R_value = "N/A" + self.Estimated_MOS_Score = "N/A" else: - if "G.711" in self.Codec_Type_Voice_Traffic: - Maximum_Theoretical_R_value = 85.9 + if "G.711" in self.Codec_Type: + self.Maximum_Theoretical_R_value = 85.9 else: - if "G.723" in self.Codec_Type_Voice_Traffic: - Maximum_Theoretical_R_value = 72.9 + if "G.723" in self.Codec_Type: + self.Maximum_Theoretical_R_value = 72.9 else: - if "G.729" in self.Codec_Type_Voice_Traffic: - Maximum_Theoretical_R_value = 81.7 + if "G.729" in self.Codec_Type: + self.Maximum_Theoretical_R_value = 81.7 else: - Maximum_Theoretical_R_value = 93.2 + self.Maximum_Theoretical_R_value = 93.2 - if Maximum_Theoretical_R_value < 0: - Estimated_MOS_Score = 1 + if self.Maximum_Theoretical_R_value < 0: + self.Estimated_MOS_Score = 1 else: - if Maximum_Theoretical_R_value > 100: - Estimated_MOS_Score = 4.5 + if self.Maximum_Theoretical_R_value > 100: + self.Estimated_MOS_Score = 4.5 else: - Estimated_MOS_Score_1 = ( - 1 + 0.035 * Maximum_Theoretical_R_value + Maximum_Theoretical_R_value * ( - Maximum_Theoretical_R_value - 60) * ( - 100 - Maximum_Theoretical_R_value) * 7 * 0.000001) - Estimated_MOS_Score = format(Estimated_MOS_Score_1, '.2f') + self.Estimated_MOS_Score_1 = ( + 1 + 0.035 * self.Maximum_Theoretical_R_value + self.Maximum_Theoretical_R_value * ( + self.Maximum_Theoretical_R_value - 60) * ( + 100 - self.Maximum_Theoretical_R_value) * 7 * 0.000001) + self.Estimated_MOS_Score = format(self.Estimated_MOS_Score_1, '.2f') # Voice_Call_Range try: @@ -1376,58 +1452,57 @@ class n11_calculator(): pass if "Data" in self.Traffic_Type: - Maximum_Bidirectional_Voice_Calls = "N/A" + self.Maximum_Bidirectional_Voice_Calls = "N/A" else: - Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + self.Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + + + + def get_result(self): print("\n" + "******************Station : 11nCalculator*****************************" + "\n") print("Theoretical Maximum Offered Load" + "\n") print("1 Client:") - All_theoretical_output = {'MAC PPDU Interval(usec)': Client_1_new, 'Max PPDU Rate(fps)': Client_8_new, - 'Max MAC MPDU Rate': Client_15_new, - 'Max MAC MSDU Rate': Client_22_new, - 'Max. 802.11 MAC Frame Data Rate(Mb/s)': Client_29_new, - 'Max. 802.11 MAC Payload Goodput(Mb/s)': Client_36_new, - 'MAC Goodput Per 802.11 Client(Mb/s)': Client_43_new, - 'Offered Load (802.3 Side)(Mb/s)': Client_50_new, - 'IP Goodput (802.11 -> 802.3)(Mb/s)': Client_57_new} + All_theoretical_output = {'MAC PPDU Interval(usec)': self.Client_1_new, + 'Max PPDU Rate(fps)': self.Client_8_new, + 'Max MAC MPDU Rate': self.Client_15_new, + 'Max MAC MSDU Rate': self.Client_22_new, + 'Max. 802.11 MAC Frame Data Rate(Mb/s)': self.Client_29_new, + 'Max. 802.11 MAC Payload Goodput(Mb/s)': self.Client_36_new, + 'MAC Goodput Per 802.11 Client(Mb/s)': self.Client_43_new, + 'Offered Load (802.3 Side)(Mb/s)': self.Client_50_new, + 'IP Goodput (802.11 -> 802.3)(Mb/s)': self.Client_57_new} print(json.dumps(All_theoretical_output, indent=4)) print("\n" + "Theroretical Voice Call Capacity" + "\n") - All_theoretical_voice = {'Maximum Theoretical R-value': Maximum_Theoretical_R_value, - 'Estimated MOS Score': Estimated_MOS_Score, - 'Maximum Bidirectional Voice Calls(calls)': Maximum_Bidirectional_Voice_Calls} + All_theoretical_voice = {'Maximum Theoretical R-value': self.Maximum_Theoretical_R_value, + 'Estimated MOS Score': self.Estimated_MOS_Score, + 'Maximum Bidirectional Voice Calls(calls)': self.Maximum_Bidirectional_Voice_Calls} print(json.dumps(All_theoretical_voice, indent=4)) ##Class to take all user input (802.11ac Standard) -class ac11_calculator(): +class ac11_calculator(n11_calculator): + + def __init__(self, Traffic_Type, Data_Voice_MCS, spatial, Channel_Bandwidth, Guard_Interval_value, - Highest_Basic_str, Encryption, QoS, + Highest_Basic_str, Encryption, QoS,IP_Packets_MSDU_str, MAC_Frames_per_A_MPDU_str, BSS_Basic_Rate, MAC_MPDU_Size_Data_Traffic, + Codec_Type, CWmin, RTS_CTS,PLCP = None,RTS_CTS_Handshake=None,CTS_to_self=None): + super().__init__(Traffic_Type, Data_Voice_MCS, Channel_Bandwidth, Guard_Interval_value, Highest_Basic_str, + Encryption, QoS, IP_Packets_MSDU_str, MAC_Frames_per_A_MPDU_str, BSS_Basic_Rate, MAC_MPDU_Size_Data_Traffic, - Codec_Type_Voice_Traffic, CWmin, RTS_CTS): - self.Traffic_Type = Traffic_Type - self.Data_Voice_MCS = Data_Voice_MCS - self.Channel_Bandwidth = Channel_Bandwidth - self.Guard_Interval_value = Guard_Interval_value - self.Highest_Basic_str = Highest_Basic_str - self.Encryption = Encryption - self.QoS = QoS - self.IP_Packets_MSDU_str = IP_Packets_MSDU_str - self.MAC_Frames_per_A_MPDU_str = MAC_Frames_per_A_MPDU_str - self.BSS_Basic_Rate = BSS_Basic_Rate - self.MAC_MPDU_Size_Data_Traffic = MAC_MPDU_Size_Data_Traffic - self.Codec_Type_Voice_Traffic = Codec_Type_Voice_Traffic - self.CWmin = CWmin - self.RTS_CTS = RTS_CTS + Codec_Type, PLCP, CWmin, RTS_CTS_Handshake, CTS_to_self) + self.spatial = spatial + self.RTS_CTS = RTS_CTS + # This function is for calculate intermediate values and Theoretical values - def input_parameter(self): + def calculate(self): SIFS = 16.00 DIFS = 34.00 @@ -1572,16 +1647,16 @@ class ac11_calculator(): MeanBackoff = CWmin_leave_alone_for_default * Slot_Time / 2 IP_Packets_MSDU = int(self.IP_Packets_MSDU_str) - if "Mixed" in self.Codec_Type_Voice_Traffic: + if "Mixed" in self.Codec_Type: plcp = 1 - elif "Greenfield" in self.Codec_Type_Voice_Traffic: + elif "Greenfield" in self.Codec_Type: plcp = 2 RTS_CTS_Handshake = 1 if "No" in self.RTS_CTS: - CTS_to_self_protection = 1 + CTS_to_self = 1 elif "Yes" in self.RTS_CTS: - CTS_to_self_protection = 2 + CTS_to_self = 2 # g24 QoS Hdr @@ -1836,7 +1911,7 @@ class ac11_calculator(): if RTS_CTS_Handshake == 2: CTS_to_self_Handshake_Overhead = 0 else: - if CTS_to_self_protection == 2: + if CTS_to_self == 2: if "20" in self.Channel_Bandwidth: CTS_to_self_Handshake_Overhead = 20 + 4 * int((22 + 14 * 8 + 24 * 4 - 1) / (24 * 4)) + SIFS else: @@ -1869,7 +1944,7 @@ class ac11_calculator(): MAC_PPDU_Interval_1 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 1) - Client_1_new = format(MAC_PPDU_Interval_1, '.2f') + self.Client_1_new = format(MAC_PPDU_Interval_1, '.2f') MAC_PPDU_Interval_2 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 2) Client_2_new = format(MAC_PPDU_Interval_2, '.2f') @@ -1894,7 +1969,7 @@ class ac11_calculator(): # Max PPDU Rate Max_PPDU_Rate_1 = 1000000 / MAC_PPDU_Interval_1 - Client_8_new = format(Max_PPDU_Rate_1, '.2f') + self.Client_8_new = format(Max_PPDU_Rate_1, '.2f') Max_PPDU_Rate_2 = 1000000 / MAC_PPDU_Interval_2 Client_9_new = format(Max_PPDU_Rate_2, '.2f') Max_PPDU_Rate_3 = 1000000 / MAC_PPDU_Interval_3 @@ -1927,7 +2002,7 @@ class ac11_calculator(): Max_MAC_MPDU_Rate_6 = Max_PPDU_Rate_6 Max_MAC_MPDU_Rate_7 = Max_PPDU_Rate_7 - Client_15_new = round(Max_MAC_MPDU_Rate_1) + self.Client_15_new = round(Max_MAC_MPDU_Rate_1) Client_16_new = round(Max_MAC_MPDU_Rate_2) Client_17_new = round(Max_MAC_MPDU_Rate_3) Client_18_new = round(Max_MAC_MPDU_Rate_4) @@ -1955,7 +2030,7 @@ class ac11_calculator(): Max_MAC_MSDU_Rate_6 = Max_MAC_MPDU_Rate_6 Max_MAC_MSDU_Rate_7 = Max_MAC_MPDU_Rate_7 - Client_22_new = round(Max_MAC_MSDU_Rate_1) + self.Client_22_new = round(Max_MAC_MSDU_Rate_1) Client_23_new = round(Max_MAC_MSDU_Rate_2) Client_24_new = round(Max_MAC_MSDU_Rate_3) Client_25_new = round(Max_MAC_MSDU_Rate_4) @@ -1973,7 +2048,7 @@ class ac11_calculator(): Max_802_11_MAC_Frame_Data_Rate_6 = Max_MAC_MPDU_Rate_6 * MAC_MPDU_Size * 8 / 1000000 Max_802_11_MAC_Frame_Data_Rate_7 = Max_MAC_MPDU_Rate_7 * MAC_MPDU_Size * 8 / 1000000 - Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') + self.Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') Client_30_new = format(Max_802_11_MAC_Frame_Data_Rate_2, '.3f') Client_31_new = format(Max_802_11_MAC_Frame_Data_Rate_3, '.3f') Client_32_new = format(Max_802_11_MAC_Frame_Data_Rate_4, '.3f') @@ -1991,7 +2066,7 @@ class ac11_calculator(): Max_802_11_MAC_Payload_Goodput_6 = MSDU * 8 * Max_MAC_MSDU_Rate_6 / 1000000 Max_802_11_MAC_Payload_Goodput_7 = MSDU * 8 * Max_MAC_MSDU_Rate_7 / 1000000 - Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') + self.Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') Client_37_new = format(Max_802_11_MAC_Payload_Goodput_2, '.3f') Client_38_new = format(Max_802_11_MAC_Payload_Goodput_3, '.3f') Client_39_new = format(Max_802_11_MAC_Payload_Goodput_4, '.3f') @@ -2009,7 +2084,7 @@ class ac11_calculator(): MAC_Goodput_Per_802_11_Client_6 = Max_802_11_MAC_Payload_Goodput_6 / 50 MAC_Goodput_Per_802_11_Client_7 = Max_802_11_MAC_Payload_Goodput_7 / 100 - Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') + self.Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') Client_44_new = format(MAC_Goodput_Per_802_11_Client_2, '.3f') Client_45_new = format(MAC_Goodput_Per_802_11_Client_3, '.3f') Client_46_new = format(MAC_Goodput_Per_802_11_Client_4, '.3f') @@ -2028,7 +2103,7 @@ class ac11_calculator(): Offered_Load_8023_Side_5 = Max_MAC_MSDU_Rate_5 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_6 = Max_MAC_MSDU_Rate_6 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_7 = Max_MAC_MSDU_Rate_7 * Ethernet_value * 8 / 1000000 - Client_50_new = format(Offered_Load_8023_Side_1, '.3f') + self.Client_50_new = format(Offered_Load_8023_Side_1, '.3f') Client_51_new = format(Offered_Load_8023_Side_2, '.3f') Client_52_new = format(Offered_Load_8023_Side_3, '.3f') Client_53_new = format(Offered_Load_8023_Side_4, '.3f') @@ -2037,7 +2112,7 @@ class ac11_calculator(): Client_56_new = format(Offered_Load_8023_Side_7, '.3f') else: - Client_50_new = "N/A" + self.Client_50_new = "N/A" Client_51_new = "N/A" Client_52_new = "N/A" Client_53_new = "N/A" @@ -2054,7 +2129,7 @@ class ac11_calculator(): IP_Goodput_802_11_8023_5 = Max_MAC_MSDU_Rate_5 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_6 = Max_MAC_MSDU_Rate_6 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_7 = Max_MAC_MSDU_Rate_7 * ip_1 * 8 / 1000000 - Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') + self.Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') Client_58_new = format(IP_Goodput_802_11_8023_2, '.3f') Client_59_new = format(IP_Goodput_802_11_8023_3, '.3f') Client_60_new = format(IP_Goodput_802_11_8023_4, '.3f') @@ -2063,7 +2138,7 @@ class ac11_calculator(): Client_63_new = format(IP_Goodput_802_11_8023_7, '.3f') else: - Client_57_new = "N/A" + self.Client_57_new = "N/A" Client_58_new = "N/A" Client_59_new = "N/A" Client_60_new = "N/A" @@ -2074,20 +2149,20 @@ class ac11_calculator(): # Theoretical Voice Call Capacity if "Data" in self.Traffic_Type: - Maximum_Theoretical_R_value = "N/A" - Estimated_MOS_Score = "N/A" + self.Maximum_Theoretical_R_value = "N/A" + self.Estimated_MOS_Score = "N/A" else: - Maximum_Theoretical_R_value = 85.9 - if Maximum_Theoretical_R_value < 0: - Estimated_MOS_Score = 1 + self.Maximum_Theoretical_R_value = 85.9 + if self.Maximum_Theoretical_R_value < 0: + self.Estimated_MOS_Score = 1 else: - if Maximum_Theoretical_R_value > 100: - Estimated_MOS_Score = 4.5 + if self.Maximum_Theoretical_R_value > 100: + self.Estimated_MOS_Score = 4.5 else: - Estimated_MOS_Score_1 = (1 + 0.035 * Maximum_Theoretical_R_value + Maximum_Theoretical_R_value * ( - Maximum_Theoretical_R_value - 60) * (100 - Maximum_Theoretical_R_value) * 7 * 0.000001) - Estimated_MOS_Score = format(Estimated_MOS_Score_1, '.2f') + Estimated_MOS_Score_1 = (1 + 0.035 * self.Maximum_Theoretical_R_value + self.Maximum_Theoretical_R_value * ( + self.Maximum_Theoretical_R_value - 60) * (100 - self.Maximum_Theoretical_R_value) * 7 * 0.000001) + self.Estimated_MOS_Score = format(Estimated_MOS_Score_1, '.2f') # Voice_Call_Range @@ -2126,26 +2201,29 @@ class ac11_calculator(): pass if "Data" in self.Traffic_Type: - Maximum_Bidirectional_Voice_Calls = "N/A" + self.Maximum_Bidirectional_Voice_Calls = "N/A" else: - Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + self.Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + + + def get_result(self): print("\n" + "******************Station : 11ac Calculator*****************************" + "\n") print("Theoretical Maximum Offered Load" + "\n") print("1 Client:") - All_theoretical_output = {'MAC PPDU Interval(usec)': Client_1_new, 'Max PPDU Rate(fps)': Client_8_new, - 'Max MAC MPDU Rate': Client_15_new, - 'Max MAC MSDU Rate': Client_22_new, - 'Max. 802.11 MAC Frame Data Rate(Mb/s)': Client_29_new, - 'Max. 802.11 MAC Payload Goodput(Mb/s)': Client_36_new, - 'MAC Goodput Per 802.11 Client(Mb/s)': Client_43_new, - 'Offered Load (802.3 Side)(Mb/s)': Client_50_new, - 'IP Goodput (802.11 -> 802.3)(Mb/s)': Client_57_new} + All_theoretical_output = {'MAC PPDU Interval(usec)': self.Client_1_new, 'Max PPDU Rate(fps)': self.Client_8_new, + 'Max MAC MPDU Rate': self.Client_15_new, + 'Max MAC MSDU Rate': self.Client_22_new, + 'Max. 802.11 MAC Frame Data Rate(Mb/s)': self.Client_29_new, + 'Max. 802.11 MAC Payload Goodput(Mb/s)': self.Client_36_new, + 'MAC Goodput Per 802.11 Client(Mb/s)': self.Client_43_new, + 'Offered Load (802.3 Side)(Mb/s)': self.Client_50_new, + 'IP Goodput (802.11 -> 802.3)(Mb/s)': self.Client_57_new} print(json.dumps(All_theoretical_output, indent=4)) print("\n" + "Theroretical Voice Call Capacity" + "\n") - All_theoretical_voice = {'Maximum Theoretical R-value': Maximum_Theoretical_R_value, - 'Estimated MOS Score': Estimated_MOS_Score, - 'Maximum Bidirectional Voice Calls(calls)': Maximum_Bidirectional_Voice_Calls} - print(json.dumps(All_theoretical_voice, indent=4)) + All_theoretical_voice = {'Maximum Theoretical R-value': self.Maximum_Theoretical_R_value, + 'Estimated MOS Score': self.Estimated_MOS_Score, + 'Maximum Bidirectional Voice Calls(calls)': self.Maximum_Bidirectional_Voice_Calls} + print(json.dumps(All_theoretical_voice, indent=4)) \ No newline at end of file diff --git a/py-scripts/wlan_capacity_calculator.py b/py-scripts/wlan_capacity_calculator.py index 1cb8d3f5..511a9afe 100755 --- a/py-scripts/wlan_capacity_calculator.py +++ b/py-scripts/wlan_capacity_calculator.py @@ -1,66 +1,53 @@ +''' +Candela Technologies Inc. +Info : Standard Script for WLAN Capacity Calculator +Date : +Author : Anjali Rahamatkar +''' + import argparse import sys import os +from pip._internal.utils import logging + if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import wlan_test +import wlan_theoretical_sta + # main method def main(): - ap = argparse.ArgumentParser(description="WLAN Capacity Calculator") - # Station : 11abg + parse = wlan_theoretical_sta.abg11_calculator.create_argparse( prog='wlan_capacity_calculator.py', + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + This python script calculates the theoretical value of three different stations( 11abg/11n/11ac)''', + description='''\ + wlan_capacity_calculator.py + --------------------------------------------------------------------------- - ap.add_argument("-sta", "--station", help="Enter Station Name : [11abg,11n,11ac](by Default 11abg)") - ap.add_argument("-t", "--traffic", help="Enter the Traffic Type : [Data,Voice](by Default Data)") - ap.add_argument("-p", "--phy", - help="Enter the PHY Bit Rate of Data Flow : [1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54](by Default 54)") - ap.add_argument("-e", "--encryption", help="Enter the Encryption : [None, WEP , TKIP, CCMP](by Default None)") - ap.add_argument("-q", "--qos", help="Enter the QoS = : [No, Yes](by Default [No for 11abg] and [Yes for 11n])") - ap.add_argument("-m", "--mac", - help="Enter the 802.11 MAC Frame : [Any Value](by Default [106 for 11abg] and [1538 for 11n])") - ap.add_argument("-b", "--basic", nargs='+', - help="Enter the Basic Rate Set : [1,2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54]" - " (by Default [1 2 5.5 11 6 12] for 11abg, [6 12 24] for 11n/11ac])") - ap.add_argument("-pre", "--preamble", help="Enter Preamble value : [ Short, Long, N/A](by Default Short)") - ap.add_argument("-s", "--slot", help="Enter the Slot Time : [Short, Long, N/A](by Default Short)") - ap.add_argument("-co", "--codec", help="Enter the Codec Type (Voice Traffic): {[ G.711 , G.723 , G.729]" - "by Default G.723 for 11abg, G.711 for 11n} and" - "{['Mixed','Greenfield'] by Default Mixed for 11ac}") - ap.add_argument("-r", "--rts", help="Enter the RTS/CTS Handshake : [No, Yes](by Default No)") - ap.add_argument("-c", "--cts", help="Enter the CTS-to-self (protection) : [No, Yes](by Default No)") - - # Station : 11n and 11ac - - ap.add_argument("-d", "--data", - help="Enter the Data/Voice MCS Index : ['0','1','2','3','4','5','6','7','8','9','10'," - "'11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26'," - "'27','28','29','30','31']by Default 7") - ap.add_argument("-ch", "--channel", help="Enter the Channel Bandwidth = : ['20','40'] by Default 40 for 11n and " - "['20','40','80'] by Default 80 for 11ac") - ap.add_argument("-gu", "--guard", help="Enter the Guard Interval = : ['400','800'] (by Default 400)") - ap.add_argument("-high", "--highest", - help="Enter the Highest Basic MCS = : ['0','1','2','3','4','5','6','7','8','9'," - "'10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'," - "'25','26','27','28','29','30','31'](by Default 1)") - ap.add_argument("-pl", "--plcp", - help="Enter the PLCP Configuration = : ['Mixed','Greenfield'] (by Default Mixed) for 11n") - ap.add_argument("-ip", "--ip", help="Enter the IP Packets per A-MSDU = : ['0','1','2','3','4','5','6','7','8','9'," - "'10','11','12','13','14','15','16','17','18','19','20'] (by Default 0)") - ap.add_argument("-mc", "--mc", - help="Enter the MAC Frames per A-MPDU = : ['0','1','2','3','4','5','6','7','8'," - "'9','10','11','12','13','14','15','16','17','18','19','20','21','22','23'," - "'24','25','26','27','28','29','30','31','32','33','34','35','36','37','38'," - "'39','40','41','42','43','44','45','46','47','48','49','50','51','52','53'," - "'54','55','56','57','58','59','60','61','62','63','64'](by Default [42 for 11n] and [64 for 11ac])") - ap.add_argument("-cw", "--cwin", help="Enter the CWmin (leave alone for default) = : [Any Value] (by Default 15)") - ap.add_argument("-spa", "--spatial", help="Enter the Spatial Streams = [1,2,3,4] (by Default 4)") - ap.add_argument("-rc", "--rtscts", help="Enter the RTS/CTS Handshake and CTS-to-self " - " = ['No','Yes'] (by Default No for 11ac)") + Example of command line to run(11ac Station): + ./wlan_capacity_calculator.py + -sta 11ac + -t Voice + -d 9 + -spa 3 + -ch 20 + -gu 800 + -high 1 + -e TKIP + -q Yes + -ip 3 + -mc 0 + -b 6 12 24 54 + -m 1518 + -co Greenfield + -cw 15 + ''') try: - args = ap.parse_args() + args = parse.parse_args() # Station if (args.station is not None): Calculator_name = args.station @@ -238,22 +225,26 @@ def main(): # Select station(802.11a/b/g/n/ac standards) if "11abg" in Calculator_name: - Station1 = wlan_test.abg11_calculator(traffic_name, phy_name, encryption_name, qos_name, mac_name, basic_name, + Station1 = wlan_theoretical_sta.abg11_calculator(traffic_name, phy_name, encryption_name, qos_name, mac_name, basic_name, preamble_name, slot_name, codec_name, rts_name, cts_name) - Station1.input_parameter() + Station1.calculate() + Station1.get_result() + if "11n" in Calculator_name: - Station2 = wlan_test.n11_calculator(traffic_name, data_name, channel_name, guard_name, highest_name, encryption_name, + Station2 = wlan_theoretical_sta.n11_calculator(traffic_name, data_name, channel_name, guard_name, highest_name, encryption_name, qos_name, ip_name, mc_name, basic_name, mac_name, codec_name, plcp_name, cwin_name, rts_name, cts_name) - Station2.input_parameter() + Station2.calculate() + Station2.get_result() if "11ac" in Calculator_name: - Station3 = wlan_test.ac11_calculator(traffic_name, data_name, spatial_name, channel_name, guard_name, highest_name, + Station3 = wlan_theoretical_sta.ac11_calculator(traffic_name, data_name, spatial_name, channel_name, guard_name, highest_name, encryption_name , qos_name, ip_name, mc_name, basic_name, mac_name, codec_name, cwin_name, rtscts_name) - Station3.input_parameter() + Station3.calculate() + Station3.get_result() if __name__ == "__main__": - main() \ No newline at end of file + main() \ No newline at end of file From 9b0471de6cae60fdf97af400472311d06fe68dda Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 07:36:47 -0700 Subject: [PATCH 068/848] lf_cisco_power.py: LCS-45 Read AP for Power values Updated command line arguments and argument checking for ap parameters --- lf_cisco_power.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 0893c9ff..9fb04e07 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -305,7 +305,8 @@ def main(): parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") - + parser.add_argument('-ap_read', type=str,help="controller prompt",required=True) + parser.add_argument('-ap','--ap_info', action='append', nargs=1, type=str, help="--ap_info ap_ip== ap_port== ap_user== ap_pw==") #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] #print(current_time) @@ -364,6 +365,20 @@ def main(): if args.log: outfile_log = "{}_{}_output_log.log".format(args.outfile,current_time) print("output file log: {}".format(outfile_log)) + + ap_dict = [] + if args.ap_info: + ap_info = args.ap_info + for _ap_info in ap_info: + print("ap_info {}".format(_ap_info)) + ap_keys = ['ap_ip','ap_port','ap_user','ap_pw'] + ap_dict = dict(map(lambda x: x.split('=='), str(_ap_info).replace('[','').replace(']','').replace("'","").split())) + for key in ap_keys: + if key not in ap_dict: + print("missing ap config, for the {}, all these need to be set {} ".format(key,ap_keys)) + exit(1) + print("ap_dict: {}".format(ap_dict)) + email_dicts = [] if args.email: emails = args.email From 07a5cbd888dd42753ac7e28d56091727834c0746 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 08:23:23 -0700 Subject: [PATCH 069/848] lf_cisco_power.py: LCS-45 Read AP for Power values - cleaned up args --- lf_cisco_power.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 9fb04e07..b1e13a1d 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -305,8 +305,7 @@ def main(): parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") - parser.add_argument('-ap_read', type=str,help="controller prompt",required=True) - parser.add_argument('-ap','--ap_info', action='append', nargs=1, type=str, help="--ap_info ap_ip== ap_port== ap_user== ap_pw==") + parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_ip== ap_port== ap_user== ap_pw==") #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] #print(current_time) @@ -421,6 +420,8 @@ def main(): logging.basicConfig(format=FORMAT, handlers=[console_handler]) #logg.addHandler(logging.StreamHandler()) # allows to logging to file and stderr + if bool(ap_dict): + logg.info("ap_dict {}".format(ap_dict)) if bool(email_dicts): logg.info("email_dicts {}".format(email_dicts)) @@ -1268,7 +1269,7 @@ def main(): subprocess.run(["./lf_firemod.pl", "--manager", lfmgr, "--resource", lfresource, "--action", "do_cmd", "--cmd", "set_cx_state all c-udp-power RUNNING"], capture_output=True, check=True) - # Wait 10 more seconds + # Wait configured number of seconds more seconds logg.info("Waiting {} seconds to let traffic run for a bit, Channel {} NSS {} BW {} TX-Power {}".format(args.duration,ch, n, bw, tx)) time.sleep(int(args.duration)) @@ -1562,7 +1563,21 @@ def main(): failed_low += 1 least = min(least, diff_a4) - if ((least < (-pfrange - pf_a4_dropoff)) or (failed_low >= 1)): + failed_low_treshold = 1 + # + # + # If the ap dictionary is set the read the AP to see the number + # of spatial streams used. For tx power 1 the AP may determine to use + # fewer spatial streams + # + # + + + # + # The controller may adjust the number of spatial streams to allow for the + # best power values + # + if ((least < (-pfrange - pf_a4_dropoff)) or (failed_low >= failed_low_treshold)): pf = 0 if (diff_a1 > pfrange): From 585c31abf16964423cc34c6966266ca266251356 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 09:59:51 -0700 Subject: [PATCH 070/848] lf_cisco_power.py: LCS-45 Read AP for Power values, subprocess call --- lf_cisco_power.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b1e13a1d..f98a24fa 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -305,7 +305,8 @@ def main(): parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") - parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_ip== ap_port== ap_user== ap_pw==") + parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_scheme== ap_ip== ap_port== ap_user== ap_pw==") + #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] #print(current_time) @@ -370,7 +371,7 @@ def main(): ap_info = args.ap_info for _ap_info in ap_info: print("ap_info {}".format(_ap_info)) - ap_keys = ['ap_ip','ap_port','ap_user','ap_pw'] + ap_keys = ['ap_scheme','ap_ip','ap_port','ap_user','ap_pw'] ap_dict = dict(map(lambda x: x.split('=='), str(_ap_info).replace('[','').replace(']','').replace("'","").split())) for key in ap_keys: if key not in ap_dict: @@ -1571,6 +1572,35 @@ def main(): # fewer spatial streams # # + if(bool(ap_dict)): + logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], + ap_dict['ap_user'],ap_dict['ap_pw'])) + try: + logg.info("cisco_ap_ctl.py: no_logging_console") + ap_info= subprocess.run(["./cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "-d", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], + "-u", ap_dict['ap_user'], "-p", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=True, check=True) + pss = ap_info.stdout.decode('utf-8', 'ignore'); + logg.info(pss) + except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + + logg.info("####################################################################################################") + logg.info("# Unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + exit_test(workbook) + + for line in pss.splitlines(): + logg.info("ap {}".format(line)) + m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') + if (m != None): + pass + + else: + logg.info("AP Check regular expression!!!") + exit(1) + # From 6916a7ce71b582324e8c85a362da988bf7b8b5f4 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 11:20:38 -0700 Subject: [PATCH 071/848] lf_cisco_power.py: LCS-45 Read AP for Power values, updates --- cisco_ap_ctl.py | 326 +++++++++++++++++----------------------------- lf_cisco_power.py | 40 +++++- 2 files changed, 150 insertions(+), 216 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index 73a8f4d1..cb341765 100644 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -31,9 +31,9 @@ import pexpect default_host = "localhost" default_ports = { - "serial": None, - "ssh": 22, - "telnet": 23 + "serial": None, + "ssh": 22, + "telnet": 23 } NL = "\n" CR = "\r\n" @@ -48,17 +48,18 @@ logfile = "stdout" # ^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+) def usage(): - print("$0 used connect to Cisco AP:") - print("-a|--ap: AP to act upon") - print("-d|--dest: destination host") - print("-o|--port: destination port") - print("-u|--user: AP login name") - print("-p|--pass: AP password") - print("-s|--scheme (serial|telnet|ssh): connect to controller via serial, ssh or telnet") - print("--tty Serial port for accessing AP") - print("-l|--log file: log messages here") - print("-b|--band: a (5Ghz) or b (2.4Ghz) or abgn for dual-band 2.4Ghz AP") - print("-h|--help") + print("$0 used connect to Cisco AP:") + print("-a|--ap: AP to act upon") + print("-d|--dest: destination host") + print("-o|--port: destination port") + print("-u|--user: AP login name") + print("-p|--pass: AP password") + print("-s|--scheme (serial|telnet|ssh): connect to controller via serial, ssh or telnet") + print("--tty Serial port for accessing AP") + print("-l|--log file: log messages here") + print("-b|--band: a (5Ghz) or b (2.4Ghz) or abgn for dual-band 2.4Ghz AP") + print("-z|--action: action") + print("-h|--help") # see https://stackoverflow.com/a/13306095/11014343 class FileAdapter(object): @@ -74,204 +75,111 @@ class FileAdapter(object): def main(): - global logfile + global logfile - parser = argparse.ArgumentParser(description="Cisco AP Control Script") - parser.add_argument("-a", "--ap", type=str, help="select AP") - parser.add_argument("-d", "--dest", type=str, help="address of the AP 172.19.27.55") - 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("-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("-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") + parser = argparse.ArgumentParser(description="Cisco AP Control Script") + 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("-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("-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("-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") + parser.add_argument("-z", "--action", type=str, help="action, current action is powercfg") - args = None - try: - args = parser.parse_args() - host = args.dest - scheme = args.scheme - port = (default_ports[scheme], args.port)[args.port != None] - user = args.user - passwd = args.passwd - if (args.log != None): - logfile = args.log - filehandler = None - except Exception as e: - logging.exception(e) - usage() - exit(2) + args = None + try: + args = parser.parse_args() + host = args.dest + scheme = args.scheme + port = (default_ports[scheme], args.port)[args.port != None] + user = args.user + passwd = args.passwd + if (args.log != None): + logfile = args.log + filehandler = None + except Exception as e: + logging.exception(e) + usage() + exit(2) + console_handler = logging.StreamHandler() + formatter = logging.Formatter(FORMAT) + 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=[file_handler]) + else: + # stdout logging + logging.basicConfig(format=FORMAT, handlers=[console_handler]) + egg = None # think "eggpect" + ser = None + try: + if (scheme == "serial"): + #eggspect = pexpect.fdpexpect.fdspan(telcon, logfile=sys.stdout.buffer) + import serial + from pexpect_serial import SerialSpawn + ser = serial.Serial(args.tty, 9600, timeout=5) + print("Created serial connection on %s, open: %s"%(args.tty, ser.is_open)) + egg = SerialSpawn(ser) + egg.logfile = FileAdapter(logg) + time.sleep(1) + elif (scheme == "ssh"): + if (port is None): + port = 22 + cmd = "ssh -p%d %s@%s"%(port, user, host) + logg.info("Spawn: "+cmd+NL) + egg = pexpect.spawn(cmd) + #egg.logfile_read = sys.stdout.buffer + egg.logfile = FileAdapter(logg) + i = egg.expect(["password:", "continue connecting (yes/no)?"], timeout=3) + time.sleep(0.1) + if i == 1: + egg.sendline('yes') + egg.expect('password:') + sleep(0.1) + egg.sendline(args.passwd) + elif (scheme == "telnet"): + if (port is None): + port = 23 + cmd = "telnet {} {}".format(host, port) + logg.info("Spawn: "+cmd+NL) + egg = pexpect.spawn(cmd) + egg.logfile = FileAdapter(logg) + # Will login below as needed. + else: + usage() + exit(1) + except Exception as e: + logging.exception(e) + + ap_prompt = "{}>".format(args.prompt) + ap_hash = "{}#".format(args.prompt) + egg.sendline() - console_handler = logging.StreamHandler() - formatter = logging.Formatter(FORMAT) - 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=[file_handler]) - else: - # stdout logging - logging.basicConfig(format=FORMAT, handlers=[console_handler]) - - egg = None # think "eggpect" - ser = None - try: - if (scheme == "serial"): - #eggspect = pexpect.fdpexpect.fdspan(telcon, logfile=sys.stdout.buffer) - import serial - from pexpect_serial import SerialSpawn - ser = serial.Serial(args.tty, 9600, timeout=5) - print("Created serial connection on %s, open: %s"%(args.tty, ser.is_open)) - egg = SerialSpawn(ser); - egg.logfile = FileAdapter(logg) - time.sleep(1) - - elif (scheme == "ssh"): - if (port is None): - port = 22 - cmd = "ssh -p%d %s@%s"%(port, user, host) - logg.info("Spawn: "+cmd+NL) - egg = pexpect.spawn(cmd) - #egg.logfile_read = sys.stdout.buffer - egg.logfile = FileAdapter(logg) - i = egg.expect(["password:", "continue connecting (yes/no)?"], timeout=3) - time.sleep(0.1) - if i == 1: - egg.sendline('yes') - egg.expect('password:') - sleep(0.1) - egg.sendline(args.passwd) - - elif (scheme == "telnet"): - if (port is None): - port = 23 - cmd = "telnet %s %d"%(host, port) - logg.info("Spawn: "+cmd+NL) - egg = pexpect.spawn(cmd) - egg.logfile = FileAdapter(logg) - # Will login below as needed. - else: - usage() - exit(1) - except Exception as e: - logging.exception(e); - - ap_prompt = "%s>"%(args.ap) - ap_hash = "%s#"%(args.ap) - egg.sendline() - - i = egg.expect(['Password:', 'Username:', ap_prompt, 'u-boot>', ap_hash], timeout=3) - j = 0 - if i == 0: - egg.sendline() - i = egg.expect(['Password:', 'Username:', ap_prompt, 'u-boot>', ap_hash], timeout=10) - - i -= 1 - - if i == 0: - time.sleep(1) - egg.sendline(args.user) - time.sleep(1) - egg.expect('Password:') - egg.sendline(args.passwd) - - if (i <= 1): - egg.expect(ap_prompt) - egg.sendline("en") - egg.expect("Password:") - egg.sendline(args.passwd) - egg.expect("#") - - # Seems this cannot work on factory images, so comment it out. It is one-time - # thing, user must do it manually. - #logg.info('Login to Devshell and issue the updt command') - #egg.sendline('devshell') - #egg.expect("#", timeout=5) - #egg.sendline("updt_util -i /lib/firmware/%s uboot"%(args.binfile)) - # if updt_util is not available, we must already be in the netbooted cookie shell - #egg.expect("#") - #egg.sendline('exit') - #egg.expect("#", timeout=5) - - logg.info("Reload the AP and bring it to u-boot") - egg.sendline('reload') - egg.expect(r"confirm") - egg.sendline('yes') - time.sleep(10) - egg.expect(r'Hit ESC key to stop autoboot:', timeout=100) - egg.sendline('\x1b') - egg.expect(r"u-boot>") - egg.sendline('printenv') - time.sleep(5) - egg.expect(r"u-boot>") - - if (i <= 2): - logg.info("Set the env variable and download bcm.bin from TFTP server") - time.sleep(1) - egg.sendline("setenv ipaddr %s"%(args.ip)) - time.sleep(1) - egg.expect(r"u-boot>") - egg.sendline("setenv netmask %s"%(args.mask)) - time.sleep(1) - egg.expect(r"u-boot>") - egg.sendline("setenv serverip %s"%(args.tftp_server)) - time.sleep(2) - egg.expect(r"u-boot>") - egg.sendline("setenv gatewayip %s"%(args.gw)) - time.sleep(2) - egg.expect(r"u-boot>") - egg.sendline('setenv tftpdir /') - time.sleep(2) - egg.expect(r"u-boot>") - egg.sendline('saveenv') - time.sleep(10) - egg.expect("u-boot>", timeout=5) - egg.sendline('printenv') - time.sleep(10) - egg.expect("u-boot>", timeout=15) - - egg.sendline("netboot %s"%(args.netboot_binfile)) - while True: - time.sleep(10) - k = egg.expect(["Username:", "Unable to download image"], timeout=240) - if (k == 0): - break - if (k == 1): - egg.sendline("netboot %s"%(args.netboot_binfile)) - continue - break - - - logg.info("Setting up the cookie from devshell and rebooting the AP") - - # Log in again - egg.sendline() - time.sleep(0.1) - egg.expect('Username:', timeout=3) - time.sleep(0.1) - egg.sendline(args.user) - time.sleep(0.1) - egg.expect('Password:') - egg.sendline(args.passwd) - - egg.expect(ap_prompt) - egg.sendline("en") - egg.expect("Password:") - egg.sendline(args.passwd) - egg.expect("#") - - - egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - egg.expect("#", timeout=5) - # ctlr.execute(cn_cmd) - - -# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- + egg.sendline() + time.sleep(0.1) + egg.expect('Username:', timeout=3) + time.sleep(0.1) + egg.sendline(args.user) + time.sleep(0.1) + egg.expect('Password:') + egg.sendline(args.passwd) + egg.expect(ap_prompt) + egg.sendline("en") + egg.expect("Password:") + egg.sendline(args.passwd) + egg.expect("#") + egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect("#", timeout=5) + # ctlr.execute(cn_cmd) + ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- if __name__ == '__main__': main() diff --git a/lf_cisco_power.py b/lf_cisco_power.py index f98a24fa..1a0dfdfe 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -305,7 +305,7 @@ def main(): parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") - parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_scheme== ap_ip== ap_port== ap_user== ap_pw==") + parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw==") #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] @@ -371,7 +371,7 @@ def main(): ap_info = args.ap_info for _ap_info in ap_info: print("ap_info {}".format(_ap_info)) - ap_keys = ['ap_scheme','ap_ip','ap_port','ap_user','ap_pw'] + ap_keys = ['ap_scheme','ap_prompt','ap_ip','ap_port','ap_user','ap_pw'] ap_dict = dict(map(lambda x: x.split('=='), str(_ap_info).replace('[','').replace(']','').replace("'","").split())) for key in ap_keys: if key not in ap_dict: @@ -1572,13 +1572,25 @@ def main(): # fewer spatial streams # # + P1 = None + T1 = None + P2 = None + T2 = None + P3 = None + T3 = None + P4 = None + T4 = None + N_ANT = None + DAA_Pwr = None + DAA_N_TX = None + DAA_Total_pwr = None if(bool(ap_dict)): logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], ap_dict['ap_user'],ap_dict['ap_pw'])) try: logg.info("cisco_ap_ctl.py: no_logging_console") - ap_info= subprocess.run(["./cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "-d", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], - "-u", ap_dict['ap_user'], "-p", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=True, check=True) + ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) pss = ap_info.stdout.decode('utf-8', 'ignore'); logg.info(pss) except subprocess.CalledProcessError as process_error: @@ -1589,14 +1601,28 @@ def main(): logg.info("####################################################################################################") logg.info("# Unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) logg.info("####################################################################################################") - exit_test(workbook) + #exit_test(workbook) + exit(1) for line in pss.splitlines(): logg.info("ap {}".format(line)) m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') if (m != None): - pass - + P1 = m.group(1) + T1 = m.group(2) + P2 = m.group(3) + T2 = m.group(4) + P3 = m.group(5) + T3 = m.group(6) + P4 = m.group(7) + T4 = m.group(8) + N_ANT = m.group(9) + DAA_Pwr = m.group(10) + DAA_N_TX = m.group(11) + DAA_Total_pwr = m.group(12) + print("P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}" + .format(P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr)) + else: logg.info("AP Check regular expression!!!") exit(1) From 74c23fb404fe0f64c83dce0dd1fb459d02498f6e Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 16:15:36 -0700 Subject: [PATCH 072/848] lf_cisco_power.py: LCS-45 Read AP for Power values, updates to AP login --- cisco_ap_ctl.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index cb341765..87a13f2c 100644 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -178,8 +178,13 @@ def main(): egg.expect("#") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') egg.expect("#", timeout=5) + egg.sendcontrol('c') + egg.expect("#",timeout=5) + egg.sendline("exit") + egg.excect(">",timeout=5) + egg.sendline("exit") + # ctlr.execute(cn_cmd) - ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- if __name__ == '__main__': main() From e9a071eff8cfb397f9534ea865f8450e43078cee Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 16:34:23 -0700 Subject: [PATCH 073/848] lf_cisco_power.py: LCS-45 Read AP for Power values, Needed to look for --More-- before sending the c --- cisco_ap_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index 87a13f2c..cf8f16e6 100644 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -177,7 +177,7 @@ def main(): egg.sendline(args.passwd) egg.expect("#") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - egg.expect("#", timeout=5) + egg.expect("--More--") egg.sendcontrol('c') egg.expect("#",timeout=5) egg.sendline("exit") From c8401192d5a2bd6e31117530905ea1094ef58bb6 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:38:40 -0800 Subject: [PATCH 074/848] html test output --- py-json/realm.py | 14 +- py-scripts/create_macvlan.py | 364 ++++---------------------- py-scripts/html_test_output.sh | 121 +++++++++ py-scripts/test_ipv4_variable_time.py | 11 +- 4 files changed, 191 insertions(+), 319 deletions(-) create mode 100644 py-scripts/html_test_output.sh diff --git a/py-json/realm.py b/py-json/realm.py index 5df91dd9..9bae7241 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1165,7 +1165,10 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] # Step 1, column names - fields = ",".join(col_names) + if fields = None: + pass + else: + fields = ",".join(col_names) print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() @@ -1178,8 +1181,13 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): + if col_names = None: + header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) + if fields = None: + response = self.json_get("/endp/all") + else: + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1205,8 +1213,6 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) - # if passes == expected_passes: - # self._pass("PASS: All tests passed") # step 3 organize data endpoints = list() for endpoint in value_map.values(): diff --git a/py-scripts/create_macvlan.py b/py-scripts/create_macvlan.py index 90a5204e..aa78ae66 100755 --- a/py-scripts/create_macvlan.py +++ b/py-scripts/create_macvlan.py @@ -1,325 +1,105 @@ #!/usr/bin/env python3 import sys + if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) if 'py-json' not in sys.path: sys.path.append('../py-json') - -# import argparse from LANforge.lfcli_base import LFCliBase from LANforge.LFUtils import * from LANforge import LFUtils -from LANforge import add_file_endp from LANforge.add_file_endp import * import argparse from realm import Realm -import time -import datetime -import pprint -class FileIOTest(Realm): - def __init__(self, host, port, ssid, security, password, - number_template="00000", +class CreateMacVlan(Realm): + def __init__(self, host, port, radio="wiphy0", - test_duration="5m", upstream_port="eth1", num_ports=1, - server_mount="10.40.0.1:/var/tmp/test", macvlan_parent=None, first_mvlan_ip=None, netmask=None, gateway=None, dhcp=True, - use_macvlans=False, - use_test_groups=False, - write_only_test_group=None, - read_only_test_group=None, port_list=[], ip_list=None, connections_per_port=1, - mode="both", - update_group_args={"name": None, "action": None, "cxs": None}, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port) - self.host = host self.port = port self.radio = radio self.upstream_port = upstream_port - self.ssid = ssid - self.security = security - self.password = password - self.number_template = number_template - self.test_duration = test_duration self.port_list = [] self.connections_per_port = connections_per_port - self.use_macvlans = use_macvlans - self.mode = mode.lower() self.ip_list = ip_list self.netmask = netmask self.gateway = gateway self.dhcp = dhcp - if self.use_macvlans: - if macvlan_parent is not None: - self.macvlan_parent = macvlan_parent - self.port_list = port_list - else: + if macvlan_parent is not None: + self.macvlan_parent = macvlan_parent self.port_list = port_list - self.use_test_groups = use_test_groups - if self.use_test_groups: - if self.mode == "write": - if write_only_test_group is not None: - self.write_only_test_group = write_only_test_group - else: - raise ValueError("--write_only_test_group must be used to set test group name") - if self.mode == "read": - if read_only_test_group is not None: - self.read_only_test_group = read_only_test_group - else: - raise ValueError("--read_only_test_group must be used to set test group name") - if self.mode == "both": - if write_only_test_group is not None and read_only_test_group is not None: - self.write_only_test_group = write_only_test_group - self.read_only_test_group = read_only_test_group - else: - raise ValueError("--write_only_test_group and --read_only_test_group " - "must be used to set test group names") - - - - self.wo_profile = self.new_fio_endp_profile() self.mvlan_profile = self.new_mvlan_profile() - if not self.use_macvlans and len(self.port_list) > 0: - self.station_profile = self.new_station_profile() - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - self.wo_profile.server_mount = server_mount - self.wo_profile.num_connections_per_port = connections_per_port - - self.ro_profile = self.wo_profile.create_ro_profile() - - if self.use_macvlans: - self.mvlan_profile.num_macvlans = int(num_ports) - self.mvlan_profile.desired_macvlans = self.port_list - self.mvlan_profile.macvlan_parent = self.macvlan_parent - self.mvlan_profile.dhcp = dhcp - self.mvlan_profile.netmask = netmask - self.mvlan_profile.first_ip_addr = first_mvlan_ip - self.mvlan_profile.gateway = gateway + self.mvlan_profile.num_macvlans = int(num_ports) + self.mvlan_profile.desired_macvlans = self.port_list + self.mvlan_profile.macvlan_parent = self.macvlan_parent + self.mvlan_profile.dhcp = dhcp + self.mvlan_profile.netmask = netmask + self.mvlan_profile.first_ip_addr = first_mvlan_ip + self.mvlan_profile.gateway = gateway self.created_ports = [] - if self.use_test_groups: - if self.mode is not None: - if self.mode == "write": - self.wo_tg_profile = self.new_test_group_profile() - self.wo_tg_profile.group_name = self.write_only_test_group - elif self.mode == "read": - self.ro_tg_profile = self.new_test_group_profile() - self.ro_tg_profile.group_name = self.read_only_test_group - elif self.mode == "both": - self.wo_tg_profile = self.new_test_group_profile() - self.ro_tg_profile = self.new_test_group_profile() - self.wo_tg_profile.group_name = self.write_only_test_group - self.ro_tg_profile.group_name = self.read_only_test_group - else: - raise ValueError("Unknown mode given ", self.mode) - else: - raise ValueError("Mode ( read, write, or both ) must be specified") - - if update_group_args is not None and update_group_args['name'] is not None: - temp_tg = self.new_test_group_profile() - temp_cxs = update_group_args['cxs'].split(',') - if update_group_args['action'] == "add": - temp_tg.group_name = update_group_args['name'] - if not temp_tg.check_group_exists(): - temp_tg.create_group() - for cx in temp_cxs: - if "CX_" not in cx: - cx = "CX_" + cx - temp_tg.add_cx(cx) - if update_group_args['action'] == "del": - temp_tg.group_name = update_group_args['name'] - if temp_tg.check_group_exists(): - for cx in temp_cxs: - temp_tg.rm_cx(cx) - time.sleep(5) - - self.wo_tg_exists = False - self.ro_tg_exists = False - self.wo_tg_cx_exists = False - self.ro_tg_cx_exists = False - print("Checking for pre-existing test groups and cxs") - if self.use_test_groups: - if self.mode == "write": - if self.wo_tg_profile.check_group_exists(): - self.wo_tg_exists = True - if len(self.wo_tg_profile.list_cxs()) > 0: - self.wo_tg_cx_exists = True - elif self.mode == "read": - if self.ro_tg_profile.check_group_exists(): - self.ro_tg_exists = True - if len(self.ro_tg_profile.list_cxs()) > 0: - self.ro_tg_cx_exists = True - elif self.mode == "both": - if self.wo_tg_profile.check_group_exists(): - self.wo_tg_exists = True - if len(self.wo_tg_profile.list_cxs()) > 0: - self.wo_tg_cx_exists = True - if self.ro_tg_profile.check_group_exists(): - self.ro_tg_exists = True - if len(self.ro_tg_profile.list_cxs()) > 0: - self.ro_tg_cx_exists = True - - def __compare_vals(self, val_list): - passes = 0 - expected_passes = 0 - # print(val_list) - for item in val_list: - expected_passes += 1 - # print(item) - if item[0] == 'r': - # print("TEST", item, - # val_list[item]['read-bps'], - # self.ro_profile.min_read_rate_bps, - # val_list[item]['read-bps'] > self.ro_profile.min_read_rate_bps) - - if val_list[item]['read-bps'] > self.wo_profile.min_read_rate_bps: - passes += 1 - else: - # print("TEST", item, - # val_list[item]['write-bps'], - # self.wo_profile.min_write_rate_bps, - # val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps) - - if val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps: - passes += 1 - if passes == expected_passes: - return True - else: - return False - else: - return False - - def __get_values(self): - time.sleep(3) - if self.mode == "write": - cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % ( - ','.join(self.wo_profile.created_cx.keys())), debug_=self.debug) - elif self.mode == "read": - cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % ( - ','.join(self.ro_profile.created_cx.keys())), debug_=self.debug) - else: - cx_list = self.json_get("fileio/%s,%s?fields=write-bps,read-bps" % ( - ','.join(self.wo_profile.created_cx.keys()), - ','.join(self.ro_profile.created_cx.keys())), debug_=self.debug) - # print(cx_list) - # print("==============\n", cx_list, "\n==============") - cx_map = {} - # pprint.pprint(cx_list) - if cx_list is not None: - cx_list = cx_list['endpoint'] - for i in cx_list: - for item, value in i.items(): - # print(item, value) - cx_map[self.name_to_eid(item)[2]] = {"read-bps": value['read-bps'], "write-bps": value['write-bps']} - # print(cx_map) - return cx_map def build(self): # Build stations - if self.use_macvlans: - print("Creating MACVLANs") - self.mvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug) - self._pass("PASS: MACVLAN build finished") - self.created_ports += self.mvlan_profile.created_macvlans - elif not self.use_macvlans and self.ip_list is None: - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.port_list, debug=self.debug) - self._pass("PASS: Station build finished") - self.created_ports += self.station_profile.station_names - - if len(self.ip_list) > 0: - # print("++++++++++++++++\n", self.ip_list, "++++++++++++++++\n") - for num_port in range(len(self.port_list)): - if self.ip_list[num_port] != 0: - if self.gateway is not None and self.netmask is not None: - shelf = self.name_to_eid(self.port_list[num_port])[0] - resource = self.name_to_eid(self.port_list[num_port])[1] - port = self.name_to_eid(self.port_list[num_port])[2] - req_url = "/cli-json/set_port" - data = { - "shelf": shelf, - "resource": resource, - "port": port, - "ip_addr": self.ip_list[num_port], - "netmask": self.netmask, - "gateway": self.gateway - } - self.json_post(req_url, data) - self.created_ports.append("%s.%s.%s" % (shelf, resource, port)) - else: - raise ValueError("Netmask and gateway must be specified") - + print("Creating MACVLANs") + self.mvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug) + self._pass("PASS: MACVLAN build finished") + self.created_ports += self.mvlan_profile.created_macvlans def main(): parser = LFCliBase.create_bare_argparse( prog='create_macvlan.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, - epilog='''Creates FileIO endpoints which can be NFS, CIFS or iSCSI endpoints.''', + epilog='''Creates MACVLAN endpoints.''', description='''\ create_macvlan.py: -------------------- Generic command layout: -./create_macvlan.py --macvlan_parent --num_ports --use_macvlans +./create_macvlan.py --macvlan_parent --num_ports --first_mvlan_ip --netmask --gateway -./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 +./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 -./create_macvlan.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans - --use_ports eth1#0,eth1#1,eth1#2 --connections_per_port 2 --mode write +./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 + --use_ports eth1#0,eth1#1,eth1#2 --connections_per_port 2 -./create_macvlan.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans +./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 --first_mvlan_ip 10.40.3.100 --netmask 255.255.240.0 --gateway 10.40.0.1 - --use_test_groups --write_only_test_group test_wo --read_only_test_group test_ro --add_to_group test_wo -./create_macvlan.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans +./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 --use_ports eth1#0=10.40.3.103,eth1#1,eth1#2 --connections_per_port 2 --netmask 255.255.240.0 --gateway 10.40.0.1 ''') parser.add_argument('--num_stations', help='Number of stations to create', default=0) parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') - parser.add_argument('--ssid', help='SSID for stations to associate to') - parser.add_argument('--passwd', '--password', '--key', help='WiFi passphrase/password/key') - parser.add_argument('--security', help='security type to use for ssid { wep | wpa | wpa2 | wpa3 | open }') parser.add_argument('-u', '--upstream_port', - help='non-station port that generates traffic: ., e.g: 1.eth1', - default='1.eth1') - parser.add_argument('--test_duration', help='sets the duration of the test', default="5m") - parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1', - default="10.40.0.1:/var/tmp/test") - + help='non-station port that generates traffic: ., e.g: 1.eth1', + default='1.eth1') parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None) parser.add_argument('--first_port', help='specifies name of first port to be used', default=None) parser.add_argument('--num_ports', help='number of ports to create', default=1) @@ -328,36 +108,13 @@ Generic command layout: parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip' '{ port_name1=ip_addr1,port_name1=ip_addr2 }. ' 'Ports without ips will be left alone', default=None) - parser.add_argument('--use_macvlans', help='will create macvlans', action='store_true', default=False) parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None) parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None) parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None) - parser.add_argument('--use_test_groups', help='will use test groups to start/stop instead of single endps/cxs', - action='store_true', default=False) - parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None) - parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None) - parser.add_argument('--mode', help='write,read,both', default='both', type=str) - tg_group = parser.add_mutually_exclusive_group() - tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None) - tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None) parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group' , default=None) args = parser.parse_args() - update_group_args = { - "name": None, - "action": None, - "cxs": None - } - if args.add_to_group is not None and args.cxs is not None: - update_group_args['name'] = args.add_to_group - update_group_args['action'] = "add" - update_group_args['cxs'] = args.cxs - elif args.del_from_group is not None and args.cxs is not None: - update_group_args['name'] = args.del_from_group - update_group_args['action'] = "del" - update_group_args['cxs'] = args.cxs - port_list = [] ip_list = [] if args.first_port is not None and args.use_ports is not None: @@ -365,17 +122,17 @@ Generic command layout: if (args.num_ports is not None) and (int(args.num_ports) > 0): start_num = int(args.first_port[3:]) num_ports = int(args.num_ports) - port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num+num_ports-1, - padding_number=10000, - radio=args.radio) + port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1, + padding_number=10000, + radio=args.radio) else: if (args.num_ports is not None) and args.macvlan_parent is not None and (int(args.num_ports) > 0) \ - and args.macvlan_parent in args.first_port: - start_num = int(args.first_port[args.first_port.index('#')+1:]) + and args.macvlan_parent in args.first_port: + start_num = int(args.first_port[args.first_port.index('#') + 1:]) num_ports = int(args.num_ports) - port_list = LFUtils.port_name_series(prefix=args.macvlan_parent+"#", start_id=start_num, - end_id=start_num+num_ports-1, padding_number=100000, - radio=args.radio) + port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=start_num, + end_id=start_num + num_ports - 1, padding_number=100000, + radio=args.radio) else: raise ValueError("Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n" "first_port must contain parent port and num_ports must be greater than 0" @@ -383,14 +140,9 @@ Generic command layout: else: if args.use_ports is None: num_ports = int(args.num_ports) - if not args.use_macvlans: - port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1, - padding_number=10000, - radio=args.radio) - else: - port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0, - end_id=num_ports - 1, padding_number=100000, - radio=args.radio) + port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0, + end_id=num_ports - 1, padding_number=100000, + radio=args.radio) else: temp_list = args.use_ports.split(',') for port in temp_list: @@ -413,34 +165,24 @@ Generic command layout: # print(port_list) # exit(1) - ip_test = FileIOTest(args.mgr, - args.mgr_port, - ssid=args.ssid, - password=args.passwd, - security=args.security, - port_list=port_list, - ip_list=ip_list, - test_duration=args.test_duration, - upstream_port=args.upstream_port, - _debug_on=args.debug, - - macvlan_parent=args.macvlan_parent, - use_macvlans=args.use_macvlans, - first_mvlan_ip=args.first_mvlan_ip, - netmask=args.netmask, - gateway=args.gateway, - dhcp=dhcp, - num_ports=args.num_ports, - use_test_groups=args.use_test_groups, - write_only_test_group=args.write_only_test_group, - read_only_test_group=args.read_only_test_group, - update_group_args = update_group_args, - connections_per_port=args.connections_per_port, - mode=args.mode - # want a mount options param - ) + ip_test = CreateMacVlan(args.mgr, + args.mgr_port, + port_list=port_list, + ip_list=ip_list, + upstream_port=args.upstream_port, + _debug_on=args.debug, + macvlan_parent=args.macvlan_parent, + first_mvlan_ip=args.first_mvlan_ip, + netmask=args.netmask, + gateway=args.gateway, + dhcp=dhcp, + num_ports=args.num_ports, + connections_per_port=args.connections_per_port, + # want a mount options param + ) ip_test.build() + if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh new file mode 100644 index 00000000..9708b50b --- /dev/null +++ b/py-scripts/html_test_output.sh @@ -0,0 +1,121 @@ +#!/bin/bash +#This bash script aims to automate the test process of all Candela Technologies's test_* scripts in the lanforge-scripts directory. The script can be run 2 ways and may include (via user input) the "start_num" and "stop_num" variables to select which tests should be run. +# OPTION ONE: ./test_all_scripts.sh : this command runs all the scripts in the array "testCommands" +# OPTION TWO: ./test_all_scripts.sh 4 5 : this command runs py-script commands (in testCommands array) that include the py-script options beginning with 4 and 5 (inclusive) in case function ret_case_num. +#Variables +NUM_STA=4 +SSID_USED="jedway-wpa2-x2048-5-3" +PASSWD_USED="jedway-wpa2-x2048-5-3" +RADIO_USED="wiphy1" +SECURITY="wpa2" + +START_NUM=0 +CURR_TEST_NUM=0 +CURR_TEST_NAME="BLANK" +STOP_NUM=9 + +#Test array +testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa " + "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" + "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep" + "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3" + "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --upstream_port eth1" + "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" + "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" + "./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" + "./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m" + "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format excel" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format csv" + "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" + "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./create_macvlan.py --radio wiphy1" + "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" +) +declare -A name_to_num +name_to_num=( + ["example_security_connection"]=1 + ["test_ipv4_connection"]=2 + ["test_generic"]=3 + ["test_ipv4_l4_urls_per_ten"]=4 + ["test_ipv4_l4_wifi"]=5 + ["test_ipv4_l4"]=6 + ["test_ipv4_variable_time"]=7 + ["create_bridge"]=8 + ["create_l3"]=9 + ["create_l4"]=10 + ["create_macvlan"]=10 + ["create_station"]=11 + ["create_vap"]=12 +) + +function blank_db() { + echo "Loading blank scenario..." >>~/test_all_output_file.txt + ./scenario.py --load BLANK >>~/test_all_output_file.txt + #check_blank.py +} +function echo_print() { + echo "Beginning $CURR_TEST_NAME test..." >>~/test_all_output_file.txt +} +results=() +function run_test() { + for i in "${testCommands[@]}"; do + CURR_TEST_NAME=${i%%.py*} + CURR_TEST_NAME=${CURR_TEST_NAME#./*} + CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" + echo "$CURR_TEST_NAME $CURR_TEST_NUM" + + if (( $CURR_TEST_NUM > $STOP_NUM )) || (( $STOP_NUM == $CURR_TEST_NUM )) && (( $STOP_NUM != 0 )); then + exit 1 + fi + if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then + echo_print + echo "$i" + [[ x$DEBUG != x ]] && sleep 2 + results+=("${CURR_TEST_NAME}success") + eval "$i" >>~/test_all_output_file_success.txt || true + [[ x$DEBUG != x ]] && exit 1 + results+=("${CURR_TEST_NAME}failure") + eval "$i" >>~/test_all_output_file_failure.txt + [[ x$DEBUG != x ]] + done +} +function check_args() { + if [ ! -z $1 ]; then + START_NUM=$1 + fi + if [ ! -z $2 ]; then + STOP_NUM=$2 + fi +} +function html_generator() { + NOW=$(date +"%Y-%m-%d-%T") + header=" + + Candela Test All Scripts Results + + + +

Candela Technologies

+ + " + tail="
+ + " + fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" + echo $header"${results[@]}"$tail > ${fname} +} +#true >~/test_all_output_file.txt +check_args $1 $2 +run_test +html_generator +#test generic and fileio are for macvlans diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 570f77c0..c3cf963d 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -213,13 +213,16 @@ python3 ./test_ipv4_variable_time.py if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) + #Create directory + homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' + os.mkdir('/home/lanforge/report_data/'+homedir) if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format + report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format output=args.output_format else: print('Defaulting to Excel') - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' + report_f='/home/lanforge/report-data/'+homedir+'/data.xlsx' output='excel' else: report_f=args.report_file @@ -258,12 +261,12 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], report_file=report_f, - duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds, + duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', arguments=args) - + ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From 61c84c47160c36bdaef2afbcc21c06418baa0a2b Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:39:23 -0800 Subject: [PATCH 075/848] test-all-scripts --- py-scripts/test_all_scripts.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/py-scripts/test_all_scripts.sh b/py-scripts/test_all_scripts.sh index e3df7f59..66106e4a 100644 --- a/py-scripts/test_all_scripts.sh +++ b/py-scripts/test_all_scripts.sh @@ -1,4 +1,3 @@ - #!/bin/bash #This bash script aims to automate the test process of all Candela Technologies's test_* scripts in the lanforge-scripts directory. The script can be run 2 ways and may include (via user input) the "start_num" and "stop_num" variables to select which tests should be run. # OPTION ONE: ./test_all_scripts.sh : this command runs all the scripts in the array "testCommands" From 5af1160a145a28def5da38819559f12bea6febdb Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 21 Jan 2021 16:48:45 -0700 Subject: [PATCH 076/848] lf_ap_power.py: LCS-45 Read AP for Power values, typo and changed the file attributesto executable --- cisco_ap_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index cf8f16e6..059b4a16 100644 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -181,7 +181,7 @@ def main(): egg.sendcontrol('c') egg.expect("#",timeout=5) egg.sendline("exit") - egg.excect(">",timeout=5) + egg.expect(">",timeout=5) egg.sendline("exit") # ctlr.execute(cn_cmd) From 07d3d2eb6f935c15b6c587d220d958d9a7a41252 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:53:34 -0800 Subject: [PATCH 077/848] realm cleaned --- py-json/realm.py | 72 ------------------------------------------------ 1 file changed, 72 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6f327744..1626e1ba 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -822,21 +822,13 @@ class Realm(LFCliBase): def new_test_group_profile(self): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) -<<<<<<< HEAD - class BaseProfile(LFCliBase): def __init__(self, local_realm): self.parent_realm = local_realm -======= -class BaseProfile(LFCliBase): - def __init__(self,local_realm): - self.parent_realm=local_realm ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee self.halt_on_error = False self.exit_on_error = False def json_get(self, target): -<<<<<<< HEAD return self.parent_realm.json_get(target) def json_post(self, req_url, data, debug_=False, suppress_related_commands_=None): @@ -875,10 +867,6 @@ class BaseProfile(LFCliBase): def wait_until_cxs_appear(self, target, debug=False): return self.parent_realm.wait_until_cxs_appear(target, debug=False) -======= - self.debug_ = False - return self.parent_realm.json_get(self,target) ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -1055,7 +1043,6 @@ class MULTICASTProfile(LFCliBase): pprint.pprint(self) -<<<<<<< HEAD class L3CXProfile(BaseProfile): def __init__(self, lfclient_host, @@ -1073,16 +1060,6 @@ class L3CXProfile(BaseProfile): name_prefix_="Unset", number_template_="00000", debug_=False): -======= - -class L3CXProfile(BaseProfile): - def __init__(self, lfclient_host, lfclient_port, local_realm, - side_a_min_bps=None, side_b_min_bps=None, - side_a_max_bps=0, side_b_max_bps=0, - side_a_min_pdu=-1, side_b_min_pdu=-1, - side_a_max_pdu=0, side_b_max_pdu=0, - report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee """ :param lfclient_host: :param lfclient_port: @@ -1162,21 +1139,13 @@ class L3CXProfile(BaseProfile): monitor_interval=1, col_names=None, created_cx=None, -<<<<<<< HEAD monitor=True, -======= - show=True, ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee report_file=None, output_format=None, script_name=None, arguments=None): try: -<<<<<<< HEAD duration_sec = self.parse_time(duration_sec).seconds -======= - duration_sec=self.local_realm.parse_time(duration_sec).seconds ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") @@ -1197,7 +1166,6 @@ class L3CXProfile(BaseProfile): else: output_format = report_file.split('.')[-1] -<<<<<<< HEAD # Step 1, column names if fields = None: pass @@ -1205,12 +1173,6 @@ class L3CXProfile(BaseProfile): fields = ",".join(col_names) print(fields) # Step 2, monitor columns -======= - #Step 1, column names - fields=",".join(col_names) - print(fields) - #Step 2, monitor columns ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) print(end_time) @@ -1219,7 +1181,6 @@ class L3CXProfile(BaseProfile): passes = 0 expected_passes = 0 old_cx_rx_values = self.__get_rx_values() -<<<<<<< HEAD timestamps = [] # for x in range(0,int(round(iterations,0))): if col_names = None: @@ -1229,12 +1190,6 @@ class L3CXProfile(BaseProfile): response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) -======= - timestamps=[] - #for x in range(0,int(round(iterations,0))): - while datetime.datetime.now() < end_time: - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1260,15 +1215,8 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) -<<<<<<< HEAD - # step 3 organize data - endpoints = list() -======= - #if passes == expected_passes: - #self._pass("PASS: All tests passed") #step 3 organize data endpoints=list() ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee for endpoint in value_map.values(): endpoints.append(endpoint['endpoint']) endpoints2 = [] @@ -1280,20 +1228,11 @@ class L3CXProfile(BaseProfile): itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) -<<<<<<< HEAD # step 4 save and close header_row = col_names header_row.insert(0, 'Timestamp') print(header_row) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': -======= - #step 4 save and close - header_row=col_names - print(header_row) - header_row.insert(0,'Timestamp') - if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee - report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) worksheet = workbook.add_worksheet() for col_num, data in enumerate(header_row): @@ -1348,15 +1287,9 @@ class L3CXProfile(BaseProfile): def refresh_cx(self): for cx_name in self.created_cx.keys(): -<<<<<<< HEAD - self.json_post("/cli-json/show_cxe", { - "test_mgr": "ALL", - "cross_connect": cx_name -======= self.local_realm.json_post("/cli-json/show_cxe", { "test_mgr": "ALL", "cross_connect": cx_name ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee }, debug_=self.debug) print(".", end='') @@ -1364,13 +1297,8 @@ class L3CXProfile(BaseProfile): print("Starting CXs...") for cx_name in self.created_cx.keys(): if self.debug: -<<<<<<< HEAD print("cx-name: %s" % (cx_name)) self.json_post("/cli-json/set_cx_state", { -======= - print("cx-name: %s"%(cx_name)) - self.local_realm.json_post("/cli-json/set_cx_state", { ->>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee "test_mgr": "default_tm", "cx_name": cx_name, "cx_state": "RUNNING" From c720a76070a5035d7ae54b25ca430859fb17a911 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:54:44 -0800 Subject: [PATCH 078/848] realm cleaned --- py-json/realm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 1626e1ba..5b831066 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1167,7 +1167,7 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] # Step 1, column names - if fields = None: + if fields == None: pass else: fields = ",".join(col_names) @@ -1183,10 +1183,10 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): - if col_names = None: + if col_names == None: header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: - if fields = None: + if fields == None: response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) From 99bb902d09982ef6acbb1d89aa8ad4396dad7640 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 21 Jan 2021 16:41:31 -0800 Subject: [PATCH 079/848] removes import of generic_cx --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index c9a38271..aefbce39 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -11,7 +11,7 @@ from LANforge import add_dut from LANforge import lfcli_base from LANforge import add_vap from LANforge.lfcli_base import LFCliBase -from generic_cx import GenericCx +# from generic_cx import GenericCx from LANforge import add_monitor from LANforge.add_monitor import * import os From 204b6d4e767042fba96fafafc5ba9b2773d2373a Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 21 Jan 2021 20:23:17 -0800 Subject: [PATCH 080/848] start of monitor additions & urls_per_ten remodeling --- py-json/realm.py | 170 +++++++++++++++++++++++- py-scripts/test_ipv4_l4_urls_per_ten.py | 34 ++--- 2 files changed, 183 insertions(+), 21 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 5b831066..fc55f189 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1130,10 +1130,6 @@ class L3CXProfile(BaseProfile): return False else: return False - - """ - coloumn names - """ def monitor(self, duration_sec=60, monitor_interval=1, @@ -1604,6 +1600,23 @@ class L4CXProfile(LFCliBase): print(".", end='') print("") + def check_request_rate(self): + endp_list = self.json_get("layer4/list?fields=urls/s") + expected_passes = 0 + passes = 0 + if endp_list is not None and endp_list['endpoint'] is not None: + endp_list = endp_list['endpoint'] + for item in endp_list: + for name, info in item.items(): + if name in self.cx_profile.created_cx.keys(): + expected_passes += 1 + if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: + print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) + passes += 1 + + return passes == expected_passes + + def cleanup(self): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: @@ -1662,6 +1675,155 @@ class L4CXProfile(LFCliBase): suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) +################# MONITOR CODE IN L4CXPROF####################### + + + def monitor(self, + duration_sec=60, + monitor_interval=1, + col_names=None, + created_cx=None, + monitor=True, + report_file=None, + output_format=None, + script_name=None, + arguments=None, + iterations=0): + try: + duration_sec = self.parse_time(duration_sec).seconds + except: + if (duration_sec is None) or (duration_sec <= 1): + raise ValueError("L4CXProfile::monitor wants duration_sec > 1 second") + if (duration_sec <= monitor_interval): + raise ValueError("L4CXProfile::monitor wants duration_sec > monitor_interval") + if report_file == None: + raise ValueError("Monitor requires an output file to be defined") + if created_cx == None: + raise ValueError("Monitor needs a list of Layer 4 connections") + if (monitor_interval is None) or (monitor_interval < 1): + raise ValueError("L4CXProfile::monitor wants monitor_interval >= 1 second") + if col_names is None: + raise ValueError("L4CXProfile::monitor wants a list of column names to monitor") + if output_format is not None: + if output_format.lower() != report_file.split('.')[-1]: + if output_format.lower() != 'excel': + raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) + else: + output_format = report_file.split('.')[-1] + + # Step 1, column names + fields = ",".join(col_names) + print(fields) + # Step 2, monitor columns, + start_time = datetime.datetime.now() + end_time = start_time + datetime.timedelta(seconds=duration_sec) + #print(end_time) + sleep_interval = duration_sec // 5 + value_map = dict() + passes = 0 + expected_passes = 0 + + timestamps = [] + for x in range(0,int(round(iterations,0))): + while datetime.datetime.now() < end_time: + response = self.json_get("layer4/list?fields=urls/s") + if "endpoint" not in response: + print(response) + raise ValueError("no endpoint?") + if monitor: + if self.debug: + print(response) + t = datetime.datetime.now() + timestamps.append(t) + value_map[t] = response + if self.debug: + print(old_cx_rx_values, new_cx_rx_values) + print("\n-----------------------------------") + print(curr_time) + print("-----------------------------------\n") + expected_passes += 1 + if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): + passes += 1 + else: + self._fail("FAIL: Not all stations increased traffic") + self.exit_fail() + old_cx_rx_values = new_cx_rx_values + time.sleep(monitor_interval) + print(value_map) + + # if passes == expected_passes: + # self._pass("PASS: All tests passed") + # step 3 organize data + endpoints = list() + for endpoint in value_map.values(): + endpoints.append(endpoint['endpoint']) + endpoints2 = [] + for y in range(0, len(endpoints)): + for x in range(0, len(endpoints[0])): + endpoints2.append(list(list(endpoints[y][x].values())[0].values())) + import itertools + timestamps2 = list( + itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) + for point in range(0, len(endpoints2)): + endpoints2[point].insert(0, timestamps2[point]) + # step 4 save and close + header_row = col_names + header_row.insert(0, 'Timestamp') + print(header_row) + if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': + report_fh = open(report_file, "w+") + workbook = xlsxwriter.Workbook(report_file) + worksheet = workbook.add_worksheet() + for col_num, data in enumerate(header_row): + worksheet.write(0, col_num, data) + row_num = 1 + for x in endpoints2: + for col_num, data in enumerate(x): + worksheet.write(row_num, col_num, str(data)) + row_num += 1 + workbook.close() + else: + df = pd.DataFrame(endpoints2) + df.columns = header_row + import requests + import ast + try: + systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + except: + systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] + df['Script Name'] = script_name + df['Arguments'] = arguments + for x in ['LFGUI Release', 'Script Name', 'Arguments']: + df[x][1:] = '' + if output_format == 'pdf': + import matplotlib.pyplot as plt + from matplotlib.backends.backend_pdf import PdfPages + fig, ax = plt.subplots(figsize=(12, 4)) + ax.axis('tight') + ax.axis('off') + the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') + pp = PdfPages(report_file) + pp.savefig(fig, bbox_inches='tight') + pp.close() + if output_format == 'hdf': + df.to_hdf(report_file, 'table', append=True) + if output_format == 'parquet': + df.to_parquet(report_file, engine='pyarrow') + if output_format == 'png': + fig = df.plot().get_figure() + fig.savefig(report_file) + if output_format == 'html': + print('Shivams function') + if output_format == 'df': + return df + supported_formats = ['csv', 'json', 'stata', 'pickle'] + for x in supported_formats: + if output_format.lower() == x or report_file.split('.')[-1] == x: + exec('df.to_' + x + '("' + report_file + '")') + else: + pass +#end of L4CXProf class class GenCXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 5a1cb981..870126da 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -24,6 +24,7 @@ from LANforge import LFUtils import realm import time import datetime +from realm import TestGroupProfile class IPV4L4(LFCliBase): @@ -66,21 +67,20 @@ class IPV4L4(LFCliBase): self.cx_profile.url = self.url self.cx_profile.requests_per_ten = self.requests_per_ten - def __check_request_rate(self): - endp_list = self.json_get("layer4/list?fields=urls/s") - expected_passes = 0 - passes = 0 - if endp_list is not None and endp_list['endpoint'] is not None: - endp_list = endp_list['endpoint'] - for item in endp_list: - for name, info in item.items(): - if name in self.cx_profile.created_cx.keys(): - expected_passes += 1 - if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: - print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) - passes += 1 - - return passes == expected_passes + # def __check_request_rate(self): + # endp_list = self.json_get("layer4/list?fields=urls/s") + # expected_passes = 0 + # passes = 0 + # if endp_list is not None and endp_list['endpoint'] is not None: + # endp_list = endp_list['endpoint'] + # for item in endp_list: + # for name, info in item.items(): + # if name in self.cx_profile.created_cx.keys(): + # expected_passes += 1 + # if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: + # print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) + # passes += 1 + # return passes == expected_passes def build(self): # Build stations @@ -106,9 +106,9 @@ class IPV4L4(LFCliBase): exit(1) self.cx_profile.start_cx() print("Starting test") - curr_time = datetime.datetime.now() + curr_time = datetime.datetime.now() end_time = self.local_realm.parse_time(self.test_duration) + curr_time - sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 + sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 passes = 0 expected_passes = 0 for test in range(self.num_tests): From 44093e28a2b93c8bcd374d76cdff52114460b526 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 21 Jan 2021 22:49:12 -0800 Subject: [PATCH 081/848] additions to L4Prof monitor, edits to logic of col names in L3 Monitor --- py-json/realm.py | 58 ++++++++++++++----------- py-scripts/test_ipv4_l4_urls_per_ten.py | 3 +- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index fc55f189..aa4355a5 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -11,7 +11,7 @@ from LANforge import add_dut from LANforge import lfcli_base from LANforge import add_vap from LANforge.lfcli_base import LFCliBase -from generic_cx import GenericCx +#from generic_cx import GenericCx from LANforge import add_monitor from LANforge.add_monitor import * import os @@ -1162,11 +1162,12 @@ class L3CXProfile(BaseProfile): else: output_format = report_file.split('.')[-1] - # Step 1, column names - if fields == None: - pass - else: + # Step 1, column names . what is this for? + fields=None + if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) + else: + header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() @@ -1179,8 +1180,6 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): - if col_names == None: - header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: if fields == None: response = self.json_get("/endp/all") @@ -1199,7 +1198,7 @@ class L3CXProfile(BaseProfile): if self.debug: print(old_cx_rx_values, new_cx_rx_values) print("\n-----------------------------------") - print(curr_time) + print(t) print("-----------------------------------\n") expected_passes += 1 if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): @@ -1711,46 +1710,53 @@ class L4CXProfile(LFCliBase): else: output_format = report_file.split('.')[-1] - # Step 1, column names - fields = ",".join(col_names) + # Step 1, column names + + fields=None + if col_names is not None and len(col_names) > 0: + fields = ",".join(col_names) + else: + header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) print(fields) + # Step 2, monitor columns, + start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) - #print(end_time) sleep_interval = duration_sec // 5 value_map = dict() passes = 0 expected_passes = 0 - timestamps = [] - for x in range(0,int(round(iterations,0))): + for test in range(1+iterations): + #while current loop hasn't ended while datetime.datetime.now() < end_time: - response = self.json_get("layer4/list?fields=urls/s") + #what does response ? get? + response=self.json_get("layer4/all") + #response = self.json_get("layer4/list?fields=urls/s") if "endpoint" not in response: print(response) - raise ValueError("no endpoint?") + raise ValueError("Cannot find any endpoints") if monitor: if self.debug: print(response) + time.sleep(sleep_interval.total_seconds()) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response - if self.debug: - print(old_cx_rx_values, new_cx_rx_values) - print("\n-----------------------------------") - print(curr_time) - print("-----------------------------------\n") expected_passes += 1 - if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): - passes += 1 + if self.cx_profile.check_errors(self.debug): + if self.__check_request_rate(): + passes += 1 + else: + self._fail("FAIL: Request rate did not exceed 90% target rate", print_fail) + break else: - self._fail("FAIL: Not all stations increased traffic") - self.exit_fail() - old_cx_rx_values = new_cx_rx_values + self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) + break time.sleep(monitor_interval) print(value_map) - +############################################# edited 'til here - dipti 1/21/20 # if passes == expected_passes: # self._pass("PASS: All tests passed") # step 3 organize data diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 870126da..50d37ef3 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -108,7 +108,7 @@ class IPV4L4(LFCliBase): print("Starting test") curr_time = datetime.datetime.now() end_time = self.local_realm.parse_time(self.test_duration) + curr_time - sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 + sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 passes = 0 expected_passes = 0 for test in range(self.num_tests): @@ -128,7 +128,6 @@ class IPV4L4(LFCliBase): else: self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) break - #interval_time = cur_time + datetime.timedelta(minutes=2) if passes == expected_passes: self._pass("PASS: All tests passes", print_pass) From 49a1e75b0a5fe278191d0cb0ad935cb0c34ece61 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 21 Jan 2021 23:07:03 -0800 Subject: [PATCH 082/848] contuination of editing pdf output format --- py-json/realm.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index aa4355a5..6538a6fe 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1674,9 +1674,6 @@ class L4CXProfile(LFCliBase): suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) -################# MONITOR CODE IN L4CXPROF####################### - - def monitor(self, duration_sec=60, monitor_interval=1, @@ -1716,6 +1713,7 @@ class L4CXProfile(LFCliBase): if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) else: + #todo:rename this... header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) print(fields) @@ -1749,16 +1747,15 @@ class L4CXProfile(LFCliBase): if self.__check_request_rate(): passes += 1 else: - self._fail("FAIL: Request rate did not exceed 90% target rate", print_fail) - break + self._fail("FAIL: Request rate did not exceed 90% target rate") + self.exit_fail() else: - self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) - break + self._fail("FAIL: Errors found getting to %s " % self.url) + self.exit_fail() + #check monitor sleep time time.sleep(monitor_interval) print(value_map) ############################################# edited 'til here - dipti 1/21/20 - # if passes == expected_passes: - # self._pass("PASS: All tests passed") # step 3 organize data endpoints = list() for endpoint in value_map.values(): From 5c18c4edfdd3f44191f9e67f5d433392cb6406e0 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 01:33:24 -0800 Subject: [PATCH 083/848] addition of test output logic for urls_per_ten , arg parsing changes to var_time --- py-json/realm.py | 4 +- py-scripts/test_ipv4_l4_urls_per_ten.py | 74 ++++++++++++------------- py-scripts/test_ipv4_variable_time.py | 8 +-- 3 files changed, 41 insertions(+), 45 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6538a6fe..ed0815a6 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1714,7 +1714,9 @@ class L4CXProfile(LFCliBase): fields = ",".join(col_names) else: #todo:rename this... - header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) + header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) + if self.debug: + print(header_row) print(fields) # Step 2, monitor columns, diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 50d37ef3..22d6213a 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -34,6 +34,7 @@ class IPV4L4(LFCliBase): _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 @@ -52,6 +53,8 @@ class IPV4L4(LFCliBase): self.target_requests_per_ten = int(target_requests_per_ten) self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.l4cxprofile=realm.L4CXProfile(lfclient_host=host, + lfclient_port=port,local_realm=self.local_realm) self.station_profile = self.local_realm.new_station_profile() self.cx_profile = self.local_realm.new_l4_cx_profile() @@ -67,20 +70,6 @@ class IPV4L4(LFCliBase): self.cx_profile.url = self.url self.cx_profile.requests_per_ten = self.requests_per_ten - # def __check_request_rate(self): - # endp_list = self.json_get("layer4/list?fields=urls/s") - # expected_passes = 0 - # passes = 0 - # if endp_list is not None and endp_list['endpoint'] is not None: - # endp_list = endp_list['endpoint'] - # for item in endp_list: - # for name, info in item.items(): - # if name in self.cx_profile.created_cx.keys(): - # expected_passes += 1 - # if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: - # print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) - # passes += 1 - # return passes == expected_passes def build(self): # Build stations @@ -105,32 +94,8 @@ class IPV4L4(LFCliBase): self._fail("Stations failed to get IPs", print_fail) exit(1) self.cx_profile.start_cx() - print("Starting test") - curr_time = datetime.datetime.now() - end_time = self.local_realm.parse_time(self.test_duration) + curr_time - sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 - passes = 0 - expected_passes = 0 - for test in range(self.num_tests): - expected_passes += 1 - while curr_time < end_time: - time.sleep(sleep_interval.total_seconds()) - if self.debug: - print(".",end="") - curr_time = datetime.datetime.now() - - if self.cx_profile.check_errors(self.debug): - if self.__check_request_rate(): - passes += 1 - else: - self._fail("FAIL: Request rate did not exceed 90% target rate", print_fail) - break - else: - self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) - break - if passes == expected_passes: - self._pass("PASS: All tests passes", print_pass) - + print("Starting test...") + def stop(self): self.cx_profile.stop_cx() self.station_profile.admin_down() @@ -202,12 +167,31 @@ python3 ./test_ipv4_l4_urls_per_ten.py optional.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90 percent this value',default=600) optional.add_argument('--mode',help='Used to force mode of stations') optional.add_argument('--ap',help='Used to force a connection to a particular AP') + optional.add_argument('--report_file',help='where you want to store results') + optional.add_argument('--output_format', help='choose either csv or xlsx') + args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted + if args.report_file is None: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: + output_form=args.output_format + print("Defaulting file output placement to /home/lanforge.") + rpt_file='/home/lanforge/data.' + output_form + else: + print("Defaulting data file output type to Excel") + rpt_file='/home/lanforge/data.xlsx' + output_form='xlsx' + + else: + rpt_file=args.report_file + if args.output_format is None: + output_form=str(args.report_file).split('.')[-1] + else: + output_form=args.output_format station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, @@ -230,6 +214,16 @@ python3 ./test_ipv4_l4_urls_per_ten.py ip_test.cleanup(station_list) ip_test.build() ip_test.start() + + try: + layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) + except: + pass + ip_test.l4cxprofile.monitor(report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), + created_cx=layer4traffic, + output_format=output_form, + script_name='test_ipv4_l4_urls_per_ten', + arguments=args) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 34adc480..b74c358f 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -202,14 +202,15 @@ python3 ./test_ipv4_variable_time.py #Create directory homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' os.mkdir('/home/lanforge/report_data/'+homedir) + if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format output=args.output_format else: - print('Defaulting to Excel') + print('Defaulting data file output type to Excel') report_f='/home/lanforge/report-data/'+homedir+'/data.xlsx' - output='excel' + output='xlsx' else: report_f=args.report_file if args.output_format is None: @@ -253,7 +254,6 @@ python3 ./test_ipv4_variable_time.py created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', - show=show, arguments=args) ip_var_test.stop() From 8910aea156404eee8bbc34eb328e84de41de21e3 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 02:22:17 -0800 Subject: [PATCH 084/848] continuation of file output edits/formatting --- py-json/realm.py | 6 +++--- py-scripts/test_ipv4_l4_urls_per_ten.py | 17 ++++++++--------- py-scripts/test_ipv4_variable_time.py | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index ed0815a6..407836a2 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1702,8 +1702,7 @@ class L4CXProfile(LFCliBase): raise ValueError("L4CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: - if output_format.lower() != 'excel': - raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) + raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) else: output_format = report_file.split('.')[-1] @@ -1712,12 +1711,13 @@ class L4CXProfile(LFCliBase): fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) + if self.debug: + print(fields) else: #todo:rename this... header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) if self.debug: print(header_row) - print(fields) # Step 2, monitor columns, diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 22d6213a..ac03c228 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -140,12 +140,14 @@ python3 ./test_ipv4_l4_urls_per_ten.py "an" : "10", "bgnAC" : "11", "abgnAX" : "12", - "bgnAX" : "13", + "bgnAX" : "13"} \\ --num_tests 1 \\ --url "dl http://10.40.0.1 /dev/null" \\ --ap "00:0e:8e:78:e1:76" --target_per_ten 600 \\ - --test_duration 2m + --output_format csv \\ + --report_file ~/Documents/results.csv \\ + --test_duration 2m \\ --debug ''') required = None @@ -168,7 +170,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py optional.add_argument('--mode',help='Used to force mode of stations') optional.add_argument('--ap',help='Used to force a connection to a particular AP') optional.add_argument('--report_file',help='where you want to store results') - optional.add_argument('--output_format', help='choose either csv or xlsx') + optional.add_argument('--output_format', help='choose csv or xlsx') #update once other forms are completed args = parser.parse_args() @@ -177,8 +179,8 @@ python3 ./test_ipv4_l4_urls_per_ten.py num_stations_converted = int(args.num_stations) num_sta = num_stations_converted if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: - output_form=args.output_format + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','png','df','xlsx']: + output_form=args.output_format.lower() print("Defaulting file output placement to /home/lanforge.") rpt_file='/home/lanforge/data.' + output_form else: @@ -220,10 +222,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py except: pass ip_test.l4cxprofile.monitor(report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), - created_cx=layer4traffic, - output_format=output_form, - script_name='test_ipv4_l4_urls_per_ten', - arguments=args) + created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', arguments=args) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index b74c358f..ffd5767e 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -204,7 +204,7 @@ python3 ./test_ipv4_variable_time.py os.mkdir('/home/lanforge/report_data/'+homedir) if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format output=args.output_format else: @@ -265,7 +265,7 @@ python3 ./test_ipv4_variable_time.py if ip_var_test.passes(): ip_var_test.exit_success() - IPV4VariableTime.cx_profile.stop_cx() + IPV4VariableTime.cx_profile.stop_cx() #is this needed? if __name__ == "__main__": main() From ce29408579581bb6c90eee7d9178678eda0a2442 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 07:42:20 -0700 Subject: [PATCH 085/848] lf_ap_power.py: LCS-45 Read AP for Power values Updated login to help with multiple logins lf_cisco_power.py: comments update --- cisco_ap_ctl.py | 83 +++++++++++++++++++++++++++++++---------------- lf_cisco_power.py | 5 +-- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index 059b4a16..654e7150 100644 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -20,12 +20,12 @@ if sys.version_info[0] != 3: print("This script requires Python 3") exit() -import re +#import re import logging import time from time import sleep -import pprint -import telnetlib +#import pprint +#import telnetlib import argparse import pexpect @@ -95,10 +95,8 @@ def main(): scheme = args.scheme port = (default_ports[scheme], args.port)[args.port != None] user = args.user - passwd = args.passwd if (args.log != None): logfile = args.log - filehandler = None except Exception as e: logging.exception(e) usage() @@ -159,31 +157,60 @@ def main(): except Exception as e: logging.exception(e) - ap_prompt = "{}>".format(args.prompt) - ap_hash = "{}#".format(args.prompt) - egg.sendline() + AP_PROMPT = "{}>".format(args.prompt) + AP_HASH = "{}#".format(args.prompt) + AP_ESCAPE = "Escape character is '^]'." + AP_USERNAME = "Username:" + AP_PASSWORD = "Password:" + AP_EN = "en" + AP_MORE = "--More--" + AP_EXIT = "exit" + CR = "\r\n" + time.sleep(0.1) + logged_in = False + loop_count = 0 + while (loop_count <= 8 and logged_in == False): + loop_count += 1 + i = egg.expect_exact([AP_ESCAPE,AP_PROMPT,AP_HASH,AP_USERNAME,AP_PASSWORD,pexpect.TIMEOUT],timeout=5) + if i == 0: + logg.info("Expect: {} i: {} before: {} after: {}".format(AP_ESCAPE,i,egg.before,egg.after)) + egg.sendline(CR) # Needed after Escape or should just do timeout and then a CR? + sleep(0.2) + if i == 1: + logg.info("Expect: {} i: {} before: {} after: {}".format(AP_PROMPT,i,egg.before,egg.after)) + egg.sendline(AP_EN) + sleep(0.2) + if i == 2: + logg.info("Expect: {} i: {} before: {} after: {}".format(AP_HASH,i,egg.before,egg.after)) + logged_in = True + sleep(0.2) + if i == 3: + logg.info("Expect: {} i: {} before: {} after: {}".format(AP_USERNAME,i,egg.before,egg.after)) + egg.sendline(args.user) + sleep(0.2) + if i == 4: + logg.info("Expect: {} i: {} before: {} after: {}".format(AP_PASSWORD,i,egg.before,egg.after)) + egg.sendline(args.passwd) + sleep(0.2) + if i == 5: + logg.info("Expect: {} i: {} before: {} after: {}".format("Timeout",i,egg.before,egg.after)) + egg.sendline(CR) + sleep(0.2) - egg.sendline() - time.sleep(0.1) - egg.expect('Username:', timeout=3) - time.sleep(0.1) - egg.sendline(args.user) - time.sleep(0.1) - egg.expect('Password:') - egg.sendline(args.passwd) - egg.expect(ap_prompt) - egg.sendline("en") - egg.expect("Password:") - egg.sendline(args.passwd) - egg.expect("#") - egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - egg.expect("--More--") - egg.sendcontrol('c') - egg.expect("#",timeout=5) - egg.sendline("exit") - egg.expect(">",timeout=5) - egg.sendline("exit") + if (args.action == "powercfg"): + egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect_exact(AP_MORE,timeout=5) + egg.sendcontrol('c') + else: # no other command at this time so send the same power command + egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect_exact(AP_MORE,timeout=5) + egg.sendcontrol('c') + + egg.expect_exact(AP_HASH,timeout=5) + egg.sendline(AP_EXIT) + egg.expect_exact(AP_PROMPT,timeout=5) + egg.sendline(AP_EXIT) # ctlr.execute(cn_cmd) if __name__ == '__main__': main() diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1a0dfdfe..543248e5 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1599,7 +1599,7 @@ def main(): logg.info("####################################################################################################") logg.info("####################################################################################################") - logg.info("# Unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) logg.info("####################################################################################################") #exit_test(workbook) exit(1) @@ -1626,9 +1626,6 @@ def main(): else: logg.info("AP Check regular expression!!!") exit(1) - - - # # The controller may adjust the number of spatial streams to allow for the # best power values From f3ccc4958092ed7e34a75c3779be711a3c40d437 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 10:14:45 -0700 Subject: [PATCH 086/848] lf_cisco_power.py: LCS-45 Read AP for Power values Print out values read from AP --- lf_cisco_power.py | 59 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 543248e5..93f5434d 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -83,7 +83,7 @@ NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme ./lf_associate_ap.pl --radio wiphy1 --ssid open-wlan --passphrase [BLANK] ssecurity open --upstream eth1 \ --first_ip DHCP --first_sta sta0001 --duration 5 --cxtype udp -Changing regulatory domain should happen outside of this script. See cisco_ap_ctl.py +Changing regulatory domain should happen outside of this script. ############################################################################################## # If wish to send Text after test completion follow the email format based on carrier @@ -757,9 +757,10 @@ def main(): "--cli_cmd", set_cmd], capture_output=True) # tx power 1 is the highest power , 2 power is 1/2 of 1 power etc till power 8 the lowest. for tx in txpowers: - # e_tot is the errors, w_tot is the warning + # e_tot is the errors, w_tot is the warning, i_tot is information e_tot = "" w_tot = "" + i_tot = "" # Stop traffic , if traffic was running , this is on the lanforge side. Commands that start with lf_ are directed # towards the lanforge @@ -1593,39 +1594,40 @@ def main(): "-user", ap_dict['ap_user'], "-passwd", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=True, check=True) pss = ap_info.stdout.decode('utf-8', 'ignore'); logg.info(pss) + for line in pss.splitlines(): + logg.info("ap {}".format(line)) + m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') + if (m != None): + P1 = m.group(1) + T1 = m.group(2) + P2 = m.group(3) + T2 = m.group(4) + P3 = m.group(5) + T3 = m.group(6) + P4 = m.group(7) + T4 = m.group(8) + N_ANT = m.group(9) + DAA_Pwr = m.group(10) + DAA_N_TX = m.group(11) + DAA_Total_pwr = m.group(12) + i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( + P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr) + print(i_tot) + logg.info(i_tot) + else: + logg.info("AP Check regular expression!!!") + except subprocess.CalledProcessError as process_error: logg.info("####################################################################################################") logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") logg.info("####################################################################################################") logg.info("####################################################################################################") - logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) logg.info("####################################################################################################") - #exit_test(workbook) - exit(1) + # for now this is not a fatal error, - for line in pss.splitlines(): - logg.info("ap {}".format(line)) - m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') - if (m != None): - P1 = m.group(1) - T1 = m.group(2) - P2 = m.group(3) - T2 = m.group(4) - P3 = m.group(5) - T3 = m.group(6) - P4 = m.group(7) - T4 = m.group(8) - N_ANT = m.group(9) - DAA_Pwr = m.group(10) - DAA_N_TX = m.group(11) - DAA_Total_pwr = m.group(12) - print("P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}" - .format(P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr)) - else: - logg.info("AP Check regular expression!!!") - exit(1) # # The controller may adjust the number of spatial streams to allow for the # best power values @@ -1738,14 +1740,13 @@ def main(): e_tot += err if (e_tot == ""): - e_w_tot = e_tot + w_tot + e_w_tot = e_tot + w_tot + i_tot if(w_tot == ""): worksheet.write(row, col, e_w_tot, green_left); col += 1 else: worksheet.write(row, col, e_w_tot, orange_left); col += 1 - else: - e_w_tot = e_tot + w_tot + e_w_tot = e_tot + w_tot + i_tot worksheet.write(row, col, e_w_tot, red_left); col += 1 row += 1 From 390f49792236adb306e428925e06bf24dc28d0e1 Mon Sep 17 00:00:00 2001 From: Chuck Date: Fri, 22 Jan 2021 11:45:32 -0700 Subject: [PATCH 087/848] cisco_ap_ctl.py: LCS-45 Read AP for Power values change properties of cisco-ap_ctl.py --- cisco_ap_ctl.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cisco_ap_ctl.py diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py old mode 100644 new mode 100755 From bdd6dbe99cc5e56e4ff974a889809faee5b91b1f Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 10:50:09 -0800 Subject: [PATCH 088/848] flexible lfclient_port and correct l3 field names --- py-json/realm.py | 27 +++++++++++++-------------- py-scripts/test_ipv4_variable_time.py | 7 ++++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 407836a2..c27c4632 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1091,6 +1091,7 @@ class L3CXProfile(BaseProfile): self.created_endp = {} self.name_prefix = name_prefix_ self.number_template = number_template_ + self.lfclient_port = lfclient_port def get_cx_names(self): return self.created_cx.keys() @@ -1163,12 +1164,11 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] # Step 1, column names . what is this for? - fields=None + fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) else: header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) - print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) @@ -1181,7 +1181,7 @@ class L3CXProfile(BaseProfile): timestamps = [] # for x in range(0,int(round(iterations,0))): while datetime.datetime.now() < end_time: - if fields == None: + if fields is None: response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) @@ -1224,7 +1224,6 @@ class L3CXProfile(BaseProfile): for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) # step 4 save and close - header_row = col_names header_row.insert(0, 'Timestamp') print(header_row) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': @@ -1244,9 +1243,9 @@ class L3CXProfile(BaseProfile): import requests import ast try: - systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) except: - systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments @@ -1706,20 +1705,20 @@ class L4CXProfile(LFCliBase): else: output_format = report_file.split('.')[-1] - # Step 1, column names - - fields=None + # Step 1, column names + + fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) if self.debug: print(fields) else: - #todo:rename this... + #todo:rename this... header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) if self.debug: print(header_row) - - # Step 2, monitor columns, + + # Step 2, monitor columns, start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) @@ -1731,7 +1730,7 @@ class L4CXProfile(LFCliBase): for test in range(1+iterations): #while current loop hasn't ended while datetime.datetime.now() < end_time: - #what does response ? get? + #what does response ? get? response=self.json_get("layer4/all") #response = self.json_get("layer4/list?fields=urls/s") if "endpoint" not in response: @@ -1828,7 +1827,7 @@ class L4CXProfile(LFCliBase): exec('df.to_' + x + '("' + report_file + '")') else: pass -#end of L4CXProf class +#end of L4CXProf class class GenCXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index ffd5767e..ebd10e05 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -200,8 +200,9 @@ python3 ./test_ipv4_variable_time.py num_sta = int(args.num_stations) #Create directory - homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' - os.mkdir('/home/lanforge/report_data/'+homedir) + homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' + path = os.path.join('/home/lanforge/report-data/',homedir) + os.mkdir(path) if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: @@ -265,7 +266,7 @@ python3 ./test_ipv4_variable_time.py if ip_var_test.passes(): ip_var_test.exit_success() - IPV4VariableTime.cx_profile.stop_cx() #is this needed? + IPV4VariableTime.cx_profile.stop_cx() #is this needed? if __name__ == "__main__": main() From 0efcf1f16210d227008c76a910b9415138e399a2 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 11:57:35 -0700 Subject: [PATCH 089/848] lf_cisco_power.py: LCS-45 Read AP for Power values Bug fixes in args parser --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 93f5434d..43715fc9 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -305,7 +305,7 @@ def main(): parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") - parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw==") + parser.add_argument('-api','--ap_info', action='append', nargs=1, type=str, help="--ap_info ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw==") #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] From 6403b96032da73a5a293dd3737d140b1cb632f14 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 11:02:51 -0800 Subject: [PATCH 090/848] Correctly get names for columns when they are user defined --- py-json/realm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py-json/realm.py b/py-json/realm.py index c27c4632..294acd48 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1167,6 +1167,7 @@ class L3CXProfile(BaseProfile): fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) + header_row=col_names else: header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) # Step 2, monitor columns From 452504cf646cc6e3b69252ea5b7f03ecb17d0c83 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 11:04:51 -0800 Subject: [PATCH 091/848] working columns names for variable_time --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index ebd10e05..84fa9842 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -249,7 +249,7 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs','Rx Drop % A', 'Rx Drop % B', 'Bps Rx A', 'Bps Rx B', 'Rx Rate', 'Cx Estab'], + ip_var_test.l3cxprofile.monitor(col_names=['Name','Rx Rate','Rx PDUs'], report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, From 5d18d9c0cdcd37b21bcf6eb5c244e256f95fe7af Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 12:19:48 -0700 Subject: [PATCH 092/848] lf_cisco_power.py: LCS-45 Read AP for Power values ap command fixes --- lf_cisco_power.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 43715fc9..f0dc1ee1 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1586,12 +1586,14 @@ def main(): DAA_N_TX = None DAA_Total_pwr = None if(bool(ap_dict)): + logg.info("ap_dict {}".format(ap_dict)) logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], ap_dict['ap_user'],ap_dict['ap_pw'])) try: - logg.info("cisco_ap_ctl.py: no_logging_console") + logg.info("cisco_ap_ctl.py: read AP power information") + logg.info() ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=True, check=True) pss = ap_info.stdout.decode('utf-8', 'ignore'); logg.info(pss) for line in pss.splitlines(): From c976120173b69e469e2282c0860808d4d5b3dc16 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 12:35:29 -0700 Subject: [PATCH 093/848] lf_cisco_power.py: LCS-45 Read AP for Power values logg cleanup --- lf_cisco_power.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index f0dc1ee1..f58d051b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1591,7 +1591,6 @@ def main(): ap_dict['ap_user'],ap_dict['ap_pw'])) try: logg.info("cisco_ap_ctl.py: read AP power information") - logg.info() ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) pss = ap_info.stdout.decode('utf-8', 'ignore'); From 74f06b5da993d91862f6c9a27095421169f5448d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 12:49:03 -0700 Subject: [PATCH 094/848] lf_cisco_power.py: LCS-45 Read AP for Power values exit on an exception accessing the AP --- lf_cisco_power.py | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index f58d051b..1c014628 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1594,29 +1594,6 @@ def main(): ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) pss = ap_info.stdout.decode('utf-8', 'ignore'); - logg.info(pss) - for line in pss.splitlines(): - logg.info("ap {}".format(line)) - m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') - if (m != None): - P1 = m.group(1) - T1 = m.group(2) - P2 = m.group(3) - T2 = m.group(4) - P3 = m.group(5) - T3 = m.group(6) - P4 = m.group(7) - T4 = m.group(8) - N_ANT = m.group(9) - DAA_Pwr = m.group(10) - DAA_N_TX = m.group(11) - DAA_Total_pwr = m.group(12) - i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( - P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr) - print(i_tot) - logg.info(i_tot) - else: - logg.info("AP Check regular expression!!!") except subprocess.CalledProcessError as process_error: logg.info("####################################################################################################") @@ -1626,8 +1603,32 @@ def main(): logg.info("####################################################################################################") logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) logg.info("####################################################################################################") - # for now this is not a fatal error, - + exit_test(workbook) + + logg.info(pss) + for line in pss.splitlines(): + logg.info("ap {}".format(line)) + m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') + if (m != None): + P1 = m.group(1) + T1 = m.group(2) + P2 = m.group(3) + T2 = m.group(4) + P3 = m.group(5) + T3 = m.group(6) + P4 = m.group(7) + T4 = m.group(8) + N_ANT = m.group(9) + DAA_Pwr = m.group(10) + DAA_N_TX = m.group(11) + DAA_Total_pwr = m.group(12) + i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( + P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr) + print(i_tot) + logg.info(i_tot) + else: + logg.info("AP Check regular expression!!!") + # # The controller may adjust the number of spatial streams to allow for the From 2931522e37b18e10c5a8be6d86799e1ea92c6bc4 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 11:53:24 -0800 Subject: [PATCH 095/848] user defined columsn in test_ipv4_variable_time --- py-json/realm.py | 4 ++-- py-scripts/test_ipv4_variable_time.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 294acd48..6d932898 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1154,8 +1154,8 @@ class L3CXProfile(BaseProfile): raise ValueError("Monitor needs a list of Layer 3 connections") if (monitor_interval is None) or (monitor_interval < 1): raise ValueError("L3CXProfile::monitor wants monitor_interval >= 1 second") - if col_names is None: - raise ValueError("L3CXProfile::monitor wants a list of column names to monitor") + #if col_names is None: + #raise ValueError("L3CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: if output_format.lower() != 'excel': diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 84fa9842..c18a2360 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -193,6 +193,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") + optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Name','Rx Rate','Rx PDUs']) args = parser.parse_args() num_sta = 2 @@ -249,7 +250,12 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - ip_var_test.l3cxprofile.monitor(col_names=['Name','Rx Rate','Rx PDUs'], + if type(args.col_names) is not list: + col_names=None + else: + col_names = args.col_names + print(col_names) + ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, From 037d9f2333af6bef3a5ccd07a489c95873f9b34f Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 13:18:56 -0700 Subject: [PATCH 096/848] lf_cisco_power.py: LCS-45 Read AP for Power values debug code --- lf_cisco_power.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1c014628..1e4c4a55 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1589,21 +1589,21 @@ def main(): logg.info("ap_dict {}".format(ap_dict)) logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], ap_dict['ap_user'],ap_dict['ap_pw'])) - try: - logg.info("cisco_ap_ctl.py: read AP power information") - ap_info= subprocess.run(["./cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'],"--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], + #try: + logg.info("cisco_ap_ctl.py: read AP power information") + ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) - pss = ap_info.stdout.decode('utf-8', 'ignore'); + pss = ap_info.stdout.decode('utf-8', 'ignore') - except subprocess.CalledProcessError as process_error: - logg.info("####################################################################################################") - logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") - logg.info("####################################################################################################") + #except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") - logg.info("####################################################################################################") - logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) - logg.info("####################################################################################################") - exit_test(workbook) + logg.info("####################################################################################################") + #logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + #exit_test(workbook) logg.info(pss) for line in pss.splitlines(): From ff70c3a71c0975c752e2f51bb9ac400c51c7d121 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 13:52:59 -0700 Subject: [PATCH 097/848] cisco_ap_ctl.py: LCS-45 Read AP for Power values fixes on subprocess caught timeouts --- cisco_ap_ctl.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index 654e7150..e57736eb 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -198,19 +198,36 @@ def main(): sleep(0.2) if (args.action == "powercfg"): + logg.info("execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - egg.expect_exact(AP_MORE,timeout=5) - egg.sendcontrol('c') + i = egg.expect_exact(AP_MORE,timeout=2) + if i == 0: + egg.sendcontrol('c') + else: + logg.info("send cntl c anyway") + egg.sendcontrol('c') else: # no other command at this time so send the same power command + logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - egg.expect_exact(AP_MORE,timeout=5) - egg.sendcontrol('c') + i = egg.expect_exact(AP_MORE,timeout=2) + if i == 0: + egg.sendcontrol('c') + else: + logg.info("send cntl c anyway, received timeout") + egg.sendcontrol('c') - egg.expect_exact(AP_HASH,timeout=5) - egg.sendline(AP_EXIT) - egg.expect_exact(AP_PROMPT,timeout=5) - egg.sendline(AP_EXIT) + i = egg.expect_exact(AP_PROMPT,AP_HASH,timeout=1) + if i == 0: + logg.info("received {} we are done send exit".format(AP_PROMPT)) + egg.sendline(AP_EXIT) + + elif i == 1: + logg.info("received {} send exit".format(AP_HASH)) + egg.sendline(AP_EXIT) + else: + logg.info("timed out waiting for {} or {}".format(AP_PROMPT,AP_HASH)) + # ctlr.execute(cn_cmd) if __name__ == '__main__': main() From e4603ac1254f85538a9489de88b1cc20fd749ef0 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 13:54:37 -0700 Subject: [PATCH 098/848] lf_cisco_power.py: LCS-45 Read AP for Power values allowed for debug to be printed --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1e4c4a55..0528da84 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1592,7 +1592,7 @@ def main(): #try: logg.info("cisco_ap_ctl.py: read AP power information") ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=False, check=True) pss = ap_info.stdout.decode('utf-8', 'ignore') #except subprocess.CalledProcessError as process_error: From 1f7adbe72ebd7b8e6b957123e7191fe82905b222 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 14:02:51 -0700 Subject: [PATCH 099/848] cisco_ap_ctl.py: LCS-45 Read AP for Power values fixed expecte with AP_MORE --- cisco_ap_ctl.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index e57736eb..a4f8c858 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -171,7 +171,7 @@ def main(): loop_count = 0 while (loop_count <= 8 and logged_in == False): loop_count += 1 - i = egg.expect_exact([AP_ESCAPE,AP_PROMPT,AP_HASH,AP_USERNAME,AP_PASSWORD,pexpect.TIMEOUT],timeout=5) + i = egg.expect_exact([AP_ESCAPE,AP_PROMPT,AP_HASH,AP_USERNAME,AP_PASSWORD,AP_MORE,pexpect.TIMEOUT],timeout=5) if i == 0: logg.info("Expect: {} i: {} before: {} after: {}".format(AP_ESCAPE,i,egg.before,egg.after)) egg.sendline(CR) # Needed after Escape or should just do timeout and then a CR? @@ -193,17 +193,22 @@ def main(): egg.sendline(args.passwd) sleep(0.2) if i == 5: + logg.info("Expect: {} i: {} before: {} after: {}".format(AP_MORE,i,egg.before,egg.after)) + egg.sendcontrol('c') + sleep(0.2) + if i == 6: logg.info("Expect: {} i: {} before: {} after: {}".format("Timeout",i,egg.before,egg.after)) egg.sendline(CR) sleep(0.2) + if (args.action == "powercfg"): logg.info("execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') i = egg.expect_exact(AP_MORE,timeout=2) if i == 0: egg.sendcontrol('c') - else: + if i == 1: logg.info("send cntl c anyway") egg.sendcontrol('c') @@ -213,7 +218,7 @@ def main(): i = egg.expect_exact(AP_MORE,timeout=2) if i == 0: egg.sendcontrol('c') - else: + if i == 1: logg.info("send cntl c anyway, received timeout") egg.sendcontrol('c') @@ -222,10 +227,10 @@ def main(): logg.info("received {} we are done send exit".format(AP_PROMPT)) egg.sendline(AP_EXIT) - elif i == 1: + if i == 1: logg.info("received {} send exit".format(AP_HASH)) egg.sendline(AP_EXIT) - else: + if i == 2: logg.info("timed out waiting for {} or {}".format(AP_PROMPT,AP_HASH)) # ctlr.execute(cn_cmd) From 88e3acb9e483ea24f6970dedbb63ce2e5e0bae42 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 14:18:47 -0700 Subject: [PATCH 100/848] cisco_ap_ctl.py: LCS-45 Read AP for Power values Time out tweaks --- cisco_ap_ctl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index a4f8c858..e0a10bd2 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -205,7 +205,7 @@ def main(): if (args.action == "powercfg"): logg.info("execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - i = egg.expect_exact(AP_MORE,timeout=2) + i = egg.expect_exact(AP_MORE,timeout=5) if i == 0: egg.sendcontrol('c') if i == 1: @@ -215,7 +215,7 @@ def main(): else: # no other command at this time so send the same power command logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - i = egg.expect_exact(AP_MORE,timeout=2) + i = egg.expect_exact(AP_MORE,timeout=5) if i == 0: egg.sendcontrol('c') if i == 1: From 4cb07fae3d340ffdf92a45c5c389eb86b0638d55 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 14:24:33 -0700 Subject: [PATCH 101/848] cisco_ap_ctl.py: LCS-45 Read AP for Power values bug fix --- cisco_ap_ctl.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index e0a10bd2..d0462b35 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -205,7 +205,7 @@ def main(): if (args.action == "powercfg"): logg.info("execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - i = egg.expect_exact(AP_MORE,timeout=5) + i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5) if i == 0: egg.sendcontrol('c') if i == 1: @@ -215,18 +215,17 @@ def main(): else: # no other command at this time so send the same power command logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') - i = egg.expect_exact(AP_MORE,timeout=5) + i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5) if i == 0: egg.sendcontrol('c') if i == 1: logg.info("send cntl c anyway, received timeout") egg.sendcontrol('c') - i = egg.expect_exact(AP_PROMPT,AP_HASH,timeout=1) + i = egg.expect_exact([AP_PROMPT,AP_HASH,pexpect.TIMEOUT],timeout=1) if i == 0: logg.info("received {} we are done send exit".format(AP_PROMPT)) egg.sendline(AP_EXIT) - if i == 1: logg.info("received {} send exit".format(AP_HASH)) egg.sendline(AP_EXIT) From 81e706abb31bd7b8db8be3c2300053e399bbcdba Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 14:33:32 -0700 Subject: [PATCH 102/848] lf_cisco_power.py : LCS-45 Read AP for Power values , process AP results --- lf_cisco_power.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 0528da84..cc526fbe 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1589,21 +1589,25 @@ def main(): logg.info("ap_dict {}".format(ap_dict)) logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], ap_dict['ap_user'],ap_dict['ap_pw'])) - #try: - logg.info("cisco_ap_ctl.py: read AP power information") - ap_info= subprocess.run(["./cisco_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"],capture_output=False, check=True) - pss = ap_info.stdout.decode('utf-8', 'ignore') + try: + logg.info("cisco_ap_ctl.py: read AP power information") + ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) + if ap_info == None: + pss = "empty" + else: + pss = ap_info.stdout.decode('utf-8', 'ignore') - #except subprocess.CalledProcessError as process_error: - logg.info("####################################################################################################") - logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") - logg.info("####################################################################################################") + except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") - logg.info("####################################################################################################") - #logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) - logg.info("####################################################################################################") - #exit_test(workbook) + logg.info("####################################################################################################") + logg.info("# Unable to commicate to AP error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + #exit_test(workbook) + pss = "empty_process_error" logg.info(pss) for line in pss.splitlines(): From d1ca2ae06a506bfab382dff6a83d55679808c3aa Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 14:54:17 -0700 Subject: [PATCH 103/848] lf_cisco_power.py : LCS-45 Read AP for Power values , wlan configurable --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index cc526fbe..aa26199d 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1870,7 +1870,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","--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "no_wlan_wireless_tag_policy","--series",args.series,"--wlan", args.wlan,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) From 455c74a5ee291ed3098134a8f016c50a4fdea9e8 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 15:07:00 -0700 Subject: [PATCH 104/848] lf_cisco_power.py : LCS-45 Read AP for Power values , logging update --- lf_cisco_power.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index aa26199d..ae5491ed 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1589,6 +1589,10 @@ def main(): logg.info("ap_dict {}".format(ap_dict)) logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], ap_dict['ap_user'],ap_dict['ap_pw'])) + logg.info("####################################################################################################") + logg.info("# READ AP POWERCFG") + logg.info("####################################################################################################") + try: logg.info("cisco_ap_ctl.py: read AP power information") ap_info= subprocess.run(["./cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'],"--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], From 577eb85098da197415dcb442c4d249cc2c19ccdc Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:13:53 -0800 Subject: [PATCH 105/848] html test output works --- py-scripts/html_test_output.sh | 43 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) mode change 100644 => 100755 py-scripts/html_test_output.sh diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh old mode 100644 new mode 100755 index 9708b50b..2d2a1b9f --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -19,20 +19,20 @@ testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid j "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3" - "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --upstream_port eth1" - "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" - "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" - "./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" - "./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m" - "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug" - "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format excel" - "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format csv" + "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./test_generic.py --mgr localhost --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" + "./test_generic.py --mgr localhost --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" + "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" + "./test_ipv4_l4_wifi.py --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" + "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" - "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./create_macvlan.py --radio wiphy1" - "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_macvlan.py --radio wiphy1" + #"./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" ) declare -A name_to_num name_to_num=( @@ -73,14 +73,14 @@ function run_test() { if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then echo_print echo "$i" - [[ x$DEBUG != x ]] && sleep 2 - results+=("${CURR_TEST_NAME}success") - eval "$i" >>~/test_all_output_file_success.txt || true - [[ x$DEBUG != x ]] && exit 1 - results+=("${CURR_TEST_NAME}failure") - eval "$i" >>~/test_all_output_file_failure.txt - [[ x$DEBUG != x ]] + if $i; then + results+=("${CURR_TEST_NAME}Success") + else + results+=("${CURR_TEST_NAME}Failure") + fi + fi done + echo $results } function check_args() { if [ ! -z $1 ]; then @@ -112,7 +112,8 @@ function html_generator() { " fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" - echo $header"${results[@]}"$tail > ${fname} + echo $fname + echo $header"${results[@]}"$tail >> $fname } #true >~/test_all_output_file.txt check_args $1 $2 From 61d553145db26913244d1fd5cfef6b1a37059f11 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 15:27:20 -0700 Subject: [PATCH 106/848] lf_cisco_power.py : LCS-45 Read AP for Power values , avoid decode of NoneType --- lf_cisco_power.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index ae5491ed..7c371c19 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1596,11 +1596,12 @@ def main(): try: logg.info("cisco_ap_ctl.py: read AP power information") ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) - if ap_info == None: - pss = "empty" - else: + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=True, check=True) + try: pss = ap_info.stdout.decode('utf-8', 'ignore') + except: + logg.info("ap_info was of type NoneType will set pss empty") + pss = "empty" except subprocess.CalledProcessError as process_error: logg.info("####################################################################################################") From 58a3401a7f946b9f4609910e520055ffe613e844 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 15:32:58 -0700 Subject: [PATCH 107/848] cisco_ap_ctl.py : LCS-45 Read AP for Power values , default logs to stdout --- cisco_ap_ctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index d0462b35..d597d6ed 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -85,7 +85,7 @@ def main(): 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("-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") + 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") args = None From 6686bd09f9cc1dbcd41fc1c306e7a217f8e9628a Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:33:07 -0800 Subject: [PATCH 108/848] args.report_file is none --- py-scripts/test_ipv4_variable_time.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index c18a2360..75e71a69 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -188,8 +188,8 @@ python3 ./test_ipv4_variable_time.py if optional_args is not None: optional_args.add_argument('--mode',help='Used to force mode of stations') optional_args.add_argument('--ap',help='Used to force a connection to a particular AP') - optional_args.add_argument('--report_file',help='where you want to store results') optional_args.add_argument('--output_format', help='choose either csv or xlsx') + optional_args.add_argument('--report_file',help='where you want to store results', default=None) optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") @@ -201,9 +201,12 @@ python3 ./test_ipv4_variable_time.py num_sta = int(args.num_stations) #Create directory - homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' - path = os.path.join('/home/lanforge/report-data/',homedir) - os.mkdir(path) + if args.report_file is None: + homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' + path = os.path.join('/home/lanforge/report-data/',homedir) + os.mkdir(path) + else: + pass if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: From c0bb4bf9c37f4918b1ab6b0fd47def2ddb2f298c Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:37:52 -0800 Subject: [PATCH 109/848] small fixes for lfclient host --- py-json/realm.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6d932898..64f9a591 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1092,6 +1092,7 @@ class L3CXProfile(BaseProfile): self.name_prefix = name_prefix_ self.number_template = number_template_ self.lfclient_port = lfclient_port + self.lfclient_host = lfclient_host def get_cx_names(self): return self.created_cx.keys() @@ -1244,9 +1245,9 @@ class L3CXProfile(BaseProfile): import requests import ast try: - systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) except: - systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments @@ -1945,7 +1946,7 @@ class GenCXProfile(LFCliBase): for endp_tpl in endp_tpls: gen_name_a = endp_tpl[2] gen_name_b = endp_tpl[3] - genl.set_flags(gen_name_a, "ClearPortOnStart", 1) + genl.set_ (gen_name_a, "ClearPortOnStart", 1) # genl.set_flags(gen_name_b, "ClearPortOnStart", 1) # genl.set_flags(gen_name_b, "Unmanaged", 1) time.sleep(sleep_time) From bcc21fecbcd03d56de6fa43f9c0a9a135ac78cd7 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 15:55:35 -0700 Subject: [PATCH 110/848] lf_cisco_power.py: : LCS-45 Read AP for Power values try to capture AP output --- lf_cisco_power.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 7c371c19..1a3c3f05 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -345,7 +345,7 @@ def main(): if (args.pf_a4_dropoff != None): pf_a4_dropoff = args.pf_p4_dropoff if (args.verbose): - # capture the controller output , thus won't got to stdout some output always present + # capture the controller output , thus won't go to stdout some output always present cap_ctl_out = False else: cap_ctl_out = True @@ -1596,7 +1596,7 @@ def main(): try: logg.info("cisco_ap_ctl.py: read AP power information") ap_info= subprocess.run(["./cisco_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"],capture_output=True, check=True) + "--user", ap_dict['ap_user'], "--passwd", ap_dict['ap_pw'],"--action", "powercfg"],stdout=subprocess.PIPE) try: pss = ap_info.stdout.decode('utf-8', 'ignore') except: From 8af7255094337c5861f419c06487cd2a16b167c2 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:56:06 -0800 Subject: [PATCH 111/848] dumping pdf for now, simple html output --- py-json/realm.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 64f9a591..e05ce082 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1174,7 +1174,6 @@ class L3CXProfile(BaseProfile): # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) - print(end_time) value_map = dict() passes = 0 @@ -1210,7 +1209,6 @@ class L3CXProfile(BaseProfile): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - print(value_map) #step 3 organize data endpoints=list() @@ -1253,16 +1251,6 @@ class L3CXProfile(BaseProfile): df['Arguments'] = arguments for x in ['LFGUI Release', 'Script Name', 'Arguments']: df[x][1:] = '' - if output_format == 'pdf': - import matplotlib.pyplot as plt - from matplotlib.backends.backend_pdf import PdfPages - fig, ax = plt.subplots(figsize=(12, 4)) - ax.axis('tight') - ax.axis('off') - the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') - pp = PdfPages(report_file) - pp.savefig(fig, bbox_inches='tight') - pp.close() if output_format == 'hdf': df.to_hdf(report_file, 'table', append=True) if output_format == 'parquet': @@ -1270,11 +1258,9 @@ class L3CXProfile(BaseProfile): if output_format == 'png': fig = df.plot().get_figure() fig.savefig(report_file) - if output_format == 'html': - print('Shivams function') if output_format == 'df': return df - supported_formats = ['csv', 'json', 'stata', 'pickle'] + supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: exec('df.to_' + x + '("' + report_file + '")') @@ -1802,16 +1788,6 @@ class L4CXProfile(LFCliBase): df['Arguments'] = arguments for x in ['LFGUI Release', 'Script Name', 'Arguments']: df[x][1:] = '' - if output_format == 'pdf': - import matplotlib.pyplot as plt - from matplotlib.backends.backend_pdf import PdfPages - fig, ax = plt.subplots(figsize=(12, 4)) - ax.axis('tight') - ax.axis('off') - the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') - pp = PdfPages(report_file) - pp.savefig(fig, bbox_inches='tight') - pp.close() if output_format == 'hdf': df.to_hdf(report_file, 'table', append=True) if output_format == 'parquet': From 745b8972306d5331a6b6ee64371f35e6964dd52e Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 13:30:47 -0800 Subject: [PATCH 112/848] contuination of monitor in l4cxprof & addition of monitor urls_per_ten --- py-json/realm.py | 9 ++++----- py-scripts/test_ipv4_l4_urls_per_ten.py | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index e05ce082..3426276f 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1685,8 +1685,6 @@ class L4CXProfile(LFCliBase): raise ValueError("Monitor needs a list of Layer 4 connections") if (monitor_interval is None) or (monitor_interval < 1): raise ValueError("L4CXProfile::monitor wants monitor_interval >= 1 second") - if col_names is None: - raise ValueError("L4CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) @@ -1698,6 +1696,7 @@ class L4CXProfile(LFCliBase): fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) + header_row=col_names if self.debug: print(fields) else: @@ -1710,17 +1709,17 @@ class L4CXProfile(LFCliBase): start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) - sleep_interval = duration_sec // 5 + sleep_interval = round(duration_sec // 5) value_map = dict() passes = 0 expected_passes = 0 timestamps = [] for test in range(1+iterations): - #while current loop hasn't ended while datetime.datetime.now() < end_time: - #what does response ? get? response=self.json_get("layer4/all") #response = self.json_get("layer4/list?fields=urls/s") + if self.debug: + print(response) if "endpoint" not in response: print(response) raise ValueError("Cannot find any endpoints") diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index ac03c228..f0dccc52 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -221,8 +221,13 @@ python3 ./test_ipv4_l4_urls_per_ten.py layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) except: pass - ip_test.l4cxprofile.monitor(report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), - created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', arguments=args) + ip_test.l4cxprofile.monitor(col_names=['Name','bytes-rd','rx rate (1 min)', 'urls/s'], + report_file=rpt_file, + duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), + created_cx=layer4traffic, + output_format=output_form, + script_name='test_ipv4_l4_urls_per_ten', + arguments=args) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) From 5cbd4288cf47eb835ea9843088909713b2cb17b5 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 14:24:30 -0800 Subject: [PATCH 113/848] additions to ipv4_l4_url monitor --- py-json/realm.py | 22 ++++++++++++++-------- py-scripts/test_ipv4_l4_urls_per_ten.py | 5 ++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 3426276f..5d8cbb9c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1671,7 +1671,8 @@ class L4CXProfile(LFCliBase): output_format=None, script_name=None, arguments=None, - iterations=0): + iterations=0, + debug=False): try: duration_sec = self.parse_time(duration_sec).seconds except: @@ -1697,12 +1698,12 @@ class L4CXProfile(LFCliBase): if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) header_row=col_names - if self.debug: + if debug: print(fields) else: #todo:rename this... header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) - if self.debug: + if debug: print(header_row) # Step 2, monitor columns, @@ -1710,6 +1711,10 @@ class L4CXProfile(LFCliBase): start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) sleep_interval = round(duration_sec // 5) + if debug: + print("Sleep_interval is..." + sleep_interval) + print("Start time is..."+ start_time) + print("End time is..."+ end_time) value_map = dict() passes = 0 expected_passes = 0 @@ -1718,21 +1723,22 @@ class L4CXProfile(LFCliBase): while datetime.datetime.now() < end_time: response=self.json_get("layer4/all") #response = self.json_get("layer4/list?fields=urls/s") - if self.debug: + if debug: print(response) if "endpoint" not in response: print(response) raise ValueError("Cannot find any endpoints") if monitor: - if self.debug: + if debug: print(response) - time.sleep(sleep_interval.total_seconds()) + + time.sleep(sleep_interval) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response expected_passes += 1 - if self.cx_profile.check_errors(self.debug): - if self.__check_request_rate(): + if self.cx_profile.check_errors(debug): + if self.__check_request_rate(): #need to changed passes += 1 else: self._fail("FAIL: Request rate did not exceed 90% target rate") diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index f0dccc52..aec2585a 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -45,6 +45,7 @@ class IPV4L4(LFCliBase): self.url = url self.mode=mode self.ap=ap + self.debug=_debug_on self.requests_per_ten = int(requests_per_ten) self.number_template = number_template self.test_duration=test_duration @@ -209,6 +210,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py url=args.url, mode=args.mode, ap=args.ap, + _debug_on=args.debug, test_duration=args.test_duration, num_tests=args.num_tests, target_requests_per_ten=args.target_per_ten, @@ -227,7 +229,8 @@ python3 ./test_ipv4_l4_urls_per_ten.py created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', - arguments=args) + arguments=args, + debug=args.debug) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) From bc765cff4cd1d3a58887c792158a0ed93b04a259 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 14:35:04 -0800 Subject: [PATCH 114/848] no major changes, committed to pull --rebase --- py-scripts/test_ipv4_l4_urls_per_ten.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index aec2585a..7a2bc7ad 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -183,7 +183,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','png','df','xlsx']: output_form=args.output_format.lower() print("Defaulting file output placement to /home/lanforge.") - rpt_file='/home/lanforge/data.' + output_form + rpt_file='/home/data.' + output_form else: print("Defaulting data file output type to Excel") rpt_file='/home/lanforge/data.xlsx' From dfb66ac2fa4422393d916053d6afb13bce2a8426 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 14:57:03 -0800 Subject: [PATCH 115/848] changes to html format in realm.py --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 5d8cbb9c..10babfe5 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1801,7 +1801,7 @@ class L4CXProfile(LFCliBase): fig = df.plot().get_figure() fig.savefig(report_file) if output_format == 'html': - print('Shivams function') + df.to_html(report_file) if output_format == 'df': return df supported_formats = ['csv', 'json', 'stata', 'pickle'] From f813db7509196ee839406736d32bedcf8af8b655 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 17:39:22 -0700 Subject: [PATCH 116/848] cisco_ap_ctl.py cisco_wifi_ctl.py : LCS-45 Read AP for Power remember to send info to stdout (have to do a print ) --- cisco_ap_ctl.py | 5 +++++ cisco_wifi_ctl.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py index d597d6ed..16205319 100755 --- a/cisco_ap_ctl.py +++ b/cisco_ap_ctl.py @@ -205,6 +205,8 @@ def main(): if (args.action == "powercfg"): logg.info("execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect([pexpect.TIMEOUT], timeout=3) # do not delete this allows for subprocess to see output + print(egg.before.decode('utf-8', 'ignore')) # do not delete this allows for subprocess to see output i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5) if i == 0: egg.sendcontrol('c') @@ -215,6 +217,9 @@ def main(): else: # no other command at this time so send the same power command logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1") egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect([pexpect.TIMEOUT], timeout=3) # do not delete this allows for subprocess to see output + print(egg.before.decode('utf-8', 'ignore')) # do not delete this allows for subprocess to see output + i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5) if i == 0: egg.sendcontrol('c') diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 25393d6a..293e0182 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -559,15 +559,15 @@ def main(): egg.sendline(CR) sleep(0.4) try: - i = egg.expect_exact(["Escape character is '^]'.",CCP,CCP_EN,"User:","Password:",CCP_CONFIG,"Bad secrets", PRESS_RETURN, CONFIG_I,pexpect.TIMEOUT],timeout=2) + i = egg.expect_exact(["Escape character is '^]'.",CCP,CCP_EN,"Username:","Password:",CCP_CONFIG,"Bad secrets", PRESS_RETURN, CONFIG_I,pexpect.TIMEOUT],timeout=2) except Exception as e: - logg.info('connection failed. or refused Connection open by other process') + logg.info('AP connection failed. or refused Connection open by other process') logg.exception(e) exit(1) if i == 0: logg.info("9800 found Escape character is '^] i:{} before: {} after: {}".format(i,egg.before,egg.after)) - egg.sendline(CR) # 1/18/2021 - may need a bit more logic + egg.sendline(CR) found_escape = True sleep(0.2) j = egg.expect_exact([CCP,CCP_EN,"User:","Password:",CCP_CONFIG,pexpect.TIMEOUT],timeout=3) @@ -1340,7 +1340,7 @@ def main(): while logged_out_9800 == False and loop_count <= 6: loop_count += 1 i = egg.expect_exact([CCP,CCP_EN, CCP_CONFIG,CCP_CONFIG_WLAN,CCP_POLICY_TAG,CCP_CONFIG_LINE,pexpect.TIMEOUT],timeout=5) - print (egg.before.decode('utf-8', 'ignore')) + print (egg.before.decode('utf-8', 'ignore')) # allows program that calls from subprocess to see output from command if i == 0: logg.info("{} prompt received can send logout, loop_count: {}".format(CCP,loop_count)) egg.sendline("logout") From 608cc9026ae0cd409eb898c921b7ad87e25a5df5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 17:48:25 -0700 Subject: [PATCH 117/848] lf_cisco_power.py : LCS-45 Read AP for Power fixed re.search(pat,line) --- lf_cisco_power.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1a3c3f05..cdd9312e 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1617,7 +1617,8 @@ def main(): logg.info(pss) for line in pss.splitlines(): logg.info("ap {}".format(line)) - m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') + pat = '^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)' + m = re.search(pat, line) if (m != None): P1 = m.group(1) T1 = m.group(2) From eba8f2119e4363ffc01b04fdb61a76712ef34260 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 18:09:05 -0700 Subject: [PATCH 118/848] lf_cisco_power.py : added information heading to Warnings and Errors --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index cdd9312e..b7a29b0b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -593,7 +593,7 @@ def main(): worksheet.set_column(col, col, 24) # Set width worksheet.write(row, col, 'Time Stamp\n', dgreen_bold); col += 1 worksheet.set_column(col, col, 100) # Set width - worksheet.write(row, col, 'Warnings and Errors', dgreen_bold_left); col += 1 + worksheet.write(row, col, 'Information, Warnings, Errors', dgreen_bold_left); col += 1 row += 1 bandwidths = args.bandwidth.split() From be785632e3375ff044437e2e41cd9cd90c497cb8 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 25 Jan 2021 01:57:26 -0800 Subject: [PATCH 119/848] urls_per_ten output works --- py-json/realm.py | 40 +++++++++++++------------ py-scripts/test_ipv4_l4_urls_per_ten.py | 38 +++++++++++++++-------- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 10babfe5..352885d1 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1186,6 +1186,11 @@ class L3CXProfile(BaseProfile): response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) + print("created cx.........") + print(created_cx) + print(fields) + print("response...........................") + print(response) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1594,7 +1599,7 @@ class L4CXProfile(LFCliBase): endp_list = endp_list['endpoint'] for item in endp_list: for name, info in item.items(): - if name in self.cx_profile.created_cx.keys(): + if name in self.created_cx.keys(): expected_passes += 1 if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) @@ -1701,7 +1706,6 @@ class L4CXProfile(LFCliBase): if debug: print(fields) else: - #todo:rename this... header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) if debug: print(header_row) @@ -1712,20 +1716,22 @@ class L4CXProfile(LFCliBase): end_time = start_time + datetime.timedelta(seconds=duration_sec) sleep_interval = round(duration_sec // 5) if debug: - print("Sleep_interval is..." + sleep_interval) - print("Start time is..."+ start_time) - print("End time is..."+ end_time) + print("Sleep_interval is %s ", sleep_interval) + print("Start time is %s " , start_time) + print("End time is %s " ,end_time) value_map = dict() passes = 0 expected_passes = 0 timestamps = [] for test in range(1+iterations): while datetime.datetime.now() < end_time: - response=self.json_get("layer4/all") - #response = self.json_get("layer4/list?fields=urls/s") + if fields is None: + response = self.json_get("/layer4/all") + else: + response = self.json_get("/layer4/%s?fields=%s" % (created_cx, fields)) if debug: print(response) - if "endpoint" not in response: + if response is None: print(response) raise ValueError("Cannot find any endpoints") if monitor: @@ -1737,8 +1743,8 @@ class L4CXProfile(LFCliBase): timestamps.append(t) value_map[t] = response expected_passes += 1 - if self.cx_profile.check_errors(debug): - if self.__check_request_rate(): #need to changed + if self.check_errors(debug): + if self.check_request_rate(): passes += 1 else: self._fail("FAIL: Request rate did not exceed 90% target rate") @@ -1746,10 +1752,9 @@ class L4CXProfile(LFCliBase): else: self._fail("FAIL: Errors found getting to %s " % self.url) self.exit_fail() - #check monitor sleep time time.sleep(monitor_interval) print(value_map) -############################################# edited 'til here - dipti 1/21/20 + # step 3 organize data endpoints = list() for endpoint in value_map.values(): @@ -1764,11 +1769,9 @@ class L4CXProfile(LFCliBase): for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) # step 4 save and close - header_row = col_names header_row.insert(0, 'Timestamp') print(header_row) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': - report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) worksheet = workbook.add_worksheet() for col_num, data in enumerate(header_row): @@ -1781,13 +1784,14 @@ class L4CXProfile(LFCliBase): workbook.close() else: df = pd.DataFrame(endpoints2) + print(header_row) df.columns = header_row import requests import ast try: - systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) except: - systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments @@ -1800,11 +1804,9 @@ class L4CXProfile(LFCliBase): if output_format == 'png': fig = df.plot().get_figure() fig.savefig(report_file) - if output_format == 'html': - df.to_html(report_file) if output_format == 'df': return df - supported_formats = ['csv', 'json', 'stata', 'pickle'] + supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: exec('df.to_' + x + '("' + report_file + '")') diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 7a2bc7ad..250bca3e 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -179,22 +179,34 @@ python3 ./test_ipv4_l4_urls_per_ten.py if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted - if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','png','df','xlsx']: - output_form=args.output_format.lower() - print("Defaulting file output placement to /home/lanforge.") - rpt_file='/home/data.' + output_form - else: - print("Defaulting data file output type to Excel") - rpt_file='/home/lanforge/data.xlsx' - output_form='xlsx' + + #Create directory + if args.report_file is None: + try: + homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_l4_urls_per_ten' + path = os.path.join('/home/lanforge/report-data/',homedir) + os.mkdir(path) + except: + path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + print('Saving file to local directory') + else: + pass + + if args.report_file is None: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: + rpt_file=path+'/data.' + args.output_format + output=args.output_format + else: + print('Defaulting data file output type to Excel') + rpt_file=path+'/data.xlsx' + output='xlsx' else: rpt_file=args.report_file if args.output_format is None: - output_form=str(args.report_file).split('.')[-1] + output=str(args.report_file).split('.')[-1] else: - output_form=args.output_format + output=args.output_format station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, @@ -223,11 +235,11 @@ python3 ./test_ipv4_l4_urls_per_ten.py layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) except: pass - ip_test.l4cxprofile.monitor(col_names=['Name','bytes-rd','rx rate (1 min)', 'urls/s'], + ip_test.l4cxprofile.monitor(col_names=['Name','bytes-rd','urls/s'], report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx=layer4traffic, - output_format=output_form, + output_format=output, script_name='test_ipv4_l4_urls_per_ten', arguments=args, debug=args.debug) From 0f7b1372f9217ac6bd96f9191b7be311e44f3885 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 25 Jan 2021 06:38:34 -0700 Subject: [PATCH 120/848] lf_cisco_power : LCS-45 Read AP for Power , updated help for --ap_info command --- lf_cisco_power.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index b7a29b0b..995db716 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -27,16 +27,29 @@ The user also has the option of setting up the station oustide of this script, h # See cisco_power_results.xlsx when complete. NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme defaults to ssh + +############################################################################################## +# read AP for powercfg values using : show controllers dot11Radio 1 powercfg | g T1' +############################################################################################## + +./lf_cisco_power.py -d 172.19.27.55 -u admin -p Wnbulab@123 --port 2013 --scheme telnet \ + --ap 9120_Candela --bandwidth "20" --channel "149" --nss 4 --txpower "1" \ + --pathloss 56 --band a --upstream_port eth2 --series 9800 --radio wiphy5 --slot 1 --ssid open-wlan \ + --prompt "katar_candela" --create_station sta0001 --ssidpw [BLANK] --security open --verbose \ + --antenna_gain "6" --wlan open-wlan --wlanID 1 \ + --ap_info "ap_scheme==telnet ap_prompt==9120_Candela ap_ip==172.19.27.55 ap_port==2008 ap_user==admin ap_pw==Wnbulab@123" + + ############################################################################################## # send email and or text on --exit_on_fail ############################################################################################## -./lf_cisco_power.py -d 192.168.100.112 -u admin -p Cisco123 -s ssh --port 22 -a APA453.0E7B.CF9C --lfmgr 192.168.100.178 - --bandwidth "80" --channel "144" --nss 4 --txpower "1" --pathloss 51 --antenna_gain 10 --lfmgr 192.168.100.178 --band a - --upstream_port eth3 --outfile cisco_power_results --create_station sta0001 --radio wiphy1 --ssid test_candela --ssidpw [BLANK] --security open - -l out_file2 -D 14 --exit_on_fail - --email "user==lanforgetest@gmail.com passwd==lanforge123 to==2082868321@vtext.com smtp==smtp.gmail.com port==465" - --email "user==lanforgetest@gmail.com passwd==lanforge123 to==lanforgetest@gmail.com smtp==smtp.gmail.com port==465" +./lf_cisco_power.py -d 192.168.100.112 -u admin -p Cisco123 -s ssh --port 22 -a APA453.0E7B.CF9C --lfmgr 192.168.100.178 \ + --bandwidth "80" --channel "144" --nss 4 --txpower "1" --pathloss 51 --antenna_gain 10 --lfmgr 192.168.100.178 --band a \ + --upstream_port eth3 --outfile cisco_power_results --create_station sta0001 --radio wiphy1 --ssid test_candela --ssidpw [BLANK] \ + --security open -l out_file2 -D 14 --exit_on_fail \ + --email "user==lanforgetest@gmail.com passwd==lanforge123 to==2082868321@vtext.com smtp==smtp.gmail.com port==465"\ + --email "user==lanforgetest@gmail.com passwd==lanforge123 to==lanforgetest@gmail.com smtp==smtp.gmail.com port==465"\ --series "3504" --prompt "(Cisco Controler)" ############################################################################################## @@ -221,6 +234,8 @@ def usage(): print('-ccp','--prompt', "--prompt controller prompt default WLC") print('--beacon_dbm_diff', "--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured") print('--show_lf_portmod'," show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") + print('-api','--ap_info', "--ap_info ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw==") + print("-h|--help") From 5ec977ff028ba09913a8a4c0186021d09b89f35d Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 25 Jan 2021 07:24:15 -0700 Subject: [PATCH 121/848] lf_cisco_power.py cisco_wifi_ctl.py : LCS-48 wlan and wlan ssid need separate config --- cisco_wifi_ctl.py | 11 +++++++---- lf_cisco_power.py | 42 ++++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 293e0182..5a65b80a 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -72,6 +72,7 @@ def usage(): print("-b|--band: a (5Ghz) or b (2.4Ghz) or abgn for dual-band 2.4Ghz AP") print("-w|--wlan: WLAN name") print("-i|--wlanID: WLAN ID") + print("-i|--wlanSSID: WLAN SSID") print("-h|--help") @@ -102,6 +103,7 @@ def main(): #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") + parser.add_argument("--wlanSSID", type=str, help="wlan SSID") parser.add_argument("-a", "--ap", type=str, help="select AP", default="APA453.0E7B.CF9C") parser.add_argument("-b", "--band", type=str, help="Select band (a | b | abgn)", choices=["a", "b", "abgn"]) @@ -1196,14 +1198,15 @@ def main(): if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): raise Exception("wlan and wlanID is required an") if (args.action == "create_wlan"): - logg.info("create_wlan wlanID {} wlan {}".format(args.wlanID, args.wlan)) + logg.info("create_wlan wlan {} wlanID {} wlanSSID {}".format(args.wlan, args.wlanID, args.wlanSSID)) if args.series == "9800": egg.sendline("config t") sleep(0.4) i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: logg.info("elevated to (config)#") - command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) # should the last one be ssid not wlan + # for create wlan + command = "wlan {} {} {}".format(args.wlanID, args.wlan, args.wlanSSID) # should the last one be ssid not wlan logg.info("open network command {}".format(command)) egg.sendline(command) sleep(0.4) @@ -1236,7 +1239,7 @@ def main(): if i == 0: logg.info("did not get the (config)# prompt") else: - command = "config wlan create %s %s %s"%(args.wlanID, args.wlan, args.wlan) + command = "config wlan create {} {} {}".format(args.wlanID, args.wlan, args.wlanSSID) if (args.action == "delete_wlan"): if args.series == "9800": @@ -1256,7 +1259,7 @@ def main(): else: if (args.action == "delete_wlan" and (args.wlanID is None)): raise Exception("wlan ID is required") - command = "config wlan delete %s"%(args.wlanID) + command = "config wlan delete {}".format(args.wlanID) logg.info("action {} series {}".format(args.action,args.series)) if (args.action == "enable_wlan"): diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 995db716..9f397e45 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -36,7 +36,7 @@ NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme --ap 9120_Candela --bandwidth "20" --channel "149" --nss 4 --txpower "1" \ --pathloss 56 --band a --upstream_port eth2 --series 9800 --radio wiphy5 --slot 1 --ssid open-wlan \ --prompt "katar_candela" --create_station sta0001 --ssidpw [BLANK] --security open --verbose \ - --antenna_gain "6" --wlan open-wlan --wlanID 1 \ + --antenna_gain "6" --wlanID 1 --wlan open-wlan --wlanSSID open-wlan\ --ap_info "ap_scheme==telnet ap_prompt==9120_Candela ap_ip==172.19.27.55 ap_port==2008 ap_user==admin ap_pw==Wnbulab@123" @@ -53,13 +53,13 @@ NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme --series "3504" --prompt "(Cisco Controler)" ############################################################################################## -# Long duration test -- need to create the --wlan open-wlan --wlanID - need to put in the notes +# Long duration test -- need to create the ---wlanID 1 --wlan open-wlan --wlanSSID open-wlan ############################################################################################## ./lf_cisco_power.py -d 172.19.36.168 -u admin -p Wnbulab@123 --port 23 --scheme telnet --ap "APA453.0E7B.CF60" \ --bandwidth "20 40 80" --channel "36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165" \ --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 54 --antenna_gain 6 --band a --upstream_port eth2 --series 9800 \ - --wlan open-wlan --wlanID 1 --create_station sta0001 --radio wiphy1 --ssid open-wlan --ssidpw [BLANK] --security open \ + --wlanID 1 --wlan open-wlan --wlanSSID open-wlan --create_station sta0001 --radio wiphy1 --ssid open-wlan --ssidpw [BLANK] --security open \ --outfile cisco_power_results_60_chan_ALL --cleanup --slot 1 --verbose @@ -77,7 +77,7 @@ NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme ./lf_cisco_power.py -d -u admin -p Cisco123 -port 23 --scheme telnet --ap AP6C71.0DE6.45D0 \ --station sta2222 --bandwidth "20" --channel "36" --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 54 --antenna_gain 6 --band a \ ---upstream_port eth2 --series 9800 --wlan open-wlan --wlanID 1 --create_station sta2222 --radio wiphy1 --ssid open-wlan \ +--upstream_port eth2 --series 9800 --wlanID 1 --wlan open-wlan --wlanSSID open-wlan --create_station sta2222 --radio wiphy1 --ssid open-wlan \ --ssidpw [BLANK] --security open --verbose ############################################################################################## @@ -86,7 +86,7 @@ NOTE: Telnet port 23 unless specified , ssh port 22 unless specified, scheme ./lf_cisco_power.py -d -u admin -p Cisco123 -port 23 --scheme telnet --ap AP6C71.0DE6.45D0 \ --station sta0000 --bandwidth "20" --channel "36" --nss 4 --txpower "1 2 3 4 5 6 7 8" --pathloss 64 --antenna_gain 5 --band a \ ---upstream_port eth2 --series 9800 --wlan open-wlan --wlanID 1 --verbose +--upstream_port eth2 --series 9800 --wlanID 1 --wlan open-wlan --wlanSSID open-wlan --verbose ############################################################################################## @@ -216,8 +216,9 @@ def usage(): print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") print("--wait_forever: Wait forever for station to associate, may aid debugging if STA cannot associate properly") print("--adjust_nf: Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") - print("--wlan: for 9800, wlan identifier defaults to wlan-open") + print("--wlan: for 9800, wlan identifier ") print("--wlanID: wlanID for 9800 , defaults to 1") + print("--wlanSSID: wlanSSID for 9800") print("--series: controller series 9800 , defaults to 3504") print("--slot: 9800 AP slot defaults to 1") print("--create_station", "create LANforge station at the beginning of the test") @@ -302,8 +303,9 @@ def main(): parser.add_argument("--pf_a4_dropoff", type=str, help="Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") - parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier, this must match the -ssid",required=True) + parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier",required=True) parser.add_argument("--wlanID", type=str, help="--wlanID 9800 , defaults to 1",default="1",required=True) + parser.add_argument("--wlanSSID", type=str, help="--wlan 9800, wlan SSID, this must match the -ssid , ssid for station",required=True) parser.add_argument("--series", type=str, help="--series 9800 or 3504, defaults to 9800",default="9800") parser.add_argument("--slot", type=str, help="--slot 1 , 9800 AP slot defaults to 1",default="1") parser.add_argument("--create_station", type=str, help="create LANforge station at the beginning of the test") @@ -364,9 +366,9 @@ def main(): cap_ctl_out = False else: cap_ctl_out = True - if (args.wlan != args.ssid): + if (args.wlanSSID != args.ssid): print("####### ERROR ################################") - print("wlan: {} must equial the station ssid: {}".format(args.wlan,args.ssid)) + print("wlanSSID: {} must equial the station ssid: {}".format(args.wlanSSID,args.ssid)) print("####### ERROR ################################") exit(1) # note: there would always be an args.outfile due to the default @@ -811,7 +813,8 @@ 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","--wlan", args.wlan, "--wlanID", args.wlanID,"--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "disable_wlan","--wlan", args.wlan, "--wlanID", args.wlanID, "--wlanSSID", args.wlanSSID, + "--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) @@ -941,7 +944,7 @@ def main(): # only create the wlan the first time if args.series == "9800": if wlan_created: - logg.info("wlan already present, no need to create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) + logg.info("wlan already present, no need to create wlanID {} wlan {} wlanSSID {} port {}".format(args.wlanID, args.wlan, args.wlanSSID, args.port)) pass else: # Verify that a wlan does not exist on wlanID @@ -971,12 +974,13 @@ def main(): cc_wlan_ssid = m.group(2) # wlanID is in use logg.info("###############################################################################") - logg.info("Need to remove wlan: {} wlanID: {} wlan ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + logg.info("Need to remove wlanID: {} cc_wlan: {} cc_wlan_ssid: {}".format(args.wlanID, cc_wlan, cc_wlan_ssid)) logg.info("###############################################################################") try: - logg.info("9800 cisco_wifi_ctl.py: delete_wlan, wlan present at start of test: wlan: {} wlanID: {} wlan_ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + logg.info("9800 cisco_wifi_ctl.py: delete_wlan, wlan present at start of test: wlanID: {} cc_wlan {} cc_wlan_ssid: {}".format(args.wlanID, cc_wlan, cc_wlan_ssid)) 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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "delete_wlan","--series",args.series, "--wlanID", args.wlanID, "--wlan", cc_wlan, "--wlanSSID", cc_wlan_ssid, + "--port",args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) @@ -989,9 +993,9 @@ def main(): wlan_created = True logg.info("create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) try: - logg.info("9800 cisco_wifi_ctl.py: create_wlan wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) + logg.info("9800 cisco_wifi_ctl.py: create_wlan wlan {} wlanID {} wlanSSID {} port {}".format(args.wlan, args.wlanID, args.wlanSSID, 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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "create_wlan","--series",args.series, "--wlanID", args.wlanID,"--wlanSSID", "--wlan", args.wlan, args.wlanSSID, "--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) @@ -1014,7 +1018,8 @@ 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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "enable_wlan", "--wlanID", args.wlanID, "--wlan", args.wlan, "--wlanSSID", args.wlanSSID, + "--series",args.series,"--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) @@ -1903,7 +1908,8 @@ 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,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "delete_wlan","--series",args.series, "--wlanID", args.wlanID, "--wlan", args.wlan, "--wlanSSID", args.wlanSSID, + "--port",args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) From 59b8f43454d3bfbfd88b3a8a94372beb146f5e9b Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 25 Jan 2021 07:35:17 -0700 Subject: [PATCH 122/848] lf_cisco_power.py : LCS-48 wlan and wlan ssid need separate config command update --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 9f397e45..03c8c46f 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -995,7 +995,7 @@ def main(): try: logg.info("9800 cisco_wifi_ctl.py: create_wlan wlan {} wlanID {} wlanSSID {} port {}".format(args.wlan, args.wlanID, args.wlanSSID, 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, "--wlanID", args.wlanID,"--wlanSSID", "--wlan", args.wlan, args.wlanSSID, "--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + "--action", "create_wlan","--series",args.series, "--wlanID", args.wlanID, "--wlan", args.wlan, "--wlanSSID", args.wlanSSID, "--port", args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) if cap_ctl_out: pss = ctl_output.stdout.decode('utf-8', 'ignore') logg.info(pss) From 94324c4f09fad72affb7d93d67cfdc3583c5641a Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 25 Jan 2021 07:48:07 -0700 Subject: [PATCH 123/848] cisco_wifi_ctl.py : : LCS-48 wlan and wlan ssid need separate config command fixed command order for 9800 wlan wlanID wlanSSID --- cisco_wifi_ctl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 5a65b80a..2740922e 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -1195,8 +1195,8 @@ def main(): print("command show wlan summary ") command = "show wlan summary" - if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): - raise Exception("wlan and wlanID is required an") + if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None) or (args.wlanSSID is None))): + raise Exception("wlanID, wlan, wlanSSID are required an") if (args.action == "create_wlan"): logg.info("create_wlan wlan {} wlanID {} wlanSSID {}".format(args.wlan, args.wlanID, args.wlanSSID)) if args.series == "9800": @@ -1206,7 +1206,7 @@ def main(): if i == 0: logg.info("elevated to (config)#") # for create wlan - command = "wlan {} {} {}".format(args.wlanID, args.wlan, args.wlanSSID) # should the last one be ssid not wlan + command = "wlan {} {} {}".format(args.wlan, args.wlanID, args.wlanSSID) logg.info("open network command {}".format(command)) egg.sendline(command) sleep(0.4) From 2247b79e4a811d1dc68d173cef92ddf229b7a1cd Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 25 Jan 2021 17:04:08 -0800 Subject: [PATCH 124/848] new report logic - uses pandas instead of xlsxwriter. deleted a few imports. moved imports to top --- py-json/realm.py | 104 +++++++++++--------------- py-scripts/test_ipv4_variable_time.py | 2 +- 2 files changed, 44 insertions(+), 62 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 352885d1..01b29985 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -19,6 +19,8 @@ import datetime import base64 import xlsxwriter import pandas as pd +import requests +import ast def wpa_ent_list(): @@ -1164,7 +1166,7 @@ class L3CXProfile(BaseProfile): else: output_format = report_file.split('.')[-1] - # Step 1, column names . what is this for? + # Step 1, column names fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) @@ -1186,11 +1188,6 @@ class L3CXProfile(BaseProfile): response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) - print("created cx.........") - print(created_cx) - print(fields) - print("response...........................") - print(response) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1215,62 +1212,47 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - #step 3 organize data - endpoints=list() - for endpoint in value_map.values(): - endpoints.append(endpoint['endpoint']) - endpoints2 = [] - for y in range(0, len(endpoints)): - for x in range(0, len(endpoints[0])): - endpoints2.append(list(list(endpoints[y][x].values())[0].values())) - import itertools - timestamps2 = list( - itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) - for point in range(0, len(endpoints2)): - endpoints2[point].insert(0, timestamps2[point]) - # step 4 save and close - header_row.insert(0, 'Timestamp') - print(header_row) + + full_test_data_list = [] + for test_timestamp, data in value_map.items(): + #reduce the endpoint data to single dictionary of dictionaries + for datum in data["endpoint"]: + for endpoint_data in datum.values(): + if self.debug: + print(endpoint_data) + endpoint_data["Timestamp"] = test_timestamp + full_test_data_list.append(endpoint_data) + + df = pd.DataFrame(full_test_data_list) + + try: + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) + except: + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) + + df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] + df['Script Name'] = script_name + df['Arguments'] = arguments + + for x in ['LFGUI Release', 'Script Name', 'Arguments']: + df[x][1:] = '' + if output_format == 'hdf': + df.to_hdf(report_file, 'table', append=True) + if output_format == 'parquet': + df.to_parquet(report_file, engine='pyarrow') + if output_format == 'png': + fig = df.plot().get_figure() + fig.savefig(report_file) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': - workbook = xlsxwriter.Workbook(report_file) - worksheet = workbook.add_worksheet() - for col_num, data in enumerate(header_row): - worksheet.write(0, col_num, data) - row_num = 1 - for x in endpoints2: - for col_num, data in enumerate(x): - worksheet.write(row_num, col_num, str(data)) - row_num += 1 - workbook.close() - else: - df = pd.DataFrame(endpoints2) - df.columns = header_row - import requests - import ast - try: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) - except: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) - df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] - df['Script Name'] = script_name - df['Arguments'] = arguments - for x in ['LFGUI Release', 'Script Name', 'Arguments']: - df[x][1:] = '' - if output_format == 'hdf': - df.to_hdf(report_file, 'table', append=True) - if output_format == 'parquet': - df.to_parquet(report_file, engine='pyarrow') - if output_format == 'png': - fig = df.plot().get_figure() - fig.savefig(report_file) - if output_format == 'df': - return df - supported_formats = ['csv', 'json', 'stata', 'pickle','html'] - for x in supported_formats: - if output_format.lower() == x or report_file.split('.')[-1] == x: - exec('df.to_' + x + '("' + report_file + '")') - else: - pass + df.to_excel(report_file) + if output_format == 'df': + return df + supported_formats = ['csv', 'json', 'stata', 'pickle','html'] + + for x in supported_formats: + if output_format.lower() == x or report_file.split('.')[-1] == x: + exec('df.to_' + x + '("' + report_file + '")') + def refresh_cx(self): for cx_name in self.created_cx.keys(): diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 75e71a69..5a212860 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -193,7 +193,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Name','Rx Rate','Rx PDUs']) + optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Dropped', 'Name', 'Rx Bytes', 'Tx Bytes']) args = parser.parse_args() num_sta = 2 From 5f63a35d6cb80bf0979a1ec4844ebd20b4f0faf4 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 07:36:15 -0700 Subject: [PATCH 125/848] lf_cisco_snp.py : prompt fix --- py-scripts/lf_cisco_snp.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index 087af28b..fb6f8be8 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -1479,13 +1479,12 @@ Eventual Realm at Cisco parser.add_argument('-cde','--cisco_data_encryption', help='--cisco_data_encryption \"enable disable\"',default="disable" ) parser.add_argument('-cs','--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) - parser.add_argument('-ccp','--prompt', type=str,help="controller prompt default WLC",default="WLC") + parser.add_argument('-ccp','--cisco_prompt', type=str,help="controller prompt default WLC",default="WLC") parser.add_argument('-cc','--cisco_ctlr', help='--cisco_ctlr default 192.168.100.178',default="192.168.100.178") parser.add_argument('-cp','--cisco_port', help='--cisco_port ssh default 22',default="22") parser.add_argument('-cu','--cisco_user', help='--cisco_user ',default="admin") parser.add_argument('-cpw','--cisco_passwd', help='--cisco_passwd ',default="Cisco123") - parser.add_argument('-ccp','--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") parser.add_argument('-cd','--cisco_dfs', help='--cisco_dfs ',default=False) parser.add_argument('-ccs','--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"]) parser.add_argument('-cw','--cisco_wlan', help='--cisco_wlan default: NA, NA means no change',default="NA") From b3c86930c1038160298e54fbe220b0fb7edda332 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 07:52:46 -0700 Subject: [PATCH 126/848] lf_cisco_snp.py : LCS-49 valriable prompt: scaling and performance --- py-scripts/lf_cisco_snp.py | 94 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index fb6f8be8..1288493f 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -51,10 +51,10 @@ class cisco_(): def controller_show_summary(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "summary"], capture_output=self.args.cap_ctl_out, check=True) @@ -76,10 +76,10 @@ class cisco_(): def controller_show_ap_summary(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"advanced")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "advanced"], capture_output=self.args.cap_ctl_out, check=True) @@ -97,10 +97,10 @@ class cisco_(): def controller_show_wlan_summary(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"show wlan summary")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "show_wlan_summary"], capture_output=self.args.cap_ctl_out, check=True) @@ -120,10 +120,10 @@ class cisco_(): def controller_disable_ap(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u",self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable"], capture_output=self.args.cap_ctl_out, check=True) @@ -144,10 +144,10 @@ class cisco_(): def controller_disable_wlan(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_wlan")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_wlan"], capture_output=self.args.cap_ctl_out, check=True) @@ -169,10 +169,10 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_5ghz")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_network_5ghz"], capture_output=self.args.cap_ctl_out, check=True) @@ -189,10 +189,10 @@ class cisco_(): else: try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a disable network")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11a disable network"], capture_output=self.args.cap_ctl_out, check=True) @@ -214,10 +214,10 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_24ghz")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_network_24ghz"], capture_output=self.args.cap_ctl_out, check=True) @@ -234,10 +234,10 @@ class cisco_(): else: try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b disable network")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11b disable network"], capture_output=self.args.cap_ctl_out, check=True) @@ -261,10 +261,10 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"manual")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "manual"], capture_output=self.args.cap_ctl_out, check=True) @@ -288,10 +288,10 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"auto")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "auto"], capture_output=self.args.cap_ctl_out, check=True) @@ -313,9 +313,9 @@ class cisco_(): def controller_set_tx_power(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"txPower", self.args.cisco_tx_power )) # TODO fix txPower to tx_power in cisco_wifi_ctl.py - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "txPower","--value", self.args.cisco_tx_power], @@ -339,9 +339,9 @@ class cisco_(): def controller_set_channel(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_channel )) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "channel","--value", self.args.cisco_channel], @@ -363,9 +363,9 @@ class cisco_(): def controller_set_bandwidth(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_chan_width )) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "channel","--value", self.args.cisco_chan_width], @@ -388,9 +388,9 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "create_wlan","--wlan", self.args.cisco_wlan, "--wlanID", self.args.cisco_wlanID], @@ -414,9 +414,9 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"wireless_tag_policy" )) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "wireless_tag_policy"], @@ -440,9 +440,9 @@ class cisco_(): def controller_enable_wlan(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_wlan")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "enable_wlan"], @@ -465,9 +465,9 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_5ghz")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "enable_network_5ghz"], @@ -485,10 +485,10 @@ class cisco_(): else: try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a enable network")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11a enable network"], capture_output=self.args.cap_ctl_out, check=True) @@ -511,9 +511,9 @@ class cisco_(): if self.args.cisco_series == "9800": try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_24ghz")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "enable_network_24ghz"], @@ -531,10 +531,10 @@ class cisco_(): else: try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b enable network")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11b enable network"], capture_output=self.args.cap_ctl_out, check=True) @@ -556,9 +556,9 @@ class cisco_(): def controller_enable_ap(self): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "enable"], @@ -578,7 +578,7 @@ class cisco_(): #advanced (showes summary) #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action advanced --series 9800 def controller_show_ap_channel(self): - advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "ap_channel"], capture_output=True) @@ -953,10 +953,10 @@ class L3VariableTime(LFCliBase): try: logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series,"--action", "summary"], capture_output=True) pss = ctl_output.stdout.decode('utf-8', 'ignore') From efa7adb65bd081fafb51eb3d26c00c1d7a8dcce5 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 26 Jan 2021 09:47:43 -0800 Subject: [PATCH 127/848] small changes -- not signif. latest version --- py-json/realm.py | 5 +++-- py-scripts/test_ipv4_variable_time.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 01b29985..e5b809e1 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1182,7 +1182,7 @@ class L3CXProfile(BaseProfile): expected_passes = 0 old_cx_rx_values = self.__get_rx_values() timestamps = [] - # for x in range(0,int(round(iterations,0))): + while datetime.datetime.now() < end_time: if fields is None: response = self.json_get("/endp/all") @@ -1224,6 +1224,8 @@ class L3CXProfile(BaseProfile): full_test_data_list.append(endpoint_data) df = pd.DataFrame(full_test_data_list) + df.columns=header_row + #df=df[[*header_row]] try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) @@ -1248,7 +1250,6 @@ class L3CXProfile(BaseProfile): if output_format == 'df': return df supported_formats = ['csv', 'json', 'stata', 'pickle','html'] - for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: exec('df.to_' + x + '("' + report_file + '")') diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 5a212860..21ee4ba7 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -78,7 +78,6 @@ class IPV4VariableTime(LFCliBase): self.station_profile.mode = mode if self.ap is not None: self.station_profile.set_command_param("add_sta", "ap",self.ap) - #self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user defined variable from terminal. self.cx_profile.host = self.host @@ -193,7 +192,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Dropped', 'Name', 'Rx Bytes', 'Tx Bytes']) + optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Tx Bytes','Name','Dropped', 'Rx Bytes']) args = parser.parse_args() num_sta = 2 From eaff7dda60455ca654087a9ab368df2d39b5849f Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 26 Jan 2021 10:17:54 -0800 Subject: [PATCH 128/848] column layout is organized --- py-json/realm.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index e5b809e1..4f224161 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1182,7 +1182,7 @@ class L3CXProfile(BaseProfile): expected_passes = 0 old_cx_rx_values = self.__get_rx_values() timestamps = [] - + # for x in range(0,int(round(iterations,0))): while datetime.datetime.now() < end_time: if fields is None: response = self.json_get("/endp/all") @@ -1212,7 +1212,7 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - + #organize data full_test_data_list = [] for test_timestamp, data in value_map.items(): #reduce the endpoint data to single dictionary of dictionaries @@ -1222,10 +1222,11 @@ class L3CXProfile(BaseProfile): print(endpoint_data) endpoint_data["Timestamp"] = test_timestamp full_test_data_list.append(endpoint_data) - + print(full_test_data_list) + + header_row.append('Timestamp') df = pd.DataFrame(full_test_data_list) df.columns=header_row - #df=df[[*header_row]] try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) From f22bdeb30523fa71829484c4db144c0fb42f0f74 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 13:49:00 -0700 Subject: [PATCH 129/848] lf_cisco_power.py : LCS-48 take spatial stream into account for failure Put controller model in results --- lf_cisco_power.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 03c8c46f..556347f3 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -563,6 +563,8 @@ def main(): row = 0 worksheet.write(row, col, 'Regulatory\nDomain', dblue_bold); col += 1 worksheet.set_column(col, col, 10) # Set width + worksheet.write(row, col, 'Controller', dblue_bold); col += 1 + worksheet.set_column(col, col, 12) # Set width worksheet.write(row, col, 'Controller\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'AP\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'NSS', dblue_bold); col += 1 @@ -1650,8 +1652,19 @@ def main(): T4 = m.group(8) N_ANT = m.group(9) DAA_Pwr = m.group(10) - DAA_N_TX = m.group(11) + DAA_N_TX = m.group(11) # number of spatial streams DAA_Total_pwr = m.group(12) + # adjust the fail criterial based on the number of spatial streams + if DAA_N_TX == 4: + failed_low_treshold = 1 + if DAA_N_TX == 3: + failed_low_treshold = 2 + if DAA_N_TX == 2: + failed_low_treshold = 3 + if DAA_N_TX == 1: + failed_low_treshold = 4 + + i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr) print(i_tot) From cbb06a7922349c1cff9eda5a77d84cebfc470cd9 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 26 Jan 2021 12:53:58 -0800 Subject: [PATCH 130/848] columns now adjusting according to order called in var_time, removed indices --- py-json/realm.py | 6 ++++-- py-scripts/test_ipv4_variable_time.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 4f224161..c3a2e1ba 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1222,11 +1222,13 @@ class L3CXProfile(BaseProfile): print(endpoint_data) endpoint_data["Timestamp"] = test_timestamp full_test_data_list.append(endpoint_data) + if self.debug: + print("Printing full data list...") print(full_test_data_list) header_row.append('Timestamp') df = pd.DataFrame(full_test_data_list) - df.columns=header_row + df=df[["Timestamp",*header_row[:-1]]] try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) @@ -1253,7 +1255,7 @@ class L3CXProfile(BaseProfile): supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: - exec('df.to_' + x + '("' + report_file + '")') + exec('df.to_' + x + '("' + report_file + '",index=False' + ')') def refresh_cx(self): diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 21ee4ba7..c61cb05d 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -192,7 +192,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Tx Bytes','Name','Dropped', 'Rx Bytes']) + optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['name','tx bytes','dropped', 'rx bytes']) args = parser.parse_args() num_sta = 2 From 6b0f58b0b14a5d13f3046efbf3bc201f3d142fff Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 14:11:20 -0700 Subject: [PATCH 131/848] lf_cisco_power.py(LCS-48): added cisco controller model to spread sheet --- lf_cisco_power.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 556347f3..1fd36d1c 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1719,6 +1719,7 @@ def main(): col = 0 worksheet.write(row, col, myrd, center_blue); col += 1 + worksheet.write(row, col, args.series, center_blue); col += 1 worksheet.write(row, col, cc_ch, center_blue); col += 1 worksheet.write(row, col, _ch, center_blue); col += 1 worksheet.write(row, col, _nss, center_blue); col += 1 From c85dd35c4ebf48f1a5289c738d2f2f044eb2df27 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 26 Jan 2021 13:48:15 -0800 Subject: [PATCH 132/848] milliseconds from datetime object now in own column from datetime object --- py-json/realm.py | 8 +++++--- py-scripts/test_ipv4_variable_time.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index c3a2e1ba..99eca37b 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1220,15 +1220,17 @@ class L3CXProfile(BaseProfile): for endpoint_data in datum.values(): if self.debug: print(endpoint_data) - endpoint_data["Timestamp"] = test_timestamp + endpoint_data["Timestamp"] = test_timestamp.strftime("%m/%d/%Y %I:%M:%S") + endpoint_data["Timestamp milliseconds"] = test_timestamp.strftime("%f") full_test_data_list.append(endpoint_data) if self.debug: print("Printing full data list...") print(full_test_data_list) header_row.append('Timestamp') + header_row.append('Timestamp milliseconds') df = pd.DataFrame(full_test_data_list) - df=df[["Timestamp",*header_row[:-1]]] + df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) @@ -1249,7 +1251,7 @@ class L3CXProfile(BaseProfile): fig = df.plot().get_figure() fig.savefig(report_file) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': - df.to_excel(report_file) + df.to_excel(report_file, index=False) if output_format == 'df': return df supported_formats = ['csv', 'json', 'stata', 'pickle','html'] diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index c61cb05d..b8a9ed02 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -192,7 +192,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['name','tx bytes','dropped', 'rx bytes']) + optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['name','tx bytes', 'rx bytes','dropped']) args = parser.parse_args() num_sta = 2 From c3b652135b982f05a8fe1adce580c9e8a3643db5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 15:06:27 -0700 Subject: [PATCH 133/848] lf_cisco_power.py(LCS-48): comment cleanup when checking AP --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1fd36d1c..4e9440cf 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1670,7 +1670,7 @@ def main(): print(i_tot) logg.info(i_tot) else: - logg.info("AP Check regular expression!!!") + logg.info("AP Check using regular expressions") # From 0e88b27ff95af93ed32b33ca8fc68525560914f4 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 26 Jan 2021 15:38:07 -0800 Subject: [PATCH 134/848] added msecs since epoch --- py-json/realm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 99eca37b..7f3ae17a 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -15,7 +15,7 @@ from LANforge.lfcli_base import LFCliBase from LANforge import add_monitor from LANforge.add_monitor import * import os -import datetime +import datetime import base64 import xlsxwriter import pandas as pd @@ -1211,6 +1211,7 @@ class L3CXProfile(BaseProfile): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) + print(value_map) #organize data full_test_data_list = [] @@ -1220,16 +1221,18 @@ class L3CXProfile(BaseProfile): for endpoint_data in datum.values(): if self.debug: print(endpoint_data) - endpoint_data["Timestamp"] = test_timestamp.strftime("%m/%d/%Y %I:%M:%S") - endpoint_data["Timestamp milliseconds"] = test_timestamp.strftime("%f") + endpoint_data["Timestamp"] = test_timestamp full_test_data_list.append(endpoint_data) if self.debug: print("Printing full data list...") print(full_test_data_list) header_row.append('Timestamp') - header_row.append('Timestamp milliseconds') + # header_row.append('Timestamp milliseconds') df = pd.DataFrame(full_test_data_list) + + df["Timestamp milliseconds"] = (df["Timestamp"] - datetime.datetime(1970,1,1)).dt.total_seconds()*1000 + df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S")) df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] try: From 152de2f4220a04700d668e19075bcbd29e6b3ab1 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 16:43:30 -0700 Subject: [PATCH 135/848] lf_cisco_power.py(LCS-48): allow for less spatial streams if read from AP or a lower poer read --- lf_cisco_power.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 4e9440cf..a68aac21 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -174,9 +174,10 @@ full_outfile = "cisco_power_results_full.txt" outfile_xlsx = "cisco_power_results.xlsx" upstream_port = "eth1" pf_dbm = 6 + # Allow one chain to have a lower signal, since customer's DUT has # lower tx-power on one chain when doing high MCS at 4x4. -pf_a4_dropoff = 3 +pf_a4_dropoff = 20 # This below is only used when --adjust_nf is used. # Noise floor on ch 36 where we calibrated -54 path loss (based on hard-coded -95 noise-floor in driver) @@ -213,7 +214,7 @@ def usage(): print("--antenna_gain: Antenna gain for AP, if no Antenna attached then antenna gain needs to be taken into account, default 0") print("--band: Select band (a | b | abgn), a means 5Ghz, b means 2.4, abgn means 2.4 on dual-band AP, default a") print("--pf_dbm: Pass/Fail range, default is 6") - print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") + print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4, default 20. Unless AP is read") print("--wait_forever: Wait forever for station to associate, may aid debugging if STA cannot associate properly") print("--adjust_nf: Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") print("--wlan: for 9800, wlan identifier ") @@ -299,8 +300,8 @@ def main(): parser.add_argument("--antenna_gain", type=str, help="Antenna gain, take into account the gain due to the antenna",default="0") parser.add_argument("--band", type=str, help="Select band (a | b), a means 5Ghz, b means 2.4Ghz. Default is a", choices=["a", "b", "abgn"]) - parser.add_argument("--pf_dbm", type=str, help="Pass/Fail threshold. Default is 6") - parser.add_argument("--pf_a4_dropoff", type=str, help="Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") + parser.add_argument("--pf_dbm", type=str, help="Pass/Fail threshold. Default is 6",default="6" ) + parser.add_argument("--pf_a4_dropoff", type=str, help="Allow a chain to have lower tx-power and still pass. Unless AP is read") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier",required=True) @@ -1570,8 +1571,8 @@ def main(): diff_a4 = calc_ant4 - allowed_per_path logg.info("(Offset 4) diff_a4: {} = calc_ant4: {} - allowed_per_path: {}".format(diff_a4, calc_ant4, allowed_per_path)) - # DUT transmits one chain at lower power when using higher MCS, so allow - # for that as passing result. + # Read AP to determin if there are less chains or spatial steams then expected + # Thus provide a passing result failed_low = 0 least = 0 if (diff_a1 < -pfrange): @@ -1587,7 +1588,7 @@ def main(): failed_low += 1 least = min(least, diff_a4) - failed_low_treshold = 1 + failed_low_threshold = 1 # # # If the ap dictionary is set the read the AP to see the number @@ -1656,13 +1657,13 @@ def main(): DAA_Total_pwr = m.group(12) # adjust the fail criterial based on the number of spatial streams if DAA_N_TX == 4: - failed_low_treshold = 1 + failed_low_threshold = 0 if DAA_N_TX == 3: - failed_low_treshold = 2 + failed_low_threshold = 1 if DAA_N_TX == 2: - failed_low_treshold = 3 + failed_low_threshold = 2 if DAA_N_TX == 1: - failed_low_treshold = 4 + failed_low_threshold = 3 i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( @@ -1677,7 +1678,12 @@ def main(): # The controller may adjust the number of spatial streams to allow for the # best power values # - if ((least < (-pfrange - pf_a4_dropoff)) or (failed_low >= failed_low_treshold)): + if bool(ap_dict) and ( failed_low > failed_low_threshold ): + pf = 0 + # if the AP is not read for number of spatial streams + # a value may be put in that if the spatial stream is less + # then it will still count as a failure + elif(least < (-pfrange - pf_a4_dropoff)): pf = 0 if (diff_a1 > pfrange): From ce505f2855c88a9f721c672261b2fa00b6119149 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 17:04:52 -0700 Subject: [PATCH 136/848] lf_cisco_power.py(LCS-48): bug cast str to int --- lf_cisco_power.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index a68aac21..694ce381 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -359,7 +359,7 @@ def main(): else: band = "a" if (args.pf_dbm != None): - pf_dbm = args.pf_dbm + pf_dbm = int(args.pf_dbm) if (args.pf_a4_dropoff != None): pf_a4_dropoff = args.pf_p4_dropoff if (args.verbose): @@ -1505,7 +1505,7 @@ def main(): w_tot = "WARNING: Controller dBm and Calculated dBm Beacon power different by greater than +/- {} dBm".format(args.beacon_dbm_diff) pfs = "PASS" - pfrange = pf_dbm; + pfrange = pf_dbm @@ -1571,7 +1571,7 @@ def main(): diff_a4 = calc_ant4 - allowed_per_path logg.info("(Offset 4) diff_a4: {} = calc_ant4: {} - allowed_per_path: {}".format(diff_a4, calc_ant4, allowed_per_path)) - # Read AP to determin if there are less chains or spatial steams then expected + # Read AP to determine if there are less chains or spatial steams then expected # Thus provide a passing result failed_low = 0 least = 0 From 02b7d33a0425e8fd0d6c2b48399cc53108fe068c Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 17:34:52 -0700 Subject: [PATCH 137/848] lf_cisco_power.py(LCS-48): debug logging --- lf_cisco_power.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 694ce381..1a0749f2 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -177,7 +177,7 @@ pf_dbm = 6 # Allow one chain to have a lower signal, since customer's DUT has # lower tx-power on one chain when doing high MCS at 4x4. -pf_a4_dropoff = 20 +pf_a4_dropoff = 0 # This below is only used when --adjust_nf is used. # Noise floor on ch 36 where we calibrated -54 path loss (based on hard-coded -95 noise-floor in driver) @@ -214,7 +214,7 @@ def usage(): print("--antenna_gain: Antenna gain for AP, if no Antenna attached then antenna gain needs to be taken into account, default 0") print("--band: Select band (a | b | abgn), a means 5Ghz, b means 2.4, abgn means 2.4 on dual-band AP, default a") print("--pf_dbm: Pass/Fail range, default is 6") - print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4, default 20. Unless AP is read") + print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4, default 0. Unless AP is read") print("--wait_forever: Wait forever for station to associate, may aid debugging if STA cannot associate properly") print("--adjust_nf: Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") print("--wlan: for 9800, wlan identifier ") @@ -301,7 +301,7 @@ def main(): parser.add_argument("--band", type=str, help="Select band (a | b), a means 5Ghz, b means 2.4Ghz. Default is a", choices=["a", "b", "abgn"]) parser.add_argument("--pf_dbm", type=str, help="Pass/Fail threshold. Default is 6",default="6" ) - parser.add_argument("--pf_a4_dropoff", type=str, help="Allow a chain to have lower tx-power and still pass. Unless AP is read") + parser.add_argument("--pf_a4_dropoff", type=str, help="Allow a chain to have lower tx-power and still pass. Unless AP is read",default="0") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier",required=True) @@ -361,7 +361,7 @@ def main(): if (args.pf_dbm != None): pf_dbm = int(args.pf_dbm) if (args.pf_a4_dropoff != None): - pf_a4_dropoff = args.pf_p4_dropoff + pf_a4_dropoff = int(args.pf_p4_dropoff) if (args.verbose): # capture the controller output , thus won't go to stdout some output always present cap_ctl_out = False @@ -1588,7 +1588,7 @@ def main(): failed_low += 1 least = min(least, diff_a4) - failed_low_threshold = 1 + failed_low_threshold = 0 # # # If the ap dictionary is set the read the AP to see the number @@ -1678,12 +1678,16 @@ def main(): # The controller may adjust the number of spatial streams to allow for the # best power values # - if bool(ap_dict) and ( failed_low > failed_low_threshold ): - pf = 0 + logg.info("failed_low: {} falied_low_threshold: {}".format(failed_low,failed_low_threshold)) + if failed_low > failed_low_threshold: + logg.info("failed_low: {} > failed_low_threshold: {}".format(failed_low,failed_low_threshold)) + pf = 0 # if the AP is not read for number of spatial streams # a value may be put in that if the spatial stream is less # then it will still count as a failure - elif(least < (-pfrange - pf_a4_dropoff)): + logg.info("least: {} pfrange: {} pf_a4_dropoff: {}".format(least, pfrange, pf_a4_dropoff)) + if(least < (-pfrange - pf_a4_dropoff)): + logg.info("least: {} < -pfrange: {} - pf_a4_dropoff: {}".format(least, pfrange, pf_a4_dropoff)) pf = 0 if (diff_a1 > pfrange): From 2c22cba6f55ca9c4dfb039d6d912b39bd1b88235 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 26 Jan 2021 16:36:02 -0800 Subject: [PATCH 138/848] milliseconds to int --- py-json/realm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 7f3ae17a..b2b12a8a 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1227,11 +1227,14 @@ class L3CXProfile(BaseProfile): print("Printing full data list...") print(full_test_data_list) - header_row.append('Timestamp') - # header_row.append('Timestamp milliseconds') + + header_row.append("Timestamp") + header_row.append('Timestamp milliseconds') df = pd.DataFrame(full_test_data_list) df["Timestamp milliseconds"] = (df["Timestamp"] - datetime.datetime(1970,1,1)).dt.total_seconds()*1000 + #round entire column + df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int) df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S")) df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] From a3a605705609bb3610c5bd75680fc249df8c501a Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 17:37:56 -0700 Subject: [PATCH 139/848] lf_cisco_power.py(LCS-48): fixed typo --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 1a0749f2..6f51d93c 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -361,7 +361,7 @@ def main(): if (args.pf_dbm != None): pf_dbm = int(args.pf_dbm) if (args.pf_a4_dropoff != None): - pf_a4_dropoff = int(args.pf_p4_dropoff) + pf_a4_dropoff = int(args.pf_a4_dropoff) if (args.verbose): # capture the controller output , thus won't go to stdout some output always present cap_ctl_out = False From 79817d2b37b40cb049f45a7925c41ebcb6bf4603 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 17:59:30 -0700 Subject: [PATCH 140/848] lf_cisco_power.py(LCS-48): debug logging --- lf_cisco_power.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 6f51d93c..f4e43bd2 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -179,6 +179,9 @@ pf_dbm = 6 # lower tx-power on one chain when doing high MCS at 4x4. pf_a4_dropoff = 0 +# Threshold for allowing a pass +failed_low_threshold = 0 + # This below is only used when --adjust_nf is used. # Noise floor on ch 36 where we calibrated -54 path loss (based on hard-coded -95 noise-floor in driver) nf_at_calibration = -105 @@ -271,6 +274,7 @@ def main(): global upstream_port global pf_dbm global pf_a4_dropoff + global failed_low_threshold scheme = "ssh" @@ -1658,12 +1662,17 @@ def main(): # adjust the fail criterial based on the number of spatial streams if DAA_N_TX == 4: failed_low_threshold = 0 + logg.info("4 failed_low_threshold {}".format(failed_low_threshold)) if DAA_N_TX == 3: failed_low_threshold = 1 + logg.info("3 failed_low_threshold {}".format(failed_low_threshold)) if DAA_N_TX == 2: failed_low_threshold = 2 + logg.info("2 failed_low_threshold {}".format(failed_low_threshold)) if DAA_N_TX == 1: failed_low_threshold = 3 + logg.info("1 failed_low_threshold {}".format(failed_low_threshold)) + i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( @@ -1678,7 +1687,7 @@ def main(): # The controller may adjust the number of spatial streams to allow for the # best power values # - logg.info("failed_low: {} falied_low_threshold: {}".format(failed_low,failed_low_threshold)) + logg.info("failed_low: {} failed_low_threshold: {}".format(failed_low,failed_low_threshold)) if failed_low > failed_low_threshold: logg.info("failed_low: {} > failed_low_threshold: {}".format(failed_low,failed_low_threshold)) pf = 0 From 6ce143aa93e64e3bdbde72aa90772d6b0ddd84b6 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 18:16:50 -0700 Subject: [PATCH 141/848] lf_cisco_power.py(LCS-48): fix comparison to compare strings --- lf_cisco_power.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index f4e43bd2..3f006a52 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1660,16 +1660,16 @@ def main(): DAA_N_TX = m.group(11) # number of spatial streams DAA_Total_pwr = m.group(12) # adjust the fail criterial based on the number of spatial streams - if DAA_N_TX == 4: + if DAA_N_TX == "4": failed_low_threshold = 0 logg.info("4 failed_low_threshold {}".format(failed_low_threshold)) - if DAA_N_TX == 3: + if DAA_N_TX == "3": failed_low_threshold = 1 logg.info("3 failed_low_threshold {}".format(failed_low_threshold)) - if DAA_N_TX == 2: + if DAA_N_TX == "2": failed_low_threshold = 2 logg.info("2 failed_low_threshold {}".format(failed_low_threshold)) - if DAA_N_TX == 1: + if DAA_N_TX == "1": failed_low_threshold = 3 logg.info("1 failed_low_threshold {}".format(failed_low_threshold)) From 62b5190dc3d5a655ba42f3374b2380de61cc619f Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 26 Jan 2021 18:31:21 -0700 Subject: [PATCH 142/848] lf_cisco_power.py(LCS-48): allow for checking AP and dBm threshold --- lf_cisco_power.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 3f006a52..d07538c4 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -177,7 +177,7 @@ pf_dbm = 6 # Allow one chain to have a lower signal, since customer's DUT has # lower tx-power on one chain when doing high MCS at 4x4. -pf_a4_dropoff = 0 +pf_a4_dropoff = 100 # Threshold for allowing a pass failed_low_threshold = 0 @@ -217,7 +217,7 @@ def usage(): print("--antenna_gain: Antenna gain for AP, if no Antenna attached then antenna gain needs to be taken into account, default 0") print("--band: Select band (a | b | abgn), a means 5Ghz, b means 2.4, abgn means 2.4 on dual-band AP, default a") print("--pf_dbm: Pass/Fail range, default is 6") - print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4, default 0. Unless AP is read") + print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4, default 100. so disabled") print("--wait_forever: Wait forever for station to associate, may aid debugging if STA cannot associate properly") print("--adjust_nf: Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") print("--wlan: for 9800, wlan identifier ") @@ -305,7 +305,7 @@ def main(): parser.add_argument("--band", type=str, help="Select band (a | b), a means 5Ghz, b means 2.4Ghz. Default is a", choices=["a", "b", "abgn"]) parser.add_argument("--pf_dbm", type=str, help="Pass/Fail threshold. Default is 6",default="6" ) - parser.add_argument("--pf_a4_dropoff", type=str, help="Allow a chain to have lower tx-power and still pass. Unless AP is read",default="0") + parser.add_argument("--pf_a4_dropoff", type=str, help="Allow a chain to have lower tx-power and still pass. default 100 so disabled",default="100") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier",required=True) @@ -1695,7 +1695,7 @@ def main(): # a value may be put in that if the spatial stream is less # then it will still count as a failure logg.info("least: {} pfrange: {} pf_a4_dropoff: {}".format(least, pfrange, pf_a4_dropoff)) - if(least < (-pfrange - pf_a4_dropoff)): + if(least < (-pfrange - pf_a4_dropoff)) and int(pf_a4_dropoff) != 100: logg.info("least: {} < -pfrange: {} - pf_a4_dropoff: {}".format(least, pfrange, pf_a4_dropoff)) pf = 0 From 388cb1843fcec6cc67de97aa1098fc91f165d66c Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Wed, 27 Jan 2021 16:30:45 +0530 Subject: [PATCH 143/848] Netear Dfs Test --- py-scripts/netgear_dfs_test.py | 765 +++++++++++++++++++++++++++++++++ 1 file changed, 765 insertions(+) create mode 100644 py-scripts/netgear_dfs_test.py diff --git a/py-scripts/netgear_dfs_test.py b/py-scripts/netgear_dfs_test.py new file mode 100644 index 00000000..8e6bdeae --- /dev/null +++ b/py-scripts/netgear_dfs_test.py @@ -0,0 +1,765 @@ +import os +import paramiko +import time +import threading +from cx_time import IPv4Test +import argparse +from threading import Thread +from itertools import islice +import datetime +from datetime import datetime +import numpy as np +import matplotlib.pyplot as plt + + +class DFS_Test: + + def __init__(self, ip, user, pswd, host, ssid, passwd, security, radio): + self.ip = ip + self.user = user + self.pswd = pswd + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + def check_last_time_ap(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(10) + return output + + def create_station_on_GUI_1(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + obj.cleanup(obj.sta_list) + obj.build() + obj.station_profile.admin_up() + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(5) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + # print(var_1) + + return var_1 + + def monitor_station_52(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "52": + print("channel at 52") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 15 + while var_1 != "52": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_station_100(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "100": + print("channel at 100") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 15 + while var_1 != "100": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_station_120(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "120": + print("channel at 120") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 15 + while var_1 != "120": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_station_140(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "140": + print("channel at 140") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 2 + while var_1 != "140": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_untill_channel_assigned(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + + timeout = time.time() + 60 * 5 + while var_1 == "-1": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def set_channel_in_ap_at_52(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(10) + + def generate_radar_at_ch52(self): + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + print("Radar detected") + time.sleep(1) + + def check_log_channel(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output + + def check_log_info(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep OTHER') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output + + def check_log_associated(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep associated') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output + + """def check_log_associated(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep Trig') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output""" + + def check_for_channels(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(1) + return output + + def set_channel_in_ap_at_100(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + + def generate_radar_at_ch100(self): + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + print("Radar detected") + time.sleep(20) + + def set_channel_in_ap_at_120(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 120') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + + def set_channel_in_ap_at_140(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 140') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + + def generate_radar_at_ch120(self): + + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + + def generate_radar_at_ch140(self): + + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + + def station_clean(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + obj.cleanup(obj.sta_list) + var_1 = "station cleaned" + print(var_1) + + def monitor_untill_connection_time(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=cx%20time%20(us)") + var_1 = (var['interface']['cx time (us)']) + return var_1 + + def convert_to_sec(self, time_string): + self.time_string = time_string + date_time = datetime.datetime.strptime(self.time_string, "%H:%M:%S") + + print(date_time) + + a_timedelta = date_time - datetime.datetime(1900, 1, 1) + seconds = a_timedelta.total_seconds() + return seconds + + +class ThreadWithReturnValue(Thread): + def __init__(self, group=None, target=None, name=None, + args=(), kwargs={}, Verbose=None): + Thread.__init__(self, group, target, name, args, kwargs) + self._return = None + + def run(self): + # print(type(self._target)) + if self._target is not None: + # self._return = self._target(*self._args, **self._kwargs) + self._return = self._target + + def join(self, *args): + Thread.join(self, *args) + return self._return + + +def main(): + parser = argparse.ArgumentParser(description="Netgear AP DFS Test Script") + parser.add_argument('-i', '--ip', type=str, help='AP ip') + parser.add_argument('-u', '--user', type=str, help='credentials login/username') + parser.add_argument('-p', '--pswd', type=str, help='credential password') + parser.add_argument('-hst', '--host', type=str, help='host name') + parser.add_argument('-s', '--ssid', type=str, help='ssid for client') + parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid') + parser.add_argument('-sec', '--security', type=str, help='security') + parser.add_argument('-rad', '--radio', type=str, help='radio at which client will be connected') + + args = parser.parse_args() + + dfs = DFS_Test(args.ip, args.user, args.pswd, args.host, args.ssid, args.passwd, args.security, args.radio) + + # check for last timesnap of ap logs + + th = ThreadWithReturnValue(target=dfs.check_last_time_ap(args.ip, args.user, args.pswd)) + th.start() + th.join() + val = th.join() + N = 1 + res = list(islice(reversed(val), 0, N)) + res.reverse() + x_list = res + var_1 = "" + for i in x_list[0][10:20]: + var_1 = var_1 + i + + var_1 = var_1.strip() + print(var_1) + print("timesnap for last log is ", var_1) + + print("creating station on GUI") + t1 = ThreadWithReturnValue( + target=dfs.create_station_on_GUI_1(args.host, args.ssid, args.passwd, args.security, args.radio)) + t1.start() + t1.join() + val_1 = t1.join() + val_1 = val_1.strip() + print("station is at channel", val_1) + + time.sleep(2) + + print("set channel to 52") + t2 = ThreadWithReturnValue(target=dfs.set_channel_in_ap_at_52(args.ip, args.user, args.pswd)) + t2.start() + t2.join() + + print("channel set checking....") + t3 = ThreadWithReturnValue(target=dfs.monitor_station_52(args.host, args.ssid, args.passwd, args.security, args.radio)) + t3.start() + t3.join() + print(t3.join()) + + var_5 = "" + time_1 = "" + channel = "" + cx_time = "" + while True: + if t3.join() == "52": + print("station allocated to 52") + print("now generate radar on 52") + + t4 = threading.Thread(target=dfs.generate_radar_at_ch52()) + t4.start() + t4.join() + + # time.sleep(80) + + print("checking channel assigned...") + th_1 = ThreadWithReturnValue(target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security,args.radio)) + th_1.start() + th_1.join() + print(th_1.join()) + channel = th_1.join() + print("after radar channel is at ", channel) + + if channel == "-1": + print("TEST Fail") + print("AP is at AUTO Channel") + break + else: + print("Test Pass") + + th_2 = ThreadWithReturnValue(target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security,args.radio)) + th_2.start() + th_2.join() + print(th_2.join()) + cx_time = th_2.join() + print("after radar station time is ", cx_time) + break + else: + print("stop") + break + + time.sleep(120) + t9 = ThreadWithReturnValue(target=dfs.check_for_channels(args.ip, args.user, args.pswd)) + t9.start() + t9.join() + var1 = t9.join() + a_list = [] + for i in var1: + a_list.append(i.strip()) + # print("hi", a_list) + + time_11 = "" + var5 = "" + channel_1 = "" + cx_time1 = "" + if any("Channel 100 : 5.5 GHz" in s for s in a_list): + print("set channel to 100") + t10 = threading.Thread(target=dfs.set_channel_in_ap_at_100(args.ip, args.user, args.pswd)) + t10.start() + t10.join() + print("channel set to 100") + + print("channel set checking....") + t31 = ThreadWithReturnValue( + target=dfs.monitor_station_100(args.host, args.ssid, args.passwd, args.security, args.radio)) + t31.start() + t31.join() + print(t31.join()) + + while True: + if t31.join() == "100": + print("station allocated to 100") + print("now generate radar on 100") + + t11 = threading.Thread(target=dfs.generate_radar_at_ch100()) + t11.start() + t11.join() + + # time.sleep(80) + print("checking channel assigned...") + th_1a = ThreadWithReturnValue( + target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security, + args.radio)) + + th_1a.start() + th_1a.join() + print(th_1a.join()) + channel_1 = th_1a.join() + print("after radar channel is at ", channel_1) + + if th_1a.join() == "-1": + print("TEST Fail") + break + else: + print("Test Pass") + th_3 = ThreadWithReturnValue( + target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security, + args.radio)) + th_3.start() + th_3.join() + print(th_3.join()) + cx_time1 = th_3.join() + print("after radar station connection time i ", cx_time1) + break + + else: + print("check for some another channel") + break + + time.sleep(120) + + t19 = ThreadWithReturnValue(target=dfs.check_for_channels(args.ip, args.user, args.pswd)) + t19.start() + t19.join() + var11 = t19.join() + b_list = [] + for i in var11: + b_list.append(i.strip()) + # print("hi", a_list) + + time_12 = "" + var51 = "" + channel_2 = "" + cx_time2 = "" + if any("Channel 120 : 5.6 GHz" in s for s in b_list): + print("set channel to 120") + + t15 = threading.Thread(target=dfs.set_channel_in_ap_at_120(args.ip, args.user, args.pswd)) + t15.start() + t15.join() + print("channel set to 120") + + print("channel set checking....") + t32 = ThreadWithReturnValue( + target=dfs.monitor_station_120(args.host, args.ssid, args.passwd, args.security, args.radio)) + t32.start() + t32.join() + print(t32.join()) + while True: + if t32.join() == "120": + print("station allocated to 120") + print("now generate radar on 120") + + t16 = threading.Thread(target=dfs.generate_radar_at_ch120()) + t16.start() + t16.join() + + # time.sleep(80) + + print("checking channel assigned...") + thr1 = ThreadWithReturnValue( + target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security, + args.radio)) + thr1.start() + thr1.join() + print(thr1.join()) + channel_2 = thr1.join() + print("after radar channel is at ", channel_2) + + if thr1.join() == "-1": + print("TEST Fail") + break + else: + print("Test Pass") + th_4 = ThreadWithReturnValue( + target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security, + args.radio)) + th_4.start() + th_4.join() + print(th_4.join()) + cx_time2 = th_4.join() + print("after radar station connection time is ", cx_time2) + break + else: + print("stop") + break + + # channel list + ch_list = [] + ch_list.extend((channel, channel_1, channel_2)) + print("after radar switched channel list ", ch_list) + + cha_list = ["52", "100", "120"] + print("test channel list", cha_list) + + time_ass = [] + time_ass.extend((cx_time, cx_time1, cx_time2)) + print("list of connection time", time_ass) + + + """ch_list = ['44', '36', '120'] + for n, i in enumerate(ch_list): + if i == '': + ch_list[n] = '0' + + # print(ch_list) + for i in range(0, len(ch_list)): + ch_list[i] = int(ch_list[i]) + + # print(ch_list) + cha_list = ['52', '100', '120'] + y_pos = np.arange(len(cha_list)) + + # Create bars and choose color + plt.bar(y_pos, ch_list, color=(0.5, 0.1, 0.5, 0.6)) + + # Add title and axis names + plt.title('channel association') + plt.xlabel('Channels') + plt.ylabel('channel assigned') + + # Limits for the Y axis + plt.ylim(0, 140) + + # Create names + plt.xticks(y_pos, cha_list) + + # Show graphic + #plt.show() + plt.savefig("channel.png")""" + + ############################################################################### + + time_ass = ['23348', '19126', ''] + for n, i in enumerate(time_ass): + if i == '': + time_ass[n] = '0' + + # print(ch_list) + for i in range(0, len(time_ass)): + time_ass[i] = int(time_ass[i]) + + # seconds = microseconds ÷ 1,000,000 + for i in range(0, len(time_ass)): + time_ass[i] = time_ass[i] / 1000 + + cha_list = ['52', '100', '120'] + y_pos = np.arange(len(cha_list)) + + # Create bars and choose color + plt.bar(y_pos, time_ass, color=(0.5, 0.1, 0.5, 0.6)) + + # Add title and axis names + plt.title('connection time') + plt.xlabel('Channels') + plt.ylabel('association time (milliseconds)') + + # Limits for the Y axis + plt.ylim(0, 100) + + # Create names + plt.xticks(y_pos, cha_list) + + # Show graphic + #plt.show() + plt.savefig("/home/lanforge/lanforge-scripts/py-scripts/time.png") + '''data = "pass" + data_1 = "Fail" + data_2 = "pass" + ch_list = ['44', '36', '120']''' + for i in range(0, len(time_ass)): + time_ass[i] = str(time_ass[i]) + + if ch_list[0] == "52" or ch_list[0] == "-1" or ch_list[0] == "" or ch_list[0] == "0": + data = "FAIL" + else: + data = "PASS" + + if ch_list[1] == "100" or ch_list[1] == "-1" or ch_list[1] == "" or ch_list[1] == "0": + data_1 = "FAIL" + else: + data_1 = "PASS" + + if ch_list[2] == "120" or ch_list[2] == "-1" or ch_list[2] == "" or ch_list[2] == "0": + data_2 = "FAIL" + else: + data_2 = "PASS" + + + + now = datetime.now() + print("Current date and time : ") + date_1 = now.strftime("%Y-%m-%d %H:%M:%S") + + html_content = "DFS TEST

Dynamic Frequency Selection

" \ + "

" + date_1 + "



Objective

The DFS Test is designed to test the Performance of the Netgear Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1
" \ + "

Graph


Detailed Results
Client NameChannelSwitched Channelstation association time(milliseconds)Result
sta000052"+ ch_list[0] +""+ time_ass[0] +""+ data +"
sta0000100"+ ch_list[1] + ""+ time_ass[1] +""+ data_1 +"
sta0000120"+ ch_list[2] +""+ time_ass[2] +""+ data_2 +"
" + + file = open("dfs.html", "w") + file.write(html_content) + file.close() + + print("Test Finished") + +if __name__ == '__main__': + main() From 603201bc139c6b33a411ec3729c7a10cbb9008e7 Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Wed, 27 Jan 2021 16:36:36 +0530 Subject: [PATCH 144/848] Netear Dfs Test --- py-scripts/netgear_dfs_test.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/py-scripts/netgear_dfs_test.py b/py-scripts/netgear_dfs_test.py index 8e6bdeae..f70742f1 100644 --- a/py-scripts/netgear_dfs_test.py +++ b/py-scripts/netgear_dfs_test.py @@ -1,3 +1,7 @@ +''' This script uses Netgear AP for DFS testing +''' + + import os import paramiko import time @@ -384,15 +388,6 @@ class DFS_Test: var_1 = (var['interface']['cx time (us)']) return var_1 - def convert_to_sec(self, time_string): - self.time_string = time_string - date_time = datetime.datetime.strptime(self.time_string, "%H:%M:%S") - - print(date_time) - - a_timedelta = date_time - datetime.datetime(1900, 1, 1) - seconds = a_timedelta.total_seconds() - return seconds class ThreadWithReturnValue(Thread): @@ -755,7 +750,7 @@ def main(): "

" + date_1 + "



Objective

The DFS Test is designed to test the Performance of the Netgear Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1
" \ "

Graph


Detailed Results
Client NameChannelSwitched Channelstation association time(milliseconds)Result
sta000052"+ ch_list[0] +""+ time_ass[0] +""+ data +"
sta0000100"+ ch_list[1] + ""+ time_ass[1] +""+ data_1 +"
sta0000120"+ ch_list[2] +""+ time_ass[2] +""+ data_2 +"
" - file = open("dfs.html", "w") + file = open("/home/lanforge/lanforge-scripts/py-scripts/dfs.html", "w") file.write(html_content) file.close() From fdcd9fdd9cb3b4904adcac08fd78d437f4561770 Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Wed, 27 Jan 2021 18:46:05 +0530 Subject: [PATCH 145/848] Netear Dfs Test --- py-scripts/netgear_dfs_test.py | 47 ++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/py-scripts/netgear_dfs_test.py b/py-scripts/netgear_dfs_test.py index f70742f1..307629f8 100644 --- a/py-scripts/netgear_dfs_test.py +++ b/py-scripts/netgear_dfs_test.py @@ -417,9 +417,19 @@ def main(): parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid') parser.add_argument('-sec', '--security', type=str, help='security') parser.add_argument('-rad', '--radio', type=str, help='radio at which client will be connected') + parser.add_argument('-n', '--name', type=str, help='Type Name of AP on which test is performed') + + + args = parser.parse_args() + if (args.name is not None): + AP_name = args.name + + if(args.ssid is not None): + ssid = args.ssid + dfs = DFS_Test(args.ip, args.user, args.pswd, args.host, args.ssid, args.passwd, args.security, args.radio) # check for last timesnap of ap logs @@ -683,6 +693,7 @@ def main(): #plt.show() plt.savefig("channel.png")""" + ############################################################################### time_ass = ['23348', '19126', ''] @@ -718,10 +729,8 @@ def main(): # Show graphic #plt.show() plt.savefig("/home/lanforge/lanforge-scripts/py-scripts/time.png") - '''data = "pass" - data_1 = "Fail" - data_2 = "pass" - ch_list = ['44', '36', '120']''' + + ch_list = ['44', '36', '120'] for i in range(0, len(time_ass)): time_ass[i] = str(time_ass[i]) @@ -729,6 +738,7 @@ def main(): data = "FAIL" else: data = "PASS" + # print(data) if ch_list[1] == "100" or ch_list[1] == "-1" or ch_list[1] == "" or ch_list[1] == "0": data_1 = "FAIL" @@ -742,15 +752,36 @@ def main(): + now = datetime.now() print("Current date and time : ") date_1 = now.strftime("%Y-%m-%d %H:%M:%S") - html_content = "DFS TEST

Dynamic Frequency Selection

" \ - "

" + date_1 + "



Objective

The DFS Test is designed to test the Performance of the Netgear Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP NameNetgear WAC505
SSIDTestAP22
Number of Clients1
" \ - "

Graph


Detailed Results
Client NameChannelSwitched Channelstation association time(milliseconds)Result
sta000052"+ ch_list[0] +""+ time_ass[0] +""+ data +"
sta0000100"+ ch_list[1] + ""+ time_ass[1] +""+ data_1 +"
sta0000120"+ ch_list[2] +""+ time_ass[2] +""+ data_2 +"
" + if data == "FAIL": + x = " FAIL " + else: + if data == "PASS": + x = " PASS " - file = open("/home/lanforge/lanforge-scripts/py-scripts/dfs.html", "w") + if data_1 == "FAIL": + x_1 = " FAIL " + else: + if data_1 == "PASS": + x_1 = " PASS " + + if data_2 == "FAIL": + x_2 = " FAIL " + else: + if data_2 == "PASS": + x_2 = " PASS " + + + + html_content = "DFS TEST

Dynamic Frequency Selection

" \ + "

" + date_1 + "



Objective

The DFS Test is designed to test the Performance of the Netgear Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP Name" + AP_name + "
SSID" + ssid + "
Number of Clients1
" \ + "

Graph


Detailed Results
" + x + """" + x_1 + "" + x_2 + "
Client NameChannelSwitched Channelstation association time(milliseconds)Result
sta000052"+ ch_list[0] +""+ time_ass[0] +"
sta0000100"+ ch_list[1] + ""+ time_ass[1] +"
sta0000120"+ ch_list[2] +""+ time_ass[2] +"
" + + file = open("/home/lanforge/lanforge-scripts/py-scripts/result.html", "w") file.write(html_content) file.close() From 5b2b811fddee04214e0b43f863c736057aebf7f2 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 07:02:43 -0700 Subject: [PATCH 146/848] lf_cisco_power.py(LCS-48): testing pf_ignore_offset, if power value outside range --- lf_cisco_power.py | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index d07538c4..8e6a605c 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -177,7 +177,7 @@ pf_dbm = 6 # Allow one chain to have a lower signal, since customer's DUT has # lower tx-power on one chain when doing high MCS at 4x4. -pf_a4_dropoff = 100 +pf_ignore_offset = 100 # Threshold for allowing a pass failed_low_threshold = 0 @@ -217,7 +217,7 @@ def usage(): print("--antenna_gain: Antenna gain for AP, if no Antenna attached then antenna gain needs to be taken into account, default 0") print("--band: Select band (a | b | abgn), a means 5Ghz, b means 2.4, abgn means 2.4 on dual-band AP, default a") print("--pf_dbm: Pass/Fail range, default is 6") - print("--pf_a4_dropoff: Allow one chain to use lower tx-power and still pass when doing 4x4, default 100. so disabled") + print("--pf_ignore_offset: Allow one chain to use lower tx-power and still pass when doing 4x4, default 100. so disabled") print("--wait_forever: Wait forever for station to associate, may aid debugging if STA cannot associate properly") print("--adjust_nf: Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") print("--wlan: for 9800, wlan identifier ") @@ -273,7 +273,7 @@ def main(): global full_outfile global upstream_port global pf_dbm - global pf_a4_dropoff + global pf_ignore_offset global failed_low_threshold scheme = "ssh" @@ -305,7 +305,7 @@ def main(): parser.add_argument("--band", type=str, help="Select band (a | b), a means 5Ghz, b means 2.4Ghz. Default is a", choices=["a", "b", "abgn"]) parser.add_argument("--pf_dbm", type=str, help="Pass/Fail threshold. Default is 6",default="6" ) - parser.add_argument("--pf_a4_dropoff", type=str, help="Allow a chain to have lower tx-power and still pass. default 100 so disabled",default="100") + parser.add_argument("--pf_ignore_offset", type=str, help="Allow a chain to have lower tx-power and still pass. default 100 so disabled",default="100") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier",required=True) @@ -364,8 +364,8 @@ def main(): band = "a" if (args.pf_dbm != None): pf_dbm = int(args.pf_dbm) - if (args.pf_a4_dropoff != None): - pf_a4_dropoff = int(args.pf_a4_dropoff) + if (args.pf_ignore_offset != None): + pf_ignore_offset = int(args.pf_ignore_offset) if (args.verbose): # capture the controller output , thus won't go to stdout some output always present cap_ctl_out = False @@ -1578,19 +1578,19 @@ def main(): # Read AP to determine if there are less chains or spatial steams then expected # Thus provide a passing result failed_low = 0 - least = 0 + # least = 0 if (diff_a1 < -pfrange): failed_low += 1 - least = diff_a1 + #least = diff_a1 #leave in code if want to move to least if (diff_a2 < -pfrange): failed_low += 1 - least = min(least, diff_a2) + #least = min(least, diff_a2) if (diff_a3 < -pfrange): failed_low += 1 - least = min(least, diff_a3) + #least = min(least, diff_a3) if (diff_a4 < -pfrange): failed_low += 1 - least = min(least, diff_a4) + #least = min(least, diff_a4) failed_low_threshold = 0 # @@ -1691,12 +1691,22 @@ def main(): if failed_low > failed_low_threshold: logg.info("failed_low: {} > failed_low_threshold: {}".format(failed_low,failed_low_threshold)) pf = 0 - # if the AP is not read for number of spatial streams + # a value may be put in that if the spatial stream is less # then it will still count as a failure - logg.info("least: {} pfrange: {} pf_a4_dropoff: {}".format(least, pfrange, pf_a4_dropoff)) - if(least < (-pfrange - pf_a4_dropoff)) and int(pf_a4_dropoff) != 100: - logg.info("least: {} < -pfrange: {} - pf_a4_dropoff: {}".format(least, pfrange, pf_a4_dropoff)) + logg.info("pf_ignore_offset: {} if set to 100 will not evaluate spatial stream for pf_ignore_offset") + logg.info("diff_a1: {} diff_a2: {} diff_a3: {} diff_a4: {} pfrange: {} pf_ignore_offset: {}".format(diff_a1,diff_a2,diff_a3,diff_a4,pfrange,pf_ignore_offset)) + if(diff_a1 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: + logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) + pf = 0 + if(diff_a2 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: + logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) + pf = 0 + if(diff_a3 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: + logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) + pf = 0 + if(diff_a4 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: + logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) pf = 0 if (diff_a1 > pfrange): From a6affe7ca90fca0637259f8295e07bd203b14104 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 07:42:04 -0700 Subject: [PATCH 147/848] lf_cisco_power.py(LCS-48): set the power value to ignore to 0 from 100 --- lf_cisco_power.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 8e6a605c..bfaa0867 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -177,7 +177,7 @@ pf_dbm = 6 # Allow one chain to have a lower signal, since customer's DUT has # lower tx-power on one chain when doing high MCS at 4x4. -pf_ignore_offset = 100 +pf_ignore_offset = 0 # Threshold for allowing a pass failed_low_threshold = 0 @@ -305,7 +305,7 @@ def main(): parser.add_argument("--band", type=str, help="Select band (a | b), a means 5Ghz, b means 2.4Ghz. Default is a", choices=["a", "b", "abgn"]) parser.add_argument("--pf_dbm", type=str, help="Pass/Fail threshold. Default is 6",default="6" ) - parser.add_argument("--pf_ignore_offset", type=str, help="Allow a chain to have lower tx-power and still pass. default 100 so disabled",default="100") + parser.add_argument("--pf_ignore_offset", type=str, help="Allow a chain to have lower tx-power and still pass. default 0 so disabled",default="0") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier",required=True) @@ -1694,21 +1694,29 @@ def main(): # a value may be put in that if the spatial stream is less # then it will still count as a failure - logg.info("pf_ignore_offset: {} if set to 100 will not evaluate spatial stream for pf_ignore_offset") logg.info("diff_a1: {} diff_a2: {} diff_a3: {} diff_a4: {} pfrange: {} pf_ignore_offset: {}".format(diff_a1,diff_a2,diff_a3,diff_a4,pfrange,pf_ignore_offset)) - if(diff_a1 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: - logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) - pf = 0 - if(diff_a2 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: - logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) - pf = 0 - if(diff_a3 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: - logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) - pf = 0 - if(diff_a4 < (-pfrange - pf_ignore_offset)) and int(pf_ignore_offset) != 100: - logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) - pf = 0 + if (diff_a1 < -pfrange): + if(diff_a1 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) + else: + pf = 0 + if (diff_a1 < -pfrange): + if(diff_a2 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) + else: + pf = 0 + if (diff_a3 < -pfrange): + if(diff_a3 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) + else: + pf = 0 + if (diff_a4 < -pfrange): + if(diff_a4 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) + else: + pf = 0 + # check for range to high if (diff_a1 > pfrange): pf = 0 if (diff_a2 > pfrange): From 6de4d545f56d4866823f560fc5ba07b83ad9bc46 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 08:08:01 -0700 Subject: [PATCH 148/848] lf_cisco_power.py(LCS-48): allow both AP and ignore offset to be used concurrently --- lf_cisco_power.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index bfaa0867..3c2e34f4 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1687,8 +1687,11 @@ def main(): # The controller may adjust the number of spatial streams to allow for the # best power values # + # for 4 spatial streams if the AP is read and the failed threshold is met then there is a failure + # the failure will be caugh below if the range is not correct. + # range check and reading the data from the AP may be used in conjunction thus it is coded to be non-exclusive logg.info("failed_low: {} failed_low_threshold: {}".format(failed_low,failed_low_threshold)) - if failed_low > failed_low_threshold: + if bool(ap_dict) and failed_low > failed_low_threshold: logg.info("failed_low: {} > failed_low_threshold: {}".format(failed_low,failed_low_threshold)) pf = 0 From 15217c4d22f41a24cb2e65b4a095f0c8a0c8d4df Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 09:14:18 -0700 Subject: [PATCH 149/848] lf_cisco_power.py(LCS-48): updated comments for failures --- lf_cisco_power.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 3c2e34f4..81d0dadd 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1702,21 +1702,25 @@ def main(): if(diff_a1 < (-pfrange - pf_ignore_offset)): logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) else: + logg.info("diff_a1: {} failure".format(diff_a1)) pf = 0 - if (diff_a1 < -pfrange): + if (diff_a2 < -pfrange): if(diff_a2 < (-pfrange - pf_ignore_offset)): logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) else: + logg.info("diff_a2: {} failure".format(diff_a2)) pf = 0 if (diff_a3 < -pfrange): if(diff_a3 < (-pfrange - pf_ignore_offset)): logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) else: + logg.info("diff_a3: {} failure".format(diff_a3)) pf = 0 if (diff_a4 < -pfrange): if(diff_a4 < (-pfrange - pf_ignore_offset)): logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) else: + logg.info("diff_a4: {} failure".format(diff_a4)) pf = 0 # check for range to high From 12112b3e92f1603603b03b885aec71d14e2a3198 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 11:40:00 -0700 Subject: [PATCH 150/848] lf_cisco_power.py(LCS-48): added notes to information if PASS due to pf_ignore_offset --- lf_cisco_power.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 81d0dadd..5890aa48 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1701,24 +1701,32 @@ def main(): if (diff_a1 < -pfrange): if(diff_a1 < (-pfrange - pf_ignore_offset)): logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) + i_tot = "PASSED diff_a1({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a1, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) else: logg.info("diff_a1: {} failure".format(diff_a1)) pf = 0 if (diff_a2 < -pfrange): if(diff_a2 < (-pfrange - pf_ignore_offset)): logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) + i_tot = "PASSED diff_a2({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a2, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) else: logg.info("diff_a2: {} failure".format(diff_a2)) pf = 0 if (diff_a3 < -pfrange): if(diff_a3 < (-pfrange - pf_ignore_offset)): logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) + i_tot = "PASSED diff_a3({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a3, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) else: logg.info("diff_a3: {} failure".format(diff_a3)) pf = 0 if (diff_a4 < -pfrange): if(diff_a4 < (-pfrange - pf_ignore_offset)): logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) + i_tot = "PASSED diff_a4({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a4, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) else: logg.info("diff_a4: {} failure".format(diff_a4)) pf = 0 From ab851dba7cdeb14ec825cac926d60e25e43c4692 Mon Sep 17 00:00:00 2001 From: Dipti Date: Wed, 27 Jan 2021 13:10:58 -0800 Subject: [PATCH 151/848] addition of report comparison in ipv4_var_time --- py-json/realm.py | 5 ++++- py-scripts/test_ipv4_variable_time.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index b2b12a8a..905a6c04 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1143,7 +1143,8 @@ class L3CXProfile(BaseProfile): report_file=None, output_format=None, script_name=None, - arguments=None): + arguments=None, + compared_report=None): try: duration_sec = self.parse_time(duration_sec).seconds except: @@ -1237,6 +1238,8 @@ class L3CXProfile(BaseProfile): df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int) df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S")) df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] + #compare previous data to current data + try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index b8a9ed02..d642e7db 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -192,7 +192,8 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['name','tx bytes', 'rx bytes','dropped']) + optional_args.add_argument('--col_names', help='Columns wished to be monitor', default=['name','tx bytes', 'rx bytes','dropped']) + optional_args.add_argument('--compared_report',help='report path and file which is wished to be compared with new report', default=None) args = parser.parse_args() num_sta = 2 @@ -221,6 +222,15 @@ python3 ./test_ipv4_variable_time.py output=str(args.report_file).split('.')[-1] else: output=args.output_format + #Retrieve last data file + if args.compared_report: + #check if last report format is same as current rpt format + last_report_format = args.compared_report.split('.')[-1] + if output == last_report_format: + compared_rept = args.compared_report + else: + ValueError("Compared report format is not the same as the new report format. Please make sure they are of the same file type.") + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_var_test = IPV4VariableTime(host=args.mgr, @@ -262,6 +272,7 @@ python3 ./test_ipv4_variable_time.py duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, output_format=output, + compared_report=compared_rept, script_name='test_ipv4_variable_time', arguments=args) From 7d24db418ded5060f5115cf7dc7c5b78343872b8 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 14:58:24 -0700 Subject: [PATCH 152/848] lf_cisco_power.py(LCS-48): ignore pf_ignore_offset when == 0 (causes everything to pass if that is the case) --- lf_cisco_power.py | 73 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 5890aa48..0d6fe3d7 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -1675,7 +1675,7 @@ def main(): - i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}".format( + i_tot = "P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {} ".format( P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr) print(i_tot) logg.info(i_tot) @@ -1694,42 +1694,41 @@ def main(): if bool(ap_dict) and failed_low > failed_low_threshold: logg.info("failed_low: {} > failed_low_threshold: {}".format(failed_low,failed_low_threshold)) pf = 0 - - # a value may be put in that if the spatial stream is less - # then it will still count as a failure - logg.info("diff_a1: {} diff_a2: {} diff_a3: {} diff_a4: {} pfrange: {} pf_ignore_offset: {}".format(diff_a1,diff_a2,diff_a3,diff_a4,pfrange,pf_ignore_offset)) - if (diff_a1 < -pfrange): - if(diff_a1 < (-pfrange - pf_ignore_offset)): - logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) - i_tot = "PASSED diff_a1({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a1, pfrange, pf_ignore_offset) - logg.info("i_tot {}".format(i_tot)) - else: - logg.info("diff_a1: {} failure".format(diff_a1)) - pf = 0 - if (diff_a2 < -pfrange): - if(diff_a2 < (-pfrange - pf_ignore_offset)): - logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) - i_tot = "PASSED diff_a2({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a2, pfrange, pf_ignore_offset) - logg.info("i_tot {}".format(i_tot)) - else: - logg.info("diff_a2: {} failure".format(diff_a2)) - pf = 0 - if (diff_a3 < -pfrange): - if(diff_a3 < (-pfrange - pf_ignore_offset)): - logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) - i_tot = "PASSED diff_a3({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a3, pfrange, pf_ignore_offset) - logg.info("i_tot {}".format(i_tot)) - else: - logg.info("diff_a3: {} failure".format(diff_a3)) - pf = 0 - if (diff_a4 < -pfrange): - if(diff_a4 < (-pfrange - pf_ignore_offset)): - logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) - i_tot = "PASSED diff_a4({}) < -pfrange({}) - pf_ignore_offset({})".format(diff_a4, pfrange, pf_ignore_offset) - logg.info("i_tot {}".format(i_tot)) - else: - logg.info("diff_a4: {} failure".format(diff_a4)) - pf = 0 + + if(pf_ignore_offset != 0): + logg.info("diff_a1: {} diff_a2: {} diff_a3: {} diff_a4: {} pfrange: {} pf_ignore_offset: {}".format(diff_a1,diff_a2,diff_a3,diff_a4,pfrange,pf_ignore_offset)) + if (diff_a1 < -pfrange): + if(diff_a1 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a1: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a1, pfrange, pf_ignore_offset)) + i_tot += "PASSED diff_a1({}) < -pfrange({}) - pf_ignore_offset({}) ".format(diff_a1, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) + else: + logg.info("diff_a1: {} failure".format(diff_a1)) + pf = 0 + if (diff_a2 < -pfrange): + if(diff_a2 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a2: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a2, pfrange, pf_ignore_offset)) + i_tot += "PASSED diff_a2({}) < -pfrange({}) - pf_ignore_offset({}) ".format(diff_a2, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) + else: + logg.info("diff_a2: {} failure".format(diff_a2)) + pf = 0 + if (diff_a3 < -pfrange): + if(diff_a3 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a3: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a3, pfrange, pf_ignore_offset)) + i_tot += "PASSED diff_a3({}) < -pfrange({}) - pf_ignore_offset({}) ".format(diff_a3, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) + else: + logg.info("diff_a3: {} failure".format(diff_a3)) + pf = 0 + if (diff_a4 < -pfrange): + if(diff_a4 < (-pfrange - pf_ignore_offset)): + logg.info("diff_a4: {} < -pfrange: {} - pf_ignore_offset: {}".format(diff_a4, pfrange, pf_ignore_offset)) + i_tot += "PASSED diff_a4({}) < -pfrange({}) - pf_ignore_offset({}) ".format(diff_a4, pfrange, pf_ignore_offset) + logg.info("i_tot {}".format(i_tot)) + else: + logg.info("diff_a4: {} failure".format(diff_a4)) + pf = 0 # check for range to high if (diff_a1 > pfrange): From f5b1fae73ed3a1cb70ab9fc523c71239bbef746f Mon Sep 17 00:00:00 2001 From: Dipti Date: Wed, 27 Jan 2021 15:10:57 -0800 Subject: [PATCH 153/848] continuation of old csv and new csv file comparison --- py-json/realm.py | 26 ++++++++++++++++++++++++++ py-scripts/test_ipv4_variable_time.py | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 905a6c04..e3f8fff9 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1166,6 +1166,32 @@ class L3CXProfile(BaseProfile): raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) else: output_format = report_file.split('.')[-1] + #retrieve compared report if specified - turn into dataframe + if compared_report is not None: + compared_format = compared_report.split('.')[-1] + #initial dataframe + previous_data_df = pd.DataFrame() + if compared_format == 'hdf': + #df.to_hdf(report_file, 'table', append=True) + continue + if compared_format == 'parquet': + #df.to_parquet(report_file, engine='pyarrow') + continue + if compared_format == 'png': + #fig = df.plot().get_figure() + #fig.savefig(report_file) + continue + if compared_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': + continue + if compared_format == 'df': + #return df + continue + supported_formats = ['csv', 'json', 'stata', 'pickle','html'] + for format in supported_formats: + if compared_format.lower() == format: + # exec('df.to_' + x + '("' + report_file + '",index=False' + ')') + previous_data_df= read_csv() + # Step 1, column names fields=None diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index d642e7db..7edc3994 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -168,7 +168,8 @@ python3 ./test_ipv4_variable_time.py --b_min 1000 --ap "00:0e:8e:78:e1:76" --output_format csv - --report_file ~/Documents/results.csv (if csv file - please use another extension for other files) + --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other files) + --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) --debug ''') From 5b2ae53da6441a3a94f076717159f4c524de6fa5 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 27 Jan 2021 17:14:50 -0700 Subject: [PATCH 154/848] lf_cisco_power.py : added working examples to epilogue --- lf_cisco_power.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 0d6fe3d7..38d376e5 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -6,6 +6,26 @@ Controller is 192.1.0.10 AP is 192.1.0.2''' EPILOG = '''\ + +############################################################################################## +# Support History +############################################################################################## + +############################################################################## +Sample script to run create station, wlan and talk to ap 1/26/2021 run on 9800 +carriage returns specifically left out +############################################################################## +./lf_cisco_power.py -d 172.19.27.55 -u admin -p Wnbulab@123 --port 2013 --scheme telnet --ap 9120_Candela --bandwidth "20" --channel "52 100 104" --nss 4 --txpower "1" --pathloss 56 --antenna_gain 6 --band a --upstream_port eth2 --series 9800 --radio wiphy5 --slot 1 --ssid open-wlan --prompt "katar_candela" --create_station sta0001 --ssidpw [BLANK] --security open --verbose --wlan open-wlan --wlanID 1 --wlanSSID open-wlan --ap_info "ap_scheme==telnet ap_prompt==9120_Candela ap_ip==172.19.27.55 ap_port==2008 ap_user==admin ap_pw==Wnbulab@123" + + + +############################################################# +Sample to test pf_ignore_offset switch 1/27/2021 run on 9800 +carriage returns specifically left out +############################################################# +./lf_cisco_power.py -d 172.19.27.55 -u admin -p Wnbulab@123 --port 2013 --scheme telnet --ap 9120_Candela --bandwidth "20" --channel "36 52 100 104 161" --nss 4 --txpower "1" --pathloss 56 --antenna_gain 6 --band a --upstream_port eth2 --series 9800 --radio wiphy5 --slot 1 --ssid open-wlan --prompt "katar_candela" --create_station sta0001 --ssidpw [BLANK] --security open --verbose --wlan open-wlan --wlanID 1 --wlanSSID open-wlan --pf_ignore_offset "35" + + ############################################################################################## ############################################################################################## From 1cb6459e1c85d6210147e67bbd11d42cd7cc215c Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 26 Jan 2021 20:15:17 -0800 Subject: [PATCH 155/848] realm: adds new_vr_profile() and fixes a debug flag --- py-json/realm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/py-json/realm.py b/py-json/realm.py index aefbce39..5174d691 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -817,6 +817,13 @@ class Realm(LFCliBase): def new_test_group_profile(self): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) + def new_vr_profile(self): + profile = VRProfile(parent_realm=self, + debug=self.debug, + halt_on_error=self.halt_on_error, + exit_on_error=self.exit_on_error) + return profile + class BaseProfile(LFCliBase): def __init__(self,local_realm): self.parent_realm=local_realm @@ -2320,6 +2327,8 @@ class VRProfile(LFCliBase): suppress_related_commands_=True): # Create vr + if self.debug: + debug = True if self.vr_name is not None: self.add_vr_data["alias"] = self.vr_name self.local_realm.json_post("add_vr", self.add_vr_data, debug_=debug) From 9a37ba42febf6fc509ddc41719483449eb710c77 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 26 Jan 2021 20:17:04 -0800 Subject: [PATCH 156/848] lfcli_base.py: create_bare_argparse updates defaults for formatter --- py-json/LANforge/lfcli_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index a280adcc..fac37d88 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -461,7 +461,10 @@ class LFCliBase: # zelf.adjust_proxy(values) @staticmethod - def create_bare_argparse(prog=None, formatter_class=None, epilog=None, description=None): + def create_bare_argparse(prog=None, + formatter_class=argparse.RawTextHelpFormatter, + epilog=None, + description=None): if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None): parser = argparse.ArgumentParser(prog=prog, formatter_class=formatter_class, From 114ec7c2abd7e3ab289fe825c99c0f901ca2dbc1 Mon Sep 17 00:00:00 2001 From: shivam Date: Sun, 17 Jan 2021 22:11:31 +0530 Subject: [PATCH 157/848] status-msg updates --- py-scripts/connection_test.py | 150 ++++++++++++++++------------------ py-scripts/test_utility.py | 49 +++++++---- 2 files changed, 103 insertions(+), 96 deletions(-) diff --git a/py-scripts/connection_test.py b/py-scripts/connection_test.py index ef52e6f9..1719bd6d 100644 --- a/py-scripts/connection_test.py +++ b/py-scripts/connection_test.py @@ -1,9 +1,7 @@ """ Candela Technologies Inc. -Info : Standard Script for Connection Testing -Date : -Author : Shivam Thakur +Info : Standard Script for Connection Testing - Creates HTML and pdf report as a result (Used for web-console) """ @@ -22,7 +20,8 @@ import datetime import time import os from test_utility import CreateHTML -from test_utility import RuntimeUpdates +# from test_utility import RuntimeUpdates +from test_utility import StatusMsg import pdfkit webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) @@ -31,12 +30,11 @@ class ConnectionTest(LFCliBase): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio="wiphy1", sta_prefix="sta", start_id=0, num_sta=2, - dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="eth1", _test_update=None, name_prefix="L3Test", + dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="eth1", name_prefix="L3Test", session_id="Layer3Test", test_name="Client/s Connectivity Test", pass_criteria=20, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - print("Test is about to start") self.host = lfclient_host self.port = lfclient_port self.radio = radio @@ -53,37 +51,34 @@ class ConnectionTest(LFCliBase): self.session_id = session_id self.test_name = test_name self.test_duration = 1 - self.test_update = _test_update self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) self.station_profile = self.local_realm.new_station_profile() self.pass_fail = "" - + self.status_msg = StatusMsg(lfclient_host=self.host, lfclient_port=self.port, session_id=self.session_id) station_list = [] for i in range(0, self.num_sta): station_list.append(self.sta_prefix + str(i).zfill(4)) - print(station_list) self.station_data = dict.fromkeys(station_list) for i in station_list: self.station_data[i] = "None" - print(self.station_data) - - self.test_update.send_update({"test_status": '1', "data": 'None', "data": [], "label": "Client Connectivity Time"}) + try: + self.status_msg.update('1', {"data": 'Initializing...', "data": [], "label": "Client Connectivity Time"}) + except: + pass self.reports_path = webconsole_dir+"/reports/" + self.test_name + "_" + self.session_id + '/' - print(self.reports_path) if not os.path.exists(self.reports_path): os.makedirs(self.reports_path) - print("Test is Initialized") self.station_list = LFUtils.portNameSeries(prefix_=self.sta_prefix, start_id_=self.sta_start_id, end_id_=self.num_sta - 1, padding_number_=10000, radio=self.radio) - print(self.station_profile.station_names) - self.test_update.send_update({"test_status": '2', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('2', {"data": 'Initialized...', "data": [], "label": "Client Connectivity Time"}) + except: + pass def precleanup(self): - print("precleanup started") sta_list = [] for i in self.local_realm.station_list(): if (list(i.keys())[0] == '1.1.wlan0'): @@ -92,19 +87,18 @@ class ConnectionTest(LFCliBase): pass else: sta_list.append(list(i.keys())[0]) - print(sta_list) for sta in sta_list: self.local_realm.rm_port(sta, check_exists=True) time.sleep(1) LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) - print("precleanup done") - self.test_update.send_update({"test_status": '3', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('3', {"data": 'Building...', "data": [], "label": "Client Connectivity Time"}) + except: + pass def build(self): - print("Building Test Configuration") self.station_profile.use_security(self.security, self.ssid, self.password) self.station_profile.set_number_template("00") self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) @@ -113,18 +107,19 @@ class ConnectionTest(LFCliBase): self.station_profile.create(radio=self.radio, sta_names_=self.station_list, debug=self.debug) self.local_realm.wait_until_ports_appear(sta_list=self.station_list) self.update(status="build complete") - print("Test Build done") - self.test_update.send_update({"test_status": '4', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('4', {"data": 'Starting...', "data": [], "label": "Client Connectivity Time"}) + except: + pass def update(self, status="None"): for i in self.station_list: - print(self.json_get("port/1/1/" + i + "/?fields=ip,ap,down")) self.station_data[i.split(".")[2]] = \ self.json_get("port/1/1/" + i.split(".")[2] + "/?fields=ip,ap,down,phantom&cx%20time%20(us)")['interface'] - self.test_update.send_update({"test_status": '5', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - - def start(self, print_pass=False, print_fail=False): - print("Test is starting") + try: + self.status_msg.update('5', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass + def start(self): self.station_profile.admin_up() associated_map = {} self.ip_map = {} @@ -134,7 +129,7 @@ class ConnectionTest(LFCliBase): for sta_name in self.station_profile.station_names: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=port,alias,ip,ap", debug_=self.debug) - print(sta_status) + if (sta_status is None or sta_status['interface'] is None) or (sta_status['interface']['ap'] is None): continue if (len(sta_status['interface']['ap']) == 17) and (sta_status['interface']['ap'][-3] == ':'): @@ -147,65 +142,50 @@ class ConnectionTest(LFCliBase): else: time.sleep(1) - if self.debug: - print("sta_list", len(self.station_profile.station_names), self.station_profile.station_names) - print("ip_map", len(self.ip_map), self.ip_map) - print("associated_map", len(associated_map), associated_map) + if (len(self.station_profile.station_names) == len(self.ip_map)) and ( len(self.station_profile.station_names) == len(associated_map)): - self._pass("PASS: All stations associated with IP", print_pass) - print("Test Passed") + + #("Test Passed") for sta_name in self.station_profile.station_names: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) + #(sta_status) while sta_status['interface']['cx time (us)'] == 0: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) + # #(sta_status) continue cx_time[sta_name] = sta_status['interface']['cx time (us)'] else: - self._fail("FAIL: Not all stations able to associate/get IP", print_fail) - print("sta_list", self.station_profile.station_names) - print("ip_map", self.ip_map) for sta_name in self.ip_map.keys(): sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) while sta_status['interface']['cx time (us)'] == 0: sta_status = self.json_get("port/1/1/" + str(sta_name).split(".")[2] + "?fields=cx%20time%20(us)", debug_=self.debug) - print(sta_status) + # #(sta_status) continue cx_time[sta_name] = sta_status['interface']['cx time (us)'] - print("associated_map", associated_map) - print("Test Failed") - print(self.ip_map) - print(associated_map) - print("cx time:", cx_time) self.test_result_data = [] self.keys = ["Client Name", "BSSID", "Channel", "Connection Time (ms)", "DHCP (ms)", "IPv4 Address", "MAC Address", "Mode", "Result"] for sta_name in self.station_profile.station_names: sta_status = self.json_get( "port/1/1/" + str(sta_name).split(".")[2] + "?fields=alias,ap,channel,cx%20time%20(us),ip,mac,mode,dhcp%20(ms)", debug_=self.debug) - print("ironman") - print(sta_status['interface']) self.test_result_data.append(sta_status['interface']) - print(self.test_result_data) offset = 0 self.chart_data = {} for data in self.test_result_data: - if (data["cx time (us)"]/1000 <= self.pass_criteria) and (data["cx time (us)"]/1000 > 0): - self.chart_data[data['alias']] = data["cx time (us)"]/1000 + if (int(data["cx time (us)"])/1000 <= self.pass_criteria) and (int(data["cx time (us)"])/1000 > 0): + self.chart_data[data['alias']] = float(data["cx time (us)"])/1000 data['Result'] = "PASS" else: - self.chart_data[data['alias']] = data["cx time (us)"] / 1000 + self.chart_data[data['alias']] = float(data["cx time (us)"]) / 1000 offset +=1 data['Result'] = "FAIL" - data["cx time (us)"] = str(data["cx time (us)"]/1000)+" / "+str(self.pass_criteria)+"ms" + data["cx time (us)"] = str(float(data["cx time (us)"])/1000)+" / "+str(self.pass_criteria)+"ms" objective = 'The Client Connectivity Test is designed to test the Performance of the Access Point. It will tell the Average Connection time that station takes to connect to Wifi Access Point. It will tell you Pass/Fail Criteria and detailed Report for Client Connection' @@ -223,26 +203,31 @@ class ConnectionTest(LFCliBase): chart_params={"chart_head": "Client Connection Time", "xlabel": "Clients", "ylabel": "Connection Time"}) self.html.write(self.html_data.report) self.html.close() + options = { + "enable-local-file-access": None + } + pdfkit.from_file(self.reports_path + self.test_name + "_" + self.session_id + ".html", + self.reports_path + self.test_name + "_" + self.session_id + '_report.pdf', options=options) - self.test_update.send_update({"test_status": '6', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('6', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass def stop(self): - print("Stopping Test") self.station_profile.admin_down() LFUtils.wait_until_ports_admin_down(port_list=self.station_profile.station_names) - self.test_update.send_update({"test_status": '7', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + try: + self.status_msg.update('7', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass def postcleanup(self): - self.station_profile.cleanup() - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, - port_list=self.station_profile.station_names, - debug=self.debug) - print("Test Completed") - self.test_update.send_update({"test_status": '8', "data": 'None', "data": [], "label": "Client Connectivity Time"}) - + self.station_profile.cleanup(delay=1) + try: + self.status_msg.update('8', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) + except: + pass def main(): - # This has --mgr, --mgr_port and --debug parser = LFCliBase.create_bare_argparse(prog="connection_test.py", formatter_class=argparse.RawTextHelpFormatter, epilog="About This Script") @@ -251,27 +236,34 @@ def main(): parser.add_argument('--passwd', help='--passwd of dut', default="[BLANK]") parser.add_argument('--radio', help='--radio to use on LANforge', default="wiphy1") parser.add_argument('--security', help='--security of dut', default="open") - parser.add_argument('--session_id', help='--session_id is for websocket', default="local") + parser.add_argument('--session_id', help='--session_id is for websocket', default=getSessionID()) parser.add_argument('--test_name', help='--test_name is for webconsole reports', default="Client Connectivity Test") parser.add_argument('--num_clients', type=int, help='--num_sta is number of stations you want to create', default=2) - parser.add_argument('--pass_criteria', type=int, help='--pass_criteria is pass criteria for connection Time', default=50) + parser.add_argument('--pass_criteria', type=int, help='--pass_criteria is pass criteria for connection Time', default=300) args = parser.parse_args() - # args.session_id = "local"; - print(args) - update = RuntimeUpdates(args.session_id, {"test_status": '0', "data": 'None', "data": [], "label": "Client Connectivity Time"}) + # Start Test - obj = ConnectionTest(lfclient_host="192.168.200.12", lfclient_port=args.mgr_port, + obj = ConnectionTest(lfclient_host=args.mgr, lfclient_port=args.mgr_port, session_id=args.session_id, test_name=args.test_name, dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, - num_sta=args.num_clients, radio=args.radio, pass_criteria=args.pass_criteria, _test_update=update) + num_sta=args.num_clients, radio=args.radio, pass_criteria=args.pass_criteria) obj.precleanup() obj.build() obj.start() obj.stop() obj.postcleanup() - print(obj.chart_data) - update.send_update({"test_status": '10', "data": obj.chart_data, "label": ["Client Names","Client Connectivity Time (ms)"], "result": obj.pass_fail}) + # #(obj.chart_data) + try: + obj.status_msg.update('10', {"data": 'done...', "data": [], "label": "Client Connectivity Time"}) + except: + pass + +def getSessionID(): + x = datetime.datetime.now() + id = x.strftime("%x").replace("/","_")+"_"+x.strftime("%x") + "_" + x.strftime("%X").split(":")[0] + "_" + x.strftime("%X").split(":")[1] + "_" + x.strftime("%X").split(":")[2]+str(x).split(".")[1] + id = str(id).replace("/", "_") + return id if __name__ == '__main__': main() diff --git a/py-scripts/test_utility.py b/py-scripts/test_utility.py index 2f9ae5fd..f684528b 100644 --- a/py-scripts/test_utility.py +++ b/py-scripts/test_utility.py @@ -9,6 +9,9 @@ Date : """ import sys +from pprint import pprint +from uuid import uuid1 + if 'py-json' not in sys.path: sys.path.append('../py-json') from LANforge import LFUtils @@ -282,21 +285,33 @@ class RuntimeUpdates(): f.close() -if __name__ == "__main__": - thread1 = ClientVisualization(lfclient_host="192.168.200.15", thread_id=1) - thread1.start() - for i in range(0, 100): - time.sleep(1) - #print(thread1.client_data) - thread1.stop() - # obj = RuntimeUpdates("1", {"test_status": 1, "data": "None"}) - # for i in range(0, 10): - # time.sleep(3) - # print(i) - # obj.send_update({"test_status": i, "data": "None"}) - # thread1 = ClientVisualization(lfclient_host="192.168.200.15", thread_id=1) - # thread1.start() - # for i in range(30): - # print(thread1.client_data) - # thread1.stop() +class StatusMsg(LFCliBase): + def __init__(self, lfclient_host="localhost", lfclient_port=8080, + _deep_clean=False, + session_id="0", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.deep_clean = _deep_clean + self.session_id = session_id + self.json_put("/status-msg/" + self.session_id, {}) + + def update(self, key, message): + self.json_post("/status-msg/" + self.session_id, { + "key": key, + "content-type": "text/plain", + "message": message + }) + pass + + + + + + +if __name__ == "__main__": + obj = StatusMsg(lfclient_host="192.168.200.15", lfclient_port=8080, session_id="Connection Test") + obj.update() + From 1a52b106648ebf6e90145391ea807ac9ff2e07a7 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Sun, 17 Jan 2021 22:20:59 -0800 Subject: [PATCH 158/848] setting up base profile --- py-json/realm.py | 88 ++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 5174d691..20ed4195 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -831,8 +831,37 @@ class BaseProfile(LFCliBase): self.exit_on_error = False def json_get(self, target): - self.debug_ = False - return self.parent_realm.json_get(self,target) + return self.json_get(target) + + def json_post(self, url,data,debug_,suppress_related_commands_=None): + return self.json_post(url,data,debug_=False,suppress_related_commands_=suppress_related_commands_) + + def parse_time(self,target): + return self.parent_realm.parse_time(target) + + def stop_cx(self, target): + return self.parent_realm.stop_cx(target) + + def cleanup_cxe_prefix(self,prefix): + return self.parent_realm.cleanup_cxe_prefix(prefix) + + def rm_cx(self,target): + return self.parent_realm.rm_cx(target) + + def created_cx(self,target): + return self.parent_realm.created_cx(target) + + def name_to_eid(self,target): + return self.parent_realm.name_to_eid(target) + + def set_endp_tos(self,target): + return self.parent_realm.set_endp_tos(target) + + def wait_until_endps_appear(self,target,debug=False): + return self.parent_realm.wait_until_endps_appear(target,debug=False) + + def wait_until_cxs_appear(self,target,debug=False): + return self.parent_realm.wait_until_cxs_appear(target,debug=False) class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -891,9 +920,6 @@ class MULTICASTProfile(LFCliBase): pass - def cleanup_prefix(self): - self.local_realm.cleanup_cxe_prefix(self.name_prefix) - def cleanup(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_=True @@ -1011,7 +1037,7 @@ class MULTICASTProfile(LFCliBase): -class L3CXProfile(BaseProfile): +class L3CXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, side_a_min_bps=None, side_b_min_bps=None, side_a_max_bps=0, side_b_max_bps=0, @@ -1034,7 +1060,7 @@ class L3CXProfile(BaseProfile): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(local_realm) + super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm @@ -1062,7 +1088,7 @@ class L3CXProfile(BaseProfile): return self.data def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes") + cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) if self.debug: print(self.created_cx.values()) print("==============\n", cx_list, "\n==============") @@ -1096,13 +1122,13 @@ class L3CXProfile(BaseProfile): monitor_interval=1, col_names=None, created_cx=None, - show=True, + show=False, report_file=None, output_format=None, script_name=None, arguments=None): try: - duration_sec=self.local_realm.parse_time(duration_sec).seconds + duration_sec=local_realm.parse_time(duration_sec).seconds except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") @@ -1125,11 +1151,9 @@ class L3CXProfile(BaseProfile): #Step 1, column names fields=",".join(col_names) - print(fields) #Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) - print(end_time) value_map = dict() passes = 0 @@ -1161,10 +1185,10 @@ class L3CXProfile(BaseProfile): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - print(value_map) + #print(value_map) - #if passes == expected_passes: - #self._pass("PASS: All tests passed") + if passes == expected_passes: + self._pass("PASS: All tests passed") #step 3 organize data endpoints=list() for endpoint in value_map.values(): @@ -1179,7 +1203,6 @@ class L3CXProfile(BaseProfile): endpoints2[point].insert(0, timestamps2[point]) #step 4 save and close header_row=col_names - print(header_row) header_row.insert(0,'Timestamp') if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': report_fh = open(report_file, "w+") @@ -1232,9 +1255,10 @@ class L3CXProfile(BaseProfile): else: pass + def refresh_cx(self): for cx_name in self.created_cx.keys(): - self.local_realm.json_post("/cli-json/show_cxe", { + self.json_post("/cli-json/show_cxe", { "test_mgr": "ALL", "cross_connect": cx_name }, debug_=self.debug) @@ -1245,7 +1269,7 @@ class L3CXProfile(BaseProfile): for cx_name in self.created_cx.keys(): if self.debug: print("cx-name: %s"%(cx_name)) - self.local_realm.json_post("/cli-json/set_cx_state", { + self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", "cx_name": cx_name, "cx_state": "RUNNING" @@ -1256,7 +1280,7 @@ class L3CXProfile(BaseProfile): def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): - self.local_realm.stop_cx(cx_name) + self.stop_cx(cx_name) print(".", end='') print("") @@ -1269,13 +1293,13 @@ class L3CXProfile(BaseProfile): for cx_name in self.created_cx.keys(): if self.debug: print("Cleaning cx: %s"%(cx_name)) - self.local_realm.rm_cx(cx_name) + self.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): ename = self.created_cx[cx_name][side] if self.debug: print("Cleaning endpoint: %s"%(ename)) - self.local_realm.rm_endp(self.created_cx[cx_name][side]) + self.rm_endp(self.created_cx[cx_name][side]) def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): if self.debug: @@ -1295,12 +1319,12 @@ class L3CXProfile(BaseProfile): raise ValueError("side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") if type(side_a) == list and type(side_b) != list: - side_b_info = self.local_realm.name_to_eid(side_b) + side_b_info = self.name_to_eid(side_b) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] for port_name in side_a: - side_a_info = self.local_realm.name_to_eid(port_name) + side_a_info = self.name_to_eid(port_name) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] if port_name.find('.') < 0: @@ -1365,8 +1389,8 @@ class L3CXProfile(BaseProfile): self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) if tos != None: - self.local_realm.set_endp_tos(endp_a_name, tos) - self.local_realm.set_endp_tos(endp_b_name, tos) + self.set_endp_tos(endp_a_name, tos) + self.set_endp_tos(endp_b_name, tos) data = { "alias": cx_name, @@ -1383,14 +1407,14 @@ class L3CXProfile(BaseProfile): }) elif type(side_b) == list and type(side_a) != list: - side_a_info = self.local_realm.name_to_eid(side_a) + side_a_info = self.name_to_eid(side_a) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] #side_a_name = side_a_info[2] for port_name in side_b: print(side_b) - side_b_info = self.local_realm.name_to_eid(port_name) + side_b_info = self.name_to_eid(port_name) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] side_b_name = side_b_info[2] @@ -1441,7 +1465,7 @@ class L3CXProfile(BaseProfile): "flag": "autohelper", "val": 1 } - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) url = "cli-json/set_endp_flag" data = { @@ -1449,7 +1473,7 @@ class L3CXProfile(BaseProfile): "flag": "autohelper", "val": 1 } - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) #print("CXNAME451: %s" % cx_name) data = { "alias": cx_name, @@ -1466,14 +1490,14 @@ class L3CXProfile(BaseProfile): else: raise ValueError("side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (type(side_a), type(side_b))) - self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) + self.wait_until_endps_appear(these_endp, debug=debug_) for data in cx_post_data: url = "/cli-json/add_cx" self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) time.sleep(0.01) - self.local_realm.wait_until_cxs_appear(these_cx, debug=debug_) + self.wait_until_cxs_appear(these_cx, debug=debug_) def to_string(self): pprint.pprint(self) @@ -2327,8 +2351,6 @@ class VRProfile(LFCliBase): suppress_related_commands_=True): # Create vr - if self.debug: - debug = True if self.vr_name is not None: self.add_vr_data["alias"] = self.vr_name self.local_realm.json_post("add_vr", self.add_vr_data, debug_=debug) From 4c0662180f5f18c3002479a406e2b0fa6df1da62 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 18 Jan 2021 13:12:27 -0800 Subject: [PATCH 159/848] inheritance fixes --- py-json/realm.py | 745 ++++++++++++++------------ py-scripts/test_ipv4_variable_time.py | 1 + 2 files changed, 406 insertions(+), 340 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 20ed4195..26af6817 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -84,7 +84,7 @@ class Realm(LFCliBase): self.freq_to_chan = {} freq = 0 chan = 1 - for freq in range( 2412, 2472, 5): + for freq in range(2412, 2472, 5): self.freq_to_chan[freq] = chan self.chan_to_freq[chan] = freq chan += 1 @@ -245,14 +245,14 @@ class Realm(LFCliBase): data = { "test_mgr": "ALL", "cx_name": cx_name - } + } self.json_post(req_url, data) def rm_endp(self, ename, debug_=False, suppress_related_commands_=True): req_url = "cli-json/rm_endp" data = { "endp_name": ename - } + } self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) def set_endp_tos(self, ename, _tos, debug_=False, suppress_related_commands_=True): @@ -270,7 +270,7 @@ class Realm(LFCliBase): data = { "name": ename, "tos": tos - } + } self.json_post(req_url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) def stop_cx(self, cx_name): @@ -278,7 +278,7 @@ class Realm(LFCliBase): "test_mgr": "ALL", "cx_name": cx_name, "cx_state": "STOPPED" - }, debug_=self.debug) + }, debug_=self.debug) def cleanup_cxe_prefix(self, prefix): cx_list = self.cx_list() @@ -297,7 +297,7 @@ class Realm(LFCliBase): self.rm_endp(endp_name) else: if self.debug: - print("cleanup_cxe_prefix no endpoints: endp_list{}".format(endp_list) ) + print("cleanup_cxe_prefix no endpoints: endp_list{}".format(endp_list)) def channel_freq(self, channel_=0): return self.chan_to_freq[channel_] @@ -307,7 +307,7 @@ class Realm(LFCliBase): # checks for OK or BUSY when querying cli-json/cv+is_built def wait_while_building(self, debug_=False): - response_json=[] + response_json = [] data = { "cmd": "cv is_built" } @@ -317,8 +317,9 @@ class Realm(LFCliBase): dbg_param = "?__debug=1" while (last_response != "YES"): - response = self.json_post("/gui-json/cmd%s" % dbg_param, data, debug_=debug_, response_json_list_=response_json) - #LFUtils.debug_printer.pprint(response_json) + response = self.json_post("/gui-json/cmd%s" % dbg_param, data, debug_=debug_, + response_json_list_=response_json) + # LFUtils.debug_printer.pprint(response_json) last_response = response_json[0]["LAST"]["response"] if (last_response != "YES"): last_response = None @@ -331,12 +332,13 @@ class Realm(LFCliBase): # loads a database def load(self, name): if (name is None) or (name == ""): - raise ValueError("Realm::load: wants a test scenario database name, please find one in the Status tab of the GUI") + raise ValueError( + "Realm::load: wants a test scenario database name, please find one in the Status tab of the GUI") data = { "name": name, - "action":"overwrite", - "clean_dut":"yes", + "action": "overwrite", + "clean_dut": "yes", "clean_chambers": "yes" } self.json_post("/cli-json/load", _data=data, debug_=self.debug) @@ -367,7 +369,7 @@ class Realm(LFCliBase): for req in these_endp: if not req in found_endps: if debug: - print("Waiting on endpoint: %s"%(req)) + print("Waiting on endpoint: %s" % (req)) wait_more = True count += 1 if (count > 100): @@ -396,7 +398,7 @@ class Realm(LFCliBase): for req in these_cx: if not req in found_cxs: if debug: - print("Waiting on CX: %s"%(req)) + print("Waiting on CX: %s" % (req)) wait_more = True count += 1 if (count > 100): @@ -536,8 +538,8 @@ class Realm(LFCliBase): return LFUtils.name_to_eid(eid) def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=60, debug=False): - print("Waiting for ips, timeout: %i..."%(timeout_sec)) - #print(station_list) + print("Waiting for ips, timeout: %i..." % (timeout_sec)) + # print(station_list) waiting_states = ["0.0.0.0", "NA", ""] if (station_list is None) or (len(station_list) < 1): @@ -549,12 +551,12 @@ class Realm(LFCliBase): for sta_eid in station_list: if debug: - print("checking sta-eid: %s"%(sta_eid)) + print("checking sta-eid: %s" % (sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % (eid[0], eid[1], eid[2])) - #pprint(response) + # pprint(response) if (response is None) or ("interface" not in response): print("station_list: incomplete response:") @@ -567,22 +569,22 @@ class Realm(LFCliBase): if (v['ip'] in waiting_states): wait_more = True if debug: - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + print("Waiting for port %s to get IPv4 Address." % (sta_eid)) else: if debug: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) if ipv6: v = response['interface'] - #print(v) + # print(v) if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ - and v['ipv6 address'] != 'AUTO': + and v['ipv6 address'] != 'AUTO': if debug: print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) else: wait_more = True if debug: - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + print("Waiting for port %s to get IPv6 Address." % (sta_eid)) if wait_more: time.sleep(1) @@ -590,7 +592,7 @@ class Realm(LFCliBase): return not wait_more - def get_curr_num_ips(self,num_sta_with_ips=0,station_list=None, ipv4=True, ipv6=False, debug=False): + def get_curr_num_ips(self, num_sta_with_ips=0, station_list=None, ipv4=True, ipv6=False, debug=False): if debug: print("checking number of stations with ips...") waiting_states = ["0.0.0.0", "NA", ""] @@ -598,42 +600,42 @@ class Realm(LFCliBase): raise ValueError("check for num curr ips expects non-empty list of ports") for sta_eid in station_list: if debug: - print("checking sta-eid: %s"%(sta_eid)) + print("checking sta-eid: %s" % (sta_eid)) eid = self.name_to_eid(sta_eid) response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" % - (eid[0], eid[1], eid[2])) + (eid[0], eid[1], eid[2])) if debug: pprint(response) if (response is None) or ("interface" not in response): print("station_list: incomplete response:") pprint(response) - #wait_more = True + # wait_more = True break if ipv4: v = response['interface'] if (v['ip'] in waiting_states): if debug: - print("Waiting for port %s to get IPv4 Address."%(sta_eid)) + print("Waiting for port %s to get IPv4 Address." % (sta_eid)) else: if debug: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) print("Incrementing stations with IP addresses found") - num_sta_with_ips+=1 + num_sta_with_ips += 1 else: - num_sta_with_ips+=1 + num_sta_with_ips += 1 if ipv6: v = response['interface'] if (v['ip'] in waiting_states): if debug: - print("Waiting for port %s to get IPv6 Address."%(sta_eid)) + print("Waiting for port %s to get IPv6 Address." % (sta_eid)) else: if debug: - print("Found IP: %s on port: %s"%(v['ip'], sta_eid)) + print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) print("Incrementing stations with IP addresses found") - num_sta_with_ips+=1 + num_sta_with_ips += 1 else: - num_sta_with_ips+=1 + num_sta_with_ips += 1 return num_sta_with_ips @@ -701,7 +703,7 @@ class Realm(LFCliBase): endp_list = self.json_get("/endp/list") if "items" in endp_list or "empty" in endp_list: return - if endp_list is not None or endp_list : + if endp_list is not None or endp_list: print("Removing all endps") endp_list = list(endp_list['endpoint']) for endp_name in range(len(endp_list)): @@ -712,7 +714,7 @@ class Realm(LFCliBase): } self.json_post(req_url, data) - def remove_all_cxs(self,remove_all_endpoints=False): + def remove_all_cxs(self, remove_all_endpoints=False): # remove cross connects # remove endpoints # nc show endpoints @@ -738,13 +740,13 @@ class Realm(LFCliBase): self.remove_all_endps() req_url = "cli-json/nc_show_endpoints" data = { - "endpoint":"all" + "endpoint": "all" } self.json_post(req_url, data) req_url = "cli-json/show_cx" - data ={ - "test_mgr":"all", - "cross_connect":"all" + data = { + "test_mgr": "all", + "cross_connect": "all" } def parse_link(self, link): @@ -757,7 +759,7 @@ class Realm(LFCliBase): def new_multicast_profile(self): multi_prof = MULTICASTProfile(self.lfclient_host, self.lfclient_port, - local_realm=self, debug_=self.debug, report_timer_=3000) + local_realm=self, debug_=self.debug, report_timer_=3000) return multi_prof def new_wifi_monitor_profile(self, resource_=1, debug_=False, up_=False): @@ -793,11 +795,13 @@ class Realm(LFCliBase): return cx_prof def new_vap_profile(self): - vap_prof = VAPProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, debug_=self.debug) + vap_prof = VAPProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, + debug_=self.debug) return vap_prof def new_vr_profile(self): - vap_prof = VRProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, debug_=self.debug) + vap_prof = VRProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, + debug_=self.debug) return vap_prof def new_http_profile(self): @@ -825,43 +829,50 @@ class Realm(LFCliBase): return profile class BaseProfile(LFCliBase): - def __init__(self,local_realm): - self.parent_realm=local_realm + def __init__(self, local_realm): + self.parent_realm = local_realm self.halt_on_error = False self.exit_on_error = False def json_get(self, target): - return self.json_get(target) + return self.parent_realm.json_get(target) - def json_post(self, url,data,debug_,suppress_related_commands_=None): - return self.json_post(url,data,debug_=False,suppress_related_commands_=suppress_related_commands_) + def json_post(self, req_url, data, debug_=False, suppress_related_commands_=None): + return self.parent_realm.json_post(req_url, + data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) - def parse_time(self,target): + def parse_time(self, target): return self.parent_realm.parse_time(target) - def stop_cx(self, target): - return self.parent_realm.stop_cx(target) + def stopping_cx(self, name): + return self.parent_realm.stop_cx(name) - def cleanup_cxe_prefix(self,prefix): + def cleanup_cxe_prefix(self, prefix): return self.parent_realm.cleanup_cxe_prefix(prefix) - def rm_cx(self,target): + def rm_cx(self, target): return self.parent_realm.rm_cx(target) - def created_cx(self,target): + def rm_endp(self, ename): + self.parent_realm.rm_endp(ename) + + def created_cx(self, target): return self.parent_realm.created_cx(target) - def name_to_eid(self,target): + def name_to_eid(self, target): return self.parent_realm.name_to_eid(target) - def set_endp_tos(self,target): + def set_endp_tos(self, target): return self.parent_realm.set_endp_tos(target) - def wait_until_endps_appear(self,target,debug=False): - return self.parent_realm.wait_until_endps_appear(target,debug=False) + def wait_until_endps_appear(self, target, debug=False): + return self.parent_realm.wait_until_endps_appear(target, debug=False) + + def wait_until_cxs_appear(self, target, debug=False): + return self.parent_realm.wait_until_cxs_appear(target, debug=False) - def wait_until_cxs_appear(self,target,debug=False): - return self.parent_realm.wait_until_cxs_appear(target,debug=False) class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -875,7 +886,7 @@ class MULTICASTProfile(LFCliBase): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) + super().__init__(local_realm) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm @@ -890,87 +901,88 @@ class MULTICASTProfile(LFCliBase): def refresh_mc(self, debug_=False): for endp_name in self.get_mc_names(): self.json_post("/cli-json/show_endpoints", { - "endpoint": endp_name + "endpoint": endp_name }, debug_=debug_) - def start_mc(self, suppress_related_commands=None, debug_ = False): + def start_mc(self, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True for endp_name in self.get_mc_names(): - print("Starting mcast endpoint: %s"%(endp_name)) + print("Starting mcast endpoint: %s" % (endp_name)) json_data = { - "endp_name":endp_name + "endp_name": endp_name } url = "cli-json/start_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) pass - def stop_mc(self, suppress_related_commands=None, debug_ = False): + def stop_mc(self, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True - + debug_ = True for endp_name in self.get_mc_names(): json_data = { - "endp_name":endp_name + "endp_name": endp_name } url = "cli-json/stop_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) pass - def cleanup(self, suppress_related_commands=None, debug_ = False): + def cleanup(self, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True for endp_name in self.get_mc_names(): self.local_realm.rm_endp(endp_name, debug_=debug_, suppress_related_commands_=suppress_related_commands) def create_mc_tx(self, endp_type, side_tx, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True side_tx_info = self.local_realm.name_to_eid(side_tx) side_tx_shelf = side_tx_info[0] side_tx_resource = side_tx_info[1] side_tx_port = side_tx_info[2] - side_tx_name = "%smtx-%s-%i"%(self.name_prefix, side_tx_port, len(self.created_mc)) + side_tx_name = "%smtx-%s-%i" % (self.name_prefix, side_tx_port, len(self.created_mc)) json_data = [] - #add_endp mcast-xmit-sta 1 1 side_tx mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 + # add_endp mcast-xmit-sta 1 1 side_tx mc_udp -1 NO 4000000 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':side_tx_name, - 'shelf':side_tx_shelf, - 'resource':side_tx_resource, - 'port':side_tx_port, - 'type':endp_type, - 'ip_port':-1, - 'is_rate_bursty': - 'NO','min_rate':256000, - 'max_rate':0, - 'is_pkt_sz_random':'NO', - 'min_pkt':1472, - 'max_pkt':0, - 'payload_pattern':'INCREASING', - 'use_checksum':'NO', - 'ttl':32, - 'send_bad_crc_per_million':0, - 'multi_conn':0 - } + 'alias': side_tx_name, + 'shelf': side_tx_shelf, + 'resource': side_tx_resource, + 'port': side_tx_port, + 'type': endp_type, + 'ip_port': -1, + 'is_rate_bursty': + 'NO', 'min_rate': 256000, + 'max_rate': 0, + 'is_pkt_sz_random': 'NO', + 'min_pkt': 1472, + 'max_pkt': 0, + 'payload_pattern': 'INCREASING', + 'use_checksum': 'NO', + 'ttl': 32, + 'send_bad_crc_per_million': 0, + 'multi_conn': 0 + } url = "/cli-json/add_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical + # set_mc_endp mcast-xmit-sta 32 224.9.9.9 9999 No # critical json_data = { - 'name':side_tx_name, - 'ttl':32, - 'mcast_group':'224.9.9.9', - 'mcast_dest_port':9999, - 'rcv_mcast':'No' - } + 'name': side_tx_name, + 'ttl': 32, + 'mcast_group': '224.9.9.9', + 'mcast_dest_port': 9999, + 'rcv_mcast': 'No' + } url = "cli-json/set_mc_endp" self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) @@ -980,10 +992,9 @@ class MULTICASTProfile(LFCliBase): these_endp = [side_tx_name] self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) - - def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_ = False): + def create_mc_rx(self, endp_type, side_rx, suppress_related_commands=None, debug_=False): if self.debug: - debug_=True + debug_ = True these_endp = [] @@ -992,40 +1003,42 @@ class MULTICASTProfile(LFCliBase): side_rx_shelf = side_rx_info[0] side_rx_resource = side_rx_info[1] side_rx_port = side_rx_info[2] - side_rx_name = "%smrx-%s-%i"%(self.name_prefix, side_rx_port, len(self.created_mc)) + side_rx_name = "%smrx-%s-%i" % (self.name_prefix, side_rx_port, len(self.created_mc)) # add_endp mcast-rcv-sta-001 1 1 sta0002 mc_udp 9999 NO 0 0 NO 1472 0 INCREASING NO 32 0 0 json_data = { - 'alias':side_rx_name, - 'shelf':side_rx_shelf, - 'resource':side_rx_resource, - 'port':side_rx_port, - 'type':endp_type, - 'ip_port':9999, - 'is_rate_bursty':'NO', - 'min_rate':0, - 'max_rate':0, - 'is_pkt_sz_random':'NO', - 'min_pkt':1472, - 'max_pkt':0, - 'payload_pattern':'INCREASING', - 'use_checksum':'NO', - 'ttl':32, - 'send_bad_crc_per_million':0, - 'multi_conn':0 - } + 'alias': side_rx_name, + 'shelf': side_rx_shelf, + 'resource': side_rx_resource, + 'port': side_rx_port, + 'type': endp_type, + 'ip_port': 9999, + 'is_rate_bursty': 'NO', + 'min_rate': 0, + 'max_rate': 0, + 'is_pkt_sz_random': 'NO', + 'min_pkt': 1472, + 'max_pkt': 0, + 'payload_pattern': 'INCREASING', + 'use_checksum': 'NO', + 'ttl': 32, + 'send_bad_crc_per_million': 0, + 'multi_conn': 0 + } url = "cli-json/add_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) json_data = { - 'name':side_rx_name, - 'ttl':32, - 'mcast_group':'224.9.9.9', - 'mcast_dest_port':9999, - 'rcv_mcast':'Yes' - } + 'name': side_rx_name, + 'ttl': 32, + 'mcast_group': '224.9.9.9', + 'mcast_dest_port': 9999, + 'rcv_mcast': 'Yes' + } url = "cli-json/set_mc_endp" - self.local_realm.json_post(url, json_data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, json_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) self.created_mc[side_rx_name] = side_rx_name these_endp.append(side_rx_name) @@ -1037,17 +1050,26 @@ class MULTICASTProfile(LFCliBase): -class L3CXProfile(LFCliBase): - def __init__(self, lfclient_host, lfclient_port, local_realm, - side_a_min_bps=None, side_b_min_bps=None, - side_a_max_bps=0, side_b_max_bps=0, - side_a_min_pdu=-1, side_b_min_pdu=-1, - side_a_max_pdu=0, side_b_max_pdu=0, - report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): +class L3CXProfile(BaseProfile): + def __init__(self, + lfclient_host, + lfclient_port, + local_realm, + side_a_min_bps=None, + side_b_min_bps=None, + side_a_max_bps=0, + side_b_max_bps=0, + side_a_min_pdu=-1, + side_b_min_pdu=-1, + side_a_max_pdu=0, + side_b_max_pdu=0, + report_timer_=3000, + name_prefix_="Unset", + number_template_="00000", + debug_=False): """ :param lfclient_host: :param lfclient_port: - :param local_realm: :param side_a_min_bps: :param side_b_min_bps: :param side_a_max_bps: @@ -1060,10 +1082,9 @@ class L3CXProfile(LFCliBase): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) + super().__init__(local_realm) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ - self.local_realm = local_realm self.side_a_min_pdu = side_a_min_pdu self.side_b_min_pdu = side_b_min_pdu self.side_a_max_pdu = side_a_max_pdu @@ -1088,7 +1109,7 @@ class L3CXProfile(LFCliBase): return self.data def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) + cx_list = self.json_get("endp?fields=name,rx+bytes") if self.debug: print(self.created_cx.values()) print("==============\n", cx_list, "\n==============") @@ -1097,8 +1118,8 @@ class L3CXProfile(LFCliBase): if cx_name != 'uri' and cx_name != 'handler': for item, value in cx_name.items(): for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.created_cx.values(): - cx_rx_map[item] = value_rx + if value_name == 'rx bytes' and item in self.created_cx.values(): + cx_rx_map[item] = value_rx return cx_rx_map def __compare_vals(self, old_list, new_list): @@ -1128,11 +1149,11 @@ class L3CXProfile(LFCliBase): script_name=None, arguments=None): try: - duration_sec=local_realm.parse_time(duration_sec).seconds + duration_sec=self.parse_time(duration_sec).seconds except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") - if (duration_sec <= monitor_interval ): + if (duration_sec <= monitor_interval): raise ValueError("L3CXProfile::monitor wants duration_sec > monitor_interval") if report_file == None: raise ValueError("Monitor requires an output file to be defined") @@ -1149,18 +1170,20 @@ class L3CXProfile(LFCliBase): else: output_format = report_file.split('.')[-1] - #Step 1, column names - fields=",".join(col_names) - #Step 2, monitor columns + # Step 1, column names + fields = ",".join(col_names) + print(fields) + # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) + print(end_time) value_map = dict() passes = 0 expected_passes = 0 old_cx_rx_values = self.__get_rx_values() - timestamps=[] - #for x in range(0,int(round(iterations,0))): + timestamps = [] + # for x in range(0,int(round(iterations,0))): while datetime.datetime.now() < end_time: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: @@ -1168,9 +1191,9 @@ class L3CXProfile(LFCliBase): raise ValueError("no endpoint?") if show: print(response) - t=datetime.datetime.now() + t = datetime.datetime.now() timestamps.append(t) - value_map[t]=response + value_map[t] = response new_cx_rx_values = self.__get_rx_values() if self.debug: print(old_cx_rx_values, new_cx_rx_values) @@ -1185,82 +1208,83 @@ class L3CXProfile(LFCliBase): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - #print(value_map) + print(value_map) - if passes == expected_passes: - self._pass("PASS: All tests passed") - #step 3 organize data - endpoints=list() + # if passes == expected_passes: + # self._pass("PASS: All tests passed") + # step 3 organize data + endpoints = list() for endpoint in value_map.values(): endpoints.append(endpoint['endpoint']) - endpoints2=[] + endpoints2 = [] for y in range(0, len(endpoints)): for x in range(0, len(endpoints[0])): endpoints2.append(list(list(endpoints[y][x].values())[0].values())) import itertools - timestamps2=list(itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) + timestamps2 = list( + itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) - #step 4 save and close - header_row=col_names - header_row.insert(0,'Timestamp') - if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': + # step 4 save and close + header_row = col_names + header_row.insert(0, 'Timestamp') + # print(header_row) + if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) worksheet = workbook.add_worksheet() - for col_num,data in enumerate(header_row): - worksheet.write(0, col_num,data) + for col_num, data in enumerate(header_row): + worksheet.write(0, col_num, data) row_num = 1 for x in endpoints2: for col_num, data in enumerate(x): - worksheet.write(row_num, col_num, str(data)) - row_num+=1 + worksheet.write(row_num, col_num, str(data)) + row_num += 1 workbook.close() else: - df=pd.DataFrame(endpoints2) - df.columns=header_row + df = pd.DataFrame(endpoints2) + df.columns = header_row import requests import ast systeminfo=ast.literal_eval(requests.get('http://localhost:8080').text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments - for x in ['LFGUI Release','Script Name','Arguments']: + for x in ['LFGUI Release', 'Script Name', 'Arguments']: df[x][1:] = '' if output_format == 'pdf': import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages - fig, ax = plt.subplots(figsize=(12,4)) + fig, ax = plt.subplots(figsize=(12, 4)) ax.axis('tight') ax.axis('off') the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') pp = PdfPages(report_file) - pp.savefig(fig, bbox_inches = 'tight') + pp.savefig(fig, bbox_inches='tight') pp.close() if output_format == 'hdf': - df.to_hdf(report_file,'table', append=True) + df.to_hdf(report_file, 'table', append=True) if output_format == 'parquet': - df.to_parquet(report_file,engine='pyarrow') + df.to_parquet(report_file, engine='pyarrow') if output_format == 'png': - fig=df.plot().get_figure() + fig = df.plot().get_figure() fig.savefig(report_file) if output_format == 'html': print('Shivams function') if output_format == 'df': return df - supported_formats = ['csv','json','stata','pickle'] + supported_formats = ['csv', 'json', 'stata', 'pickle'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: - exec('df.to_'+x+'("'+report_file+'")') + exec('df.to_' + x + '("' + report_file + '")') else: pass - def refresh_cx(self): for cx_name in self.created_cx.keys(): self.json_post("/cli-json/show_cxe", { - "test_mgr": "ALL", - "cross_connect": cx_name + "test_mgr": "ALL", + "cross_connect": cx_name }, debug_=self.debug) print(".", end='') @@ -1268,7 +1292,7 @@ class L3CXProfile(LFCliBase): print("Starting CXs...") for cx_name in self.created_cx.keys(): if self.debug: - print("cx-name: %s"%(cx_name)) + print("cx-name: %s" % (cx_name)) self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", "cx_name": cx_name, @@ -1280,30 +1304,31 @@ class L3CXProfile(LFCliBase): def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): - self.stop_cx(cx_name) + self.stopping_cx(cx_name) print(".", end='') print("") def cleanup_prefix(self): - self.local_realm.cleanup_cxe_prefix(self.name_prefix) + self.cleanup_cxe_prefix(self.name_prefix) def cleanup(self): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: for cx_name in self.created_cx.keys(): if self.debug: - print("Cleaning cx: %s"%(cx_name)) + print("Cleaning cx: %s" % (cx_name)) self.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): ename = self.created_cx[cx_name][side] if self.debug: - print("Cleaning endpoint: %s"%(ename)) + print("Cleaning endpoint: %s" % (ename)) self.rm_endp(self.created_cx[cx_name][side]) - def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): + def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, + tos=None): if self.debug: - debug_=True + debug_ = True cx_post_data = [] timer_post_data = [] @@ -1316,7 +1341,8 @@ class L3CXProfile(LFCliBase): or (self.side_a_max_bps is None) \ or (self.side_b_min_bps is None) \ or (self.side_b_max_bps is None): - raise ValueError("side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") + raise ValueError( + "side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") if type(side_a) == list and type(side_b) != list: side_b_info = self.name_to_eid(side_b) @@ -1330,11 +1356,11 @@ class L3CXProfile(LFCliBase): if port_name.find('.') < 0: port_name = "%d.%s" % (side_a_info[1], port_name) - cx_name = "%s%s-%i"%(self.name_prefix, side_a_info[2], len(self.created_cx)) + cx_name = "%s%s-%i" % (self.name_prefix, side_a_info[2], len(self.created_cx)) endp_a_name = cx_name + "-A" endp_b_name = cx_name + "-B" - self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] + self.created_cx[cx_name] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name self.created_endp[endp_b_name] = endp_b_name these_cx.append(cx_name) @@ -1366,9 +1392,11 @@ class L3CXProfile(LFCliBase): } url = "/cli-json/add_endp" - self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands) - self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print("napping %f sec"%sleep_time) + self.json_post(url, endp_side_a, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + self.json_post(url, endp_side_b, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + # print("napping %f sec"%sleep_time) time.sleep(sleep_time) url = "cli-json/set_endp_flag" @@ -1377,16 +1405,20 @@ class L3CXProfile(LFCliBase): "flag": "AutoHelper", "val": 1 } - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) data["name"] = endp_b_name - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) if (endp_type == "lf_udp") or (endp_type == "udp") or (endp_type == "lf_udp6") or (endp_type == "udp6"): data["name"] = endp_a_name data["flag"] = "UseAutoNAT" - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) data["name"] = endp_b_name - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, + suppress_related_commands_=suppress_related_commands) if tos != None: self.set_endp_tos(endp_a_name, tos) @@ -1398,19 +1430,19 @@ class L3CXProfile(LFCliBase): "tx_endp": endp_a_name, "rx_endp": endp_b_name, } - #pprint(data) + # pprint(data) cx_post_data.append(data) timer_post_data.append({ - "test_mgr":"default_tm", - "cx_name":cx_name, - "milliseconds":self.report_timer + "test_mgr": "default_tm", + "cx_name": cx_name, + "milliseconds": self.report_timer }) elif type(side_b) == list and type(side_a) != list: side_a_info = self.name_to_eid(side_a) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] - #side_a_name = side_a_info[2] + # side_a_name = side_a_info[2] for port_name in side_b: print(side_b) @@ -1422,7 +1454,7 @@ class L3CXProfile(LFCliBase): cx_name = "%s%s-%i" % (self.name_prefix, port_name, len(self.created_cx)) endp_a_name = cx_name + "-A" endp_b_name = cx_name + "-B" - self.created_cx[ cx_name ] = [endp_a_name, endp_b_name] + self.created_cx[cx_name] = [endp_a_name, endp_b_name] self.created_endp[endp_a_name] = endp_a_name self.created_endp[endp_b_name] = endp_b_name these_cx.append(cx_name) @@ -1454,9 +1486,11 @@ class L3CXProfile(LFCliBase): } url = "/cli-json/add_endp" - self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands) - self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print("napping %f sec" %sleep_time ) + self.json_post(url, endp_side_a, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + self.json_post(url, endp_side_b, debug_=debug_, + suppress_related_commands_=suppress_related_commands) + # print("napping %f sec" %sleep_time ) time.sleep(sleep_time) url = "cli-json/set_endp_flag" @@ -1474,7 +1508,7 @@ class L3CXProfile(LFCliBase): "val": 1 } self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - #print("CXNAME451: %s" % cx_name) + # print("CXNAME451: %s" % cx_name) data = { "alias": cx_name, "test_mgr": "default_tm", @@ -1483,18 +1517,20 @@ class L3CXProfile(LFCliBase): } cx_post_data.append(data) timer_post_data.append({ - "test_mgr":"default_tm", - "cx_name":cx_name, - "milliseconds":self.report_timer + "test_mgr": "default_tm", + "cx_name": cx_name, + "milliseconds": self.report_timer }) else: - raise ValueError("side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % (type(side_a), type(side_b))) + raise ValueError( + "side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % ( + type(side_a), type(side_b))) self.wait_until_endps_appear(these_endp, debug=debug_) for data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) time.sleep(0.01) self.wait_until_cxs_appear(these_cx, debug=debug_) @@ -1569,13 +1605,13 @@ class L4CXProfile(LFCliBase): "cx_name": self.created_cx[cx_name] } self.json_post(req_url, data) - #pprint(data) + # pprint(data) req_url = "cli-json/rm_endp" data = { "endp_name": cx_name } self.json_post(req_url, data) - #pprint(data) + # pprint(data) def create(self, ports=[], sleep_time=.5, debug_=False, suppress_related_commands_=None): cx_post_data = [] @@ -1598,7 +1634,8 @@ class L4CXProfile(LFCliBase): "proxy_auth_type": 0x200 } url = "cli-json/add_l4_endp" - self.local_realm.json_post(url, endp_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, endp_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) endp_data = { @@ -1612,7 +1649,8 @@ class L4CXProfile(LFCliBase): for cx_data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, cx_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) @@ -1636,7 +1674,7 @@ class GenCXProfile(LFCliBase): if self.type == "lfping": if ((self.dest is not None) or (self.dest != "")) and ((self.interval is not None) or (self.interval > 0)): self.cmd = "%s -i %s -I %s %s" % (self.type, self.interval, sta_name, self.dest) - #print(self.cmd) + # print(self.cmd) else: raise ValueError("Please ensure dest and interval have been set correctly") elif self.type == "generic": @@ -1652,8 +1690,8 @@ class GenCXProfile(LFCliBase): def start_cx(self): print("Starting CXs...") - #print(self.created_cx) - #print(self.created_endp) + # print(self.created_cx) + # print(self.created_endp) for cx_name in self.created_cx: self.json_post("/cli-json/set_cx_state", { "test_mgr": "default_tm", @@ -1711,15 +1749,15 @@ class GenCXProfile(LFCliBase): # this naming convention follows what you see when you use # lf_firemod.pl --action list_endp after creating a generic endpoint - gen_name_a = "%s-%s"%(self.name_prefix, name) - gen_name_b = "D_%s-%s"%(self.name_prefix, name) - endp_tpls.append( (resource, name, gen_name_a, gen_name_b)) + gen_name_a = "%s-%s" % (self.name_prefix, name) + gen_name_b = "D_%s-%s" % (self.name_prefix, name) + endp_tpls.append((resource, name, gen_name_a, gen_name_b)) for endp_tpl in endp_tpls: - resource = endp_tpl[0] - name = endp_tpl[1] - gen_name_a = endp_tpl[2] - #gen_name_b = endp_tpl[3] + resource = endp_tpl[0] + name = endp_tpl[1] + gen_name_a = endp_tpl[2] + # gen_name_b = endp_tpl[3] genl = GenericCx(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, debug_=self.debug) # (self, alias=None, shelf=1, resource=1, port=None, type=None): genl.create_gen_endp(alias=gen_name_a, shelf=shelf, resource=resource, port=name) @@ -1729,26 +1767,26 @@ class GenCXProfile(LFCliBase): time.sleep(sleep_time) for endp_tpl in endp_tpls: - gen_name_a = endp_tpl[2] - gen_name_b = endp_tpl[3] + gen_name_a = endp_tpl[2] + gen_name_b = endp_tpl[3] genl.set_flags(gen_name_a, "ClearPortOnStart", 1) # genl.set_flags(gen_name_b, "ClearPortOnStart", 1) # genl.set_flags(gen_name_b, "Unmanaged", 1) time.sleep(sleep_time) for endp_tpl in endp_tpls: - name = endp_tpl[1] - gen_name_a = endp_tpl[2] + name = endp_tpl[1] + gen_name_a = endp_tpl[2] # gen_name_b = endp_tpl[3] self.parse_command(name) genl.set_cmd(gen_name_a, self.cmd) time.sleep(sleep_time) for endp_tpl in endp_tpls: - name = endp_tpl[1] - gen_name_a = endp_tpl[2] - gen_name_b = endp_tpl[3] - cx_name = "CX_%s-%s"%(self.name_prefix, name) + name = endp_tpl[1] + gen_name_a = endp_tpl[2] + gen_name_b = endp_tpl[3] + cx_name = "CX_%s-%s" % (self.name_prefix, name) data = { "alias": cx_name, "test_mgr": "default_tm", @@ -1771,11 +1809,12 @@ class GenCXProfile(LFCliBase): time.sleep(sleep_time) for data in post_data: self.local_realm.json_post("/cli-json/show_cx", { - "test_mgr":"default_tm", + "test_mgr": "default_tm", "cross_connect": data["alias"] }) time.sleep(sleep_time) + class WifiMonitor: def __init__(self, lfclient_url, local_realm, up=True, debug_=False, resource_=1): self.debug = debug_ @@ -1787,10 +1826,10 @@ class WifiMonitor: self.flag_names = [] self.flag_mask_names = [] self.flags_mask = add_monitor.default_flags_mask - self.aid = "NA" # used when sniffing /ax radios - self.bsssid = "00:00:00:00:00:00" # used when sniffing on /ax radios + self.aid = "NA" # used when sniffing /ax radios + self.bsssid = "00:00:00:00:00:00" # used when sniffing on /ax radios - def create(self, resource_=1, channel=None, radio_="wiphy0", name_="moni0" ): + def create(self, resource_=1, channel=None, radio_="wiphy0", name_="moni0"): print("Creating monitor " + name_) self.monitor_name = name_ computed_flags = 0 @@ -1800,11 +1839,12 @@ class WifiMonitor: # we want to query the existing country code of the radio # there's no reason to change it but we get hollering from server # if we don't provide a value for the parameter - jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country"%(resource_, radio_), debug_=self.debug) + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource_, radio_), + debug_=self.debug) if jr is None: - raise ValueError("No radio %s.%s found"%(resource_, radio_)) + raise ValueError("No radio %s.%s found" % (resource_, radio_)) - eid = "1.%s.%s"%(resource_, radio_) + eid = "1.%s.%s" % (resource_, radio_) frequency = 0 country = 0 if eid in jr: @@ -1814,7 +1854,7 @@ class WifiMonitor: "shelf": 1, "resource": resource_, "radio": radio_, - "mode": 0, #"NA", #0 for AUTO or "NA" + "mode": 0, # "NA", #0 for AUTO or "NA" "channel": channel, "country": country, "frequency": self.local_realm.channel_freq(channel_=channel) @@ -1851,18 +1891,18 @@ class WifiMonitor: debug=self.debug) else: names = ",".join(desired_ports) - existing_ports = self.local_realm.json_get("/port/1/%d/%s?fields=alias"%(resource_, names), debug_=False) + existing_ports = self.local_realm.json_get("/port/1/%d/%s?fields=alias" % (resource_, names), debug_=False) if (existing_ports is None) or ("interfaces" not in existing_ports) or ("interface" not in existing_ports): print("No monitor names found to delete") return if ("interfaces" in existing_ports): - for eid,info in existing_ports["interfaces"].items(): + for eid, info in existing_ports["interfaces"].items(): LFUtils.removePort(resource=resource_, port_name=info["alias"], baseurl=self.lfclient_url, debug=self.debug) if ("interface" in existing_ports): - for eid,info in existing_ports["interface"].items(): + for eid, info in existing_ports["interface"].items(): LFUtils.removePort(resource=resource_, port_name=info["alias"], baseurl=self.lfclient_url, @@ -1882,19 +1922,17 @@ class WifiMonitor: if capname is None: raise ValueError("Need a capture file name") data = { - "shelf": 1, - "resource": 1, - "port": self.monitor_name, - "display": "NA", - "flags": 0x2, - "outfile": capname, - "duration": duration_sec - } - self.local_realm.json_post("/cli-json/sniff_port", _data= data) + "shelf": 1, + "resource": 1, + "port": self.monitor_name, + "display": "NA", + "flags": 0x2, + "outfile": capname, + "duration": duration_sec + } + self.local_realm.json_post("/cli-json/sniff_port", _data=data) - # "sniff_port 1 %s %s NA %s %s.pcap %i"%(r, m, sflags, m, int(dur)) - class VAPProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, vap_name="", @@ -1904,7 +1942,7 @@ class VAPProfile(LFCliBase): debug_=False): super().__init__(_lfjson_host=lfclient_host, _lfjson_port=lfclient_port, _debug=debug_) self.debug = debug_ - #self.lfclient_url = lfclient_url # done in super() + # self.lfclient_url = lfclient_url # done in super() self.ssid = ssid self.ssid_pass = ssid_pass self.mode = mode @@ -2033,7 +2071,9 @@ class VAPProfile(LFCliBase): self.desired_add_vap_flags_mask.append(param_name) elif command_name == "set_port": - if (param_name not in set_port.set_port_current_flags) and (param_name not in set_port.set_port_cmd_flags) and (param_name not in set_port.set_port_interest_flags): + if (param_name not in set_port.set_port_current_flags) and ( + param_name not in set_port.set_port_cmd_flags) and ( + param_name not in set_port.set_port_interest_flags): print("Parameter name [%s] not defined in set_port.py" % param_name) if self.debug: pprint(set_port.set_port_cmd_flags) @@ -2089,18 +2129,19 @@ class VAPProfile(LFCliBase): if self.debug: pprint(command_ref) raise ValueError("flag %s not in map" % name) - #print("add-named-flags: %s %i"%(name, command_ref[name])) + # print("add-named-flags: %s %i"%(name, command_ref[name])) result |= command_ref[name] return result - def create(self, resource, radio, channel=None, up_=None, debug=False, use_ht40=True, use_ht80=True, use_ht160=False, + def create(self, resource, radio, channel=None, up_=None, debug=False, use_ht40=True, use_ht80=True, + use_ht160=False, suppress_related_commands_=True, use_radius=False, hs20_enable=False): port_list = self.local_realm.json_get("port/1/1/list") if port_list is not None: port_list = port_list['interfaces'] for port in port_list: - for k,v in port.items(): + for k, v in port.items(): if v['alias'] == self.vap_name: self.local_realm.rm_port(k, check_exists=True) if use_ht160: @@ -2123,9 +2164,10 @@ class VAPProfile(LFCliBase): self.desired_add_vap_flags.append("hs20_enable") self.desired_add_vap_flags_mask.append("hs20_enable") - #print("MODE ========= ", self.mode) + # print("MODE ========= ", self.mode) - jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource, radio), debug_=self.debug) + jr = self.local_realm.json_get("/radiostatus/1/%s/%s?fields=channel,frequency,country" % (resource, radio), + debug_=self.debug) if jr is None: raise ValueError("No radio %s.%s found" % (resource, radio)) @@ -2139,7 +2181,7 @@ class VAPProfile(LFCliBase): "shelf": 1, "resource": resource, "radio": radio, - "mode": self.mode, #"NA", #0 for AUTO or "NA" + "mode": self.mode, # "NA", #0 for AUTO or "NA" "channel": channel, "country": country, "frequency": self.local_realm.channel_freq(channel_=channel) @@ -2200,12 +2242,11 @@ class VAPProfile(LFCliBase): wifi_extra_r.addPostData(self.wifi_extra_data) json_response = wifi_extra_r.jsonPost(debug) - port_list = self.local_realm.json_get("port/1/1/list") if port_list is not None: port_list = port_list['interfaces'] for port in port_list: - for k,v in port.items(): + for k, v in port.items(): if v['alias'] == 'br0': self.local_realm.rm_port(k, check_exists=True) time.sleep(5) @@ -2228,8 +2269,6 @@ class VAPProfile(LFCliBase): } self.local_realm.json_post("cli-json/set_port", bridge_set_port) - - if (self.up): self.admin_up(1) @@ -2246,10 +2285,11 @@ class VAPProfile(LFCliBase): # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_ports) + class VRProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, ssid="NA", ssid_pass="NA", mode=0, debug_=False): super().__init__(_lfjson_host=lfclient_host, _lfjson_port=lfclient_port, _debug=debug_) - #self.debug = debug_ + # self.debug = debug_ # self.lfclient_url = lfclient_url self.ssid = ssid self.ssid_pass = ssid_pass @@ -2275,8 +2315,8 @@ class VRProfile(LFCliBase): 'shelf': 1, 'resource': 1, 'vr-name': None, - 'local_dev': None, # outer rdd - 'remote_dev': None, # inner rdd + 'local_dev': None, # outer rdd + 'remote_dev': None, # inner rdd "x": 0, "y": 0, "width": 10, @@ -2304,7 +2344,8 @@ class VRProfile(LFCliBase): "peer_ifname": "rdd1" } # print("creating rdd0") - self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, + debug_=debug_) rdd_data = { "shelf": 1, @@ -2313,24 +2354,28 @@ class VRProfile(LFCliBase): "peer_ifname": "rdd0" } # print("creating rdd1") - self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, + debug_=debug_) self.set_port_data["port"] = "rdd0" self.set_port_data["ip_addr"] = gateway self.set_port_data["netmask"] = netmask self.set_port_data["gateway"] = gateway - self.local_realm.json_post("set_port", self.set_port_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("set_port", self.set_port_data, + suppress_related_commands_=suppress_related_commands_, debug_=debug_) self.set_port_data["port"] = "rdd1" self.set_port_data["ip_addr"] = ip_addr self.set_port_data["netmask"] = netmask self.set_port_data["gateway"] = gateway - self.local_realm.json_post("set_port", self.set_port_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("set_port", self.set_port_data, + suppress_related_commands_=suppress_related_commands_, debug_=debug_) self.created_rdds.append("rdd0") self.created_rdds.append("rdd1") - def create_vrcx(self, resource, local_dev, remote_dev, subnets, nexthop, flags, suppress_related_commands_=True, debug_=False): + def create_vrcx(self, resource, local_dev, remote_dev, subnets, nexthop, flags, suppress_related_commands_=True, + debug_=False): if self.vr_name is not None: self.vrcx_data["resource"] = resource self.vrcx_data["vr_name"] = self.vr_name @@ -2339,7 +2384,8 @@ class VRProfile(LFCliBase): self.vrcx_data["subnets"] = subnets self.vrcx_data["nexthop"] = nexthop self.vrcx_data["flags"] = flags - self.local_realm.json_post("add_vrcx", self.vrcx_data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.local_realm.json_post("add_vrcx", self.vrcx_data, + suppress_related_commands_=suppress_related_commands_, debug_=debug_) else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) @@ -2357,18 +2403,22 @@ class VRProfile(LFCliBase): else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) # Create 1 rdd pair - self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network + self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, + netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network # connect rdds and upstream - self.create_vrcx(resource=resource, local_dev=upstream_port, remote_dev="NA", subnets=upstream_subnets, nexthop=upstream_nexthop, + self.create_vrcx(resource=resource, local_dev=upstream_port, remote_dev="NA", subnets=upstream_subnets, + nexthop=upstream_nexthop, flags=257, suppress_related_commands_=suppress_related_commands_, debug_=debug) - self.create_vrcx(resource=resource, local_dev="rdd0", remote_dev="rdd1", subnets=local_subnets, nexthop=local_nexthop, + self.create_vrcx(resource=resource, local_dev="rdd0", remote_dev="rdd1", subnets=local_subnets, + nexthop=local_nexthop, flags=1, suppress_related_commands_=suppress_related_commands_, debug_=debug) def cleanup(self, resource, delay=0.03): # TODO: Cleanup for VRProfile pass + class DUTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True, _local_realm=local_realm) @@ -2421,13 +2471,13 @@ class DUTProfile(LFCliBase): for param in add_dut.dut_params: if (param.name in self.__dict__): if (self.__dict__[param.name] is not None) \ - and (self.__dict__[param.name] != "NA"): + and (self.__dict__[param.name] != "NA"): data[param.name] = self.__dict__[param.name] else: print("---------------------------------------------------------") pprint(self.__dict__[param.name]) print("---------------------------------------------------------") - raise ValueError("parameter %s not in dut_profile"%param) + raise ValueError("parameter %s not in dut_profile" % param) if (flags is not None) and (int(flags) > -1): data["flags"] = flags @@ -2448,7 +2498,7 @@ class DUTProfile(LFCliBase): print("---------------------------------------------------------") self.json_post(url, data, debug_=self.debug) - if (self.notes is not None) and (len(self.notes)>0): + if (self.notes is not None) and (len(self.notes) > 0): self.json_post("/cli-json/add_dut_notes", { "dut": self.name, "text": "[BLANK]" @@ -2465,7 +2515,7 @@ class DUTProfile(LFCliBase): "dut": self.name, "text-64": notebytes.decode('ascii') }, self.debug) - if (self.append is not None) and (len(self.append)>0): + if (self.append is not None) and (len(self.append) > 0): notebytes = None for line in self.append: notebytes = base64.b64encode(line.encode('ascii')) @@ -2479,6 +2529,7 @@ class DUTProfile(LFCliBase): "text-64": notebytes.decode('ascii') }, self.debug) + class TestGroupProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, test_group_name=None, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) @@ -2494,7 +2545,7 @@ class TestGroupProfile(LFCliBase): def quiesce_group(self): if self.group_name is not None: - self.local_realm.json_post("/cli-json/quiesce_group", {"name": self.group_name}) + self.local_realm.json_post("/cli-json/quiesce_group", {"name": self.group_name}) else: raise ValueError("test_group name must be set.") @@ -2527,7 +2578,7 @@ class TestGroupProfile(LFCliBase): if test_groups is not None and "groups" in test_groups: test_groups = test_groups["groups"] for group in test_groups: - for k,v in group.items(): + for k, v in group.items(): if v['name'] == self.group_name: return True else: @@ -2548,7 +2599,7 @@ class TestGroupProfile(LFCliBase): if test_groups is not None: test_groups = test_groups["groups"] for group in test_groups: - for k,v in group.items(): + for k, v in group.items(): if v['name'] == self.group_name: return v['cross connects'] @@ -2561,6 +2612,7 @@ class FIOEndpProfile(LFCliBase): Very often you will create the FileIO writer profile first so that it creates the data that a reader profile will subsequently use. """ + def __init__(self, lfclient_host, lfclient_port, local_realm, io_direction="write", debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) self.local_realm = local_realm @@ -2575,8 +2627,8 @@ class FIOEndpProfile(LFCliBase): self.min_write_rate_bps = 1000 * 1000 * 1000 self.max_write_rate_bps = 1000 * 1000 * 1000 - self.file_num = 10 # number of files to write - self.directory = None # directory like /mnt/lf/$endp_name + self.file_num = 10 # number of files to write + self.directory = None # directory like /mnt/lf/$endp_name # this refers to locally mounted directories presently used for writing # you would set this when doing read tests simultaneously to write tests @@ -2585,14 +2637,14 @@ class FIOEndpProfile(LFCliBase): # /mnt/lf/ro_300GB_001, this overwrites a readers directory name to wo_300GB_001 self.mount_dir = "AUTO" - self.server_mount = None # like cifs://10.0.0.1/bashful or 192.168.1.1:/var/tmp + self.server_mount = None # like cifs://10.0.0.1/bashful or 192.168.1.1:/var/tmp self.mount_options = None self.iscsi_vol = None self.retry_timer_ms = 2000 - self.io_direction = io_direction # read / write + self.io_direction = io_direction # read / write self.quiesce_ms = 3000 self.pattern = "increasing" - self.file_prefix = "AUTO" # defaults to endp_name + self.file_prefix = "AUTO" # defaults to endp_name self.cx_prefix = "wo_" self.created_cx = {} @@ -2653,13 +2705,13 @@ class FIOEndpProfile(LFCliBase): "cx_name": self.created_cx[cx_name] } self.json_post(req_url, data) - #pprint(data) + # pprint(data) req_url = "cli-json/rm_endp" data = { "endp_name": cx_name } self.json_post(req_url, data) - #pprint(data) + # pprint(data) def create(self, ports=[], connections_per_port=1, sleep_time=.5, debug_=False, suppress_related_commands_=None): cx_post_data = [] @@ -2672,9 +2724,10 @@ class FIOEndpProfile(LFCliBase): else: raise ValueError("Unexpected name for port_name %s" % port_name) if self.directory is None or self.server_mount is None or self.fs_type is None: - raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % (self.directory, self.server_mount, self.fs_type)) + raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % ( + self.directory, self.server_mount, self.fs_type)) endp_data = { - "alias": self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "alias": self.cx_prefix + name + "_" + str(num_connection) + "_fio", "shelf": shelf, "resource": resource, "port": name, @@ -2696,11 +2749,12 @@ class FIOEndpProfile(LFCliBase): endp_data["directory"] = "/mnt/lf/wo_" + name + "_" + str(num_connection) + "_fio" url = "cli-json/add_file_endp" - self.local_realm.json_post(url, endp_data, debug_=False, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, endp_data, debug_=False, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) data = { - "name": self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "name": self.cx_prefix + name + "_" + str(num_connection) + "_fio", "io_direction": self.io_direction, "num_files": 5 } @@ -2716,17 +2770,19 @@ class FIOEndpProfile(LFCliBase): name = self.local_realm.name_to_eid(port_name)[2] endp_data = { - "alias": "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "alias": "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio", "test_mgr": "default_tm", - "tx_endp": self.cx_prefix + name + "_" + str(num_connection) + "_fio" , + "tx_endp": self.cx_prefix + name + "_" + str(num_connection) + "_fio", "rx_endp": "NA" } cx_post_data.append(endp_data) - self.created_cx[self.cx_prefix + name + "_" + str(num_connection) + "_fio" ] = "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" + self.created_cx[self.cx_prefix + name + "_" + str( + num_connection) + "_fio"] = "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" for cx_data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, cx_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) @@ -2753,8 +2809,8 @@ class MACVLANProfile(LFCliBase): self.ip_list = [] self.COMMANDS = ["set_port"] self.desired_set_port_cmd_flags = [] - self.desired_set_port_current_flags = [] # do not default down, "if_down" - self.desired_set_port_interest_flags = ["current_flags"] # do not default down, "ifdown" + self.desired_set_port_current_flags = [] # do not default down, "if_down" + self.desired_set_port_interest_flags = ["current_flags"] # do not default down, "ifdown" self.set_port_data = { "shelf": 1, "resource": 1, @@ -2842,7 +2898,8 @@ class MACVLANProfile(LFCliBase): self.desired_set_port_interest_flags.append("ip_address") self.desired_set_port_interest_flags.append("ip_Mask") self.desired_set_port_interest_flags.append("ip_gateway") - self.ip_list = LFUtils.gen_ip_series(ip_addr=self.first_ip_addr, netmask=self.netmask, num_ips=self.num_macvlans) + self.ip_list = LFUtils.gen_ip_series(ip_addr=self.first_ip_addr, netmask=self.netmask, + num_ips=self.num_macvlans) self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags, set_port.set_port_current_flags) @@ -2861,7 +2918,7 @@ class MACVLANProfile(LFCliBase): "resource": self.resource, "mac": "xx:xx:xx:*:*:xx", "port": self.local_realm.name_to_eid(self.macvlan_parent)[2], - "index": int(self.desired_macvlans[i][self.desired_macvlans[i].index('#')+1:]), + "index": int(self.desired_macvlans[i][self.desired_macvlans[i].index('#') + 1:]), "flags": None } if admin_down: @@ -2869,11 +2926,12 @@ class MACVLANProfile(LFCliBase): else: data["flags"] = 0 self.created_macvlans.append("%s.%s.%s#%d" % (self.shelf, self.resource, - self.macvlan_parent, int(self.desired_macvlans[i][self.desired_macvlans[i].index('#')+1:]))) + self.macvlan_parent, int( + self.desired_macvlans[i][self.desired_macvlans[i].index('#') + 1:]))) self.local_realm.json_post(req_url, data) time.sleep(sleep_time) - LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=self.created_macvlans) + LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=self.created_macvlans) print(self.created_macvlans) time.sleep(5) @@ -2909,6 +2967,7 @@ class MACVLANProfile(LFCliBase): for macvlan in self.created_macvlans: self.local_realm.admin_down(macvlan) + class PacketFilter(): def get_filter_wlan_assoc_packets(self, ap_mac, sta_mac): @@ -2933,6 +2992,7 @@ class PacketFilter(): return lines + class PortUtils(): def __init__(self, local_realm): self.local_realm = local_realm @@ -2977,6 +3037,7 @@ class PortUtils(): else: raise ValueError("Port name required") + class HTTPProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) @@ -3011,7 +3072,7 @@ class HTTPProfile(LFCliBase): if passes == expected_passes: return True else: - print(list(debug_info), " Endps in this list showed errors getting to its URL") # %s") % self.url) + print(list(debug_info), " Endps in this list showed errors getting to its URL") # %s") % self.url) return False def start_cx(self): @@ -3046,19 +3107,19 @@ class HTTPProfile(LFCliBase): "cx_name": self.created_cx[cx_name] } self.json_post(req_url, data) - #pprint(data) + # pprint(data) req_url = "cli-json/rm_endp" data = { "endp_name": cx_name } self.json_post(req_url, data) - #pprint(data) + # pprint(data) def map_sta_ips(self, sta_list=[]): for sta_eid in sta_list: eid = self.local_realm.name_to_eid(sta_eid) sta_list = self.json_get("/port/%s/%s/%s?fields=alias,ip" % - (eid[0], eid[1], eid[2])) + (eid[0], eid[1], eid[2])) if sta_list['interface'] is not None: self.ip_map[sta_list['interface']['alias']] = sta_list['interface']['ip'] @@ -3070,7 +3131,7 @@ class HTTPProfile(LFCliBase): url = None if i != len(list(self.ip_map)) - 1: port_name = list(self.ip_map)[i] - ip_addr = self.ip_map[list(self.ip_map)[i+1]] + ip_addr = self.ip_map[list(self.ip_map)[i + 1]] else: port_name = list(self.ip_map)[i] ip_addr = self.ip_map[list(self.ip_map)[0]] @@ -3091,7 +3152,7 @@ class HTTPProfile(LFCliBase): if ftp: self.port_util.set_ftp(port_name=name, resource=resource, on=True) if user is not None and passwd is not None and source is not None: - url = "%s ftp://%s:%s@%s%s %s" % (self.direction, user, passwd, ip_addr, source, self.dest) + url = "%s ftp://%s:%s@%s%s %s" % (self.direction, user, passwd, ip_addr, source, self.dest) else: raise ValueError("user: %s, passwd: %s, and source: %s must all be set" % (user, passwd, source)) if not http and not ftp: @@ -3112,7 +3173,8 @@ class HTTPProfile(LFCliBase): "proxy_auth_type": 0x200 } url = "cli-json/add_l4_endp" - self.local_realm.json_post(url, endp_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, endp_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) endp_data = { @@ -3126,7 +3188,8 @@ class HTTPProfile(LFCliBase): for cx_data in cx_post_data: url = "/cli-json/add_cx" - self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) + self.local_realm.json_post(url, cx_data, debug_=debug_, + suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) @@ -3159,8 +3222,8 @@ class StationProfile: self.ssid_pass = ssid_pass self.mode = mode self.up = up - self.resource=resource - self.shelf=shelf + self.resource = resource + self.shelf = shelf self.dhcp = dhcp self.security = security self.local_realm = local_realm @@ -3226,7 +3289,7 @@ class StationProfile: pairwise="CCMP TKIP", group="CCMP TKIP", psk="[BLANK]", - wep_key="[BLANK]", #wep key + wep_key="[BLANK]", # wep key ca_cert="[BLANK]", eap="TTLS", identity="testuser", @@ -3302,7 +3365,7 @@ class StationProfile: self.desired_add_sta_flags_mask.remove(name) if security_type != "open": self.desired_add_sta_flags.append(types[security_type]) - #self.set_command_flag("add_sta", types[security_type], 1) + # self.set_command_flag("add_sta", types[security_type], 1) self.desired_add_sta_flags_mask.append(types[security_type]) else: passwd = "[BLANK]" @@ -3312,7 +3375,7 @@ class StationProfile: if security_type == "wpa3": self.set_command_param("add_sta", "ieee80211w", 2) - #self.add_sta_data["key"] = passwd + # self.add_sta_data["key"] = passwd def set_command_param(self, command_name, param_name, param_value): # we have to check what the param name is @@ -3351,7 +3414,9 @@ class StationProfile: self.desired_add_sta_flags_mask.append(param_name) elif command_name == "set_port": - if (param_name not in set_port.set_port_current_flags) and (param_name not in set_port.set_port_cmd_flags) and (param_name not in set_port.set_port_interest_flags): + if (param_name not in set_port.set_port_current_flags) and ( + param_name not in set_port.set_port_cmd_flags) and ( + param_name not in set_port.set_port_interest_flags): print("Parameter name [%s] not defined in set_port.py" % param_name) if self.debug: pprint(set_port.set_port_cmd_flags) @@ -3374,7 +3439,8 @@ class StationProfile: elif value == 0: self.desired_set_port_interest_flags.remove(param_name) else: - raise ValueError("Unknown param name: "+param_name) + raise ValueError("Unknown param name: " + param_name) + # use this for hinting station name; stations begin with 'sta', the # stations created with a prefix '0100' indicate value 10100 + n with # resulting substring(1,) applied; station 900 becomes 'sta1000' @@ -3426,10 +3492,9 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: self.local_realm.rm_port(port_eid, check_exists=True, debug_=debug_) - time.sleep(delay) - # And now see if they are gone - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) + # And now see if they are gone + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) # Checks for errors in initialization values and creates specified number of stations using init parameters def create(self, radio, @@ -3473,7 +3538,7 @@ class StationProfile: self.desired_add_sta_flags.append("create_admin_down") # create stations down, do set_port on them, then set stations up - self.add_sta_data["flags"] = self.add_named_flags(self.desired_add_sta_flags, add_sta.add_sta_flags) + self.add_sta_data["flags"] = self.add_named_flags(self.desired_add_sta_flags, add_sta.add_sta_flags) self.add_sta_data["flags_mask"] = self.add_named_flags(self.desired_add_sta_flags_mask, add_sta.add_sta_flags) self.add_sta_data["radio"] = radio_port @@ -3493,14 +3558,14 @@ class StationProfile: # these are unactivated LFRequest objects that we can modify and # re-use inside a loop, reducing the number of object creations add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta", debug_=debug) - set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port",debug_=debug) - wifi_extra_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_wifi_extra",debug_=debug) + set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port", debug_=debug) + wifi_extra_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_wifi_extra", debug_=debug) my_sta_names = [] - #add radio here + # add radio here if (num_stations > 0) and (len(sta_names_) < 1): - #print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") + # print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") my_sta_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template)) - #print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") + # print("CREATING MORE STA NAMES == == == == == == == == == == == == == == == == == == == == == == == ==") else: my_sta_names = sta_names_ @@ -3540,7 +3605,7 @@ class StationProfile: self.add_sta_data["shelf"] = radio_shelf self.add_sta_data["resource"] = radio_resource self.add_sta_data["radio"] = radio_port - self.add_sta_data["sta_name"] = name # for create station calls + self.add_sta_data["sta_name"] = name # for create station calls self.set_port_data["port"] = name # for set_port calls. self.set_port_data["shelf"] = radio_shelf self.set_port_data["resource"] = radio_resource @@ -3554,7 +3619,7 @@ class StationProfile: pprint(self.set_port_data) print("- ~3254 - - - - - - - - - - - - - - - - - - - ") if dry_run: - print("dry run: not creating "+eidn) + print("dry run: not creating " + eidn) continue # print("- 3264 - ## %s ## add_sta_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) @@ -3563,9 +3628,9 @@ class StationProfile: # print("- ~3264 - %s - add_sta_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) time.sleep(0.01) set_port_r.addPostData(self.set_port_data) - #print("- 3270 -- %s -- set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) + # print("- 3270 -- %s -- set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) json_response = set_port_r.jsonPost(debug) - #print("- ~3270 - %s - set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) + # print("- ~3270 - %s - set_port_r.jsonPost - - - - - - - - - - - - - - - - - - "%eidn) time.sleep(0.01) self.wifi_extra_data["resource"] = radio_resource @@ -3578,7 +3643,7 @@ class StationProfile: self.station_names.append("%s.%s.%s" % (radio_shelf, radio_resource, name)) time.sleep(sleep_time) - #print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - "%eidn) + # print("- ~3287 - waitUntilPortsAppear - - - - - - - - - - - - - - - - - - "%eidn) LFUtils.wait_until_ports_appear(self.lfclient_url, my_sta_names) # and set ports up diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index e52ce374..50eabf11 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -264,6 +264,7 @@ python3 ./test_ipv4_variable_time.py script_name='test_ipv4_variable_time', show=show, arguments=args) + print(ip_var_test.cx_profile.create()) ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From 7b7aaa25db1c359fa51e30918ac2bf2bb4c306a8 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 18 Jan 2021 14:02:06 -0800 Subject: [PATCH 160/848] rename show to monitor --- py-json/realm.py | 94 +++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 26af6817..1c15616a 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -20,6 +20,7 @@ import base64 import xlsxwriter import pandas as pd + def wpa_ent_list(): return [ "DEFAULT", @@ -45,6 +46,7 @@ def wpa_ent_list(): "OWE" ] + class Realm(LFCliBase): def __init__(self, lfclient_host="localhost", @@ -67,13 +69,13 @@ class Realm(LFCliBase): # self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) super().__init__(lfclient_host, lfclient_port, - _debug=debug_, - _halt_on_error=halt_on_error_, - _exit_on_error=_exit_on_error, - _exit_on_fail=_exit_on_fail, - #_local_realm=self, - _proxy_str=_proxy_str, - _capture_signal_list=_capture_signal_list) + _debug=debug_, + _halt_on_error=halt_on_error_, + _exit_on_error=_exit_on_error, + _exit_on_fail=_exit_on_fail, + # _local_realm=self, + _proxy_str=_proxy_str, + _capture_signal_list=_capture_signal_list) self.debug = debug_ # if debug_: @@ -638,7 +640,6 @@ class Realm(LFCliBase): num_sta_with_ips += 1 return num_sta_with_ips - def duration_time_to_seconds(self, time_string): if isinstance(time_string, str): pattern = re.compile("^(\d+)([dhms]$)") @@ -1049,7 +1050,6 @@ class MULTICASTProfile(LFCliBase): pprint.pprint(self) - class L3CXProfile(BaseProfile): def __init__(self, lfclient_host, @@ -1143,13 +1143,13 @@ class L3CXProfile(BaseProfile): monitor_interval=1, col_names=None, created_cx=None, - show=False, + monitor=True, report_file=None, output_format=None, script_name=None, arguments=None): try: - duration_sec=self.parse_time(duration_sec).seconds + duration_sec = self.parse_time(duration_sec).seconds except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") @@ -1189,7 +1189,7 @@ class L3CXProfile(BaseProfile): if "endpoint" not in response: print(response) raise ValueError("no endpoint?") - if show: + if monitor: print(response) t = datetime.datetime.now() timestamps.append(t) @@ -1908,8 +1908,6 @@ class WifiMonitor: baseurl=self.lfclient_url, debug=self.debug) - - def admin_up(self): up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.monitor_name) self.local_realm.json_post("/cli-json/set_port", up_request) @@ -2389,7 +2387,6 @@ class VRProfile(LFCliBase): else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - def create(self, resource, upstream_port="eth1", debug=False, upstream_subnets="20.20.20.0/24", upstream_nexthop="20.20.20.1", local_subnets="10.40.0.0/24", local_nexthop="10.40.3.198", @@ -2422,38 +2419,38 @@ class VRProfile(LFCliBase): class DUTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True, _local_realm=local_realm) - self.name = "NA" - self.flags = "NA" - self.img_file = "NA" - self.sw_version = "NA" - self.hw_version = "NA" - self.model_num = "NA" - self.serial_num = "NA" - self.serial_port = "NA" - self.wan_port = "NA" - self.lan_port = "NA" - self.ssid1 = "NA" - self.ssid2 = "NA" - self.ssid3 = "NA" - self.passwd1 = "NA" - self.passwd2 = "NA" - self.passwd3 = "NA" - self.mgt_ip = "NA" - self.api_id = "NA" - self.flags_mask = "NA" - self.antenna_count1 = "NA" - self.antenna_count2 = "NA" - self.antenna_count3 = "NA" - self.bssid1 = "NA" - self.bssid2 = "NA" - self.bssid3 = "NA" - self.top_left_x = "NA" - self.top_left_y = "NA" - self.eap_id = "NA" - self.flags = 0 - self.flags_mask = 0 - self.notes = [] - self.append = [] + self.name = "NA" + self.flags = "NA" + self.img_file = "NA" + self.sw_version = "NA" + self.hw_version = "NA" + self.model_num = "NA" + self.serial_num = "NA" + self.serial_port = "NA" + self.wan_port = "NA" + self.lan_port = "NA" + self.ssid1 = "NA" + self.ssid2 = "NA" + self.ssid3 = "NA" + self.passwd1 = "NA" + self.passwd2 = "NA" + self.passwd3 = "NA" + self.mgt_ip = "NA" + self.api_id = "NA" + self.flags_mask = "NA" + self.antenna_count1 = "NA" + self.antenna_count2 = "NA" + self.antenna_count3 = "NA" + self.bssid1 = "NA" + self.bssid2 = "NA" + self.bssid3 = "NA" + self.top_left_x = "NA" + self.top_left_y = "NA" + self.eap_id = "NA" + self.flags = 0 + self.flags_mask = 0 + self.notes = [] + self.append = [] def set_param(self, name, value): if (name in self.__dict__): @@ -2958,7 +2955,6 @@ class MACVLANProfile(LFCliBase): # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.created_macvlans) - def admin_up(self): for macvlan in self.created_macvlans: self.local_realm.admin_up(macvlan) @@ -3229,7 +3225,7 @@ class StationProfile: self.local_realm = local_realm self.use_ht160 = use_ht160 self.COMMANDS = ["add_sta", "set_port"] - self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] + self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.desired_add_sta_flags_mask = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.number_template = number_template_ self.station_names = [] # eids, these are created station names From 5d95390fba895051fdb09148c52f9131eff2b275 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 18 Jan 2021 14:35:25 -0800 Subject: [PATCH 161/848] small fix to variable_time --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 50eabf11..bb6b59e2 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -264,7 +264,7 @@ python3 ./test_ipv4_variable_time.py script_name='test_ipv4_variable_time', show=show, arguments=args) - print(ip_var_test.cx_profile.create()) + ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From 554892d0cf1ec7e494d0b12a1b2d6adca667a328 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 19 Jan 2021 11:32:16 -0800 Subject: [PATCH 162/848] python update script --- py-scripts/update_deps.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 py-scripts/update_deps.sh diff --git a/py-scripts/update_deps.sh b/py-scripts/update_deps.sh new file mode 100755 index 00000000..3d6ffe6c --- /dev/null +++ b/py-scripts/update_deps.sh @@ -0,0 +1 @@ +pip install pandas seaborn plotly numpy --upgrade From 198ddd99260bb0e30f5c958f7699f11c6e928cc9 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 19 Jan 2021 16:44:02 -0800 Subject: [PATCH 163/848] install dash on machines --- py-scripts/update_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/update_deps.sh b/py-scripts/update_deps.sh index 3d6ffe6c..0ff68504 100755 --- a/py-scripts/update_deps.sh +++ b/py-scripts/update_deps.sh @@ -1 +1 @@ -pip install pandas seaborn plotly numpy --upgrade +pip install pandas seaborn plotly numpy dash --upgrade From cc83acc6fbbc155dd4db7b8568dfcf61155efe3e Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 19 Jan 2021 13:26:52 -0800 Subject: [PATCH 164/848] help and debug changes --- py-json/realm.py | 12 ++++++--- py-scripts/test_ipv4_variable_time.py | 35 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 1c15616a..4731f543 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1298,15 +1298,19 @@ class L3CXProfile(BaseProfile): "cx_name": cx_name, "cx_state": "RUNNING" }, debug_=self.debug) - print(".", end='') - print("") + if self.debug: + print(".", end='') + if self.debug: + print("") def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): self.stopping_cx(cx_name) - print(".", end='') - print("") + if self.debug: + print(".", end='') + if self.debug: + print("") def cleanup_prefix(self): self.cleanup_cxe_prefix(self.name_prefix) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index bb6b59e2..0fc88639 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -182,6 +182,8 @@ python3 ./test_ipv4_variable_time.py --a_min 1000 --b_min 1000 --ap "00:0e:8e:78:e1:76" + --output_format csv + --report_file ~/Documents/results.csv (if csv file - please use another extension for other files) --debug ''') @@ -190,10 +192,8 @@ python3 ./test_ipv4_variable_time.py if group.title == "required arguments": required_args=group break - if required_args is not None: - required_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) - required_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) - required_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") + #if required_args is not None: + optional_args=None for group in parser._action_groups: if group.title == "optional arguments": @@ -204,13 +204,30 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--ap',help='Used to force a connection to a particular AP') optional_args.add_argument('--report_file',help='where you want to store results') optional_args.add_argument('--output_format', help='choose either csv or xlsx') - optional_args.add_argument('--show', help='display results of test in terminal',default=True) + optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) + optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) + optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) + if args.report_file is None: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: + report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format + output=args.output_format + else: + print('Defaulting to Excel') + report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' + output='excel' + else: + report_f=args.report_file + if args.output_format is None: + output=str(args.report_file).split('.')[-1] + else: + output=args.output_format + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio) ip_var_test = IPV4VariableTime(host=args.mgr, port=args.mgr_port, @@ -252,17 +269,13 @@ python3 ./test_ipv4_variable_time.py else: output=args.output_format - try: - layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) - except: - raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs','Rx Drop % A', 'Rx Drop % B', 'Bps Rx A', 'Bps Rx B', 'Rx Rate', 'Cx Estab'], + layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) + ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds, created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', - show=show, arguments=args) ip_var_test.stop() From c544d4424b4313b35973c8f809781238d09e4a22 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 19 Jan 2021 13:30:23 -0800 Subject: [PATCH 165/848] debug --- py-json/realm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 4731f543..6db7c973 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1190,7 +1190,8 @@ class L3CXProfile(BaseProfile): print(response) raise ValueError("no endpoint?") if monitor: - print(response) + if self.debug: + print(response) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response From e4869e715a9fe47677162ed9dc7e16f929477cfa Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 03:38:34 +0530 Subject: [PATCH 166/848] test_utility update --- py-json/LANforge/lfcli_base.py | 1 + py-scripts/connection_test.py | 11 +- py-scripts/test_utility.py | 317 --------------------------------- 3 files changed, 10 insertions(+), 319 deletions(-) delete mode 100644 py-scripts/test_utility.py diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index fac37d88..208deb23 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -293,6 +293,7 @@ class LFCliBase: debug_=debug_, die_on_error_=self.exit_on_error) json_response = lf_r.json_delete(debug=debug_, die_on_error_=self.halt_on_error) + print(json_response) #debug_printer.pprint(json_response) if (json_response is None) and debug_: print("LFCliBase.json_delete: no entity/response, probabily status 404") diff --git a/py-scripts/connection_test.py b/py-scripts/connection_test.py index 1719bd6d..525b4fa6 100644 --- a/py-scripts/connection_test.py +++ b/py-scripts/connection_test.py @@ -24,6 +24,7 @@ from test_utility import CreateHTML from test_utility import StatusMsg import pdfkit + webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) class ConnectionTest(LFCliBase): @@ -97,6 +98,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('3', {"data": 'Building...', "data": [], "label": "Client Connectivity Time"}) except: pass + def build(self): self.station_profile.use_security(self.security, self.ssid, self.password) @@ -111,6 +113,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('4', {"data": 'Starting...', "data": [], "label": "Client Connectivity Time"}) except: pass + def update(self, status="None"): for i in self.station_list: self.station_data[i.split(".")[2]] = \ @@ -119,6 +122,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('5', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) except: pass + def start(self): self.station_profile.admin_up() associated_map = {} @@ -213,6 +217,7 @@ class ConnectionTest(LFCliBase): self.status_msg.update('6', {"data": 'None', "data": [], "label": "Client Connectivity Time"}) except: pass + def stop(self): self.station_profile.admin_down() LFUtils.wait_until_ports_admin_down(port_list=self.station_profile.station_names) @@ -258,12 +263,14 @@ def main(): obj.status_msg.update('10', {"data": 'done...', "data": [], "label": "Client Connectivity Time"}) except: pass - + for i in obj.status_msg.read()['messages']: + print(i) def getSessionID(): x = datetime.datetime.now() id = x.strftime("%x").replace("/","_")+"_"+x.strftime("%x") + "_" + x.strftime("%X").split(":")[0] + "_" + x.strftime("%X").split(":")[1] + "_" + x.strftime("%X").split(":")[2]+str(x).split(".")[1] - id = str(id).replace("/", "_") + id = str(id).replace("/", "_").split("P")[0].replace(" ","") return id + if __name__ == '__main__': main() diff --git a/py-scripts/test_utility.py b/py-scripts/test_utility.py deleted file mode 100644 index f684528b..00000000 --- a/py-scripts/test_utility.py +++ /dev/null @@ -1,317 +0,0 @@ - -""" -Candela Technologies Inc. - -Info : Standard Script for Webconsole Test Utility -Date : - - -""" - -import sys -from pprint import pprint -from uuid import uuid1 - -if 'py-json' not in sys.path: - sys.path.append('../py-json') -from LANforge import LFUtils -from LANforge import lfcli_base -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -import realm -from realm import PortUtils -import argparse -import datetime -import time -import matplotlib.pyplot as plt -import threading -import re -import json -import os -webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) -updates_path = webconsole_dir + "/web_json/updates.js" - - -class ClientVisualization(LFCliBase, threading.Thread): - def __init__(self, lfclient_host="localhost", lfclient_port=8080, num_clients= 64, max_data= 120, thread_id=None, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): - super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, - _exit_on_fail=_exit_on_fail) - threading.Thread.__init__(self) - self.num_clients = num_clients - self.max_data = max_data - self._stop_event = threading.Event() - self.client_data = {"down":[], "phantom":[], "ip":[], "scanning":[]} - - def stop(self): - self._stop_event.set() - - def stopped(self): - return self._stop_event.is_set() - - def run(self): - self.start_thread() - - def start_thread(self): - while True: - self.scanning = 0 - self.ip = 0 - self.down = 0 - self.phantom = 0 - for i in self.json_get("/port/list?fields=port,alias,parent%20dev,down,phantom,ip,port%20type")['interfaces']: - - for j in i: - print(i[j]['port type']) - if i[j]['port type'] == "WIFI-STA" and i[j]['parent dev'] == "wiphy1" and i[j]['alias'] != 'wlan1': - #print(j) - if i[j]['down'] == False and i[j]['phantom'] == False and i[j]['ip'] == '0.0.0.0': - self.scanning += 1 - elif i[j]['down'] == False and i[j]['phantom'] == True: - self.phantom += 1 - elif i[j]['down'] == True and i[j]['phantom'] == True: - self.phantom += 1 - self.client_data['phantom'].append(self.phantom) - elif i[j]['down'] == True and i[j]['phantom'] == False: - self.down += 1 - elif i[j]['ip'] != "0.0.0.0": - self.ip += 1 - else: - continue - self.client_data['scanning'].append(self.scanning) - self.client_data['phantom'].append(self.phantom) - self.client_data['down'].append(self.down) - self.client_data['ip'].append(self.ip) - - - for i in self.client_data: - if len(self.client_data[i]) >= self.max_data: - self.client_data[i].pop(0) - time.sleep(1) - if self.stopped(): - break - - -class CreateHTML(): - def __init__(self, path="", test_name="", time_snap="", dut_ssid="", test_conf_data={}, objective="", test_results={}, chart_data={}, chart_params={}): - self.head = """ - - - """+test_name+""" - - -
- -
-
-

"""+test_name+"""

-

"""+time_snap+"""

-
-
-
- """ - self.test_conf = """ - - - - - - - - -
- Test Setup Information -
- Device Under Test - - - - - - - """ - - for i in test_conf_data: - self.test_conf = self.test_conf + """ - - - - """ - - self.test_conf = self.test_conf + """
- SSID - """+dut_ssid+""" -
"""+str(i)+""" - """+test_conf_data[i]+""" -
-
- """ - - self.objective = """ -

Objective

- """+objective+""" -

-
- """ - - if str(test_results['summary']).__contains__("PASS"): - self.summary_results =""" -
- - - - - - - -
- Summary Results -
- """ + test_results['summary'] + """ -
-
- """ - else: - self.summary_results = """ -
- - - - - - - -
- Summary Results -
- """ + test_results['summary'] + """ -
-
- """ - chart_d =[] - chart_label =[] - for i in chart_data: - chart_label.append(i) - chart_d.append(chart_data[i]) - - - - - self.detail_result = """ - -
Detailed Results
- - """ - for index in test_results['detail']['keys']: - self.detail_result = self.detail_result+"" - self.detail_result = self.detail_result +"" - - for data in test_results['detail']['data']: - self.detail_result = self.detail_result + "" - print("shivam") - print(data) - for i in data: - print(data[i]) - if str(data[i]).__contains__("PASS"): - self.detail_result = self.detail_result + "" - elif str(data[i]).__contains__("FAIL"): - self.detail_result = self.detail_result + "" - else: - self.detail_result = self.detail_result + "" - self.detail_result = self.detail_result +"" - - self.chart_data = chart_data - chart_values = [] - for i in self.chart_data: - chart_values.append(self.chart_data[i]) - plt.bar(list(self.chart_data.keys()), chart_values, tick_label=list(self.chart_data.keys())) - - plt.xlabel(chart_params['xlabel']) - # naming the y-axis - plt.ylabel(chart_params['ylabel']) - # plot title - plt.title(chart_params['chart_head']) - plt.xticks(rotation=90, fontsize=8) - plt.tight_layout() - # function to show the plot - plt.savefig(fname=path + "plot.png") - plt.close() - - self.chart = """""" - - - self.end = """
"+index+"
" + str(data[i]) + "" + str(data[i]) + "" + str(data[i]) + "
- - - - """ - self.report = self.head + self.test_conf + self.objective + self.summary_results + self.chart +self.detail_result + self.end - - - -class RuntimeUpdates(): - def __init__(self, session_id, init_data): - self.session_id = session_id - self.init_data = init_data - f = open(updates_path, 'r+') - data = f.read() - f.close() - obj = data[data.find('{'): data.rfind('}') + 1] - obj = re.sub('[\']', '"', obj) - data = json.loads(obj) - print(data) - data["web_updates"].append({"ID": self.session_id, "data": self.init_data}) - print(data) - f = open(updates_path, 'r+') - f.seek(0) - f.truncate() - f.write("var updates = " + str(data) + ";") - f.close() - - def send_update(self, update_data): - f = open(updates_path, 'r+') - data = f.read() - f.close() - obj = data[data.find('{'): data.rfind('}') + 1] - obj = re.sub('[\']', '"', obj) - data = json.loads(obj) - - for update in data["web_updates"]: - if update["ID"] == self.session_id: - update["data"] = update_data - print(data) - f = open(updates_path, 'r+') - f.seek(0) - f.truncate() - f.write("var updates = " + str(data) + ";") - f.close() - - -class StatusMsg(LFCliBase): - def __init__(self, lfclient_host="localhost", lfclient_port=8080, - _deep_clean=False, - session_id="0", - _debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.deep_clean = _deep_clean - self.session_id = session_id - self.json_put("/status-msg/" + self.session_id, {}) - - def update(self, key, message): - self.json_post("/status-msg/" + self.session_id, { - "key": key, - "content-type": "text/plain", - "message": message - }) - pass - - - - - - -if __name__ == "__main__": - obj = StatusMsg(lfclient_host="192.168.200.15", lfclient_port=8080, session_id="Connection Test") - obj.update() - - From 78e714819646effa6d75efd6eae666287973be0b Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 03:55:06 +0530 Subject: [PATCH 167/848] basic arg parse update --- py-json/LANforge/lfcli_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 208deb23..fbfcae82 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -513,9 +513,9 @@ class LFCliBase: help='Connection proxy like http://proxy.localnet:80 or https://user:pass@proxy.localnet:3128') #Required Args required.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') - required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >') + required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', default="open") required.add_argument('--ssid', help='WiFi SSID for script objects to associate to') - required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key') + required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key', default="[BLANK]") return parser From 29353588ea876dbf938d65ec1aa55c8af3d5b483 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:38:40 -0800 Subject: [PATCH 168/848] html test output --- py-json/realm.py | 14 +- py-scripts/create_macvlan.py | 364 ++++---------------------- py-scripts/html_test_output.sh | 121 +++++++++ py-scripts/test_ipv4_variable_time.py | 11 +- 4 files changed, 191 insertions(+), 319 deletions(-) create mode 100644 py-scripts/html_test_output.sh diff --git a/py-json/realm.py b/py-json/realm.py index 6db7c973..149687b9 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1171,7 +1171,10 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] # Step 1, column names - fields = ",".join(col_names) + if fields = None: + pass + else: + fields = ",".join(col_names) print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() @@ -1184,8 +1187,13 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): + if col_names = None: + header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) + if fields = None: + response = self.json_get("/endp/all") + else: + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1211,8 +1219,6 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) - # if passes == expected_passes: - # self._pass("PASS: All tests passed") # step 3 organize data endpoints = list() for endpoint in value_map.values(): diff --git a/py-scripts/create_macvlan.py b/py-scripts/create_macvlan.py index 90a5204e..aa78ae66 100755 --- a/py-scripts/create_macvlan.py +++ b/py-scripts/create_macvlan.py @@ -1,325 +1,105 @@ #!/usr/bin/env python3 import sys + if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) if 'py-json' not in sys.path: sys.path.append('../py-json') - -# import argparse from LANforge.lfcli_base import LFCliBase from LANforge.LFUtils import * from LANforge import LFUtils -from LANforge import add_file_endp from LANforge.add_file_endp import * import argparse from realm import Realm -import time -import datetime -import pprint -class FileIOTest(Realm): - def __init__(self, host, port, ssid, security, password, - number_template="00000", +class CreateMacVlan(Realm): + def __init__(self, host, port, radio="wiphy0", - test_duration="5m", upstream_port="eth1", num_ports=1, - server_mount="10.40.0.1:/var/tmp/test", macvlan_parent=None, first_mvlan_ip=None, netmask=None, gateway=None, dhcp=True, - use_macvlans=False, - use_test_groups=False, - write_only_test_group=None, - read_only_test_group=None, port_list=[], ip_list=None, connections_per_port=1, - mode="both", - update_group_args={"name": None, "action": None, "cxs": None}, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port) - self.host = host self.port = port self.radio = radio self.upstream_port = upstream_port - self.ssid = ssid - self.security = security - self.password = password - self.number_template = number_template - self.test_duration = test_duration self.port_list = [] self.connections_per_port = connections_per_port - self.use_macvlans = use_macvlans - self.mode = mode.lower() self.ip_list = ip_list self.netmask = netmask self.gateway = gateway self.dhcp = dhcp - if self.use_macvlans: - if macvlan_parent is not None: - self.macvlan_parent = macvlan_parent - self.port_list = port_list - else: + if macvlan_parent is not None: + self.macvlan_parent = macvlan_parent self.port_list = port_list - self.use_test_groups = use_test_groups - if self.use_test_groups: - if self.mode == "write": - if write_only_test_group is not None: - self.write_only_test_group = write_only_test_group - else: - raise ValueError("--write_only_test_group must be used to set test group name") - if self.mode == "read": - if read_only_test_group is not None: - self.read_only_test_group = read_only_test_group - else: - raise ValueError("--read_only_test_group must be used to set test group name") - if self.mode == "both": - if write_only_test_group is not None and read_only_test_group is not None: - self.write_only_test_group = write_only_test_group - self.read_only_test_group = read_only_test_group - else: - raise ValueError("--write_only_test_group and --read_only_test_group " - "must be used to set test group names") - - - - self.wo_profile = self.new_fio_endp_profile() self.mvlan_profile = self.new_mvlan_profile() - if not self.use_macvlans and len(self.port_list) > 0: - self.station_profile = self.new_station_profile() - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - self.wo_profile.server_mount = server_mount - self.wo_profile.num_connections_per_port = connections_per_port - - self.ro_profile = self.wo_profile.create_ro_profile() - - if self.use_macvlans: - self.mvlan_profile.num_macvlans = int(num_ports) - self.mvlan_profile.desired_macvlans = self.port_list - self.mvlan_profile.macvlan_parent = self.macvlan_parent - self.mvlan_profile.dhcp = dhcp - self.mvlan_profile.netmask = netmask - self.mvlan_profile.first_ip_addr = first_mvlan_ip - self.mvlan_profile.gateway = gateway + self.mvlan_profile.num_macvlans = int(num_ports) + self.mvlan_profile.desired_macvlans = self.port_list + self.mvlan_profile.macvlan_parent = self.macvlan_parent + self.mvlan_profile.dhcp = dhcp + self.mvlan_profile.netmask = netmask + self.mvlan_profile.first_ip_addr = first_mvlan_ip + self.mvlan_profile.gateway = gateway self.created_ports = [] - if self.use_test_groups: - if self.mode is not None: - if self.mode == "write": - self.wo_tg_profile = self.new_test_group_profile() - self.wo_tg_profile.group_name = self.write_only_test_group - elif self.mode == "read": - self.ro_tg_profile = self.new_test_group_profile() - self.ro_tg_profile.group_name = self.read_only_test_group - elif self.mode == "both": - self.wo_tg_profile = self.new_test_group_profile() - self.ro_tg_profile = self.new_test_group_profile() - self.wo_tg_profile.group_name = self.write_only_test_group - self.ro_tg_profile.group_name = self.read_only_test_group - else: - raise ValueError("Unknown mode given ", self.mode) - else: - raise ValueError("Mode ( read, write, or both ) must be specified") - - if update_group_args is not None and update_group_args['name'] is not None: - temp_tg = self.new_test_group_profile() - temp_cxs = update_group_args['cxs'].split(',') - if update_group_args['action'] == "add": - temp_tg.group_name = update_group_args['name'] - if not temp_tg.check_group_exists(): - temp_tg.create_group() - for cx in temp_cxs: - if "CX_" not in cx: - cx = "CX_" + cx - temp_tg.add_cx(cx) - if update_group_args['action'] == "del": - temp_tg.group_name = update_group_args['name'] - if temp_tg.check_group_exists(): - for cx in temp_cxs: - temp_tg.rm_cx(cx) - time.sleep(5) - - self.wo_tg_exists = False - self.ro_tg_exists = False - self.wo_tg_cx_exists = False - self.ro_tg_cx_exists = False - print("Checking for pre-existing test groups and cxs") - if self.use_test_groups: - if self.mode == "write": - if self.wo_tg_profile.check_group_exists(): - self.wo_tg_exists = True - if len(self.wo_tg_profile.list_cxs()) > 0: - self.wo_tg_cx_exists = True - elif self.mode == "read": - if self.ro_tg_profile.check_group_exists(): - self.ro_tg_exists = True - if len(self.ro_tg_profile.list_cxs()) > 0: - self.ro_tg_cx_exists = True - elif self.mode == "both": - if self.wo_tg_profile.check_group_exists(): - self.wo_tg_exists = True - if len(self.wo_tg_profile.list_cxs()) > 0: - self.wo_tg_cx_exists = True - if self.ro_tg_profile.check_group_exists(): - self.ro_tg_exists = True - if len(self.ro_tg_profile.list_cxs()) > 0: - self.ro_tg_cx_exists = True - - def __compare_vals(self, val_list): - passes = 0 - expected_passes = 0 - # print(val_list) - for item in val_list: - expected_passes += 1 - # print(item) - if item[0] == 'r': - # print("TEST", item, - # val_list[item]['read-bps'], - # self.ro_profile.min_read_rate_bps, - # val_list[item]['read-bps'] > self.ro_profile.min_read_rate_bps) - - if val_list[item]['read-bps'] > self.wo_profile.min_read_rate_bps: - passes += 1 - else: - # print("TEST", item, - # val_list[item]['write-bps'], - # self.wo_profile.min_write_rate_bps, - # val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps) - - if val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps: - passes += 1 - if passes == expected_passes: - return True - else: - return False - else: - return False - - def __get_values(self): - time.sleep(3) - if self.mode == "write": - cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % ( - ','.join(self.wo_profile.created_cx.keys())), debug_=self.debug) - elif self.mode == "read": - cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % ( - ','.join(self.ro_profile.created_cx.keys())), debug_=self.debug) - else: - cx_list = self.json_get("fileio/%s,%s?fields=write-bps,read-bps" % ( - ','.join(self.wo_profile.created_cx.keys()), - ','.join(self.ro_profile.created_cx.keys())), debug_=self.debug) - # print(cx_list) - # print("==============\n", cx_list, "\n==============") - cx_map = {} - # pprint.pprint(cx_list) - if cx_list is not None: - cx_list = cx_list['endpoint'] - for i in cx_list: - for item, value in i.items(): - # print(item, value) - cx_map[self.name_to_eid(item)[2]] = {"read-bps": value['read-bps'], "write-bps": value['write-bps']} - # print(cx_map) - return cx_map def build(self): # Build stations - if self.use_macvlans: - print("Creating MACVLANs") - self.mvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug) - self._pass("PASS: MACVLAN build finished") - self.created_ports += self.mvlan_profile.created_macvlans - elif not self.use_macvlans and self.ip_list is None: - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - 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=self.radio, sta_names_=self.port_list, debug=self.debug) - self._pass("PASS: Station build finished") - self.created_ports += self.station_profile.station_names - - if len(self.ip_list) > 0: - # print("++++++++++++++++\n", self.ip_list, "++++++++++++++++\n") - for num_port in range(len(self.port_list)): - if self.ip_list[num_port] != 0: - if self.gateway is not None and self.netmask is not None: - shelf = self.name_to_eid(self.port_list[num_port])[0] - resource = self.name_to_eid(self.port_list[num_port])[1] - port = self.name_to_eid(self.port_list[num_port])[2] - req_url = "/cli-json/set_port" - data = { - "shelf": shelf, - "resource": resource, - "port": port, - "ip_addr": self.ip_list[num_port], - "netmask": self.netmask, - "gateway": self.gateway - } - self.json_post(req_url, data) - self.created_ports.append("%s.%s.%s" % (shelf, resource, port)) - else: - raise ValueError("Netmask and gateway must be specified") - + print("Creating MACVLANs") + self.mvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug) + self._pass("PASS: MACVLAN build finished") + self.created_ports += self.mvlan_profile.created_macvlans def main(): parser = LFCliBase.create_bare_argparse( prog='create_macvlan.py', # formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, - epilog='''Creates FileIO endpoints which can be NFS, CIFS or iSCSI endpoints.''', + epilog='''Creates MACVLAN endpoints.''', description='''\ create_macvlan.py: -------------------- Generic command layout: -./create_macvlan.py --macvlan_parent --num_ports --use_macvlans +./create_macvlan.py --macvlan_parent --num_ports --first_mvlan_ip --netmask --gateway -./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 +./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 -./create_macvlan.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans - --use_ports eth1#0,eth1#1,eth1#2 --connections_per_port 2 --mode write +./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 + --use_ports eth1#0,eth1#1,eth1#2 --connections_per_port 2 -./create_macvlan.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans +./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 --first_mvlan_ip 10.40.3.100 --netmask 255.255.240.0 --gateway 10.40.0.1 - --use_test_groups --write_only_test_group test_wo --read_only_test_group test_ro --add_to_group test_wo -./create_macvlan.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans +./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 --use_ports eth1#0=10.40.3.103,eth1#1,eth1#2 --connections_per_port 2 --netmask 255.255.240.0 --gateway 10.40.0.1 ''') parser.add_argument('--num_stations', help='Number of stations to create', default=0) parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') - parser.add_argument('--ssid', help='SSID for stations to associate to') - parser.add_argument('--passwd', '--password', '--key', help='WiFi passphrase/password/key') - parser.add_argument('--security', help='security type to use for ssid { wep | wpa | wpa2 | wpa3 | open }') parser.add_argument('-u', '--upstream_port', - help='non-station port that generates traffic: ., e.g: 1.eth1', - default='1.eth1') - parser.add_argument('--test_duration', help='sets the duration of the test', default="5m") - parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1', - default="10.40.0.1:/var/tmp/test") - + help='non-station port that generates traffic: ., e.g: 1.eth1', + default='1.eth1') parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None) parser.add_argument('--first_port', help='specifies name of first port to be used', default=None) parser.add_argument('--num_ports', help='number of ports to create', default=1) @@ -328,36 +108,13 @@ Generic command layout: parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip' '{ port_name1=ip_addr1,port_name1=ip_addr2 }. ' 'Ports without ips will be left alone', default=None) - parser.add_argument('--use_macvlans', help='will create macvlans', action='store_true', default=False) parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None) parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None) parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None) - parser.add_argument('--use_test_groups', help='will use test groups to start/stop instead of single endps/cxs', - action='store_true', default=False) - parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None) - parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None) - parser.add_argument('--mode', help='write,read,both', default='both', type=str) - tg_group = parser.add_mutually_exclusive_group() - tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None) - tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None) parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group' , default=None) args = parser.parse_args() - update_group_args = { - "name": None, - "action": None, - "cxs": None - } - if args.add_to_group is not None and args.cxs is not None: - update_group_args['name'] = args.add_to_group - update_group_args['action'] = "add" - update_group_args['cxs'] = args.cxs - elif args.del_from_group is not None and args.cxs is not None: - update_group_args['name'] = args.del_from_group - update_group_args['action'] = "del" - update_group_args['cxs'] = args.cxs - port_list = [] ip_list = [] if args.first_port is not None and args.use_ports is not None: @@ -365,17 +122,17 @@ Generic command layout: if (args.num_ports is not None) and (int(args.num_ports) > 0): start_num = int(args.first_port[3:]) num_ports = int(args.num_ports) - port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num+num_ports-1, - padding_number=10000, - radio=args.radio) + port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1, + padding_number=10000, + radio=args.radio) else: if (args.num_ports is not None) and args.macvlan_parent is not None and (int(args.num_ports) > 0) \ - and args.macvlan_parent in args.first_port: - start_num = int(args.first_port[args.first_port.index('#')+1:]) + and args.macvlan_parent in args.first_port: + start_num = int(args.first_port[args.first_port.index('#') + 1:]) num_ports = int(args.num_ports) - port_list = LFUtils.port_name_series(prefix=args.macvlan_parent+"#", start_id=start_num, - end_id=start_num+num_ports-1, padding_number=100000, - radio=args.radio) + port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=start_num, + end_id=start_num + num_ports - 1, padding_number=100000, + radio=args.radio) else: raise ValueError("Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n" "first_port must contain parent port and num_ports must be greater than 0" @@ -383,14 +140,9 @@ Generic command layout: else: if args.use_ports is None: num_ports = int(args.num_ports) - if not args.use_macvlans: - port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1, - padding_number=10000, - radio=args.radio) - else: - port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0, - end_id=num_ports - 1, padding_number=100000, - radio=args.radio) + port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0, + end_id=num_ports - 1, padding_number=100000, + radio=args.radio) else: temp_list = args.use_ports.split(',') for port in temp_list: @@ -413,34 +165,24 @@ Generic command layout: # print(port_list) # exit(1) - ip_test = FileIOTest(args.mgr, - args.mgr_port, - ssid=args.ssid, - password=args.passwd, - security=args.security, - port_list=port_list, - ip_list=ip_list, - test_duration=args.test_duration, - upstream_port=args.upstream_port, - _debug_on=args.debug, - - macvlan_parent=args.macvlan_parent, - use_macvlans=args.use_macvlans, - first_mvlan_ip=args.first_mvlan_ip, - netmask=args.netmask, - gateway=args.gateway, - dhcp=dhcp, - num_ports=args.num_ports, - use_test_groups=args.use_test_groups, - write_only_test_group=args.write_only_test_group, - read_only_test_group=args.read_only_test_group, - update_group_args = update_group_args, - connections_per_port=args.connections_per_port, - mode=args.mode - # want a mount options param - ) + ip_test = CreateMacVlan(args.mgr, + args.mgr_port, + port_list=port_list, + ip_list=ip_list, + upstream_port=args.upstream_port, + _debug_on=args.debug, + macvlan_parent=args.macvlan_parent, + first_mvlan_ip=args.first_mvlan_ip, + netmask=args.netmask, + gateway=args.gateway, + dhcp=dhcp, + num_ports=args.num_ports, + connections_per_port=args.connections_per_port, + # want a mount options param + ) ip_test.build() + if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh new file mode 100644 index 00000000..9708b50b --- /dev/null +++ b/py-scripts/html_test_output.sh @@ -0,0 +1,121 @@ +#!/bin/bash +#This bash script aims to automate the test process of all Candela Technologies's test_* scripts in the lanforge-scripts directory. The script can be run 2 ways and may include (via user input) the "start_num" and "stop_num" variables to select which tests should be run. +# OPTION ONE: ./test_all_scripts.sh : this command runs all the scripts in the array "testCommands" +# OPTION TWO: ./test_all_scripts.sh 4 5 : this command runs py-script commands (in testCommands array) that include the py-script options beginning with 4 and 5 (inclusive) in case function ret_case_num. +#Variables +NUM_STA=4 +SSID_USED="jedway-wpa2-x2048-5-3" +PASSWD_USED="jedway-wpa2-x2048-5-3" +RADIO_USED="wiphy1" +SECURITY="wpa2" + +START_NUM=0 +CURR_TEST_NUM=0 +CURR_TEST_NAME="BLANK" +STOP_NUM=9 + +#Test array +testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa " + "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" + "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep" + "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3" + "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --upstream_port eth1" + "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" + "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" + "./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" + "./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m" + "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format excel" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format csv" + "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" + "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./create_macvlan.py --radio wiphy1" + "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" +) +declare -A name_to_num +name_to_num=( + ["example_security_connection"]=1 + ["test_ipv4_connection"]=2 + ["test_generic"]=3 + ["test_ipv4_l4_urls_per_ten"]=4 + ["test_ipv4_l4_wifi"]=5 + ["test_ipv4_l4"]=6 + ["test_ipv4_variable_time"]=7 + ["create_bridge"]=8 + ["create_l3"]=9 + ["create_l4"]=10 + ["create_macvlan"]=10 + ["create_station"]=11 + ["create_vap"]=12 +) + +function blank_db() { + echo "Loading blank scenario..." >>~/test_all_output_file.txt + ./scenario.py --load BLANK >>~/test_all_output_file.txt + #check_blank.py +} +function echo_print() { + echo "Beginning $CURR_TEST_NAME test..." >>~/test_all_output_file.txt +} +results=() +function run_test() { + for i in "${testCommands[@]}"; do + CURR_TEST_NAME=${i%%.py*} + CURR_TEST_NAME=${CURR_TEST_NAME#./*} + CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" + echo "$CURR_TEST_NAME $CURR_TEST_NUM" + + if (( $CURR_TEST_NUM > $STOP_NUM )) || (( $STOP_NUM == $CURR_TEST_NUM )) && (( $STOP_NUM != 0 )); then + exit 1 + fi + if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then + echo_print + echo "$i" + [[ x$DEBUG != x ]] && sleep 2 + results+=("${CURR_TEST_NAME}success") + eval "$i" >>~/test_all_output_file_success.txt || true + [[ x$DEBUG != x ]] && exit 1 + results+=("${CURR_TEST_NAME}failure") + eval "$i" >>~/test_all_output_file_failure.txt + [[ x$DEBUG != x ]] + done +} +function check_args() { + if [ ! -z $1 ]; then + START_NUM=$1 + fi + if [ ! -z $2 ]; then + STOP_NUM=$2 + fi +} +function html_generator() { + NOW=$(date +"%Y-%m-%d-%T") + header=" + + Candela Test All Scripts Results + + + +

Candela Technologies

+ + " + tail="
+ + " + fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" + echo $header"${results[@]}"$tail > ${fname} +} +#true >~/test_all_output_file.txt +check_args $1 $2 +run_test +html_generator +#test generic and fileio are for macvlans diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 0fc88639..f501b262 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -213,13 +213,16 @@ python3 ./test_ipv4_variable_time.py if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) + #Create directory + homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' + os.mkdir('/home/lanforge/report_data/'+homedir) if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format + report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format output=args.output_format else: print('Defaulting to Excel') - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' + report_f='/home/lanforge/report-data/'+homedir+'/data.xlsx' output='excel' else: report_f=args.report_file @@ -272,12 +275,12 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], report_file=report_f, - duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds, + duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', arguments=args) - + ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From d6650f20c44fdf163b5fe3b2b7c897dc3a8d7699 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:39:23 -0800 Subject: [PATCH 169/848] test-all-scripts --- py-scripts/test_all_scripts.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/py-scripts/test_all_scripts.sh b/py-scripts/test_all_scripts.sh index e3df7f59..66106e4a 100644 --- a/py-scripts/test_all_scripts.sh +++ b/py-scripts/test_all_scripts.sh @@ -1,4 +1,3 @@ - #!/bin/bash #This bash script aims to automate the test process of all Candela Technologies's test_* scripts in the lanforge-scripts directory. The script can be run 2 ways and may include (via user input) the "start_num" and "stop_num" variables to select which tests should be run. # OPTION ONE: ./test_all_scripts.sh : this command runs all the scripts in the array "testCommands" From 28cde390dcad4354b07e33993af112b81eb288d9 Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 05:17:44 +0530 Subject: [PATCH 170/848] some work --- py-json/realm.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 149687b9..6db7c973 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1171,10 +1171,7 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] # Step 1, column names - if fields = None: - pass - else: - fields = ",".join(col_names) + fields = ",".join(col_names) print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() @@ -1187,13 +1184,8 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): - if col_names = None: - header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: - if fields = None: - response = self.json_get("/endp/all") - else: - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1219,6 +1211,8 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) + # if passes == expected_passes: + # self._pass("PASS: All tests passed") # step 3 organize data endpoints = list() for endpoint in value_map.values(): From 0403a867cc6c6f404a35b6a6ff5f3137906bbf62 Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 20 Jan 2021 19:40:14 +0530 Subject: [PATCH 171/848] StatusSession Uodates --- py-json/test_utility.py | 333 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 py-json/test_utility.py diff --git a/py-json/test_utility.py b/py-json/test_utility.py new file mode 100644 index 00000000..68235da9 --- /dev/null +++ b/py-json/test_utility.py @@ -0,0 +1,333 @@ + +""" +Candela Technologies Inc. + +Info : Standard Script for Webconsole Test Utility +Date : + + +""" + +import sys +from pprint import pprint +from uuid import uuid1 + +if 'py-json' not in sys.path: + sys.path.append('../py-json') +from LANforge import LFUtils +from LANforge import lfcli_base +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +import realm +from realm import PortUtils +import argparse +import datetime +import time +import matplotlib.pyplot as plt +import threading +import re +import json +import os +webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) +updates_path = webconsole_dir + "/web_json/updates.js" + + +class ClientVisualization(LFCliBase, threading.Thread): + def __init__(self, lfclient_host="localhost", lfclient_port=8080, num_clients= 64, max_data= 120, thread_id=None, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): + super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, + _exit_on_fail=_exit_on_fail) + threading.Thread.__init__(self) + self.num_clients = num_clients + self.max_data = max_data + self._stop_event = threading.Event() + self.client_data = {"down":[], "phantom":[], "ip":[], "scanning":[]} + + def stop(self): + self._stop_event.set() + + def stopped(self): + return self._stop_event.is_set() + + def run(self): + self.start_thread() + + def start_thread(self): + while True: + self.scanning = 0 + self.ip = 0 + self.down = 0 + self.phantom = 0 + for i in self.json_get("/port/list?fields=port,alias,parent%20dev,down,phantom,ip,port%20type")['interfaces']: + + for j in i: + print(i[j]['port type']) + if i[j]['port type'] == "WIFI-STA" and i[j]['parent dev'] == "wiphy1" and i[j]['alias'] != 'wlan1': + #print(j) + if i[j]['down'] == False and i[j]['phantom'] == False and i[j]['ip'] == '0.0.0.0': + self.scanning += 1 + elif i[j]['down'] == False and i[j]['phantom'] == True: + self.phantom += 1 + elif i[j]['down'] == True and i[j]['phantom'] == True: + self.phantom += 1 + self.client_data['phantom'].append(self.phantom) + elif i[j]['down'] == True and i[j]['phantom'] == False: + self.down += 1 + elif i[j]['ip'] != "0.0.0.0": + self.ip += 1 + else: + continue + self.client_data['scanning'].append(self.scanning) + self.client_data['phantom'].append(self.phantom) + self.client_data['down'].append(self.down) + self.client_data['ip'].append(self.ip) + + + for i in self.client_data: + if len(self.client_data[i]) >= self.max_data: + self.client_data[i].pop(0) + time.sleep(1) + if self.stopped(): + break + + +class CreateHTML(): + def __init__(self, path="", test_name="", time_snap="", dut_ssid="", test_conf_data={}, objective="", test_results={}, chart_data={}, chart_params={}): + self.head = """ + + + """+test_name+""" + + +
+ +
+
+

"""+test_name+"""

+

"""+time_snap+"""

+
+
+
+ """ + self.test_conf = """ + + + + + + + + +
+ Test Setup Information +
+ Device Under Test + + + + + + + """ + + for i in test_conf_data: + self.test_conf = self.test_conf + """ + + + + """ + + self.test_conf = self.test_conf + """
+ SSID + """+dut_ssid+""" +
"""+str(i)+""" + """+test_conf_data[i]+""" +
+
+ """ + + self.objective = """ +

Objective

+ """+objective+""" +

+
+ """ + + if str(test_results['summary']).__contains__("PASS"): + self.summary_results =""" +
+ + + + + + + +
+ Summary Results +
+ """ + test_results['summary'] + """ +
+
+ """ + else: + self.summary_results = """ +
+ + + + + + + +
+ Summary Results +
+ """ + test_results['summary'] + """ +
+
+ """ + chart_d =[] + chart_label =[] + for i in chart_data: + chart_label.append(i) + chart_d.append(chart_data[i]) + + + + + self.detail_result = """ + +
Detailed Results
+ + """ + for index in test_results['detail']['keys']: + self.detail_result = self.detail_result+"" + self.detail_result = self.detail_result +"" + + for data in test_results['detail']['data']: + self.detail_result = self.detail_result + "" + print("shivam") + print(data) + for i in data: + print(data[i]) + if str(data[i]).__contains__("PASS"): + self.detail_result = self.detail_result + "" + elif str(data[i]).__contains__("FAIL"): + self.detail_result = self.detail_result + "" + else: + self.detail_result = self.detail_result + "" + self.detail_result = self.detail_result +"" + + self.chart_data = chart_data + chart_values = [] + for i in self.chart_data: + chart_values.append(self.chart_data[i]) + plt.bar(list(self.chart_data.keys()), chart_values, tick_label=list(self.chart_data.keys())) + + plt.xlabel(chart_params['xlabel']) + # naming the y-axis + plt.ylabel(chart_params['ylabel']) + # plot title + plt.title(chart_params['chart_head']) + plt.xticks(rotation=90, fontsize=8) + plt.tight_layout() + # function to show the plot + plt.savefig(fname=path + "plot.png") + plt.close() + + self.chart = """""" + + + self.end = """
"+index+"
" + str(data[i]) + "" + str(data[i]) + "" + str(data[i]) + "
+ + + + """ + self.report = self.head + self.test_conf + self.objective + self.summary_results + self.chart +self.detail_result + self.end + + + +class RuntimeUpdates(): + def __init__(self, session_id, init_data): + self.session_id = session_id + self.init_data = init_data + f = open(updates_path, 'r+') + data = f.read() + f.close() + obj = data[data.find('{'): data.rfind('}') + 1] + obj = re.sub('[\']', '"', obj) + data = json.loads(obj) + print(data) + data["web_updates"].append({"ID": self.session_id, "data": self.init_data}) + print(data) + f = open(updates_path, 'r+') + f.seek(0) + f.truncate() + f.write("var updates = " + str(data) + ";") + f.close() + + def send_update(self, update_data): + f = open(updates_path, 'r+') + data = f.read() + f.close() + obj = data[data.find('{'): data.rfind('}') + 1] + obj = re.sub('[\']', '"', obj) + data = json.loads(obj) + + for update in data["web_updates"]: + if update["ID"] == self.session_id: + update["data"] = update_data + print(data) + f = open(updates_path, 'r+') + f.seek(0) + f.truncate() + f.write("var updates = " + str(data) + ";") + f.close() + + +class StatusSession(LFCliBase): + def __init__(self, lfclient_host="localhost", lfclient_port=8080, + _deep_clean=False, + session_id="0", + _debug_on=False, + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.deep_clean = _deep_clean + self.session_id = session_id + self.json_put("/status-msg/" + self.session_id, {}) + + def update(self, key, message): + """ + Method to add new Message into a session + """ + self.json_post("/status-msg/" + self.session_id, { + "key": key, + "content-type": "text/plain", + "message": message + }) + + def read(self): + """ + Method to read all the messages for a particular session + """ + keys = [] + for i in self.json_get("/status-msg/"+self.session_id)['messages']: + keys.append(i['key']) + json_uri = "/status-msg/"+self.session_id + "/" + for i in keys: + json_uri = json_uri + i + "," + return self.json_get(json_uri)['messages'] + + + + + + + + +if __name__ == "__main__": + obj = StatusMsg(lfclient_host="localhost", lfclient_port=8090, session_id="01_18_21_20_04_20") + print(obj.read()) + + From 35fb049a1fb3975cc74960e94366e4912fc44a04 Mon Sep 17 00:00:00 2001 From: Dipti Date: Wed, 20 Jan 2021 23:32:11 -0800 Subject: [PATCH 172/848] deletion of excess func - 'get rx values' , indication of if IP address is present --- py-scripts/test_ipv4_variable_time.py | 41 ++++----------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index f501b262..d2e32f4d 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -89,23 +89,9 @@ class IPV4VariableTime(LFCliBase): self.cx_profile.side_b_min_bps = side_b_min_rate self.cx_profile.side_b_max_bps = side_b_max_rate - - def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) - if self.debug: - print(self.cx_profile.created_cx.values()) - print("==============\n", cx_list, "\n==============") - cx_rx_map = {} - for cx_name in cx_list['endpoint']: - if cx_name != 'uri' and cx_name != 'handler': - for item, value in cx_name.items(): - for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): - cx_rx_map[item] = value_rx - return cx_rx_map - def start(self, print_pass=False, print_fail=False): self.station_profile.admin_up() + #to-do- check here if upstream port got IP temp_stas = self.station_profile.station_names.copy() if self.local_realm.wait_for_ip(temp_stas): @@ -213,16 +199,13 @@ python3 ./test_ipv4_variable_time.py if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) - #Create directory - homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' - os.mkdir('/home/lanforge/report_data/'+homedir) if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: - report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format + report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format output=args.output_format else: print('Defaulting to Excel') - report_f='/home/lanforge/report-data/'+homedir+'/data.xlsx' + report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' output='excel' else: report_f=args.report_file @@ -257,30 +240,16 @@ python3 ./test_ipv4_variable_time.py ip_var_test.exit_fail() ip_var_test.start(False, False) - if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format - output=args.output_format - else: - print('Defaulting to Excel') - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' - output='excel' - else: - report_f=args.report_file - if args.output_format is None: - output=str(args.report_file).split('.')[-1] - else: - output=args.output_format layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], report_file=report_f, - duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), + duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds, created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', arguments=args) - + ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From e8344dec8a7aca8f52223948523532b83b073bcf Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:53:34 -0800 Subject: [PATCH 173/848] realm cleaned --- py-json/realm.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6db7c973..11557ee5 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1184,8 +1184,13 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): + if col_names = None: + header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: - response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) + if fields = None: + response = self.json_get("/endp/all") + else: + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1211,10 +1216,8 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) - # if passes == expected_passes: - # self._pass("PASS: All tests passed") - # step 3 organize data - endpoints = list() + #step 3 organize data + endpoints=list() for endpoint in value_map.values(): endpoints.append(endpoint['endpoint']) endpoints2 = [] @@ -1226,6 +1229,7 @@ class L3CXProfile(BaseProfile): itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) + # step 4 save and close header_row = col_names header_row.insert(0, 'Timestamp') @@ -3493,7 +3497,7 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: self.local_realm.rm_port(port_eid, check_exists=True, debug_=debug_) - + time.sleep(delay) # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) From 0c002a4310fcc75523f819f7a4f67e22cb424ca7 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 21 Jan 2021 15:54:44 -0800 Subject: [PATCH 174/848] realm cleaned --- py-json/realm.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 11557ee5..134c75a7 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1184,10 +1184,10 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): - if col_names = None: + if col_names == None: header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: - if fields = None: + if fields == None: response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) @@ -1235,7 +1235,6 @@ class L3CXProfile(BaseProfile): header_row.insert(0, 'Timestamp') # print(header_row) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': - report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) worksheet = workbook.add_worksheet() for col_num, data in enumerate(header_row): From 5df2dfb35d4ef83de686698029e6d0b8e515304b Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 21 Jan 2021 20:23:17 -0800 Subject: [PATCH 175/848] start of monitor additions & urls_per_ten remodeling --- py-json/realm.py | 17 +++++++++++++ py-scripts/test_ipv4_l4_urls_per_ten.py | 34 ++++++++++++------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 134c75a7..6d33dd99 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1603,6 +1603,23 @@ class L4CXProfile(LFCliBase): print(".", end='') print("") + def check_request_rate(self): + endp_list = self.json_get("layer4/list?fields=urls/s") + expected_passes = 0 + passes = 0 + if endp_list is not None and endp_list['endpoint'] is not None: + endp_list = endp_list['endpoint'] + for item in endp_list: + for name, info in item.items(): + if name in self.cx_profile.created_cx.keys(): + expected_passes += 1 + if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: + print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) + passes += 1 + + return passes == expected_passes + + def cleanup(self): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 5a1cb981..870126da 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -24,6 +24,7 @@ from LANforge import LFUtils import realm import time import datetime +from realm import TestGroupProfile class IPV4L4(LFCliBase): @@ -66,21 +67,20 @@ class IPV4L4(LFCliBase): self.cx_profile.url = self.url self.cx_profile.requests_per_ten = self.requests_per_ten - def __check_request_rate(self): - endp_list = self.json_get("layer4/list?fields=urls/s") - expected_passes = 0 - passes = 0 - if endp_list is not None and endp_list['endpoint'] is not None: - endp_list = endp_list['endpoint'] - for item in endp_list: - for name, info in item.items(): - if name in self.cx_profile.created_cx.keys(): - expected_passes += 1 - if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: - print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) - passes += 1 - - return passes == expected_passes + # def __check_request_rate(self): + # endp_list = self.json_get("layer4/list?fields=urls/s") + # expected_passes = 0 + # passes = 0 + # if endp_list is not None and endp_list['endpoint'] is not None: + # endp_list = endp_list['endpoint'] + # for item in endp_list: + # for name, info in item.items(): + # if name in self.cx_profile.created_cx.keys(): + # expected_passes += 1 + # if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: + # print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) + # passes += 1 + # return passes == expected_passes def build(self): # Build stations @@ -106,9 +106,9 @@ class IPV4L4(LFCliBase): exit(1) self.cx_profile.start_cx() print("Starting test") - curr_time = datetime.datetime.now() + curr_time = datetime.datetime.now() end_time = self.local_realm.parse_time(self.test_duration) + curr_time - sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 + sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 passes = 0 expected_passes = 0 for test in range(self.num_tests): From 021b8ad306350263d5daaa3ad1f1db1a84ff19d8 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 21 Jan 2021 22:49:12 -0800 Subject: [PATCH 176/848] additions to L4Prof monitor, edits to logic of col names in L3 Monitor --- py-json/realm.py | 2 +- py-scripts/test_ipv4_l4_urls_per_ten.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6d33dd99..41b78477 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1204,7 +1204,7 @@ class L3CXProfile(BaseProfile): if self.debug: print(old_cx_rx_values, new_cx_rx_values) print("\n-----------------------------------") - print(curr_time) + print(t) print("-----------------------------------\n") expected_passes += 1 if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 870126da..50d37ef3 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -108,7 +108,7 @@ class IPV4L4(LFCliBase): print("Starting test") curr_time = datetime.datetime.now() end_time = self.local_realm.parse_time(self.test_duration) + curr_time - sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 + sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 passes = 0 expected_passes = 0 for test in range(self.num_tests): @@ -128,7 +128,6 @@ class IPV4L4(LFCliBase): else: self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) break - #interval_time = cur_time + datetime.timedelta(minutes=2) if passes == expected_passes: self._pass("PASS: All tests passes", print_pass) From ac86b2bd4544b2cd9fdbf85e535fa49cdc06fe65 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 21 Jan 2021 23:07:03 -0800 Subject: [PATCH 177/848] contuination of editing pdf output format --- py-json/realm.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 41b78477..ad15a706 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1184,8 +1184,6 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = self.__get_rx_values() timestamps = [] # for x in range(0,int(round(iterations,0))): - if col_names == None: - header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) while datetime.datetime.now() < end_time: if fields == None: response = self.json_get("/endp/all") From 96d445b4967473901528e47bae0831463933dc98 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 01:33:24 -0800 Subject: [PATCH 178/848] addition of test output logic for urls_per_ten , arg parsing changes to var_time --- py-scripts/test_ipv4_l4_urls_per_ten.py | 74 ++++++++++++------------- py-scripts/test_ipv4_variable_time.py | 26 +++++---- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 50d37ef3..22d6213a 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -34,6 +34,7 @@ class IPV4L4(LFCliBase): _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 @@ -52,6 +53,8 @@ class IPV4L4(LFCliBase): self.target_requests_per_ten = int(target_requests_per_ten) self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.l4cxprofile=realm.L4CXProfile(lfclient_host=host, + lfclient_port=port,local_realm=self.local_realm) self.station_profile = self.local_realm.new_station_profile() self.cx_profile = self.local_realm.new_l4_cx_profile() @@ -67,20 +70,6 @@ class IPV4L4(LFCliBase): self.cx_profile.url = self.url self.cx_profile.requests_per_ten = self.requests_per_ten - # def __check_request_rate(self): - # endp_list = self.json_get("layer4/list?fields=urls/s") - # expected_passes = 0 - # passes = 0 - # if endp_list is not None and endp_list['endpoint'] is not None: - # endp_list = endp_list['endpoint'] - # for item in endp_list: - # for name, info in item.items(): - # if name in self.cx_profile.created_cx.keys(): - # expected_passes += 1 - # if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: - # print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) - # passes += 1 - # return passes == expected_passes def build(self): # Build stations @@ -105,32 +94,8 @@ class IPV4L4(LFCliBase): self._fail("Stations failed to get IPs", print_fail) exit(1) self.cx_profile.start_cx() - print("Starting test") - curr_time = datetime.datetime.now() - end_time = self.local_realm.parse_time(self.test_duration) + curr_time - sleep_interval = self.local_realm.parse_time(self.test_duration) // 5 - passes = 0 - expected_passes = 0 - for test in range(self.num_tests): - expected_passes += 1 - while curr_time < end_time: - time.sleep(sleep_interval.total_seconds()) - if self.debug: - print(".",end="") - curr_time = datetime.datetime.now() - - if self.cx_profile.check_errors(self.debug): - if self.__check_request_rate(): - passes += 1 - else: - self._fail("FAIL: Request rate did not exceed 90% target rate", print_fail) - break - else: - self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) - break - if passes == expected_passes: - self._pass("PASS: All tests passes", print_pass) - + print("Starting test...") + def stop(self): self.cx_profile.stop_cx() self.station_profile.admin_down() @@ -202,12 +167,31 @@ python3 ./test_ipv4_l4_urls_per_ten.py optional.add_argument('--target_per_ten', help='--target_per_ten target number of request per ten minutes. test will check for 90 percent this value',default=600) optional.add_argument('--mode',help='Used to force mode of stations') optional.add_argument('--ap',help='Used to force a connection to a particular AP') + optional.add_argument('--report_file',help='where you want to store results') + optional.add_argument('--output_format', help='choose either csv or xlsx') + args = parser.parse_args() num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted + if args.report_file is None: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: + output_form=args.output_format + print("Defaulting file output placement to /home/lanforge.") + rpt_file='/home/lanforge/data.' + output_form + else: + print("Defaulting data file output type to Excel") + rpt_file='/home/lanforge/data.xlsx' + output_form='xlsx' + + else: + rpt_file=args.report_file + if args.output_format is None: + output_form=str(args.report_file).split('.')[-1] + else: + output_form=args.output_format station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, @@ -230,6 +214,16 @@ python3 ./test_ipv4_l4_urls_per_ten.py ip_test.cleanup(station_list) ip_test.build() ip_test.start() + + try: + layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) + except: + pass + ip_test.l4cxprofile.monitor(report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), + created_cx=layer4traffic, + output_format=output_form, + script_name='test_ipv4_l4_urls_per_ten', + arguments=args) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index d2e32f4d..b96b501f 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -199,14 +199,17 @@ python3 ./test_ipv4_variable_time.py if (args.num_stations is not None) and (int(args.num_stations) > 0): num_sta = int(args.num_stations) + #Create directory + homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' + os.mkdir('/home/lanforge/report_data/'+homedir) if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet']: - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.' + args.output_format + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: + report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format output=args.output_format else: - print('Defaulting to Excel') - report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx' - output='excel' + print('Defaulting data file output type to Excel') + report_f='/home/lanforge/report-data/'+homedir+'/data.xlsx' + output='xlsx' else: report_f=args.report_file if args.output_format is None: @@ -240,16 +243,19 @@ python3 ./test_ipv4_variable_time.py ip_var_test.exit_fail() ip_var_test.start(False, False) - - layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) - ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], + try: + layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) + except: + raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') + ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs','Rx Drop % A', 'Rx Drop % B', 'Bps Rx A', 'Bps Rx B', 'Rx Rate', 'Cx Estab'], report_file=report_f, - duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds, + duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', + show=show, arguments=args) - + ip_var_test.stop() if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) From ca5a673a4f69689218bf08177441f5071a8b1413 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 02:22:17 -0800 Subject: [PATCH 179/848] continuation of file output edits/formatting --- py-scripts/test_ipv4_l4_urls_per_ten.py | 17 ++++++++--------- py-scripts/test_ipv4_variable_time.py | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index 22d6213a..ac03c228 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -140,12 +140,14 @@ python3 ./test_ipv4_l4_urls_per_ten.py "an" : "10", "bgnAC" : "11", "abgnAX" : "12", - "bgnAX" : "13", + "bgnAX" : "13"} \\ --num_tests 1 \\ --url "dl http://10.40.0.1 /dev/null" \\ --ap "00:0e:8e:78:e1:76" --target_per_ten 600 \\ - --test_duration 2m + --output_format csv \\ + --report_file ~/Documents/results.csv \\ + --test_duration 2m \\ --debug ''') required = None @@ -168,7 +170,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py optional.add_argument('--mode',help='Used to force mode of stations') optional.add_argument('--ap',help='Used to force a connection to a particular AP') optional.add_argument('--report_file',help='where you want to store results') - optional.add_argument('--output_format', help='choose either csv or xlsx') + optional.add_argument('--output_format', help='choose csv or xlsx') #update once other forms are completed args = parser.parse_args() @@ -177,8 +179,8 @@ python3 ./test_ipv4_l4_urls_per_ten.py num_stations_converted = int(args.num_stations) num_sta = num_stations_converted if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: - output_form=args.output_format + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','png','df','xlsx']: + output_form=args.output_format.lower() print("Defaulting file output placement to /home/lanforge.") rpt_file='/home/lanforge/data.' + output_form else: @@ -220,10 +222,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py except: pass ip_test.l4cxprofile.monitor(report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), - created_cx=layer4traffic, - output_format=output_form, - script_name='test_ipv4_l4_urls_per_ten', - arguments=args) + created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', arguments=args) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index b96b501f..368489b1 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -203,7 +203,7 @@ python3 ./test_ipv4_variable_time.py homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' os.mkdir('/home/lanforge/report_data/'+homedir) if args.report_file is None: - if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','xlsx']: + if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format output=args.output_format else: @@ -265,7 +265,7 @@ python3 ./test_ipv4_variable_time.py if ip_var_test.passes(): ip_var_test.exit_success() - IPV4VariableTime.cx_profile.stop_cx() + IPV4VariableTime.cx_profile.stop_cx() #is this needed? if __name__ == "__main__": main() From 51ea187b2ffcea4314b82bcacf1e3a376dba0b99 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 10:50:09 -0800 Subject: [PATCH 180/848] flexible lfclient_port and correct l3 field names --- py-json/realm.py | 10 +++++++--- py-scripts/test_ipv4_variable_time.py | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index ad15a706..751e99db 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1170,8 +1170,12 @@ class L3CXProfile(BaseProfile): else: output_format = report_file.split('.')[-1] - # Step 1, column names - fields = ",".join(col_names) + # Step 1, column names . what is this for? + fields=None + if col_names is not None and len(col_names) > 0: + fields = ",".join(col_names) + else: + header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() @@ -1185,7 +1189,7 @@ class L3CXProfile(BaseProfile): timestamps = [] # for x in range(0,int(round(iterations,0))): while datetime.datetime.now() < end_time: - if fields == None: + if fields is None: response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 368489b1..ebd10e05 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -200,8 +200,10 @@ python3 ./test_ipv4_variable_time.py num_sta = int(args.num_stations) #Create directory - homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time' - os.mkdir('/home/lanforge/report_data/'+homedir) + homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' + path = os.path.join('/home/lanforge/report-data/',homedir) + os.mkdir(path) + if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format @@ -253,7 +255,6 @@ python3 ./test_ipv4_variable_time.py created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', - show=show, arguments=args) ip_var_test.stop() @@ -265,7 +266,7 @@ python3 ./test_ipv4_variable_time.py if ip_var_test.passes(): ip_var_test.exit_success() - IPV4VariableTime.cx_profile.stop_cx() #is this needed? + IPV4VariableTime.cx_profile.stop_cx() #is this needed? if __name__ == "__main__": main() From e7e3360deab4e3f5516ee30baaf6327785ecb76c Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 11:02:51 -0800 Subject: [PATCH 181/848] Correctly get names for columns when they are user defined --- py-json/realm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py-json/realm.py b/py-json/realm.py index 751e99db..8bfff99d 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1174,6 +1174,7 @@ class L3CXProfile(BaseProfile): fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) + header_row=col_names else: header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) print(fields) From 7b71a52a4385a868606bc4d38cc00245e61b67eb Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 11:04:51 -0800 Subject: [PATCH 182/848] working columns names for variable_time --- py-scripts/test_ipv4_variable_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index ebd10e05..84fa9842 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -249,7 +249,7 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs','Rx Drop % A', 'Rx Drop % B', 'Bps Rx A', 'Bps Rx B', 'Rx Rate', 'Cx Estab'], + ip_var_test.l3cxprofile.monitor(col_names=['Name','Rx Rate','Rx PDUs'], report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, From fe51e0eca22155252d641aff1043dd633a673a02 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 11:53:24 -0800 Subject: [PATCH 183/848] user defined columsn in test_ipv4_variable_time --- py-json/realm.py | 4 ++-- py-scripts/test_ipv4_variable_time.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 8bfff99d..ceb1095e 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1161,8 +1161,8 @@ class L3CXProfile(BaseProfile): raise ValueError("Monitor needs a list of Layer 3 connections") if (monitor_interval is None) or (monitor_interval < 1): raise ValueError("L3CXProfile::monitor wants monitor_interval >= 1 second") - if col_names is None: - raise ValueError("L3CXProfile::monitor wants a list of column names to monitor") + #if col_names is None: + #raise ValueError("L3CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: if output_format.lower() != 'excel': diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 84fa9842..c18a2360 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -193,6 +193,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") + optional_args.add_argument('--col_names', help='Which columns you want to monitor', default=['Name','Rx Rate','Rx PDUs']) args = parser.parse_args() num_sta = 2 @@ -249,7 +250,12 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - ip_var_test.l3cxprofile.monitor(col_names=['Name','Rx Rate','Rx PDUs'], + if type(args.col_names) is not list: + col_names=None + else: + col_names = args.col_names + print(col_names) + ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, From 7a3cb5663ebd8f58d737286532885172373fa980 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:13:53 -0800 Subject: [PATCH 184/848] html test output works --- py-scripts/html_test_output.sh | 43 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) mode change 100644 => 100755 py-scripts/html_test_output.sh diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh old mode 100644 new mode 100755 index 9708b50b..2d2a1b9f --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -19,20 +19,20 @@ testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid j "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3" - "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --upstream_port eth1" - "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" - "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" - "./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" - "./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m" - "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug" - "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format excel" - "./test_ipv4_variable_time.py --radio wiphy1 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --mode 4 --ap 00:0e:8e:ff:86:e6 --test_duration 30s --output_format csv" + "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./test_generic.py --mgr localhost --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" + "./test_generic.py --mgr localhost --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" + "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" + "./test_ipv4_l4_wifi.py --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" + "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" + "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" - "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./create_macvlan.py --radio wiphy1" - "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_macvlan.py --radio wiphy1" + #"./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + #"./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" ) declare -A name_to_num name_to_num=( @@ -73,14 +73,14 @@ function run_test() { if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then echo_print echo "$i" - [[ x$DEBUG != x ]] && sleep 2 - results+=("${CURR_TEST_NAME}success") - eval "$i" >>~/test_all_output_file_success.txt || true - [[ x$DEBUG != x ]] && exit 1 - results+=("${CURR_TEST_NAME}failure") - eval "$i" >>~/test_all_output_file_failure.txt - [[ x$DEBUG != x ]] + if $i; then + results+=("${CURR_TEST_NAME}Success") + else + results+=("${CURR_TEST_NAME}Failure") + fi + fi done + echo $results } function check_args() { if [ ! -z $1 ]; then @@ -112,7 +112,8 @@ function html_generator() { " fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" - echo $header"${results[@]}"$tail > ${fname} + echo $fname + echo $header"${results[@]}"$tail >> $fname } #true >~/test_all_output_file.txt check_args $1 $2 From 67b236cbe1ca7a69fac8363430ad7143673522ae Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:33:07 -0800 Subject: [PATCH 185/848] args.report_file is none --- py-scripts/test_ipv4_variable_time.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index c18a2360..75e71a69 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -188,8 +188,8 @@ python3 ./test_ipv4_variable_time.py if optional_args is not None: optional_args.add_argument('--mode',help='Used to force mode of stations') optional_args.add_argument('--ap',help='Used to force a connection to a particular AP') - optional_args.add_argument('--report_file',help='where you want to store results') optional_args.add_argument('--output_format', help='choose either csv or xlsx') + optional_args.add_argument('--report_file',help='where you want to store results', default=None) optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") @@ -201,9 +201,12 @@ python3 ./test_ipv4_variable_time.py num_sta = int(args.num_stations) #Create directory - homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' - path = os.path.join('/home/lanforge/report-data/',homedir) - os.mkdir(path) + if args.report_file is None: + homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' + path = os.path.join('/home/lanforge/report-data/',homedir) + os.mkdir(path) + else: + pass if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: From ad838a2395ca751e4adc4acb75e2ae85bd433ebd Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:37:52 -0800 Subject: [PATCH 186/848] small fixes for lfclient host --- py-json/realm.py | 165 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 161 insertions(+), 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index ceb1095e..f44850e1 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1098,6 +1098,7 @@ class L3CXProfile(BaseProfile): self.created_endp = {} self.name_prefix = name_prefix_ self.number_template = number_template_ + self.lfclient_port = lfclient_port def get_cx_names(self): return self.created_cx.keys() @@ -1171,13 +1172,12 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] # Step 1, column names . what is this for? - fields=None + fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) header_row=col_names else: header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys())) - print(fields) # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) @@ -1232,7 +1232,6 @@ class L3CXProfile(BaseProfile): itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) - # step 4 save and close header_row = col_names header_row.insert(0, 'Timestamp') @@ -1253,7 +1252,10 @@ class L3CXProfile(BaseProfile): df.columns = header_row import requests import ast - systeminfo=ast.literal_eval(requests.get('http://localhost:8080').text) + try: + systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) + except: + systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments @@ -1681,6 +1683,161 @@ class L4CXProfile(LFCliBase): suppress_related_commands_=suppress_related_commands_) time.sleep(sleep_time) + def monitor(self, + duration_sec=60, + monitor_interval=1, + col_names=None, + created_cx=None, + monitor=True, + report_file=None, + output_format=None, + script_name=None, + arguments=None, + iterations=0): + try: + duration_sec = self.parse_time(duration_sec).seconds + except: + if (duration_sec is None) or (duration_sec <= 1): + raise ValueError("L4CXProfile::monitor wants duration_sec > 1 second") + if (duration_sec <= monitor_interval): + raise ValueError("L4CXProfile::monitor wants duration_sec > monitor_interval") + if report_file == None: + raise ValueError("Monitor requires an output file to be defined") + if created_cx == None: + raise ValueError("Monitor needs a list of Layer 4 connections") + if (monitor_interval is None) or (monitor_interval < 1): + raise ValueError("L4CXProfile::monitor wants monitor_interval >= 1 second") + if col_names is None: + raise ValueError("L4CXProfile::monitor wants a list of column names to monitor") + if output_format is not None: + if output_format.lower() != report_file.split('.')[-1]: + raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) + else: + output_format = report_file.split('.')[-1] + + # Step 1, column names + + fields=None + if col_names is not None and len(col_names) > 0: + fields = ",".join(col_names) + if self.debug: + print(fields) + else: + #todo:rename this... + header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) + if self.debug: + print(header_row) + + # Step 2, monitor columns, + + start_time = datetime.datetime.now() + end_time = start_time + datetime.timedelta(seconds=duration_sec) + sleep_interval = duration_sec // 5 + value_map = dict() + passes = 0 + expected_passes = 0 + timestamps = [] + for test in range(1+iterations): + #while current loop hasn't ended + while datetime.datetime.now() < end_time: + #what does response ? get? + response=self.json_get("layer4/all") + #response = self.json_get("layer4/list?fields=urls/s") + if "endpoint" not in response: + print(response) + raise ValueError("Cannot find any endpoints") + if monitor: + if self.debug: + print(response) + time.sleep(sleep_interval.total_seconds()) + t = datetime.datetime.now() + timestamps.append(t) + value_map[t] = response + expected_passes += 1 + if self.cx_profile.check_errors(self.debug): + if self.__check_request_rate(): + passes += 1 + else: + self._fail("FAIL: Request rate did not exceed 90% target rate") + self.exit_fail() + else: + self._fail("FAIL: Errors found getting to %s " % self.url) + self.exit_fail() + #check monitor sleep time + time.sleep(monitor_interval) + print(value_map) +############################################# edited 'til here - dipti 1/21/20 + # step 3 organize data + endpoints = list() + for endpoint in value_map.values(): + endpoints.append(endpoint['endpoint']) + endpoints2 = [] + for y in range(0, len(endpoints)): + for x in range(0, len(endpoints[0])): + endpoints2.append(list(list(endpoints[y][x].values())[0].values())) + import itertools + timestamps2 = list( + itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) + for point in range(0, len(endpoints2)): + endpoints2[point].insert(0, timestamps2[point]) + # step 4 save and close + header_row = col_names + header_row.insert(0, 'Timestamp') + print(header_row) + if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': + report_fh = open(report_file, "w+") + workbook = xlsxwriter.Workbook(report_file) + worksheet = workbook.add_worksheet() + for col_num, data in enumerate(header_row): + worksheet.write(0, col_num, data) + row_num = 1 + for x in endpoints2: + for col_num, data in enumerate(x): + worksheet.write(row_num, col_num, str(data)) + row_num += 1 + workbook.close() + else: + df = pd.DataFrame(endpoints2) + df.columns = header_row + import requests + import ast + try: + systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + except: + systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text) + df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] + df['Script Name'] = script_name + df['Arguments'] = arguments + for x in ['LFGUI Release', 'Script Name', 'Arguments']: + df[x][1:] = '' + if output_format == 'pdf': + import matplotlib.pyplot as plt + from matplotlib.backends.backend_pdf import PdfPages + fig, ax = plt.subplots(figsize=(12, 4)) + ax.axis('tight') + ax.axis('off') + the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') + pp = PdfPages(report_file) + pp.savefig(fig, bbox_inches='tight') + pp.close() + if output_format == 'hdf': + df.to_hdf(report_file, 'table', append=True) + if output_format == 'parquet': + df.to_parquet(report_file, engine='pyarrow') + if output_format == 'png': + fig = df.plot().get_figure() + fig.savefig(report_file) + if output_format == 'html': + print('Shivams function') + if output_format == 'df': + return df + supported_formats = ['csv', 'json', 'stata', 'pickle'] + for x in supported_formats: + if output_format.lower() == x or report_file.split('.')[-1] == x: + exec('df.to_' + x + '("' + report_file + '")') + else: + pass +#end of L4CXProf class class GenCXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): From 6e229d5edaa8fe03e55b1a3dce9b9f20c9f6adb0 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 14:56:06 -0800 Subject: [PATCH 187/848] dumping pdf for now, simple html output --- py-json/realm.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f44850e1..dd7af872 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1181,7 +1181,6 @@ class L3CXProfile(BaseProfile): # Step 2, monitor columns start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) - print(end_time) value_map = dict() passes = 0 @@ -1217,7 +1216,6 @@ class L3CXProfile(BaseProfile): self.exit_fail() old_cx_rx_values = new_cx_rx_values time.sleep(monitor_interval) - print(value_map) #step 3 organize data endpoints=list() @@ -1261,16 +1259,6 @@ class L3CXProfile(BaseProfile): df['Arguments'] = arguments for x in ['LFGUI Release', 'Script Name', 'Arguments']: df[x][1:] = '' - if output_format == 'pdf': - import matplotlib.pyplot as plt - from matplotlib.backends.backend_pdf import PdfPages - fig, ax = plt.subplots(figsize=(12, 4)) - ax.axis('tight') - ax.axis('off') - the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') - pp = PdfPages(report_file) - pp.savefig(fig, bbox_inches='tight') - pp.close() if output_format == 'hdf': df.to_hdf(report_file, 'table', append=True) if output_format == 'parquet': @@ -1278,11 +1266,9 @@ class L3CXProfile(BaseProfile): if output_format == 'png': fig = df.plot().get_figure() fig.savefig(report_file) - if output_format == 'html': - print('Shivams function') if output_format == 'df': return df - supported_formats = ['csv', 'json', 'stata', 'pickle'] + supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: exec('df.to_' + x + '("' + report_file + '")') @@ -1810,16 +1796,6 @@ class L4CXProfile(LFCliBase): df['Arguments'] = arguments for x in ['LFGUI Release', 'Script Name', 'Arguments']: df[x][1:] = '' - if output_format == 'pdf': - import matplotlib.pyplot as plt - from matplotlib.backends.backend_pdf import PdfPages - fig, ax = plt.subplots(figsize=(12, 4)) - ax.axis('tight') - ax.axis('off') - the_table = ax.table(cellText=df.values, colLabels=df.columns, loc='center') - pp = PdfPages(report_file) - pp.savefig(fig, bbox_inches='tight') - pp.close() if output_format == 'hdf': df.to_hdf(report_file, 'table', append=True) if output_format == 'parquet': From 2c78b4b427b07c77e53bc62633e7f7b5011b06dc Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 13:30:47 -0800 Subject: [PATCH 188/848] contuination of monitor in l4cxprof & addition of monitor urls_per_ten --- py-json/realm.py | 9 ++++----- py-scripts/test_ipv4_l4_urls_per_ten.py | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index dd7af872..6656098b 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1693,8 +1693,6 @@ class L4CXProfile(LFCliBase): raise ValueError("Monitor needs a list of Layer 4 connections") if (monitor_interval is None) or (monitor_interval < 1): raise ValueError("L4CXProfile::monitor wants monitor_interval >= 1 second") - if col_names is None: - raise ValueError("L4CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) @@ -1706,6 +1704,7 @@ class L4CXProfile(LFCliBase): fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) + header_row=col_names if self.debug: print(fields) else: @@ -1718,17 +1717,17 @@ class L4CXProfile(LFCliBase): start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) - sleep_interval = duration_sec // 5 + sleep_interval = round(duration_sec // 5) value_map = dict() passes = 0 expected_passes = 0 timestamps = [] for test in range(1+iterations): - #while current loop hasn't ended while datetime.datetime.now() < end_time: - #what does response ? get? response=self.json_get("layer4/all") #response = self.json_get("layer4/list?fields=urls/s") + if self.debug: + print(response) if "endpoint" not in response: print(response) raise ValueError("Cannot find any endpoints") diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index ac03c228..f0dccc52 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -221,8 +221,13 @@ python3 ./test_ipv4_l4_urls_per_ten.py layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) except: pass - ip_test.l4cxprofile.monitor(report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), - created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', arguments=args) + ip_test.l4cxprofile.monitor(col_names=['Name','bytes-rd','rx rate (1 min)', 'urls/s'], + report_file=rpt_file, + duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), + created_cx=layer4traffic, + output_format=output_form, + script_name='test_ipv4_l4_urls_per_ten', + arguments=args) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) From f09f31ca5237a0739ef604d6c97991aa036aecb8 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 14:24:30 -0800 Subject: [PATCH 189/848] additions to ipv4_l4_url monitor --- py-json/realm.py | 22 ++++++++++++++-------- py-scripts/test_ipv4_l4_urls_per_ten.py | 5 ++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 6656098b..277fdbc4 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1679,7 +1679,8 @@ class L4CXProfile(LFCliBase): output_format=None, script_name=None, arguments=None, - iterations=0): + iterations=0, + debug=False): try: duration_sec = self.parse_time(duration_sec).seconds except: @@ -1705,12 +1706,12 @@ class L4CXProfile(LFCliBase): if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) header_row=col_names - if self.debug: + if debug: print(fields) else: #todo:rename this... header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys())) - if self.debug: + if debug: print(header_row) # Step 2, monitor columns, @@ -1718,6 +1719,10 @@ class L4CXProfile(LFCliBase): start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) sleep_interval = round(duration_sec // 5) + if debug: + print("Sleep_interval is..." + sleep_interval) + print("Start time is..."+ start_time) + print("End time is..."+ end_time) value_map = dict() passes = 0 expected_passes = 0 @@ -1726,21 +1731,22 @@ class L4CXProfile(LFCliBase): while datetime.datetime.now() < end_time: response=self.json_get("layer4/all") #response = self.json_get("layer4/list?fields=urls/s") - if self.debug: + if debug: print(response) if "endpoint" not in response: print(response) raise ValueError("Cannot find any endpoints") if monitor: - if self.debug: + if debug: print(response) - time.sleep(sleep_interval.total_seconds()) + + time.sleep(sleep_interval) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response expected_passes += 1 - if self.cx_profile.check_errors(self.debug): - if self.__check_request_rate(): + if self.cx_profile.check_errors(debug): + if self.__check_request_rate(): #need to changed passes += 1 else: self._fail("FAIL: Request rate did not exceed 90% target rate") diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index f0dccc52..aec2585a 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -45,6 +45,7 @@ class IPV4L4(LFCliBase): self.url = url self.mode=mode self.ap=ap + self.debug=_debug_on self.requests_per_ten = int(requests_per_ten) self.number_template = number_template self.test_duration=test_duration @@ -209,6 +210,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py url=args.url, mode=args.mode, ap=args.ap, + _debug_on=args.debug, test_duration=args.test_duration, num_tests=args.num_tests, target_requests_per_ten=args.target_per_ten, @@ -227,7 +229,8 @@ python3 ./test_ipv4_l4_urls_per_ten.py created_cx=layer4traffic, output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', - arguments=args) + arguments=args, + debug=args.debug) ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) From fee1a51fa466e84c763e1100107ec090555952ea Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 14:35:04 -0800 Subject: [PATCH 190/848] no major changes, committed to pull --rebase --- py-scripts/test_ipv4_l4_urls_per_ten.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index aec2585a..7a2bc7ad 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -183,7 +183,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','parquet','png','df','xlsx']: output_form=args.output_format.lower() print("Defaulting file output placement to /home/lanforge.") - rpt_file='/home/lanforge/data.' + output_form + rpt_file='/home/data.' + output_form else: print("Defaulting data file output type to Excel") rpt_file='/home/lanforge/data.xlsx' From 85736c769d743a7a15571ba8617acadb29f5df29 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 22 Jan 2021 14:57:03 -0800 Subject: [PATCH 191/848] changes to html format in realm.py --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 277fdbc4..8b9550e2 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1809,7 +1809,7 @@ class L4CXProfile(LFCliBase): fig = df.plot().get_figure() fig.savefig(report_file) if output_format == 'html': - print('Shivams function') + df.to_html(report_file) if output_format == 'df': return df supported_formats = ['csv', 'json', 'stata', 'pickle'] From 1bacc79ec9ba00c09cf2c251153763fcab5482e8 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 15:22:46 -0800 Subject: [PATCH 192/848] unnecessary line --- py-scripts/test_ipv4_variable_time.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 75e71a69..481ab880 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -275,7 +275,5 @@ python3 ./test_ipv4_variable_time.py if ip_var_test.passes(): ip_var_test.exit_success() - IPV4VariableTime.cx_profile.stop_cx() #is this needed? - if __name__ == "__main__": main() From 210e2615f1cd8baf7887527010ee6d90454cc009 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 15:51:31 -0800 Subject: [PATCH 193/848] update scripts --- py-scripts/update_deps.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 py-scripts/update_deps.py diff --git a/py-scripts/update_deps.py b/py-scripts/update_deps.py new file mode 100644 index 00000000..dac713ce --- /dev/null +++ b/py-scripts/update_deps.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +import subprocess +def main(): + command = "pip install pandas seaborn plotly numpy dash --upgrade" + res = subprocess.call(command, shell = True) + + print("Returned Value: ", res) + +if __name__ == "__main__": + main() From 708c785b0cfea716825555598053a97c4559aee8 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 22 Jan 2021 16:17:14 -0800 Subject: [PATCH 194/848] html_test_all adds formatting, updates title, better output redirection --- py-scripts/html_test_output.sh | 65 ++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh index 2d2a1b9f..28da2606 100755 --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -14,6 +14,9 @@ CURR_TEST_NUM=0 CURR_TEST_NAME="BLANK" STOP_NUM=9 +DATA_DIR="/home/lanforge/report-data" +REPORT_DIR="/home/lanforge/html-reports" + #Test array testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa " "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" @@ -65,11 +68,13 @@ function run_test() { CURR_TEST_NAME=${i%%.py*} CURR_TEST_NAME=${CURR_TEST_NAME#./*} CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" - echo "$CURR_TEST_NAME $CURR_TEST_NUM" if (( $CURR_TEST_NUM > $STOP_NUM )) || (( $STOP_NUM == $CURR_TEST_NUM )) && (( $STOP_NUM != 0 )); then exit 1 fi + echo "" + echo "Test $CURR_TEST_NUM: $CURR_TEST_NAME" + if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then echo_print echo "$i" @@ -93,28 +98,44 @@ function check_args() { function html_generator() { NOW=$(date +"%Y-%m-%d-%T") header=" - - Candela Test All Scripts Results - - - -

Candela Technologies

- - " - tail="
- - " - fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" - echo $fname - echo $header"${results[@]}"$tail >> $fname + +Test All Scripts Results $NOW + + + +

Test All Scripts Results

+

$NOW

+ +" + tail="
+ +" + + fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" + echo $fname >> $fname + echo "$header" >> $fname + echo "${results[@]}" >> $fname + echo "$tail" >> $fname +} + #true >~/test_all_output_file.txt check_args $1 $2 run_test From 9d7e518bd3629a99ba144968bfce31d2ea17836c Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 22 Jan 2021 17:04:50 -0800 Subject: [PATCH 195/848] save on local machine without failure --- py-scripts/test_ipv4_variable_time.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 481ab880..c043c71e 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -202,19 +202,23 @@ python3 ./test_ipv4_variable_time.py #Create directory if args.report_file is None: - homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' - path = os.path.join('/home/lanforge/report-data/',homedir) - os.mkdir(path) + try: + homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time' + path = os.path.join('/home/lanforge/report-data/',homedir) + os.mkdir(path) + except: + path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + print('Saving file to local directory') else: pass if args.report_file is None: if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']: - report_f='/home/lanforge/report-data/'+homedir+'/data.' + args.output_format + report_f=path+'/data.' + args.output_format output=args.output_format else: print('Defaulting data file output type to Excel') - report_f='/home/lanforge/report-data/'+homedir+'/data.xlsx' + report_f=path+'/data.xlsx' output='xlsx' else: report_f=args.report_file @@ -257,7 +261,7 @@ python3 ./test_ipv4_variable_time.py col_names=None else: col_names = args.col_names - print(col_names) + print(report_f) ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), From a55ce37db9c61f7ad55b7b1af184c8490a0176a2 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 25 Jan 2021 10:41:03 -0800 Subject: [PATCH 196/848] fixing errors in l4cxprofile --- py-json/realm.py | 6 +++--- py-scripts/test_ipv4_connection.py | 0 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 py-scripts/test_ipv4_connection.py diff --git a/py-json/realm.py b/py-json/realm.py index 8b9550e2..3a31bb5d 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1602,7 +1602,7 @@ class L4CXProfile(LFCliBase): endp_list = endp_list['endpoint'] for item in endp_list: for name, info in item.items(): - if name in self.cx_profile.created_cx.keys(): + if name in self.created_cx.keys(): expected_passes += 1 if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) @@ -1739,13 +1739,13 @@ class L4CXProfile(LFCliBase): if monitor: if debug: print(response) - + time.sleep(sleep_interval) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response expected_passes += 1 - if self.cx_profile.check_errors(debug): + if self.check_errors(debug): if self.__check_request_rate(): #need to changed passes += 1 else: diff --git a/py-scripts/test_ipv4_connection.py b/py-scripts/test_ipv4_connection.py old mode 100644 new mode 100755 From 545b6198481e7325616f9cdde1467cabe0472c11 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 25 Jan 2021 13:31:24 -0800 Subject: [PATCH 197/848] create l3 cleanup --- py-scripts/create_l3.py | 43 ++--------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/py-scripts/create_l3.py b/py-scripts/create_l3.py index 2f59cdfb..8624b3a3 100755 --- a/py-scripts/create_l3.py +++ b/py-scripts/create_l3.py @@ -1,11 +1,9 @@ #!/usr/bin/env python3 """ - This script will create a variable number of stations each with their own set of cross-connects and endpoints. - It will then create layer 3 traffic over a specified amount of time, testing for increased traffic at regular intervals. - This test will pass if all stations increase traffic over the full test duration. + This script will create a variable number of layer3 stations each with their own set of cross-connects and endpoints. - Use './test_ipv4_variable_time.py --help' to see command line usage and options + Use './create_l3.py --help' to see command line usage and options """ import sys @@ -75,48 +73,11 @@ class CreateL3(Realm): self.cx_profile.side_b_min_bps = side_b_min_rate self.cx_profile.side_b_max_bps = side_b_max_rate - - def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) - if self.debug: - print(self.cx_profile.created_cx.values()) - print("==============\n", cx_list, "\n==============") - cx_rx_map = {} - for cx_name in cx_list['endpoint']: - if cx_name != 'uri' and cx_name != 'handler': - for item, value in cx_name.items(): - for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): - cx_rx_map[item] = value_rx - return cx_rx_map - - def start(self, print_pass=False, print_fail=False): - self.station_profile.admin_up() - temp_stas = self.station_profile.station_names.copy() - - if self.wait_for_ip(temp_stas): - self._pass("All stations got IPs") - else: - self._fail("Stations failed to get IPs") - self.exit_fail() - self.cx_profile.start_cx() - - - def stop(self): - self.cx_profile.stop_cx() - self.station_profile.admin_down() - def pre_cleanup(self): self.cx_profile.cleanup_prefix() for sta in self.sta_list: self.rm_port(sta, check_exists=True) - def cleanup(self): - self.cx_profile.cleanup() - self.station_profile.cleanup() - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, - port_list=self.station_profile.station_names, - debug=self.debug) def build(self): From be7e94916f24b1fa05126194b5d28732c1d7593f Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 26 Jan 2021 15:28:39 -0800 Subject: [PATCH 198/848] Cleaned up Create L4 --- py-scripts/create_l4.py | 44 +++++------------------------------------ 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/py-scripts/create_l4.py b/py-scripts/create_l4.py index ec9258fb..cb522fb6 100755 --- a/py-scripts/create_l4.py +++ b/py-scripts/create_l4.py @@ -1,13 +1,11 @@ #!/usr/bin/env python3 -""" - This script will create a variable number of stations each with their own set of cross-connects and endpoints. - It will then create layer 3 traffic over a specified amount of time, testing for increased traffic at regular intervals. - This test will pass if all stations increase traffic over the full test duration. - Use './test_ipv4_variable_time.py --help' to see command line usage and options """ + This script will create a variable number of layer4 stations each with their own set of cross-connects and endpoints. + Use './create_l4.py --help' to see command line usage and options +""" import sys import os @@ -75,38 +73,6 @@ class CreateL4(Realm): self.cx_profile.side_b_min_bps = side_b_min_rate self.cx_profile.side_b_max_bps = side_b_max_rate - - def __get_rx_values(self): - cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) - if self.debug: - print(self.cx_profile.created_cx.values()) - print("==============\n", cx_list, "\n==============") - cx_rx_map = {} - for cx_name in cx_list['endpoint']: - if cx_name != 'uri' and cx_name != 'handler': - for item, value in cx_name.items(): - for value_name, value_rx in value.items(): - if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values(): - cx_rx_map[item] = value_rx - return cx_rx_map - - def start(self, print_pass=False, print_fail=False): - self.station_profile.admin_up() - temp_stas = self.station_profile.station_names.copy() - - if self.wait_for_ip(temp_stas): - self._pass("All stations got IPs") - else: - self._fail("Stations failed to get IPs") - self.exit_fail() - self.cx_profile.start_cx() - - - def stop(self): - self.cx_profile.stop_cx() - self.station_profile.admin_down() - - def cleanup(self): self.cx_profile.cleanup() self.station_profile.cleanup() @@ -136,11 +102,11 @@ def main(): ''', description='''\ -test_ipv4_variable_time.py: +layer4.py: -------------------- Generic command layout: -python3 ./test_ipv4_variable_time.py +python3 ./layer4.py --upstream_port eth1 --radio wiphy0 --num_stations 32 From 2550204f3e93b06cb467299ac9ebe28c7d8e4630 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 26 Jan 2021 15:52:45 -0800 Subject: [PATCH 199/848] instruct people to use update_deps.py --- py-json/README.md | 11 ++-- py-scripts/README.md | 82 ++++++++++++------------ py-scripts/html_test_output.sh | 112 +++++++++++++++++++++------------ 3 files changed, 118 insertions(+), 87 deletions(-) diff --git a/py-json/README.md b/py-json/README.md index e90b4eb2..4dc1748c 100644 --- a/py-json/README.md +++ b/py-json/README.md @@ -10,6 +10,8 @@ Follow our [getting started cookbook](http://www.candelatech.com/cookbook.php?vo to learn more about how to operate your LANforge client. ## Getting Started ## +The first step is to run update_deps.py which is located in py-scripts. This command will install all dependencies necessary for lanforge-scripts on your system. + New automation tests and JSON client scripts should go in `../py-scripts`. This directory is intended for utility and library scripts. To use this module, make sure your include path captures this module by adding it to your `sys.path`. We recommend your scripts in `../py-scripts` @@ -33,7 +35,7 @@ begin with these imports: `import LANforge` `from LANforge import LFUtils` `from LANforge import LFRequest` -## create_sta.py ## +## create_sta.py ## Please follow though `create_sta.py` to see how you can utilize the JSON API provided by the LANforge client. It is possible to use similar commands to create virtual Access points. @@ -41,7 +43,7 @@ is possible to use similar commands to create virtual Access points. Example that creates a WANlink ## generic_cx.py ## Example that creates a cross connect -## realm.py ## +## realm.py ## Module defining the Realm class. `Realm` is a toolbox class that also serves as a facade for finer-grained methods in LFUtils and LFRequest: * `__init__`: our constructor @@ -107,7 +109,7 @@ Module defining the Realm class. `Realm` is a toolbox class that also serves as * `run_filter()` : This function will run the filter specified by the `filter` argument on the pcap file specified by the `pcap_file` argument. It redirects this output into a txt file in /tmp and returns the lines in that file as an array. -## realm_test.py ## +## realm_test.py ## Exercises realm.py ## show_ports.py ## This simple example shows how to gather a digest of ports @@ -115,7 +117,7 @@ This simple example shows how to gather a digest of ports Example of how to use LFRequest to create a L4 endpoint ## wct-example.py ## Example of using expect on port 3990 to operate a WiFi Capacity Test -## ws-sta-monitor.py ## +## ws-sta-monitor.py ## Websocket 8081 client that filters interesting station events from the lfclient websocket @@ -172,4 +174,3 @@ This directory defines the LANforge module holding the following classes: Have fun coding! support@candelatech.com - diff --git a/py-scripts/README.md b/py-scripts/README.md index 0460d0a9..e405dd9c 100644 --- a/py-scripts/README.md +++ b/py-scripts/README.md @@ -1,7 +1,10 @@ -# LANForge Python Scripts +# LANForge Python Scripts This directory contains python scripts useful for unit-tests. It uses libraries in ../py-json. Please place new tests in this directory. Unless they are libraries, please avoid adding python scripts to ../py-json. Please read https://www.candelatech.com/cookbook/cli/json-python to learn about how to use the LANforge client JSON directly. Review http://www.candelatech.com/scripting_cookbook.php to understand more about scripts in general. # Getting Started + +The first step is to make sure all dependencies are installed in your system by running update_deps.py in this folder. + Please consider using the `LFCliBase` class as your script superclass. It will help you with a consistent set of JSON handling methods and pass and fail methods for recording test results. Below is a sample snippet that includes LFCliBase: if 'py-json' not in sys.path: @@ -12,11 +15,11 @@ Please consider using the `LFCliBase` class as your script superclass. It will h from LANforge.LFUtils import * import realm from realm import Realm - + class Eggzample(LFCliBase): def __init__(self, lfclient_host, lfclient_port): super().__init__(lfclient_host, lfclient_port, debug=True) - + def main(): eggz = Eggzample("http://localhost", 8080) frontpage_json = eggz.json_get("/") @@ -25,7 +28,7 @@ Please consider using the `LFCliBase` class as your script superclass. It will h "message": "hello world" } eggz.json_post("/cli-json/gossip", data, debug_=True) - + if __name__ == "__main__": main() @@ -47,14 +50,14 @@ The above example will stimulate output on the LANforge client websocket `ws://l * /stations: entities that are associated to your virtual access points (vAP) There are more URIs you can explore, these are the more useful ones. -#### Scripts included are: +#### Scripts included are: * `cicd_TipIntegration.py`: battery of TIP tests that include upgrading DUT and executing sta_connect script -* `cicd_testrail.py`: +* `cicd_testrail.py`: * `function send_get`: Issues a GET request (read) against the API. * `function send_post`: Issues a write against the API. - * `function __send_request`: + * `function __send_request`: * `function get_project_id`: Gets the project ID using the project name * `function get_run_id`: Gets the run ID using test name and project name * `function update_testrail`: Update TestRail for a given run_id and case_id @@ -74,7 +77,7 @@ There are more URIs you can explore, these are the more useful ones. * `run_cv_scenario.py`: * class `RunCvScenario`: imports the LFCliBase class. * function `get_report_file_name`: returns report name - * function `build`: loads and sends the ports available? + * function `build`: loads and sends the ports available? * function `start`: /gui_cli takes commands keyed on 'cmd' and this function create an array of commands * `sta_connect.py`: This function creates a station, create TCP and UDP traffic, run it a short amount of time, and verify whether traffic was sent and received. It also verifies the station connected @@ -88,7 +91,7 @@ There are more URIs you can explore, these are the more useful ones. * function `remove_stations`: removes all stations * function `num_associated`: * function `clear_test_results`: - * function `run`: + * function `run`: * function `setup`: * function `start`: * function `stop`: @@ -103,61 +106,61 @@ There are more URIs you can explore, these are the more useful ones. * function `get_upstream_url`: * function `compare_vals`: compares pre-test values to post-test values * function `remove_stations`: removes all ports - * function `num_associated`: + * function `num_associated`: * function `clear_test_results` * function `setup`: verifies upstream url, creates stations and turns dhcp on, creates endpoints, UDP endpoints, - * function `start`: + * function `start`: * function `stop`: * function `cleanup`: - * function `main`: + * function `main`: * `sta_connect_example.py`: example of how to instantiate StaConnect and run the test -* `sta_connect_multi_example.py`: example of how to instantiate StaConnect and run the test and create multiple OPEN stations,have -some stations using WPA2 +* `sta_connect_multi_example.py`: example of how to instantiate StaConnect and run the test and create multiple OPEN stations,have +some stations using WPA2 * `stations_connected.py`: Contains examples of using realm to query stations and get specific information from them -* `test_ipv4_connection.py`: This script will create a variable number of stations that will attempt to connect to a chosen SSID using a provided password and security type. - The test is considered passed if all stations are able to associate and obtain IPV4 addresses +* `test_ipv4_connection.py`: This script will create a variable number of stations that will attempt to connect to a chosen SSID using a provided password and security type. + The test is considered passed if all stations are able to associate and obtain IPV4 addresses * class `IPv4Test` * function `build`: This function will use the given parameters (Number of stations, SSID, password, and security type) to create a series of stations. - * function `start`: This function will admin-up the stations created in the build phase. It will then check all stations periodically for association and IP addresses. - This will continue until either the specified timeout has been reached or all stations obtain an IP address. - * function `stop`: This function will admin-down all stations once one of the ending criteria is met. + * function `start`: This function will admin-up the stations created in the build phase. It will then check all stations periodically for association and IP addresses. + This will continue until either the specified timeout has been reached or all stations obtain an IP address. + * function `stop`: This function will admin-down all stations once one of the ending criteria is met. * function `cleanup`: This function will clean up all stations created during the test. * command line options : * `--mgr`: Specifies the hostname where LANforge is running. Defaults to http://localhost * `--mgr_port`: Specifies the port to use when connecting to LANforge. Defaults to 8080 * `--ssid`: Specifies SSID to be used in the test - * `--password`: Specifies the password for the SSID to be used in the test + * `--password`: Specifies the password for the SSID to be used in the test * `--security`: Specifies security type (WEP, WPA, WPA2, WPA3, Open) of SSID to be used in the test * `--num_stations`: Specifies number of stations to create for the test * `--radio`: Specifies the radio to be used in the test. Eg wiphy0 * `--debug`: Turns on debug output for the test * `--help`: Displays help output for the script -* `test_ipv6_connection.py`: This script will create a variable number of stations that will attempt to connect to a chosen SSID using a provided password and security type. - The test is considered passed if all stations are able to associate and obtain IPV6 addresses +* `test_ipv6_connection.py`: This script will create a variable number of stations that will attempt to connect to a chosen SSID using a provided password and security type. + The test is considered passed if all stations are able to associate and obtain IPV6 addresses * class `IPv6Test` * function `build`: This function will use the given parameters (Number of stations, SSID, password, and security type) to create a series of stations. - * function `start`: This function will admin-up the stations created in the build phase. It will then check all stations periodically for association and IP addresses. - This will continue until either the specified timeout has been reached or all stations obtain an IP address. - * function `stop`: This function will admin-down all stations once one of the ending criteria is met. + * function `start`: This function will admin-up the stations created in the build phase. It will then check all stations periodically for association and IP addresses. + This will continue until either the specified timeout has been reached or all stations obtain an IP address. + * function `stop`: This function will admin-down all stations once one of the ending criteria is met. * function `cleanup`: This function will clean up all stations created during the test. * Command line options : * `--mgr`: Specifies the hostname where LANforge is running. Defaults to http://localhost * `--mgr_port`: Specifies the port to use when connecting to LANforge. Defaults to 8080 * `--ssid`: Specifies SSID to be used in the test - * `--password`: Specifies the password for the SSID to be used in the test + * `--password`: Specifies the password for the SSID to be used in the test * `--security`: Specifies security type (WEP, WPA, WPA2, WPA3, Open) of SSID to be used in the test * `--num_stations`: Specifies number of stations to create for the test * `--radio`: Specifies the radio to be used in the test. Eg wiphy0 * `--debug`: Turns on debug output for the test * `--help`: Displays help output for the script -* `test_l3_unicast_traffic_gen.py`: This script will create stations, create traffic between upstream port and stations, run traffic. +* `test_l3_unicast_traffic_gen.py`: This script will create stations, create traffic between upstream port and stations, run traffic. The traffic on the stations will be checked once per minute to verify that traffic is transmitted and received. Test will exit on failure of not receiving traffic for one minute on any station. * class `L3VariableTimeLongevity` @@ -170,10 +173,10 @@ Test will exit on failure of not receiving traffic for one minute on any station * `-d, --test_duration`: Determines the total length of the test. Consists of number followed by letter indicating length 10m would be 10 minutes or 3d would be 3 days. Available options for length are Day (d), Hour (h), Minute (m), or Second (s) * `-t, --endp_type`: Specifies type of endpoint to be used in the test. Options are lf_udp, lf_udp6, lf_tcp, lf_tcp6 - * `-u, --upstream_port`: This is the upstream port to be used for traffic. An upstream port is some data source on the wired LAN or WAN beyond the AP + * `-u, --upstream_port`: This is the upstream port to be used for traffic. An upstream port is some data source on the wired LAN or WAN beyond the AP * `-r, --radio`: This switch will determine the radio name, number of stations, ssid, and ssid password. Security type is fixed at WPA2. Usage of this switch could look like: `--radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3` - + * `test_ipv4_l4_urls_per_ten.py`: This script measure the number of urls per ten minutes over layer 4 traffic * class `IPV4L4` * function `build`: This function will create all stations and cross-connects to be used in the test @@ -186,17 +189,17 @@ Test will exit on failure of not receiving traffic for one minute on any station * `--mgr`: Specifies the hostname where LANforge is running. Defaults to http://localhost * `--mgr_port`: Specifies the port to use when connecting to LANforge. Defaults to 8080 * `--ssid`: Specifies SSID to be used in the test - * `--password`: Specifies the password for the SSID to be used in the test + * `--password`: Specifies the password for the SSID to be used in the test * `--security`: Specifies security type (WEP, WPA, WPA2, WPA3, Open) of SSID to be used in the test * `--num_stations`: Specifies number of stations to create for the test * `--radio`: Specifies the radio to be used in the test. Eg wiphy0 * `--requests_per_ten`: Configures the number of request per ten minutes * `--num_tests`: Configures the number of tests to be run. Each test runs for ten minutes * `--url`: Specifies the upload/download, address, and destination. Example: dl http://10.40.0.1 /dev/null - * `--target_per_ten`: Rate of target urls per ten minutes. 90% of this value will be considered the threshold for a passed test. + * `--target_per_ten`: Rate of target urls per ten minutes. 90% of this value will be considered the threshold for a passed test. * `--debug`: Turns on debug output for the test * `--help`: Displays help output for the script - + * `test_ipv4_l4_ftp_urls_per_ten.py`: This script measure the number of urls per ten minutes over layer 4 ftp traffic * class `IPV4L4` @@ -210,29 +213,29 @@ Test will exit on failure of not receiving traffic for one minute on any station * `--mgr`: Specifies the hostname where LANforge is running. Defaults to http://localhost * `--mgr_port`: Specifies the port to use when connecting to LANforge. Defaults to 8080 * `--ssid`: Specifies SSID to be used in the test - * `--password`: Specifies the password for the SSID to be used in the test + * `--password`: Specifies the password for the SSID to be used in the test * `--security`: Specifies security type (WEP, WPA, WPA2, WPA3, Open) of SSID to be used in the test * `--num_stations`: Specifies number of stations to create for the test * `--radio`: Specifies the radio to be used in the test. Eg wiphy0 * `--requests_per_ten`: Configures the number of request per ten minutes * `--num_tests`: Configures the number of tests to be run. Each test runs for ten minutes * `--url`: Specifies the upload/download, address, and destination. Example: dl http://10.40.0.1 /dev/null - * `--target_per_ten`: Rate of target urls per ten minutes. 90% of this value will be considered the threshold for a passed test. + * `--target_per_ten`: Rate of target urls per ten minutes. 90% of this value will be considered the threshold for a passed test. * `--debug`: Turns on debug output for the test * `--help`: Displays help output for the script * `test_generic`: - * class `GenTest`: This script will create + * class `GenTest`: This script will create * function `build`: This function will create the stations and cross-connects to be used during the test. - * function `start`: This function will start traffic and measure different values dependent on the command chosen. + * function `start`: This function will start traffic and measure different values dependent on the command chosen. Commands currently available for use: lfping, generic, and speedtest. * function `stop`: This function will admin-down stations, stop traffic on cross-connects and cleanup any stations or cross-connects associated with the test. * function `cleanup`: This function will remove any stations and cross-connects created during the test. - * Command line options: + * Command line options: * `--mgr`: Specifies the hostname where LANforge is running. Defaults to http://localhost * `--mgr_port`: Specifies the port to use when connecting to LANforge. Defaults to 8080 * `--ssid`: Specifies SSID to be used in the test - * `--password`: Specifies the password for the SSID to be used in the test + * `--password`: Specifies the password for the SSID to be used in the test * `--security`: Specifies security type (WEP, WPA, WPA2, WPA3, Open) of SSID to be used in the test * `--num_stations`: Specifies number of stations to create for the test * `--radio`: Specifies the radio to be used in the test. Eg wiphy0 @@ -263,6 +266,3 @@ Test will exit on failure of not receiving traffic for one minute on any station * class `VapStations` * function `run`: * function `main`: - - - diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh index 28da2606..813870c2 100755 --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -14,23 +14,26 @@ CURR_TEST_NUM=0 CURR_TEST_NAME="BLANK" STOP_NUM=9 -DATA_DIR="/home/lanforge/report-data" +DATA_DIR="${TEST_DIR}" REPORT_DIR="/home/lanforge/html-reports" +#set -vex + #Test array -testCommands=("./example_security_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa " +testCommands=( + "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa" "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3" "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" - "./test_generic.py --mgr localhost --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" - "./test_generic.py --mgr localhost --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" - "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" - "./test_ipv4_l4_wifi.py --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" - "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m" + "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" + "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" + "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" + "./test_ipv4_l4_wifi.py --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" + "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m" "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" - "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" + #"./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" #"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" #"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" #"./create_macvlan.py --radio wiphy1" @@ -63,6 +66,11 @@ function echo_print() { echo "Beginning $CURR_TEST_NAME test..." >>~/test_all_output_file.txt } results=() +detailedresults=() +NOW=$(date +"%Y-%m-%d-%H-%M") +NOW="${NOW/:/-}" +TEST_DIR="/home/lanforge/report-data/${NOW}" +mkdir "$TEST_DIR" function run_test() { for i in "${testCommands[@]}"; do CURR_TEST_NAME=${i%%.py*} @@ -78,10 +86,14 @@ function run_test() { if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then echo_print echo "$i" - if $i; then - results+=("${CURR_TEST_NAME}Success") + $i > "${TEST_DIR}/${i}.txt" 2> "${TEST_DIR}/${i}_stderr.txt" + retval=$? + grep -i fail "${TEST_DIR}/${i}.txt" && retval=1 + chmod 664 "${TEST_DIR}/${i}.txt" + if (( $retval == 0 )); then + results+=("${CURR_TEST_NAME}${i}Success") else - results+=("${CURR_TEST_NAME}Failure") + results+=("${CURR_TEST_NAME}${i}Failure") fi fi done @@ -98,46 +110,64 @@ function check_args() { function html_generator() { NOW=$(date +"%Y-%m-%d-%T") header=" - -Test All Scripts Results $NOW - - - -

Test All Scripts Results

-

$NOW

- -" - tail="
- -" + + Test All Scripts Results $NOW + + + + +

Test All Scripts Results

+

$NOW

+ + " + tail=" + " fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" echo $fname >> $fname echo "$header" >> $fname echo "${results[@]}" >> $fname + echo "
" >> $fname + for item in "${testCommands[@]}"; do + CURR_TEST_NAME=${item%%.py*} + CURR_TEST_NAME=${CURR_TEST_NAME#./*} + echo "
" >> $fname + done; echo "$tail" >> $fname } #true >~/test_all_output_file.txt check_args $1 $2 run_test +echo "${detailedresults}" html_generator #test generic and fileio are for macvlans From c45dad5fc7e5ac20e3ec15e086b05c9feac0ffff Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 26 Jan 2021 17:09:49 -0800 Subject: [PATCH 200/848] html test output update --- py-scripts/html_test_output.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh index 813870c2..52978d83 100755 --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -158,9 +158,8 @@ function html_generator() { echo "${results[@]}" >> $fname echo "" >> $fname for item in "${testCommands[@]}"; do - CURR_TEST_NAME=${item%%.py*} - CURR_TEST_NAME=${CURR_TEST_NAME#./*} - echo "
" >> $fname + item2=$(echo $item | sed 's/^..//') + echo "
" >> $fname done; echo "$tail" >> $fname } From ea80924d70f740af3c15bf6e86d87c919b00a5b8 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Wed, 27 Jan 2021 12:44:00 -0800 Subject: [PATCH 201/848] README and name in column names --- README.md | 6 +++--- py-json/realm.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d4febe83..b44416e7 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Read more examples in the [scripting LANforge](http://www.candelatech.com/lfcli_ ### Python Scripts ### +When starting to use Python, please run the update_deps.py script located in py-scripts to install all necessary dependencies for this library. + | Name | Purpose | |------|---------| | `lf_tos_test.py` | Python script to generate traffic at different QoS and report performance in a spreadsheet | @@ -121,7 +123,7 @@ one script to a separate directory is going to break its requirements. ### Requirements ### The perl scripts require the following perl packages to be installed. Most of these -perl packages are available through your repository as `.deb` or `.rpm` packages. +perl packages are available through your repository as `.deb` or `.rpm` packages. | Perl Package | RPM | Required | | -------------------|------------------|----------------| @@ -161,5 +163,3 @@ Please contact support@candelatech.com if you have any questions. _Thanks, Ben_ - - diff --git a/py-json/realm.py b/py-json/realm.py index 3a31bb5d..65e2ad15 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1173,6 +1173,8 @@ class L3CXProfile(BaseProfile): # Step 1, column names . what is this for? fields=None + if 'Name' not in col_names': + col_names.insert(0,'Name') if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) header_row=col_names From 4316830314244036e7aa69085c85c5272dff57e2 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Wed, 27 Jan 2021 12:46:58 -0800 Subject: [PATCH 202/848] fix col_names realm issue --- py-json/realm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 65e2ad15..f58d59ca 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1173,7 +1173,7 @@ class L3CXProfile(BaseProfile): # Step 1, column names . what is this for? fields=None - if 'Name' not in col_names': + if 'Name' not in col_names: col_names.insert(0,'Name') if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) From 4f37a96ba55dd1ba5d6fe5eb9fae0e82748a62c3 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Wed, 27 Jan 2021 12:50:46 -0800 Subject: [PATCH 203/848] fix col_names realm issue --- py-json/realm.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f58d59ca..3a31bb5d 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1173,8 +1173,6 @@ class L3CXProfile(BaseProfile): # Step 1, column names . what is this for? fields=None - if 'Name' not in col_names: - col_names.insert(0,'Name') if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) header_row=col_names From ec706aa1b6923670f730c7e7d65634534887007e Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 21 Jan 2021 16:41:31 -0800 Subject: [PATCH 204/848] removes import of generic_cx --- py-json/realm.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 3a31bb5d..d97a76f5 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -640,6 +640,7 @@ class Realm(LFCliBase): num_sta_with_ips += 1 return num_sta_with_ips + def duration_time_to_seconds(self, time_string): if isinstance(time_string, str): pattern = re.compile("^(\d+)([dhms]$)") @@ -1098,7 +1099,6 @@ class L3CXProfile(BaseProfile): self.created_endp = {} self.name_prefix = name_prefix_ self.number_template = number_template_ - self.lfclient_port = lfclient_port def get_cx_names(self): return self.created_cx.keys() @@ -1250,10 +1250,7 @@ class L3CXProfile(BaseProfile): df.columns = header_row import requests import ast - try: - systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) - except: - systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text) + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] df['Script Name'] = script_name df['Arguments'] = arguments @@ -1268,7 +1265,7 @@ class L3CXProfile(BaseProfile): fig.savefig(report_file) if output_format == 'df': return df - supported_formats = ['csv', 'json', 'stata', 'pickle','html'] + supported_formats = ['csv','json','stata','pickle'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: exec('df.to_' + x + '("' + report_file + '")') @@ -2074,6 +2071,7 @@ class WifiMonitor: baseurl=self.lfclient_url, debug=self.debug) + def admin_up(self): up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.monitor_name) self.local_realm.json_post("/cli-json/set_port", up_request) @@ -2553,6 +2551,7 @@ class VRProfile(LFCliBase): else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) + def create(self, resource, upstream_port="eth1", debug=False, upstream_subnets="20.20.20.0/24", upstream_nexthop="20.20.20.1", local_subnets="10.40.0.0/24", local_nexthop="10.40.3.198", @@ -3121,6 +3120,7 @@ class MACVLANProfile(LFCliBase): # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.created_macvlans) + def admin_up(self): for macvlan in self.created_macvlans: self.local_realm.admin_up(macvlan) @@ -3391,7 +3391,7 @@ class StationProfile: self.local_realm = local_realm self.use_ht160 = use_ht160 self.COMMANDS = ["add_sta", "set_port"] - self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] + self.desired_add_sta_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.desired_add_sta_flags_mask = ["wpa2_enable", "80211u_enable", "create_admin_down"] self.number_template = number_template_ self.station_names = [] # eids, these are created station names @@ -3658,6 +3658,7 @@ class StationProfile: # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) + # Checks for errors in initialization values and creates specified number of stations using init parameters def create(self, radio, num_stations=0, From 00ddbd58a26b8439f4454c715ccb7f000e06fdb2 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Fri, 22 Jan 2021 07:42:20 -0700 Subject: [PATCH 205/848] lf_ap_power.py: LCS-45 Read AP for Power values Updated login to help with multiple logins lf_cisco_power.py: comments update --- lf_cisco_power.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 38d376e5..92ac654b 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -2194,4 +2194,4 @@ if __name__ == '__main__': #### #### #### - \ No newline at end of file + From 1a4cfe0d4ab1673f6ab244c0634a480de361aa34 Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Wed, 27 Jan 2021 16:30:45 +0530 Subject: [PATCH 206/848] Netear Dfs Test --- py-scripts/netgear_dfs_test.py | 1582 ++++++++++++++++---------------- 1 file changed, 791 insertions(+), 791 deletions(-) diff --git a/py-scripts/netgear_dfs_test.py b/py-scripts/netgear_dfs_test.py index 307629f8..109562d6 100644 --- a/py-scripts/netgear_dfs_test.py +++ b/py-scripts/netgear_dfs_test.py @@ -1,791 +1,791 @@ -''' This script uses Netgear AP for DFS testing -''' - - -import os -import paramiko -import time -import threading -from cx_time import IPv4Test -import argparse -from threading import Thread -from itertools import islice -import datetime -from datetime import datetime -import numpy as np -import matplotlib.pyplot as plt - - -class DFS_Test: - - def __init__(self, ip, user, pswd, host, ssid, passwd, security, radio): - self.ip = ip - self.user = user - self.pswd = pswd - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - def check_last_time_ap(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(10) - return output - - def create_station_on_GUI_1(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - obj.cleanup(obj.sta_list) - obj.build() - obj.station_profile.admin_up() - obj.local_realm.wait_for_ip(obj.sta_list) - time.sleep(5) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - # print(var_1) - - return var_1 - - def monitor_station_52(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - if var_1 == "52": - print("channel at 52") - else: - print("wait untill channel assigned") - timeout = time.time() + 60 * 15 - while var_1 != "52": - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = var['interface']['channel'] - time.sleep(1) - if time.time() > timeout: - break - - return var_1 - - def monitor_station_100(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - if var_1 == "100": - print("channel at 100") - else: - print("wait untill channel assigned") - timeout = time.time() + 60 * 15 - while var_1 != "100": - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = var['interface']['channel'] - time.sleep(1) - if time.time() > timeout: - break - - return var_1 - - def monitor_station_120(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - if var_1 == "120": - print("channel at 120") - else: - print("wait untill channel assigned") - timeout = time.time() + 60 * 15 - while var_1 != "120": - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = var['interface']['channel'] - time.sleep(1) - if time.time() > timeout: - break - - return var_1 - - def monitor_station_140(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - if var_1 == "140": - print("channel at 140") - else: - print("wait untill channel assigned") - timeout = time.time() + 60 * 2 - while var_1 != "140": - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = var['interface']['channel'] - time.sleep(1) - if time.time() > timeout: - break - - return var_1 - - def monitor_untill_channel_assigned(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = (var['interface']['channel']) - - timeout = time.time() + 60 * 5 - while var_1 == "-1": - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = var['interface']['channel'] - time.sleep(1) - if time.time() > timeout: - break - - return var_1 - - def set_channel_in_ap_at_52(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(10) - - def generate_radar_at_ch52(self): - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - print("Radar detected") - time.sleep(1) - - def check_log_channel(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - return output - - def check_log_info(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep OTHER') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - return output - - def check_log_associated(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep associated') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - return output - - """def check_log_associated(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep Trig') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - return output""" - - def check_for_channels(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(1) - return output - - def set_channel_in_ap_at_100(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - - def generate_radar_at_ch100(self): - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - print("Radar detected") - time.sleep(20) - - def set_channel_in_ap_at_120(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 120') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - - def set_channel_in_ap_at_140(self, ip, user, pswd): - self.ip = ip - self.user = user - self.pswd = pswd - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect(ip, port=22, username=user, password=pswd) - stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 140') - output = stdout.readlines() - # print('\n'.join(output)) - time.sleep(30) - - def generate_radar_at_ch120(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - - def generate_radar_at_ch140(self): - - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - - def station_clean(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - obj.cleanup(obj.sta_list) - var_1 = "station cleaned" - print(var_1) - - def monitor_untill_connection_time(self, host, ssid, passwd, security, radio): - self.host = host - self.ssid = ssid - self.passwd = passwd - self.security = security - self.radio = radio - - obj = IPv4Test(_host=host, - _port=8080, - _ssid=ssid, - _password=passwd, - _security=security, - _radio=radio) - var = obj.json_get("/port/1/1/sta0000?fields=cx%20time%20(us)") - var_1 = (var['interface']['cx time (us)']) - return var_1 - - - -class ThreadWithReturnValue(Thread): - def __init__(self, group=None, target=None, name=None, - args=(), kwargs={}, Verbose=None): - Thread.__init__(self, group, target, name, args, kwargs) - self._return = None - - def run(self): - # print(type(self._target)) - if self._target is not None: - # self._return = self._target(*self._args, **self._kwargs) - self._return = self._target - - def join(self, *args): - Thread.join(self, *args) - return self._return - - -def main(): - parser = argparse.ArgumentParser(description="Netgear AP DFS Test Script") - parser.add_argument('-i', '--ip', type=str, help='AP ip') - parser.add_argument('-u', '--user', type=str, help='credentials login/username') - parser.add_argument('-p', '--pswd', type=str, help='credential password') - parser.add_argument('-hst', '--host', type=str, help='host name') - parser.add_argument('-s', '--ssid', type=str, help='ssid for client') - parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid') - parser.add_argument('-sec', '--security', type=str, help='security') - parser.add_argument('-rad', '--radio', type=str, help='radio at which client will be connected') - parser.add_argument('-n', '--name', type=str, help='Type Name of AP on which test is performed') - - - - - args = parser.parse_args() - - if (args.name is not None): - AP_name = args.name - - if(args.ssid is not None): - ssid = args.ssid - - dfs = DFS_Test(args.ip, args.user, args.pswd, args.host, args.ssid, args.passwd, args.security, args.radio) - - # check for last timesnap of ap logs - - th = ThreadWithReturnValue(target=dfs.check_last_time_ap(args.ip, args.user, args.pswd)) - th.start() - th.join() - val = th.join() - N = 1 - res = list(islice(reversed(val), 0, N)) - res.reverse() - x_list = res - var_1 = "" - for i in x_list[0][10:20]: - var_1 = var_1 + i - - var_1 = var_1.strip() - print(var_1) - print("timesnap for last log is ", var_1) - - print("creating station on GUI") - t1 = ThreadWithReturnValue( - target=dfs.create_station_on_GUI_1(args.host, args.ssid, args.passwd, args.security, args.radio)) - t1.start() - t1.join() - val_1 = t1.join() - val_1 = val_1.strip() - print("station is at channel", val_1) - - time.sleep(2) - - print("set channel to 52") - t2 = ThreadWithReturnValue(target=dfs.set_channel_in_ap_at_52(args.ip, args.user, args.pswd)) - t2.start() - t2.join() - - print("channel set checking....") - t3 = ThreadWithReturnValue(target=dfs.monitor_station_52(args.host, args.ssid, args.passwd, args.security, args.radio)) - t3.start() - t3.join() - print(t3.join()) - - var_5 = "" - time_1 = "" - channel = "" - cx_time = "" - while True: - if t3.join() == "52": - print("station allocated to 52") - print("now generate radar on 52") - - t4 = threading.Thread(target=dfs.generate_radar_at_ch52()) - t4.start() - t4.join() - - # time.sleep(80) - - print("checking channel assigned...") - th_1 = ThreadWithReturnValue(target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security,args.radio)) - th_1.start() - th_1.join() - print(th_1.join()) - channel = th_1.join() - print("after radar channel is at ", channel) - - if channel == "-1": - print("TEST Fail") - print("AP is at AUTO Channel") - break - else: - print("Test Pass") - - th_2 = ThreadWithReturnValue(target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security,args.radio)) - th_2.start() - th_2.join() - print(th_2.join()) - cx_time = th_2.join() - print("after radar station time is ", cx_time) - break - else: - print("stop") - break - - time.sleep(120) - t9 = ThreadWithReturnValue(target=dfs.check_for_channels(args.ip, args.user, args.pswd)) - t9.start() - t9.join() - var1 = t9.join() - a_list = [] - for i in var1: - a_list.append(i.strip()) - # print("hi", a_list) - - time_11 = "" - var5 = "" - channel_1 = "" - cx_time1 = "" - if any("Channel 100 : 5.5 GHz" in s for s in a_list): - print("set channel to 100") - t10 = threading.Thread(target=dfs.set_channel_in_ap_at_100(args.ip, args.user, args.pswd)) - t10.start() - t10.join() - print("channel set to 100") - - print("channel set checking....") - t31 = ThreadWithReturnValue( - target=dfs.monitor_station_100(args.host, args.ssid, args.passwd, args.security, args.radio)) - t31.start() - t31.join() - print(t31.join()) - - while True: - if t31.join() == "100": - print("station allocated to 100") - print("now generate radar on 100") - - t11 = threading.Thread(target=dfs.generate_radar_at_ch100()) - t11.start() - t11.join() - - # time.sleep(80) - print("checking channel assigned...") - th_1a = ThreadWithReturnValue( - target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security, - args.radio)) - - th_1a.start() - th_1a.join() - print(th_1a.join()) - channel_1 = th_1a.join() - print("after radar channel is at ", channel_1) - - if th_1a.join() == "-1": - print("TEST Fail") - break - else: - print("Test Pass") - th_3 = ThreadWithReturnValue( - target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security, - args.radio)) - th_3.start() - th_3.join() - print(th_3.join()) - cx_time1 = th_3.join() - print("after radar station connection time i ", cx_time1) - break - - else: - print("check for some another channel") - break - - time.sleep(120) - - t19 = ThreadWithReturnValue(target=dfs.check_for_channels(args.ip, args.user, args.pswd)) - t19.start() - t19.join() - var11 = t19.join() - b_list = [] - for i in var11: - b_list.append(i.strip()) - # print("hi", a_list) - - time_12 = "" - var51 = "" - channel_2 = "" - cx_time2 = "" - if any("Channel 120 : 5.6 GHz" in s for s in b_list): - print("set channel to 120") - - t15 = threading.Thread(target=dfs.set_channel_in_ap_at_120(args.ip, args.user, args.pswd)) - t15.start() - t15.join() - print("channel set to 120") - - print("channel set checking....") - t32 = ThreadWithReturnValue( - target=dfs.monitor_station_120(args.host, args.ssid, args.passwd, args.security, args.radio)) - t32.start() - t32.join() - print(t32.join()) - while True: - if t32.join() == "120": - print("station allocated to 120") - print("now generate radar on 120") - - t16 = threading.Thread(target=dfs.generate_radar_at_ch120()) - t16.start() - t16.join() - - # time.sleep(80) - - print("checking channel assigned...") - thr1 = ThreadWithReturnValue( - target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security, - args.radio)) - thr1.start() - thr1.join() - print(thr1.join()) - channel_2 = thr1.join() - print("after radar channel is at ", channel_2) - - if thr1.join() == "-1": - print("TEST Fail") - break - else: - print("Test Pass") - th_4 = ThreadWithReturnValue( - target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security, - args.radio)) - th_4.start() - th_4.join() - print(th_4.join()) - cx_time2 = th_4.join() - print("after radar station connection time is ", cx_time2) - break - else: - print("stop") - break - - # channel list - ch_list = [] - ch_list.extend((channel, channel_1, channel_2)) - print("after radar switched channel list ", ch_list) - - cha_list = ["52", "100", "120"] - print("test channel list", cha_list) - - time_ass = [] - time_ass.extend((cx_time, cx_time1, cx_time2)) - print("list of connection time", time_ass) - - - """ch_list = ['44', '36', '120'] - for n, i in enumerate(ch_list): - if i == '': - ch_list[n] = '0' - - # print(ch_list) - for i in range(0, len(ch_list)): - ch_list[i] = int(ch_list[i]) - - # print(ch_list) - cha_list = ['52', '100', '120'] - y_pos = np.arange(len(cha_list)) - - # Create bars and choose color - plt.bar(y_pos, ch_list, color=(0.5, 0.1, 0.5, 0.6)) - - # Add title and axis names - plt.title('channel association') - plt.xlabel('Channels') - plt.ylabel('channel assigned') - - # Limits for the Y axis - plt.ylim(0, 140) - - # Create names - plt.xticks(y_pos, cha_list) - - # Show graphic - #plt.show() - plt.savefig("channel.png")""" - - - ############################################################################### - - time_ass = ['23348', '19126', ''] - for n, i in enumerate(time_ass): - if i == '': - time_ass[n] = '0' - - # print(ch_list) - for i in range(0, len(time_ass)): - time_ass[i] = int(time_ass[i]) - - # seconds = microseconds ÷ 1,000,000 - for i in range(0, len(time_ass)): - time_ass[i] = time_ass[i] / 1000 - - cha_list = ['52', '100', '120'] - y_pos = np.arange(len(cha_list)) - - # Create bars and choose color - plt.bar(y_pos, time_ass, color=(0.5, 0.1, 0.5, 0.6)) - - # Add title and axis names - plt.title('connection time') - plt.xlabel('Channels') - plt.ylabel('association time (milliseconds)') - - # Limits for the Y axis - plt.ylim(0, 100) - - # Create names - plt.xticks(y_pos, cha_list) - - # Show graphic - #plt.show() - plt.savefig("/home/lanforge/lanforge-scripts/py-scripts/time.png") - - ch_list = ['44', '36', '120'] - for i in range(0, len(time_ass)): - time_ass[i] = str(time_ass[i]) - - if ch_list[0] == "52" or ch_list[0] == "-1" or ch_list[0] == "" or ch_list[0] == "0": - data = "FAIL" - else: - data = "PASS" - # print(data) - - if ch_list[1] == "100" or ch_list[1] == "-1" or ch_list[1] == "" or ch_list[1] == "0": - data_1 = "FAIL" - else: - data_1 = "PASS" - - if ch_list[2] == "120" or ch_list[2] == "-1" or ch_list[2] == "" or ch_list[2] == "0": - data_2 = "FAIL" - else: - data_2 = "PASS" - - - - - now = datetime.now() - print("Current date and time : ") - date_1 = now.strftime("%Y-%m-%d %H:%M:%S") - - if data == "FAIL": - x = " FAIL " - else: - if data == "PASS": - x = " PASS " - - if data_1 == "FAIL": - x_1 = " FAIL " - else: - if data_1 == "PASS": - x_1 = " PASS " - - if data_2 == "FAIL": - x_2 = " FAIL " - else: - if data_2 == "PASS": - x_2 = " PASS " - - - - html_content = "DFS TEST

Dynamic Frequency Selection

" \ - "

" + date_1 + "



Objective

The DFS Test is designed to test the Performance of the Netgear Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP Name" + AP_name + "
SSID" + ssid + "
Number of Clients1
" \ - "

Graph


Detailed Results
" + x + """" + x_1 + "" + x_2 + "
Client NameChannelSwitched Channelstation association time(milliseconds)Result
sta000052"+ ch_list[0] +""+ time_ass[0] +"
sta0000100"+ ch_list[1] + ""+ time_ass[1] +"
sta0000120"+ ch_list[2] +""+ time_ass[2] +"
" - - file = open("/home/lanforge/lanforge-scripts/py-scripts/result.html", "w") - file.write(html_content) - file.close() - - print("Test Finished") - -if __name__ == '__main__': - main() +''' This script uses Netgear AP for DFS testing +''' + + +import os +import paramiko +import time +import threading +from cx_time import IPv4Test +import argparse +from threading import Thread +from itertools import islice +import datetime +from datetime import datetime +import numpy as np +import matplotlib.pyplot as plt + + +class DFS_Test: + + def __init__(self, ip, user, pswd, host, ssid, passwd, security, radio): + self.ip = ip + self.user = user + self.pswd = pswd + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + def check_last_time_ap(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(10) + return output + + def create_station_on_GUI_1(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + obj.cleanup(obj.sta_list) + obj.build() + obj.station_profile.admin_up() + obj.local_realm.wait_for_ip(obj.sta_list) + time.sleep(5) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + # print(var_1) + + return var_1 + + def monitor_station_52(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "52": + print("channel at 52") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 15 + while var_1 != "52": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_station_100(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "100": + print("channel at 100") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 15 + while var_1 != "100": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_station_120(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "120": + print("channel at 120") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 15 + while var_1 != "120": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_station_140(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + if var_1 == "140": + print("channel at 140") + else: + print("wait untill channel assigned") + timeout = time.time() + 60 * 2 + while var_1 != "140": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def monitor_untill_channel_assigned(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = (var['interface']['channel']) + + timeout = time.time() + 60 * 5 + while var_1 == "-1": + var = obj.json_get("/port/1/1/sta0000?fields=channel") + var_1 = var['interface']['channel'] + time.sleep(1) + if time.time() > timeout: + break + + return var_1 + + def set_channel_in_ap_at_52(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(10) + + def generate_radar_at_ch52(self): + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + print("Radar detected") + time.sleep(1) + + def check_log_channel(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep channel') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output + + def check_log_info(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep OTHER') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output + + def check_log_associated(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep associated') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output + + """def check_log_associated(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('cat /tmp/log/messages | grep Trig') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + return output""" + + def check_for_channels(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('iwlist wifi1vap0 channel') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(1) + return output + + def set_channel_in_ap_at_100(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 100') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + + def generate_radar_at_ch100(self): + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + print("Radar detected") + time.sleep(20) + + def set_channel_in_ap_at_120(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 120') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + + def set_channel_in_ap_at_140(self, ip, user, pswd): + self.ip = ip + self.user = user + self.pswd = pswd + ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key + ssh.connect(ip, port=22, username=user, password=pswd) + stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 140') + output = stdout.readlines() + # print('\n'.join(output)) + time.sleep(30) + + def generate_radar_at_ch120(self): + + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + + def generate_radar_at_ch140(self): + + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" + # print("Current working directory: {0}".format(os.getcwd())) + os.chdir('/usr/lib64/python2.7/site-packages/') + # print("Current working directory: {0}".format(os.getcwd())) + os.system(cmd) + + def station_clean(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + obj.cleanup(obj.sta_list) + var_1 = "station cleaned" + print(var_1) + + def monitor_untill_connection_time(self, host, ssid, passwd, security, radio): + self.host = host + self.ssid = ssid + self.passwd = passwd + self.security = security + self.radio = radio + + obj = IPv4Test(_host=host, + _port=8080, + _ssid=ssid, + _password=passwd, + _security=security, + _radio=radio) + var = obj.json_get("/port/1/1/sta0000?fields=cx%20time%20(us)") + var_1 = (var['interface']['cx time (us)']) + return var_1 + + + +class ThreadWithReturnValue(Thread): + def __init__(self, group=None, target=None, name=None, + args=(), kwargs={}, Verbose=None): + Thread.__init__(self, group, target, name, args, kwargs) + self._return = None + + def run(self): + # print(type(self._target)) + if self._target is not None: + # self._return = self._target(*self._args, **self._kwargs) + self._return = self._target + + def join(self, *args): + Thread.join(self, *args) + return self._return + + +def main(): + parser = argparse.ArgumentParser(description="Netgear AP DFS Test Script") + parser.add_argument('-i', '--ip', type=str, help='AP ip') + parser.add_argument('-u', '--user', type=str, help='credentials login/username') + parser.add_argument('-p', '--pswd', type=str, help='credential password') + parser.add_argument('-hst', '--host', type=str, help='host name') + parser.add_argument('-s', '--ssid', type=str, help='ssid for client') + parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid') + parser.add_argument('-sec', '--security', type=str, help='security') + parser.add_argument('-rad', '--radio', type=str, help='radio at which client will be connected') + parser.add_argument('-n', '--name', type=str, help='Type Name of AP on which test is performed') + + + + + args = parser.parse_args() + + if (args.name is not None): + AP_name = args.name + + if(args.ssid is not None): + ssid = args.ssid + + dfs = DFS_Test(args.ip, args.user, args.pswd, args.host, args.ssid, args.passwd, args.security, args.radio) + + # check for last timesnap of ap logs + + th = ThreadWithReturnValue(target=dfs.check_last_time_ap(args.ip, args.user, args.pswd)) + th.start() + th.join() + val = th.join() + N = 1 + res = list(islice(reversed(val), 0, N)) + res.reverse() + x_list = res + var_1 = "" + for i in x_list[0][10:20]: + var_1 = var_1 + i + + var_1 = var_1.strip() + print(var_1) + print("timesnap for last log is ", var_1) + + print("creating station on GUI") + t1 = ThreadWithReturnValue( + target=dfs.create_station_on_GUI_1(args.host, args.ssid, args.passwd, args.security, args.radio)) + t1.start() + t1.join() + val_1 = t1.join() + val_1 = val_1.strip() + print("station is at channel", val_1) + + time.sleep(2) + + print("set channel to 52") + t2 = ThreadWithReturnValue(target=dfs.set_channel_in_ap_at_52(args.ip, args.user, args.pswd)) + t2.start() + t2.join() + + print("channel set checking....") + t3 = ThreadWithReturnValue(target=dfs.monitor_station_52(args.host, args.ssid, args.passwd, args.security, args.radio)) + t3.start() + t3.join() + print(t3.join()) + + var_5 = "" + time_1 = "" + channel = "" + cx_time = "" + while True: + if t3.join() == "52": + print("station allocated to 52") + print("now generate radar on 52") + + t4 = threading.Thread(target=dfs.generate_radar_at_ch52()) + t4.start() + t4.join() + + # time.sleep(80) + + print("checking channel assigned...") + th_1 = ThreadWithReturnValue(target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security,args.radio)) + th_1.start() + th_1.join() + print(th_1.join()) + channel = th_1.join() + print("after radar channel is at ", channel) + + if channel == "-1": + print("TEST Fail") + print("AP is at AUTO Channel") + break + else: + print("Test Pass") + + th_2 = ThreadWithReturnValue(target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security,args.radio)) + th_2.start() + th_2.join() + print(th_2.join()) + cx_time = th_2.join() + print("after radar station time is ", cx_time) + break + else: + print("stop") + break + + time.sleep(120) + t9 = ThreadWithReturnValue(target=dfs.check_for_channels(args.ip, args.user, args.pswd)) + t9.start() + t9.join() + var1 = t9.join() + a_list = [] + for i in var1: + a_list.append(i.strip()) + # print("hi", a_list) + + time_11 = "" + var5 = "" + channel_1 = "" + cx_time1 = "" + if any("Channel 100 : 5.5 GHz" in s for s in a_list): + print("set channel to 100") + t10 = threading.Thread(target=dfs.set_channel_in_ap_at_100(args.ip, args.user, args.pswd)) + t10.start() + t10.join() + print("channel set to 100") + + print("channel set checking....") + t31 = ThreadWithReturnValue( + target=dfs.monitor_station_100(args.host, args.ssid, args.passwd, args.security, args.radio)) + t31.start() + t31.join() + print(t31.join()) + + while True: + if t31.join() == "100": + print("station allocated to 100") + print("now generate radar on 100") + + t11 = threading.Thread(target=dfs.generate_radar_at_ch100()) + t11.start() + t11.join() + + # time.sleep(80) + print("checking channel assigned...") + th_1a = ThreadWithReturnValue( + target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security, + args.radio)) + + th_1a.start() + th_1a.join() + print(th_1a.join()) + channel_1 = th_1a.join() + print("after radar channel is at ", channel_1) + + if th_1a.join() == "-1": + print("TEST Fail") + break + else: + print("Test Pass") + th_3 = ThreadWithReturnValue( + target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security, + args.radio)) + th_3.start() + th_3.join() + print(th_3.join()) + cx_time1 = th_3.join() + print("after radar station connection time i ", cx_time1) + break + + else: + print("check for some another channel") + break + + time.sleep(120) + + t19 = ThreadWithReturnValue(target=dfs.check_for_channels(args.ip, args.user, args.pswd)) + t19.start() + t19.join() + var11 = t19.join() + b_list = [] + for i in var11: + b_list.append(i.strip()) + # print("hi", a_list) + + time_12 = "" + var51 = "" + channel_2 = "" + cx_time2 = "" + if any("Channel 120 : 5.6 GHz" in s for s in b_list): + print("set channel to 120") + + t15 = threading.Thread(target=dfs.set_channel_in_ap_at_120(args.ip, args.user, args.pswd)) + t15.start() + t15.join() + print("channel set to 120") + + print("channel set checking....") + t32 = ThreadWithReturnValue( + target=dfs.monitor_station_120(args.host, args.ssid, args.passwd, args.security, args.radio)) + t32.start() + t32.join() + print(t32.join()) + while True: + if t32.join() == "120": + print("station allocated to 120") + print("now generate radar on 120") + + t16 = threading.Thread(target=dfs.generate_radar_at_ch120()) + t16.start() + t16.join() + + # time.sleep(80) + + print("checking channel assigned...") + thr1 = ThreadWithReturnValue( + target=dfs.monitor_untill_channel_assigned(args.host, args.ssid, args.passwd, args.security, + args.radio)) + thr1.start() + thr1.join() + print(thr1.join()) + channel_2 = thr1.join() + print("after radar channel is at ", channel_2) + + if thr1.join() == "-1": + print("TEST Fail") + break + else: + print("Test Pass") + th_4 = ThreadWithReturnValue( + target=dfs.monitor_untill_connection_time(args.host, args.ssid, args.passwd, args.security, + args.radio)) + th_4.start() + th_4.join() + print(th_4.join()) + cx_time2 = th_4.join() + print("after radar station connection time is ", cx_time2) + break + else: + print("stop") + break + + # channel list + ch_list = [] + ch_list.extend((channel, channel_1, channel_2)) + print("after radar switched channel list ", ch_list) + + cha_list = ["52", "100", "120"] + print("test channel list", cha_list) + + time_ass = [] + time_ass.extend((cx_time, cx_time1, cx_time2)) + print("list of connection time", time_ass) + + + """ch_list = ['44', '36', '120'] + for n, i in enumerate(ch_list): + if i == '': + ch_list[n] = '0' + + # print(ch_list) + for i in range(0, len(ch_list)): + ch_list[i] = int(ch_list[i]) + + # print(ch_list) + cha_list = ['52', '100', '120'] + y_pos = np.arange(len(cha_list)) + + # Create bars and choose color + plt.bar(y_pos, ch_list, color=(0.5, 0.1, 0.5, 0.6)) + + # Add title and axis names + plt.title('channel association') + plt.xlabel('Channels') + plt.ylabel('channel assigned') + + # Limits for the Y axis + plt.ylim(0, 140) + + # Create names + plt.xticks(y_pos, cha_list) + + # Show graphic + #plt.show() + plt.savefig("channel.png")""" + + + ############################################################################### + + time_ass = ['23348', '19126', ''] + for n, i in enumerate(time_ass): + if i == '': + time_ass[n] = '0' + + # print(ch_list) + for i in range(0, len(time_ass)): + time_ass[i] = int(time_ass[i]) + + # seconds = microseconds ÷ 1,000,000 + for i in range(0, len(time_ass)): + time_ass[i] = time_ass[i] / 1000 + + cha_list = ['52', '100', '120'] + y_pos = np.arange(len(cha_list)) + + # Create bars and choose color + plt.bar(y_pos, time_ass, color=(0.5, 0.1, 0.5, 0.6)) + + # Add title and axis names + plt.title('connection time') + plt.xlabel('Channels') + plt.ylabel('association time (milliseconds)') + + # Limits for the Y axis + plt.ylim(0, 100) + + # Create names + plt.xticks(y_pos, cha_list) + + # Show graphic + #plt.show() + plt.savefig("/home/lanforge/lanforge-scripts/py-scripts/time.png") + + ch_list = ['44', '36', '120'] + for i in range(0, len(time_ass)): + time_ass[i] = str(time_ass[i]) + + if ch_list[0] == "52" or ch_list[0] == "-1" or ch_list[0] == "" or ch_list[0] == "0": + data = "FAIL" + else: + data = "PASS" + # print(data) + + if ch_list[1] == "100" or ch_list[1] == "-1" or ch_list[1] == "" or ch_list[1] == "0": + data_1 = "FAIL" + else: + data_1 = "PASS" + + if ch_list[2] == "120" or ch_list[2] == "-1" or ch_list[2] == "" or ch_list[2] == "0": + data_2 = "FAIL" + else: + data_2 = "PASS" + + + + + now = datetime.now() + print("Current date and time : ") + date_1 = now.strftime("%Y-%m-%d %H:%M:%S") + + if data == "FAIL": + x = " FAIL " + else: + if data == "PASS": + x = " PASS " + + if data_1 == "FAIL": + x_1 = " FAIL " + else: + if data_1 == "PASS": + x_1 = " PASS " + + if data_2 == "FAIL": + x_2 = " FAIL " + else: + if data_2 == "PASS": + x_2 = " PASS " + + + + html_content = "DFS TEST

Dynamic Frequency Selection

" \ + "

" + date_1 + "



Objective

The DFS Test is designed to test the Performance of the Netgear Access Point.Dynamic frequency selection is a technology that is designed to ensure that wireless devices operating in the unlicensed WLAN 5 GHz bands are able to detect when they may be interfering with military and weather radar systems and automatically switch over to another frequency where they will not cause any disturbance.
Test Setup Information
Device Under Test
AP Name" + AP_name + "
SSID" + ssid + "
Number of Clients1
" \ + "

Graph


Detailed Results
" + x + """" + x_1 + "" + x_2 + "
Client NameChannelSwitched Channelstation association time(milliseconds)Result
sta000052"+ ch_list[0] +""+ time_ass[0] +"
sta0000100"+ ch_list[1] + ""+ time_ass[1] +"
sta0000120"+ ch_list[2] +""+ time_ass[2] +"
" + + file = open("/home/lanforge/lanforge-scripts/py-scripts/result.html", "w") + file.write(html_content) + file.close() + + print("Test Finished") + +if __name__ == '__main__': + main() From b4dc2f87077f006219424decc3d281721020412a Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 26 Jan 2021 20:15:17 -0800 Subject: [PATCH 207/848] realm: adds new_vr_profile() and fixes a debug flag --- py-json/realm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py-json/realm.py b/py-json/realm.py index d97a76f5..0d23cb42 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -2559,6 +2559,8 @@ class VRProfile(LFCliBase): suppress_related_commands_=True): # Create vr + if self.debug: + debug = True if self.vr_name is not None: self.add_vr_data["alias"] = self.vr_name self.local_realm.json_post("add_vr", self.add_vr_data, debug_=debug) From 6b7fb15e94616fb6afa2869b513bea5cf4b64c34 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 28 Jan 2021 06:54:54 -0700 Subject: [PATCH 208/848] lf_cisco_snp.py : updated comments for command error in subprocess call --- py-scripts/lf_cisco_snp.py | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index 1288493f..3e2d99a8 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -63,7 +63,7 @@ class cisco_(): 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 {}" + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}" .format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -88,7 +88,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -110,7 +110,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -133,7 +133,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -157,7 +157,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -182,7 +182,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -202,7 +202,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -227,7 +227,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -247,7 +247,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -274,7 +274,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -301,7 +301,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -326,7 +326,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -352,7 +352,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -376,7 +376,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -401,7 +401,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -427,7 +427,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -453,7 +453,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -478,7 +478,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -498,7 +498,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -524,7 +524,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -544,7 +544,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -569,7 +569,7 @@ class cisco_(): 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 {}". + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) @@ -962,7 +962,7 @@ class L3VariableTime(LFCliBase): pss = ctl_output.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 {}" + logg.info("Command Error, Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}" .format(process_error.returncode, process_error.output)) time.sleep(1) exit(1) From 908e770d317e5ee5193302f326e16b9ae8868767 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 28 Jan 2021 10:31:00 -0700 Subject: [PATCH 209/848] lf_cisco_snp.py:(LCS-50) fix for update wlan, wlanID, wlanSSID --- py-scripts/lf_cisco_snp.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index 3e2d99a8..b0077523 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -143,9 +143,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_wlan --series 9800 def controller_disable_wlan(self): try: - logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} wlan: {} action: {}".format(self.args.cisco_scheme, self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user, - self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_wlan")) + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"--wlan", self.args.cisco_wlan,"disable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -387,13 +387,13 @@ class cisco_(): def controller_create_wlan(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {} wlanSSID {}".format(self.args.cisco_scheme, self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, - self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) + self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID, self.args.cisco_wlanSSID )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, - "--action", "create_wlan","--wlan", self.args.cisco_wlan, "--wlanID", self.args.cisco_wlanID], + "--action", "create_wlan","--wlan", self.args.cisco_wlan, "--wlanID", self.args.cisco_wlanID, "--wlanSSID", self.args.cisco_wlanSSID], capture_output=self.args.cap_ctl_out, check=True) if self.args.cap_ctl_out: @@ -439,12 +439,12 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_wlan --series 9800 def controller_enable_wlan(self): try: - logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} wlan: {} action: {}".format(self.args.cisco_scheme, self.args.cisco_ctlr,self.args.cisco_port,self.args.cisco_prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, - self.args.cisco_band,"enable_wlan")) + self.args.cisco_band,"--wlan", self.args.cisco_wlan,"enable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, - "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--wlan","--wlan", self.args.cisco_wlan, "--action", "enable_wlan"], capture_output=self.args.cap_ctl_out, check=True) @@ -1462,8 +1462,8 @@ Eventual Realm at Cisco # reorder to follow looping - parser.add_argument('-ca','--cisco_all', help='--cisco_all flag present default to all tests',action="store_true") - parser.add_argument('-ct','--cisco_test', help='--cisco_test flag present default to subset tests',action="store_true") + parser.add_argument('-ca' ,'--cisco_all', help='--cisco_all flag present default to all tests',action="store_true") + parser.add_argument('-ct' ,'--cisco_test', help='--cisco_test flag present default to subset tests',action="store_true") parser.add_argument('-cca','--cisco_ap', help='--cisco_ap List of APs to test default: Axel',default="APA453.0E7B.CF9C") parser.add_argument('-ccf','--cisco_band', help='--cisco_band
',default="a b") # cisco wanted 11ax , 11ac, 11n, 11gb @@ -1478,17 +1478,19 @@ Eventual Realm at Cisco default="1 10 20 50 100 200" ) parser.add_argument('-cde','--cisco_data_encryption', help='--cisco_data_encryption \"enable disable\"',default="disable" ) - parser.add_argument('-cs','--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) + parser.add_argument('-cs' ,'--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) parser.add_argument('-ccp','--cisco_prompt', type=str,help="controller prompt default WLC",default="WLC") - parser.add_argument('-cc','--cisco_ctlr', help='--cisco_ctlr default 192.168.100.178',default="192.168.100.178") - parser.add_argument('-cp','--cisco_port', help='--cisco_port ssh default 22',default="22") - parser.add_argument('-cu','--cisco_user', help='--cisco_user ',default="admin") + parser.add_argument('-cc' ,'--cisco_ctlr', help='--cisco_ctlr default 192.168.100.178',default="192.168.100.178") + parser.add_argument('-cp' ,'--cisco_port', help='--cisco_port ssh default 22',default="22") + parser.add_argument('-cu' ,'--cisco_user', help='--cisco_user ',default="admin") parser.add_argument('-cpw','--cisco_passwd', help='--cisco_passwd ',default="Cisco123") - parser.add_argument('-cd','--cisco_dfs', help='--cisco_dfs ',default=False) + parser.add_argument('-cd' ,'--cisco_dfs', help='--cisco_dfs ',default=False) parser.add_argument('-ccs','--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"]) - parser.add_argument('-cw','--cisco_wlan', help='--cisco_wlan default: NA, NA means no change',default="NA") - parser.add_argument('-cwi','--cisco_wlanID', help='--cisco_wlanID default: NA , NA means not change',default="NA") + parser.add_argument('-cw' ,'--cisco_wlan', help='--cisco_wlan ',required=True) + parser.add_argument('-cwi','--cisco_wlanID', help='--cisco_wlanID ',required=True) + parser.add_argument('-cws' ,'--cisco_wlanSSID', help='--cisco_wlanSSID ',required=True) + parser.add_argument('-ctp','--cisco_tx_power', help='--cisco_tx_power <1 | 2 | 3 | 4 | 5 | 6 | 7 | 8> 1 is highest power default NA NA means no change',default="NA" ,choices=["1","2","3","4","5","6","7","8","NA"]) parser.add_argument('-cco','--cap_ctl_out', help='--cap_ctl_out , switch the cisco controller output will be captured', action='store_true') @@ -1507,7 +1509,6 @@ Eventual Realm at Cisco parser.add_argument('-o','--csv_outfile', help="--csv_outfile ", default='snp') parser.add_argument("-l", "--log", action='store_true', help="create logfile for messages, default stdout") parser.add_argument('-pi','--polling_interval', help="--polling_interval ", default='10s') - #parser.add_argument('-c','--csv_output', help="Generate csv output", default=False) parser.add_argument('-c','--csv_output', help="Generate csv output", default=True) #to do add wifimode From e39d613b79ec155961b15b52c0506f71c5343fec Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 28 Jan 2021 10:35:47 -0700 Subject: [PATCH 210/848] lf_cisco_snp.py:(LCS-50) update disable_wlan command to include wlan --- py-scripts/lf_cisco_snp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index b0077523..da5c8d08 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -149,7 +149,7 @@ class cisco_(): ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, - "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_wlan"], + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band,"--wlan", self.args.cisco_wlan, "--action", "disable_wlan"], capture_output=self.args.cap_ctl_out, check=True) if self.args.cap_ctl_out: @@ -444,7 +444,7 @@ class cisco_(): self.args.cisco_band,"--wlan", self.args.cisco_wlan,"enable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.cisco_prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, - "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--wlan","--wlan", self.args.cisco_wlan, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--wlan", self.args.cisco_wlan, "--action", "enable_wlan"], capture_output=self.args.cap_ctl_out, check=True) From b7b9e301dd37807909de348d09c87def26fb5493 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 28 Jan 2021 10:41:35 -0700 Subject: [PATCH 211/848] lf_cisco_snp.py:(LCS-50) update default AP --- py-scripts/lf_cisco_snp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index da5c8d08..62b934a4 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -1762,7 +1762,8 @@ Eventual Realm at Cisco } if args.cisco_all: - cisco_aps = "APA453.0E7B.CF9C".split() +# cisco_aps = "APA453.0E7B.CF9C".split() + cisco_aps = "vanc-e".split() # cisco_bands = "a b".split() cisco_bands = "a ".split() # cisco_wifimodes = "an anAX anAC abgn bg".split() From e9e92ae76b84fcf0dbde25b83c7cce7ef35e10f7 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 28 Jan 2021 11:31:35 -0800 Subject: [PATCH 212/848] arg additions --- py-json/realm.py | 20 +------------------- py-scripts/test_ipv4_variable_time.py | 8 ++++++-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index e3f8fff9..621d1e5f 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1168,24 +1168,6 @@ class L3CXProfile(BaseProfile): output_format = report_file.split('.')[-1] #retrieve compared report if specified - turn into dataframe if compared_report is not None: - compared_format = compared_report.split('.')[-1] - #initial dataframe - previous_data_df = pd.DataFrame() - if compared_format == 'hdf': - #df.to_hdf(report_file, 'table', append=True) - continue - if compared_format == 'parquet': - #df.to_parquet(report_file, engine='pyarrow') - continue - if compared_format == 'png': - #fig = df.plot().get_figure() - #fig.savefig(report_file) - continue - if compared_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': - continue - if compared_format == 'df': - #return df - continue supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for format in supported_formats: if compared_format.lower() == format: @@ -1237,6 +1219,7 @@ class L3CXProfile(BaseProfile): self._fail("FAIL: Not all stations increased traffic") self.exit_fail() old_cx_rx_values = new_cx_rx_values + #write csv file here - open, write, and close file time.sleep(monitor_interval) print(value_map) @@ -1266,7 +1249,6 @@ class L3CXProfile(BaseProfile): df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] #compare previous data to current data - try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) except: diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 7edc3994..8e205f65 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -193,9 +193,10 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Columns wished to be monitor', default=['name','tx bytes', 'rx bytes','dropped']) + optional_args.add_argument('--col_names', help='Columns wished to be monitor',default=['name','tx bytes', 'rx bytes','dropped']) optional_args.add_argument('--compared_report',help='report path and file which is wished to be compared with new report', default=None) args = parser.parse_args() + #['name','tx bytes', 'rx bytes','dropped'] num_sta = 2 if (args.num_stations is not None) and (int(args.num_stations) > 0): @@ -223,7 +224,9 @@ python3 ./test_ipv4_variable_time.py output=str(args.report_file).split('.')[-1] else: output=args.output_format + #Retrieve last data file + compared_rept=None if args.compared_report: #check if last report format is same as current rpt format last_report_format = args.compared_report.split('.')[-1] @@ -267,7 +270,8 @@ python3 ./test_ipv4_variable_time.py col_names=None else: col_names = args.col_names - print(col_names) + if args.debug: + print(col_names) ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), From 98f7250aad270d70cd7994c5a9c57fbd8ecf8ce4 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 28 Jan 2021 13:20:22 -0800 Subject: [PATCH 213/848] realm fix --- py-json/realm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-json/realm.py b/py-json/realm.py index 0d23cb42..206c06f3 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1099,6 +1099,8 @@ class L3CXProfile(BaseProfile): self.created_endp = {} self.name_prefix = name_prefix_ self.number_template = number_template_ + self.lfclient_port = lfclient_port + self.lfclient_host = lfclient_host def get_cx_names(self): return self.created_cx.keys() @@ -1231,7 +1233,6 @@ class L3CXProfile(BaseProfile): for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) # step 4 save and close - header_row = col_names header_row.insert(0, 'Timestamp') # print(header_row) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': From 4aec4c0ec4c3d68dd22efeb3e76e9be0a805b50a Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 28 Jan 2021 13:33:01 -0800 Subject: [PATCH 214/848] arg changes --- py-json/realm.py | 6 +++--- py-scripts/test_ipv4_variable_time.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 621d1e5f..a2596239 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1158,8 +1158,6 @@ class L3CXProfile(BaseProfile): raise ValueError("Monitor needs a list of Layer 3 connections") if (monitor_interval is None) or (monitor_interval < 1): raise ValueError("L3CXProfile::monitor wants monitor_interval >= 1 second") - #if col_names is None: - #raise ValueError("L3CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: if output_format.lower() != 'excel': @@ -1221,7 +1219,9 @@ class L3CXProfile(BaseProfile): old_cx_rx_values = new_cx_rx_values #write csv file here - open, write, and close file time.sleep(monitor_interval) - print(value_map) + if self.debug: + print("Printing value map...") + print(value_map) #organize data full_test_data_list = [] diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 8e205f65..21830ccd 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -164,12 +164,13 @@ python3 ./test_ipv4_variable_time.py --ssid netgear --password admin123 --test_duration 2m (default) - --a_min 1000 + --a_min 3000 --b_min 1000 --ap "00:0e:8e:78:e1:76" --output_format csv --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other files) - --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) + --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) - UNDER CONSTRUCTION + --col_names ['name','tx bytes', 'rx bytes','dropped'] --debug ''') From a68d5eda246f46a08438bdf75377053181918cae Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 28 Jan 2021 14:33:24 -0700 Subject: [PATCH 215/848] cisco_wifi_ctl.py : update comments --- cisco_wifi_ctl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 2740922e..8879e3d6 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -14,8 +14,10 @@ $ pip3 install pexpect-serial ./cisco_wifi_ctl.py -d 172.19.27.95 -o 2013 -l stdout -a AxelMain -u cisco -p Cisco123 -s telnet # For LANforge lab system. -./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action summary --prompt "\(Cisco Controller\)" -./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 -u admin -p Cisco123 --action cmd --value "show ap config general APA453.0E7B.CF9C" +./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 --user admin --passwd Cisco123 --ap APA453.0E7B.CF9C --series 3504 --action cmd --value "show ap config general APA453.0E7B.CF9C" --prompt "(Cisco Controller)" +./cisco_wifi_ctl.py --scheme ssh -d 192.168.100.112 --user admin --passwd Cisco123 --ap APA453.0E7B.CF9C --series 3504 --action summary --prompt "(Cisco Controller)" + + telnet 172.19.36.168(Pwd:), go to the privileged mode and execute the command “clear line 43”. From 4fda8d0f9bc0333e062efec194417cdc749b8f81 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 28 Jan 2021 14:09:46 -0800 Subject: [PATCH 216/848] var_time col name arg parse fixed --- py-scripts/test_ipv4_variable_time.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 21830ccd..57345c2b 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -267,11 +267,14 @@ python3 ./test_ipv4_variable_time.py layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') - if type(args.col_names) is not list: - col_names=None - else: - col_names = args.col_names + if args.col_names is not None: + print(args.col_names) + if type(args.col_names) is not list: + col_names=list(args.col_names.split(",")) + else: + col_names = args.col_names if args.debug: + print("Column names are...") print(col_names) ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, From d4a4c3b494fe04b8d8573c459ace4abcab234719 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 28 Jan 2021 14:16:11 -0800 Subject: [PATCH 217/848] fixed col_names default to be all columns --- py-scripts/test_ipv4_variable_time.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 57345c2b..4349e369 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -170,7 +170,7 @@ python3 ./test_ipv4_variable_time.py --output_format csv --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other files) --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) - UNDER CONSTRUCTION - --col_names ['name','tx bytes', 'rx bytes','dropped'] + --col_names 'name','tx bytes', 'rx bytes','dropped' --debug ''') @@ -194,7 +194,7 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") - optional_args.add_argument('--col_names', help='Columns wished to be monitor',default=['name','tx bytes', 'rx bytes','dropped']) + optional_args.add_argument('--col_names', help='Columns wished to be monitor',default=None) optional_args.add_argument('--compared_report',help='report path and file which is wished to be compared with new report', default=None) args = parser.parse_args() #['name','tx bytes', 'rx bytes','dropped'] @@ -273,6 +273,8 @@ python3 ./test_ipv4_variable_time.py col_names=list(args.col_names.split(",")) else: col_names = args.col_names + else: + col_names=None if args.debug: print("Column names are...") print(col_names) From 13d5ec0770adff053201e8cd706a0763fddd4f97 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 28 Jan 2021 18:02:03 -0800 Subject: [PATCH 218/848] fix ipv4_l4 --- py-scripts/test_ipv4_l4.py | 48 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/py-scripts/test_ipv4_l4.py b/py-scripts/test_ipv4_l4.py index 7144770e..236dde4b 100755 --- a/py-scripts/test_ipv4_l4.py +++ b/py-scripts/test_ipv4_l4.py @@ -30,12 +30,12 @@ import datetime class IPV4L4(LFCliBase): def __init__(self, host, port, ssid, security, password, url, - station_list, - number_template="00000", radio="wiphy0", - test_duration="5m", upstream_port="eth1", - _debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): + station_list, + number_template="00000", radio="wiphy0", + test_duration="5m", upstream_port="eth1", + _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 @@ -107,8 +107,7 @@ class IPV4L4(LFCliBase): suppress_related_commands_=None) def start(self, print_pass=False, print_fail=False): - temp_stas = self.sta_list.copy() - # temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2]) + temp_stas = self.station_profile.station_names.copy() self.station_profile.admin_up() if self.local_realm.wait_for_ip(temp_stas): self._pass("All stations got IPs", print_pass) @@ -189,9 +188,8 @@ def main(): ''') parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m") - parser.add_argument('--url', help='--url specifies upload/download, address, and dest', default="dl http://10.40.0.1 /dev/null") - - + parser.add_argument('--url', help='--url specifies upload/download, address, and dest', + default="dl http://10.40.0.1 /dev/null") args = parser.parse_args() num_sta = 2 @@ -199,26 +197,32 @@ def main(): num_stations_converted = int(args.num_stations) num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_= num_sta-1, padding_number_=10000, radio=args.radio) + station_list = LFUtils.portNameSeries(prefix_="sta", + start_id_=0, + end_id_=num_sta - 1, + padding_number_=10000, + radio=args.radio) ip_test = IPV4L4(host=args.mgr, port=args.mgr_port, - ssid=args.ssid, - radio=args.radio, - password=args.passwd, - security=args.security, - station_list=station_list, - url=args.url, - test_duration=args.test_duration, - upstream_port=args.upstream_port, - _debug_on=args.debug) + ssid=args.ssid, + radio=args.radio, + password=args.passwd, + security=args.security, + station_list=station_list, + url=args.url, + test_duration=args.test_duration, + upstream_port=args.upstream_port, + _debug_on=args.debug) ip_test.cleanup(station_list) ip_test.build() + print('Stations built') if not ip_test.passes(): print(ip_test.get_fail_message()) ip_test.exit_fail() + print('Starting Stations') ip_test.start(False, False) + print('Stopping Stations') ip_test.stop() if not ip_test.passes(): print(ip_test.get_fail_message()) From baa792545b6b72c7c3ef47a3bbf0d94e4c59707c Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Thu, 28 Jan 2021 18:18:24 -0800 Subject: [PATCH 219/848] html test output --- py-scripts/html_test_output.sh | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh index 52978d83..fa2222e9 100755 --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -91,9 +91,9 @@ function run_test() { grep -i fail "${TEST_DIR}/${i}.txt" && retval=1 chmod 664 "${TEST_DIR}/${i}.txt" if (( $retval == 0 )); then - results+=("${CURR_TEST_NAME}${i}Success") + results+=("${CURR_TEST_NAME}${i}SuccessSTDOUTSTDERR") else - results+=("${CURR_TEST_NAME}${i}Failure") + results+=("${CURR_TEST_NAME}${i}FailureSTDOUTSTDERR") fi fi done @@ -133,16 +133,6 @@ function html_generator() { .scriptdetails { font-size: 10px; } - -

Test All Scripts Results

@@ -157,10 +147,6 @@ function html_generator() { echo "$header" >> $fname echo "${results[@]}" >> $fname echo "" >> $fname - for item in "${testCommands[@]}"; do - item2=$(echo $item | sed 's/^..//') - echo "
" >> $fname - done; echo "$tail" >> $fname } From 7b8f4bd15d337b80e92fd8f799200f9ec853eca9 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 29 Jan 2021 14:02:44 -0800 Subject: [PATCH 220/848] py-json: updates __init__.py to import most useful libraries --- py-json/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py-json/__init__.py b/py-json/__init__.py index 09430889..adfa88db 100644 --- a/py-json/__init__.py +++ b/py-json/__init__.py @@ -1,2 +1,5 @@ -from .LFRequest import LFRequest +from .LANforge import LFUtils +from .LANforge import LFRequest +from .LANforge import lfcli_base +from .LANforge.lfcli_base import LFCliBase From e14e17a06ac9646c956845dc047806c4ba1598cc Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 29 Jan 2021 14:06:38 -0800 Subject: [PATCH 221/848] realm.py: correcting several places where VRProfile was using bad URLs... - BaseProfile no longer inherits from LFCliBase - VRProfile now based on BaseProfile - whitespace, organized parameters into columns - added parameter names - added parameter defaults More work on this class is necessary. Next commits will be pulling RDD creation into an RDDProfile class --- py-json/realm.py | 111 ++++++++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 40 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 206c06f3..706cbc5c 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -55,7 +55,7 @@ class Realm(LFCliBase): halt_on_error_=False, _exit_on_error=False, _exit_on_fail=False, - _local_realm=None, + # _local_realm=None, _proxy_str=None, _capture_signal_list=[]): super().__init__(_lfjson_host=lfclient_host, @@ -802,7 +802,9 @@ class Realm(LFCliBase): return vap_prof def new_vr_profile(self): - vap_prof = VRProfile(lfclient_host=self.lfclient_host, lfclient_port=self.lfclient_port, local_realm=self, + vap_prof = VRProfile(lfclient_host=self.lfclient_host, + lfclient_port=self.lfclient_port, + local_realm=self, debug_=self.debug) return vap_prof @@ -824,24 +826,23 @@ class Realm(LFCliBase): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) def new_vr_profile(self): - profile = VRProfile(parent_realm=self, - debug=self.debug, - halt_on_error=self.halt_on_error, - exit_on_error=self.exit_on_error) + profile = VRProfile(local_realm=self, + debug=self.debug) return profile -class BaseProfile(LFCliBase): - def __init__(self, local_realm): +class BaseProfile: + def __init__(self, local_realm, debug=False): self.parent_realm = local_realm self.halt_on_error = False self.exit_on_error = False + self.debug = debug or local_realm.debug def json_get(self, target): return self.parent_realm.json_get(target) - def json_post(self, req_url, data, debug_=False, suppress_related_commands_=None): - return self.parent_realm.json_post(req_url, - data, + def json_post(self, req_url=None, data=None, debug_=False, suppress_related_commands_=None): + return self.parent_realm.json_post(_req_url=req_url, + _data=data, suppress_related_commands_=suppress_related_commands_, debug_=debug_) @@ -2449,17 +2450,17 @@ class VAPProfile(LFCliBase): LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_ports) -class VRProfile(LFCliBase): - def __init__(self, lfclient_host, lfclient_port, local_realm, ssid="NA", ssid_pass="NA", mode=0, debug_=False): - super().__init__(_lfjson_host=lfclient_host, _lfjson_port=lfclient_port, _debug=debug_) - # self.debug = debug_ - # self.lfclient_url = lfclient_url - self.ssid = ssid - self.ssid_pass = ssid_pass - self.mode = mode - self.local_realm = local_realm - self.vr_name = None - +class VRProfile(BaseProfile): + """ + Virtual Router profile + """ + def __init__(self, + local_realm, + vr_id=0, + debug=False): + super().__init__(local_realm=local_realm, + debug=debug) + self.vr_name = vr_id self.created_rdds = [] self.created_vrcxs = [] @@ -2499,7 +2500,13 @@ class VRProfile(LFCliBase): "gateway": None } - def create_rdd(self, resource, ip_addr, netmask, gateway, suppress_related_commands_=True, debug_=False): + def create_rdd(self, + resource=1, + ip_addr=None, + netmask=None, + gateway=None, + suppress_related_commands_=True, + debug_=False): rdd_data = { "shelf": 1, "resource": resource, @@ -2507,8 +2514,10 @@ class VRProfile(LFCliBase): "peer_ifname": "rdd1" } # print("creating rdd0") - self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, - debug_=debug_) + self.json_post("/cli-json/add_rdd", + rdd_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) rdd_data = { "shelf": 1, @@ -2517,27 +2526,40 @@ class VRProfile(LFCliBase): "peer_ifname": "rdd0" } # print("creating rdd1") - self.local_realm.json_post("add_rdd", rdd_data, suppress_related_commands_=suppress_related_commands_, - debug_=debug_) + self.json_post("/cli-json/add_rdd", + rdd_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) self.set_port_data["port"] = "rdd0" self.set_port_data["ip_addr"] = gateway self.set_port_data["netmask"] = netmask self.set_port_data["gateway"] = gateway - self.local_realm.json_post("set_port", self.set_port_data, - suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.json_post("/cli-json/set_port", + self.set_port_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) self.set_port_data["port"] = "rdd1" self.set_port_data["ip_addr"] = ip_addr self.set_port_data["netmask"] = netmask self.set_port_data["gateway"] = gateway - self.local_realm.json_post("set_port", self.set_port_data, - suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.json_post("/cli-json/set_port", + self.set_port_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) self.created_rdds.append("rdd0") self.created_rdds.append("rdd1") - def create_vrcx(self, resource, local_dev, remote_dev, subnets, nexthop, flags, suppress_related_commands_=True, + def create_vrcx(self, + resource=1, + local_dev=None, + remote_dev=None, + subnets=None, + nexthop=None, + flags=0, + suppress_related_commands_=True, debug_=False): if self.vr_name is not None: self.vrcx_data["resource"] = resource @@ -2547,24 +2569,33 @@ class VRProfile(LFCliBase): self.vrcx_data["subnets"] = subnets self.vrcx_data["nexthop"] = nexthop self.vrcx_data["flags"] = flags - self.local_realm.json_post("add_vrcx", self.vrcx_data, - suppress_related_commands_=suppress_related_commands_, debug_=debug_) + self.json_post("/cli-json/add_vrcx", + self.vrcx_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - def create(self, resource, upstream_port="eth1", debug=False, - upstream_subnets="20.20.20.0/24", upstream_nexthop="20.20.20.1", - local_subnets="10.40.0.0/24", local_nexthop="10.40.3.198", - rdd_ip="20.20.20.20", rdd_gateway="20.20.20.1", rdd_netmask="255.255.255.0", + def create(self, + resource=1, + vr_id=0, + upstream_port="eth1", + upstream_subnets="20.20.20.0/24", + upstream_nexthop="20.20.20.1", + local_subnets="10.40.0.0/24", + local_nexthop="10.40.3.198", + rdd_ip="20.20.20.20", + rdd_gateway="20.20.20.1", + rdd_netmask="255.255.255.0", + debug=False, suppress_related_commands_=True): - # Create vr if self.debug: debug = True if self.vr_name is not None: self.add_vr_data["alias"] = self.vr_name - self.local_realm.json_post("add_vr", self.add_vr_data, debug_=debug) + self.json_post("/cli-json/add_vr", self.add_vr_data, debug_=debug) else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) # Create 1 rdd pair From 8a513833eb4e4b4859182d1875cf5b61f05d80cb Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 29 Jan 2021 15:01:27 -0800 Subject: [PATCH 222/848] create_vr.py WIP, to be used for creating virtual routers --- py-scripts/create_vr.py | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 py-scripts/create_vr.py diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py new file mode 100755 index 00000000..90afd1bd --- /dev/null +++ b/py-scripts/create_vr.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 + +""" + Script for creating a variable number of bridges. +""" + +import sys +import os +import argparse + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'py-json' not in sys.path: + sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) +import LANforge +from LANforge.lfcli_base import LFCliBase +from LANforge import LFUtils +from realm import Realm +import time +import pprint + +class CreateVR(Realm): + def __init__(self, + lfclient_host="localhost", + lfclient_port=8080, + debug=False, + vr_id=0, + resource=1, + ports_list=[], + services_list=[], + _halt_on_error=False, + _exit_on_error=False, + _exit_on_fail=False, + _proxy_str=None, + _capture_signal_list=[]): + super().__init__(lfclient_host=lfclient_host, + lfclient_port=lfclient_port, + debug_=debug, + halt_on_error_=_halt_on_error, + _exit_on_error=_exit_on_error, + _exit_on_fail=_exit_on_fail, + _proxy_str=_proxy_str, + _capture_signal_list=_capture_signal_list) + self.vr_id = vr_id + self.resource = resource + self.services_list = services_list + self.vr_profile = self.new_vr_profile() + self.vr_profile.resource=self.resource + + + def build(self): + self.vr_profile.create(resource=self.resource, + vr_id=self.vr_id, + upstream_port="up0", + upstream_subnets="10.0.0.0/24", + upstream_nexthop="10.0.0.1", + local_nexthop="10.1.0.1", + local_subnets="10.1.0.0/24", + debug=self.debug) + + +def main(): + parser = LFCliBase.create_bare_argparse( + prog=__file__, + description="""\ +%s +-------------------- +Command example: +%s --vr_id 0 --resource 2 --ports br0,rdd0a --services br0=dhcp,nat + + --debug +""") + required = parser.add_argument_group('required arguments') + required.add_argument('--vr_id', help='ID of virtual router', default=0, required=False) + + optional = parser.add_argument_group('optional arguments') + optional.add_argument('--resource', help='Resource number to create virtual router on', default=1, required=False) + optional.add_argument('--ports', help='Comma separated list of ports to add to virtual router', default=None, required=False) + optional.add_argument('--services', help='Add router services to a port, "br0=nat,dhcp"', default=None, required=False) + + args = parser.parse_args() + + + create_vr = CreateVR(lfclient_host=args.mgr, + lfclient_port=args.mgr_port, + vr_id=args.vr_id, + resource=1, + ports_list=args.ports, + services_list=args.services, + debug=args.debug, + _halt_on_error=True, + _exit_on_error=True, + _exit_on_fail=True) + + create_vr.build() + +if __name__ == "__main__": + main() + +# \ No newline at end of file From 86ddd71e10870a425b4b4f97c3b3d7c98dc7c8da Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 29 Jan 2021 16:02:11 -0800 Subject: [PATCH 223/848] leftover merge --- py-json/realm.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f418b42c..a2495d84 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -2086,10 +2086,6 @@ class WifiMonitor: baseurl=self.lfclient_url, debug=self.debug) -<<<<<<< HEAD - -======= ->>>>>>> dipti-branch def admin_up(self): up_request = LFUtils.port_up_request(resource_id=self.resource, port_name=self.monitor_name) self.local_realm.json_post("/cli-json/set_port", up_request) From 916c3a9bcbfc98abd41adc2d7788c377a87a4818 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 29 Jan 2021 16:03:23 -0800 Subject: [PATCH 224/848] leftover merge pt 2 --- py-json/realm.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a2495d84..fe934818 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -3702,10 +3702,6 @@ class StationProfile: time.sleep(delay) # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) -<<<<<<< HEAD - -======= ->>>>>>> dipti-branch # Checks for errors in initialization values and creates specified number of stations using init parameters def create(self, radio, From a81aaa85577de21a1350605b76df50775dad0d47 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Fri, 29 Jan 2021 16:49:02 -0800 Subject: [PATCH 225/848] cleanup html_test_output --- py-scripts/html_test_output.sh | 43 +--------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/py-scripts/html_test_output.sh b/py-scripts/html_test_output.sh index 0e81c7cf..77eeb6b2 100755 --- a/py-scripts/html_test_output.sh +++ b/py-scripts/html_test_output.sh @@ -80,7 +80,6 @@ function run_test() { if (( $CURR_TEST_NUM > $STOP_NUM )) || (( $STOP_NUM == $CURR_TEST_NUM )) && (( $STOP_NUM != 0 )); then exit 1 fi -<<<<<<< HEAD echo "" echo "Test $CURR_TEST_NUM: $CURR_TEST_NAME" @@ -94,20 +93,8 @@ function run_test() { if (( $retval == 0 )); then results+=("${CURR_TEST_NAME}${i}Success
STDOUTSTDERR") else -<<<<<<< HEAD results+=("${CURR_TEST_NAME}${i}Failure") -======= - if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then - echo_print - echo "$i" - if $i; then - results+=("${CURR_TEST_NAME}Success") - else - results+=("${CURR_TEST_NAME}Failure") ->>>>>>> dipti-branch -======= - results+=("${CURR_TEST_NAME}${i}FailureSTDOUTSTDERR") ->>>>>>> 8a513833eb4e4b4859182d1875cf5b61f05d80cb + fi fi done @@ -124,7 +111,6 @@ function check_args() { function html_generator() { NOW=$(date +"%Y-%m-%d-%T") header=" -<<<<<<< HEAD Test All Scripts Results $NOW - - -

Candela Technologies

- - " - tail="
- - " - fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" - echo $fname - echo $header"${results[@]}"$tail >> $fname -} -#true >~/test_all_output_file.txt -check_args $1 $2 -run_test ->>>>>>> dipti-branch html_generator #test generic and fileio are for macvlans From ae9e2f1445100a37078d635d786cdc58601a372c Mon Sep 17 00:00:00 2001 From: Dipti Date: Sat, 30 Jan 2021 00:55:38 -0800 Subject: [PATCH 226/848] help option for ipv4_var_time until further GUI-JSON implementation is done --- py-json/realm.py | 28 +++++----- py-scripts/test_ipv4_variable_time.py | 73 +++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 19 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index fe934818..18fb37f1 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1153,7 +1153,8 @@ class L3CXProfile(BaseProfile): output_format=None, script_name=None, arguments=None, - compared_report=None): + compared_report=None, + debug=False): try: duration_sec = self.parse_time(duration_sec).seconds except: @@ -1173,16 +1174,16 @@ class L3CXProfile(BaseProfile): raise ValueError('Filename %s does not match output format %s' % (report_file, output_format)) else: output_format = report_file.split('.')[-1] - #retrieve compared report if specified - turn into dataframe + #retrieve compared report if specified - turn into dataframe -- under construction if compared_report is not None: supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for format in supported_formats: - if compared_format.lower() == format: - # exec('df.to_' + x + '("' + report_file + '",index=False' + ')') - previous_data_df= read_csv() + if compared_report.lower() == format: + #exec('df.to_' + x + '("' + report_file + '",index=False' + ')') + #previous_data_df= read_csv() + pass - - # Step 1, column names + #Step 1, column names fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) @@ -1208,13 +1209,13 @@ class L3CXProfile(BaseProfile): print(response) raise ValueError("no endpoint?") if monitor: - if self.debug: + if debug: print(response) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response new_cx_rx_values = self.__get_rx_values() - if self.debug: + if debug: print(old_cx_rx_values, new_cx_rx_values) print("\n-----------------------------------") print(t) @@ -1223,12 +1224,12 @@ class L3CXProfile(BaseProfile): if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): passes += 1 else: - self._fail("FAIL: Not all stations increased traffic") + self.fail("FAIL: Not all stations increased traffic") self.exit_fail() old_cx_rx_values = new_cx_rx_values #write csv file here - open, write, and close file time.sleep(monitor_interval) - if self.debug: + if debug: print("Printing value map...") print(value_map) @@ -1238,13 +1239,10 @@ class L3CXProfile(BaseProfile): #reduce the endpoint data to single dictionary of dictionaries for datum in data["endpoint"]: for endpoint_data in datum.values(): - if self.debug: + if debug: print(endpoint_data) endpoint_data["Timestamp"] = test_timestamp full_test_data_list.append(endpoint_data) - if self.debug: - print("Printing full data list...") - print(full_test_data_list) header_row.append("Timestamp") diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 42085230..caea769d 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -168,10 +168,74 @@ python3 ./test_ipv4_variable_time.py --b_min 1000 --ap "00:0e:8e:78:e1:76" --output_format csv - --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other files) - --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) - UNDER CONSTRUCTION - --col_names 'name','tx bytes', 'rx bytes','dropped' + --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other files) + --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) - UNDER CONSTRUCTION + --col_names 'name', 'tx bytes', 'rx bytes', 'dropped' (names of according json columns, please read below to understand what to put here according to what you would like to track) --debug +=============================================================================== + ** FURTHER INFORMATION ** + Using the col_names flag: + + Currently the output function does not support inputting the columns in col_names the way they are displayed in the GUI. That is under construction. To output + certain columns in the GUI in your final report, please match the according GUI column display to it's counterpart to have the columns correctly displayed in + your report. + + GUI Column Col_names argument (to print in report) + + Name | + EID | 'eid' + Run | 'run' + Mng | 'mng' + Script | 'script' + Tx Rate | 'tx rate' + Tx Rate (1 min) | 'tx rate (1 min)' + Tx Rate (last) | 'tx rate (last)' + Tx Rate LL | 'tx rate ll' + Rx Rate | 'rx rate' + Rx Rate (1 min) | 'rx rate (1 min)' + Rx Rate (last) | 'rx rate (last)' + Rx Rate LL | 'rx rate ll' + Rx Drop % | 'rx drop %' + Tx PDUs | 'tx pdus' + Tx Pkts LL | 'tx pkts ll' + PDU/s TX | 'pdu/s tx' + Pps TX LL | 'pps tx ll' + Rx PDUs | 'rx pdus' + Rx Pkts LL | 'pps rx ll' + PDU/s RX | 'pdu/s tx' + Pps RX LL | 'pps rx ll' + Delay | 'delay' + Dropped | 'dropped' + Jitter | 'jitter' + Tx Bytes | 'tx bytes' + Rx Bytes | 'rx bytes' + Replays | 'replays' + TCP Rtx | 'tcp rtx' + Dup Pkts | 'dup pkts' + Rx Dup % | 'rx dup %' + OOO Pkts | 'ooo pkts' + Rx OOO % | 'rx ooo %' + RX Wrong Dev | 'rx wrong dev' + CRC Fail | 'crc fail' + RX BER | 'rx ber' + CX Active | 'cx active' + CX Estab/s | 'cx estab/s' + 1st RX | '1st rx' + CX TO | 'cx to' + Pattern | 'pattern' + Min PDU | 'min pdu' + Max PDU | 'max pdu' + Min Rate | 'min rate' + Max Rate | 'max rate' + Send Buf | 'send buf' + Rcv Buf | 'rcv buf' + CWND | 'cwnd' + TCP MSS | 'tcp mss' + Bursty | 'bursty' + A/B | 'a/b' + Elapsed | 'elapsed' + Destination Addr| 'destination addr' + Source Addr | 'source addr' ''') required_args=None @@ -289,7 +353,8 @@ python3 ./test_ipv4_variable_time.py output_format=output, compared_report=compared_rept, script_name='test_ipv4_variable_time', - arguments=args) + arguments=args, + debug=args.debug) ip_var_test.stop() if not ip_var_test.passes(): From a28363cef2f0ad2781966d5110501940be021678 Mon Sep 17 00:00:00 2001 From: Dipti Date: Sat, 30 Jan 2021 01:09:37 -0800 Subject: [PATCH 227/848] small help fixes --- py-scripts/test_ipv4_variable_time.py | 120 +++++++++++++------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index caea769d..51d39c2a 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -145,7 +145,7 @@ python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 --num_stations 32 - --security {open|wep|wpa|wpa2|wpa3} \\ + --security {open|wep|wpa|wpa2|wpa3} --mode 1 {"auto" : "0", "a" : "1", @@ -168,74 +168,74 @@ python3 ./test_ipv4_variable_time.py --b_min 1000 --ap "00:0e:8e:78:e1:76" --output_format csv - --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other files) - --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other files) - UNDER CONSTRUCTION - --col_names 'name', 'tx bytes', 'rx bytes', 'dropped' (names of according json columns, please read below to understand what to put here according to what you would like to track) + --report_file ~/Documents/results.csv (Example of csv file output - please use another extension for other file formats) + --compared_report ~/Documents/results_prev.csv (Example of csv file retrieval - please use another extension for other file formats) - UNDER CONSTRUCTION + --col_names 'name', 'tx bytes', 'rx bytes', 'dropped' (column names from the GUI to print on report - please read below to know what to put here according to preferences) --debug =============================================================================== ** FURTHER INFORMATION ** Using the col_names flag: - Currently the output function does not support inputting the columns in col_names the way they are displayed in the GUI. That is under construction. To output + Currently the output function does not support inputting the columns in col_names the way they are displayed in the GUI. This quirk is under construction. To output certain columns in the GUI in your final report, please match the according GUI column display to it's counterpart to have the columns correctly displayed in your report. - GUI Column Col_names argument (to print in report) + GUI Column Display Col_names argument to type in (to print in report) - Name | - EID | 'eid' - Run | 'run' - Mng | 'mng' - Script | 'script' - Tx Rate | 'tx rate' - Tx Rate (1 min) | 'tx rate (1 min)' - Tx Rate (last) | 'tx rate (last)' - Tx Rate LL | 'tx rate ll' - Rx Rate | 'rx rate' - Rx Rate (1 min) | 'rx rate (1 min)' - Rx Rate (last) | 'rx rate (last)' - Rx Rate LL | 'rx rate ll' - Rx Drop % | 'rx drop %' - Tx PDUs | 'tx pdus' - Tx Pkts LL | 'tx pkts ll' - PDU/s TX | 'pdu/s tx' - Pps TX LL | 'pps tx ll' - Rx PDUs | 'rx pdus' - Rx Pkts LL | 'pps rx ll' - PDU/s RX | 'pdu/s tx' - Pps RX LL | 'pps rx ll' - Delay | 'delay' - Dropped | 'dropped' - Jitter | 'jitter' - Tx Bytes | 'tx bytes' - Rx Bytes | 'rx bytes' - Replays | 'replays' - TCP Rtx | 'tcp rtx' - Dup Pkts | 'dup pkts' - Rx Dup % | 'rx dup %' - OOO Pkts | 'ooo pkts' - Rx OOO % | 'rx ooo %' - RX Wrong Dev | 'rx wrong dev' - CRC Fail | 'crc fail' - RX BER | 'rx ber' - CX Active | 'cx active' - CX Estab/s | 'cx estab/s' - 1st RX | '1st rx' - CX TO | 'cx to' - Pattern | 'pattern' - Min PDU | 'min pdu' - Max PDU | 'max pdu' - Min Rate | 'min rate' - Max Rate | 'max rate' - Send Buf | 'send buf' - Rcv Buf | 'rcv buf' - CWND | 'cwnd' - TCP MSS | 'tcp mss' - Bursty | 'bursty' - A/B | 'a/b' - Elapsed | 'elapsed' - Destination Addr| 'destination addr' - Source Addr | 'source addr' + Name | + EID | 'eid' + Run | 'run' + Mng | 'mng' + Script | 'script' + Tx Rate | 'tx rate' + Tx Rate (1 min) | 'tx rate (1 min)' + Tx Rate (last) | 'tx rate (last)' + Tx Rate LL | 'tx rate ll' + Rx Rate | 'rx rate' + Rx Rate (1 min) | 'rx rate (1 min)' + Rx Rate (last) | 'rx rate (last)' + Rx Rate LL | 'rx rate ll' + Rx Drop % | 'rx drop %' + Tx PDUs | 'tx pdus' + Tx Pkts LL | 'tx pkts ll' + PDU/s TX | 'pdu/s tx' + Pps TX LL | 'pps tx ll' + Rx PDUs | 'rx pdus' + Rx Pkts LL | 'pps rx ll' + PDU/s RX | 'pdu/s tx' + Pps RX LL | 'pps rx ll' + Delay | 'delay' + Dropped | 'dropped' + Jitter | 'jitter' + Tx Bytes | 'tx bytes' + Rx Bytes | 'rx bytes' + Replays | 'replays' + TCP Rtx | 'tcp rtx' + Dup Pkts | 'dup pkts' + Rx Dup % | 'rx dup %' + OOO Pkts | 'ooo pkts' + Rx OOO % | 'rx ooo %' + RX Wrong Dev | 'rx wrong dev' + CRC Fail | 'crc fail' + RX BER | 'rx ber' + CX Active | 'cx active' + CX Estab/s | 'cx estab/s' + 1st RX | '1st rx' + CX TO | 'cx to' + Pattern | 'pattern' + Min PDU | 'min pdu' + Max PDU | 'max pdu' + Min Rate | 'min rate' + Max Rate | 'max rate' + Send Buf | 'send buf' + Rcv Buf | 'rcv buf' + CWND | 'cwnd' + TCP MSS | 'tcp mss' + Bursty | 'bursty' + A/B | 'a/b' + Elapsed | 'elapsed' + Destination Addr | 'destination addr' + Source Addr | 'source addr' ''') required_args=None From ea82d4ade4cdf26032ebc2ef3ebcf5dfc80449c4 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Sat, 30 Jan 2021 21:12:36 -0800 Subject: [PATCH 228/848] fix monitor df to blank function --- py-json/realm.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 18fb37f1..35626cce 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -15,7 +15,7 @@ from LANforge.lfcli_base import LFCliBase from LANforge import add_monitor from LANforge.add_monitor import * import os -import datetime +import datetime import base64 import xlsxwriter import pandas as pd @@ -1143,6 +1143,7 @@ class L3CXProfile(BaseProfile): return False else: return False + def monitor(self, duration_sec=60, monitor_interval=1, @@ -1183,7 +1184,7 @@ class L3CXProfile(BaseProfile): #previous_data_df= read_csv() pass - #Step 1, column names + #Step 1, column names fields=None if col_names is not None and len(col_names) > 0: fields = ",".join(col_names) @@ -1233,7 +1234,7 @@ class L3CXProfile(BaseProfile): print("Printing value map...") print(value_map) - #organize data + #organize data full_test_data_list = [] for test_timestamp, data in value_map.items(): #reduce the endpoint data to single dictionary of dictionaries @@ -1243,19 +1244,19 @@ class L3CXProfile(BaseProfile): print(endpoint_data) endpoint_data["Timestamp"] = test_timestamp full_test_data_list.append(endpoint_data) - + header_row.append("Timestamp") header_row.append('Timestamp milliseconds') df = pd.DataFrame(full_test_data_list) - + df["Timestamp milliseconds"] = (df["Timestamp"] - datetime.datetime(1970,1,1)).dt.total_seconds()*1000 #round entire column df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int) df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S")) df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] #compare previous data to current data - + try: systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) except: @@ -1281,7 +1282,7 @@ class L3CXProfile(BaseProfile): supported_formats = ['csv', 'json', 'stata', 'pickle','html'] for x in supported_formats: if output_format.lower() == x or report_file.split('.')[-1] == x: - exec('df.to_' + x + '("' + report_file + '",index=False' + ')') + exec('df.to_' + x + '("'+report_file+'")') def refresh_cx(self): @@ -1743,20 +1744,20 @@ class L4CXProfile(LFCliBase): response = self.json_get("/layer4/%s?fields=%s" % (created_cx, fields)) if debug: print(response) - if response is None: + if response is None: print(response) raise ValueError("Cannot find any endpoints") if monitor: if debug: print(response) - + time.sleep(sleep_interval) t = datetime.datetime.now() timestamps.append(t) value_map[t] = response expected_passes += 1 if self.check_errors(debug): - if self.check_request_rate(): + if self.check_request_rate(): passes += 1 else: self._fail("FAIL: Request rate did not exceed 90% target rate") From 3cc55b8508d67f1e0abcd8456a8f8b0f23246266 Mon Sep 17 00:00:00 2001 From: Nikita Yadav Date: Sun, 31 Jan 2021 18:47:29 +0530 Subject: [PATCH 229/848] station with layer3 cx --- py-scripts/station_layer3.py | 103 +++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 py-scripts/station_layer3.py diff --git a/py-scripts/station_layer3.py b/py-scripts/station_layer3.py new file mode 100644 index 00000000..0f749ae9 --- /dev/null +++ b/py-scripts/station_layer3.py @@ -0,0 +1,103 @@ +'''this script creates 1 station on given arguments +how to run - [lanforge@LF4-Node2 py-scripts]$ python3 station_banao.py -hst localhost -s TestAP22 -pwd [BLANK] -sec open -rad wiphy0 + +''' + +import sys +import argparse +import time +if 'py-json' not in sys.path: + sys.path.append('../py-json') +from LANforge import LFUtils +from LANforge import lfcli_base +from LANforge.lfcli_base import LFCliBase +from LANforge.LFUtils import * +import realm +from realm import Realm + +class STATION(LFCliBase): + def __init__(self, lfclient_host, lfclient_port, ssid, paswd, security, radio, sta_list=None, name_prefix="L3Test", upstream="eth2"): + super().__init__(lfclient_host, lfclient_port) + self.host = lfclient_host + self.port = lfclient_port + self.ssid = ssid + self.paswd = paswd + self.security = security + self.radio = radio + self.sta_list = sta_list + self.name_prefix = name_prefix + self.upstream = upstream + + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) + self.station_profile = self.local_realm.new_station_profile() + self.station_profile.ssid = self.ssid + self.station_profile.ssid_pass = self.paswd, + self.station_profile.security = self.security + self.cx_profile = self.local_realm.new_l3_cx_profile() + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = 1000000 + self.cx_profile.side_a_max_bps = 1000000 + self.cx_profile.side_b_min_bps = 1000000 + self.cx_profile.side_b_max_bps = 1000000 + + + def precleanup(self, sta_list): + self.cx_profile.cleanup_prefix() + for sta in self.sta_list: + self.local_realm.rm_port(sta, check_exists=True) + LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, + port_list=sta_list, + debug=self.debug) + time.sleep(1) + + def build(self): + self.station_profile.use_security(self.security, self.ssid, self.paswd) + self.station_profile.create(radio=self.radio) + self.cx_profile.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b=self.upstream, + sleep_time=0) + + def start(self, sta_list): + self.station_profile.admin_up() + temp_stas = self.station_profile.station_names.copy() + if self.local_realm.wait_for_ip(temp_stas): + self._pass("All stations got IPs") + else: + self._fail("Stations failed to get IPs") + self.exit_fail() + self.cx_profile.start_cx() + + + def stop(self): + # Bring stations down + self.station_profile.admin_down() + self.cx_profile.stop_cx() + + + + + +def main(): + parser = argparse.ArgumentParser(description="Netgear AP DFS Test Script") + parser.add_argument('-hst', '--host', type=str, help='host name') + parser.add_argument('-s', '--ssid', type=str, help='ssid for client') + parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid') + parser.add_argument('-sec', '--security', type=str, help='security') + parser.add_argument('-rad', '--radio', type=str, help='radio at which client will be connected') + #parser.add_argument() + args = parser.parse_args() + num_sta = 1 + station_list = LFUtils.port_name_series(prefix="sta", + start_id=0, + end_id=num_sta - 1, + padding_number=10000, + radio=args.radio) + obj = STATION(lfclient_host= args.host, lfclient_port=8080, ssid=args.ssid , paswd=args.passwd, security=args.security, radio=args.radio, sta_list=station_list) + obj.precleanup(station_list) + obj.build() + obj.start(station_list) + + +if __name__ == '__main__': + main() \ No newline at end of file From a622584094204ff44917216a692be119e07f223c Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 1 Feb 2021 12:25:28 -0800 Subject: [PATCH 230/848] working html_test_output --- py-scripts/{html_test_output.sh => regression_test.sh} | 0 py-scripts/update_dependencies.py | 10 ++++++++++ 2 files changed, 10 insertions(+) rename py-scripts/{html_test_output.sh => regression_test.sh} (100%) create mode 100644 py-scripts/update_dependencies.py diff --git a/py-scripts/html_test_output.sh b/py-scripts/regression_test.sh similarity index 100% rename from py-scripts/html_test_output.sh rename to py-scripts/regression_test.sh diff --git a/py-scripts/update_dependencies.py b/py-scripts/update_dependencies.py new file mode 100644 index 00000000..dac713ce --- /dev/null +++ b/py-scripts/update_dependencies.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +import subprocess +def main(): + command = "pip install pandas seaborn plotly numpy dash --upgrade" + res = subprocess.call(command, shell = True) + + print("Returned Value: ", res) + +if __name__ == "__main__": + main() From f62ee82e772671ef5c09c5de450f20cf5f610282 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 1 Feb 2021 12:50:40 -0800 Subject: [PATCH 231/848] fix regression test --- py-scripts/regression_test.sh | 10 ++++++++-- py-scripts/update_deps.py | 10 ---------- py-scripts/update_deps.sh | 1 - 3 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 py-scripts/update_deps.py delete mode 100755 py-scripts/update_deps.sh diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 77eeb6b2..50a172fe 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -91,9 +91,15 @@ function run_test() { grep -i fail "${TEST_DIR}/${i}.txt" && retval=1 chmod 664 "${TEST_DIR}/${i}.txt" if (( $retval == 0 )); then - results+=("${CURR_TEST_NAME}${i}Success
STDOUTSTDERR") + results+=("${CURR_TEST_NAME}${i} + Success + STDOUT + STDERR") else - results+=("${CURR_TEST_NAME}${i}Failure") + results+=("${CURR_TEST_NAME}${i} + Failure + STDOUT + STDERR") fi fi diff --git a/py-scripts/update_deps.py b/py-scripts/update_deps.py deleted file mode 100644 index dac713ce..00000000 --- a/py-scripts/update_deps.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -import subprocess -def main(): - command = "pip install pandas seaborn plotly numpy dash --upgrade" - res = subprocess.call(command, shell = True) - - print("Returned Value: ", res) - -if __name__ == "__main__": - main() diff --git a/py-scripts/update_deps.sh b/py-scripts/update_deps.sh deleted file mode 100755 index 0ff68504..00000000 --- a/py-scripts/update_deps.sh +++ /dev/null @@ -1 +0,0 @@ -pip install pandas seaborn plotly numpy dash --upgrade From 7b6c1245102e2fe4a47a6fbdc7573938e407132a Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Thu, 28 Jan 2021 15:32:05 -0700 Subject: [PATCH 232/848] test_l3_longevity.py: fixes for realm.py updates --- py-scripts/test_l3_longevity.py | 106 ++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 34 deletions(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 1c9b4ec1..b556c6cd 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -11,31 +11,52 @@ if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) import argparse -from LANforge.lfcli_base import LFCliBase +import LANforge from LANforge import LFUtils -import realm import time import datetime import subprocess import re import csv import random +from realm import Realm -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, station_lists, name_prefix, debug_on, outfile, +class L3VariableTime(Realm): + def __init__(self, + args, + endp_types, + tos, + side_b, + radio_name_list, + number_of_stations_per_radio_list, + ssid_list, + ssid_password_list, + ssid_security_list, + station_lists, + name_prefix, reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list, + lfclient_host="localhost", + lfclient_port=8080, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", polling_interval="60s", + _halt_on_error=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 + _exit_on_fail=False, + debug=False, + outfile="outfile"): + super().__init__(lfclient_host="localhost", + lfclient_port=8080, + debug_=debug, + _halt_on_error=False, + _exit_on_error=False, + _exit_on_fail=False + ) + + self.tos = tos.split() self.endp_types = endp_types.split() self.side_b = side_b @@ -51,17 +72,19 @@ class L3VariableTime(LFCliBase): self.test_duration = test_duration self.radio_name_list = radio_name_list self.number_of_stations_per_radio_list = number_of_stations_per_radio_list - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) - 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.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) + #self.polling_interval_seconds = self.local_realm.duration_time_to_seconds(polling_interval) + self.polling_interval_seconds = self.duration_time_to_seconds(polling_interval) + #self.cx_profile = self.local_realm.new_l3_cx_profile() + self.cx_profile = self.new_l3_cx_profile() + #self.multicast_profile = self.local_realm.new_multicast_profile() + self.multicast_profile = self.new_multicast_profile() self.multicast_profile.name_prefix = "MLT-"; self.station_profiles = [] self.args = args self.outfile = outfile self.csv_started = False self.epoch_time = int(time.time()) - self.debug = debug_on # Some checking on the duration @@ -82,7 +105,8 @@ class L3VariableTime(LFCliBase): reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \ in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list,\ reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list): - self.station_profile = self.local_realm.new_station_profile() + #self.station_profile = self.local_realm.new_station_profile() + self.station_profile = self.new_station_profile() self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = ssid_ self.station_profile.ssid_pass = ssid_password_ @@ -90,9 +114,13 @@ class L3VariableTime(LFCliBase): self.station_profile.number_template = self.number_template self.station_profile.mode = 0 self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,\ - test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ - reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ - reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) + #test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ + #reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ + #reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) + + test_duration=self.duration_time_to_seconds(self.test_duration),\ + reset_port_min_time=self.duration_time_to_seconds(reset_port_time_min_),\ + reset_port_max_time=self.duration_time_to_seconds(reset_port_time_max_)) self.station_profiles.append(self.station_profile) self.multicast_profile.host = self.host @@ -862,7 +890,8 @@ class L3VariableTime(LFCliBase): station_profile.reset_port_extra_data['reset_port_timer_started'] = False port_to_reset = random.randint(0,len(station_profile.station_names)-1) print("reset on radio {} station: {}".format(station_profile.add_sta_data['radio'],station_profile.station_names[port_to_reset])) - self.local_realm.reset_port(station_profile.station_names[port_to_reset]) + #self.local_realm.reset_port(station_profile.station_names[port_to_reset]) + self.reset_port(station_profile.station_names[port_to_reset]) def pre_cleanup(self): self.cx_profile.cleanup_prefix() @@ -870,7 +899,8 @@ class L3VariableTime(LFCliBase): self.total_stas = 0 for station_list in self.station_lists: for sta in station_list: - self.local_realm.rm_port(sta, check_exists=True) + #self.local_realm.rm_port(sta, check_exists=True) + self.rm_port(sta, check_exists=True) self.total_stas += 1 # Make sure they are gone @@ -912,18 +942,21 @@ class L3VariableTime(LFCliBase): def start(self, print_pass=False, print_fail=False): print("Bringing up stations") - self.local_realm.admin_up(self.side_b) + #self.local_realm.admin_up(self.side_b) + self.admin_up(self.side_b) for station_profile in self.station_profiles: for sta in station_profile.station_names: print("Bringing up station %s"%(sta)) - self.local_realm.admin_up(sta) + #self.local_realm.admin_up(sta) + self.admin_up(sta) temp_stations_list = [] temp_stations_list.append(self.side_b) for station_profile in self.station_profiles: temp_stations_list.extend(station_profile.station_names.copy()) - if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): + #if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): + if self.wait_for_ip(temp_stations_list, timeout_sec=120): print("ip's acquired") else: print("print failed to get IP's") @@ -940,7 +973,8 @@ class L3VariableTime(LFCliBase): print("Getting initial values.") old_rx_values, rx_drop_percent = self.__get_rx_values() - end_time = self.local_realm.parse_time(self.test_duration) + cur_time + #end_time = self.local_realm.parse_time(self.test_duration) + cur_time + end_time = self.parse_time(self.test_duration) + cur_time print("Monitoring throughput for duration: %s"%(self.test_duration)) @@ -977,7 +1011,8 @@ class L3VariableTime(LFCliBase): self.multicast_profile.stop_mc() for station_list in self.station_lists: for station_name in station_list: - self.local_realm.admin_down(station_name) + #self.local_realm.admin_down(station_name) + self.admin_down(station_name) def cleanup(self): self.cx_profile.cleanup() @@ -1201,7 +1236,7 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr if args.radio: radios = args.radio - + csv_outfile = "dog" if args.csv_outfile != None: current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time) @@ -1271,17 +1306,15 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr #print("endp-types: %s"%(endp_types)) - ip_var_test = L3VariableTime( - lfjson_host, - lfjson_port, + ip_var_test = L3VariableTime( args=args, - number_template="00", - station_lists= station_lists, - name_prefix="LT-", endp_types=endp_types, tos=args.tos, side_b=side_b, radio_name_list=radio_name_list, + number_template="00", + station_lists= station_lists, + name_prefix="LT-", number_of_stations_per_radio_list=number_of_stations_per_radio_list, ssid_list=ssid_list, ssid_password_list=ssid_password_list, @@ -1291,10 +1324,15 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr reset_port_enable_list=reset_port_enable_list, reset_port_time_min_list=reset_port_time_min_list, reset_port_time_max_list=reset_port_time_max_list, + #lfclient_host=lfjson_host, + #lfjson_port=lfjson_port, side_a_min_rate=256000, side_b_min_rate=256000, - debug_on=debug_on, - outfile=csv_outfile) + debug=debug_on, + outfile=csv_outfile, + _halt_on_error=False, + _exit_on_error=False, + _exit_on_fail=False) ip_var_test.pre_cleanup() From 12363705435ea303da8a1743237591b32793e011 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 1 Feb 2021 15:40:56 -0700 Subject: [PATCH 233/848] test_l3_longevity.py : revert changes from Jan 28th --- py-scripts/test_l3_longevity.py | 106 ++++++++++---------------------- 1 file changed, 34 insertions(+), 72 deletions(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index b556c6cd..1c9b4ec1 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -11,52 +11,31 @@ if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) import argparse -import LANforge +from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils +import realm import time import datetime import subprocess import re import csv import random -from realm import Realm -class L3VariableTime(Realm): - def __init__(self, - args, - endp_types, - tos, - side_b, - radio_name_list, - number_of_stations_per_radio_list, - ssid_list, - ssid_password_list, - ssid_security_list, - station_lists, - name_prefix, +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, station_lists, name_prefix, debug_on, outfile, reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list, - lfclient_host="localhost", - lfclient_port=8080, side_a_min_rate=56000, side_a_max_rate=0, side_b_min_rate=56000, side_b_max_rate=0, number_template="00", test_duration="256s", polling_interval="60s", - _halt_on_error=False, _exit_on_error=False, - _exit_on_fail=False, - debug=False, - outfile="outfile"): - super().__init__(lfclient_host="localhost", - lfclient_port=8080, - debug_=debug, - _halt_on_error=False, - _exit_on_error=False, - _exit_on_fail=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.tos = tos.split() self.endp_types = endp_types.split() self.side_b = side_b @@ -72,19 +51,17 @@ class L3VariableTime(Realm): self.test_duration = test_duration self.radio_name_list = radio_name_list self.number_of_stations_per_radio_list = number_of_stations_per_radio_list - #self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) - #self.polling_interval_seconds = self.local_realm.duration_time_to_seconds(polling_interval) - self.polling_interval_seconds = self.duration_time_to_seconds(polling_interval) - #self.cx_profile = self.local_realm.new_l3_cx_profile() - self.cx_profile = self.new_l3_cx_profile() - #self.multicast_profile = self.local_realm.new_multicast_profile() - self.multicast_profile = self.new_multicast_profile() + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) + 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.station_profiles = [] self.args = args self.outfile = outfile self.csv_started = False self.epoch_time = int(time.time()) + self.debug = debug_on # Some checking on the duration @@ -105,8 +82,7 @@ class L3VariableTime(Realm): reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \ in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list,\ reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list): - #self.station_profile = self.local_realm.new_station_profile() - self.station_profile = self.new_station_profile() + self.station_profile = self.local_realm.new_station_profile() self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = ssid_ self.station_profile.ssid_pass = ssid_password_ @@ -114,13 +90,9 @@ class L3VariableTime(Realm): self.station_profile.number_template = self.number_template self.station_profile.mode = 0 self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,\ - #test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ - #reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ - #reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) - - test_duration=self.duration_time_to_seconds(self.test_duration),\ - reset_port_min_time=self.duration_time_to_seconds(reset_port_time_min_),\ - reset_port_max_time=self.duration_time_to_seconds(reset_port_time_max_)) + test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ + reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ + reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) self.station_profiles.append(self.station_profile) self.multicast_profile.host = self.host @@ -890,8 +862,7 @@ class L3VariableTime(Realm): station_profile.reset_port_extra_data['reset_port_timer_started'] = False port_to_reset = random.randint(0,len(station_profile.station_names)-1) print("reset on radio {} station: {}".format(station_profile.add_sta_data['radio'],station_profile.station_names[port_to_reset])) - #self.local_realm.reset_port(station_profile.station_names[port_to_reset]) - self.reset_port(station_profile.station_names[port_to_reset]) + self.local_realm.reset_port(station_profile.station_names[port_to_reset]) def pre_cleanup(self): self.cx_profile.cleanup_prefix() @@ -899,8 +870,7 @@ class L3VariableTime(Realm): self.total_stas = 0 for station_list in self.station_lists: for sta in station_list: - #self.local_realm.rm_port(sta, check_exists=True) - self.rm_port(sta, check_exists=True) + self.local_realm.rm_port(sta, check_exists=True) self.total_stas += 1 # Make sure they are gone @@ -942,21 +912,18 @@ class L3VariableTime(Realm): def start(self, print_pass=False, print_fail=False): print("Bringing up stations") - #self.local_realm.admin_up(self.side_b) - self.admin_up(self.side_b) + self.local_realm.admin_up(self.side_b) for station_profile in self.station_profiles: for sta in station_profile.station_names: print("Bringing up station %s"%(sta)) - #self.local_realm.admin_up(sta) - self.admin_up(sta) + self.local_realm.admin_up(sta) temp_stations_list = [] temp_stations_list.append(self.side_b) for station_profile in self.station_profiles: temp_stations_list.extend(station_profile.station_names.copy()) - #if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): - if self.wait_for_ip(temp_stations_list, timeout_sec=120): + if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): print("ip's acquired") else: print("print failed to get IP's") @@ -973,8 +940,7 @@ class L3VariableTime(Realm): print("Getting initial values.") old_rx_values, rx_drop_percent = self.__get_rx_values() - #end_time = self.local_realm.parse_time(self.test_duration) + cur_time - end_time = self.parse_time(self.test_duration) + cur_time + end_time = self.local_realm.parse_time(self.test_duration) + cur_time print("Monitoring throughput for duration: %s"%(self.test_duration)) @@ -1011,8 +977,7 @@ class L3VariableTime(Realm): self.multicast_profile.stop_mc() for station_list in self.station_lists: for station_name in station_list: - #self.local_realm.admin_down(station_name) - self.admin_down(station_name) + self.local_realm.admin_down(station_name) def cleanup(self): self.cx_profile.cleanup() @@ -1236,7 +1201,7 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr if args.radio: radios = args.radio - csv_outfile = "dog" + if args.csv_outfile != None: current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time) @@ -1306,15 +1271,17 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr #print("endp-types: %s"%(endp_types)) - ip_var_test = L3VariableTime( + ip_var_test = L3VariableTime( + lfjson_host, + lfjson_port, args=args, + number_template="00", + station_lists= station_lists, + name_prefix="LT-", endp_types=endp_types, tos=args.tos, side_b=side_b, radio_name_list=radio_name_list, - number_template="00", - station_lists= station_lists, - name_prefix="LT-", number_of_stations_per_radio_list=number_of_stations_per_radio_list, ssid_list=ssid_list, ssid_password_list=ssid_password_list, @@ -1324,15 +1291,10 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr reset_port_enable_list=reset_port_enable_list, reset_port_time_min_list=reset_port_time_min_list, reset_port_time_max_list=reset_port_time_max_list, - #lfclient_host=lfjson_host, - #lfjson_port=lfjson_port, side_a_min_rate=256000, side_b_min_rate=256000, - debug=debug_on, - outfile=csv_outfile, - _halt_on_error=False, - _exit_on_error=False, - _exit_on_fail=False) + debug_on=debug_on, + outfile=csv_outfile) ip_var_test.pre_cleanup() From c98abcd7be8685fd83c719deb4c29a426cbda6e4 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 1 Feb 2021 16:06:07 -0800 Subject: [PATCH 234/848] realm l3cxprofile and regression fixes --- py-json/realm.py | 35 ++++++++++----------- py-scripts/regression_test.sh | 1 + py-scripts/test_ipv4_variable_time.py | 44 +++++++++++++-------------- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 35626cce..f32ca4f1 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -839,8 +839,8 @@ class BaseProfile: self.exit_on_error = False self.debug = debug or local_realm.debug - def json_get(self, target): - return self.parent_realm.json_get(target) + def json_get(self, _req_url, debug_=False): + return self.parent_realm.json_get(_req_url, debug_=False) def json_post(self, req_url=None, data=None, debug_=False, suppress_related_commands_=None): return self.parent_realm.json_post(_req_url=req_url, @@ -848,8 +848,8 @@ class BaseProfile: suppress_related_commands_=suppress_related_commands_, debug_=debug_) - def parse_time(self, target): - return self.parent_realm.parse_time(target) + def parse_time(self, time_string): + return self.parent_realm.parse_time(time_string) def stopping_cx(self, name): return self.parent_realm.stop_cx(name) @@ -857,26 +857,23 @@ class BaseProfile: def cleanup_cxe_prefix(self, prefix): return self.parent_realm.cleanup_cxe_prefix(prefix) - def rm_cx(self, target): - return self.parent_realm.rm_cx(target) + def rm_cx(self, cx_name): + return self.parent_realm.rm_cx(cx_name) - def rm_endp(self, ename): - self.parent_realm.rm_endp(ename) + def rm_endp(self, ename, debug_=False, suppress_related_commands_=True): + self.parent_realm.rm_endp(ename, debug_=False, suppress_related_commands_=True) - def created_cx(self, target): - return self.parent_realm.created_cx(target) + def name_to_eid(self, eid): + return self.parent_realm.name_to_eid(eid) - def name_to_eid(self, target): - return self.parent_realm.name_to_eid(target) + def set_endp_tos(self, ename, _tos, debug_=False, suppress_related_commands_=True): + return self.parent_realm.set_endp_tos(ename, _tos, debug_=False, suppress_related_commands_=True) - def set_endp_tos(self, target): - return self.parent_realm.set_endp_tos(target) + def wait_until_endps_appear(self, these_endp, debug=False): + return self.parent_realm.wait_until_endps_appear(these_endp, debug=False) - def wait_until_endps_appear(self, target, debug=False): - return self.parent_realm.wait_until_endps_appear(target, debug=False) - - def wait_until_cxs_appear(self, target, debug=False): - return self.parent_realm.wait_until_cxs_appear(target, debug=False) + def wait_until_cxs_appear(self, these_cx, debug=False): + return self.parent_realm.wait_until_cxs_appear(these_cx, debug=False) class MULTICASTProfile(LFCliBase): diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 50a172fe..e2dca47b 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -140,6 +140,7 @@ function html_generator() { .scriptdetails { font-size: 10px; } +

Test All Scripts Results

diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 51d39c2a..5f0b8c90 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -24,32 +24,32 @@ if 'py-json' not in sys.path: import argparse from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils -import realm +from realm import Realm import time import datetime -from realm import TestGroupProfile -class IPV4VariableTime(LFCliBase): +class IPV4VariableTime(Realm): def __init__(self, - ssid, security, password, sta_list, name_prefix, upstream, radio, - host="localhost", port=8080, mode = 0, ap=None, + ssid=None, + security=None, + password=None, + sta_list=[], + name_prefix=None, + upstream=None, + radio=None, + host="localhost", + port=8080, + mode = 0, + ap=None, side_a_min_rate=56, side_a_max_rate=0, side_b_min_rate=56, side_b_max_rate=0, number_template="00000", test_duration="5m", use_ht160=False, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): - super().__init__(host, port, - _local_realm = realm.Realm(lfclient_host=host, - lfclient_port=port, - debug_=_debug_on, - halt_on_error_=_exit_on_error), - _debug=_debug_on, - _halt_on_error=_exit_on_error, - _exit_on_fail=_exit_on_fail), - self.l3cxprofile = realm.L3CXProfile(lfclient_host=host, - lfclient_port=port, - local_realm=self.local_realm) + super().__init__(lfclient_host=host, + lfclient_port=port), + self.l3cxprofile = self.new_l3_cx_profile() self.upstream = upstream self.host = host self.port = port @@ -64,8 +64,8 @@ class IPV4VariableTime(LFCliBase): self.debug = _debug_on self.name_prefix = name_prefix self.test_duration = test_duration - self.station_profile = self.local_realm.new_station_profile() - self.cx_profile = self.local_realm.new_l3_cx_profile() + self.station_profile = self.new_station_profile() + self.cx_profile = self.new_l3_cx_profile() self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = self.ssid self.station_profile.ssid_pass = self.password @@ -93,7 +93,7 @@ class IPV4VariableTime(LFCliBase): #to-do- check here if upstream port got IP temp_stas = self.station_profile.station_names.copy() - if self.local_realm.wait_for_ip(temp_stas): + if self.wait_for_ip(temp_stas): self._pass("All stations got IPs") else: self._fail("Stations failed to get IPs") @@ -108,7 +108,7 @@ class IPV4VariableTime(LFCliBase): def pre_cleanup(self): self.cx_profile.cleanup_prefix() for sta in self.sta_list: - self.local_realm.rm_port(sta, check_exists=True) + self.rm_port(sta, check_exists=True) def cleanup(self): self.cx_profile.cleanup() @@ -332,7 +332,7 @@ python3 ./test_ipv4_variable_time.py ip_var_test.start(False, False) try: - layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) + layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.json_get('endp')['endpoint']]) except: raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') if args.col_names is not None: @@ -348,7 +348,7 @@ python3 ./test_ipv4_variable_time.py print(col_names) ip_var_test.l3cxprofile.monitor(col_names=col_names, report_file=report_f, - duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), + duration_sec=ip_var_test.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, output_format=output, compared_report=compared_rept, From 24e9a33e63be32817711ef4b044af704d6867b2f Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 1 Feb 2021 16:44:11 -0800 Subject: [PATCH 235/848] regression typo --- py-scripts/regression_test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index e2dca47b..7a160bce 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -93,13 +93,13 @@ function run_test() { if (( $retval == 0 )); then results+=("${CURR_TEST_NAME}${i} Success -
STDOUT - STDERR") + STDOUT + STDERR") else results+=("${CURR_TEST_NAME}${i} Failure - STDOUT - STDERR") + STDOUT + STDERR") fi fi From a296363cdd11dadc7f7a4eb287bb1bbbc84e6093 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 2 Feb 2021 00:37:22 -0800 Subject: [PATCH 236/848] changed timeout on 1k and added comments to ipv4 for including where helper file is --- py-scripts/test_1k_clients_jedtest.py | 4 ++-- py-scripts/test_ipv4_variable_time.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/py-scripts/test_1k_clients_jedtest.py b/py-scripts/test_1k_clients_jedtest.py index 09478d1f..4a917570 100755 --- a/py-scripts/test_1k_clients_jedtest.py +++ b/py-scripts/test_1k_clients_jedtest.py @@ -24,7 +24,7 @@ class Test1KClients(LFCliBase): side_a_min_rate= 0,side_a_max_rate= 56000, side_b_min_rate= 0,side_b_max_rate= 56000, num_sta_=200, - test_duration="30s", + test_duration="2d", _debug_on=True, _exit_on_error=False, _exit_on_fail=False): @@ -133,7 +133,7 @@ class Test1KClients(LFCliBase): self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=30) curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,station_list=self.station_radio_map[radio], debug=self.debug) while ((prev_ip_num < curr_ip_num) and (curr_ip_num < total_num_sta)): - self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=60) + self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=90) prev_ip_num = curr_ip_num curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,station_list=self.station_radio_map[radio], debug=self.debug) if curr_ip_num == total_num_sta: diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index 5f0b8c90..20e0bffd 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -339,8 +339,10 @@ python3 ./test_ipv4_variable_time.py print(args.col_names) if type(args.col_names) is not list: col_names=list(args.col_names.split(",")) + #send col names here to file to reformat else: col_names = args.col_names + #send col names here to file to reformat else: col_names=None if args.debug: From ec3909ba377cf76bb6ab8162ae411234d1cb67d9 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 2 Feb 2021 11:41:38 -0800 Subject: [PATCH 237/848] fixing errors in urls per ten and regression test --- py-scripts/regression_test.sh | 10 +++++----- py-scripts/test_ipv4_l4_urls_per_ten.py | 14 +++----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 7a160bce..e060514f 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -25,14 +25,14 @@ testCommands=( "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3" - "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" + "./test_ipv4_connection.py --radio $RADIO_USED --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY" "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600" - "./test_ipv4_l4_wifi.py --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" - "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m" - "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" - "./test_ipv4_variable_time.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" + "./test_ipv4_l4_wifi.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" + "./test_ipv4_l4.py --radio $RADIO_USED --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" + "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" + "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" #"./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" #"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" #"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" diff --git a/py-scripts/test_ipv4_l4_urls_per_ten.py b/py-scripts/test_ipv4_l4_urls_per_ten.py index de2a787b..497dae9b 100755 --- a/py-scripts/test_ipv4_l4_urls_per_ten.py +++ b/py-scripts/test_ipv4_l4_urls_per_ten.py @@ -251,19 +251,11 @@ python3 ./test_ipv4_l4_urls_per_ten.py layer4traffic=','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']]) except: pass -<<<<<<< HEAD ip_test.l4cxprofile.monitor(col_names=['Name','bytes-rd','rx rate (1 min)', 'urls/s'], - report_file=rpt_file, + report_file=rpt_file, duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), - created_cx=layer4traffic, - output_format=output_form, -======= - ip_test.l4cxprofile.monitor(col_names=['Name','bytes-rd','urls/s'], - report_file=rpt_file, - duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(), - created_cx=layer4traffic, - output_format=output, ->>>>>>> dipti-branch + created_cx=layer4traffic, + output_format=output_form, script_name='test_ipv4_l4_urls_per_ten', arguments=args, debug=args.debug) From 4bcba94bf81ba160e49b1678c13b0f1458e253c0 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 2 Feb 2021 07:05:56 -0700 Subject: [PATCH 238/848] test_l3_longevity.py: change inheritance from LFCliBase to Realm --- py-scripts/test_l3_longevity.py | 96 +++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 1c9b4ec1..ce63353d 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -11,9 +11,10 @@ if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) import argparse -from LANforge.lfcli_base import LFCliBase +#from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils -import realm +#import realm +from realm import Realm import time import datetime import subprocess @@ -21,21 +22,46 @@ import re import csv import random -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, station_lists, name_prefix, debug_on, outfile, +class L3VariableTime(Realm): + def __init__(self, + endp_types, + args, + tos, + side_b, + radio_name_list, + number_of_stations_per_radio_list, + ssid_list, + ssid_password_list, + ssid_security_list, + station_lists, + name_prefix, + outfile, reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list, - side_a_min_rate=56000, side_a_max_rate=0, - side_b_min_rate=56000, side_b_max_rate=0, - number_template="00", test_duration="256s", + side_a_min_rate=56000, + side_a_max_rate=0, + side_b_min_rate=56000, + side_b_max_rate=0, + number_template="00", + test_duration="256s", polling_interval="60s", + lfclient_host="localhost", + lfclient_port=8080, + debug=False, + _halt_on_error=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 + _exit_on_fail=False, + _proxy_str=None, + _capture_signal_list=[]): + super().__init__(lfclient_host=lfclient_host, + lfclient_port=lfclient_port, + debug_=debug, + halt_on_error_=_halt_on_error, + _exit_on_error=_exit_on_error, + _exit_on_fail=_exit_on_fail, + _proxy_str=_proxy_str, + _capture_signal_list=_capture_signal_list) self.tos = tos.split() self.endp_types = endp_types.split() self.side_b = side_b @@ -51,21 +77,21 @@ class L3VariableTime(LFCliBase): self.test_duration = test_duration self.radio_name_list = radio_name_list self.number_of_stations_per_radio_list = number_of_stations_per_radio_list - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) - 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.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) + self.polling_interval_seconds = self.duration_time_to_seconds(polling_interval) + self.cx_profile = self.new_l3_cx_profile() + self.multicast_profile = self.new_multicast_profile() self.multicast_profile.name_prefix = "MLT-"; self.station_profiles = [] self.args = args self.outfile = outfile self.csv_started = False self.epoch_time = int(time.time()) - self.debug = debug_on + self.debug = debug # Some checking on the duration - #self.local_realm.parse_time(self.test_duration) + #self.parse_time(self.test_duration) #if ( (radio_info_dict['reset_port_time_min'] >= args.test_duration) # or (radio_info_dict['reset_port_time_max'] >= args.test_duration)): # print("port reset times min {} max {} mismatched with test duration {}"\ @@ -82,7 +108,7 @@ class L3VariableTime(LFCliBase): reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \ in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list,\ reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list): - self.station_profile = self.local_realm.new_station_profile() + self.station_profile = self.new_station_profile() self.station_profile.lfclient_url = self.lfclient_url self.station_profile.ssid = ssid_ self.station_profile.ssid_pass = ssid_password_ @@ -90,9 +116,9 @@ class L3VariableTime(LFCliBase): self.station_profile.number_template = self.number_template self.station_profile.mode = 0 self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,\ - test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ - reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ - reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) + test_duration=self.duration_time_to_seconds(self.test_duration),\ + reset_port_min_time=self.duration_time_to_seconds(reset_port_time_min_),\ + reset_port_max_time=self.duration_time_to_seconds(reset_port_time_max_)) self.station_profiles.append(self.station_profile) self.multicast_profile.host = self.host @@ -862,7 +888,7 @@ class L3VariableTime(LFCliBase): station_profile.reset_port_extra_data['reset_port_timer_started'] = False port_to_reset = random.randint(0,len(station_profile.station_names)-1) print("reset on radio {} station: {}".format(station_profile.add_sta_data['radio'],station_profile.station_names[port_to_reset])) - self.local_realm.reset_port(station_profile.station_names[port_to_reset]) + self.reset_port(station_profile.station_names[port_to_reset]) def pre_cleanup(self): self.cx_profile.cleanup_prefix() @@ -870,7 +896,7 @@ class L3VariableTime(LFCliBase): self.total_stas = 0 for station_list in self.station_lists: for sta in station_list: - self.local_realm.rm_port(sta, check_exists=True) + self.rm_port(sta, check_exists=True) self.total_stas += 1 # Make sure they are gone @@ -879,7 +905,7 @@ class L3VariableTime(LFCliBase): more = False for station_list in self.station_lists: for sta in station_list: - rv = self.local_realm.rm_port(sta, check_exists=True) + rv = self.rm_port(sta, check_exists=True) if (rv): more = True if not more: @@ -912,18 +938,18 @@ class L3VariableTime(LFCliBase): def start(self, print_pass=False, print_fail=False): print("Bringing up stations") - self.local_realm.admin_up(self.side_b) + self.admin_up(self.side_b) for station_profile in self.station_profiles: for sta in station_profile.station_names: print("Bringing up station %s"%(sta)) - self.local_realm.admin_up(sta) + self.admin_up(sta) temp_stations_list = [] temp_stations_list.append(self.side_b) for station_profile in self.station_profiles: temp_stations_list.extend(station_profile.station_names.copy()) - if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120): + if self.wait_for_ip(temp_stations_list, timeout_sec=120): print("ip's acquired") else: print("print failed to get IP's") @@ -940,7 +966,7 @@ class L3VariableTime(LFCliBase): print("Getting initial values.") old_rx_values, rx_drop_percent = self.__get_rx_values() - end_time = self.local_realm.parse_time(self.test_duration) + cur_time + end_time = self.parse_time(self.test_duration) + cur_time print("Monitoring throughput for duration: %s"%(self.test_duration)) @@ -977,7 +1003,7 @@ class L3VariableTime(LFCliBase): self.multicast_profile.stop_mc() for station_list in self.station_lists: for station_name in station_list: - self.local_realm.admin_down(station_name) + self.admin_down(station_name) def cleanup(self): self.cx_profile.cleanup() @@ -1022,7 +1048,7 @@ def main(): lfjson_host = "localhost" lfjson_port = 8080 endp_types = "lf_udp" - debug_on = False + debug = False parser = argparse.ArgumentParser( prog='test_l3_longevity.py', @@ -1182,7 +1208,7 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr args = parser.parse_args() #print("args: {}".format(args)) - debug_on = args.debug + debug = args.debug if args.test_duration: test_duration = args.test_duration @@ -1272,8 +1298,6 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr #print("endp-types: %s"%(endp_types)) ip_var_test = L3VariableTime( - lfjson_host, - lfjson_port, args=args, number_template="00", station_lists= station_lists, @@ -1288,12 +1312,14 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr ssid_security_list=ssid_security_list, test_duration=test_duration, polling_interval= polling_interval, + lfclient_host=lfjson_host, + lfclient_port=lfjson_port, reset_port_enable_list=reset_port_enable_list, reset_port_time_min_list=reset_port_time_min_list, reset_port_time_max_list=reset_port_time_max_list, side_a_min_rate=256000, side_b_min_rate=256000, - debug_on=debug_on, + debug=debug, outfile=csv_outfile) ip_var_test.pre_cleanup() From 97516c825da03fb07355bfc2c9f44ea3cfe29bd4 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 2 Feb 2021 14:52:44 -0800 Subject: [PATCH 239/848] random characters for titles in regression test output --- py-json/LANforge/lfcli_base.py | 31 ++++++++++++++++++++++++++----- py-scripts/regression_test.sh | 17 +++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index fbfcae82..7758c7e0 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -6,6 +6,8 @@ import traceback # Extend this class to use common set of debug and request features for your script from pprint import pprint import time +import random +import string import LANforge.LFUtils from LANforge.LFUtils import * import argparse @@ -16,7 +18,7 @@ class LFCliBase: SHOULD_RUN = 0 # indicates normal operation SHOULD_QUIT = 1 # indicates to quit loops, close files, send SIGQUIT to threads and return - SHOULD_HALT = 2 # indicates to quit loops, send SIGABRT to threads and exit + SHOULD_HALT = 2 # indicates to quit loops, send SIGABRT to threads and exit # do not use `super(LFCLiBase,self).__init__(self, host, port, _debug) # that is py2 era syntax and will force self into the host variable, making you @@ -385,11 +387,11 @@ class LFCliBase: def get_pass_message(self): pass_messages = self.get_passed_result_list() - return "\n".join(pass_messages) + return "\n".join(pass_messages) def get_fail_message(self): fail_messages = self.get_failed_result_list() - return "\n".join(fail_messages) + return "\n".join(fail_messages) def get_all_message(self): return "\n".join(self.test_results) @@ -422,7 +424,7 @@ class LFCliBase: if self.exit_on_fail: sys.exit(1) - #EXIT script with a success + #EXIT script with a success def exit_success(self,message="%d out of %d tests passed successfully. Exiting script with script success."): num_total=len(self.get_result_list()) num_passing=len(self.get_passed_result_list()) @@ -520,7 +522,12 @@ class LFCliBase: return parser # use this function to add an event You can see these events when watching websocket_client at 8081 port - def add_event(self, message=None, event_id="new", name="custom", priority=1, debug_=False): + def add_event(self, + message=None, + event_id="new", + name="custom", + priority=1, + debug_=False): data = { "event_id": event_id, "details": message, @@ -529,6 +536,20 @@ class LFCliBase: } self.json_post("/cli-json/add_event", data, debug_=debug_) + def read_file(self, + filename): + #Convert file contents to a list + filename = open(filename, 'r') + return [line.split(',') for line in filename.readlines()] + + def random_chars(self, + size, + chars=None): + #Create random characters made of letters + if chars is None: + chars = string.ascii_letters + return ''.join(random.choice(chars) for x in range(size)) + Help_Mode = """Station WiFi modes: use the number value below: auto : 0, a : 1, diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index e060514f..5dbdd697 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -33,7 +33,7 @@ testCommands=( "./test_ipv4_l4.py --radio $RADIO_USED --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 2m" "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format excel" "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 30s --output_format csv" - #"./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000" + #"./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000"NAME #"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" #"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY" #"./create_macvlan.py --radio wiphy1" @@ -73,6 +73,7 @@ TEST_DIR="/home/lanforge/report-data/${NOW}" mkdir "$TEST_DIR" function run_test() { for i in "${testCommands[@]}"; do + NAME=python -c "import sys ; sys.path.append('../py-json') ; from LANforge.lfcli_base import LFCliBase ; lfcli=LFCliBase('localhost','8080') ; print(lfcli.random_chars(10))" CURR_TEST_NAME=${i%%.py*} CURR_TEST_NAME=${CURR_TEST_NAME#./*} CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" @@ -86,20 +87,20 @@ function run_test() { if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then echo_print echo "$i" - $i > "${TEST_DIR}/${i}.txt" 2> "${TEST_DIR}/${i}_stderr.txt" + $i > "${TEST_DIR}/${NAME}.txt" 2> "${TEST_DIR}/${NAME}_stderr.txt" retval=$? - grep -i fail "${TEST_DIR}/${i}.txt" && retval=1 - chmod 664 "${TEST_DIR}/${i}.txt" + grep -i fail "${TEST_DIR}/${NAME}.txt" && retval=1 + chmod 664 "${TEST_DIR}/${NAME}.txt" if (( $retval == 0 )); then results+=("${CURR_TEST_NAME}${i} Success - STDOUT - STDERR") + STDOUT + STDERR") else results+=("${CURR_TEST_NAME}${i} Failure - STDOUT - STDERR") + STDOUT + STDERR") fi fi From 6dc7b0609034334e8d0e5bafd601a4ac77edeee7 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Tue, 2 Feb 2021 15:24:04 -0800 Subject: [PATCH 240/848] regression test minor fix --- py-scripts/regression_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 5dbdd697..83f431a0 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -73,7 +73,7 @@ TEST_DIR="/home/lanforge/report-data/${NOW}" mkdir "$TEST_DIR" function run_test() { for i in "${testCommands[@]}"; do - NAME=python -c "import sys ; sys.path.append('../py-json') ; from LANforge.lfcli_base import LFCliBase ; lfcli=LFCliBase('localhost','8080') ; print(lfcli.random_chars(10))" + NAME=$(python -c "import sys ; sys.path.append('../py-json') ; from LANforge.lfcli_base import LFCliBase ; lfcli=LFCliBase('localhost','8080') ; print(lfcli.random_chars(10))") CURR_TEST_NAME=${i%%.py*} CURR_TEST_NAME=${CURR_TEST_NAME#./*} CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" From 568cec5c9021fc42509e365aee1578821b88396a Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 2 Feb 2021 15:55:38 -0800 Subject: [PATCH 241/848] added logic to decrement stations admin-ed up per batch --- py-scripts/test_1k_clients_jedtest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/py-scripts/test_1k_clients_jedtest.py b/py-scripts/test_1k_clients_jedtest.py index 4a917570..63cd8a7d 100755 --- a/py-scripts/test_1k_clients_jedtest.py +++ b/py-scripts/test_1k_clients_jedtest.py @@ -67,6 +67,16 @@ class Test1KClients(LFCliBase): self.cx_profile.side_b_max_bps = side_b_max_rate self.station_profile_map = {} + #change resource admin_up rate + self.local_realm.json_post("/cli-json/set_resource", { + "shelf":1, + "resource":all, + "max_staged_bringup": 30, + "max_trying_ifup": 15, + "max_station_bringup": 6 + }) + + def build(self): for (radio, name_series) in self.station_radio_map.items(): print("building stations for %s"%radio) From 5044c2c66ce9c98f2587f252bfac715cd60a9832 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 2 Feb 2021 17:20:37 -0700 Subject: [PATCH 242/848] test_l3_longevity.py : updates for new Realm --- py-scripts/test_l3_longevity.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index ce63353d..2e151834 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -121,9 +121,9 @@ class L3VariableTime(Realm): reset_port_max_time=self.duration_time_to_seconds(reset_port_time_max_)) self.station_profiles.append(self.station_profile) - self.multicast_profile.host = self.host - self.cx_profile.host = self.host - self.cx_profile.port = self.port + self.multicast_profile.host = self.lfclient_host + self.cx_profile.host = self.lfclient_host + self.cx_profile.port = self.lfclient_port 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 @@ -1059,7 +1059,7 @@ def main(): 1. Polling interval for checking traffic is fixed at 1 minute 2. The test will generate csv file 3. The tx/rx rates are fixed at 256000 bits per second - 4. Maximum stations per radio is 64 + 4. Maximum stations per radio based on radio ''', description='''\ @@ -1234,7 +1234,7 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr print("csv output file : {}".format(csv_outfile)) - MAX_NUMBER_OF_STATIONS = 64 + MAX_NUMBER_OF_STATIONS = 1000 radio_name_list = [] number_of_stations_per_radio_list = [] From 7f45190a049d2a9652730d91ea42ee9a63d128a6 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 2 Feb 2021 17:31:04 -0700 Subject: [PATCH 243/848] realm.py: changes for L3CX and Multicast --- py-json/realm.py | 85 +++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index f32ca4f1..73eb3827 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -888,7 +888,7 @@ class MULTICASTProfile(LFCliBase): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(local_realm) + super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ self.local_realm = local_realm @@ -934,7 +934,10 @@ class MULTICASTProfile(LFCliBase): pass - def cleanup(self, suppress_related_commands=None, debug_=False): + def cleanup_prefix(self): + self.local_realm.cleanup_cxe_prefix(self.name_prefix) + + def cleanup(self, suppress_related_commands=None, debug_ = False): if self.debug: debug_ = True @@ -1051,7 +1054,7 @@ class MULTICASTProfile(LFCliBase): pprint.pprint(self) -class L3CXProfile(BaseProfile): +class L3CXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, @@ -1071,6 +1074,7 @@ class L3CXProfile(BaseProfile): """ :param lfclient_host: :param lfclient_port: + :param local_realm: :param side_a_min_bps: :param side_b_min_bps: :param side_a_max_bps: @@ -1083,9 +1087,10 @@ class L3CXProfile(BaseProfile): :param number_template_: how many zeros wide we padd, possibly a starting integer with left padding :param debug_: """ - super().__init__(local_realm) + super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True) self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port) self.debug = debug_ + self.local_realm = local_realm self.side_a_min_pdu = side_a_min_pdu self.side_b_min_pdu = side_b_min_pdu self.side_a_max_pdu = side_a_max_pdu @@ -1166,6 +1171,8 @@ class L3CXProfile(BaseProfile): raise ValueError("Monitor needs a list of Layer 3 connections") if (monitor_interval is None) or (monitor_interval < 1): raise ValueError("L3CXProfile::monitor wants monitor_interval >= 1 second") + if col_names is None: + raise ValueError("L3CXProfile::monitor wants a list of column names to monitor") if output_format is not None: if output_format.lower() != report_file.split('.')[-1]: if output_format.lower() != 'excel': @@ -1308,28 +1315,26 @@ class L3CXProfile(BaseProfile): def stop_cx(self): print("Stopping CXs...") for cx_name in self.created_cx.keys(): - self.stopping_cx(cx_name) - if self.debug: - print(".", end='') - if self.debug: - print("") + self.local_realm.stop_cx(cx_name) + print(".", end='') + print("") def cleanup_prefix(self): - self.cleanup_cxe_prefix(self.name_prefix) + self.local_realm.cleanup_cxe_prefix(self.name_prefix) def cleanup(self): print("Cleaning up cxs and endpoints") if len(self.created_cx) != 0: for cx_name in self.created_cx.keys(): if self.debug: - print("Cleaning cx: %s" % (cx_name)) - self.rm_cx(cx_name) + print("Cleaning cx: %s"%(cx_name)) + self.local_realm.rm_cx(cx_name) for side in range(len(self.created_cx[cx_name])): ename = self.created_cx[cx_name][side] if self.debug: - print("Cleaning endpoint: %s" % (ename)) - self.rm_endp(self.created_cx[cx_name][side]) + print("Cleaning endpoint: %s"%(ename)) + self.local_realm.rm_endp(self.created_cx[cx_name][side]) def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): @@ -1351,12 +1356,12 @@ class L3CXProfile(BaseProfile): "side_a_min_bps, side_a_max_bps, side_b_min_bps, and side_b_max_bps must all be set to a value") if type(side_a) == list and type(side_b) != list: - side_b_info = self.name_to_eid(side_b) + side_b_info = self.local_realm.name_to_eid(side_b) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] for port_name in side_a: - side_a_info = self.name_to_eid(port_name) + side_a_info = self.local_realm.name_to_eid(port_name) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] if port_name.find('.') < 0: @@ -1398,11 +1403,9 @@ class L3CXProfile(BaseProfile): } url = "/cli-json/add_endp" - self.json_post(url, endp_side_a, debug_=debug_, - suppress_related_commands_=suppress_related_commands) - self.json_post(url, endp_side_b, debug_=debug_, - suppress_related_commands_=suppress_related_commands) - # print("napping %f sec"%sleep_time) + self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands) + #print("napping %f sec"%sleep_time) time.sleep(sleep_time) url = "cli-json/set_endp_flag" @@ -1411,24 +1414,20 @@ class L3CXProfile(BaseProfile): "flag": "AutoHelper", "val": 1 } - self.json_post(url, data, debug_=debug_, - suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) data["name"] = endp_b_name - self.json_post(url, data, debug_=debug_, - suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) if (endp_type == "lf_udp") or (endp_type == "udp") or (endp_type == "lf_udp6") or (endp_type == "udp6"): data["name"] = endp_a_name data["flag"] = "UseAutoNAT" - self.json_post(url, data, debug_=debug_, - suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) data["name"] = endp_b_name - self.json_post(url, data, debug_=debug_, - suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) if tos != None: - self.set_endp_tos(endp_a_name, tos) - self.set_endp_tos(endp_b_name, tos) + self.local_realm.set_endp_tos(endp_a_name, tos) + self.local_realm.set_endp_tos(endp_b_name, tos) data = { "alias": cx_name, @@ -1445,14 +1444,14 @@ class L3CXProfile(BaseProfile): }) elif type(side_b) == list and type(side_a) != list: - side_a_info = self.name_to_eid(side_a) + side_a_info = self.local_realm.name_to_eid(side_a) side_a_shelf = side_a_info[0] side_a_resource = side_a_info[1] # side_a_name = side_a_info[2] for port_name in side_b: print(side_b) - side_b_info = self.name_to_eid(port_name) + side_b_info = self.local_realm.name_to_eid(port_name) side_b_shelf = side_b_info[0] side_b_resource = side_b_info[1] side_b_name = side_b_info[2] @@ -1492,11 +1491,9 @@ class L3CXProfile(BaseProfile): } url = "/cli-json/add_endp" - self.json_post(url, endp_side_a, debug_=debug_, - suppress_related_commands_=suppress_related_commands) - self.json_post(url, endp_side_b, debug_=debug_, - suppress_related_commands_=suppress_related_commands) - # print("napping %f sec" %sleep_time ) + self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands) + #print("napping %f sec" %sleep_time ) time.sleep(sleep_time) url = "cli-json/set_endp_flag" @@ -1505,7 +1502,7 @@ class L3CXProfile(BaseProfile): "flag": "autohelper", "val": 1 } - self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) url = "cli-json/set_endp_flag" data = { @@ -1513,8 +1510,8 @@ class L3CXProfile(BaseProfile): "flag": "autohelper", "val": 1 } - self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) - # print("CXNAME451: %s" % cx_name) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + #print("CXNAME451: %s" % cx_name) data = { "alias": cx_name, "test_mgr": "default_tm", @@ -1532,14 +1529,14 @@ class L3CXProfile(BaseProfile): "side_a or side_b must be of type list but not both: side_a is type %s side_b is type %s" % ( type(side_a), type(side_b))) - self.wait_until_endps_appear(these_endp, debug=debug_) + self.local_realm.wait_until_endps_appear(these_endp, debug=debug_) for data in cx_post_data: url = "/cli-json/add_cx" - self.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) + self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands) time.sleep(0.01) - self.wait_until_cxs_appear(these_cx, debug=debug_) + self.local_realm.wait_until_cxs_appear(these_cx, debug=debug_) def to_string(self): pprint.pprint(self) From 12b044db8732694c89fa061052e69d35f55291f7 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Fri, 29 Jan 2021 16:03:10 -0800 Subject: [PATCH 244/848] create_vr.py: renaming parameters to --vr_names --- py-scripts/create_vr.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py index 90afd1bd..1252e241 100755 --- a/py-scripts/create_vr.py +++ b/py-scripts/create_vr.py @@ -26,8 +26,8 @@ class CreateVR(Realm): lfclient_host="localhost", lfclient_port=8080, debug=False, - vr_id=0, - resource=1, + # resource=1, # USE name=1.2.vr0 convention instead + vr_names=None, ports_list=[], services_list=[], _halt_on_error=False, @@ -43,8 +43,8 @@ class CreateVR(Realm): _exit_on_fail=_exit_on_fail, _proxy_str=_proxy_str, _capture_signal_list=_capture_signal_list) - self.vr_id = vr_id - self.resource = resource + self.vr_names = vr_names + self.ports_list = ports_list self.services_list = services_list self.vr_profile = self.new_vr_profile() self.vr_profile.resource=self.resource @@ -68,12 +68,13 @@ def main(): %s -------------------- Command example: -%s --vr_id 0 --resource 2 --ports br0,rdd0a --services br0=dhcp,nat +%s --vr_name 1.vr0 --ports 1.br0,1.rdd0a --services 1.br0=dhcp,nat --services 1.vr0=radvd +%s --vr_name 2.vr0 --ports 2.br0,2.vap2 --services --debug """) required = parser.add_argument_group('required arguments') - required.add_argument('--vr_id', help='ID of virtual router', default=0, required=False) + required.add_argument('--vr_name', '--vr_names', help='ID of virtual router', default="1.1.vr0", required=False) optional = parser.add_argument_group('optional arguments') optional.add_argument('--resource', help='Resource number to create virtual router on', default=1, required=False) @@ -85,8 +86,7 @@ Command example: create_vr = CreateVR(lfclient_host=args.mgr, lfclient_port=args.mgr_port, - vr_id=args.vr_id, - resource=1, + vr_names=args.vr_names, ports_list=args.ports, services_list=args.services, debug=args.debug, From 3f8c2735121db4821629145602755d50aafe8329 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Mon, 1 Feb 2021 09:40:42 -0800 Subject: [PATCH 245/848] create_vr.py WIP --- py-scripts/create_vr.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py index 1252e241..80362141 100755 --- a/py-scripts/create_vr.py +++ b/py-scripts/create_vr.py @@ -27,7 +27,7 @@ class CreateVR(Realm): lfclient_port=8080, debug=False, # resource=1, # USE name=1.2.vr0 convention instead - vr_names=None, + vr_name=None, ports_list=[], services_list=[], _halt_on_error=False, @@ -43,17 +43,16 @@ class CreateVR(Realm): _exit_on_fail=_exit_on_fail, _proxy_str=_proxy_str, _capture_signal_list=_capture_signal_list) - self.vr_names = vr_names + + eid_name = self.name_to_eid(vr_name) + self.vr_name = eid_name self.ports_list = ports_list self.services_list = services_list self.vr_profile = self.new_vr_profile() - self.vr_profile.resource=self.resource def build(self): - self.vr_profile.create(resource=self.resource, - vr_id=self.vr_id, - upstream_port="up0", + self.vr_profile.create(upstream_port="up0", upstream_subnets="10.0.0.0/24", upstream_nexthop="10.0.0.1", local_nexthop="10.1.0.1", @@ -65,19 +64,19 @@ def main(): parser = LFCliBase.create_bare_argparse( prog=__file__, description="""\ -%s +{f} -------------------- Command example: -%s --vr_name 1.vr0 --ports 1.br0,1.rdd0a --services 1.br0=dhcp,nat --services 1.vr0=radvd -%s --vr_name 2.vr0 --ports 2.br0,2.vap2 --services +{f} --vr_name 1.vr0 --ports 1.br0,1.rdd0a --services 1.br0=dhcp,nat --services 1.vr0=radvd +{f} --vr_name 2.vr0 --ports 2.br0,2.vap2 --services --debug -""") +""".format(f=__file__)) required = parser.add_argument_group('required arguments') - required.add_argument('--vr_name', '--vr_names', help='ID of virtual router', default="1.1.vr0", required=False) + required.add_argument('--vr_name', '--vr_names', help='EID of virtual router, like 1.2.vr0', default="1.1.vr0", required=False) optional = parser.add_argument_group('optional arguments') - optional.add_argument('--resource', help='Resource number to create virtual router on', default=1, required=False) + optional.add_argument('--ports', help='Comma separated list of ports to add to virtual router', default=None, required=False) optional.add_argument('--services', help='Add router services to a port, "br0=nat,dhcp"', default=None, required=False) @@ -86,7 +85,7 @@ Command example: create_vr = CreateVR(lfclient_host=args.mgr, lfclient_port=args.mgr_port, - vr_names=args.vr_names, + vr_name=args.vr_name, ports_list=args.ports, services_list=args.services, debug=args.debug, From 088659b9ad10c85cdafdd72f13f8a9efd4f3b621 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 2 Feb 2021 15:25:17 -0800 Subject: [PATCH 246/848] create_vr.py: removes use of halt parameter --- py-scripts/create_vr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py index 80362141..d46b831c 100755 --- a/py-scripts/create_vr.py +++ b/py-scripts/create_vr.py @@ -38,7 +38,6 @@ class CreateVR(Realm): super().__init__(lfclient_host=lfclient_host, lfclient_port=lfclient_port, debug_=debug, - halt_on_error_=_halt_on_error, _exit_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail, _proxy_str=_proxy_str, From 2e6a5bd5df763c6a66993693f8d06a9afd854fae Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 2 Feb 2021 15:27:28 -0800 Subject: [PATCH 247/848] realm.py: adds note to remove halt_on_error in future; changes check on vr_name to gaurd --- py-json/realm.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index 73eb3827..e9d41c32 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -55,7 +55,7 @@ class Realm(LFCliBase): lfclient_host="localhost", lfclient_port=8080, debug_=False, - halt_on_error_=False, + halt_on_error_=False, # remove me _exit_on_error=False, _exit_on_fail=False, # _local_realm=None, @@ -2584,7 +2584,7 @@ class VRProfile(BaseProfile): def create(self, resource=1, - vr_id=0, + vr_name=None, upstream_port="eth1", upstream_subnets="20.20.20.0/24", upstream_nexthop="20.20.20.1", @@ -2598,11 +2598,13 @@ class VRProfile(BaseProfile): # Create vr if self.debug: debug = True - if self.vr_name is not None: - self.add_vr_data["alias"] = self.vr_name - self.json_post("/cli-json/add_vr", self.add_vr_data, debug_=debug) - else: + if self.vr_name is None: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) + + self.add_vr_data["alias"] = self.vr_name + self.json_post("/cli-json/add_vr", self.add_vr_data, debug_=debug) + + # Create 1 rdd pair self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network From a2d78418707c3ca614ae36f5b679d09cc029dd19 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 2 Feb 2021 15:27:54 -0800 Subject: [PATCH 248/848] lfcli_base.py: adds -d for debug to bare argparse --- py-json/LANforge/lfcli_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 7758c7e0..dc56dd7c 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -480,7 +480,7 @@ class LFCliBase: required = parser.add_argument_group('required arguments') optional.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost') optional.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080) - optional.add_argument('--debug', help='Enable debugging', default=False, action="store_true") + optional.add_argument('--debug', '-d', help='Enable debugging', default=False, action="store_true") optional.add_argument('--proxy', nargs='?', default=None, # action=ProxyAction, help='Connection proxy like http://proxy.localnet:80 or https://user:pass@proxy.localnet:3128') From f2504bdf98d881603495978d5007616cfce30631 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 2 Feb 2021 20:54:36 -0800 Subject: [PATCH 249/848] extracts class VRProfile from realm.py --- py-json/realm.py | 167 +---------------------------------------- py-json/vr_profile.py | 168 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 165 deletions(-) create mode 100644 py-json/vr_profile.py diff --git a/py-json/realm.py b/py-json/realm.py index e9d41c32..a1b86c65 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -828,6 +828,8 @@ class Realm(LFCliBase): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) def new_vr_profile(self): + import vr_profile + from vr_profile import VRProfile profile = VRProfile(local_realm=self, debug=self.debug) return profile @@ -2455,171 +2457,6 @@ class VAPProfile(LFCliBase): LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_ports) -class VRProfile(BaseProfile): - """ - Virtual Router profile - """ - def __init__(self, - local_realm, - vr_id=0, - debug=False): - super().__init__(local_realm=local_realm, - debug=debug) - self.vr_name = vr_id - self.created_rdds = [] - self.created_vrcxs = [] - - self.add_vr_data = { - "alias": None, - "shelf": 1, - "resource": 1, - "x": 100, - "y": 100, - "width": 250, - "height": 250, - "flags": 0 - } - - self.vrcx_data = { - 'shelf': 1, - 'resource': 1, - 'vr-name': None, - 'local_dev': None, # outer rdd - 'remote_dev': None, # inner rdd - "x": 0, - "y": 0, - "width": 10, - "height": 10, - 'flags': 0, - "subnets": None, - "nexthop": None, - "vrrp_ip": "0.0.0.0" - } - - self.set_port_data = { - "shelf": 1, - "resource": 1, - "port": None, - "ip_addr": None, - "netmask": None, - "gateway": None - } - - def create_rdd(self, - resource=1, - ip_addr=None, - netmask=None, - gateway=None, - suppress_related_commands_=True, - debug_=False): - rdd_data = { - "shelf": 1, - "resource": resource, - "port": "rdd0", - "peer_ifname": "rdd1" - } - # print("creating rdd0") - self.json_post("/cli-json/add_rdd", - rdd_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - rdd_data = { - "shelf": 1, - "resource": resource, - "port": "rdd1", - "peer_ifname": "rdd0" - } - # print("creating rdd1") - self.json_post("/cli-json/add_rdd", - rdd_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - self.set_port_data["port"] = "rdd0" - self.set_port_data["ip_addr"] = gateway - self.set_port_data["netmask"] = netmask - self.set_port_data["gateway"] = gateway - self.json_post("/cli-json/set_port", - self.set_port_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - self.set_port_data["port"] = "rdd1" - self.set_port_data["ip_addr"] = ip_addr - self.set_port_data["netmask"] = netmask - self.set_port_data["gateway"] = gateway - self.json_post("/cli-json/set_port", - self.set_port_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - self.created_rdds.append("rdd0") - self.created_rdds.append("rdd1") - - def create_vrcx(self, - resource=1, - local_dev=None, - remote_dev=None, - subnets=None, - nexthop=None, - flags=0, - suppress_related_commands_=True, - debug_=False): - if self.vr_name is not None: - self.vrcx_data["resource"] = resource - self.vrcx_data["vr_name"] = self.vr_name - self.vrcx_data["local_dev"] = local_dev - self.vrcx_data["remote_dev"] = remote_dev - self.vrcx_data["subnets"] = subnets - self.vrcx_data["nexthop"] = nexthop - self.vrcx_data["flags"] = flags - self.json_post("/cli-json/add_vrcx", - self.vrcx_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - else: - raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - - - def create(self, - resource=1, - vr_name=None, - upstream_port="eth1", - upstream_subnets="20.20.20.0/24", - upstream_nexthop="20.20.20.1", - local_subnets="10.40.0.0/24", - local_nexthop="10.40.3.198", - rdd_ip="20.20.20.20", - rdd_gateway="20.20.20.1", - rdd_netmask="255.255.255.0", - debug=False, - suppress_related_commands_=True): - # Create vr - if self.debug: - debug = True - if self.vr_name is None: - raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - - self.add_vr_data["alias"] = self.vr_name - self.json_post("/cli-json/add_vr", self.add_vr_data, debug_=debug) - - - # Create 1 rdd pair - self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, - netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network - - # connect rdds and upstream - self.create_vrcx(resource=resource, local_dev=upstream_port, remote_dev="NA", subnets=upstream_subnets, - nexthop=upstream_nexthop, - flags=257, suppress_related_commands_=suppress_related_commands_, debug_=debug) - self.create_vrcx(resource=resource, local_dev="rdd0", remote_dev="rdd1", subnets=local_subnets, - nexthop=local_nexthop, - flags=1, suppress_related_commands_=suppress_related_commands_, debug_=debug) - - def cleanup(self, resource, delay=0.03): - # TODO: Cleanup for VRProfile - pass class DUTProfile(LFCliBase): diff --git a/py-json/vr_profile.py b/py-json/vr_profile.py new file mode 100644 index 00000000..6f7f51d6 --- /dev/null +++ b/py-json/vr_profile.py @@ -0,0 +1,168 @@ +import realm +from realm import BaseProfile + +class VRProfile(BaseProfile): + """ + Virtual Router profile + """ + def __init__(self, + local_realm, + vr_id=0, + debug=False): + super().__init__(local_realm=local_realm, + debug=debug) + self.vr_name = vr_id + self.created_rdds = [] + self.created_vrcxs = [] + + self.add_vr_data = { + "alias": None, + "shelf": 1, + "resource": 1, + "x": 100, + "y": 100, + "width": 250, + "height": 250, + "flags": 0 + } + + self.vrcx_data = { + 'shelf': 1, + 'resource': 1, + 'vr-name': None, + 'local_dev': None, # outer rdd + 'remote_dev': None, # inner rdd + "x": 0, + "y": 0, + "width": 10, + "height": 10, + 'flags': 0, + "subnets": None, + "nexthop": None, + "vrrp_ip": "0.0.0.0" + } + + self.set_port_data = { + "shelf": 1, + "resource": 1, + "port": None, + "ip_addr": None, + "netmask": None, + "gateway": None + } + + def create_rdd(self, + resource=1, + ip_addr=None, + netmask=None, + gateway=None, + suppress_related_commands_=True, + debug_=False): + rdd_data = { + "shelf": 1, + "resource": resource, + "port": "rdd0", + "peer_ifname": "rdd1" + } + # print("creating rdd0") + self.json_post("/cli-json/add_rdd", + rdd_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) + + rdd_data = { + "shelf": 1, + "resource": resource, + "port": "rdd1", + "peer_ifname": "rdd0" + } + # print("creating rdd1") + self.json_post("/cli-json/add_rdd", + rdd_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) + + self.set_port_data["port"] = "rdd0" + self.set_port_data["ip_addr"] = gateway + self.set_port_data["netmask"] = netmask + self.set_port_data["gateway"] = gateway + self.json_post("/cli-json/set_port", + self.set_port_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) + + self.set_port_data["port"] = "rdd1" + self.set_port_data["ip_addr"] = ip_addr + self.set_port_data["netmask"] = netmask + self.set_port_data["gateway"] = gateway + self.json_post("/cli-json/set_port", + self.set_port_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) + + self.created_rdds.append("rdd0") + self.created_rdds.append("rdd1") + + def create_vrcx(self, + resource=1, + local_dev=None, + remote_dev=None, + subnets=None, + nexthop=None, + flags=0, + suppress_related_commands_=True, + debug_=False): + if self.vr_name is not None: + self.vrcx_data["resource"] = resource + self.vrcx_data["vr_name"] = self.vr_name + self.vrcx_data["local_dev"] = local_dev + self.vrcx_data["remote_dev"] = remote_dev + self.vrcx_data["subnets"] = subnets + self.vrcx_data["nexthop"] = nexthop + self.vrcx_data["flags"] = flags + self.json_post("/cli-json/add_vrcx", + self.vrcx_data, + suppress_related_commands_=suppress_related_commands_, + debug_=debug_) + else: + raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) + + + def create(self, + resource=1, + vr_name=None, + upstream_port="eth1", + upstream_subnets="20.20.20.0/24", + upstream_nexthop="20.20.20.1", + local_subnets="10.40.0.0/24", + local_nexthop="10.40.3.198", + rdd_ip="20.20.20.20", + rdd_gateway="20.20.20.1", + rdd_netmask="255.255.255.0", + debug=False, + suppress_related_commands_=True): + # Create vr + if self.debug: + debug = True + if self.vr_name is None: + raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) + + self.add_vr_data["alias"] = self.vr_name + self.json_post("/cli-json/add_vr", self.add_vr_data, debug_=debug) + + + # # Create 1 rdd pair + # self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, + # netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network + # + # # connect rdds and upstream + # self.create_vrcx(resource=resource, local_dev=upstream_port, remote_dev="NA", subnets=upstream_subnets, + # nexthop=upstream_nexthop, + # flags=257, suppress_related_commands_=suppress_related_commands_, debug_=debug) + # self.create_vrcx(resource=resource, local_dev="rdd0", remote_dev="rdd1", subnets=local_subnets, + # nexthop=local_nexthop, + # flags=1, suppress_related_commands_=suppress_related_commands_, debug_=debug) + + def cleanup(self, resource, delay=0.03): + # TODO: Cleanup for VRProfile + pass From 45cede98a20b623c91cda6e3745bab3b565267b3 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 2 Feb 2021 21:17:57 -0800 Subject: [PATCH 250/848] vr_profile.py: updates can now create a basic VR in Netsmith --- py-json/vr_profile.py | 157 +++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 80 deletions(-) diff --git a/py-json/vr_profile.py b/py-json/vr_profile.py index 6f7f51d6..57a23b3b 100644 --- a/py-json/vr_profile.py +++ b/py-json/vr_profile.py @@ -1,4 +1,6 @@ import realm +from realm import Realm +import random from realm import BaseProfile class VRProfile(BaseProfile): @@ -7,49 +9,37 @@ class VRProfile(BaseProfile): """ def __init__(self, local_realm, - vr_id=0, debug=False): super().__init__(local_realm=local_realm, debug=debug) - self.vr_name = vr_id + self.vr_eid = None self.created_rdds = [] self.created_vrcxs = [] - self.add_vr_data = { - "alias": None, - "shelf": 1, - "resource": 1, - "x": 100, - "y": 100, - "width": 250, - "height": 250, - "flags": 0 - } - - self.vrcx_data = { - 'shelf': 1, - 'resource': 1, - 'vr-name': None, - 'local_dev': None, # outer rdd - 'remote_dev': None, # inner rdd - "x": 0, - "y": 0, - "width": 10, - "height": 10, - 'flags': 0, - "subnets": None, - "nexthop": None, - "vrrp_ip": "0.0.0.0" - } - - self.set_port_data = { - "shelf": 1, - "resource": 1, - "port": None, - "ip_addr": None, - "netmask": None, - "gateway": None - } + # self.vrcx_data = { + # 'shelf': 1, + # 'resource': 1, + # 'vr-name': None, + # 'local_dev': None, # outer rdd + # 'remote_dev': None, # inner rdd + # "x": 200+ran, + # "y": 0, + # "width": 10, + # "height": 10, + # 'flags': 0, + # "subnets": None, + # "nexthop": None, + # "vrrp_ip": "0.0.0.0" + # } + # + # self.set_port_data = { + # "shelf": 1, + # "resource": 1, + # "port": None, + # "ip_addr": None, + # "netmask": None, + # "gateway": None + # } def create_rdd(self, resource=1, @@ -67,8 +57,7 @@ class VRProfile(BaseProfile): # print("creating rdd0") self.json_post("/cli-json/add_rdd", rdd_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) + ) rdd_data = { "shelf": 1, @@ -77,31 +66,31 @@ class VRProfile(BaseProfile): "peer_ifname": "rdd0" } # print("creating rdd1") - self.json_post("/cli-json/add_rdd", - rdd_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - self.set_port_data["port"] = "rdd0" - self.set_port_data["ip_addr"] = gateway - self.set_port_data["netmask"] = netmask - self.set_port_data["gateway"] = gateway - self.json_post("/cli-json/set_port", - self.set_port_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - self.set_port_data["port"] = "rdd1" - self.set_port_data["ip_addr"] = ip_addr - self.set_port_data["netmask"] = netmask - self.set_port_data["gateway"] = gateway - self.json_post("/cli-json/set_port", - self.set_port_data, - suppress_related_commands_=suppress_related_commands_, - debug_=debug_) - - self.created_rdds.append("rdd0") - self.created_rdds.append("rdd1") + # self.json_post("/cli-json/add_rdd", + # rdd_data, + # suppress_related_commands_=suppress_related_commands_, + # debug_=debug_) + # + # self.set_port_data["port"] = "rdd0" + # self.set_port_data["ip_addr"] = gateway + # self.set_port_data["netmask"] = netmask + # self.set_port_data["gateway"] = gateway + # self.json_post("/cli-json/set_port", + # self.set_port_data, + # suppress_related_commands_=suppress_related_commands_, + # debug_=debug_) + # + # self.set_port_data["port"] = "rdd1" + # self.set_port_data["ip_addr"] = ip_addr + # self.set_port_data["netmask"] = netmask + # self.set_port_data["gateway"] = gateway + # self.json_post("/cli-json/set_port", + # self.set_port_data, + # suppress_related_commands_=suppress_related_commands_, + # debug_=debug_) + # + # self.created_rdds.append("rdd0") + # self.created_rdds.append("rdd1") def create_vrcx(self, resource=1, @@ -127,30 +116,36 @@ class VRProfile(BaseProfile): else: raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - def create(self, - resource=1, vr_name=None, - upstream_port="eth1", - upstream_subnets="20.20.20.0/24", - upstream_nexthop="20.20.20.1", - local_subnets="10.40.0.0/24", - local_nexthop="10.40.3.198", - rdd_ip="20.20.20.20", - rdd_gateway="20.20.20.1", - rdd_netmask="255.255.255.0", + upstream_port=None, + upstream_subnets=[], + upstream_nexthop=None, + local_subnets=[], + local_nexthop=None, debug=False, suppress_related_commands_=True): # Create vr if self.debug: debug = True - if self.vr_name is None: - raise ValueError("vr_name must be set. Current name: %s" % self.vr_name) - - self.add_vr_data["alias"] = self.vr_name - self.json_post("/cli-json/add_vr", self.add_vr_data, debug_=debug) - + if vr_name is None: + raise ValueError("vr_name must be set. Current name: %s" % vr_name) + self.vr_eid = self.parent_realm.name_to_eid(vr_name) + from random import randint + x = randint(100, 200) + y = randint(100, 200) + self.add_vr_data = { + "alias": self.vr_eid[2], + "shelf": 1, + "resource": self.vr_eid[1], + "x": x, + "y": y, + "width": 250, + "height": 250, + "flags": 0 + } + self.json_post("/cli-json/add_vr", self.add_vr_data) # # Create 1 rdd pair # self.create_rdd(resource=resource, ip_addr=rdd_ip, gateway=rdd_gateway, # netmask=rdd_netmask) # rdd0, rdd1; rdd0 gateway, rdd1 connected to network @@ -166,3 +161,5 @@ class VRProfile(BaseProfile): def cleanup(self, resource, delay=0.03): # TODO: Cleanup for VRProfile pass + +# \ No newline at end of file From 052779ad0649a185e4740d6abbb01f7d228b80be Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 2 Feb 2021 21:19:16 -0800 Subject: [PATCH 251/848] create_vr.py: WIP can now create bare VR --- py-scripts/create_vr.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py index d46b831c..b970dee1 100755 --- a/py-scripts/create_vr.py +++ b/py-scripts/create_vr.py @@ -4,9 +4,8 @@ Script for creating a variable number of bridges. """ -import sys import os -import argparse +import sys if sys.version_info[0] != 3: print("This script requires Python 3") @@ -14,12 +13,9 @@ if sys.version_info[0] != 3: if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils from realm import Realm -import time -import pprint + class CreateVR(Realm): def __init__(self, @@ -51,12 +47,14 @@ class CreateVR(Realm): def build(self): - self.vr_profile.create(upstream_port="up0", - upstream_subnets="10.0.0.0/24", - upstream_nexthop="10.0.0.1", - local_nexthop="10.1.0.1", - local_subnets="10.1.0.0/24", - debug=self.debug) + self.vr_profile.create( + vr_name="1.1.vr9", + upstream_port="up0", + upstream_subnets="10.0.0.0/24", + upstream_nexthop="10.0.0.1", + local_nexthop="10.1.0.1", + local_subnets="10.1.0.0/24", + debug=self.debug) def main(): From df7e5a89b1e212e3bdaf78e8a1af762d81bc7478 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Wed, 3 Feb 2021 10:48:32 -0800 Subject: [PATCH 252/848] fixing urls per ten --- py-json/realm.py | 112 ++++++++++++++++------------------ py-scripts/regression_test.sh | 16 ++--- 2 files changed, 60 insertions(+), 68 deletions(-) diff --git a/py-json/realm.py b/py-json/realm.py index a1b86c65..974241fa 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1554,6 +1554,8 @@ class L4CXProfile(LFCliBase): self.local_realm = local_realm self.created_cx = {} self.created_endp = [] + self.lfclient_port = lfclient_port + self.lfclient_host = lfclient_host def check_errors(self, debug=False): fields_list = ["!conn", "acc.+denied", "bad-proto", "bad-url", "other-err", "total-err", "rslv-p", "rslv-h", @@ -1764,68 +1766,56 @@ class L4CXProfile(LFCliBase): time.sleep(monitor_interval) print(value_map) - # step 3 organize data - endpoints = list() - for endpoint in value_map.values(): - endpoints.append(endpoint['endpoint']) - endpoints2 = [] - for y in range(0, len(endpoints)): - for x in range(0, len(endpoints[0])): - endpoints2.append(list(list(endpoints[y][x].values())[0].values())) - import itertools - timestamps2 = list( - itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) - for point in range(0, len(endpoints2)): - endpoints2[point].insert(0, timestamps2[point]) - # step 4 save and close - header_row = col_names - header_row.insert(0, 'Timestamp') - print(header_row) + #organize data + full_test_data_list = [] + for test_timestamp, data in value_map.items(): + #reduce the endpoint data to single dictionary of dictionaries + for datum in data["endpoint"]: + for endpoint_data in datum.values(): + if debug: + print(endpoint_data) + endpoint_data["Timestamp"] = test_timestamp + full_test_data_list.append(endpoint_data) + + + header_row.append("Timestamp") + header_row.append('Timestamp milliseconds') + df = pd.DataFrame(full_test_data_list) + + df["Timestamp milliseconds"] = (df["Timestamp"] - datetime.datetime(1970,1,1)).dt.total_seconds()*1000 + #round entire column + df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int) + df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S")) + df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]] + #compare previous data to current data + + try: + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) + except: + systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) + + df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] + df['Script Name'] = script_name + df['Arguments'] = arguments + + for x in ['LFGUI Release', 'Script Name', 'Arguments']: + df[x][1:] = '' + if output_format == 'hdf': + df.to_hdf(report_file, 'table', append=True) + if output_format == 'parquet': + df.to_parquet(report_file, engine='pyarrow') + if output_format == 'png': + fig = df.plot().get_figure() + fig.savefig(report_file) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': - report_fh = open(report_file, "w+") - workbook = xlsxwriter.Workbook(report_file) - worksheet = workbook.add_worksheet() - for col_num, data in enumerate(header_row): - worksheet.write(0, col_num, data) - row_num = 1 - for x in endpoints2: - for col_num, data in enumerate(x): - worksheet.write(row_num, col_num, str(data)) - row_num += 1 - workbook.close() - else: - df = pd.DataFrame(endpoints2) - print(header_row) - df.columns = header_row - import requests - import ast - try: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) - except: - systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text) - df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion'] - df['Script Name'] = script_name - df['Arguments'] = arguments - for x in ['LFGUI Release', 'Script Name', 'Arguments']: - df[x][1:] = '' - if output_format == 'hdf': - df.to_hdf(report_file, 'table', append=True) - if output_format == 'parquet': - df.to_parquet(report_file, engine='pyarrow') - if output_format == 'png': - fig = df.plot().get_figure() - fig.savefig(report_file) - if output_format == 'html': - df.to_html(report_file) - if output_format == 'df': - return df - supported_formats = ['csv', 'json', 'stata', 'pickle'] - for x in supported_formats: - if output_format.lower() == x or report_file.split('.')[-1] == x: - exec('df.to_' + x + '("' + report_file + '")') - else: - pass -#end of L4CXProf class + df.to_excel(report_file, index=False) + if output_format == 'df': + return df + supported_formats = ['csv', 'json', 'stata', 'pickle','html'] + for x in supported_formats: + if output_format.lower() == x or report_file.split('.')[-1] == x: + exec('df.to_' + x + '("'+report_file+'")') + class GenCXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 83f431a0..72411432 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -73,7 +73,11 @@ TEST_DIR="/home/lanforge/report-data/${NOW}" mkdir "$TEST_DIR" function run_test() { for i in "${testCommands[@]}"; do - NAME=$(python -c "import sys ; sys.path.append('../py-json') ; from LANforge.lfcli_base import LFCliBase ; lfcli=LFCliBase('localhost','8080') ; print(lfcli.random_chars(10))") + chars=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + for i in {1..10} ; do + NAME+= + done + NAME=$(python3 -c "import sys ; sys.path.append('../py-json') ; from LANforge.lfcli_base import LFCliBase ; lfcli=LFCliBase('localhost','8080') ; print(lfcli.random_chars(10))") CURR_TEST_NAME=${i%%.py*} CURR_TEST_NAME=${CURR_TEST_NAME#./*} CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}" @@ -94,13 +98,13 @@ function run_test() { if (( $retval == 0 )); then results+=("${CURR_TEST_NAME}${i} Success - STDOUT - STDERR") + STDOUT + ") else results+=("${CURR_TEST_NAME}${i} Failure - STDOUT - STDERR") + STDOUT + STDERR") fi fi @@ -116,7 +120,6 @@ function check_args() { fi } function html_generator() { - NOW=$(date +"%Y-%m-%d-%T") header=" Test All Scripts Results $NOW @@ -152,7 +155,6 @@ function html_generator() { " fname="/home/lanforge/html-reports/test_all_output_file-${NOW}.html" - echo $fname >> $fname echo "$header" >> $fname echo "${results[@]}" >> $fname echo "" >> $fname From 6ddc64d1907c694afa96f737085852655c276741 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 3 Feb 2021 11:52:15 -0700 Subject: [PATCH 253/848] test_l3_longevity.py: configurable wait at end of test --- py-scripts/test_l3_longevity.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 2e151834..00529839 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -1204,6 +1204,7 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr \"radio== ssid== ssid_pw== security==\" '\ , required=True) parser.add_argument("--cap_ctl_out", help="--cap_ctl_out , switch the cisco controller output will be captured", action='store_true') + parser.add_argument("--wait", help="--wait