1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix nxos_switchport (#37328)

This commit is contained in:
Mike Wiebe 2018-03-13 02:33:05 -04:00 committed by Trishna Guha
parent 9031533c0c
commit ff57fd0bb4
2 changed files with 46 additions and 12 deletions

View file

@ -269,9 +269,14 @@ def remove_switchport_config_commands(interface, existing, proposed, module):
commands.append(command) commands.append(command)
elif mode == 'trunk': elif mode == 'trunk':
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
if tv_check: # Supported Remove Scenarios for trunk_vlans_list
# 1) Existing: 1,2,3 Proposed: 1,2,3 - Remove all
# 2) Existing: 1,2,3 Proposed: 1,2 - Remove 1,2 Leave 3
# 3) Existing: 1,2,3 Proposed: 2,3 - Remove 2,3 Leave 1
# 4) Existing: 1,2,3 Proposed: 4,5,6 - None removed.
# 5) Existing: None Proposed: 1,2,3 - None removed.
existing_vlans = existing.get('trunk_vlans_list') existing_vlans = existing.get('trunk_vlans_list')
proposed_vlans = proposed.get('trunk_vlans_list') proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans) vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)

View file

@ -88,7 +88,7 @@
- assert: *false - assert: *false
- name: Ensure these VLANs are not being tagged on the trunk - name: Remove full trunk vlan range 2-50.
nxos_switchport: &no_tag nxos_switchport: &no_tag
interface: "{{ intname }}" interface: "{{ intname }}"
mode: trunk mode: trunk
@ -99,12 +99,41 @@
- assert: *true - assert: *true
- name: "no tag vlan Idempotence" - name: Check Idempotence Remove full trunk vlan range 2-50.
nxos_switchport: *no_tag nxos_switchport: *no_tag
register: result register: result
- assert: *false - assert: *false
- name: Reconfigure interface trunk port and ensure 2-50 are being tagged
nxos_switchport: *tag
register: result
- assert: *true
- name: Check Idempotence Reconfigure interface trunk port and ensure 2-50 are being tagged
nxos_switchport: *tag
register: result
- assert: *false
- name: Remove partial trunk vlan range 30-4096 are removed
nxos_switchport: &partial
interface: "{{ intname }}"
mode: trunk
trunk_vlans: 30-4094
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: Check Idempotence Remove partial trunk vlan range 30-4096 are removed
nxos_switchport: *partial
register: result
- assert: *false
- name: put interface default state - name: put interface default state
nxos_switchport: *def_swi nxos_switchport: *def_swi
register: result register: result