Fixed create_qvlan.py script

Signed-off-by: Matthew Stidham <stidmatt@protonmail.com>
This commit is contained in:
Matthew Stidham
2021-03-16 14:33:51 -07:00
parent ada88a0bc2
commit dc938a9603
5 changed files with 260 additions and 364 deletions

169
py-json/qvlan_profile.py Normal file
View File

@@ -0,0 +1,169 @@
#!/usr/bin/env python3
from LANforge.lfcli_base import LFCliBase
from LANforge import LFRequest
from LANforge import LFUtils
from LANforge import set_port
import pprint
from pprint import pprint
import time
class QVLANProfile(LFCliBase):
def __init__(self, lfclient_host, lfclient_port,
local_realm,
qvlan_parent="eth1",
num_qvlans=1,
admin_down=False,
dhcp=False,
debug_=False):
super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True)
self.local_realm = local_realm
self.num_qvlans = num_qvlans
self.qvlan_parent = qvlan_parent
self.resource = 1
self.shelf = 1
self.desired_qvlans = []
self.created_qvlans = []
self.dhcp = dhcp
self.netmask = None
self.first_ip_addr = None
self.gateway = None
self.ip_list = []
self.COMMANDS = ["set_port"]
self.desired_set_port_cmd_flags = []
self.desired_set_port_current_flags = [] # do not default down, "if_down"
self.desired_set_port_interest_flags = ["current_flags"] # do not default down, "ifdown"
self.set_port_data = {
"shelf": 1,
"resource": 1,
"port": None
}
def add_named_flags(self, desired_list, command_ref):
if desired_list is None:
raise ValueError("addNamedFlags wants a list of desired flag names")
if len(desired_list) < 1:
print("addNamedFlags: empty desired list")
return 0
if (command_ref is None) or (len(command_ref) < 1):
raise ValueError("addNamedFlags wants a maps of flag values")
result = 0
for name in desired_list:
if (name is None) or (name == ""):
continue
if name not in command_ref:
if self.debug:
pprint(command_ref)
raise ValueError("flag %s not in map" % name)
result += command_ref[name]
return result
def set_command_param(self, command_name, param_name, param_value):
# we have to check what the param name is
if (command_name is None) or (command_name == ""):
return
if (param_name is None) or (param_name == ""):
return
if command_name not in self.COMMANDS:
raise ValueError("Command name name [%s] not defined in %s" % (command_name, self.COMMANDS))
# return
if command_name == "set_port":
self.set_port_data[param_name] = param_value
def set_command_flag(self, command_name, param_name, value):
# we have to check what the param name is
if (command_name is None) or (command_name == ""):
return
if (param_name is None) or (param_name == ""):
return
if command_name not in self.COMMANDS:
print("Command name name [%s] not defined in %s" % (command_name, self.COMMANDS))
return
elif command_name == "set_port":
if (param_name not in set_port.set_port_current_flags) and (
param_name not in set_port.set_port_cmd_flags) and (
param_name not in set_port.set_port_interest_flags):
print("Parameter name [%s] not defined in set_port.py" % param_name)
if self.debug:
pprint(set_port.set_port_cmd_flags)
pprint(set_port.set_port_current_flags)
pprint(set_port.set_port_interest_flags)
return
if (param_name in set_port.set_port_cmd_flags):
if (value == 1) and (param_name not in self.desired_set_port_cmd_flags):
self.desired_set_port_cmd_flags.append(param_name)
elif value == 0:
self.desired_set_port_cmd_flags.remove(param_name)
elif (param_name in set_port.set_port_current_flags):
if (value == 1) and (param_name not in self.desired_set_port_current_flags):
self.desired_set_port_current_flags.append(param_name)
elif value == 0:
self.desired_set_port_current_flags.remove(param_name)
elif (param_name in set_port.set_port_interest_flags):
if (value == 1) and (param_name not in self.desired_set_port_interest_flags):
self.desired_set_port_interest_flags.append(param_name)
elif value == 0:
self.desired_set_port_interest_flags.remove(param_name)
else:
raise ValueError("Unknown param name: " + param_name)
def create(self, admin_down=False, debug=False, sleep_time=1):
print("Creating qvlans...")
req_url = "/cli-json/add_vlan"
if not self.dhcp and self.first_ip_addr is not None and self.netmask is not None and self.gateway is not None:
self.desired_set_port_interest_flags.append("ip_address")
self.desired_set_port_interest_flags.append("ip_Mask")
self.desired_set_port_interest_flags.append("ip_gateway")
self.ip_list = LFUtils.gen_ip_series(ip_addr=self.first_ip_addr, netmask=self.netmask,
num_ips=self.num_qvlans)
if self.dhcp:
print("Using DHCP")
self.desired_set_port_current_flags.append("use_dhcp")
self.desired_set_port_interest_flags.append("dhcp")
self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags,
set_port.set_port_current_flags)
self.set_port_data["interest"] = self.add_named_flags(self.desired_set_port_interest_flags,
set_port.set_port_interest_flags)
set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port")
for i in range(len(self.desired_qvlans)):
data = {
"shelf": self.shelf,
"resource": self.resource,
"port": self.local_realm.name_to_eid(self.qvlan_parent)[2],
"vid": i+1
}
self.created_qvlans.append("%s.%s.%s#%d" % (self.shelf, self.resource,
self.qvlan_parent, int(
self.desired_qvlans[i][self.desired_qvlans[i].index('#') + 1:])))
self.local_realm.json_post(req_url, data)
time.sleep(sleep_time)
print(self.created_qvlans)
def cleanup(self):
print("Cleaning up qvlans...")
print(self.created_qvlans)
for port_eid in self.created_qvlans:
self.local_realm.rm_port(port_eid, check_exists=True)
time.sleep(.02)
# And now see if they are gone
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.created_qvlans)
def admin_up(self):
for qvlan in self.created_qvlans:
self.local_realm.admin_up(qvlan)
def admin_down(self):
for qvlan in self.created_qvlans:
self.local_realm.admin_down(qvlan)

View File

@@ -17,6 +17,7 @@ from vap_profile import VAPProfile
from mac_vlan_profile import MACVLANProfile from mac_vlan_profile import MACVLANProfile
from wifi_monitor_profile import WifiMonitor from wifi_monitor_profile import WifiMonitor
from gen_cxprofile import GenCXProfile from gen_cxprofile import GenCXProfile
from qvlan_profile import QVLANProfile
from port_utils import PortUtils from port_utils import PortUtils
# ---- ---- ---- ---- Other Imports ---- ---- ---- ---- # ---- ---- ---- ---- Other Imports ---- ---- ---- ----
import re import re
@@ -658,7 +659,7 @@ class Realm(LFCliBase):
else: else:
if debug: if debug:
print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) print("Found IP: %s on port: %s" % (v['ip'], sta_eid))
print("Incrementing stations with IP addresses found") print("Incmenting stations with IP addresses found")
num_sta_with_ips += 1 num_sta_with_ips += 1
else: else:
num_sta_with_ips += 1 num_sta_with_ips += 1
@@ -911,6 +912,9 @@ class Realm(LFCliBase):
# mac_vlan_profile = mac_vlan_profile2.MACVLANProfile2(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) # mac_vlan_profile = mac_vlan_profile2.MACVLANProfile2(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug)
return mac_vlan_profile return mac_vlan_profile
def new_qvlan_profile(self):
return QVLANProfile(self.host, self.port, local_realm=self, debug_=self.debug)
def new_test_group_profile(self, ver = 1): def new_test_group_profile(self, ver = 1):
if ver == 1: if ver == 1:
test_group_profile = TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) test_group_profile = TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug)

View File

@@ -1,363 +1,105 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
import os
if sys.version_info[0] != 3: if sys.version_info[0] != 3:
print("This script requires Python 3") print("This script requires Python 3")
exit(1) exit(1)
if 'py-json' not in sys.path: if 'py-json' not in sys.path:
sys.path.append('../py-json') sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
# import argparse import argparse
from LANforge.lfcli_base import LFCliBase from LANforge.lfcli_base import LFCliBase
from LANforge.LFUtils import * from LANforge.LFUtils import *
from LANforge import LFUtils
from LANforge import add_file_endp
from LANforge.add_file_endp import * from LANforge.add_file_endp import *
from LANforge import LFUtils
import argparse import argparse
from realm import Realm from realm import Realm
import time
import datetime
import pprint
class FileIOTest(Realm): class CreateQVlan(Realm):
def __init__(self, host, port, ssid, security, password, def __init__(self,
number_template="00000", host="localhost",
radio="wiphy0", port=8080,
test_duration="5m",
upstream_port="eth1",
num_ports=1,
server_mount="10.40.0.1:/var/tmp/test",
qvlan_parent=None, qvlan_parent=None,
first_qvlan_ip=None, num_ports=1,
netmask=None,
gateway=None,
dhcp=True, dhcp=True,
use_qvlans=False, netmask=None,
use_test_groups=False, first_qvlan_ip=None,
write_only_test_group=None, gateway=None,
read_only_test_group=None,
port_list=[], port_list=[],
ip_list=None, ip_list=[],
connections_per_port=1, halt_on_error=False,
mode="both", exit_on_error=False,
update_group_args={"name": None, "action": None, "cxs": None}, debug=False):
_debug_on=False,
_exit_on_error=False,
_exit_on_fail=False):
super().__init__(host, port) super().__init__(host, port)
self.host = host self.host = host
self.port = port self.port = port
self.radio = radio self.qvlan_parent = qvlan_parent
self.upstream_port = upstream_port self.debug = debug
self.ssid = ssid self.port_list = port_list
self.security = security
self.password = password
self.number_template = number_template
self.test_duration = test_duration
self.port_list = []
self.connections_per_port = connections_per_port
self.use_qvlans = use_qvlans
self.mode = mode.lower()
self.ip_list = ip_list self.ip_list = ip_list
self.netmask = netmask self.halt_on_error = halt_on_error
self.gateway = gateway self.exit_on_error = exit_on_error
self.dhcp = dhcp
if self.use_qvlans:
if qvlan_parent is not None:
self.qvlan_parent = qvlan_parent
self.port_list = port_list
else:
self.port_list = port_list
self.use_test_groups = use_test_groups
if self.use_test_groups:
if self.mode == "write":
if write_only_test_group is not None:
self.write_only_test_group = write_only_test_group
else:
raise ValueError("--write_only_test_group must be used to set test group name")
if self.mode == "read":
if read_only_test_group is not None:
self.read_only_test_group = read_only_test_group
else:
raise ValueError("--read_only_test_group must be used to set test group name")
if self.mode == "both":
if write_only_test_group is not None and read_only_test_group is not None:
self.write_only_test_group = write_only_test_group
self.read_only_test_group = read_only_test_group
else:
raise ValueError("--write_only_test_group and --read_only_test_group "
"must be used to set test group names")
self.wo_profile = self.new_fio_endp_profile()
self.qvlan_profile = self.new_qvlan_profile() self.qvlan_profile = self.new_qvlan_profile()
self.qvlan_profile.num_qvlans = int(num_ports)
if not self.use_qvlans and len(self.port_list) > 0: self.qvlan_profile.desired_qvlans = self.port_list
self.station_profile = self.new_station_profile() self.qvlan_profile.qvlan_parent = self.qvlan_parent
self.station_profile.lfclient_url = self.lfclient_url self.qvlan_profile.dhcp = dhcp
self.station_profile.ssid = self.ssid self.qvlan_profile.netmask = netmask
self.station_profile.ssid_pass = self.password self.qvlan_profile.first_ip_addr = first_qvlan_ip
self.station_profile.security = self.security self.qvlan_profile.gateway = gateway
self.station_profile.number_template_ = self.number_template self.qvlan_profile.dhcp = dhcp
self.station_profile.mode = 0
self.wo_profile.server_mount = server_mount
self.wo_profile.num_connections_per_port = connections_per_port
self.ro_profile = self.wo_profile.create_ro_profile()
if self.use_qvlans:
self.qvlan_profile.num_qvlans = int(num_ports)
self.qvlan_profile.desired_qvlans = self.port_list
self.qvlan_profile.qvlan_parent = self.qvlan_parent
self.qvlan_profile.dhcp = dhcp
self.qvlan_profile.netmask = netmask
self.qvlan_profile.first_ip_addr = first_qvlan_ip
self.qvlan_profile.gateway = gateway
self.created_ports = []
if self.use_test_groups:
if self.mode is not None:
if self.mode == "write":
self.wo_tg_profile = self.new_test_group_profile()
self.wo_tg_profile.group_name = self.write_only_test_group
elif self.mode == "read":
self.ro_tg_profile = self.new_test_group_profile()
self.ro_tg_profile.group_name = self.read_only_test_group
elif self.mode == "both":
self.wo_tg_profile = self.new_test_group_profile()
self.ro_tg_profile = self.new_test_group_profile()
self.wo_tg_profile.group_name = self.write_only_test_group
self.ro_tg_profile.group_name = self.read_only_test_group
else:
raise ValueError("Unknown mode given ", self.mode)
else:
raise ValueError("Mode ( read, write, or both ) must be specified")
if update_group_args is not None and update_group_args['name'] is not None:
temp_tg = self.new_test_group_profile()
temp_cxs = update_group_args['cxs'].split(',')
if update_group_args['action'] == "add":
temp_tg.group_name = update_group_args['name']
if not temp_tg.check_group_exists():
temp_tg.create_group()
for cx in temp_cxs:
if "CX_" not in cx:
cx = "CX_" + cx
temp_tg.add_cx(cx)
if update_group_args['action'] == "del":
temp_tg.group_name = update_group_args['name']
if temp_tg.check_group_exists():
for cx in temp_cxs:
temp_tg.rm_cx(cx)
time.sleep(5)
self.wo_tg_exists = False
self.ro_tg_exists = False
self.wo_tg_cx_exists = False
self.ro_tg_cx_exists = False
print("Checking for pre-existing test groups and cxs")
if self.use_test_groups:
if self.mode == "write":
if self.wo_tg_profile.check_group_exists():
self.wo_tg_exists = True
if len(self.wo_tg_profile.list_cxs()) > 0:
self.wo_tg_cx_exists = True
elif self.mode == "read":
if self.ro_tg_profile.check_group_exists():
self.ro_tg_exists = True
if len(self.ro_tg_profile.list_cxs()) > 0:
self.ro_tg_cx_exists = True
elif self.mode == "both":
if self.wo_tg_profile.check_group_exists():
self.wo_tg_exists = True
if len(self.wo_tg_profile.list_cxs()) > 0:
self.wo_tg_cx_exists = True
if self.ro_tg_profile.check_group_exists():
self.ro_tg_exists = True
if len(self.ro_tg_profile.list_cxs()) > 0:
self.ro_tg_cx_exists = True
def __compare_vals(self, val_list):
passes = 0
expected_passes = 0
# print(val_list)
for item in val_list:
expected_passes += 1
# print(item)
if item[0] == 'r':
# print("TEST", item,
# val_list[item]['read-bps'],
# self.ro_profile.min_read_rate_bps,
# val_list[item]['read-bps'] > self.ro_profile.min_read_rate_bps)
if val_list[item]['read-bps'] > self.wo_profile.min_read_rate_bps:
passes += 1
else:
# print("TEST", item,
# val_list[item]['write-bps'],
# self.wo_profile.min_write_rate_bps,
# val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps)
if val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps:
passes += 1
if passes == expected_passes:
return True
else:
return False
else:
return False
def __get_values(self):
time.sleep(3)
if self.mode == "write":
cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % (
','.join(self.wo_profile.created_cx.keys())), debug_=self.debug)
elif self.mode == "read":
cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % (
','.join(self.ro_profile.created_cx.keys())), debug_=self.debug)
else:
cx_list = self.json_get("fileio/%s,%s?fields=write-bps,read-bps" % (
','.join(self.wo_profile.created_cx.keys()),
','.join(self.ro_profile.created_cx.keys())), debug_=self.debug)
# print(cx_list)
# print("==============\n", cx_list, "\n==============")
cx_map = {}
# pprint.pprint(cx_list)
if cx_list is not None:
cx_list = cx_list['endpoint']
for i in cx_list:
for item, value in i.items():
# print(item, value)
cx_map[self.name_to_eid(item)[2]] = {"read-bps": value['read-bps'], "write-bps": value['write-bps']}
# print(cx_map)
return cx_map
def build(self): def build(self):
# Build stations print("Creating QVLAN stations")
if self.use_qvlans: self.qvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug)
print("Creating qvlans")
self.qvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug)
self._pass("PASS: qvlan build finished")
self.created_ports += self.qvlan_profile.created_qvlans
elif not self.use_qvlans and self.ip_list is None:
self.station_profile.use_security(self.security, self.ssid, self.password)
self.station_profile.set_number_template(self.number_template)
print("Creating stations")
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
self.station_profile.set_command_param("set_port", "report_timer", 1500)
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
self.station_profile.create(radio=self.radio, sta_names_=self.port_list, debug=self.debug)
self._pass("PASS: Station build finished")
self.created_ports += self.station_profile.station_names
if len(self.ip_list) > 0:
# print("++++++++++++++++\n", self.ip_list, "++++++++++++++++\n")
for num_port in range(len(self.port_list)):
if self.ip_list[num_port] != 0:
if self.gateway is not None and self.netmask is not None:
shelf = self.name_to_eid(self.port_list[num_port])[0]
resource = self.name_to_eid(self.port_list[num_port])[1]
port = self.name_to_eid(self.port_list[num_port])[2]
req_url = "/cli-json/set_port"
data = {
"shelf": shelf,
"resource": resource,
"port": port,
"ip_addr": self.ip_list[num_port],
"netmask": self.netmask,
"gateway": self.gateway
}
self.json_post(req_url, data)
self.created_ports.append("%s.%s.%s" % (shelf, resource, port))
else:
raise ValueError("Netmask and gateway must be specified")
def main(): def main():
parser = LFCliBase.create_bare_argparse( parser = LFCliBase.create_bare_argparse(
prog='create_qvlan.py', prog='create_qvlan.py',
# formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter, formatter_class=argparse.RawTextHelpFormatter,
epilog='''Creates FileIO endpoints which can be NFS, CIFS or iSCSI endpoints.''', epilog='''Creates Q-VLAN stations attached to the Eth port of the user's choice.''',
description='''\ description='''\
create_qvlan.py: create_qvlan.py:
-------------------- ---------------------
Generic command layout: Generic command ''')
./create_qvlan.py --qvlan_parent <port> --num_ports <num ports> --use_qvlans
--first_qvlan_ip <first ip in series> --netmask <netmask to use> --gateway <gateway ip addr>
./create_qvlan.py --qvlan_parent eth2 --num_ports 3 --use_qvlans --first_qvlan_ip 192.168.92.13
--netmask 255.255.255.0 --gateway 192.168.92.1
./create_qvlan.py --radio 1.wiphy0 --test_duration 1m --qvlan_parent eth1 --num_ports 3 --use_qvlans
--use_ports eth1#0,eth1#1,eth1#2 --connections_per_port 2 --mode write
./create_qvlan.py --radio 1.wiphy0 --test_duration 1m --qvlan_parent eth1 --num_ports 3 --use_qvlans
--first_qvlan_ip 10.40.3.100 --netmask 255.255.240.0 --gateway 10.40.0.1
--use_test_groups --write_only_test_group test_wo --read_only_test_group test_ro
--add_to_group test_wo
./create_qvlan.py --radio 1.wiphy0 --test_duration 1m --qvlan_parent eth1 --num_ports 3 --use_qvlans
--use_ports eth1#0=10.40.3.103,eth1#1,eth1#2 --connections_per_port 2
--netmask 255.255.240.0 --gateway 10.40.0.1
''')
parser.add_argument('--num_stations', help='Number of stations to create', default=0)
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2') parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
parser.add_argument('--ssid', help='SSID for stations to associate to')
parser.add_argument('--passwd', '--password', '--key', help='WiFi passphrase/password/key')
parser.add_argument('--security', help='security type to use for ssid { wep | wpa | wpa2 | wpa3 | open }')
parser.add_argument('-u', '--upstream_port',
help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',
default='1.eth1')
parser.add_argument('--test_duration', help='sets the duration of the test', default="5m")
parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1',
default="10.40.0.1:/var/tmp/test")
parser.add_argument('--qvlan_parent', help='specifies parent port for qvlan creation', default=None) parser.add_argument('--qvlan_parent', help='specifies parent port for qvlan creation', default=None)
parser.add_argument('--first_port', help='specifies name of first port to be used', default=None) parser.add_argument('--first_port', help='specifies name of first port to be used', default=None)
parser.add_argument('--num_ports', help='number of ports to create', default=1) parser.add_argument('--num_ports', help='number of ports to create', default=1)
parser.add_argument('--connections_per_port', help='specifies number of connections to be used per port', default=1,
type=int)
parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip'
'{ port_name1=ip_addr1,port_name1=ip_addr2 }. '
'Ports without ips will be left alone', default=None)
parser.add_argument('--use_qvlans', help='will create qvlans', action='store_true', default=False)
parser.add_argument('--first_qvlan_ip', help='specifies first static ip address to be used or dhcp', default=None) parser.add_argument('--first_qvlan_ip', help='specifies first static ip address to be used or dhcp', default=None)
parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None) parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None)
parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None) parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None)
parser.add_argument('--use_test_groups', help='will use test groups to start/stop instead of single endps/cxs', parser.add_argument('--use_ports',
action='store_true', default=False) help='list of comma separated ports to use with ips, \'=\' separates name and ip { port_name1=ip_addr1,port_name1=ip_addr2 }. Ports without ips will be left alone',
parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None) default=None)
parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None)
parser.add_argument('--mode', help='write,read,both', default='both', type=str)
tg_group = parser.add_mutually_exclusive_group() tg_group = parser.add_mutually_exclusive_group()
tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None) tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None)
tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None)
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group' parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group'
, default=None) , default=None)
parser.add_argument('--use_qvlans', help='will create qvlans', action='store_true', default=False)
args = parser.parse_args() args = parser.parse_args()
update_group_args = { update_group_args = {
"name": None, "name": None,
"action": None, "action": None,
"cxs": None "cxs": None
} }
if args.add_to_group is not None and args.cxs is not None: # update_group_args['name'] =
update_group_args['name'] = args.add_to_group if args.first_qvlan_ip.lower() == "dhcp":
update_group_args['action'] = "add" dhcp = True
update_group_args['cxs'] = args.cxs else:
elif args.del_from_group is not None and args.cxs is not None: dhcp = False
update_group_args['name'] = args.del_from_group update_group_args['action'] = "add"
update_group_args['action'] = "del" update_group_args['cxs'] = args.cxs
update_group_args['cxs'] = args.cxs
port_list = [] port_list = []
ip_list = [] ip_list = []
if args.first_port is not None and args.use_ports is not None: if args.first_port is not None and args.use_ports is not None:
@@ -365,17 +107,19 @@ Generic command layout:
if (args.num_ports is not None) and (int(args.num_ports) > 0): if (args.num_ports is not None) and (int(args.num_ports) > 0):
start_num = int(args.first_port[3:]) start_num = int(args.first_port[3:])
num_ports = int(args.num_ports) num_ports = int(args.num_ports)
port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num+num_ports-1, port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1,
padding_number=10000, padding_number=10000,
radio=args.radio) radio=args.radio)
print(1)
else: else:
if (args.num_ports is not None) and args.qvlan_parent is not None and (int(args.num_ports) > 0) \ if (args.num_ports is not None) and args.qvlan_parent is not None and (int(args.num_ports) > 0) \
and args.qvlan_parent in args.first_port: and args.qvlan_parent in args.first_port:
start_num = int(args.first_port[args.first_port.index('#')+1:]) start_num = int(args.first_port[args.first_port.index('#') + 1:])
num_ports = int(args.num_ports) num_ports = int(args.num_ports)
port_list = LFUtils.port_name_series(prefix=args.qvlan_parent+"#", start_id=start_num, port_list = LFUtils.port_name_series(prefix=args.qvlan_parent + "#", start_id=start_num,
end_id=start_num+num_ports-1, padding_number=100000, end_id=start_num + num_ports - 1, padding_number=10000,
radio=args.radio) radio=args.radio)
print(2)
else: else:
raise ValueError("Invalid values for num_ports [%s], qvlan_parent [%s], and/or first_port [%s].\n" raise ValueError("Invalid values for num_ports [%s], qvlan_parent [%s], and/or first_port [%s].\n"
"first_port must contain parent port and num_ports must be greater than 0" "first_port must contain parent port and num_ports must be greater than 0"
@@ -383,14 +127,10 @@ Generic command layout:
else: else:
if args.use_ports is None: if args.use_ports is None:
num_ports = int(args.num_ports) num_ports = int(args.num_ports)
if not args.use_qvlans: port_list = LFUtils.port_name_series(prefix=args.qvlan_parent + "#", start_id=1,
port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1, end_id=num_ports, padding_number=10000,
padding_number=10000, radio=args.radio)
radio=args.radio) print(3)
else:
port_list = LFUtils.port_name_series(prefix=args.qvlan_parent + "#", start_id=0,
end_id=num_ports - 1, padding_number=100000,
radio=args.radio)
else: else:
temp_list = args.use_ports.split(',') temp_list = args.use_ports.split(',')
for port in temp_list: for port in temp_list:
@@ -403,44 +143,25 @@ Generic command layout:
if len(port_list) != len(ip_list): if len(port_list) != len(ip_list):
raise ValueError(temp_list, " ports must have matching ip addresses!") raise ValueError(temp_list, " ports must have matching ip addresses!")
if args.first_qvlan_ip is not None: if args.first_qvlan_ip.lower() == "dhcp":
if args.first_qvlan_ip.lower() == "dhcp":
dhcp = True
else:
dhcp = False
else:
dhcp = True dhcp = True
# print(port_list) else:
dhcp = False
# exit(1) print(port_list)
ip_test = FileIOTest(args.mgr, print(ip_list)
args.mgr_port, create_qvlan = CreateQVlan(args.mgr,
ssid=args.ssid, args.mgr_port,
password=args.passwd, qvlan_parent=args.qvlan_parent,
security=args.security, num_ports=args.num_ports,
port_list=port_list, dhcp=dhcp,
ip_list=ip_list, netmask=args.netmask,
test_duration=args.test_duration, first_qvlan_ip=args.first_qvlan_ip,
upstream_port=args.upstream_port, gateway=args.gateway,
_debug_on=args.debug, port_list=port_list,
ip_list=ip_list,
qvlan_parent=args.qvlan_parent, debug=args.debug)
use_qvlans=args.use_qvlans, create_qvlan.build()
first_qvlan_ip=args.first_qvlan_ip, print('Created %s QVLAN stations' % num_ports)
netmask=args.netmask,
gateway=args.gateway,
dhcp=dhcp,
num_ports=args.num_ports,
use_test_groups=args.use_test_groups,
write_only_test_group=args.write_only_test_group,
read_only_test_group=args.read_only_test_group,
update_group_args = update_group_args,
connections_per_port=args.connections_per_port,
mode=args.mode
# want a mount options param
)
ip_test.build()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

View File

@@ -73,7 +73,7 @@ if [[ $mgrlen -gt 0 ]]; then
"./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --radio $RADIO_USED --security wpa2 --debug --mgr $MGR" "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --radio $RADIO_USED --security wpa2 --debug --mgr $MGR"
"./sta_connect2.py --dut_ssid $SSID_USED --dut_passwd $PASSWD_USED --dut_security $SECURITY --mgr $MGR" "./sta_connect2.py --dut_ssid $SSID_USED --dut_passwd $PASSWD_USED --dut_security $SECURITY --mgr $MGR"
# want if [[ $DO_FILEIO = 1 ]] # want if [[ $DO_FILEIO = 1 ]]
"./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --mgr $MGR" # Better tested on Kelly, where VRF is turned off "./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --test_duration 30s --mgr $MGR" # Better tested on Kelly, where VRF is turned off
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest $TEST_HTTP_IP --debug --mgr $MGR" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest $TEST_HTTP_IP --debug --mgr $MGR"
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY --debug --mgr $MGR" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY --debug --mgr $MGR"
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type iperf3 --debug --mgr $MGR" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type iperf3 --debug --mgr $MGR"
@@ -102,6 +102,7 @@ if [[ $mgrlen -gt 0 ]]; then
"./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
"./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
"./create_macvlan.py --radio wiphy1 --macvlan_parent eth1 --debug --mgr $MGR" "./create_macvlan.py --radio wiphy1 --macvlan_parent eth1 --debug --mgr $MGR"
"./create_qvlan.py --first_qvlan_ip 192.168.1.50"
"./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
"./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
"./wlan_capacity_calculator.py -sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes --mgr $MGR" "./wlan_capacity_calculator.py -sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes --mgr $MGR"
@@ -130,7 +131,7 @@ else
"./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3 --debug" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3 --debug"
"./sta_connect2.py --dut_ssid $SSID_USED --dut_passwd $PASSWD_USED --dut_security $SECURITY" "./sta_connect2.py --dut_ssid $SSID_USED --dut_passwd $PASSWD_USED --dut_security $SECURITY"
# want if [[ $DO_FILEIO = 1 ]] # want if [[ $DO_FILEIO = 1 ]]
"./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1" # Better tested on Kelly, where VRF is turned off "./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --test_duration 30s --gateway 192.168.92.1" # Better tested on Kelly, where VRF is turned off
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest $TEST_HTTP_IP --debug" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest $TEST_HTTP_IP --debug"
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY --debug" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY --debug"
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type iperf3 --debug" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type iperf3 --debug"
@@ -162,6 +163,7 @@ else
"./create_macvlan.py --radio wiphy1 --macvlan_parent eth1 --debug" "./create_macvlan.py --radio wiphy1 --macvlan_parent eth1 --debug"
"./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
"./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
"./create_qvlan.py --radio wiphy1 "
"./wlan_capacity_calculator.py -sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes" "./wlan_capacity_calculator.py -sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes"
"./wlan_capacity_calculator.py -sta 11n -t Voice -d 17 -ch 40 -gu 800 -high 9 -e WEP -q Yes -ip 5 -mc 42 -b 6 9 12 24 -m 1538 -co G.729 -pl Greenfield -cw 15 -r Yes -c Yes" "./wlan_capacity_calculator.py -sta 11n -t Voice -d 17 -ch 40 -gu 800 -high 9 -e WEP -q Yes -ip 5 -mc 42 -b 6 9 12 24 -m 1538 -co G.729 -pl Greenfield -cw 15 -r Yes -c Yes"
"./wlan_capacity_calculator.py -sta 11ac -t Voice -d 9 -spa 3 -ch 20 -gu 800 -high 1 -e TKIP -q Yes -ip 3 -mc 0 -b 6 12 24 54 -m 1518 -co Greenfield -cw 15 -rc Yes" "./wlan_capacity_calculator.py -sta 11ac -t Voice -d 9 -spa 3 -ch 20 -gu 800 -high 1 -e TKIP -q Yes -ip 3 -mc 0 -b 6 12 24 54 -m 1518 -co Greenfield -cw 15 -rc Yes"