From 1d7578251c2dc8660838cf27ae02e51178a519ff Mon Sep 17 00:00:00 2001 From: erinnerim Date: Wed, 15 Sep 2021 16:17:16 -0700 Subject: [PATCH] Updates to import statements: - Import importlib, os, and sys to each python script. - Append "lanforge-scripts" root directory to the system path, allowing each script to be called from an antecedent directory. e.g. if 'lanforge-scripts' not in sys.path: sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) - All statements of the form 'from import ' replace with: = importlib.import_module("lanforge-scripts..") = . --- py-dashboard/GhostRequest.py | 22 +- py-json/LANforge/LFRequest.py | 16 +- py-json/LANforge/LFUtils.py | 18 +- py-json/LANforge/lf_json_autogen.py | 18 +- py-json/LANforge/lfcli_base.py | 23 ++- py-json/LANforge/set_port.py | 18 +- py-json/__init__.py | 5 - py-json/base_profile.py | 4 +- py-json/create_wanlink.py | 9 +- py-json/cv_dut_profile.py | 20 +- py-json/cv_test_manager.py | 29 ++- py-json/dataplane_test_profile.py | 9 +- py-json/dut_profile.py | 13 +- py-json/fio_endp_profile.py | 20 +- py-json/gen_cxprofile.py | 16 +- py-json/http_profile.py | 15 +- py-json/l3_cxprofile.py | 10 +- py-json/l3_cxprofile2.py | 12 +- py-json/l4_cxprofile.py | 13 +- py-json/lf_attenmod.py | 14 +- py-json/lf_cv_base.py | 11 +- py-json/mac_vlan_profile.py | 16 +- py-json/multicast_profile.py | 11 +- py-json/qvlan_profile.py | 15 +- py-json/realm.py | 87 +++++--- py-json/realm_test.py | 17 +- py-json/show_ports.py | 12 +- py-json/station_profile.py | 43 ++-- py-json/test_base.py | 12 +- py-json/test_group_profile.py | 10 +- py-json/test_histogram.py | 11 +- py-json/test_utility.py | 25 ++- py-json/vap_profile.py | 56 +++--- py-json/vr_profile2.py | 13 +- py-json/wifi_monitor_profile.py | 16 +- py-json/ws-sta-monitor.py | 23 ++- py-scripts/cicd_TipIntegration.py | 7 +- py-scripts/connection_test.py | 30 +-- py-scripts/create_bond.py | 20 +- py-scripts/create_bridge.py | 20 +- py-scripts/create_chamberview.py | 12 +- py-scripts/create_chamberview_dut.py | 15 +- py-scripts/create_l3.py | 165 +++++---------- py-scripts/create_l4.py | 24 ++- py-scripts/create_macvlan.py | 23 ++- py-scripts/create_qvlan.py | 20 +- py-scripts/create_station.py | 18 +- py-scripts/create_station_from_df.py | 18 +- py-scripts/create_vap.py | 22 +- py-scripts/create_vr.py | 23 ++- py-scripts/csv_convert.py | 8 +- py-scripts/csv_processor.py | 15 +- py-scripts/csv_to_grafana.py | 29 ++- py-scripts/csv_to_influx.py | 20 +- py-scripts/cv_manager.py | 13 +- py-scripts/cv_to_grafana.py | 24 ++- py-scripts/download_test.py | 20 +- py-scripts/event_breaker.py | 27 ++- py-scripts/event_flood.py | 25 ++- py-scripts/example_security_connection.py | 25 ++- py-scripts/ghost_profile.py | 10 +- py-scripts/grafana_profile.py | 16 +- py-scripts/influx.py | 20 +- py-scripts/layer3_test.py | 26 +-- py-scripts/layer4_test.py | 42 ++-- py-scripts/lf_ap_auto_test.py | 13 +- py-scripts/lf_atten_mod_test.py | 24 ++- py-scripts/lf_csv.py | 2 +- py-scripts/lf_dataplane_test.py | 13 +- py-scripts/lf_dfs_test.py | 27 ++- py-scripts/lf_dut_sta_vap_test.py | 31 ++- py-scripts/lf_ftp.py | 30 +-- py-scripts/lf_ftp_test.py | 37 ++-- py-scripts/lf_graph.py | 20 +- py-scripts/lf_mesh_test.py | 13 +- py-scripts/lf_multipsk.py | 21 +- py-scripts/lf_report_test.py | 18 +- py-scripts/lf_rvr_test.py | 14 +- py-scripts/lf_rx_sensitivity_test.py | 14 +- py-scripts/lf_sniff_radio.py | 17 +- py-scripts/lf_snp_test.py | 31 +-- py-scripts/lf_tr398_test.py | 15 +- py-scripts/lf_webpage.py | 21 +- py-scripts/lf_wifi_capacity_test.py | 14 +- py-scripts/measure_station_time_up.py | 23 ++- py-scripts/modify_station.py | 14 +- py-scripts/modify_vap.py | 14 +- py-scripts/recordinflux.py | 13 +- py-scripts/run_cv_scenario.py | 23 ++- py-scripts/rvr_scenario.py | 24 ++- py-scripts/sandbox/__init__.py | 3 - py-scripts/scenario.py | 18 +- py-scripts/sta_connect.py | 37 ++-- py-scripts/sta_connect2.py | 38 ++-- py-scripts/sta_connect_bssid_mac.py | 57 +++--- py-scripts/sta_connect_example.py | 21 +- py-scripts/sta_connect_multi_example.py | 26 +-- py-scripts/station_layer3.py | 49 ++--- py-scripts/stations_connected.py | 19 +- py-scripts/test_1k_clients_jedtest.py | 25 ++- py-scripts/test_client_admission.py | 20 +- py-scripts/test_fileio.py | 32 +-- py-scripts/test_generic.py | 26 +-- py-scripts/test_ip_connection.py | 22 +- py-scripts/test_ip_variable_time.py | 19 +- py-scripts/test_ipv4_ps.py | 20 +- py-scripts/test_ipv4_ttls.py | 24 ++- py-scripts/test_l3_WAN_LAN.py | 20 +- py-scripts/test_l3_longevity.py | 190 ++++++------------ py-scripts/test_l3_powersave_traffic.py | 24 ++- py-scripts/test_l3_scenario_throughput.py | 33 ++- py-scripts/test_l3_unicast_traffic_gen.py | 21 +- py-scripts/test_l4.py | 26 +-- py-scripts/test_status_msg.py | 22 +- py-scripts/test_wanlink.py | 22 +- py-scripts/test_wpa_passphrases.py | 22 +- py-scripts/testgroup.py | 23 ++- py-scripts/testgroup2.py | 23 ++- py-scripts/tip-cicd-sanity/Nightly_Sanity.py | 59 +++--- py-scripts/tip-cicd-sanity/Throughput_Test.py | 11 + py-scripts/tip-cicd-sanity/eap_connect.py | 39 ++-- .../single_client_throughput.py | 37 ++-- py-scripts/tip_station_powersave.py | 26 ++- py-scripts/tools/lf_check.py | 2 - py-scripts/tools/lf_qa.py | 15 +- py-scripts/vap_stations_example.py | 19 +- py-scripts/wlan_capacity_calculator.py | 15 +- py-scripts/ws_generic_monitor_test.py | 17 +- 128 files changed, 1639 insertions(+), 1388 deletions(-) diff --git a/py-dashboard/GhostRequest.py b/py-dashboard/GhostRequest.py index 3d8b8deb..790bf845 100644 --- a/py-dashboard/GhostRequest.py +++ b/py-dashboard/GhostRequest.py @@ -1,16 +1,10 @@ #!/usr/bin/env python3 - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Class holds default settings for json requests to Ghost - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -import os import sys - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit() - +import os +import importlib import requests import jwt from datetime import datetime @@ -23,8 +17,16 @@ from collections import Counter import shutil import itertools -from GrafanaRequest import GrafanaRequest -from InfluxRequest import RecordInflux +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +GrafanaRequest = importlib.import_module("lanforge-scripts.py-dashboard.GrafanaRequest") +InfluxRequest = importlib.import_module("lanforge-scripts.py-dashboard.InfluxRequest") +RecordInflux = InfluxRequest.RecordInflux class CSVReader: diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index d68595db..1efd4522 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -2,18 +2,22 @@ # Class holds default settings for json requests - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import sys +import os +import importlib +import urllib +from urllib import request +from urllib import error +from urllib import parse +import json if sys.version_info[0] != 3: print("This script requires Python 3") exit() -import urllib -from urllib import request -from urllib import error -from urllib import parse +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) -import json -from . import LFUtils +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") class LFRequest: diff --git a/py-json/LANforge/LFUtils.py b/py-json/LANforge/LFUtils.py index 0b1b4f62..494d83b0 100644 --- a/py-json/LANforge/LFUtils.py +++ b/py-json/LANforge/LFUtils.py @@ -2,24 +2,28 @@ # Define useful common methods - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import sys - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit() import os +import importlib import pprint import time from time import sleep from random import seed +from random import randint import re import ipaddress -seed(int(round(time.time() * 1000))) -from random import randint -from LANforge import LFRequest +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) + +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") debug_printer = pprint.PrettyPrinter(indent=2) +seed(int(round(time.time() * 1000))) NA = "NA" # used to indicate parameter to skip ADD_STA_FLAGS_DOWN_WPA2 = 68719477760 REPORT_TIMER_MS_FAST = 1500 diff --git a/py-json/LANforge/lf_json_autogen.py b/py-json/LANforge/lf_json_autogen.py index 8fe6f96f..2865af89 100644 --- a/py-json/LANforge/lf_json_autogen.py +++ b/py-json/LANforge/lf_json_autogen.py @@ -5,13 +5,21 @@ The API this library provides is actively being changed. This file expects to live in py-json/LANforge directory. ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----""" -# import keyword -# import pprint -# import time +import sys +import os +import importlib from enum import Enum from enum import IntFlag -# from . import LFRequest -from .lfcli_base import LFCliBase + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase class LFJsonGet(LFCliBase): diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index 3b838aa4..451d958c 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -1,6 +1,7 @@ #!env /usr/bin/python - import sys +import os +import importlib import signal import traceback # Extend this class to use common set of debug and request features for your script @@ -10,13 +11,19 @@ import random import string import datetime import argparse -import LANforge.LFUtils -from LANforge.LFUtils import * -from LANforge import LFRequest -import LANforge.LFRequest import csv import pandas as pd -import os +import re + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") class LFCliBase: @@ -201,7 +208,7 @@ class LFCliBase: lf_r.addPostData(_data) if debug_: - LANforge.LFUtils.debug_printer.pprint(_data) + LFUtils.debug_printer.pprint(_data) json_response = lf_r.json_post(show_error=debug_, debug=debug_, response_json_list_=response_json_list_, @@ -239,7 +246,7 @@ class LFCliBase: die_on_error_=self.exit_on_error) lf_r.addPostData(_data) if debug_: - LANforge.LFUtils.debug_printer.pprint(_data) + LFUtils.debug_printer.pprint(_data) json_response = lf_r.json_put(show_error=self.debug, debug=debug_, response_json_list_=response_json_list_, diff --git a/py-json/LANforge/set_port.py b/py-json/LANforge/set_port.py index 8ef23c24..0d73daff 100644 --- a/py-json/LANforge/set_port.py +++ b/py-json/LANforge/set_port.py @@ -1,7 +1,19 @@ +import sys import os +import importlib + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) + +lf_json_autogen = importlib.import_module("lanforge-scripts.py-json.LANforge.lf_json_autogen") +LFJsonPost = lf_json_autogen.LFJsonPost + + if os.environ.get("LF_USE_AUTOGEN") == 1: - import lf_json_autogen - from lf_json_autogen import LFJsonPost set_port_current_flags = LFJsonPost.SetPortCurrentFlags.__members__ set_port_cmd_flags = LFJsonPost.SetPortCmdFlags.__members__ set_port_interest_flags = LFJsonPost.SetPortInterest.__members__ @@ -107,4 +119,4 @@ else: "no_apply_dhcp" : 0x80000000, # Enable/disable NO-APPLY-DHCP flag for a port "skip_ifup_roam" : 0x100000000, # Enable/disable SKIP-IFUP-ON-ROAM flag for a port } -# \ No newline at end of file +# diff --git a/py-json/__init__.py b/py-json/__init__.py index adfa88db..e69de29b 100644 --- a/py-json/__init__.py +++ b/py-json/__init__.py @@ -1,5 +0,0 @@ -from .LANforge import LFUtils -from .LANforge import LFRequest -from .LANforge import lfcli_base -from .LANforge.lfcli_base import LFCliBase - diff --git a/py-json/base_profile.py b/py-json/base_profile.py index c6291e30..5a3f5ebb 100644 --- a/py-json/base_profile.py +++ b/py-json/base_profile.py @@ -1,4 +1,3 @@ - #!/usr/bin/env python3 import re import time @@ -9,7 +8,6 @@ import random import string import pprint from pprint import pprint -#from LANforge.lfcriteria import LFCriteria class BaseProfile: def __init__(self, local_realm, debug=False): @@ -126,4 +124,4 @@ class BaseProfile: # else: # compared_rept=args.compared_report - \ No newline at end of file + diff --git a/py-json/create_wanlink.py b/py-json/create_wanlink.py index ffd56b34..19a46b95 100755 --- a/py-json/create_wanlink.py +++ b/py-json/create_wanlink.py @@ -3,22 +3,21 @@ # Written by Candela Technologies Inc. # Updated by: Erin Grimes import sys - +import urllib +import importlib if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) import os -import importlib import time from time import sleep -import urllib from urllib import error import pprint if 'lanforge-scripts' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('../..'), 'lanforge-scripts')) -LANforge = importlib.import_module("lanforge-scripts.py-json.LANforge") + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") diff --git a/py-json/cv_dut_profile.py b/py-json/cv_dut_profile.py index 74a6606b..a1dd83c2 100644 --- a/py-json/cv_dut_profile.py +++ b/py-json/cv_dut_profile.py @@ -1,9 +1,19 @@ -import time - # !/usr/bin/env python3 -# ---- ---- ---- ---- LANforge Base Imports ---- ---- ---- ---- -from LANforge.lfcli_base import LFCliBase -from LANforge.add_dut import add_dut_flags +import sys +import os +import importlib + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +add_dut = importlib.import_module("lanforge-scripts.py-json.LANforge.add_dut") +add_dut_flags = add_dut.add_dut_flags class cv_dut(LFCliBase): diff --git a/py-json/cv_test_manager.py b/py-json/cv_test_manager.py index fa9a89fe..f9262ce6 100644 --- a/py-json/cv_test_manager.py +++ b/py-json/cv_test_manager.py @@ -3,21 +3,30 @@ Note: This script is working as library for chamberview tests. It holds different commands to automate test. """ -import time import sys import os - -if 'py-dashboard' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) - -from LANforge.lfcli_base import LFCliBase -from realm import Realm +import importlib +import time import json from pprint import pprint import argparse -from cv_test_reports import lanforge_reports as lf_rpt -from InfluxRequest import * -import os.path + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +cv_test_reports = importlib.import_module("lanforge-scripts.py-json.cv_test_reports") +lf_rpt = cv_test_reports.lanforge_reports +InfluxRequest = importlib.import_module("lanforge-scripts.py-dashboard.InfluxRequest") +influx_add_parser_args = InfluxRequest.influx_add_parser_args +RecordInflux = InfluxRequest.RecordInflux def cv_base_adjust_parser(args): diff --git a/py-json/dataplane_test_profile.py b/py-json/dataplane_test_profile.py index 1ddc138d..8e683d80 100644 --- a/py-json/dataplane_test_profile.py +++ b/py-json/dataplane_test_profile.py @@ -3,8 +3,15 @@ Library to Run Dataplane Test: Using lf_cv_base class """ +import sys +import os +import importlib -from lf_cv_base import ChamberViewBase +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lf_cv_base = importlib.import_module("lanforge-scripts.py-json.lf_cv_base") +ChamberViewBase = lf_cv_base.ChamberViewBase class DataPlaneTest(ChamberViewBase): diff --git a/py-json/dut_profile.py b/py-json/dut_profile.py index edc6afa6..0f6dee78 100644 --- a/py-json/dut_profile.py +++ b/py-json/dut_profile.py @@ -1,12 +1,19 @@ - #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -from LANforge import add_dut +import sys +import os +import importlib import pprint from pprint import pprint import time import base64 +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +add_dut = importlib.import_module("lanforge-scripts.py-json.LANforge.add_dut") + class DUTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): diff --git a/py-json/fio_endp_profile.py b/py-json/fio_endp_profile.py index 10329895..8af64467 100644 --- a/py-json/fio_endp_profile.py +++ b/py-json/fio_endp_profile.py @@ -1,15 +1,21 @@ #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase +# Class: FIOEndpProfile(LFCliBase) + +# Written by Candela Technologies Inc. +# Updated by: +import sys +import os +import importlib import pprint from pprint import pprint import time -# Class: FIOEndpProfile(LFCliBase) -# +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase -# Written by Candela Technologies Inc. -# Updated by: -# class FIOEndpProfile(LFCliBase): """ @@ -187,4 +193,4 @@ class FIOEndpProfile(LFCliBase): url = "/cli-json/add_cx" self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) - time.sleep(sleep_time) \ No newline at end of file + time.sleep(sleep_time) diff --git a/py-json/gen_cxprofile.py b/py-json/gen_cxprofile.py index 0bea33a6..d4e9c3ec 100644 --- a/py-json/gen_cxprofile.py +++ b/py-json/gen_cxprofile.py @@ -1,16 +1,22 @@ - #!/usr/bin/env python3 - -from LANforge.lfcli_base import LFCliBase +import sys +import os +import importlib import pprint from pprint import pprint -from LANforge.lfcli_base import LFCliBase import csv import pandas as pd import time import datetime import json +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + + class GenCXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_) @@ -599,4 +605,4 @@ class GenCXProfile(LFCliBase): self.df_to_file(dataframe=pd.read_csv(report_file), output_f=output_format, save_path=report_file) else: if output_format.lower() != 'csv': - self.df_to_file(dataframe=pd.read_csv(report_file), output_f=output_format, save_path=report_file) \ No newline at end of file + self.df_to_file(dataframe=pd.read_csv(report_file), output_f=output_format, save_path=report_file) diff --git a/py-json/http_profile.py b/py-json/http_profile.py index 6da182e8..f990380c 100644 --- a/py-json/http_profile.py +++ b/py-json/http_profile.py @@ -1,11 +1,20 @@ #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -import port_utils -from port_utils import PortUtils +import sys +import os +import importlib from pprint import pprint import pprint import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +port_utils = importlib.import_module("lanforge-scripts.py-json.port_utils") +PortUtils = port_utils.PortUtils +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + + class HTTPProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): super().__init__(lfclient_host, lfclient_port, debug_) diff --git a/py-json/l3_cxprofile.py b/py-json/l3_cxprofile.py index b33327c7..06953f58 100644 --- a/py-json/l3_cxprofile.py +++ b/py-json/l3_cxprofile.py @@ -1,12 +1,20 @@ # !/usr/bin/env python3 +import sys +import os +import importlib import pprint from pprint import pprint -from LANforge.lfcli_base import LFCliBase import csv import pandas as pd import time import datetime +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + class L3CXProfile(LFCliBase): def __init__(self, diff --git a/py-json/l3_cxprofile2.py b/py-json/l3_cxprofile2.py index 0eb67df4..72980ccf 100644 --- a/py-json/l3_cxprofile2.py +++ b/py-json/l3_cxprofile2.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 +import sys +import os +import importlib import re import time import pprint -from lfdata import LFDataCollection -from base_profile import BaseProfile -import os import datetime import base64 import csv @@ -14,6 +14,12 @@ import random import string import datetime +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfdata = importlib.import_module("lanforge-scripts.py-json.lfdata") +base_profile = importlib.import_module("lanforge-scripts.py-json.base_profile") +BaseProfile = base_profile.BaseProfile class L3CXProfile2(BaseProfile): diff --git a/py-json/l4_cxprofile.py b/py-json/l4_cxprofile.py index 87e327ca..e68fbd88 100644 --- a/py-json/l4_cxprofile.py +++ b/py-json/l4_cxprofile.py @@ -1,6 +1,7 @@ - #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase +import sys +import os +import importlib import pprint from pprint import pprint import requests @@ -9,7 +10,13 @@ import time import datetime import ast import csv -import os + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + class L4CXProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): diff --git a/py-json/lf_attenmod.py b/py-json/lf_attenmod.py index 33b7f2b3..d95e0d37 100644 --- a/py-json/lf_attenmod.py +++ b/py-json/lf_attenmod.py @@ -1,9 +1,17 @@ #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -from LANforge import LFRequest -from LANforge import LFUtils +import sys +import os +import importlib import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") + class ATTENUATORProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False): diff --git a/py-json/lf_cv_base.py b/py-json/lf_cv_base.py index 48a0c25a..97659659 100644 --- a/py-json/lf_cv_base.py +++ b/py-json/lf_cv_base.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Base Class to be used for Chamber View Tests @@ -8,10 +7,16 @@ Methods: 2.) Remove a CV Profile 3.) Add a DUT 4.) Show a CV Profile - """ +import sys +import os +import importlib -from LANforge.lfcli_base import LFCliBase +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase class ChamberViewBase(LFCliBase): diff --git a/py-json/mac_vlan_profile.py b/py-json/mac_vlan_profile.py index edfbdc82..01223001 100644 --- a/py-json/mac_vlan_profile.py +++ b/py-json/mac_vlan_profile.py @@ -1,15 +1,19 @@ - #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -from LANforge import LFRequest -from LANforge import LFUtils -from LANforge import set_port +import sys +import os +import importlib import pprint from pprint import pprint import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) - +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +set_port = importlib.import_module("lanforge-scripts.py-json.LANforge.set_port") class MACVLANProfile(LFCliBase): diff --git a/py-json/multicast_profile.py b/py-json/multicast_profile.py index ca99872d..eab915cf 100644 --- a/py-json/multicast_profile.py +++ b/py-json/multicast_profile.py @@ -1,9 +1,16 @@ - #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase +import sys +import os +import importlib import pprint from pprint import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, diff --git a/py-json/qvlan_profile.py b/py-json/qvlan_profile.py index c968cee7..b133cdbf 100644 --- a/py-json/qvlan_profile.py +++ b/py-json/qvlan_profile.py @@ -1,15 +1,18 @@ - #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -from LANforge import LFRequest -from LANforge import LFUtils -from LANforge import set_port +import sys +import os +import importlib import pprint from pprint import pprint import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) - +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") class QVLANProfile(LFCliBase): diff --git a/py-json/realm.py b/py-json/realm.py index 02f825b3..b9edbafe 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1,44 +1,67 @@ #!/usr/bin/env python3 - # The Realm Class is inherited by most python tests. Realm Class inherites from LFCliBase. -# The Realm Class contains the configurable components for LANforge, +# The Realm Class contains the configurable components for LANforge, # For example L3 / L4 cross connects, stations. Also contains helper methods # http://www.candelatech.com/cookbook.php?vol=cli&book=Python_Create_Test_Scripts_With_the_Realm_Class -# # Written by Candela Technologies Inc. # Updated by: -# - -# ---- ---- ---- ---- LANforge Base Imports ---- ---- ---- ---- -from LANforge import LFRequest -from LANforge import LFUtils -from LANforge.lfcli_base import LFCliBase -# ---- ---- ---- ---- Profile Imports ---- ---- ---- ---- -from l3_cxprofile import L3CXProfile -from l3_cxprofile2 import L3CXProfile2 -from l4_cxprofile import L4CXProfile -from lf_attenmod import ATTENUATORProfile -from multicast_profile import MULTICASTProfile -from http_profile import HTTPProfile -from station_profile import StationProfile -from fio_endp_profile import FIOEndpProfile -from test_group_profile import TestGroupProfile -from dut_profile import DUTProfile -from vap_profile import VAPProfile -from mac_vlan_profile import MACVLANProfile -from wifi_monitor_profile import WifiMonitor -from gen_cxprofile import GenCXProfile -from qvlan_profile import QVLANProfile -from port_utils import PortUtils -from lfdata import LFDataCollection -# ---- ---- ---- ---- Other Imports ---- ---- ---- ---- +import sys +import os +import importlib import re import time import pprint from pprint import pprint +# ---- ---- ---- ---- LANforge Base Imports ---- ---- ---- ---- + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LANforge = importlib.import_module("lanforge-scripts.py-json.LANforge") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + +# ---- ---- ---- ---- Profile Imports ---- ---- ---- ---- + +l3_cxprofile = importlib.import_module("lanforge-scripts.py-json.l3_cxprofile") +L3CXProfile = l3_cxprofile.L3CXProfile +l3_cxprofile2 = importlib.import_module("lanforge-scripts.py-json.l3_cxprofile2") +L3CXProfile2 = l3_cxprofile2.L3CXProfile2 +l4_cxprofile = importlib.import_module("lanforge-scripts.py-json.l4_cxprofile") +L4CXProfile = l4_cxprofile.L4CXProfile +lf_attenmod = importlib.import_module("lanforge-scripts.py-json.lf_attenmod") +ATTENUATORProfile = lf_attenmod.ATTENUATORProfile +multicast_profile = importlib.import_module("lanforge-scripts.py-json.multicast_profile") +MULTICASTProfile = multicast_profile.MULTICASTProfile +http_profile = importlib.import_module("lanforge-scripts.py-json.http_profile") +HTTPProfile = http_profile.HTTPProfile +station_profile = importlib.import_module("lanforge-scripts.py-json.station_profile") +StationProfile = station_profile.StationProfile +fio_endp_profile = importlib.import_module("lanforge-scripts.py-json.fio_endp_profile") +FIOEndpProfile = fio_endp_profile.FIOEndpProfile +test_group_profile = importlib.import_module("lanforge-scripts.py-json.test_group_profile") +TestGroupProfile = test_group_profile.TestGroupProfile +dut_profile = importlib.import_module("lanforge-scripts.py-json.dut_profile") +DUTProfile = dut_profile.DUTProfile +vap_profile = importlib.import_module("lanforge-scripts.py-json.vap_profile") +VAPProfile = vap_profile.VAPProfile +mac_vlan_profile = importlib.import_module("lanforge-scripts.py-json.mac_vlan_profile") +MACVLANProfile = mac_vlan_profile.MACVLANProfile +wifi_monitor_profile = importlib.import_module("lanforge-scripts.py-json.wifi_monitor_profile") +WifiMonitor = wifi_monitor_profile.WifiMonitor +gen_cxprofile = importlib.import_module("lanforge-scripts.py-json.gen_cxprofile") +GenCXProfile = gen_cxprofile.GenCXProfile +qvlan_profile = importlib.import_module("lanforge-scripts.py-json.qvlan_profile") +QVLANProfile = qvlan_profile.QVLANProfile +port_utils = importlib.import_module("lanforge-scripts.py-json.port_utils") +PortUtils = port_utils.PortUtils +lfdata = importlib.import_module("lanforge-scripts.py-json.lfdata") +LFDataCollection = lfdata.LFDataCollection + def wpa_ent_list(): return [ @@ -844,15 +867,13 @@ class Realm(LFCliBase): def new_l3_cx_profile(self, ver=1): if ver == 1: - import l3_cxprofile - cx_prof = l3_cxprofile.L3CXProfile(self.lfclient_host, + cx_prof = L3CXProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug, report_timer_=3000) elif ver == 2: - import l3_cxprofile2 - cx_prof = l3_cxprofile2.L3CXProfile2(self.lfclient_host, + cx_prof = L3CXProfile2(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug, @@ -860,7 +881,7 @@ class Realm(LFCliBase): return cx_prof def new_l4_cx_profile(self, ver=1): - if ver == 1 : + if ver == 1: cx_prof = L4CXProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) #elif ver == 2: # import l4_cxprofile2 diff --git a/py-json/realm_test.py b/py-json/realm_test.py index acb6f8f6..04ff7169 100755 --- a/py-json/realm_test.py +++ b/py-json/realm_test.py @@ -1,11 +1,18 @@ #!/usr/bin/env python3 +import sys +import os +import importlib import pprint import time from pprint import pprint -import realm -from realm import Realm -import LANforge -from LANforge import LFUtils + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") + localrealm = Realm("localhost", 8080, True) @@ -130,4 +137,4 @@ except Exception as x: pprint(x) exit(1) # -exit(0) \ No newline at end of file +exit(0) diff --git a/py-json/show_ports.py b/py-json/show_ports.py index 35a976e1..bfd12802 100644 --- a/py-json/show_ports.py +++ b/py-json/show_ports.py @@ -4,13 +4,19 @@ # the syntax of the request is /port/// - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import sys +import os +import importlib +import json +import pprint + if sys.version_info[0] != 3: print("This script requires Python 3") exit() -import json -import pprint -from LANforge import LFRequest +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") def main(): diff --git a/py-json/station_profile.py b/py-json/station_profile.py index 9e99f9c7..2320d26a 100644 --- a/py-json/station_profile.py +++ b/py-json/station_profile.py @@ -1,30 +1,39 @@ # !/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -from LANforge import LFRequest -from LANforge import LFUtils -from LANforge import set_port -from LANforge import add_sta +import sys +import os +import importlib import pprint from pprint import pprint import time -# Uncomment below to include autogen library. -# import os -# if os.environ.get("LF_USE_AUTOGEN") == 1: -# import LANforge -# import LANforge.lf_json_autogen -# from LANforge.lf_json_autogen import LFJsonPost +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +set_port = importlib.import_module("lanforge-scripts.py-json.LANforge.set_port") +add_sta = importlib.import_module("lanforge-scripts.py-json.LANforge.add_sta") + +# Uncomment below to include autogen library. +# if os.environ.get("LF_USE_AUTOGEN") == 1: +# lf_json_autogen = importlib.import_module("lanforge-scripts.py-json.LANforge.lf_json_autogen") +# LFJsonPost = jf_json_autogen.LFJsonPost # use the station profile to set the combination of features you want on your stations # once this combination is configured, build the stations with the build(resource, radio, number) call # build() calls will fail if the station already exists. Please survey and clean your resource # before calling build() -# survey = Realm.findStations(resource=1) -# Realm.removeStations(survey) -# profile = Realm.newStationProfile() -# profile.set... -# profile.build(resource, radio, 64) -# +# realm = importlib.import_module("lanforge-scripts.py-json.realm") +# Realm = realm.Realm +# survey = Realm.findStations(resource=1) +# Realm.removeStations(survey) +# profile = Realm.newStationProfile() +# profile.set... +# profile.build(resource, radio, 64) + + class StationProfile: def __init__(self, lfclient_url, local_realm, ssid="NA", diff --git a/py-json/test_base.py b/py-json/test_base.py index 5187a94b..a2d60dad 100644 --- a/py-json/test_base.py +++ b/py-json/test_base.py @@ -1,6 +1,14 @@ #!/usr/bin/env python3 -from lfdata import LFDataCollection -#import lfreporting +import sys +import os +import importlib + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfdata = importlib.import_module("lanforge-scripts.py-json.lfdata") +LFDataCollection = lfdata.LFDataCollection + class TestBase: def __init__(self): diff --git a/py-json/test_group_profile.py b/py-json/test_group_profile.py index fe08363d..6005bd70 100644 --- a/py-json/test_group_profile.py +++ b/py-json/test_group_profile.py @@ -1,9 +1,17 @@ #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase +import sys +import os +import importlib import pprint from pprint import pprint import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase + class TestGroupProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, test_group_name=None, debug_=False): diff --git a/py-json/test_histogram.py b/py-json/test_histogram.py index b6bf3cd0..414f312d 100755 --- a/py-json/test_histogram.py +++ b/py-json/test_histogram.py @@ -2,10 +2,17 @@ """ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- internal test driving LFUtils.expand_endp_histogram ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- """ -import LANforge -from LANforge import LFUtils +import sys +import os +import importlib import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") + + distrib_load = { "histo_category_width" : 3, "histogram" : [ diff --git a/py-json/test_utility.py b/py-json/test_utility.py index a18cb8d6..fb2d9c88 100644 --- a/py-json/test_utility.py +++ b/py-json/test_utility.py @@ -1,25 +1,15 @@ - """ Candela Technologies Inc. Info : Standard Script for Webconsole Test Utility Date : - """ - import sys +import os +import importlib 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 @@ -27,7 +17,16 @@ import matplotlib.pyplot as plt import threading import re import json -import os + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +PortUtils = realm.PortUtils + webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) updates_path = webconsole_dir + "/web_json/updates.js" diff --git a/py-json/vap_profile.py b/py-json/vap_profile.py index 573dc157..49a2a6c4 100644 --- a/py-json/vap_profile.py +++ b/py-json/vap_profile.py @@ -1,14 +1,21 @@ #!/usr/bin/env python3 - -from LANforge.lfcli_base import LFCliBase -from LANforge import LFRequest -from LANforge import add_vap, set_wifi_radio -from LANforge import set_port -from LANforge import LFUtils +import sys +import os +import importlib import pprint from pprint import pprint import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") +add_vap = importlib.import_module("lanforge-scripts.py-json.LANforge.add_vap") +set_port = importlib.import_module("lanforge-scripts.py-json.LANforge.set_port") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") + class VAPProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -212,15 +219,15 @@ class VAPProfile(LFCliBase): return result def create(self, resource, radio, channel=None, up_=None, debug=False, use_ht40=True, use_ht80=True, - use_ht160=False, country=0, + use_ht160=False, suppress_related_commands_=True, use_radius=False, hs20_enable=False, bridge=True): - #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(): - # if v['alias'] == self.vap_name: - # self.local_realm.rm_port(v['port'], check_exists=True) + 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(): + if v['alias'] == self.vap_name: + self.local_realm.rm_port(k, check_exists=True) if use_ht160: self.desired_add_vap_flags.append("enable_80211d") self.desired_add_vap_flags_mask.append("enable_80211d") @@ -249,11 +256,11 @@ class VAPProfile(LFCliBase): raise ValueError("No radio %s.%s found" % (resource, radio)) eid = "1.%s.%s" % (resource, radio) + frequency = 0 + country = 0 if eid in jr: country = jr[eid]["country"] - self.mode = set_wifi_radio.set_radio_mode[self.mode] - data = { "shelf": 1, "resource": resource, @@ -263,7 +270,6 @@ class VAPProfile(LFCliBase): "country": country, "frequency": self.local_realm.channel_freq(channel_=channel) } - print(data) self.local_realm.json_post("/cli-json/set_wifi_radio", _data=data) if up_ is not None: self.up = up_ @@ -352,22 +358,6 @@ class VAPProfile(LFCliBase): if (self.up): self.admin_up(resource) - def modify(self, radio): - self.add_vap_data["flags"] = self.add_named_flags(self.desired_add_vap_flags, add_vap.add_vap_flags) - self.add_vap_data["flags_mask"] = self.add_named_flags(self.desired_add_vap_flags_mask, add_vap.add_vap_flags) - self.add_vap_data["radio"] = radio - self.add_vap_data["ap_name"] = self.vap_name - self.add_vap_data["ssid"] = 'NA' - self.add_vap_data["key"] = 'NA' - self.add_vap_data['mac'] = 'NA' - - add_vap_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_vap") - if self.debug: - print(self.add_vap_data) - add_vap_r.addPostData(self.add_vap_data) - json_response = add_vap_r.jsonPost(self.debug) - - def cleanup(self, resource, delay=0.03): print("Cleaning up VAPs") desired_ports = ["1.%s.%s" % (resource, self.vap_name), "1.%s.br0" % resource] diff --git a/py-json/vr_profile2.py b/py-json/vr_profile2.py index 0e37756c..59612d38 100644 --- a/py-json/vr_profile2.py +++ b/py-json/vr_profile2.py @@ -1,9 +1,16 @@ +import sys +import os +import importlib import time from pprint import pprint from random import randint -from LANforge import LFUtils -from base_profile import BaseProfile +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +base_profile = importlib.import_module("lanforge-scripts.py-json.base_profile") +BaseProfile = base_profile.BaseProfile class VRProfile(BaseProfile): @@ -760,4 +767,4 @@ class VRProfile(BaseProfile): return (new_x, new_y) ### ### -### \ No newline at end of file +### diff --git a/py-json/wifi_monitor_profile.py b/py-json/wifi_monitor_profile.py index 1a7ad13e..5d023f19 100644 --- a/py-json/wifi_monitor_profile.py +++ b/py-json/wifi_monitor_profile.py @@ -1,14 +1,20 @@ #!/usr/bin/env python3 -from LANforge.lfcli_base import LFCliBase -from LANforge import add_monitor -from LANforge.add_monitor import * -from LANforge import LFUtils +import sys +import os +import importlib import pprint from pprint import pprint import time -from LANforge.set_wifi_radio import set_radio_mode +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +add_monitor = importlib.import_module("lanforge-scripts.py-json.LANforge.add_monitor") +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +set_wifi_radio = importlib.import_module("lanforge-scripts.py-json.LANforge.set_wifi_radio") +set_radio_mode = set_wifi_radio.set_radio_mode class WifiMonitor: diff --git a/py-json/ws-sta-monitor.py b/py-json/ws-sta-monitor.py index e5a9a5eb..659a87b2 100755 --- a/py-json/ws-sta-monitor.py +++ b/py-json/ws-sta-monitor.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -''' +""" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - # Example of how to filter messages from the :8081 websocket - @@ -7,12 +7,10 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You will need websocket-client: apt install python3-websocket -''' - +""" import sys -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit() +import os +import importlib import argparse import json import logging @@ -26,7 +24,16 @@ try: import thread except ImportError: import _thread as thread -from LANforge import LFUtils + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") + cre={ "phy": re.compile(r'^(1\.\d+):\s+(\S+)\s+\(phy', re.I), @@ -353,4 +360,4 @@ if __name__ == '__main__': #### #### -#### \ No newline at end of file +#### diff --git a/py-scripts/cicd_TipIntegration.py b/py-scripts/cicd_TipIntegration.py index 02651f2c..113716aa 100755 --- a/py-scripts/cicd_TipIntegration.py +++ b/py-scripts/cicd_TipIntegration.py @@ -1,18 +1,17 @@ - +import os +import sys import base64 import urllib.request from bs4 import BeautifulSoup import ssl -import subprocess, os +import subprocess from artifactory import ArtifactoryPath import tarfile import paramiko from paramiko import SSHClient from scp import SCPClient -import os import pexpect from pexpect import pxssh -import sys import paramiko from scp import SCPClient import pprint diff --git a/py-scripts/connection_test.py b/py-scripts/connection_test.py index 1fc5fe46..b5a3ddff 100755 --- a/py-scripts/connection_test.py +++ b/py-scripts/connection_test.py @@ -5,33 +5,33 @@ Candela Technologies Inc. Info : Standard Script for Connection Testing - Creates HTML and pdf report as a result (Used for web-console) """ - 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') -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 +import os +import importlib import argparse import datetime import time -import os from test_utility import CreateHTML # from test_utility import RuntimeUpdates from test_utility import StatusMsg import pdfkit +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) + class ConnectionTest(LFCliBase): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio="wiphy1", sta_prefix="sta", start_id=0, diff --git a/py-scripts/create_bond.py b/py-scripts/create_bond.py index fcde84c9..0b7ae168 100755 --- a/py-scripts/create_bond.py +++ b/py-scripts/create_bond.py @@ -9,23 +9,25 @@ Use './create_bond.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - import sys import os +import importlib import argparse +import time +import pprint 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 +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateBond(LFCliBase): diff --git a/py-scripts/create_bridge.py b/py-scripts/create_bridge.py index d72155b2..24a9a060 100755 --- a/py-scripts/create_bridge.py +++ b/py-scripts/create_bridge.py @@ -3,23 +3,25 @@ """ Script for creating a variable number of bridges. """ - import sys import os +import importlib +import time +import pprint 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 +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateBridge(Realm): diff --git a/py-scripts/create_chamberview.py b/py-scripts/create_chamberview.py index a92b2e68..8a71e746 100755 --- a/py-scripts/create_chamberview.py +++ b/py-scripts/create_chamberview.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -30,11 +29,10 @@ Output: You should see build scenario with the given arguments at the end of this script. To verify this: open Chamber View -> Manage scenario - """ - import sys import os +import importlib import argparse import time import re @@ -43,10 +41,12 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cv = cv_test_manager.cv_test -from cv_test_manager import cv_test as cv class CreateChamberview(cv): def __init__(self, diff --git a/py-scripts/create_chamberview_dut.py b/py-scripts/create_chamberview_dut.py index 28bb03d0..af9bbcd1 100755 --- a/py-scripts/create_chamberview_dut.py +++ b/py-scripts/create_chamberview_dut.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -45,9 +44,9 @@ How to Run this: Output : DUT will be created in Chamber View """ - import sys import os +import importlib import argparse import time @@ -55,11 +54,15 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from cv_dut_profile import cv_dut as dut -from cv_test_manager import cv_test as cvtest +# from cv_dut_profile import cv_dut as dut +cv_dut_profile = importlib.import_module("lanforge-scripts.py-json.cv_dut_profile") +dut = cv_dut_profile.cv_dut +# from cv_test_manager import cv_test as cvtest +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cvtest = cv_test_manager.cv_test class DUT(dut): diff --git a/py-scripts/create_l3.py b/py-scripts/create_l3.py index 3b51dbe8..14f7b2e3 100755 --- a/py-scripts/create_l3.py +++ b/py-scripts/create_l3.py @@ -1,103 +1,73 @@ #!/usr/bin/env python3 - +# Create Layer-3 Cross Connection Using LANforge JSON AP : https://www.candelatech.com/cookbook.php?vol=fire&book=scripted+layer-3+test +# Written by Candela Technologies Inc. +# Updated by: Erin Grimes """ - This script will create a variable number of layer3 stations each with their own set of cross-connects and endpoints. - - If you want to - - Use './create_l3.py --help' to see command line usage and options +Example Command: +./create_l3.py --endp_a 'eth1' --endp_b 'eth2' --min_rate_a '56000' --min_rate_b '40000' """ - import sys import os +import importlib +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import time -import datetime -from realm import TestGroupProfile +LANforge = importlib.import_module("lanforge-scripts.py-json.LANforge") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +TestGroupProfile = realm.TestGroupProfile class CreateL3(Realm): def __init__(self, - ssid, security, password, sta_list, name_prefix, upstream, radio, - 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", use_ht160=False, + name_prefix, + endp_b, + endp_a, + host="localhost", port=8080, mode=0, + min_rate_a=56, max_rate_a=0, + min_rate_b=56, max_rate_b=0, _debug_on=False, _exit_on_error=False, _exit_on_fail=False): super().__init__(host, port) - self.upstream = upstream self.host = host self.port = port - self.ssid = ssid - self.sta_list = sta_list - self.security = security - self.password = password - self.radio = radio + self.endp_b = endp_b + self.endp_a = endp_a self.mode = mode - self.ap = ap - self.number_template = number_template - self.debug = _debug_on self.name_prefix = name_prefix 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 - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.debug = self.debug - self.station_profile.use_ht160 = use_ht160 - if self.station_profile.use_ht160: - self.station_profile.mode = 9 - 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.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 self.cx_profile.port = self.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 - self.cx_profile.side_b_min_bps = side_b_min_rate - self.cx_profile.side_b_max_bps = side_b_max_rate + self.cx_profile.side_a_min_bps = min_rate_a + self.cx_profile.side_a_max_bps = max_rate_a + self.cx_profile.side_b_min_bps = min_rate_b + self.cx_profile.side_b_max_bps = max_rate_b def pre_cleanup(self): self.cx_profile.cleanup_prefix() - for sta in self.sta_list: - self.rm_port(sta, check_exists=True) def build(self): - - 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.cx_profile.create(endp_type="lf_udp", - side_a=self.station_profile.station_names, - side_b=self.upstream, + side_a=self.endp_a, + side_b=self.endp_b, sleep_time=0) - self._pass("PASS: Station build finished") + self._pass("PASS: Cross-connect build finished") def main(): @@ -105,51 +75,21 @@ def main(): prog='create_l3.py', formatter_class=argparse.RawTextHelpFormatter, epilog='''\ - Create stations to test connection and traffic on VAPs of varying security types (WEP, WPA, WPA2, WPA3, Open) + Generate traffic between ports ''', - description='''\ -test_ipv4_variable_time.py: --------------------- -Generic command layout: - -python3 ./test_ipv4_variable_time.py - --upstream_port eth1 - --radio wiphy0 - --num_stations 32 - --security {open|wep|wpa|wpa2|wpa3} \\ - --mode 1 - {"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", - --ssid netgear - --password admin123 - --a_min 1000 - --b_min 1000 - --ap "00:0e:8e:78:e1:76" - --number_template 0000 - --debug - ''') + ''') required_args = None for group in parser._action_groups: if group.title == "required arguments": required_args = group - break; + 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('--min_rate_a', help='--min_rate_a bps rate minimum for side_a', default=56000) + required_args.add_argument('--min_rate_b', help='--min_rate_b bps rate minimum for side_b', default=56000) + required_args.add_argument('--endp_a', help='--endp_a station list', default=["eth1"], action="append") + required_args.add_argument('--endp_b', help='--upstream port', default="eth2") optional_args = None for group in parser._action_groups: @@ -158,31 +98,22 @@ python3 ./test_ipv4_variable_time.py break; 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('--number_template', help='Start the station numbering with a particular number. Default is 0000', default=0000) 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_=int(args.number_template), end_id_=num_sta+int(args.number_template) - 1, padding_number_=10000, - radio=args.radio) + # station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=int(args.number_template), end_id_=num_sta+int(args.number_template) - 1, padding_number_=10000, + # radio=args.radio) ip_var_test = CreateL3(host=args.mgr, port=args.mgr_port, - number_template=str(args.number_template), - sta_list=station_list, name_prefix="VT", - upstream=args.upstream_port, - ssid=args.ssid, - password=args.passwd, - radio=args.radio, - security=args.security, - use_ht160=False, - side_a_min_rate=args.a_min, - side_b_min_rate=args.b_min, + endp_a=args.endp_a, + endp_b=args.endp_b, + min_rate_a=args.min_rate_a, + min_rate_b=args.min_rate_b, mode=args.mode, - ap=args.ap, _debug_on=args.debug) ip_var_test.pre_cleanup() @@ -190,7 +121,7 @@ python3 ./test_ipv4_variable_time.py if not ip_var_test.passes(): print(ip_var_test.get_fail_message()) ip_var_test.exit_fail() - print('Creates %s stations and connections' % num_sta) + print('Created %s stations and connections' % num_sta) if __name__ == "__main__": diff --git a/py-scripts/create_l4.py b/py-scripts/create_l4.py index 309873e0..adef9031 100755 --- a/py-scripts/create_l4.py +++ b/py-scripts/create_l4.py @@ -1,6 +1,4 @@ #!/usr/bin/env python3 - - """ This script will create a variable number of layer4 stations each with their own set of cross-connects and endpoints. @@ -8,21 +6,25 @@ """ import sys import os +import importlib +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +TestGroupProfile = realm.TestGroupProfile -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import time -import datetime -from realm import TestGroupProfile class CreateL4(Realm): def __init__(self, diff --git a/py-scripts/create_macvlan.py b/py-scripts/create_macvlan.py index 9c216c90..ef977d9a 100755 --- a/py-scripts/create_macvlan.py +++ b/py-scripts/create_macvlan.py @@ -1,19 +1,22 @@ #!/usr/bin/env python3 - import sys +import os +import importlib +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('../py-json') -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge import LFUtils -from LANforge.add_file_endp import * -import argparse -from realm import Realm +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +add_file_endp = importlib.import_module("lanforge-scripts.py-json.LANforge.add_file_endp") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateMacVlan(Realm): @@ -186,4 +189,4 @@ Generic command layout: if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/create_qvlan.py b/py-scripts/create_qvlan.py index 0ea89d08..0e36792b 100755 --- a/py-scripts/create_qvlan.py +++ b/py-scripts/create_qvlan.py @@ -1,22 +1,22 @@ #!/usr/bin/env python3 - import sys import os +import importlib +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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge.add_file_endp import * -from LANforge import LFUtils -import argparse -from realm import Realm +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +add_file_endp = importlib.import_module("lanforge-scripts.py-json.LANforge.add_file_endp") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateQVlan(Realm): diff --git a/py-scripts/create_station.py b/py-scripts/create_station.py index c1998c3c..b622422d 100755 --- a/py-scripts/create_station.py +++ b/py-scripts/create_station.py @@ -1,23 +1,25 @@ #!/usr/bin/env python3 - """ Script for creating a variable number of stations. """ - import sys import os +import importlib import argparse +import pprint 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')) -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateStation(Realm): diff --git a/py-scripts/create_station_from_df.py b/py-scripts/create_station_from_df.py index 1d949ce4..ce06c923 100755 --- a/py-scripts/create_station_from_df.py +++ b/py-scripts/create_station_from_df.py @@ -1,23 +1,25 @@ #!/usr/bin/env python3 - """ Script for creating a variable number of stations. """ - import sys import os +import importlib import argparse +import pandas as pd +import pprint 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')) -from LANforge.lfcli_base import LFCliBase -from realm import Realm -import pandas as pd -import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateStation(Realm): diff --git a/py-scripts/create_vap.py b/py-scripts/create_vap.py index 8bddae17..834fa701 100755 --- a/py-scripts/create_vap.py +++ b/py-scripts/create_vap.py @@ -1,26 +1,26 @@ #!/usr/bin/env python3 - """ Script for creating a variable number of VAPs. """ - import sys import os +import importlib import argparse +import time +import pprint 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 -from realm import Realm -import time -import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class CreateVAP(Realm): diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py index dbf27110..87990cd3 100755 --- a/py-scripts/create_vr.py +++ b/py-scripts/create_vr.py @@ -1,23 +1,26 @@ #!/usr/bin/env python3 - """ Script for creating a variable number of virtual routers. """ - -import os import sys +import os +import importlib +import time +from pprint import pprint 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')) -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import time -from pprint import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + class CreateVR(Realm): def __init__(self, diff --git a/py-scripts/csv_convert.py b/py-scripts/csv_convert.py index fb8dd296..242d7568 100755 --- a/py-scripts/csv_convert.py +++ b/py-scripts/csv_convert.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - # This program is used to read in a LANforge Dataplane CSV file and output # a csv file that works with a customer's RvRvO visualization tool. # @@ -13,18 +12,17 @@ # Second part: # Step Index,Position [Deg],Attenuation [dB],Traffic Pair 1 Throughput [Mbps] - 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + class CSVParcer(): def __init__(self,csv_infile=None,csv_outfile=None): diff --git a/py-scripts/csv_processor.py b/py-scripts/csv_processor.py index 734bf15e..f92aad65 100755 --- a/py-scripts/csv_processor.py +++ b/py-scripts/csv_processor.py @@ -1,19 +1,8 @@ #!/usr/bin/env python3 - import sys import os - import argparse -#import time -#import datetime -#import subprocess -#import re -#import csv -#import time -#import operator import pandas as pd -#import matplotlib.pyplot as plt -#import numpy as np #https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html #https://queirozf.com/entries/pandas-dataframe-plot-examples-with-matplotlib-pyplot @@ -23,8 +12,8 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) class L3CSVParcer(): def __init__(self,csv_file): diff --git a/py-scripts/csv_to_grafana.py b/py-scripts/csv_to_grafana.py index 5399d4a9..2857be0a 100755 --- a/py-scripts/csv_to_grafana.py +++ b/py-scripts/csv_to_grafana.py @@ -1,24 +1,31 @@ #!/usr/bin/env python3 - import sys import os +import importlib import argparse +import json +import random +import string 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')) - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +csv_to_influx = importlib.import_module("lanforge-scripts.py-scripts.csv_to_influx") +CSVtoInflux = csv_to_influx.CSVtoInflux +influx_add_parser_args = csv_to_influx.influx_add_parser_args +grafana_profile = importlib.import_module("lanforge-scripts.py-scripts.grafana_profile") +UseGrafana = grafana_profile.UseGrafana +influx = importlib.import_module("lanforge-scripts.py-scripts.influx") +RecordInflux = influx.RecordInflux +InfluxRequest = importlib.import_module("lanforge-scripts.py-dashboard.InfluxRequest") +influx_add_parser_args = InfluxRequest.influx_add_parser_args -from LANforge.lfcli_base import LFCliBase -import json -from InfluxRequest import RecordInflux -from csv_to_influx import CSVtoInflux, influx_add_parser_args -from grafana_profile import UseGrafana -import random -import string class data_to_grafana(LFCliBase): def __init__(self, diff --git a/py-scripts/csv_to_influx.py b/py-scripts/csv_to_influx.py index 35c9666f..087139e5 100755 --- a/py-scripts/csv_to_influx.py +++ b/py-scripts/csv_to_influx.py @@ -1,17 +1,19 @@ #!/usr/bin/env python3 - - import sys import os - -if 'py-dashboard' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) - -from InfluxRequest import * -from cv_test_manager import * +import importlib from pathlib import Path import argparse +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser +InfluxRequest = importlib.import_module("lanforge-scripts.py-dashboard.InfluxRequest") +RecordInflux = InfluxRequest.RecordInflux +influx_add_parser_args = InfluxRequest.influx_add_parser_args class CSVtoInflux: def __init__(self, @@ -39,7 +41,7 @@ def main(): parser = argparse.ArgumentParser() cv_add_base_parser(parser) - parser.add_argument('--path', append=True) + parser.add_argument('--path', action='append') args = parser.parse_args() diff --git a/py-scripts/cv_manager.py b/py-scripts/cv_manager.py index 95d578b7..a3d59c55 100755 --- a/py-scripts/cv_manager.py +++ b/py-scripts/cv_manager.py @@ -1,19 +1,18 @@ #!/usr/bin/env python3 - import sys import os +import importlib 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')) - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from cv_test_manager import cv_test -from cv_test_manager import * +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cv_test = cv_test_manager.cv_test class CVManager(cv_test): @@ -44,4 +43,4 @@ def main(): manager.apply_and_build_scenario() if __name__ =="__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/cv_to_grafana.py b/py-scripts/cv_to_grafana.py index 3e1574c5..610428de 100755 --- a/py-scripts/cv_to_grafana.py +++ b/py-scripts/cv_to_grafana.py @@ -62,6 +62,7 @@ DUT syntax is somewhat tricky: DUT-name SSID BSID (bssid-idx), example: linksys ''' import sys import os +import importlib import argparse import time @@ -69,17 +70,20 @@ 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')) - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from lf_wifi_capacity_test import WiFiCapacityTest -from cv_test_manager import * -from create_chamberview_dut import DUT -from create_chamberview import CreateChamberview -from lf_dataplane_test import DataplaneTest -from grafana_profile import UseGrafana -from lf_ap_auto_test import ApAutoTest +lf_wifi_capacity_test = importlib.import_module("lanforge-scripts.py-scripts.lf_wifi_capacity_test") +WiFiCapacityTest = lf_wifi_capacity_test.WiFiCapacityTest +cv_test_manager = importlib.import_module("lanforge-scripts.py-scripts.cv_test_manager") +create_chamberview = importlib.import_module("lanforge-scripts.py-scripts.create_chamberview") +CreateChamberview = create_chamberview.CreateChamberview +DUT = create_chamberview.DUT +lf_dataplane_test = importlib.import_module("lanforge-scripts.py-scripts.lf_dataplane_test") +DataplaneTest = lf_dataplane_test.DataplaneTest +grafana_profile = importlib.import_module("lanforge-scripts.py-scripts.grafana_profile") +UseGrafana = grafana_profile.UseGrafana +lf_ap_auto_test = importlib.import_module("lanforge-scripts.py-scripts.lf_ap_auto_test") def main(): diff --git a/py-scripts/download_test.py b/py-scripts/download_test.py index a84d62cf..3bd2abd7 100644 --- a/py-scripts/download_test.py +++ b/py-scripts/download_test.py @@ -2,19 +2,23 @@ """download_test.py will do lf_report::add_kpi(tags, 'throughput-download-bps', $my_value);""" import sys import os - +import importlib +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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +influx = importlib.import_module("lanforge-scripts.py-scripts.influx") +RecordInflux = influx.RecordInflux +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -from LANforge.lfcli_base import LFCliBase -from influx import RecordInflux -from realm import Realm -import argparse class DownloadTest(Realm): def __init__(self, @@ -78,4 +82,4 @@ def main(): ) if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/event_breaker.py b/py-scripts/event_breaker.py index df7c03f2..3c580b0f 100755 --- a/py-scripts/event_breaker.py +++ b/py-scripts/event_breaker.py @@ -5,22 +5,27 @@ problems in the /events/ URL handler by querying events rapidly. Please use concurrently with event_flood.py. """ 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 realm import Realm +import os +import importlib import datetime from datetime import datetime import time from time import sleep import pprint +import argparse + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + class EventBreaker(Realm): def __init__(self, host, port, diff --git a/py-scripts/event_flood.py b/py-scripts/event_flood.py index 0c2b6555..96dc6678 100755 --- a/py-scripts/event_flood.py +++ b/py-scripts/event_flood.py @@ -5,23 +5,28 @@ problems in the /events/ URL handler by inserting events rapidly. Please concurrently use with event_breaker.py. """ 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 os +import importlib import argparse -from LANforge.lfcli_base import LFCliBase -from realm import Realm import datetime from datetime import datetime import time from time import sleep import pprint +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + + class EventBreaker(Realm): def __init__(self, host, port, duration=None, diff --git a/py-scripts/example_security_connection.py b/py-scripts/example_security_connection.py index 80802dfd..64b163c0 100755 --- a/py-scripts/example_security_connection.py +++ b/py-scripts/example_security_connection.py @@ -1,21 +1,24 @@ #!/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 importlib import argparse import time import pprint +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + class IPv4Test(LFCliBase): def __init__(self, ssid, security, password, sta_list=None, ap=None, mode = 0, number_template="00000", host="localhost", port=8080,radio = "wiphy0",_debug_on=False, diff --git a/py-scripts/ghost_profile.py b/py-scripts/ghost_profile.py index 297b4fd6..974569ad 100755 --- a/py-scripts/ghost_profile.py +++ b/py-scripts/ghost_profile.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: ghost_profile.py PURPOSE: modify ghost database from the command line. @@ -27,17 +26,18 @@ this script uses pyjwt. If you get the issue module 'jwt' has no attribute 'enco """ import sys import os +import importlib 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')) - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from GhostRequest import GhostRequest +# from GhostRequest import GhostRequest +GhostRequest = importlib.import_module("lanforge-scripts.py-dashboard.GhostRequest") class UseGhost(GhostRequest): diff --git a/py-scripts/grafana_profile.py b/py-scripts/grafana_profile.py index ad8bcc90..38d4910d 100755 --- a/py-scripts/grafana_profile.py +++ b/py-scripts/grafana_profile.py @@ -7,19 +7,23 @@ It gets the columns of the files and from that it automatically determines the n """ import sys import os +import importlib import argparse +import string 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')) - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +# from GrafanaRequest import GrafanaRequest +GrafanaRequest = importlib.import_module("lanforge-scripts.py-dashboard.GrafanaRequest") +GrafanaRequest = GrafanaRequest.GrafanaRequest +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase -from GrafanaRequest import GrafanaRequest -from LANforge.lfcli_base import LFCliBase -import string class UseGrafana(GrafanaRequest): diff --git a/py-scripts/influx.py b/py-scripts/influx.py index b6725316..7d37af63 100755 --- a/py-scripts/influx.py +++ b/py-scripts/influx.py @@ -1,19 +1,23 @@ #!/usr/bin/env python3 - # pip3 install influxdb - import sys +import os +import importlib +import requests +import json +from influxdb import InfluxDBClient +import datetime +import time if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) -import requests -import json -from influxdb import InfluxDBClient -import datetime -from LANforge.lfcli_base import LFCliBase -import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase class RecordInflux(LFCliBase): diff --git a/py-scripts/layer3_test.py b/py-scripts/layer3_test.py index ea10971d..12c52388 100755 --- a/py-scripts/layer3_test.py +++ b/py-scripts/layer3_test.py @@ -1,22 +1,24 @@ #!/usr/bin/env python3 - import sys +import os +import importlib +import argparse +import datetime +import time 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') -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 -import argparse -import datetime -import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + class Layer3Test(LFCliBase): diff --git a/py-scripts/layer4_test.py b/py-scripts/layer4_test.py index a4030c54..be7fe4ec 100755 --- a/py-scripts/layer4_test.py +++ b/py-scripts/layer4_test.py @@ -1,40 +1,42 @@ #!/usr/bin/env python3 - """ Candela Technologies Inc. Info : Standard Script for Layer 4 Testing Date : Author : Shivam Thakur - """ - import sys +import os +import importlib +import argparse +import datetime +import time +import pdfkit +import json +import re + 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') -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 -from test_utility import CreateHTML -from test_utility import RuntimeUpdates -import pdfkit -import json -import re -import os +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +PortUtils = realm.PortUtils +test_utility = importlib.import_module("lanforge-scripts.py-json.test_utility") +CreateHTML = test_utility.CreateHTML +RuntimeUpdates = test_utility.RuntimeUpdates webconsole_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))) print(webconsole_dir) + class HTTPTest(LFCliBase): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio="wiphy1", sta_prefix="sta", start_id=0, num_sta=2, diff --git a/py-scripts/lf_ap_auto_test.py b/py-scripts/lf_ap_auto_test.py index 983af9c4..151fdb76 100755 --- a/py-scripts/lf_ap_auto_test.py +++ b/py-scripts/lf_ap_auto_test.py @@ -162,9 +162,9 @@ reset_duration_max: 60000 bandsteer_always_5g: 0 """ - import sys import os +import importlib import argparse import time import json @@ -174,11 +174,14 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cvtest = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser -from cv_test_manager import cv_test as cvtest -from cv_test_manager import * class ApAutoTest(cvtest): def __init__(self, diff --git a/py-scripts/lf_atten_mod_test.py b/py-scripts/lf_atten_mod_test.py index 7b4ca4c5..c56a14fa 100755 --- a/py-scripts/lf_atten_mod_test.py +++ b/py-scripts/lf_atten_mod_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: lf_atten_mod_test.py @@ -19,22 +18,25 @@ Use './lf_atten_mod_test.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - import sys +import os +import importlib +import argparse +import time 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge import LFUtils -import realm -import time class CreateAttenuator(LFCliBase): def __init__(self, host, port, serno, idx, val, @@ -80,4 +82,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/lf_csv.py b/py-scripts/lf_csv.py index 5e9af5f8..01a90ad3 100644 --- a/py-scripts/lf_csv.py +++ b/py-scripts/lf_csv.py @@ -10,7 +10,7 @@ SETUP: /lanforge/html-reports directory needs to be present or output generated in local file EXAMPLE: -see: /py-scritps/lf_report_test.py for example +see: /py-scripts/lf_report_test.py for example COPYWRITE Copyright 2021 Candela Technologies Inc diff --git a/py-scripts/lf_dataplane_test.py b/py-scripts/lf_dataplane_test.py index e76d6bc0..7cc3be9c 100755 --- a/py-scripts/lf_dataplane_test.py +++ b/py-scripts/lf_dataplane_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -95,9 +94,9 @@ tos: 0 loop_iterations: 1 """ - import sys import os +import importlib import argparse import time import json @@ -107,11 +106,13 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from cv_test_manager import cv_test -from cv_test_manager import * +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cv_test = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser class DataplaneTest(cv_test): diff --git a/py-scripts/lf_dfs_test.py b/py-scripts/lf_dfs_test.py index 6e54c2d3..1a3d11a8 100755 --- a/py-scripts/lf_dfs_test.py +++ b/py-scripts/lf_dfs_test.py @@ -1,21 +1,8 @@ #!/usr/bin/env python3 - import sys import os +import importlib import pexpect - -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 -#from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -#import realm -from realm import Realm import time import datetime import subprocess @@ -24,6 +11,18 @@ import csv import random import logging +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +import argparse +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + # Check for the logs channel switching time and radar detected diff --git a/py-scripts/lf_dut_sta_vap_test.py b/py-scripts/lf_dut_sta_vap_test.py index d3b95bdc..3d648543 100755 --- a/py-scripts/lf_dut_sta_vap_test.py +++ b/py-scripts/lf_dut_sta_vap_test.py @@ -22,26 +22,12 @@ This Script is intended to automate the testing of DUT that has stations as well as AP. To automate the simultaenous testing and check the DUT Temperature ''' - 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 os +import importlib import argparse import time -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 import logging - import paramiko as pm from paramiko.ssh_exception import NoValidConnectionsError as exception import xlsxwriter @@ -51,6 +37,19 @@ from bokeh.models import LinearAxis, Range1d from bokeh.models import HoverTool from bokeh.layouts import row +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + # Specifically for Measuring CPU Core Temperatures class Login_DUT: diff --git a/py-scripts/lf_ftp.py b/py-scripts/lf_ftp.py index 9e86f4ea..14662d2f 100644 --- a/py-scripts/lf_ftp.py +++ b/py-scripts/lf_ftp.py @@ -4,26 +4,30 @@ License: Free to distribute and modify. LANforge systems must be licensed. """ import sys +import os +import importlib import paramiko - -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') - -from LANforge import LFUtils -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -import realm import argparse import datetime from datetime import datetime import time import os import matplotlib.patches as mpatches -from lf_report import * -from lf_graph import * + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +lf_report = importlib.import_module("lanforge-scripts.py-scripts.lf_report") +lf_graph = importlib.import_module("lanforge-scripts.py-scripts.lf_graph") class FtpTest(LFCliBase): diff --git a/py-scripts/lf_ftp_test.py b/py-scripts/lf_ftp_test.py index 3b0627f3..923a681a 100755 --- a/py-scripts/lf_ftp_test.py +++ b/py-scripts/lf_ftp_test.py @@ -1,20 +1,19 @@ #!/usr/bin/env python3 """ - NAME: ftp_test.py -PURPOSE: +PURPOSE: will create stations and endpoints to generate and verify layer-4 traffic over an ftp connection. find out download/upload time of each client according to file size. This script will monitor the bytes-rd attribute of the endpoints. -SETUP: +SETUP: Create a file to be downloaded linux: fallocate -l example fallocate -l 2M ftp_test.txt -EXAMPLE: +EXAMPLE: './ftp_test.py --ssid "jedway-wap2-x2048-5-3" --passwd "jedway-wpa2-x2048-5-3" --security wpa2 --bands "5G" --direction "Download" \ --file_size "2MB" --num_stations 2 @@ -24,25 +23,29 @@ INCLUDE_IN_README -Jitendrakumar Kushavah Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. - """ import sys -from ftp_html import * +import os +import importlib import paramiko -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') - -from LANforge import LFUtils -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -import realm import argparse from datetime import datetime import time -import os + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +ftp_html = importlib.import_module("lanforge-scripts.py-scripts.ftp_html") + class ftp_test(LFCliBase): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio = "wiphy0", sta_prefix="sta", start_id=0, num_sta= None, diff --git a/py-scripts/lf_graph.py b/py-scripts/lf_graph.py index 6be1ec69..3b005248 100755 --- a/py-scripts/lf_graph.py +++ b/py-scripts/lf_graph.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 -''' +""" NAME: lf_graph.py -PURPOSE: +PURPOSE: Common Library for generating graphs for LANforge output -SETUP: +SETUP: /lanforge/html-reports directory needs to be present or output generated in local file -EXAMPLE: +EXAMPLE: see: /py-scritps/lf_report_test.py for example COPYWRITE @@ -16,8 +16,10 @@ COPYWRITE License: Free to distribute and modify. LANforge systems must be licensed. INCLUDE_IN_README -''' - +""" +import sys +import os +import importlib import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np @@ -25,8 +27,12 @@ import pandas as pd import pdfkit import math from matplotlib.colors import ListedColormap -from lf_csv import lf_csv +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lf_csv = importlib.import_module("lanforge-scripts.py-scripts.lf_csv") +lf_csv = lf_csv.lf_csv # internal candela references included during intial phases, to be deleted at future date diff --git a/py-scripts/lf_mesh_test.py b/py-scripts/lf_mesh_test.py index 9de4650c..b6b0ae67 100755 --- a/py-scripts/lf_mesh_test.py +++ b/py-scripts/lf_mesh_test.py @@ -113,9 +113,9 @@ path: Orbit Current traf_use_sta: 0 """ - import sys import os +import importlib import argparse import time import json @@ -125,11 +125,14 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cvtest = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser -from cv_test_manager import cv_test as cvtest -from cv_test_manager import * class MeshTest(cvtest): def __init__(self, diff --git a/py-scripts/lf_multipsk.py b/py-scripts/lf_multipsk.py index 6f7b3ea2..50522e15 100644 --- a/py-scripts/lf_multipsk.py +++ b/py-scripts/lf_multipsk.py @@ -1,5 +1,4 @@ """ - NAME: lf_multipsk.py PURPOSE: @@ -20,23 +19,25 @@ INCLUDE_IN_README -Nikita Yadav Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. - """ -import argparse -import os import sys +import os +import importlib +import argparse import time 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')) -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -from realm import Realm +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class MultiPsk(Realm): diff --git a/py-scripts/lf_report_test.py b/py-scripts/lf_report_test.py index f076f1c7..ab06428e 100755 --- a/py-scripts/lf_report_test.py +++ b/py-scripts/lf_report_test.py @@ -17,16 +17,28 @@ COPYWRITE INCLUDE_IN_README ''' - +import sys +import os +import importlib import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np import pandas as pd import pdfkit -from lf_report import lf_report -from lf_graph import lf_bar_graph, lf_scatter_graph, lf_stacked_graph, lf_horizontal_stacked_graph import random +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lf_report = importlib.import_module("lanforge-scripts.py-scripts.lf_report") +lf_report = lf_report.lf_report +lf_graph = importlib.import_module("lanforge-scripts.py-scripts.lf_graph") +lf_bar_graph = lf_graph.lf_bar_graph +lf_scatter_graph = lf_graph.lf_scatter_graph +lf_stacked_graph = lf_graph.lf_stacked_graph +lf_horizontal_stacked_graph = lf_graph.lf_horizontal_stacked_graph + + # Unit Test if __name__ == "__main__": # Testing: generate data frame diff --git a/py-scripts/lf_rvr_test.py b/py-scripts/lf_rvr_test.py index ad7f13c3..9ace21c1 100755 --- a/py-scripts/lf_rvr_test.py +++ b/py-scripts/lf_rvr_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -98,11 +97,10 @@ mconn: 1 mpkt: 1000 tos: 0 loop_iterations: 1 - """ - import sys import os +import importlib import argparse import time import json @@ -112,11 +110,13 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from cv_test_manager import cv_test as cvtest -from cv_test_manager import * +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cvtest = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser class RvrTest(cvtest): diff --git a/py-scripts/lf_rx_sensitivity_test.py b/py-scripts/lf_rx_sensitivity_test.py index f51ed36c..01853127 100644 --- a/py-scripts/lf_rx_sensitivity_test.py +++ b/py-scripts/lf_rx_sensitivity_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -100,11 +99,10 @@ mconn: 1 mpkt: 1000 tos: 0 loop_iterations: 1 - """ - import sys import os +import importlib import argparse import time import json @@ -114,11 +112,13 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from cv_test_manager import cv_test -from cv_test_manager import * +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cv_test = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser class RxSensitivityTest(cv_test): diff --git a/py-scripts/lf_sniff_radio.py b/py-scripts/lf_sniff_radio.py index 6f5fd91d..c4cc3b7c 100755 --- a/py-scripts/lf_sniff_radio.py +++ b/py-scripts/lf_sniff_radio.py @@ -15,17 +15,18 @@ --radio_mode AUTO """ - import sys - -if 'py-json' not in sys.path: - sys.path.append('../py-json') - +import os +import importlib import argparse import time -from LANforge.LFUtils import * -from realm import Realm -import realm + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class SniffRadio(Realm): diff --git a/py-scripts/lf_snp_test.py b/py-scripts/lf_snp_test.py index bd6cbd66..1314306c 100755 --- a/py-scripts/lf_snp_test.py +++ b/py-scripts/lf_snp_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - ''' NAME: lf_snp_test.py snp == Scaling and Performance @@ -140,31 +139,35 @@ COPYWRITE ''' import sys import os +import importlib import itertools from pprint import pprint - -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 -from LANforge import LFUtils -from realm import Realm import time import datetime import subprocess import csv import random import logging -from lf_report import lf_report -#from lf_graph import lf_bar_graph + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +lf_report = importlib.import_module("lanforge-scripts.py-scripts.lf_report") +# lf_graph = importlib.import_module("lanforge-scripts.py-scripts.lf_graph") +# lf_bar_graph = lf_graph.lf_bar_graph 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 diff --git a/py-scripts/lf_tr398_test.py b/py-scripts/lf_tr398_test.py index 8cbec10a..37e7776b 100755 --- a/py-scripts/lf_tr398_test.py +++ b/py-scripts/lf_tr398_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -152,11 +151,10 @@ reset: 0 mu_mimo: 0 stability: 0 ap_coex: 0 - """ - import sys import os +import importlib import argparse import time import json @@ -166,11 +164,14 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cvtest = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser -from cv_test_manager import cv_test as cvtest -from cv_test_manager import * class DataplaneTest(cvtest): def __init__(self, diff --git a/py-scripts/lf_webpage.py b/py-scripts/lf_webpage.py index ae283416..e8733d0b 100644 --- a/py-scripts/lf_webpage.py +++ b/py-scripts/lf_webpage.py @@ -7,22 +7,23 @@ python3 lf_webpage.py --mgr 192.168.200.29 --mgr_port 8080 --upstream_port eth Copyright 2021 Candela Technologies Inc 04 - April - 2021 """ - import sys +import os +import importlib import time import argparse import paramiko -if 'py-json' not in sys.path: - sys.path.append('../py-json') -from LANforge import LFUtils -from LANforge.LFUtils import * -import realm -from realm import Realm -from realm import PortUtils +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +PortUtils = realm.PortUtils +lf_report = importlib.import_module("lanforge-scripts.py-scripts.lf_report") +lf_graph = importlib.import_module("lanforge-scripts.py-scripts.lf_graph") -from lf_report import * -from lf_graph import * class HttpDownload(Realm): def __init__(self, lfclient_host, lfclient_port, upstream, num_sta, security, ssid, password, diff --git a/py-scripts/lf_wifi_capacity_test.py b/py-scripts/lf_wifi_capacity_test.py index 2f9ab4c2..3b10c698 100755 --- a/py-scripts/lf_wifi_capacity_test.py +++ b/py-scripts/lf_wifi_capacity_test.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ Note: To Run this script gui should be opened with @@ -303,9 +302,9 @@ show_4way: 1 show_latency: 1 """ - import sys import os +import importlib import argparse import time import json @@ -315,11 +314,14 @@ 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -from cv_test_manager import * -from LANforge import LFUtils +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +cv_test_manager = importlib.import_module("lanforge-scripts.py-json.cv_test_manager") +cv_test = cv_test_manager.cv_test +cv_add_base_parser = cv_test_manager.cv_add_base_parser +cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser class WiFiCapacityTest(cv_test): diff --git a/py-scripts/measure_station_time_up.py b/py-scripts/measure_station_time_up.py index 6ea49b0f..e14f78b7 100755 --- a/py-scripts/measure_station_time_up.py +++ b/py-scripts/measure_station_time_up.py @@ -3,24 +3,27 @@ """ Script for creating a variable number of stations. """ - import sys import os +import importlib import argparse +import datetime +import pprint +import pandas as pd +import time 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')) -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import datetime -import pprint -import pandas as pd -import time +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class MeasureTimeUp(Realm): diff --git a/py-scripts/modify_station.py b/py-scripts/modify_station.py index ebbbf5bf..98fb0239 100755 --- a/py-scripts/modify_station.py +++ b/py-scripts/modify_station.py @@ -1,21 +1,23 @@ #!/usr/bin/env python3 - """ Script for modifying stations. """ - import sys import os +import importlib 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')) -from LANforge.lfcli_base import LFCliBase -from realm import Realm +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class ModifyStation(Realm): diff --git a/py-scripts/modify_vap.py b/py-scripts/modify_vap.py index aebcafbd..0f9bc716 100755 --- a/py-scripts/modify_vap.py +++ b/py-scripts/modify_vap.py @@ -1,21 +1,23 @@ #!/usr/bin/env python3 - """ Script for modifying VAPs. """ - import sys import os +import importlib 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')) -from LANforge.lfcli_base import LFCliBase -from realm import Realm +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class ModifyVAP(Realm): diff --git a/py-scripts/recordinflux.py b/py-scripts/recordinflux.py index cfee0a09..80f30ffb 100755 --- a/py-scripts/recordinflux.py +++ b/py-scripts/recordinflux.py @@ -12,19 +12,18 @@ License: Free to distribute and modify. LANforge systems must be licensed. """ import sys import os +import importlib +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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -if 'py-dashboard' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) - -from LANforge.lfcli_base import LFCliBase -import argparse +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase def main(): diff --git a/py-scripts/run_cv_scenario.py b/py-scripts/run_cv_scenario.py index 373e4a59..d497e8b6 100755 --- a/py-scripts/run_cv_scenario.py +++ b/py-scripts/run_cv_scenario.py @@ -1,24 +1,25 @@ #!/usr/bin/env python3 - # This script will set the LANforge to a BLANK database then it will load the specified database # and start a graphical report - import sys +import os +import importlib +import argparse +from time import sleep +import pprint 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -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 +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm """ cvScenario.scenario_db = args.scenario_db diff --git a/py-scripts/rvr_scenario.py b/py-scripts/rvr_scenario.py index 0c0c549d..a7510afd 100755 --- a/py-scripts/rvr_scenario.py +++ b/py-scripts/rvr_scenario.py @@ -1,24 +1,26 @@ #!/usr/bin/env python3 - # This script will set the LANforge to a BLANK database then it will load the specified database # and start a graphical report - import sys +import os +import importlib +import argparse +import pprint +from pprint import pprint +from time import sleep 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge import LFUtils -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from realm import Realm -import pprint -from pprint import pprint +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm """ cvScenario.lanforge_db = args.lanforge_db diff --git a/py-scripts/sandbox/__init__.py b/py-scripts/sandbox/__init__.py index ab982366..e69de29b 100755 --- a/py-scripts/sandbox/__init__.py +++ b/py-scripts/sandbox/__init__.py @@ -1,3 +0,0 @@ -sys.path.insert(1, '../../py-json') -import LANforge -import LANforge.lfcli_base \ No newline at end of file diff --git a/py-scripts/scenario.py b/py-scripts/scenario.py index eb35fcdc..5f51b49a 100755 --- a/py-scripts/scenario.py +++ b/py-scripts/scenario.py @@ -1,19 +1,23 @@ #!/usr/bin/env python3 -import pprint import sys import os +import importlib +import pprint +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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm parser = LFCliBase.create_bare_argparse( prog='scenario.py', diff --git a/py-scripts/sta_connect.py b/py-scripts/sta_connect.py index 0b710780..bac8a222 100755 --- a/py-scripts/sta_connect.py +++ b/py-scripts/sta_connect.py @@ -1,34 +1,35 @@ #!/usr/bin/env python3 - # This will create 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 # to the requested BSSID if bssid is specified as an argument. # The script will clean up the station and connections at the end of the test. - import sys +import os +import importlib +import argparse +import time 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -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 time +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +removeCX = LFUtils.removeCX +removeEndps = LFUtils.removeEndps +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + +OPEN = "open" +WEP = "wep" +WPA = "wpa" +WPA2 = "wpa2" +MODE_AUTO = 0 -OPEN="open" -WEP="wep" -WPA="wpa" -WPA2="wpa2" -MODE_AUTO=0 class StaConnect(LFCliBase): def __init__(self, host, port, _dut_ssid="MyAP", _dut_passwd="NA", _dut_bssid="", diff --git a/py-scripts/sta_connect2.py b/py-scripts/sta_connect2.py index bf69e72b..06a79e57 100755 --- a/py-scripts/sta_connect2.py +++ b/py-scripts/sta_connect2.py @@ -4,31 +4,37 @@ # and verify whether traffic was sent and received. It also verifies the station connected # to the requested BSSID if bssid is specified as an argument. # The script will clean up the station and connections at the end of the test. - import sys +import os +import importlib +import argparse +import pprint +import time 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge import LFUtils -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from realm import Realm -import pprint -from influx import RecordInflux -import time +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +removeCX = LFUtils.removeCX +removeEndps = LFUtils.removeEndps +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +influx = importlib.import_module("lanforge-scripts.py-scripts.influx") +RecordInflux = influx.RecordInflux -OPEN="open" -WEP="wep" -WPA="wpa" -WPA2="wpa2" +OPEN = "open" +WEP = "wep" +WPA = "wpa" +WPA2 = "wpa2" WPA3 = "wpa3" -MODE_AUTO=0 +MODE_AUTO = 0 + class StaConnect2(LFCliBase): def __init__(self, host, port, _dut_ssid="jedway-open-1", _dut_passwd="NA", _dut_bssid="", diff --git a/py-scripts/sta_connect_bssid_mac.py b/py-scripts/sta_connect_bssid_mac.py index c4a04719..7b11da56 100644 --- a/py-scripts/sta_connect_bssid_mac.py +++ b/py-scripts/sta_connect_bssid_mac.py @@ -12,34 +12,35 @@ Example: --passwd "BLANK" #password --bssid 78:d2:94:4f:20:c5,78:d2:94:4f:20:c5 #bssid names --sta_name "sta001,sta002" #station names - --mac 04:f0:21:89:3e:ea,04:f0:21:89:4e:ea #mac - --bss_trans #flag to set BSS transition on all stations -""" - -import sys -import os -import argparse -import time -import json -from os import path - -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 -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge import LFUtils -from realm import Realm -import time -import datetime - - -class client_connect(Realm): + --mac 04:f0:21:89:3e:ea,04:f0:21:89:4e:ea #mac + --bss_trans #flag to set BSS transition on all stations +""" +import sys +import os +import importlib +import argparse +import time +import json +from os import path +import argparse +import time +import datetime + +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + + +class client_connect(Realm): def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio=None, sta_name=None, ssid=None, security=None, paswd=None, bssid=None, mac=None, bss_trans=False): super().__init__(lfclient_host, lfclient_port) diff --git a/py-scripts/sta_connect_example.py b/py-scripts/sta_connect_example.py index b034c0af..da6961b7 100755 --- a/py-scripts/sta_connect_example.py +++ b/py-scripts/sta_connect_example.py @@ -1,21 +1,24 @@ #!/usr/bin/env python3 - # Example of how to instantiate StaConnect and run the test - import sys +import os +import importlib +import time +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('../py-json') + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) # if you lack __init__.py in this directory you will not find sta_connect module -import sta_connect -from sta_connect import StaConnect -import time -import argparse -from LANforge.lfcli_base import LFCliBase +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +sta_connect = importlib.import_module("lanforge-scripts.py-scripts.sta_connect") +StaConnect = sta_connect.StaConnect + def main(): parser = LFCliBase.create_basic_argparse( diff --git a/py-scripts/sta_connect_multi_example.py b/py-scripts/sta_connect_multi_example.py index 33196bdf..9a239244 100755 --- a/py-scripts/sta_connect_multi_example.py +++ b/py-scripts/sta_connect_multi_example.py @@ -1,25 +1,25 @@ #!/usr/bin/env python3 - - # Example of how to instantiate StaConnect and run the test - import sys +import os +import importlib +import pprint +from pprint import pprint 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') + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) # if you lack __init__.py in this directory you will not find sta_connect module -import pprint -from pprint import pprint -import sta_connect -from sta_connect import * -import realm -from realm import Realm -import LANforge -from LANforge import LFUtils +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +sta_connect = importlib.import_module("lanforge-scripts.py-scripts.sta_connect") +StaConnect = sta_connect.StaConnect + def main(): # create multiple OPEN stations diff --git a/py-scripts/station_layer3.py b/py-scripts/station_layer3.py index 0f749ae9..b074c4b7 100644 --- a/py-scripts/station_layer3.py +++ b/py-scripts/station_layer3.py @@ -1,22 +1,26 @@ -'''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"): +#!/usr/bin/env python3 +''' +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 os +import importlib +import argparse +import time + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.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 @@ -97,7 +101,6 @@ def main(): obj.precleanup(station_list) obj.build() obj.start(station_list) - - -if __name__ == '__main__': - main() \ No newline at end of file + +if __name__ == '__main__': + main() diff --git a/py-scripts/stations_connected.py b/py-scripts/stations_connected.py index 96c4c3ae..04a8f26c 100755 --- a/py-scripts/stations_connected.py +++ b/py-scripts/stations_connected.py @@ -1,20 +1,23 @@ #!/usr/bin/env python3 - # Contains examples of using realm to query stations and get specific information from them - import sys +import os +import importlib +import pprint +from pprint import pprint 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -from LANforge.lfcli_base import LFCliBase -from realm import Realm -import pprint -from pprint import pprint class StationsConnected(LFCliBase): def __init__(self, lfjson_host, lfjson_port): diff --git a/py-scripts/test_1k_clients_jedtest.py b/py-scripts/test_1k_clients_jedtest.py index 3c047387..b9dbc9a7 100755 --- a/py-scripts/test_1k_clients_jedtest.py +++ b/py-scripts/test_1k_clients_jedtest.py @@ -1,21 +1,26 @@ #!/usr/bin/env python3 import sys -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - import os - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -from realm import Realm -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils +import importlib import argparse import time import datetime import pprint +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + + class Test1KClients(LFCliBase): def __init__(self, upstream, diff --git a/py-scripts/test_client_admission.py b/py-scripts/test_client_admission.py index f750ff8b..173d18fa 100755 --- a/py-scripts/test_client_admission.py +++ b/py-scripts/test_client_admission.py @@ -6,17 +6,19 @@ -date: 23-02-2021 """ import sys +import os +import importlib 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 +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class LoadLayer3(Realm): @@ -119,4 +121,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/py-scripts/test_fileio.py b/py-scripts/test_fileio.py index 8cf8e6c7..a5b875a6 100755 --- a/py-scripts/test_fileio.py +++ b/py-scripts/test_fileio.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: test_fileio.py @@ -27,27 +26,28 @@ Use './test_fileio.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - import sys +import os +import importlib +import argparse +import time +import datetime +import pprint + 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -# 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 -import realm -import time -import datetime -import pprint -import os +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +add_file_endp = importlib.import_module("lanforge-scripts.py-json.LANforge.add_file_endp") +fe_fstype = add_file_endp.fe_fstype +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class FileIOTest(LFCliBase): diff --git a/py-scripts/test_generic.py b/py-scripts/test_generic.py index 50118d15..2fffdee5 100755 --- a/py-scripts/test_generic.py +++ b/py-scripts/test_generic.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: test_generic.py @@ -32,25 +31,28 @@ Use './test_generic.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - -import pprint import sys import os +import importlib +import pprint +import argparse +import time +import datetime +import json 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import time -import datetime -import json class GenTest(LFCliBase): def __init__(self, ssid, security, passwd, sta_list, client, name_prefix, upstream, host="localhost", port=8080, diff --git a/py-scripts/test_ip_connection.py b/py-scripts/test_ip_connection.py index db41b1fe..ac17f747 100755 --- a/py-scripts/test_ip_connection.py +++ b/py-scripts/test_ip_connection.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: test_ip_connection.py This script combines functionality of test_ipv4_connection.py and test_ipv6_connection.py. @@ -21,23 +20,26 @@ Use './test_ip_connection.py' --help to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - import sys import os +import importlib import argparse +import time +import pprint 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 time -import pprint +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + class ConnectTest(LFCliBase): def __init__(self, diff --git a/py-scripts/test_ip_variable_time.py b/py-scripts/test_ip_variable_time.py index 3eef1e0f..bbfa2f52 100755 --- a/py-scripts/test_ip_variable_time.py +++ b/py-scripts/test_ip_variable_time.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: test_ip_variable_time.py @@ -24,24 +23,22 @@ Use './test_ip_variable_time.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - import sys import os +import importlib +import argparse +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -if 'py-dashboard' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) - -import argparse -from LANforge import LFUtils -from realm import Realm -import datetime +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class IPVariableTime(Realm): diff --git a/py-scripts/test_ipv4_ps.py b/py-scripts/test_ipv4_ps.py index eb5b0fdb..264c9e49 100755 --- a/py-scripts/test_ipv4_ps.py +++ b/py-scripts/test_ipv4_ps.py @@ -1,21 +1,23 @@ #!/usr/bin/env python3 - import sys import os +import importlib +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import time -import datetime +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class IPV4VariableTime(LFCliBase): diff --git a/py-scripts/test_ipv4_ttls.py b/py-scripts/test_ipv4_ttls.py index bc54998b..09228af7 100755 --- a/py-scripts/test_ipv4_ttls.py +++ b/py-scripts/test_ipv4_ttls.py @@ -1,23 +1,25 @@ #!/usr/bin/env python3 - - import sys import os +import importlib import argparse +import time +import pprint 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 time -import pprint -from test_ip_variable_time import IPVariableTime +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +test_ip_variable_time = importlib.import_module("lanforge-scripts.py-scripts.test_ip_variable_time") +IPVariableTime = test_ip_variable_time.IPVariableTime class TTLSTest(LFCliBase): diff --git a/py-scripts/test_l3_WAN_LAN.py b/py-scripts/test_l3_WAN_LAN.py index 2b315f8a..121628d5 100755 --- a/py-scripts/test_l3_WAN_LAN.py +++ b/py-scripts/test_l3_WAN_LAN.py @@ -1,21 +1,23 @@ #!/usr/bin/env python3 - import sys import os +import importlib +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import time -import datetime +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm class VRTest(LFCliBase): diff --git a/py-scripts/test_l3_longevity.py b/py-scripts/test_l3_longevity.py index 0d425413..871ac994 100755 --- a/py-scripts/test_l3_longevity.py +++ b/py-scripts/test_l3_longevity.py @@ -44,34 +44,38 @@ COPYRIGHT: Copyright 2021 Candela Technologies Inc INCLUDE_IN_README - ''' - - import sys import os +import importlib +from pprint import pprint +import re +import serial +import pexpect +from pexpect_serial import SerialSpawn +import argparse +import time +import datetime +import subprocess +import csv 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')) -if 'py-dashboard' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lf_report = importlib.import_module("lanforge-scripts.py-scripts.lf_report") +# lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +# LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +csv_to_influx = importlib.import_module("lanforge-scripts.py-scripts.csv_to_influx") +InfluxRequest = importlib.import_module("lanforge-scripts.py-dashboard.InfluxRequest") +influx_add_parser_args = InfluxRequest.influx_add_parser_args -from pprint import pprint -from InfluxRequest import * -import serial -import pexpect -from pexpect_serial import SerialSpawn -from lf_report import lf_report -import argparse -from LANforge import LFUtils -from realm import Realm -import time -import datetime -import csv # This class handles running the test and generating reports. class L3VariableTime(Realm): @@ -288,83 +292,52 @@ class L3VariableTime(Realm): def get_endp_stats_for_port(self, eid_name, endps): lat = 0 jit = 0 - total_dl_rate = 0 - total_dl_rate_ll = 0 - total_dl_pkts_ll = 0 - total_ul_rate = 0 - total_ul_rate_ll = 0 - total_ul_pkts_ll = 0 + tput = 0 count = 0 - sta_name = 'no_station' #print("endp-stats-for-port, port-eid: {}".format(eid_name)) eid = self.name_to_eid(eid_name) - print("eid_name: {eid_name} eid: {eid}".format(eid_name=eid_name,eid=eid)) # Convert all eid elements to strings eid[0] = str(eid[0]) eid[1] = str(eid[1]) eid[2] = str(eid[2]) - for endp in endps: - pprint(endp) - eid_endp = endp["eid"].split(".") - print("Comparing eid:{eid} to endp-id {eid_endp}".format(eid=eid,eid_endp=eid_endp)) + for e in endps: + #pprint(e) + eid_endp = e["eid"].split(".") + print("Comparing eid: ", eid, " to endp-id: ", eid_endp) # Look through all the endpoints (endps), to find the port the eid_name is using. # The eid_name that has the same Shelf, Resource, and Port as the eid_endp (looking at all the endps) # Then read the eid_endp to get the delay, jitter and rx rate # Note: the endp eid is shelf.resource.port.endp-id, the eid can be treated somewhat as # child class of port-eid , and look up the port the eid is using. if eid[0] == eid_endp[0] and eid[1] == eid_endp[1] and eid[2] == eid_endp[2]: - lat += int(endp["delay"]) - jit += int(endp["jitter"]) - name = endp["name"] - print("endp name {name}".format(name=name)) - sta_name = name.replace('-A','') - #only the -A endpoint will be found so need to look - - + lat += int(e["delay"]) + jit += int(e["jitter"]) + tput += int(e["rx rate"]) count += 1 - print("Matched: name: {name} eid:{eid} to endp-id {eid_endp}".format(name=name,eid=eid,eid_endp=eid_endp)) + print("matched: ") else: - name = endp["name"] - print("No Match: name: {name} eid:{eid} to endp-id {eid_endp}".format(name=name,eid=eid,eid_endp=eid_endp)) + print("Did not match") if count > 1: lat = int(lat / count) jit = int(jit / count) - # need to loop though again to find the upload and download per station if the name matched - for endp in endps: - if sta_name in endp["name"]: - name = endp["name"] - if name.endswith("-A"): - print("name has -A") - total_dl_rate += int(endp["rx rate"]) - total_dl_rate_ll += int(endp["rx rate ll"]) - total_dl_pkts_ll += int(endp["rx pkts ll"]) - # -B upload side - else: - total_ul_rate += int(endp["rx rate"]) - total_ul_rate_ll += int(endp["rx rate ll"]) - total_ul_pkts_ll += int(endp["rx pkts ll"]) - - - return lat, jit, total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll + return lat, jit, tput # Query all endpoints to generate rx and other stats, returned # as an array of objects. def __get_rx_values(self): - endp_list = self.json_get("endp?fields=name,eid,delay,jitter,rx+rate,rx+rate+ll,rx+bytes,rx+drop+%25,rx+pkts+ll", debug_=False) + endp_list = self.json_get("endp?fields=name,eid,delay,jitter,rx+rate,rx+bytes,rx+drop+%25", debug_=False) endp_rx_drop_map = {} endp_rx_map = {} our_endps = {} endps = [] total_ul = 0 - total_ul_ll = 0 total_dl = 0 - total_dl_ll = 0 for e in self.multicast_profile.get_mc_names(): our_endps[e] = e; @@ -377,16 +350,10 @@ class L3VariableTime(Realm): endps.append(value) print("endpoint: ", item, " value:\n") pprint(value) - + for value_name, value in value.items(): if value_name == 'rx bytes': endp_rx_map[item] = value - if value_name == 'rx rate': - endp_rx_map[item] = value - if value_name == 'rx rate ll': - endp_rx_map[item] = value - if value_name == 'rx pkts ll': - endp_rx_map[item] = value if value_name == 'rx drop %': endp_rx_drop_map[item] = value if value_name == 'rx rate': @@ -396,16 +363,9 @@ class L3VariableTime(Realm): total_dl += int(value) else: total_ul += int(value) - if value_name == 'rx rate ll': - # This hack breaks for mcast or if someone names endpoints weirdly. - if item.endswith("-A"): - total_dl_ll += int(value) - else: - total_ul_ll += int(value) - #print("total-dl: ", total_dl, " total-ul: ", total_ul, "\n") - return endp_rx_map, endp_rx_drop_map, endps, total_dl, total_ul, total_dl_ll, total_ul_ll + return endp_rx_map, endp_rx_drop_map, endps, total_dl, total_ul # Common code to generate timestamp for CSV files. def time_stamp(self): @@ -535,7 +495,7 @@ class L3VariableTime(Realm): ss.sendline(str(self.ap_cmd_5g)) ss.expect([pexpect.TIMEOUT], timeout=1) # do not detete line, waits for output ap_stats_5g = ss.before.decode('utf-8','ignore') - print("ap_stats_5g from AP: {}".format(ap_stats_5g)) + print("ap_stats_5g {}".format(ap_stats_5g)) except: print("WARNING unable to read AP") @@ -551,8 +511,8 @@ class L3VariableTime(Realm): ss = SerialSpawn(ser) ss.sendline(str(self.ap_cmd_2g)) ss.expect([pexpect.TIMEOUT], timeout=1) # do not detete line, waits for output - ap_stats_2g = ss.before.decode('utf-8','ignore') - print("ap_stats_2g from AP: {}".format(ap_stats_2g)) + ap_stats = ss.before.decode('utf-8','ignore') + print("ap_stats_2g {}".format(ap_stats_2g)) except: print("WARNING unable to read AP") @@ -683,7 +643,7 @@ class L3VariableTime(Realm): cur_time = datetime.datetime.now() print("Getting initial values.") - old_rx_values, rx_drop_percent, endps, total_dl_bps, total_ul_bps, total_dl_ll_bps, total_ul_ll_bps = self.__get_rx_values() + old_rx_values, rx_drop_percent, endps, total_dl_bps, total_ul_bps = self.__get_rx_values() end_time = self.parse_time(self.test_duration) + cur_time @@ -694,8 +654,6 @@ class L3VariableTime(Realm): expected_passes = 0 total_dl_bps = 0 total_ul_bps = 0 - total_dl_ll_bps = 0 - total_ul_ll_bps = 0 endps = [] ap_row = [] ap_stats_col_titles = [] @@ -712,9 +670,9 @@ class L3VariableTime(Realm): time.sleep(.2) self.epoch_time = int(time.time()) - new_rx_values, rx_drop_percent, endps, total_dl_bps, total_ul_bps, total_dl_ll_bps, total_ul_ll_bps = self.__get_rx_values() + new_rx_values, rx_drop_percent, endps, total_dl_bps, total_ul_bps = self.__get_rx_values() - print("main loop, total-dl: ", total_dl_bps, " total-ul: ", total_ul_bps, " total-dl-ll: ", total_dl_ll_bps," total-ul-ll: ", total_ul_ll_bps) + #print("main loop, total-dl: ", total_dl_bps, " total-ul: ", total_ul_bps) # AP OUTPUT if self.ap_read: @@ -733,9 +691,7 @@ class L3VariableTime(Realm): ap_chanim_stats_5g = "{}{}{}{}".format("root@Docsis-Gateway:~# wl -i wl1 chanim_stats\n", "version: 3\n", "chanspec tx inbss obss nocat nopkt doze txop goodtx badtx glitch badplcp knoise idle timestamp\n", - #`"0xe06a 61 15 0 17 0 0 6 53 2 0 0 -91 65 343370578\n") - "0xe06a 1.67 15.00 0.00 17.00 0.00 0.00 97.33 53.00 2.00 0 0 -91 65 343370578\n") - + "0xe06a 61 15 0 17 0 0 6 53 2 0 0 -91 65 343370578\n") else: # read from the AP ap_stats_5g = self.read_ap_stats_5g() @@ -763,7 +719,7 @@ class L3VariableTime(Realm): # print("response".format(response)) pprint(response) p = response['interface'] - print("#### From LANforge: p, response['insterface']:{}".format(p)) + #print("#### From LANforge: p, response['insterface']:{}".format(p)) mac = p['mac'] #print("#### From LANforge: p['mac']: {mac}".format(mac=mac)) @@ -791,7 +747,7 @@ class L3VariableTime(Realm): print("selected ap_row (from split_row): {}".format(ap_row)) # Find latency, jitter for connections using this port. - latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll = self.get_endp_stats_for_port(p["port"], endps) + latency, jitter, tput = self.get_endp_stats_for_port(p["port"], endps) # now report the ap_chanim_stats along side of the ap_stats_5g xtop_reported = False @@ -800,9 +756,7 @@ class L3VariableTime(Realm): if xtop_reported: try: xtop = split_row[7] - print("xtop 5g {xtop}".format(xtop=xtop)) - channel_utilization = float(100) - float(xtop) - print("channel_utilization {utilization}".format(utilization=channel_utilization)) + channel_utilization = 100 - int(xtop) except: print("detected chanspec with reading chanim_stats, failed reading xtop") # should be only one channel utilization @@ -821,8 +775,7 @@ class L3VariableTime(Realm): ap_stats_5g_col_titles = ['Station Address','PHY Mbps','Data Mbps','Air Use','Data Use','Retries','bw','mcs','Nss','ofdma','mu-mimo','channel_utilization'] self.write_port_csv(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, eid_name, p, - latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, - total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll , ap_row, ap_stats_5g_col_titles) #ap_stats_5g_col_titles used as a length + latency, jitter, tput, ap_row, ap_stats_5g_col_titles) #ap_stats_5g_col_titles used as a length if self.ap_test_mode: # Create the test data as a continuous string ap_stats_2g="{}{}{}{}{}{}".format("root@Docsis-Gateway:~# wl -i wl1 bs_data\n", @@ -838,8 +791,7 @@ class L3VariableTime(Realm): ap_chanim_stats_2g = "{}{}{}{}".format("root@Docsis-Gateway:~# wl -i wl1 chanim_stats\n", "version: 3\n", "chanspec tx inbss obss nocat nopkt doze txop goodtx badtx glitch badplcp knoise idle timestamp\n", - #"0xe06a 62 15 0 17 0 0 6 53 2 0 0 -91 65 343370578\n") - "0xe06a 1.67 15.00 0.00 17.00 0.00 0.00 97.33 53.00 2.00 0 0 -91 65 343370578\n") + "0xe06a 61 15 0 17 0 0 6 53 2 0 0 -91 65 343370578\n") else: # read from the AP ap_stats_2g = self.read_ap_stats_2g() @@ -895,7 +847,7 @@ class L3VariableTime(Realm): print("selected ap_row (from split_row): {}".format(ap_row)) # Find latency, jitter for connections using this port. - latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll = self.get_endp_stats_for_port(p["port"], endps) + latency, jitter, tput = self.get_endp_stats_for_port(p["port"], endps) # now report the ap_chanim_stats along side of the ap_stats_2g xtop_reported = False @@ -904,9 +856,7 @@ class L3VariableTime(Realm): if xtop_reported: try: xtop = split_row[7] - print("xtop 2g {xtop}".format(xtop=xtop)) - channel_utilization = float(100) - float(xtop) - print("channel_utilization 2g {utilization}".format(utilization=channel_utilization)) + channel_utilization = 100 - int(xtop) except: print("detected chanspec with reading chanim_stats, failed reading xtop") # should be only one channel utilization @@ -925,8 +875,7 @@ class L3VariableTime(Realm): ap_stats_2g_col_titles = ['Station Address','PHY Mbps','Data Mbps','Air Use','Data Use','Retries','bw','mcs','Nss','ofdma','mu-mimo','channel_utilization'] self.write_port_csv(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, eid_name, p, - latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, - total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll, ap_row, ap_stats_2g_col_titles) #ap_stats_2g_col_titles used as a length + latency, jitter, tput, ap_row, ap_stats_2g_col_titles) #ap_stats_2g_col_titles used as a length else: @@ -942,15 +891,14 @@ class L3VariableTime(Realm): pprint(response) else: p = response['interface'] - latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll= self.get_endp_stats_for_port(p["port"], endps) + latency, jitter, tput = self.get_endp_stats_for_port(p["port"], endps) self.write_port_csv(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, eid_name, p, - latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, - total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll, ap_row, ap_stats_col_titles) #ap_stats_col_titles used as a length + latency, jitter, tput, ap_row, ap_stats_col_titles) #ap_stats_col_titles used as a length - # At end of test step, record KPI information. This is different the kpi.csv - self.record_kpi(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, total_dl_bps, total_ul_bps, total_dl_ll_bps, total_ul_ll_bps) + # At end of test step, record KPI information. + self.record_kpi(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, total_dl_bps, total_ul_bps) # At end of test if requested store upload and download stats if self.ap_scheduler_stats: @@ -975,15 +923,15 @@ class L3VariableTime(Realm): if passes == expected_passes: self._pass("PASS: Requested-Rate: %s <-> %s PDU: %s <-> %s All tests passed" % (ul, dl, ul_pdu, dl_pdu), print_pass) - def write_port_csv(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, eid_name, port_data, latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, - total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll, ap_row, ap_stats_col_titles): + def write_port_csv(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, eid_name, port_data, latency, jitter, tput, + ap_row, ap_stats_col_titles): row = [self.epoch_time, self.time_stamp(), sta_count, ul, ul, dl, dl, dl_pdu, dl_pdu, ul_pdu, ul_pdu, atten, eid_name ] row = row + [port_data['bps rx'], port_data['bps tx'], port_data['rx-rate'], port_data['tx-rate'], - port_data['signal'], port_data['ap'], port_data['mode'], latency, jitter, total_ul_rate, total_ul_rate_ll, total_ul_pkts_ll, total_dl_rate, total_dl_rate_ll, total_dl_pkts_ll] + port_data['signal'], port_data['ap'], port_data['mode'], latency, jitter, tput] #Add in info queried from AP. NOTE: do not need to pass in the ap_stats_col_titles #print("ap_row length {} col_titles length {}".format(len(ap_row),len(self.ap_stats_col_titles))) @@ -1001,7 +949,7 @@ class L3VariableTime(Realm): # Submit data to the influx db if configured to do so. - def record_kpi(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, total_dl_bps, total_ul_bps, total_dl_ll_bps, total_ul_ll_bps): + def record_kpi(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, total_dl_bps, total_ul_bps): tags = dict() tags['requested-ul-bps'] = ul @@ -1029,8 +977,7 @@ class L3VariableTime(Realm): row = [self.epoch_time, self.time_stamp(), sta_count, ul, ul, dl, dl, dl_pdu, dl_pdu, ul_pdu, ul_pdu, atten, - total_dl_bps, total_ul_bps, (total_ul_bps + total_dl_bps), - total_dl_ll_bps, total_ul_ll_bps, (total_ul_ll_bps + total_dl_ll_bps) + total_dl_bps, total_ul_bps, (total_ul_bps + total_dl_bps) ] # Add values for any user specified tags for k in self.user_tags: @@ -1067,7 +1014,7 @@ class L3VariableTime(Realm): 'UL-Min-Requested','UL-Max-Requested','DL-Min-Requested','DL-Max-Requested', 'UL-Min-PDU','UL-Max-PDU','DL-Min-PDU','DL-Max-PDU','Attenuation', 'Name', 'Rx-Bps', 'Tx-Bps', 'Rx-Link-Rate', 'Tx-Link-Rate', 'RSSI', 'AP', 'Mode', - 'Rx-Latency', 'Rx-Jitter', 'Ul-Rx-Goodput-bps', 'Ul-Rx-Rate-ll', 'Ul-Rx-Pkts-ll', 'Dl-Rx-Goodput-bps', 'Dl-Rx-Rate-ll', 'Dl-Rx-Pkts-ll' + 'Rx-Latency', 'Rx-Jitter', 'Rx-Goodput-Bps' ] # Add in columns we are going to query from the AP for col in self.ap_stats_col_titles: @@ -1079,8 +1026,7 @@ class L3VariableTime(Realm): csv_rx_headers = ['Time epoch', 'Time', 'Station-Count', 'UL-Min-Requested','UL-Max-Requested','DL-Min-Requested','DL-Max-Requested', 'UL-Min-PDU','UL-Max-PDU','DL-Min-PDU','DL-Max-PDU','Attenuation', - 'Total-Download-Bps', 'Total-Upload-Bps', 'Total-UL/DL-Bps', - 'Total-Download-LL-Bps', 'Total-Upload-LL-Bps','Total-UL/DL-LL-Bps' + 'Total-Download-Bps', 'Total-Upload-Bps', 'Total-UL/DL-Bps' ] for k in self.user_tags: csv_rx_headers.append(k[0]) @@ -1227,7 +1173,7 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp m 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('--lfmgr', help='--lfmgr ',default='localhost') + parser.add_argument('--mgr', help='--mgr ',default='localhost') parser.add_argument('--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('--tos', help='--tos: Support different ToS settings: BK | BE | VI | VO | numeric',default="BE") parser.add_argument('--debug', help='--debug flag present debug on enable debugging',action='store_true') @@ -1243,9 +1189,7 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp m parser.add_argument('--ap_read', help='--ap_read flag present enable reading ap', action='store_true') parser.add_argument('--ap_port', help='--ap_port \'/dev/ttyUSB0\'',default='/dev/ttyUSB0') parser.add_argument('--ap_baud', help='--ap_baud \'115200\'',default='115200') - # note wl1 is the 5G interface , check the MAC ifconfig -a of the interface to the AP BSSID connection (default may be eth7) parser.add_argument('--ap_cmd_5g', help='ap_cmd_5g \'wl -i wl1 bs_data\'', default="wl -i wl1 bs_data") - # note wl1 is the 2.4G interface , check the MAC ifconfig -a of the interface to the AP BSSID connection parser.add_argument('--ap_cmd_2g', help='ap_cmd_2g \'wl -i wl0 bs_data\'', default="wl -i wl0 bs_data") parser.add_argument('--ap_chanim_cmd_5g', help='ap_chanim_cmd_5g \'wl -i wl1 chanim_stats\'', default="wl -i wl1 chanim_stats") parser.add_argument('--ap_chanim_cmd_2g', help='ap_chanim_cmd_2g \'w1 -i wl0 chanim_stats\'', default="wl -i wl0 chanim_stats") @@ -1333,8 +1277,8 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp m if args.endp_type: endp_types = args.endp_type - if args.lfmgr: - lfjson_host = args.lfmgr + if args.mgr: + lfjson_host = args.mgr if args.upstream_port: side_b = args.upstream_port @@ -1366,7 +1310,7 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp m influxdb = None if args.influx_bucket is not None: - from InfluxRequest import RecordInflux + from influx2 import RecordInflux influxdb = RecordInflux(_influx_host=args.influx_host, _influx_port=args.influx_port, _influx_org=args.influx_org, diff --git a/py-scripts/test_l3_powersave_traffic.py b/py-scripts/test_l3_powersave_traffic.py index 77cb8592..f4f2c323 100755 --- a/py-scripts/test_l3_powersave_traffic.py +++ b/py-scripts/test_l3_powersave_traffic.py @@ -1,23 +1,25 @@ #!/usr/bin/env python3 import sys -import pprint import os +import importlib +import pprint +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge import LFUtils -import l3_cxprofile -import realm -import time -import datetime +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +l3_cxprofile = importlib.import_module("lanforge-scripts.py-json.l3_cxprofile") # Currently, this test can only be applied to UDP connections diff --git a/py-scripts/test_l3_scenario_throughput.py b/py-scripts/test_l3_scenario_throughput.py index d36caf5f..6d51edc1 100755 --- a/py-scripts/test_l3_scenario_throughput.py +++ b/py-scripts/test_l3_scenario_throughput.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 ''' - This Script Loads the Existing Scenario and Run the Simultaenous Throughput over time and Generate Report and Plot the Graph This Script has three classes : 1. LoadScenario : It will load the existing saved scenario to the Lanforge (Here used for Loading Bridged VAP) @@ -25,26 +24,12 @@ This Script is intended to automate the testing of DUT That has stations as well as AP. To automate the simultaenous testing and check the DUT Temperature ''' - 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 os +import importlib import argparse import time -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 import logging - import paramiko as pmgo from paramiko.ssh_exception import NoValidConnectionsError as exception import xlsxwriter @@ -56,6 +41,20 @@ from bokeh.layouts import row from datetime import datetime import socket +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit(1) + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + + # Specifically for Measuring CPU Core Temperatures class Login_DUT: diff --git a/py-scripts/test_l3_unicast_traffic_gen.py b/py-scripts/test_l3_unicast_traffic_gen.py index 3ef31fae..87ac0557 100755 --- a/py-scripts/test_l3_unicast_traffic_gen.py +++ b/py-scripts/test_l3_unicast_traffic_gen.py @@ -1,21 +1,24 @@ #!/usr/bin/env python3 - import sys import os +import importlib +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import time -import datetime class L3VariableTimeLongevity(LFCliBase): def __init__(self, host, port, endp_type, side_b, radios, radio_name_list, number_of_stations_per_radio_list, diff --git a/py-scripts/test_l4.py b/py-scripts/test_l4.py index e2200500..85290d25 100755 --- a/py-scripts/test_l4.py +++ b/py-scripts/test_l4.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """ NAME: test_l4.py @@ -51,25 +50,28 @@ Use './test_l4.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. """ - import sys import os +import importlib +import time +import argparse +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import time -import datetime -from realm import TestGroupProfile -from port_utils import PortUtils +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +TestGroupProfile = realm.TestGroupProfile +port_utils = importlib.import_module("lanforge-scripts.py-json.port_utils") +PortUtils = port_utils.PortUtils class IPV4L4(LFCliBase): diff --git a/py-scripts/test_status_msg.py b/py-scripts/test_status_msg.py index bdc925ad..b5a37c0f 100755 --- a/py-scripts/test_status_msg.py +++ b/py-scripts/test_status_msg.py @@ -1,21 +1,23 @@ #!/usr/bin/env python3 - -import os import sys +import os +import importlib +# import time +import argparse +from uuid import uuid1 +import pprint +from pprint import pprint 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase -import argparse -from LANforge.lfcli_base import LFCliBase -# import time -from uuid import uuid1 -import pprint -from pprint import pprint class TestStatusMessage(LFCliBase): def __init__(self, host, port, diff --git a/py-scripts/test_wanlink.py b/py-scripts/test_wanlink.py index 4e603fde..0bb41963 100755 --- a/py-scripts/test_wanlink.py +++ b/py-scripts/test_wanlink.py @@ -6,20 +6,24 @@ sample command: ./test_wanlink.py --name my_wanlink4 --latency_A 20 --latency_B 69 --rate 1000 --jitter_A 53 --jitter_B 73 --jitter_freq 6 --drop_A 12 --drop_B 11 """ - import sys +import os +import importlib +import argparse + if sys.version_info[0] != 3: print("This script requires Python 3") exit(1) -import os -import importlib -import argparse -sys.path.append("../py-json") -import LANforge -from LANforge.lfcli_base import LFCliBase -from realm import Realm -import create_wanlink +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +create_wanlink = importlib.import_module("lanforge-scripts.py-json.create_wanlink") class LANtoWAN(Realm): diff --git a/py-scripts/test_wpa_passphrases.py b/py-scripts/test_wpa_passphrases.py index ec36cd31..c748b34c 100755 --- a/py-scripts/test_wpa_passphrases.py +++ b/py-scripts/test_wpa_passphrases.py @@ -1,24 +1,28 @@ #!/usr/bin/env python3 - ''' test_wpa_passphrases will test challenging wpa psk passphrases Use './test_wpa_passphrases.py --help' to see command line usage and options Copyright 2021 Candela Technologies Inc License: Free to distribute and modify. LANforge systems must be licensed. ''' - +import sys +import os +import importlib +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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm class WPAPassphrases(Realm): def __init__(self, @@ -34,4 +38,4 @@ def main(): pass if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/testgroup.py b/py-scripts/testgroup.py index 69b91ad5..f82384d1 100755 --- a/py-scripts/testgroup.py +++ b/py-scripts/testgroup.py @@ -1,18 +1,23 @@ #!/usr/bin/env python3 - import sys +import os +import importlib +import argparse +import time + 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge import LFUtils -import argparse -import realm class TestGroup(LFCliBase): def __init__(self, host, port, @@ -159,4 +164,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/testgroup2.py b/py-scripts/testgroup2.py index 700720c6..929296e0 100755 --- a/py-scripts/testgroup2.py +++ b/py-scripts/testgroup2.py @@ -1,28 +1,29 @@ #!/usr/bin/env python3 - """ This script will create a variable number of layer3 stations each with their own set of cross-connects and endpoints. Use './create_l3.py --help' to see command line usage and options """ - import sys import os +import importlib +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -from realm import Realm -import time -import datetime -from realm import TestGroupProfile +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm +TestGroupProfile = realm.TestGroupProfile class TestGroup2(Realm): diff --git a/py-scripts/tip-cicd-sanity/Nightly_Sanity.py b/py-scripts/tip-cicd-sanity/Nightly_Sanity.py index 81a15657..c0b6d9a9 100755 --- a/py-scripts/tip-cicd-sanity/Nightly_Sanity.py +++ b/py-scripts/tip-cicd-sanity/Nightly_Sanity.py @@ -1,5 +1,7 @@ #!/usr/bin/python3 - +import sys +import os +import importlib import base64 import urllib.request from bs4 import BeautifulSoup @@ -10,7 +12,6 @@ import tarfile import paramiko from paramiko import SSHClient from scp import SCPClient -import os import pexpect from pexpect import pxssh import sys @@ -39,40 +40,34 @@ import glob 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') -from LANforge.LFUtils import * +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) -# if you lack __init__.py in this directory you will not find sta_connect module# - -if 'py-json' not in sys.path: - sys.path.append('../../py-scripts') - -import sta_connect2 -from sta_connect2 import StaConnect2 -import testrail_api -from testrail_api import APIClient -import eap_connect -from eap_connect import EAPConnect -import cloudsdk -from cloudsdk import CloudSDK -import ap_ssh -from ap_ssh import ssh_cli_active_fw -from ap_ssh import iwinfo_status +sta_connect2 = importlib.import_module("lanforge-scripts.py-scripts.sta_connect2") +StaConnect2 = sta_connect2.StaConnect2 +testrail_api = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.testrail_api") +APIClient = testrail_api.APIClient +eap_connect = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.eap_connect") +EAPConnect = eap_connect.EAPConnect +cloudsdk = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.cloudsdk") +CloudSDK = cloudsdk.CloudSDK +ap_ssh = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.ap_ssh") +ssh_cli_active_fw = ap_ssh.ssh_cli_active_fw +iwinfo_status = ap_ssh.iwinfo_status ##Import info for lab setup and APs under test -import lab_ap_info -from lab_ap_info import equipment_id_dict -from lab_ap_info import profile_info_dict -from lab_ap_info import cloud_sdk_models -from lab_ap_info import equipment_ip_dict -from lab_ap_info import eqiupment_credentials_dict -from lab_ap_info import ap_models -from lab_ap_info import customer_id -from lab_ap_info import cloud_type -from lab_ap_info import test_cases -from lab_ap_info import radius_info +lab_ap_info = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.lab_ap_info") +equipment_id_dict = lab_ap_info.equipment_id_dict +profile_info_dict = lab_ap_info.profile_info_dict +cloud_sdk_models = lab_ap_info.cloud_sdk_models +equipment_ip_dict = lab_ap_info.equipment_ip_dict +eqiupment_credentials_dict = lab_ap_info.eqiupment_credentials_dict +ap_models = lab_ap_info.ap_models +customer_id = lab_ap_info.customer_id +cloud_type = lab_ap_info.cloud_type +test_cases = lab_ap_info.test_cases +radius_info = lab_ap_info.radius_info ### Set CloudSDK URL ### cloudSDK_url = os.getenv('CLOUD_SDK_URL') diff --git a/py-scripts/tip-cicd-sanity/Throughput_Test.py b/py-scripts/tip-cicd-sanity/Throughput_Test.py index 8200d33d..f3dc097a 100755 --- a/py-scripts/tip-cicd-sanity/Throughput_Test.py +++ b/py-scripts/tip-cicd-sanity/Throughput_Test.py @@ -1,3 +1,6 @@ +import sys +import os +import importlib import csv import sys import time @@ -7,11 +10,19 @@ import json import os import logging +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) + import single_client_throughput +single_client_throughput = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.single_client_throughput") import cloudsdk +cloudsdk = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.cloudsdk") from cloudsdk import CloudSDK +CloudSDK = cloudsdk.CloudSDK import lab_ap_info +lab_ap_info = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.lab_ap_info") import throughput_profiles +throughput_profiles = importlib.import_module("lanforge-scripts.py-scripts.tip-cicd-sanity.throughput_profiles") cloudSDK_url=os.getenv('CLOUD_SDK_URL') station = ["tput5000"] diff --git a/py-scripts/tip-cicd-sanity/eap_connect.py b/py-scripts/tip-cicd-sanity/eap_connect.py index 628f2914..452dac7d 100755 --- a/py-scripts/tip-cicd-sanity/eap_connect.py +++ b/py-scripts/tip-cicd-sanity/eap_connect.py @@ -11,32 +11,35 @@ # and verify whether traffic was sent and received. It also verifies the station connected # to the requested BSSID if bssid is specified as an argument. # The script will clean up the station and connections at the end of the test. - import sys +import os +import importlib +import time +import argparse +import pprint 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) -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 +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +removeCX = LFUtils.removeCX +removeEndps = LFUtils.removeEndps +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + +OPEN = "open" +WEP = "wep" +WPA = "wpa" +WPA2 = "wpa2" +MODE_AUTO = 0 -OPEN="open" -WEP="wep" -WPA="wpa" -WPA2="wpa2" -MODE_AUTO=0 class EAPConnect(LFCliBase): def __init__(self, host, port, security=None, ssid=None, sta_list=None, number_template="00000", _debug_on=False, _dut_bssid="", diff --git a/py-scripts/tip-cicd-sanity/single_client_throughput.py b/py-scripts/tip-cicd-sanity/single_client_throughput.py index c007866f..fde64439 100755 --- a/py-scripts/tip-cicd-sanity/single_client_throughput.py +++ b/py-scripts/tip-cicd-sanity/single_client_throughput.py @@ -21,32 +21,35 @@ # 3. TCP Downstream (AP to STA) # 4. TCP Upstream (STA to AP) # The script will clean up the station and connections at the end of the test. - import sys +import os +import importlib import csv +import argparse +import pprint +import time 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') +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) -import argparse -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 +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +removeCX = LFUtils.removeCX +removeEndps = LFUtils.removeEndps +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm + +OPEN = "open" +WEP = "wep" +WPA = "wpa" +WPA2 = "wpa2" +MODE_AUTO = 0 -OPEN="open" -WEP="wep" -WPA="wpa" -WPA2="wpa2" -MODE_AUTO=0 class SingleClient(LFCliBase): def __init__(self, host, port, _dut_ssid="jedway-open-1", _dut_passwd="NA", _dut_bssid="", diff --git a/py-scripts/tip_station_powersave.py b/py-scripts/tip_station_powersave.py index 28c62d6e..b65f1d79 100755 --- a/py-scripts/tip_station_powersave.py +++ b/py-scripts/tip_station_powersave.py @@ -1,22 +1,25 @@ #!/usr/bin/env python3 import sys -import pprint import os +import importlib +import pprint +import argparse +import time +import datetime 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')) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) -import argparse -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -from LANforge import LFUtils -import realm -import time -import datetime +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +LFRequest = importlib.import_module("lanforge-scripts.py-json.LANforge.LFRequest") +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm ''' This script uses filters from realm's PacketFilter class to filter pcap output for specific packets. @@ -26,8 +29,9 @@ either the station MAC or the AP MAC in wlan.addr These are returned as an array of lines from the output in the format $subtype $mac_addresses $wlan.fc.pwrmgt ''' - #Currently, this test can only be applied to UDP connections + + class TIPStationPowersave(LFCliBase): def __init__(self, host, port, ssid=None, diff --git a/py-scripts/tools/lf_check.py b/py-scripts/tools/lf_check.py index 0c7d9d89..1231b2b2 100755 --- a/py-scripts/tools/lf_check.py +++ b/py-scripts/tools/lf_check.py @@ -143,8 +143,6 @@ class lf_check(): # meta.txt self.meta_data_path = "" - - # lanforge configuration self.lf_mgr_ip = "192.168.0.102" self.lf_mgr_port = "8080" diff --git a/py-scripts/tools/lf_qa.py b/py-scripts/tools/lf_qa.py index 05490e13..0c5b3b6a 100755 --- a/py-scripts/tools/lf_qa.py +++ b/py-scripts/tools/lf_qa.py @@ -4,12 +4,11 @@ File: read kpi.csv place in sql database, create png of historical kpi and prese Usage: kpi_csv_sq.py --store --png --show --path --database Example: kpi_csv_sq.py --show (show dashboard generated from database) Example: kpi_csv_sq.py --store --png --show --path (read kpi.csv store to database, write png, show dashboard ) - ''' # visit http://127.0.0.1:8050/ in your web browser. - import sys import os +import importlib import dash import dash_core_components as dcc import dash_html_components as html @@ -20,13 +19,11 @@ import argparse from pathlib import Path import time -# lf_report is from the parent of the current file -dir_path = os.path.dirname(os.path.realpath(__file__)) -parent_dir_path = os.path.abspath(os.path.join(dir_path, os.pardir)) -sys.path.insert(0, parent_dir_path) +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../"))) -from lf_report import lf_report -sys.path.append('/') +lf_report = importlib.import_module("lanforge-scripts.py-scripts.lf_report") +lf_report = lf_report.lf_report # Any style components can be used external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] @@ -608,4 +605,4 @@ Example: kpi_csv_sq.py --store --png --show --path (read if __name__ == '__main__': main() - \ No newline at end of file + diff --git a/py-scripts/vap_stations_example.py b/py-scripts/vap_stations_example.py index c6366ae9..772cd9d8 100755 --- a/py-scripts/vap_stations_example.py +++ b/py-scripts/vap_stations_example.py @@ -3,17 +3,22 @@ This is an outdated example. Please see modern py-scripts/test_X example scripts. """ import sys +import os +import importlib +import traceback + 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 traceback -from LANforge import LFUtils -from LANforge.LFUtils import * -from LANforge.lfcli_base import LFCliBase -from generic_cx import GenericCx +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + + +lfcli_base = importlib.import_module("lanforge-scripts.py-json.LANforge.lfcli_base") +LFCliBase = lfcli_base.LFCliBase +LFUtils = importlib.import_module("lanforge-scripts.py-json.LANforge.LFUtils") +# from generic_cx import GenericCx mgrURL = "http://localhost:8080/" staName = "sta0" diff --git a/py-scripts/wlan_capacity_calculator.py b/py-scripts/wlan_capacity_calculator.py index 35d3147a..0635cb9a 100755 --- a/py-scripts/wlan_capacity_calculator.py +++ b/py-scripts/wlan_capacity_calculator.py @@ -5,18 +5,17 @@ Info : Standard Script for WLAN Capacity Calculator Date : Author : Anjali Rahamatkar ''' - -import argparse import sys import os - +import importlib +import argparse 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_theoretical_sta +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +wlan_theoretical_sta = importlib.import_module("lanforge-scripts.py-json.wlan_theoretical_sta") -# main method def main(): @@ -248,4 +247,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/py-scripts/ws_generic_monitor_test.py b/py-scripts/ws_generic_monitor_test.py index f9345b90..c651d2bf 100755 --- a/py-scripts/ws_generic_monitor_test.py +++ b/py-scripts/ws_generic_monitor_test.py @@ -4,17 +4,22 @@ This example is to demonstrate ws_generic_monitor to monitor events triggered by This script when running, will monitor the events triggered by test_ipv4_connection.py """ - - import sys +import os +import importlib import json -if 'py-json' not in sys.path: - sys.path.append('../py-json') -from ws_generic_monitor import WS_Listener -from realm import Realm + +if 'lanforge-scripts' not in sys.path: + sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) + +ws_generic_monitor = importlib.import_module("lanforge-scripts.py-json.ws_generic_monitor") +WS_Listener = ws_generic_monitor.WS_Listener +realm = importlib.import_module("lanforge-scripts.py-json.realm") +Realm = realm.Realm reference = "test_ipv4_connection.py" + class GenericMonitorTest(Realm): def __init__(self, ssid=None,