summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2018-03-13 13:36:38 +0530
committerGitHub <noreply@github.com>2018-03-13 13:36:38 +0530
commitba5e562c76464c3fde7c6a285576a286c7e6d523 (patch)
tree4a32ab2500b8aaac5b3b90ace155f358b92d1ad1
parentff57fd0bb49a12d7a59deb05e488228725f73417 (diff)
downloadansible-ba5e562c76464c3fde7c6a285576a286c7e6d523.tar.gz
Fix nxos_l2_interface and test typo (#37336)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
-rw-r--r--lib/ansible/modules/network/nxos/nxos_l2_interface.py21
-rw-r--r--test/integration/targets/nxos_l2_interface/tests/common/sanity.yaml34
-rw-r--r--test/integration/targets/nxos_switchport/tests/common/sanity.yaml4
3 files changed, 43 insertions, 16 deletions
diff --git a/lib/ansible/modules/network/nxos/nxos_l2_interface.py b/lib/ansible/modules/network/nxos/nxos_l2_interface.py
index 72e3ab26fd..d7a9add776 100644
--- a/lib/ansible/modules/network/nxos/nxos_l2_interface.py
+++ b/lib/ansible/modules/network/nxos/nxos_l2_interface.py
@@ -252,18 +252,15 @@ 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 tv_check:
- existing_vlans = existing.get('trunk_vlans_list')
- proposed_vlans = proposed.get('trunk_vlans_list')
- vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
-
- if vlans_to_remove:
- proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
- remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
- command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
- commands.append(command)
+ existing_vlans = existing.get('trunk_vlans_list')
+ proposed_vlans = proposed.get('trunk_vlans_list')
+ vlans_to_remove = set(proposed_vlans).intersection(existing_vlans)
+
+ if vlans_to_remove:
+ proposed_allowed_vlans = proposed.get('trunk_allowed_vlans')
+ remove_trunk_allowed_vlans = proposed.get('trunk_vlans', proposed_allowed_vlans)
+ command = 'switchport trunk allowed vlan remove {0}'.format(remove_trunk_allowed_vlans)
+ commands.append(command)
native_check = existing.get('native_vlan') == proposed.get('native_vlan')
if native_check and proposed.get('native_vlan'):
diff --git a/test/integration/targets/nxos_l2_interface/tests/common/sanity.yaml b/test/integration/targets/nxos_l2_interface/tests/common/sanity.yaml
index 1558ebac7c..16dc7604da 100644
--- a/test/integration/targets/nxos_l2_interface/tests/common/sanity.yaml
+++ b/test/integration/targets/nxos_l2_interface/tests/common/sanity.yaml
@@ -20,6 +20,7 @@
nxos_interface:
interface: "{{ intname }}"
mode: layer2
+ provider: "{{ connection }}"
- name: "Setup vlans"
nxos_vlan:
@@ -91,7 +92,7 @@
- assert: *false
- - name: Ensure these VLANs are not being tagged on the trunk
+ - name: Remove full trunk vlan range 2-50
nxos_l2_interface: &no_tag
name: "{{ intname }}"
mode: trunk
@@ -102,12 +103,41 @@
- assert: *true
- - name: "no tag vlan Idempotence"
+ - name: Check Idempotence Remove full trunk vlan range 2-50
nxos_l2_interface: *no_tag
register: result
- assert: *false
+ - name: Reconfigure interface trunk port and ensure 2-50 are being tagged
+ nxos_l2_interface: *tag
+ register: result
+
+ - assert: *true
+
+ - name: Check Idempotence Reconfigure interface trunk port and ensure 2-50 are being tagged
+ nxos_l2_interface: *tag
+ register: result
+
+ - assert: *false
+
+ - name: Remove partial trunk vlan range 30-4094 are removed
+ nxos_l2_interface: &partial
+ name: "{{ intname }}"
+ mode: trunk
+ trunk_vlans: 30-4094
+ state: absent
+ provider: "{{ connection }}"
+ register: result
+
+ - assert: *true
+
+ - name: Check Idempotence Remove partial trunk vlan range 30-4094 are removed
+ nxos_l2_interface: *partial
+ register: result
+
+ - assert: *false
+
- name: put interface default state
nxos_l2_interface: *def_swi
register: result
diff --git a/test/integration/targets/nxos_switchport/tests/common/sanity.yaml b/test/integration/targets/nxos_switchport/tests/common/sanity.yaml
index e477c4dad2..899d5acfd2 100644
--- a/test/integration/targets/nxos_switchport/tests/common/sanity.yaml
+++ b/test/integration/targets/nxos_switchport/tests/common/sanity.yaml
@@ -117,7 +117,7 @@
- assert: *false
- - name: Remove partial trunk vlan range 30-4096 are removed
+ - name: Remove partial trunk vlan range 30-4094 are removed
nxos_switchport: &partial
interface: "{{ intname }}"
mode: trunk
@@ -128,7 +128,7 @@
- assert: *true
- - name: Check Idempotence Remove partial trunk vlan range 30-4096 are removed
+ - name: Check Idempotence Remove partial trunk vlan range 30-4094 are removed
nxos_switchport: *partial
register: result