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

This commit is contained in:
Ben Greear
2021-04-22 10:13:15 -07:00
141 changed files with 24521 additions and 9184 deletions

View File

@@ -15,15 +15,13 @@ if 'py-json' not in sys.path:
sys.path.append('../py-json')
import argparse
import LANforge
from LANforge import LFUtils
# from LANforge import LFCliBase
from LANforge import lfcli_base
from LANforge.lfcli_base import LFCliBase
from LANforge.LFUtils import *
import realm
from realm import Realm
import pprint
from influx import RecordInflux
import time
OPEN="open"
WEP="wep"
@@ -35,6 +33,8 @@ MODE_AUTO=0
class StaConnect2(LFCliBase):
def __init__(self, host, port, _dut_ssid="jedway-open-1", _dut_passwd="NA", _dut_bssid="",
_user="", _passwd="", _sta_mode="0", _radio="wiphy0",
_influx_host=None, _influx_db=None, _influx_user=None,
_influx_passwd=None,
_resource=1, _upstream_resource=1, _upstream_port="eth1",
_sta_name=None, _sta_prefix='sta', _bringup_time_sec=300,
debug_=False, _dut_security=OPEN, _exit_on_error=False,
@@ -42,7 +42,7 @@ class StaConnect2(LFCliBase):
# do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn)
# that is py2 era syntax and will force self into the host variable, making you
# very confused.
super().__init__(host, port, _debug=debug_, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
super().__init__(host, port, _debug=debug_, _exit_on_fail=_exit_on_fail)
self.debug = debug_
self.dut_security = _dut_security
self.dut_ssid = _dut_ssid
@@ -72,6 +72,10 @@ class StaConnect2(LFCliBase):
self.station_profile = None
self.l3_udp_profile = None
self.l3_tcp_profile = None
self.influx_host = _influx_host
self.influx_db = _influx_db
self.influx_user = _influx_user
self.influx_passwd = _influx_passwd
# def get_realm(self) -> Realm: # py > 3.6
def get_realm(self):
@@ -216,6 +220,16 @@ class StaConnect2(LFCliBase):
self.station_profile.admin_up()
LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names)
if self.influx_db is not None:
grapher = RecordInflux(_influx_host=self.influx_host,
_influx_db=self.influx_db,
_influx_user=self.influx_user,
_influx_passwd=self.influx_passwd,
_longevity=1,
_devices=self.station_names,
_monitor_interval=1,
_target_kpi=['bps rx'])
# station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl()))
duration = 0
maxTime = self.bringup_time_sec
@@ -254,6 +268,9 @@ class StaConnect2(LFCliBase):
"probe_flags": 1
}
self.json_post("/cli-json/nc_show_ports", data)
if self.influx_db is not None:
grapher.getdata()
LFUtils.wait_until_ports_appear()
for sta_name in self.station_names:
sta_url = self.get_station_url(sta_name)
@@ -391,6 +408,12 @@ Example:
parser.add_argument("--debug", type=str, help="enable debugging")
parser.add_argument("--prefix", type=str, help="Station prefix. Default: 'sta'", default='sta')
parser.add_argument("--bringup_time", type=int, help="Seconds to wait for stations to associate and aquire IP. Default: 300", default=300)
parser.add_argument('--influx_user', help='Username for your Influx database', default=None)
parser.add_argument('--influx_passwd', help='Password for your Influx database', default=None)
parser.add_argument('--influx_db', help='Name of your Influx database', default=None)
parser.add_argument('--influx_host', help='Host of your influx database if different from the system you are running on', default='localhost')
parser.add_argument('--monitor_interval', help='How frequently you want to append to your database', default='5s')
args = parser.parse_args()
if args.dest is not None:
lfjson_host = args.dest
@@ -405,8 +428,13 @@ Example:
staConnect = StaConnect2(lfjson_host, lfjson_port,
debug_=True,
_influx_db = args.influx_db,
_influx_passwd = args.influx_passwd,
_influx_user = args.influx_user,
_influx_host = args.influx_host,
_exit_on_fail=True,
_exit_on_error=False)
if args.user is not None:
staConnect.user = args.user
if args.passwd is not None:
@@ -438,6 +466,7 @@ Example:
staConnect.setup()
staConnect.start()
print("napping %f sec" % staConnect.runtime_secs)
time.sleep(staConnect.runtime_secs)
staConnect.stop()
run_results = staConnect.get_result_list()