fix ios_l2_interface (#37389)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2018-03-15 11:33:59 +05:30 committed by GitHub
parent 7328c94268
commit dd37857884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 15 deletions

View file

@ -185,9 +185,12 @@ def remove_switchport_config_commands(name, existing, proposed, module):
commands.append(command)
elif mode == 'trunk':
tv_check = existing.get('trunk_vlans_list') == proposed.get('trunk_vlans_list')
if not 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')
proposed_vlans = proposed.get('trunk_vlans_list')
vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
@ -291,7 +294,7 @@ def vlan_range_to_list(vlans):
result = []
if vlans:
for part in vlans.split(','):
if part == 'none':
if part.lower() == 'none':
break
if '-' in part:
start, stop = (int(i) for i in part.split('-'))

View file

@ -88,8 +88,37 @@
- assert: *false
- name: Ensure these VLANs are not being tagged on the trunk
- name: Remove full trunk vlan range 2-50
ios_l2_interface: &no_tag
name: "{{ test_interface }}"
mode: trunk
trunk_vlans: 2-50
state: absent
provider: "{{ cli }}"
register: result
- assert: *true
- name: Check Idempotence Remove full trunk vlan range 2-50
ios_l2_interface: *no_tag
register: result
- assert: *false
- name: Reconfigure interface trunk port and ensure 2-50 are being tagged
ios_l2_interface: *tag
register: result
- assert: *true
- name: Check Idempotence Reconfigure interface trunk port and ensure 2-50 are being tagged
ios_l2_interface: *tag
register: result
- assert: *false
- name: Remove partial trunk vlan range 30-4094 are removed
ios_l2_interface: &partial
name: "{{ test_interface }}"
mode: trunk
trunk_vlans: 30-4094
@ -99,8 +128,8 @@
- assert: *true
- name: "no tag vlan Idempotence"
ios_l2_interface: *no_tag
- name: Check Idempotence Remove partial trunk vlan range 30-4094 are removed
ios_l2_interface: *partial
register: result
- assert: *false