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:
Trishna Guha 2018-05-29 21:44:19 +05:30 committed by GitHub
parent a7421e8611
commit 17b6ecf101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 46 deletions

View file

@ -454,21 +454,31 @@ def parse_vni(module, vlan_id):
return str(vni) 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): def parse_interfaces(module, vlan):
vlan_int = [] vlan_int = []
interfaces = vlan.get('vlanshowplist-ifidx') interfaces = vlan.get('vlanshowplist-ifidx')
if interfaces: if interfaces:
for i in interfaces.split(','): if isinstance(interfaces, list):
if 'eth' in i.lower() and '-' in i: interfaces_list = [i.strip() for i in interfaces]
int_range = i.split('-') interfaces_str = ','.join(interfaces_list)
stop = int((int_range)[1]) vlan_int = get_vlan_int(interfaces_str)
start = int(int_range[0].split('/')[1]) else:
eth = int_range[0].split('/')[0] vlan_int = get_vlan_int(interfaces)
for r in range(start, stop + 1):
vlan_int.append(eth + '/' + str(r))
else:
vlan_int.append(i)
return vlan_int return vlan_int

View file

@ -7,6 +7,13 @@
- set_fact: testint2="{{ nxos_int2 }}" - set_fact: testint2="{{ nxos_int2 }}"
- block: - block:
- name: Install and Enable FabricPath feature set
nxos_config:
lines:
- install feature-set fabricpath
- feature-set fabricpath
when: platform is search('N5K|N7K')
- name: "Enable feature vn segment" - name: "Enable feature vn segment"
nxos_config: nxos_config:
commands: commands:
@ -114,41 +121,41 @@
when: platform is search('N3K|N7K') when: platform is search('N3K|N7K')
# Uncomment this once the get_capabilities() work on nxapi as well # Uncomment this once the get_capabilities() work on nxapi as well
# - name: Change mode - name: Change mode
# nxos_vlan: &mode1 nxos_vlan: &mode1
# vlan_id: 50 vlan_id: 50
# mode: fabricpath mode: fabricpath
# register: result register: result
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - assert: *true - assert: *true
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - name: "mode1 Idempotence" - name: "mode1 Idempotence"
# nxos_vlan: *mode1 nxos_vlan: *mode1
# register: result register: result
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - assert: *false - assert: *false
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - name: Change mode again - name: Change mode again
# nxos_vlan: &mode2 nxos_vlan: &mode2
# vlan_id: 50 vlan_id: 50
# mode: ce mode: ce
# register: result register: result
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - assert: *true - assert: *true
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - name: "mode2 Idempotence" - name: "mode2 Idempotence"
# nxos_vlan: *mode2 nxos_vlan: *mode2
# register: result register: result
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
#
# - assert: *false - assert: *false
# when: platform is search('N5k|N7K') when: platform is search('N5K|N7K')
- name: Ensure VLAN is NOT on the device - name: Ensure VLAN is NOT on the device
nxos_vlan: &no_vlan nxos_vlan: &no_vlan