mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
nxos_vlan fix (#40822)
* nxos_vlan fix Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * uncomment mode test as nxapi now has get_capabilities Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
@@ -454,21 +454,31 @@ def parse_vni(module, vlan_id):
|
||||
return str(vni)
|
||||
|
||||
|
||||
def get_vlan_int(interfaces):
|
||||
vlan_int = []
|
||||
for i in interfaces.split(','):
|
||||
if 'eth' in i.lower() and '-' in i:
|
||||
int_range = i.split('-')
|
||||
stop = int((int_range)[1])
|
||||
start = int(int_range[0].split('/')[1])
|
||||
eth = int_range[0].split('/')[0]
|
||||
for r in range(start, stop + 1):
|
||||
vlan_int.append(eth + '/' + str(r))
|
||||
else:
|
||||
vlan_int.append(i)
|
||||
return vlan_int
|
||||
|
||||
|
||||
def parse_interfaces(module, vlan):
|
||||
vlan_int = []
|
||||
interfaces = vlan.get('vlanshowplist-ifidx')
|
||||
if interfaces:
|
||||
for i in interfaces.split(','):
|
||||
if 'eth' in i.lower() and '-' in i:
|
||||
int_range = i.split('-')
|
||||
stop = int((int_range)[1])
|
||||
start = int(int_range[0].split('/')[1])
|
||||
eth = int_range[0].split('/')[0]
|
||||
for r in range(start, stop + 1):
|
||||
vlan_int.append(eth + '/' + str(r))
|
||||
else:
|
||||
vlan_int.append(i)
|
||||
|
||||
if isinstance(interfaces, list):
|
||||
interfaces_list = [i.strip() for i in interfaces]
|
||||
interfaces_str = ','.join(interfaces_list)
|
||||
vlan_int = get_vlan_int(interfaces_str)
|
||||
else:
|
||||
vlan_int = get_vlan_int(interfaces)
|
||||
return vlan_int
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user