Fix nxos_vtp_password and nxos_vrf_interface for remove idempotency tests (#27724)

* fixes for 27600 27676

* add sanity tests
pull/27904/merge
saichint 7 years ago committed by Nathaniel Case
parent 63d0ea3d5a
commit babec35faa

@ -222,7 +222,9 @@ def main():
changed = False
end_state = existing
if vrf != existing['vrf'] and state == 'absent':
if not existing['vrf']:
pass
elif vrf != existing['vrf'] and state == 'absent':
module.fail_json(msg='The VRF you are trying to remove '
'from the interface does not exist '
'on that interface.',

@ -215,7 +215,10 @@ def main():
commands = []
if state == 'absent':
if vtp_password is not None:
# if vtp_password is not set, some devices returns '\\'
if not existing['vtp_password'] or existing['vtp_password'] == '\\':
pass
elif vtp_password is not None:
if existing['vtp_password'] == proposed['vtp_password']:
commands.append(['no vtp password'])
else:

@ -1,3 +1,7 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }
# Use block to ensure that both cli and nxapi tests
# will run even if there are failures or errors.
- block:
- { include: cli.yaml, tags: ['cli'] }
always:
- { include: nxapi.yaml, tags: ['nxapi'] }

@ -1,39 +1,4 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vrf_interface sanity test"
- set_fact: connection="{{ cli }}"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- block:
- name: put interface in L3
nxos_config:
commands:
- no switchport
parents:
- "interface {{ intname }}"
match: none
provider: "{{ cli }}"
- name: Ensure vrf ntc exists on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: present
provider: "{{ cli }}"
- name: Ensure ntc VRF does not exist on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: absent
provider: "{{ cli }}"
always:
- name: put interface in default mode
nxos_config:
lines: "default interface {{ intname }}"
provider: "{{ cli }}"
match: none
ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_vrf_interface sanity test"
- import_tasks: targets/nxos_vrf_interface/tests/common/sanity.yaml

@ -0,0 +1,61 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vrf_interface sanity test"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- block:
- name: put interface in L3
nxos_config:
commands:
- no switchport
parents:
- "interface {{ intname }}"
match: none
provider: "{{ connection }}"
- name: Ensure vrf ntc exists on interface
nxos_vrf_interface: &configure
vrf: ntc
interface: "{{ intname }}"
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Conf Idempotence"
nxos_vrf_interface: *configure
register: result
- assert: &false
that:
- "result.changed == false"
- name: Ensure ntc VRF does not exist on interface
nxos_vrf_interface: &remove
vrf: ntc
interface: "{{ intname }}"
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Remove Idempotence"
nxos_vrf_interface: *remove
register: result
- assert: *false
always:
- name: put interface in default mode
nxos_config:
lines: "default interface {{ intname }}"
provider: "{{ connection }}"
match: none
ignore_errors: yes
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vrf_interface sanity test"

@ -1,39 +1,4 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vrf_interface sanity test"
- set_fact: connection="{{ nxapi }}"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- block:
- name: put interface in L3
nxos_config:
commands:
- no switchport
parents:
- "interface {{ intname }}"
match: none
provider: "{{ nxapi }}"
- name: Ensure vrf ntc exists on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: present
provider: "{{ nxapi }}"
- name: Ensure ntc VRF does not exist on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: absent
provider: "{{ nxapi }}"
always:
- name: put interface in default mode
nxos_config:
lines: "default interface {{ intname }}"
provider: "{{ nxapi }}"
match: none
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_vrf_interface sanity test"
- import_tasks: targets/nxos_vrf_interface/tests/common/sanity.yaml

@ -1,3 +1,7 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }
# Use block to ensure that both cli and nxapi tests
# will run even if there are failures or errors.
- block:
- { include: cli.yaml, tags: ['cli'] }
always:
- { include: nxapi.yaml, tags: ['nxapi'] }

@ -1,30 +1,4 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vtp_password sanity test"
- set_fact: connection="{{ cli }}"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ cli }}"
- name: configure vtp password
nxos_vtp_password:
password: ntc
state: present
provider: "{{ cli }}"
- name: remove vtp password
nxos_vtp_password:
password: ntc
state: absent
provider: "{{ cli }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ cli }}"
- debug: msg="END TRANSPORT:CLI nxos_vtp_password sanity test"
- import_tasks: targets/nxos_vtp_password/tests/common/sanity.yaml

@ -0,0 +1,57 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vtp_password sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ connection }}"
- name: configure vtp domain
nxos_vtp_domain:
domain: testing
provider: "{{ connection }}"
- name: configure vtp password
nxos_vtp_password: &configure
vtp_password: ntc
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Conf Idempotence"
nxos_vtp_password: *configure
register: result
- assert: &false
that:
- "result.changed == false"
- name: remove vtp password
nxos_vtp_password: &remove
vtp_password: ntc
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Remove Idempotence"
nxos_vtp_password: *remove
register: result
- assert: *false
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ connection }}"
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vtp_password sanity test"

@ -1,30 +1,4 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vtp_password sanity test"
- set_fact: connection="{{ nxapi }}"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ nxapi }}"
- name: configure vtp password
nxos_vtp_password:
password: ntc
state: present
provider: "{{ nxapi }}"
- name: remove vtp password
nxos_vtp_password:
password: ntc
state: absent
provider: "{{ nxapi }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_vtp_password sanity test"
- import_tasks: targets/nxos_vtp_password/tests/common/sanity.yaml

Loading…
Cancel
Save