fix nxos_vpc_interface peer_link idempotence (#35737)

* fix peer_link idempotence

* review comment
pull/35819/head
saichint 7 years ago committed by Trishna Guha
parent 8a2bda0e06
commit c9e0ce1d7d

@ -193,12 +193,15 @@ def get_portchannel_vpc_config(module, portchannel):
def get_commands_to_config_vpc_interface(portchannel, delta, config_value, existing): def get_commands_to_config_vpc_interface(portchannel, delta, config_value, existing):
commands = [] commands = []
if delta.get('peer-link') is False and existing.get('peer-link') is True: if not delta.get('peer-link') and existing.get('peer-link'):
command = 'no vpc peer-link'
commands.append('no vpc peer-link') commands.append('no vpc peer-link')
commands.insert(0, 'interface port-channel{0}'.format(portchannel)) commands.insert(0, 'interface port-channel{0}'.format(portchannel))
elif delta.get('peer-link') or not existing.get('vpc'): elif delta.get('peer-link') and not existing.get('peer-link'):
commands.append('vpc peer-link')
commands.insert(0, 'interface port-channel{0}'.format(portchannel))
elif delta.get('vpc') and not existing.get('vpc'):
command = 'vpc {0}'.format(config_value) command = 'vpc {0}'.format(config_value)
commands.append(command) commands.append(command)
commands.insert(0, 'interface port-channel{0}'.format(portchannel)) commands.insert(0, 'interface port-channel{0}'.format(portchannel))

@ -10,7 +10,7 @@
state: enabled state: enabled
provider: "{{ connection }}" provider: "{{ connection }}"
- name: create port-channel - name: create port-channel10
nxos_config: nxos_config:
commands: commands:
- interface port-channel10 - interface port-channel10
@ -18,6 +18,14 @@
match: none match: none
provider: "{{ connection }}" provider: "{{ connection }}"
- name: create port-channel11
nxos_config:
commands:
- interface port-channel11
- switchport
match: none
provider: "{{ connection }}"
- name: configure vpc - name: configure vpc
nxos_vpc: nxos_vpc:
state: present state: present
@ -33,7 +41,7 @@
- name: Configure vpc port channel - name: Configure vpc port channel
nxos_vpc_interface: &conf nxos_vpc_interface: &conf
portchannel: 10 portchannel: 10
vpc: 100 vpc: 10
provider: "{{ connection }}" provider: "{{ connection }}"
register: result register: result
@ -49,10 +57,40 @@
that: that:
- "result.changed == false" - "result.changed == false"
- name: Configure vpc port channel
nxos_vpc_interface: &conf1
portchannel: 11
peer_link: True
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Conf Idempotence"
nxos_vpc_interface: *conf1
register: result
- assert: *false
- name: Configure vpc port channel
nxos_vpc_interface: &conf2
portchannel: 11
peer_link: False
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Conf Idempotence"
nxos_vpc_interface: *conf2
register: result
- assert: *false
- name: remove vpc port channel - name: remove vpc port channel
nxos_vpc_interface: &remove nxos_vpc_interface: &remove
portchannel: 10 portchannel: 10
vpc: 100 vpc: 10
state: absent state: absent
provider: "{{ connection }}" provider: "{{ connection }}"
register: result register: result
@ -82,7 +120,7 @@
- name: remove vpc port channel - name: remove vpc port channel
nxos_vpc_interface: nxos_vpc_interface:
portchannel: 10 portchannel: 10
vpc: 100 vpc: 10
state: absent state: absent
provider: "{{ connection }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
@ -91,6 +129,7 @@
nxos_config: nxos_config:
commands: commands:
- no interface port-channel10 - no interface port-channel10
- no interface port-channel11
match: none match: none
provider: "{{ connection }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes

Loading…
Cancel
Save