mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	create_macvlan autopep8
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		| @@ -63,7 +63,10 @@ class CreateMacVlan(Realm): | |||||||
|     def build(self): |     def build(self): | ||||||
|         # Build stations |         # Build stations | ||||||
|         print("Creating MACVLANs") |         print("Creating MACVLANs") | ||||||
|         self.mvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug) |         self.mvlan_profile.create( | ||||||
|  |             admin_down=False, | ||||||
|  |             sleep_time=.5, | ||||||
|  |             debug=self.debug) | ||||||
|         self._pass("PASS: MACVLAN build finished") |         self._pass("PASS: MACVLAN build finished") | ||||||
|         self.created_ports += self.mvlan_profile.created_macvlans |         self.created_ports += self.mvlan_profile.created_macvlans | ||||||
|  |  | ||||||
| @@ -79,7 +82,7 @@ def main(): | |||||||
| create_macvlan.py: | create_macvlan.py: | ||||||
| -------------------- | -------------------- | ||||||
| Generic command layout: | Generic command layout: | ||||||
| ./create_macvlan.py --macvlan_parent <port> --num_ports <num ports>  | ./create_macvlan.py --macvlan_parent <port> --num_ports <num ports> | ||||||
|                  --first_mvlan_ip <first ip in series> --netmask <netmask to use> --gateway <gateway ip addr> |                  --first_mvlan_ip <first ip in series> --netmask <netmask to use> --gateway <gateway ip addr> | ||||||
|  |  | ||||||
| ./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --first_mvlan_ip 192.168.92.13 | ./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --first_mvlan_ip 192.168.92.13 | ||||||
| @@ -95,28 +98,59 @@ Generic command layout: | |||||||
| ./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 | ./create_macvlan.py --radio 1.wiphy0 --macvlan_parent eth1 --num_ports 3 | ||||||
|                  --use_ports eth1#0=10.40.3.103,eth1#1,eth1#2 --connections_per_port 2 |                  --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 |                  --netmask 255.255.240.0 --gateway 10.40.0.1 | ||||||
|                   |  | ||||||
|                  You can only add MAC-VLANs to Ethernet, Bonding, Redir, and 802.1Q VLAN devices.  |                  You can only add MAC-VLANs to Ethernet, Bonding, Redir, and 802.1Q VLAN devices. | ||||||
|  |  | ||||||
| ''') | ''') | ||||||
|     parser.add_argument('--num_stations', help='Number of stations to create', default=0) |     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('-u', '--upstream_port', |     parser.add_argument( | ||||||
|                         help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1', |         '-u', | ||||||
|                         default='1.eth1') |         '--upstream_port', | ||||||
|     parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', required=True) |         help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1', | ||||||
|     parser.add_argument('--first_port', help='specifies name of first port to be used', default=None) |         default='1.eth1') | ||||||
|     parser.add_argument('--num_ports', help='number of ports to create', default=1) |     parser.add_argument( | ||||||
|     parser.add_argument('--connections_per_port', help='specifies number of connections to be used per port', default=1, |         '--macvlan_parent', | ||||||
|                         type=int) |         help='specifies parent port for macvlan creation', | ||||||
|     parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip' |         required=True) | ||||||
|                                             '{ port_name1=ip_addr1,port_name1=ip_addr2 }. ' |     parser.add_argument( | ||||||
|                                             'Ports without ips will be left alone', default=None) |         '--first_port', | ||||||
|     parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None) |         help='specifies name of first port to be used', | ||||||
|     parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None) |         default=None) | ||||||
|     parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None) |     parser.add_argument( | ||||||
|     parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group', |         '--num_ports', | ||||||
|                         default=None) |         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( | ||||||
|  |         '--first_mvlan_ip', | ||||||
|  |         help='specifies first static ip address to be used or dhcp', | ||||||
|  |         default=None) | ||||||
|  |     parser.add_argument( | ||||||
|  |         '--netmask', | ||||||
|  |         help='specifies netmask to be used with static ip addresses', | ||||||
|  |         default=None) | ||||||
|  |     parser.add_argument( | ||||||
|  |         '--gateway', | ||||||
|  |         help='specifies default gateway to be used with static addressing', | ||||||
|  |         default=None) | ||||||
|  |     parser.add_argument( | ||||||
|  |         '--cxs', | ||||||
|  |         help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group', | ||||||
|  |         default=None) | ||||||
|     args = parser.parse_args() |     args = parser.parse_args() | ||||||
|  |  | ||||||
|     port_list = [] |     port_list = [] | ||||||
| @@ -126,27 +160,38 @@ 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( | ||||||
|                                                      padding_number=10000, |                     prefix="sta", | ||||||
|                                                      radio=args.radio) |                     start_id=start_num, | ||||||
|  |                     end_id=start_num + num_ports - 1, | ||||||
|  |                     padding_number=10000, | ||||||
|  |                     radio=args.radio) | ||||||
|         else: |         else: | ||||||
|             if (args.num_ports is not None) and args.macvlan_parent is not None and (int(args.num_ports) > 0) \ |             if (args.num_ports is not None) and args.macvlan_parent is not None and ( | ||||||
|                     and args.macvlan_parent in args.first_port: |                     int(args.num_ports) > 0) and args.macvlan_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.macvlan_parent + "#", start_id=start_num, |                 port_list = LFUtils.port_name_series( | ||||||
|                                                      end_id=start_num + num_ports - 1, padding_number=100000, |                     prefix=args.macvlan_parent + "#", | ||||||
|                                                      radio=args.radio) |                     start_id=start_num, | ||||||
|  |                     end_id=start_num + num_ports - 1, | ||||||
|  |                     padding_number=100000, | ||||||
|  |                     radio=args.radio) | ||||||
|             else: |             else: | ||||||
|                 raise ValueError("Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n" |                 raise ValueError( | ||||||
|                                  "first_port must contain parent port and num_ports must be greater than 0" |                     "Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n" | ||||||
|                                  % (args.num_ports, args.macvlan_parent, args.first_port)) |                     "first_port must contain parent port and num_ports must be greater than 0" % | ||||||
|  |                     (args.num_ports, args.macvlan_parent, args.first_port)) | ||||||
|     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) | ||||||
|             port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0, |             port_list = LFUtils.port_name_series( | ||||||
|                                                  end_id=num_ports - 1, padding_number=100000, |                 prefix=args.macvlan_parent + "#", | ||||||
|                                                  radio=args.radio) |                 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: | ||||||
| @@ -157,7 +202,8 @@ Generic command layout: | |||||||
|                     ip_list.append(0) |                     ip_list.append(0) | ||||||
|  |  | ||||||
|             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_mvlan_ip is not None: |     if args.first_mvlan_ip is not None: | ||||||
|         if args.first_mvlan_ip.lower() == "dhcp": |         if args.first_mvlan_ip.lower() == "dhcp": | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Matthew Stidham
					Matthew Stidham