mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Deprecate nxos_ip_interface and Add nxos_l3_interface DI module (#33866)
* Deprecate nxos_ip_interface module Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add nxos_l3_interface DI module Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add integration test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * pep8 fixes * Add nxapi cli test * Improve complexity * manage layer3 interface * fix unit test
This commit is contained in:
parent
27be2a0f5a
commit
3cce8dfafd
14 changed files with 523 additions and 8 deletions
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/nxos_l3_interface/meta/main.yml
Normal file
2
test/integration/targets/nxos_l3_interface/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
25
test/integration/targets/nxos_l3_interface/tasks/cli.yaml
Normal file
25
test/integration/targets/nxos_l3_interface/tasks/cli.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: cli_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }} connection={{ cli }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
25
test/integration/targets/nxos_l3_interface/tasks/nxapi.yaml
Normal file
25
test/integration/targets/nxos_l3_interface/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- name: collect common nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/nxapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: nxapi_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }} connection={{ nxapi }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
107
test/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml
Normal file
107
test/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml
Normal file
|
@ -0,0 +1,107 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:CLI nxos_l3_interface sanity test"
|
||||
|
||||
# Select interface for test
|
||||
- set_fact: testint2="{{ nxos_int2 }}"
|
||||
- set_fact: testint3="{{ nxos_int3 }}"
|
||||
|
||||
- name: Setup - remove address from interface prior to testing(Part1)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no ip address 192.168.22.1/24
|
||||
parents: no switchport
|
||||
before: "interface {{ testint2 }}"
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Setup - remove address from interface prior to testing(Part2)
|
||||
nxos_config:
|
||||
lines:
|
||||
- no ip address 192.168.20.1/24
|
||||
- no ipv6 address 33:db::2/8
|
||||
parents: no switchport
|
||||
before: "interface {{ testint3 }}"
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Configure ipv4 address to interface
|
||||
nxos_l3_interface: &conf
|
||||
name: "{{ testint2 }}"
|
||||
ipv4: 192.168.22.1/24
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Configure ipv4 address to interface(Idempotence)
|
||||
nxos_l3_interface: *conf
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove ipv4 address from interface
|
||||
nxos_l3_interface: &rm
|
||||
name: "{{ testint2 }}"
|
||||
ipv4: 192.168.22.1/24
|
||||
provider: "{{ cli }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Remove ipv4 address from interface(Idempotence)
|
||||
nxos_l3_interface: *rm
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Configure address to interfaces aggregate
|
||||
nxos_l3_interface: &conf_agg
|
||||
aggregate:
|
||||
- { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 }
|
||||
- { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" }
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Configure address to interfaces aggregate(Idempotence)
|
||||
nxos_l3_interface: *conf_agg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove address from interfaces aggregate
|
||||
nxos_l3_interface: &rm_agg
|
||||
aggregate:
|
||||
- { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 }
|
||||
- { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" }
|
||||
provider: "{{ cli }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Remove address from interfaces aggregate(Idempotence)
|
||||
nxos_l3_interface: *rm_agg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- debug: msg="END TRANSPORT:CLI nxos_l3_interface sanity test"
|
|
@ -0,0 +1,97 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:NXAPI nxos_l3_interface sanity test"
|
||||
|
||||
# Select interface for test
|
||||
- set_fact: testint2="{{ nxos_int2 }}"
|
||||
- set_fact: testint3="{{ nxos_int3 }}"
|
||||
|
||||
- name: Setup - Remove address from interfaces aggregate
|
||||
nxos_l3_interface:
|
||||
aggregate:
|
||||
- { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 }
|
||||
- { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" }
|
||||
provider: "{{ nxapi }}"
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Configure ipv4 address to interface
|
||||
nxos_l3_interface: &conf
|
||||
name: "{{ testint2 }}"
|
||||
ipv4: 192.168.22.1/24
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Configure ipv4 address to interface(Idempotence)
|
||||
nxos_l3_interface: *conf
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove ipv4 address from interface
|
||||
nxos_l3_interface: &rm
|
||||
name: "{{ testint2 }}"
|
||||
ipv4: 192.168.22.1/24
|
||||
provider: "{{ nxapi }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Remove ipv4 address from interface(Idempotence)
|
||||
nxos_l3_interface: *rm
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Configure address to interfaces aggregate
|
||||
nxos_l3_interface: &conf_agg
|
||||
aggregate:
|
||||
- { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 }
|
||||
- { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" }
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Configure address to interfaces aggregate(Idempotence)
|
||||
nxos_l3_interface: *conf_agg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove address from interfaces aggregate
|
||||
nxos_l3_interface: &rm_agg
|
||||
aggregate:
|
||||
- { name: "{{ testint2 }}", ipv4: 192.168.22.1/24 }
|
||||
- { name: "{{ testint3 }}", ipv4: 192.168.20.1/24, ipv6: "33:db::2/8" }
|
||||
provider: "{{ nxapi }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Remove address from interfaces aggregate(Idempotence)
|
||||
nxos_l3_interface: *rm_agg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- debug: msg="END TRANSPORT:NXAPI nxos_l3_interface sanity test"
|
Loading…
Add table
Add a link
Reference in a new issue