Fix system default dict generation (#69690)

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

Add changelog
pull/69409/head
Nilashish Chakraborty 5 years ago committed by GitHub
parent d9366cb818
commit 307d86de4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix nxos_interfaces enabled not working properly because of broken system default dict generation (https://github.com/ansible-collections/cisco.nxos/pull/56).

@ -49,7 +49,9 @@ class InterfacesFacts(object):
objs = [] objs = []
if not data: if not data:
data = connection.get("show running-config all | incl 'system default switchport'") data = connection.get("show running-config all | incl 'system default switchport'")
data += connection.get('show running-config | section ^interface') data += "\n" + connection.get(
"show running-config | section ^interface"
)
# Collect device defaults & per-intf defaults # Collect device defaults & per-intf defaults
self.render_system_defaults(data) self.render_system_defaults(data)

@ -2,7 +2,10 @@
- debug: - debug:
msg: "Start nxos_interfaces merged integration tests connection={{ ansible_connection }}" msg: "Start nxos_interfaces merged integration tests connection={{ ansible_connection }}"
- set_fact: test_int1="{{ nxos_int1 }}" - set_fact:
test_int1: "{{ nxos_int1 }}"
test_int2: "{{ nxos_int2 }}"
- set_fact: enabled=true - set_fact: enabled=true
when: platform is not search('N3[5KL]|N[56]K|titanium') when: platform is not search('N3[5KL]|N[56]K|titanium')
@ -10,6 +13,7 @@
cli_config: &cleanup cli_config: &cleanup
config: | config: |
default interface {{ test_int1 }} default interface {{ test_int1 }}
default interface {{ test_int2 }}
- block: - block:
- name: Merged - name: Merged
@ -52,6 +56,31 @@
- "result.changed == false" - "result.changed == false"
- "result.commands|length == 0" - "result.commands|length == 0"
- name: "Populate {{ test_int2 }}"
nxos_config:
lines:
- "description Test"
- "switchport"
- "no shutdown"
parents: "interface {{ test_int2 }}"
- name: Update interface state
nxos_interfaces:
config:
- name: "{{ test_int2 }}"
enabled: False
mode: layer2
description: Test
state: merged
register: result
- assert:
that:
- "'interface {{ test_int2 }}' in result.commands"
- "'shutdown' in result.commands"
- result.changed == True
- result.commands|length == 2
always: always:
- name: teardown - name: teardown
cli_config: *cleanup cli_config: *cleanup

Loading…
Cancel
Save