mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Convert nxos_vlan to DI module (#31866)
* Convert nxos_vlan to DI * fix conflict * push fix for qalthos's comment Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
8b15b93d01
commit
60f3649ebd
6 changed files with 483 additions and 243 deletions
105
test/integration/targets/nxos_vlan/tests/common/interface.yaml
Normal file
105
test/integration/targets/nxos_vlan/tests/common/interface.yaml
Normal file
|
@ -0,0 +1,105 @@
|
|||
---
|
||||
- set_fact: testint1="{{ nxos_int1 }}"
|
||||
- set_fact: testint2="{{ nxos_int2 }}"
|
||||
|
||||
- name: setup - remove vlan used in test
|
||||
nxos_config:
|
||||
lines:
|
||||
- no vlan 100
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: setup - remove vlan from interfaces used in test(part1)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no switchport access vlan 100
|
||||
parents: switchport
|
||||
before: "interface {{ testint1 }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: setup - remove vlan from interfaces used in test(part2)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no switchport access vlan 100
|
||||
parents: switchport
|
||||
before: "interface {{ testint2 }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: create vlan
|
||||
nxos_vlan:
|
||||
vlan_id: 100
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: Add interfaces to vlan
|
||||
nxos_vlan: &interfaces
|
||||
vlan_id: 100
|
||||
interfaces:
|
||||
- "{{ testint1 }}"
|
||||
- "{{ testint2 }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"interface {{ testint1 }}" in result.commands'
|
||||
- '"switchport" in result.commands'
|
||||
- '"switchport mode access" in result.commands'
|
||||
- '"switchport access vlan 100" in result.commands'
|
||||
- '"interface {{ testint2 }}" in result.commands'
|
||||
- '"switchport" in result.commands'
|
||||
- '"switchport mode access" in result.commands'
|
||||
- '"switchport access vlan 100" in result.commands'
|
||||
|
||||
- name: Add interfaces to vlan(idempotence)
|
||||
nxos_vlan: *interfaces
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Remove interface from vlan
|
||||
nxos_vlan: &single_int
|
||||
vlan_id: 100
|
||||
interfaces:
|
||||
- "{{ testint2 }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"interface {{ testint1 }}" in result.commands'
|
||||
- '"switchport" in result.commands'
|
||||
- '"switchport mode access" in result.commands'
|
||||
- '"no switchport access vlan 100" in result.commands'
|
||||
|
||||
- name: Remove interface from vlan(idempotence)
|
||||
nxos_vlan: *single_int
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: teardown(part1)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no vlan 100
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: teardown - remove vlan from interfaces used in test(part1)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no switchport access vlan 100
|
||||
parents: switchport
|
||||
before: "interface {{ testint1 }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: teardown - remove vlan from interfaces used in test(part2)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no switchport access vlan 100
|
||||
parents: switchport
|
||||
before: "interface {{ testint2 }}"
|
||||
provider: "{{ connection }}"
|
Loading…
Add table
Add a link
Reference in a new issue