From c04cd8642d0589c3ffc0395a24bd2843a066b196 Mon Sep 17 00:00:00 2001 From: saichint Date: Sun, 14 Jan 2018 22:57:37 -0800 Subject: [PATCH] fix vxlan idempotent issue (#34750) --- .../modules/network/nxos/nxos_vxlan_vtep.py | 5 ++- .../nxos_vxlan_vtep/tests/common/sanity.yaml | 45 +++++++++++++++++-- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py index 6f8046492ec..65f98b7f2a7 100644 --- a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py +++ b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py @@ -58,7 +58,7 @@ options: - Administratively shutdown the NVE interface. required: false choices: ['true','false'] - default: false + default: true source_interface: description: - Specify the loopback interface whose IP address should be @@ -100,6 +100,7 @@ commands: ''' import re + from ansible.module_utils.network.nxos.nxos import get_config, load_config from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args from ansible.module_utils.basic import AnsibleModule @@ -120,6 +121,7 @@ PARAM_TO_COMMAND_KEYMAP = { PARAM_TO_DEFAULT_KEYMAP = { 'description': False, 'shutdown': True, + 'source_interface_hold_down_time': '180', } @@ -270,7 +272,6 @@ def main(): shutdown=dict(required=False, type='bool'), source_interface=dict(required=False, type='str'), source_interface_hold_down_time=dict(required=False, type='str'), - m_facts=dict(required=False, default=False, type='bool'), state=dict(choices=['present', 'absent'], default='present', required=False), ) diff --git a/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml b/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml index 0b58c9aa599..2c7a41596a5 100644 --- a/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml +++ b/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml @@ -1,5 +1,5 @@ --- -- - debug: msg="START connection={{ ansible_connection }} nxos_vxlan_vtep sanity test" +- debug: msg="START connection={{ ansible_connection }} nxos_vxlan_vtep sanity test" - debug: msg="Using provider={{ connection.transport }}" when: ansible_connection == "local" @@ -19,11 +19,11 @@ - name: configure vxlan_vtep nxos_vxlan_vtep: &configure9 interface: nve1 - description: default + description: "abcd" host_reachability: true source_interface: Loopback0 source_interface_hold_down_time: 30 - shutdown: true + shutdown: false provider: "{{ connection }}" register: result @@ -39,6 +39,25 @@ that: - "result.changed == false" + - name: reset vxlan_vtep + nxos_vxlan_vtep: &def9 + interface: nve1 + description: default + host_reachability: false + source_interface_hold_down_time: default + source_interface: default + shutdown: true + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "reset Idempotence" + nxos_vxlan_vtep: *def9 + register: result + + - assert: *false + when: (platform is search('N9K')) - block: @@ -48,7 +67,7 @@ description: default host_reachability: true source_interface: Loopback0 - shutdown: true + shutdown: false provider: "{{ connection }}" register: result @@ -64,6 +83,24 @@ that: - "result.changed == false" + - name: reset vxlan_vtep + nxos_vxlan_vtep: &def7 + interface: nve1 + description: default + host_reachability: false + source_interface: default + shutdown: true + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "reset Idempotence" + nxos_vxlan_vtep: *def7 + register: result + + - assert: *false + when: (platform is search('N7K')) - name: remove vxlan_vtep