mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
create_qvlan autopep8
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
@@ -8,7 +8,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -29,11 +29,15 @@ class CreateQVlan(Realm):
|
||||
netmask=None,
|
||||
first_qvlan_ip=None,
|
||||
gateway=None,
|
||||
port_list=[],
|
||||
ip_list=[],
|
||||
port_list=None,
|
||||
ip_list=None,
|
||||
exit_on_error=False,
|
||||
debug=False):
|
||||
super().__init__(host, port)
|
||||
if port_list is None:
|
||||
port_list = []
|
||||
if ip_list is None:
|
||||
ip_list = []
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.qvlan_parent = qvlan_parent
|
||||
@@ -54,7 +58,10 @@ class CreateQVlan(Realm):
|
||||
|
||||
def build(self):
|
||||
print("Creating QVLAN stations")
|
||||
self.qvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug)
|
||||
self.qvlan_profile.create(
|
||||
admin_down=False,
|
||||
sleep_time=.5,
|
||||
debug=self.debug)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -68,21 +75,49 @@ def main():
|
||||
---------------------
|
||||
Generic command ''')
|
||||
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
||||
parser.add_argument('--qvlan_parent', help='specifies parent port for qvlan creation', default=None, required=True)
|
||||
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('--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('--gateway', help='specifies default gateway to be used with static addressing', default=None)
|
||||
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(
|
||||
'--qvlan_parent',
|
||||
help='specifies parent port for qvlan creation',
|
||||
default=None,
|
||||
required=True)
|
||||
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(
|
||||
'--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(
|
||||
'--gateway',
|
||||
help='specifies default gateway to be used with static addressing',
|
||||
default=None)
|
||||
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)
|
||||
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)
|
||||
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group'
|
||||
, default=None)
|
||||
parser.add_argument('--use_qvlans', help='will create qvlans', action='store_true', default=False)
|
||||
|
||||
tg_group.add_argument(
|
||||
'--add_to_group',
|
||||
help='name of test group to add cxs to',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--cxs',
|
||||
help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--use_qvlans',
|
||||
help='will create qvlans',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -105,29 +140,42 @@ def main():
|
||||
if (args.num_ports is not None) and (int(args.num_ports) > 0):
|
||||
start_num = int(args.first_port[3:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix="sta",
|
||||
start_id=start_num,
|
||||
end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
print(1)
|
||||
else:
|
||||
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:
|
||||
start_num = int(args.first_port[args.first_port.index('#') + 1:])
|
||||
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:
|
||||
start_num = int(
|
||||
args.first_port[args.first_port.index('#') + 1:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=str(args.qvlan_parent) + "#", start_id=start_num,
|
||||
end_id=start_num + num_ports - 1, padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix=str(
|
||||
args.qvlan_parent) + "#",
|
||||
start_id=start_num,
|
||||
end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
print(2)
|
||||
else:
|
||||
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"
|
||||
% (args.num_ports, args.qvlan_parent, args.first_port))
|
||||
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" %
|
||||
(args.num_ports, args.qvlan_parent, args.first_port))
|
||||
else:
|
||||
if args.use_ports is None:
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=str(args.qvlan_parent) + "#", start_id=1,
|
||||
end_id=num_ports, padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix=str(
|
||||
args.qvlan_parent) + "#",
|
||||
start_id=1,
|
||||
end_id=num_ports,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
print(3)
|
||||
else:
|
||||
temp_list = args.use_ports.split(',')
|
||||
@@ -139,7 +187,8 @@ def main():
|
||||
ip_list.append(0)
|
||||
|
||||
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!")
|
||||
|
||||
print(port_list)
|
||||
print(ip_list)
|
||||
@@ -157,5 +206,6 @@ def main():
|
||||
create_qvlan.build()
|
||||
print('Created %s QVLAN stations' % num_ports)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user