Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.9] Fix system default dict generation in nxos_interfaces #69690

Merged
merged 1 commit into from Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_nxos_interfaces_enabled.yaml
@@ -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).
Expand Up @@ -49,7 +49,9 @@ def populate_facts(self, connection, ansible_facts, data=None):
objs = []
if not data:
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
self.render_system_defaults(data)
Expand Down
31 changes: 30 additions & 1 deletion test/integration/targets/nxos_interfaces/tests/cli/merged.yaml
Expand Up @@ -2,14 +2,18 @@
- debug:
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
when: platform is not search('N3[5KL]|N[56]K|titanium')

- name: setup
cli_config: &cleanup
config: |
default interface {{ test_int1 }}
default interface {{ test_int2 }}

- block:
- name: Merged
Expand Down Expand Up @@ -52,6 +56,31 @@
- "result.changed == false"
- "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:
- name: teardown
cli_config: *cleanup