diff options
Diffstat (limited to 'ansible_collections/cisco/nxos/tests')
254 files changed, 5288 insertions, 3825 deletions
diff --git a/ansible_collections/cisco/nxos/tests/config.yml b/ansible_collections/cisco/nxos/tests/config.yml new file mode 100644 index 000000000..41f529264 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/config.yml @@ -0,0 +1,3 @@ +--- +modules: + python_requires: ">=3.6" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml index f41fb7360..3e5e72a07 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml index 86c82adda..59a0777c5 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/cli.yaml index c34726ef5..3e5e72a07 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/cli.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/nxapi.yaml index e0ebc3f54..59a0777c5 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_acls/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_banner/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml index 9aa0d8690..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml @@ -23,11 +23,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/defaults/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/meta/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/cli.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - connection: local - register: test_cases - -- name: Collect CLI test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - connection: local - register: cli_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + cli_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases (connection=ansible.netcommon.network_cli) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - -- name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml deleted file mode 100644 index 0f4bd883e..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml +++ /dev/null @@ -1,85 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp parameter test - -- ansible.builtin.debug: - msg: This bgp_disable_policy is not supported on {{ image_version }} - when: imagetag is search("A8|D1") - -- name: Set a fact for 'bgp_disable_policy' - ansible.builtin.set_fact: - bgp_disable_policy: false - -- name: Set a fact for 'bgp_disable_policy' - ansible.builtin.set_fact: - bgp_disable_policy: true - when: imagetag is not search("A8|D1") - -- name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- block: - - name: Set disable policy - register: result - when: bgp_disable_policy - cisco.nxos.nxos_bgp: &id001 - asn: 65535 - disable_policy_batching: true - disable_policy_batching_ipv4_prefix_list: v4_p - disable_policy_batching_ipv6_prefix_list: v6_p - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - when: bgp_disable_policy - - - name: Check idempotence - register: result - when: bgp_disable_policy - cisco.nxos.nxos_bgp: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - when: bgp_disable_policy - - - name: Reset disable policy - register: result - when: bgp_disable_policy - cisco.nxos.nxos_bgp: &id003 - asn: 65535 - disable_policy_batching: false - disable_policy_batching_ipv4_prefix_list: default - disable_policy_batching_ipv6_prefix_list: default - - - ansible.builtin.assert: *id002 - when: bgp_disable_policy - - - name: Check idempotence - register: result - when: bgp_disable_policy - cisco.nxos.nxos_bgp: *id003 - - - ansible.builtin.assert: *id004 - when: bgp_disable_policy - rescue: - - ansible.builtin.debug: - msg: Tests can fail on A8 or helsinki images - always: - - name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp parameter test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/hels.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/hels.yaml deleted file mode 100644 index 65b7c7251..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/hels.yaml +++ /dev/null @@ -1,101 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp parameter test - -- ansible.builtin.debug: - msg: This test is not supported on {{ image_version }} - when: imagetag is search("D1") - -- name: Set a fact for 'test_helsinki' - ansible.builtin.set_fact: - test_helsinki: false - -- name: Set a fact for 'test_helsinki' - ansible.builtin.set_fact: - test_helsinki: true - when: imagetag is not search("D1") - -- name: Disable 'feature bgp' - ignore_errors: true - when: test_helsinki - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - ignore_errors: true - when: test_helsinki - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- block: - - name: Set helsinki - with_items: "{{ vrfs }}" - register: result - when: test_helsinki - cisco.nxos.nxos_bgp: &id001 - asn: 65535 - vrf: "{{ item }}" - graceful_restart_timers_restart: 130 - graceful_restart_timers_stalepath_time: 310 - neighbor_down_fib_accelerate: true - reconnect_interval: 55 - timer_bgp_hold: 110 - timer_bgp_keepalive: 45 - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - when: test_helsinki - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - when: test_helsinki - cisco.nxos.nxos_bgp: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - when: test_helsinki - - - name: Reset helsinki - with_items: "{{ vrfs }}" - register: result - when: test_helsinki - cisco.nxos.nxos_bgp: &id003 - asn: 65535 - vrf: "{{ item }}" - graceful_restart: true - graceful_restart_timers_restart: default - graceful_restart_timers_stalepath_time: default - neighbor_down_fib_accelerate: false - reconnect_interval: default - timer_bgp_hold: default - timer_bgp_keepalive: default - - - ansible.builtin.assert: *id002 - when: test_helsinki - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - when: test_helsinki - cisco.nxos.nxos_bgp: *id003 - - - ansible.builtin.assert: *id004 - when: test_helsinki - rescue: - - ansible.builtin.debug: - msg: Tests can fail on helsinki images - always: - - name: Disable 'feature bgp' - ignore_errors: true - when: test_helsinki - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp parameter test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml deleted file mode 100644 index de4bafb11..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml +++ /dev/null @@ -1,81 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp parameter test - -- ansible.builtin.debug: - msg: This bgp_isolate is not supported on {{ image_version }} - when: imagetag is search("A8") - -- name: Set a fact for 'bgp_isolate' - ansible.builtin.set_fact: - bgp_isolate: false - -- name: Set a fact for 'bgp_isolate' - ansible.builtin.set_fact: - bgp_isolate: true - when: imagetag is not search("A8") - -- name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- block: - - name: Set isolate - register: result - when: bgp_isolate - cisco.nxos.nxos_bgp: &id001 - asn: 65535 - isolate: false - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - when: bgp_isolate - - - name: Check idempotence - register: result - when: bgp_isolate - cisco.nxos.nxos_bgp: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - when: bgp_isolate - - - name: Reset isolate - register: result - when: bgp_isolate - cisco.nxos.nxos_bgp: &id003 - asn: 65535 - isolate: true - - - ansible.builtin.assert: *id002 - when: bgp_isolate - - - name: Check idempotence - register: result - when: bgp_isolate - cisco.nxos.nxos_bgp: *id003 - - - ansible.builtin.assert: *id004 - when: bgp_isolate - rescue: - - ansible.builtin.debug: - msg: Tests can fail on A8 images - always: - - name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp parameter test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/param.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/param.yaml deleted file mode 100644 index a4d7c2ffa..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/param.yaml +++ /dev/null @@ -1,258 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp parameter test - -- name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- block: - - name: Set multi VRF params - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: &id001 - asn: 65535 - vrf: "{{ item }}" - router_id: 192.0.2.1 - bestpath_always_compare_med: true - bestpath_aspath_multipath_relax: true - bestpath_compare_routerid: true - bestpath_cost_community_ignore: true - bestpath_med_confed: true - bestpath_med_missing_as_worst: true - bestpath_med_non_deterministic: true - graceful_restart_helper: true - log_neighbor_changes: true - maxas_limit: 50 - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Reset multi VRF params - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: &id003 - asn: 65535 - vrf: "{{ item }}" - bestpath_always_compare_med: false - bestpath_aspath_multipath_relax: false - bestpath_compare_routerid: false - bestpath_cost_community_ignore: false - bestpath_med_confed: false - bestpath_med_missing_as_worst: false - bestpath_med_non_deterministic: false - graceful_restart_helper: false - log_neighbor_changes: false - maxas_limit: default - router_id: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: *id003 - - - ansible.builtin.assert: *id004 - - - name: Set clusterid - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: &id005 - asn: 65535 - vrf: "{{ item }}" - cluster_id: 10.0.0.1 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: *id005 - - - ansible.builtin.assert: *id004 - - - name: Reset cluster_id - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: &id006 - asn: 65535 - vrf: "{{ item }}" - cluster_id: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: *id006 - - - ansible.builtin.assert: *id004 - - - name: Set confederation - register: result - cisco.nxos.nxos_bgp: &id007 - asn: 65535 - confederation_id: 99 - confederation_peers: - - 16 - - 22 - - 18 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id007 - - - ansible.builtin.assert: *id004 - - - name: Reset confederation - register: result - cisco.nxos.nxos_bgp: &id008 - asn: 65535 - confederation_id: default - confederation_peers: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id008 - - - ansible.builtin.assert: *id004 - - - name: Set confederation_local_as - register: result - cisco.nxos.nxos_bgp: &id009 - asn: 65535 - vrf: myvrf - local_as: 33 - confederation_id: 99 - confederation_peers: - - 16 - - 22 - - 18 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id009 - - - ansible.builtin.assert: *id004 - - - name: Reset confederation local_as - register: result - cisco.nxos.nxos_bgp: &id010 - asn: 65535 - vrf: myvrf - local_as: default - confederation_id: default - confederation_peers: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id010 - - - ansible.builtin.assert: *id004 - - - name: Set local_as - register: result - cisco.nxos.nxos_bgp: &id011 - asn: 65535 - vrf: myvrf - local_as: 33 - confederation_id: 99 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id011 - - - ansible.builtin.assert: *id004 - - - name: Reset local_as - register: result - cisco.nxos.nxos_bgp: &id012 - asn: 65535 - vrf: myvrf - confederation_id: default - local_as: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id012 - - - ansible.builtin.assert: *id004 - - - name: Set default VRF params - register: result - cisco.nxos.nxos_bgp: &id013 - asn: 65535 - event_history_cli: size_medium - event_history_detail: size_large - event_history_events: size_medium - event_history_periodic: size_small - enforce_first_as: false - fast_external_fallover: false - flush_routes: true - shutdown: true - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id013 - - - ansible.builtin.assert: *id004 - - - name: Reset default VRF params - register: result - cisco.nxos.nxos_bgp: &id014 - asn: 65535 - event_history_detail: default - enforce_first_as: true - fast_external_fallover: true - flush_routes: false - shutdown: false - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id014 - - - ansible.builtin.assert: *id004 - always: - - name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp parameter test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml deleted file mode 100644 index dc2b018cc..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml +++ /dev/null @@ -1,138 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp sanity test - -- name: Set a fact for 'neighbor_down_fib_accelerate' - ansible.builtin.set_fact: - neighbor_down_fib_accelerate: true - when: (not titanium) and ((imagetag != 'N1') and (imagetag != 'D1')) - -- name: Set a fact for 'reconnect_interval' - ansible.builtin.set_fact: - reconnect_interval: "55" - when: (not titanium) and ((imagetag != 'N1') and (imagetag != 'D1')) - -- name: Set a fact for 'isolate' - ansible.builtin.set_fact: - isolate: false - when: platform is not match("N35") - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- name: Setup - ignore_errors: true - register: result - cisco.nxos.nxos_bgp: &id002 - asn: 65535 - state: absent - -- block: - - name: Configure BGP defaults - register: result - cisco.nxos.nxos_bgp: &id001 - asn: 65535 - router_id: 192.0.2.1 - state: present - - - ansible.builtin.assert: &id003 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Remove BGP - register: result - cisco.nxos.nxos_bgp: *id002 - - - ansible.builtin.assert: *id003 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id002 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP non defaults - register: result - cisco.nxos.nxos_bgp: &id005 - asn: 65535 - router_id: 192.0.2.1 - bestpath_always_compare_med: true - bestpath_aspath_multipath_relax: true - bestpath_compare_routerid: true - bestpath_cost_community_ignore: true - bestpath_med_confed: true - bestpath_med_missing_as_worst: true - bestpath_med_non_deterministic: true - cluster_id: 10.0.0.1 - confederation_id: 99 - disable_policy_batching: true - enforce_first_as: false - fast_external_fallover: false - flush_routes: true - graceful_restart_helper: true - graceful_restart_timers_restart: 130 - graceful_restart_timers_stalepath_time: 310 - isolate: "{{isolate|default(omit)}}" - log_neighbor_changes: true - maxas_limit: 50 - neighbor_down_fib_accelerate: "{{neighbor_down_fib_accelerate|default(omit)}}" - reconnect_interval: "{{reconnect_interval|default(omit)}}" - shutdown: true - timer_bestpath_limit: 255 - timer_bgp_hold: 110 - timer_bgp_keepalive: 45 - event_history_cli: size_medium - event_history_detail: size_large - event_history_events: size_medium - event_history_periodic: size_small - suppress_fib_pending: true - state: present - - - ansible.builtin.assert: *id003 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id005 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - register: result - cisco.nxos.nxos_bgp: *id002 - - - ansible.builtin.assert: *id003 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp: *id002 - - - ansible.builtin.assert: *id004 - - - name: Disable 'feature bgp' - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - rescue: - - name: Cleanup BGP - ignore_errors: true - cisco.nxos.nxos_bgp: *id002 - - - name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - always: - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml deleted file mode 100644 index ead5a515e..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml +++ /dev/null @@ -1,120 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp parameter test - -- name: Set a fact for 'bgp_best_path_limit' - ansible.builtin.set_fact: - bgp_best_path_limit: false - -- name: Set a fact for 'bgp_best_path_limit' - ansible.builtin.set_fact: - bgp_best_path_limit: true - when: imagetag is not search("I2") - -- name: Set a fact for 'bgp_suppress_fib_supported' - ansible.builtin.set_fact: - bgp_suppress_fib_supported: false - -- name: Set a fact for 'bgp_suppress_fib_supported' - ansible.builtin.set_fact: - bgp_suppress_fib_supported: true - when: imagetag is not search("A8|D1|I2|I4") - -- name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- block: - - name: Set bestpath limit - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: &id001 - asn: 65535 - vrf: "{{ item }}" - timer_bestpath_limit: 255 - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Reset bestpath limit - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp: &id003 - asn: 65535 - vrf: "{{ item }}" - timer_bestpath_limit: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - when: bgp_best_path_limit - cisco.nxos.nxos_bgp: *id003 - - - ansible.builtin.assert: *id004 - when: bgp_best_path_limit - - - name: Set suppress FIB - register: result - cisco.nxos.nxos_bgp: &id005 - asn: 65535 - suppress_fib_pending: false - - - ansible.builtin.assert: *id002 - when: bgp_suppress_fib_supported - - - name: Check idempotence - register: result - when: bgp_suppress_fib_supported - cisco.nxos.nxos_bgp: *id005 - - - ansible.builtin.assert: *id004 - when: bgp_suppress_fib_supported - - - name: Reset suppress FIB - register: result - cisco.nxos.nxos_bgp: &id006 - asn: 65535 - suppress_fib_pending: true - - - ansible.builtin.assert: *id002 - when: bgp_suppress_fib_supported - - - name: Check idempotence - register: result - when: bgp_suppress_fib_supported - cisco.nxos.nxos_bgp: *id006 - - - ansible.builtin.assert: *id004 - when: bgp_suppress_fib_supported - rescue: - - ansible.builtin.debug: - msg: Tests can fail on I2/I4/A8/Fretta or helsinki images - always: - - name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp parameter test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/defaults/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/meta/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - connection: local - register: test_cases - -- name: Collect CLI test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - connection: local - register: cli_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + cli_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases (connection=ansible.netcommon.network_cli) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - -- name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - connection: local - register: test_cases - -- name: Collect NX-API test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/nxapi" - patterns: "{{ testcase }}.yaml" - connection: local - register: nxapi_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + nxapi_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases (connection=ansible.netcommon.httpapi) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml deleted file mode 100644 index 93eb7654c..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml +++ /dev/null @@ -1,132 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp_af multisite sanity test - -- name: Enable 'feature bgp' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- name: Enable 'feature nv overlay' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nv overlay - state: enabled - -- name: Setup - multisite - ignore_errors: true - cisco.nxos.nxos_bgp: - asn: 65535 - state: absent - -- name: Enable NV overlay EVPN - multisite - when: platform is search('N9K') - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - nv overlay evpn - -- name: Enable multisite border gateway - multisite - ignore_errors: true - register: multiout - cisco.nxos.nxos_config: - lines: - - evpn multisite border-gateway 10 - -- block: - - name: Configure BGP_AF route target name - register: result - cisco.nxos.nxos_bgp_af: &id001 - asn: 65535 - afi: l2vpn - safi: evpn - state: present - retain_route_target: abc - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_af: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure BGP_AF route target default - register: result - cisco.nxos.nxos_bgp_af: &id003 - asn: 65535 - afi: l2vpn - safi: evpn - state: present - retain_route_target: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_af: *id003 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP_AF 1 route target all - register: result - cisco.nxos.nxos_bgp_af: &id005 - asn: 65535 - afi: l2vpn - safi: evpn - state: present - retain_route_target: all - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_af: *id005 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - route target - register: result - cisco.nxos.nxos_bgp_af: - asn: 65535 - afi: l2vpn - safi: evpn - retain_route_target: all - state: absent - - - ansible.builtin.assert: *id002 - - - name: Disable multisite border gateway - multisite - cisco.nxos.nxos_config: - lines: - - no evpn multisite border-gateway 10 - when: multiout is not search("Invalid command") - -- name: Disable 'feature bgp' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Disable 'feature nv overlay' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nv overlay - state: disabled - -- ansible.builtin.pause: - seconds: 5 - -- name: Remove NV overlay EVPN - multisite - when: platform is search('N9K') - cisco.nxos.nxos_config: - lines: - - no nv overlay evpn - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp_af multisite sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml deleted file mode 100644 index fa06c19f9..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml +++ /dev/null @@ -1,342 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp_af sanity test - -- name: Set a fact for 'advertise_l2vpn_evpn' - ansible.builtin.set_fact: - advertise_l2vpn_evpn: true - when: platform is search('N9K') - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- name: Enable 'feature nv overlay' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nv overlay - state: enabled - -- name: Setup - ignore_errors: true - cisco.nxos.nxos_bgp: &id012 - asn: 65535 - state: absent - -- block: - - name: Enable NV overlay EVPN - when: platform is search('N9K') - cisco.nxos.nxos_config: - lines: - - nv overlay evpn - - - name: Configure BGP_AF 1 - register: result - cisco.nxos.nxos_bgp_af: &id001 - asn: 65535 - vrf: testing - afi: ipv4 - safi: unicast - advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_af: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Remove BGP - register: result - cisco.nxos.nxos_bgp_af: - asn: 65535 - vrf: testing - afi: ipv4 - safi: unicast - state: absent - - - ansible.builtin.assert: *id002 - - - name: Configure BGP_AF 2 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id003 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampening_state: true - additional_paths_install: true - additional_paths_receive: true - additional_paths_selection: RouteMap - additional_paths_send: true - client_to_client: false - default_information_originate: true - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id003 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP_AF def2 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id005 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampening_state: false - additional_paths_install: false - additional_paths_receive: false - additional_paths_selection: default - additional_paths_send: false - client_to_client: true - default_information_originate: false - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id005 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id008 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - state: absent - - - ansible.builtin.assert: *id002 - - - name: Configure BGP_AF 3 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id006 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampening_routemap: abcd - default_metric: 50 - distance_ebgp: 30 - distance_ibgp: 60 - distance_local: 90 - maximum_paths: 9 - maximum_paths_ibgp: 9 - next_hop_route_map: RouteMap - suppress_inactive: true - table_map: RouteMap - table_map_filter: true - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id006 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP_AF def3 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id007 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampening_routemap: default - default_metric: default - distance_ebgp: default - distance_ibgp: default - distance_local: default - maximum_paths: default - maximum_paths_ibgp: default - next_hop_route_map: default - suppress_inactive: false - table_map: default - table_map_filter: false - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id007 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id008 - - - ansible.builtin.assert: *id002 - - - name: Configure BGP_AF 4 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id009 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampen_igp_metric: 200 - dampening_half_time: 1 - dampening_max_suppress_time: 4 - dampening_reuse_time: 2 - dampening_suppress_time: 3 - inject_map: - - - lax_inject_map - - lax_exist_map - - - nyc_inject_map - - nyc_exist_map - - copy-attributes - - - fsd_inject_map - - fsd_exist_map - networks: - - - 10.0.0.0/16 - - routemap_LA - - - 192.168.1.1/32 - - Chicago - - - 192.168.2.0/24 - - - 192.168.3.0/24 - - routemap_NYC - redistribute: - - - direct - - rm_direct - - - lisp - - rm_lisp - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id009 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP_AF 5 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id010 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampen_igp_metric: 300 - dampening_half_time: 10 - dampening_max_suppress_time: 40 - dampening_reuse_time: 20 - dampening_suppress_time: 30 - inject_map: - - - fsd_inject_map - - fsd_exist_map - networks: - - - 192.168.2.0/24 - redistribute: - - - lisp - - rm_lisp - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id010 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP_AF def5 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: &id011 - asn: 65535 - vrf: "{{ item }}" - afi: ipv4 - safi: unicast - dampen_igp_metric: default - dampening_half_time: default - dampening_max_suppress_time: default - dampening_reuse_time: default - dampening_suppress_time: default - inject_map: default - networks: default - redistribute: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id011 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id008 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_af: *id008 - - - ansible.builtin.assert: *id004 - rescue: - - name: Cleanup BGP - ignore_errors: true - cisco.nxos.nxos_bgp: *id012 - always: - - name: Disable 'feature bgp' - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - - - name: Disable 'feature nv overlay' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nv overlay - state: disabled - - - ansible.builtin.pause: - seconds: 5 - - - name: Remove NV overlay EVPN - when: platform is search('N9K') - cisco.nxos.nxos_config: - lines: - - no nv overlay evpn - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp_af sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/meta/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - -- name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - connection: local - register: test_cases - -- name: Collect NX-API test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/nxapi" - patterns: "{{ testcase }}.yaml" - connection: local - register: nxapi_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + nxapi_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases (connection=ansible.netcommon.httpapi) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml deleted file mode 100644 index f567a6e04..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml +++ /dev/null @@ -1,123 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp_neighbor multisite sanity test - -- name: Set a fact for 'intname' - ansible.builtin.set_fact: - intname: "{{ nxos_int1 }}" - -- name: "Setup: disable features - multisite" - loop: - - bgp - - bfd - - nv overlay - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- name: "Setup: enable features - multisite" - loop: - - bgp - - bfd - - nv overlay - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: enabled - -- name: Enable NV overlay EVPN - multisite - when: platform is search('N9K') - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - nv overlay evpn - -- name: Enable multisite border gateway - multisite - ignore_errors: true - register: multiout - cisco.nxos.nxos_config: - lines: - - evpn multisite border-gateway 10 - -- block: - - name: Configure BGP neighbor1 - multisite - register: result - cisco.nxos.nxos_bgp_neighbor: &id001 - asn: 65535 - neighbor: 192.0.2.3/32 - remote_as: 33.22 - description: just a description - shutdown: true - state: present - peer_type: fabric_border_leaf - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure BGP neighbor2 - multisite - register: result - cisco.nxos.nxos_bgp_neighbor: &id003 - asn: 65535 - neighbor: 192.0.2.3/32 - peer_type: disable - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor: *id003 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor3 - multisite - register: result - cisco.nxos.nxos_bgp_neighbor: &id005 - asn: 65535 - neighbor: 192.0.2.3/32 - peer_type: fabric_external - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor: *id005 - - - ansible.builtin.assert: *id004 - - - name: Disable multisite border gateway - multisite - cisco.nxos.nxos_config: - lines: - - no evpn multisite border-gateway 10 - when: multiout is not search("Invalid command") - -- name: "Teardown: disable features" - loop: - - bgp - - bfd - - nv overlay - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- ansible.builtin.pause: - seconds: 5 - -- name: Remove NV overlay EVPN - multisite - when: platform is search('N9K') - cisco.nxos.nxos_config: - lines: - - no nv overlay evpn - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp_neighbor multisite sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml deleted file mode 100644 index c2fff45a0..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml +++ /dev/null @@ -1,357 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp_neighbor sanity test - -- name: Set a fact for 'intname' - ansible.builtin.set_fact: - intname: "{{ nxos_int1 }}" - -- name: Set a fact for 'log_neighbor_changese' - ansible.builtin.set_fact: - log_neighbor_changese: enable - when: (imagetag and imagetag is not search("D1|N1")) - -- name: Set a fact for 'log_neighbor_changesd' - ansible.builtin.set_fact: - log_neighbor_changesd: disable - when: (imagetag and imagetag is not search("D1|N1")) - -- ansible.builtin.debug: - var: titanium - -- name: Set a fact for 'remove_private_asa' - ansible.builtin.set_fact: - remove_private_asa: all - when: not titanium - -- name: Set a fact for 'remove_private_asr' - ansible.builtin.set_fact: - remove_private_asr: replace-as - when: not titanium - -- name: "Setup: disable features" - loop: - - bgp - - bfd - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- name: "Setup: enable features" - loop: - - bgp - - bfd - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: enabled - -- block: - - name: Configure BGP neighbor1 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id001 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - connected_check: true - capability_negotiation: true - dynamic_capability: true - ebgp_multihop: 2 - low_memory_exempt: true - maximum_peers: 10 - suppress_4_byte_as: true - timers_keepalive: 90 - timers_holdtime: 270 - log_neighbor_changes: "{{log_neighbor_changese|default(omit)}}" - local_as: 22.33 - remote_as: 33.22 - description: just a description - update_source: "{{ intname.capitalize() }}" - shutdown: true - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure BGP neighbor2 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id003 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - connected_check: false - capability_negotiation: false - dynamic_capability: false - ebgp_multihop: default - low_memory_exempt: false - maximum_peers: default - suppress_4_byte_as: false - timers_keepalive: default - timers_holdtime: default - log_neighbor_changes: "{{log_neighbor_changesd|default(omit)}}" - local_as: default - remote_as: default - description: default - update_source: default - shutdown: false - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id003 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id005 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id005 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor3 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id006 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - description: tested by ansible - remove_private_as: "{{remove_private_asa|default(omit)}}" - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id006 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor4 - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id007 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - description: tested by ansible - remove_private_as: "{{remove_private_asr|default(omit)}}" - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id007 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id005 - - - ansible.builtin.assert: *id002 - - - name: Configure BGP neighbor 3des password - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id008 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - remote_as: 30 - pwd: 386c0565965f89de - pwd_type: 3des - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id008 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id005 - - - ansible.builtin.assert: *id002 - - - name: Configure BGP neighbor type 7 password - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id009 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - remote_as: 30 - pwd: 386c0565965f89de - pwd_type: cisco_type_7 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id009 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP neighbor password - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id010 - asn: 65535 - neighbor: 192.0.2.3/32 - vrf: "{{ item }}" - remote_as: 30 - pwd: default - pwd_type: default - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id010 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id005 - - - ansible.builtin.assert: *id002 - - - name: Configure BGP neighbor transport type passive - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id011 - asn: 65535 - neighbor: 192.0.2.3 - vrf: "{{ item }}" - remote_as: 30 - transport_passive_only: true - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id011 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor transport type default - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id012 - asn: 65535 - neighbor: 192.0.2.3 - vrf: "{{ item }}" - remote_as: 30 - transport_passive_only: false - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id012 - - - ansible.builtin.assert: *id004 - - - name: Remove BGP - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: &id013 - asn: 65535 - neighbor: 192.0.2.3 - vrf: "{{ item }}" - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_bgp_neighbor: *id013 - - - ansible.builtin.assert: *id004 - - - name: Configure BFD enable - register: result - cisco.nxos.nxos_bgp_neighbor: &id014 - asn: 65535 - neighbor: 192.168.1.1 - bfd: enable - state: present - - - ansible.builtin.assert: *id002 - - - name: Check BFD enable idempotence - register: result - cisco.nxos.nxos_bgp_neighbor: *id014 - - - ansible.builtin.assert: *id004 - - - name: Configure BFD disable idempotence - register: result - cisco.nxos.nxos_bgp_neighbor: &id015 - asn: 65535 - neighbor: 192.168.1.1 - bfd: disable - state: present - - - ansible.builtin.assert: *id002 - - - name: Check BFD disable idempotence - register: result - cisco.nxos.nxos_bgp_neighbor: *id015 - - - ansible.builtin.assert: *id004 - always: - - name: "Teardown: disable features" - loop: - - bgp - - bfd - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp_neighbor sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - connection: local - register: test_cases - -- name: Collect CLI test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - connection: local - register: cli_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + cli_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases (connection=ansible.netcommon.network_cli) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - -- name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - connection: local - register: test_cases - -- name: Collect NX-API test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/nxapi" - patterns: "{{ testcase }}.yaml" - connection: local - register: nxapi_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + nxapi_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases (connection=ansible.netcommon.httpapi) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml deleted file mode 100644 index 12c31f7a2..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml +++ /dev/null @@ -1,117 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp_neighbor_af multisite sanity test - -- name: Set a fact for 'soft_reconfiguration_ina' - ansible.builtin.set_fact: - soft_reconfiguration_ina: always - when: imagetag is not search("D1|N1") - -- name: Disable 'feature bgp' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- name: Enable 'feature nv overlay' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nv overlay - state: enabled - -- name: Enable NV overlay EVPN - multisite - when: platform is search('N9K') - cisco.nxos.nxos_config: - lines: - - nv overlay evpn - -- name: Enable multisite border gateway - multisite - ignore_errors: true - register: multiout - cisco.nxos.nxos_config: - lines: - - evpn multisite border-gateway 10 - -- block: - - name: Configure EBGP - multisite - cisco.nxos.nxos_bgp_neighbor: - asn: 65535 - neighbor: 192.0.2.3 - remote_as: 2 - - - name: Configure BGP neighbor - multisite - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id001 - asn: 65535 - neighbor: 192.0.2.3 - afi: l2vpn - safi: evpn - send_community: standard - rewrite_evpn_rt_asn: true - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure BGP neighbor 1 - multisite - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id003 - asn: 65535 - neighbor: 192.0.2.3 - afi: l2vpn - safi: evpn - send_community: standard - rewrite_evpn_rt_asn: false - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id003 - - - ansible.builtin.assert: *id004 - - - name: Disable multisite border gateway - multisite - cisco.nxos.nxos_config: - lines: - - no evpn multisite border-gateway 10 - when: multiout is not search("Invalid command") - -- name: Disable 'feature bgp' - multisite - cisco.nxos.nxos_feature: - feature: bgp - state: disabled - -- name: Disable 'feature nv overlay' - multisite - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nv overlay - state: disabled - -- ansible.builtin.pause: - seconds: 5 - -- name: Remove NV overlay EVPN - multisite - when: platform is search('N9K') - cisco.nxos.nxos_config: - lines: - - no nv overlay evpn - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp_neighbor_af multisite sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml deleted file mode 100644 index 3b680ad59..000000000 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml +++ /dev/null @@ -1,295 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_bgp_neighbor_af sanity test - -- name: Set a fact for 'soft_reconfiguration_ina' - ansible.builtin.set_fact: - soft_reconfiguration_ina: always - when: imagetag is not search("D1|N1") - -- name: Disable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: &id013 - feature: bgp - state: disabled - -- name: Enable 'feature bgp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: bgp - state: enabled - -- block: - - name: Configure BGP neighbor address-family - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id001 - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - additional_paths_receive: enable - additional_paths_send: enable - advertise_map_exist: - - ansible_rm - - my_exist_map - allowas_in: true - default_originate: true - disable_peer_as_check: true - filter_list_in: my_filter_list_in - filter_list_out: my_filter_list_out - max_prefix_limit: 100 - max_prefix_threshold: 50 - max_prefix_warning: "true" - next_hop_self: true - next_hop_third_party: false - prefix_list_in: pfx_in - prefix_list_out: pfx_out - send_community: both - soft_reconfiguration_in: enable - suppress_inactive: true - unsuppress_map: unsup_map - weight: "30" - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure BGP neighbor address-family def1 - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id003 - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - additional_paths_receive: inherit - additional_paths_send: inherit - advertise_map_exist: default - allowas_in: false - default_originate: false - disable_peer_as_check: false - filter_list_in: default - filter_list_out: default - max_prefix_limit: default - max_prefix_threshold: default - max_prefix_warning: false - next_hop_self: false - next_hop_third_party: false - prefix_list_in: default - prefix_list_out: default - send_community: none - soft_reconfiguration_in: inherit - suppress_inactive: false - unsuppress_map: default - weight: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id003 - - - ansible.builtin.assert: *id004 - - - name: "Setup: remove BGP configuration" - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id005 - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id005 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor address-family - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id006 - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - allowas_in_max: "5" - advertise_map_non_exist: - - ansible_rm - - my_non_exist_map - default_originate_route_map: my_route_map - max_prefix_limit: 100 - max_prefix_interval: 30 - max_prefix_threshold: 50 - route_map_in: rm_in - route_map_out: rm_out - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id006 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor address-family def2 - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id007 - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - allowas_in_max: default - advertise_map_non_exist: default - default_originate_route_map: default - max_prefix_limit: default - max_prefix_interval: default - max_prefix_threshold: default - route_map_in: default - route_map_out: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id007 - - - ansible.builtin.assert: *id004 - - - name: "Setup: remove BGP configuration" - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id005 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id005 - - - ansible.builtin.assert: *id004 - - - name: Configure EBGP - cisco.nxos.nxos_bgp_neighbor: - asn: 65535 - vrf: blue - neighbor: 192.0.2.3 - remote_as: 2 - - - name: Configure BGP neighbor 3 - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id008 - asn: 65535 - vrf: blue - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - additional_paths_receive: disable - additional_paths_send: disable - as_override: "true" - send_community: standard - soft_reconfiguration_in: "{{soft_reconfiguration_ina|default(omit)}}" - soo: "3:3" - next_hop_third_party: true - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id008 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor def3 - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id009 - asn: 65535 - vrf: blue - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - additional_paths_receive: inherit - additional_paths_send: inherit - as_override: false - send_community: default - soo: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id009 - - - ansible.builtin.assert: *id004 - - - name: "Setup: remove BGP configuration" - register: result - cisco.nxos.nxos_bgp: &id012 - asn: 65535 - state: absent - - - ansible.builtin.assert: *id002 - - - name: Configure BGP neighbor AF route_reflector_client - cisco.nxos.nxos_bgp_neighbor: - asn: 65535 - neighbor: 192.0.2.2 - remote_as: 65535 - - - name: Configure BGP neighbor 4 - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id010 - asn: 65535 - neighbor: 192.0.2.2 - afi: ipv4 - safi: unicast - route_reflector_client: "true" - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id010 - - - ansible.builtin.assert: *id004 - - - name: Configure BGP neighbor def4 - register: result - cisco.nxos.nxos_bgp_neighbor_af: &id011 - asn: 65535 - neighbor: 192.0.2.2 - afi: ipv4 - safi: unicast - route_reflector_client: false - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_bgp_neighbor_af: *id011 - - - ansible.builtin.assert: *id004 - always: - - name: Cleanup BGP - ignore_errors: true - cisco.nxos.nxos_bgp: *id012 - - - name: Disable 'feature bgp' - cisco.nxos.nxos_feature: *id013 - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_bgp_neighbor_af sanity test diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/defaults/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/defaults/main.yaml new file mode 100644 index 000000000..871ea460c --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "[^_].*" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/meta/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/meta/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml index f6096901f..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml @@ -3,6 +3,7 @@ ansible.builtin.find: paths: "{{ role_path }}/tests/common" patterns: "{{ testcase }}.yaml" + use_regex: true connection: local register: test_cases @@ -22,11 +23,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/main.yaml new file mode 100644 index 000000000..026b6e477 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/main.yaml @@ -0,0 +1,26 @@ +--- +- name: Enable 'feature bgp' + cisco.nxos.nxos_feature: + feature: bgp + vars: + ansible_connection: ansible.netcommon.network_cli + +- name: Run the CLI and NX-API tests + block: + - name: Include the CLI tasks + ansible.builtin.include_tasks: cli.yaml + tags: + - cli + + - name: Include the NX-API tasks + ansible.builtin.include_tasks: nxapi.yaml + tags: + - nxapi + + always: + - name: Disable 'feature bgp' + cisco.nxos.nxos_feature: + feature: bgp + state: disabled + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml index b4ed55204..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml @@ -3,6 +3,7 @@ ansible.builtin.find: paths: "{{ role_path }}/tests/common" patterns: "{{ testcase }}.yaml" + use_regex: true connection: local register: test_cases @@ -22,11 +23,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/_populate_config.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/_populate_config.yaml new file mode 100644 index 000000000..2fe977e28 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/_populate_config.yaml @@ -0,0 +1,25 @@ +--- +- name: "Setup - 1" + cisco.nxos.nxos_config: + lines: + - router bgp 65536 + - template peer neighbor_tmplt_2 + - description Test_BGP_PEER_TEMPLATE_2 + - inherit peer-session psession1 + - timers 45 100 + - address-family ipv4 multicast + - advertise-map rmap1 exist-map emap1 + - as-override + - filter-list flist1 in + - filter-list flist2 out + - template peer neighbor_tmplt_1 + - bmp-activate-server 2 + - capability suppress 4-byte-as + - description Test_BGP_PEER_TEMPLATE_1 + - local-as 65536 + - remote-as 65001 + - address-family ipv4 unicast + - advertise-map rmap1 non-exist-map nemap1 + - advertisement-interval 60 + - disable-peer-as-check + match: none diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/_remove_config.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/_remove_config.yaml new file mode 100644 index 000000000..af7092576 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Remove pre-existing BGP configurations + cisco.nxos.nxos_config: + lines: + - no router bgp 65536 + ignore_errors: true + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/deleted.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/deleted.yaml new file mode 100644 index 000000000..ab2efb521 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/deleted.yaml @@ -0,0 +1,44 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bgp_templates deleted integration tests connection={{ ansible_connection}} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Delete BGP configs handled by this module + cisco.nxos.nxos_bgp_templates: &id001 + state: deleted + register: result + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - merged['after'] == result['before'] + + - ansible.builtin.debug: + msg: "{{ result['commands'] | symmetric_difference(deleted['commands']) }}" + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ result['commands'] | symmetric_difference(deleted['commands']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - deleted['after'] == result['after'] + + - name: Delete BGP configs handled by this module (idempotent) + register: result + cisco.nxos.nxos_bgp_templates: *id001 + + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + - result.commands|length == 0 + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/empty_config.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/empty_config.yaml new file mode 100644 index 000000000..f57679e8b --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bgp_templates empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bgp_templates: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bgp_templates: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bgp_templates: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bgp_templates: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bgp_templates: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- ansible.builtin.debug: + msg: END nxos_bgp_templates empty_config integration tests diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/fixtures/parsed.cfg b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/fixtures/parsed.cfg new file mode 100644 index 000000000..615f7fa21 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/fixtures/parsed.cfg @@ -0,0 +1,20 @@ +router bgp 65536 + template peer neighbor_tmplt_1 + bmp-activate-server 2 + capability suppress 4-byte-as + description Test_BGP_PEER_TEMPLATE_1 + local-as 65536 + remote-as 65001 + address-family ipv4 unicast + advertise-map rmap1 non-exist-map nemap1 + advertisement-interval 60 + disable-peer-as-check + template peer neighbor_tmplt_2 + description Test_BGP_PEER_TEMPLATE_2 + inherit peer-session psession1 + timers 45 100 + address-family ipv4 multicast + advertise-map rmap1 exist-map emap1 + as-override + filter-list flist1 in + filter-list flist2 out diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/gathered.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/gathered.yaml new file mode 100644 index 000000000..1cdf9a2f2 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/gathered.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: "START nxos_bgp_templates gathered integration tests" + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Gather BGP templates facts using gathered + register: result + cisco.nxos.nxos_bgp_templates: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: merged['after'] == result['gathered'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/merged.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/merged.yaml new file mode 100644 index 000000000..acacacd02 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/merged.yaml @@ -0,0 +1,72 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bgp_templates merged integration tests connection={{ ansible_connection}} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- block: + - name: Merge the provided configuration with the existing running configuration + cisco.nxos.nxos_bgp_templates: &id001 + config: + as_number: 65536 + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + route_map: rmap1 + non_exist_map: nemap1 + advertisement_interval: 60 + disable_peer_as_check: true + bmp_activate_server: 2 + capability: + suppress_4_byte_as: true + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65536 + remote_as: 65001 + + - name: neighbor_tmplt_2 + description: Test_BGP_PEER_TEMPLATE_2 + address_family: + - afi: ipv4 + safi: multicast + advertise_map: + route_map: rmap1 + exist_map: emap1 + as_override: true + filter_list: + inbound: flist1 + outbound: flist2 + inherit: + peer_session: psession1 + timers: + holdtime: 100 + keepalive: 45 + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ result['before'] == {} }}" + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + + - name: Assert that after dicts were correctly generated + ansible.builtin.assert: + that: + - merged['after'] == result['after'] + + - name: Merge the provided configuration with the existing running configuration (idempotent) + cisco.nxos.nxos_bgp_templates: *id001 + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + - result.commands|length == 0 + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/overridden.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/overridden.yaml new file mode 100644 index 000000000..c66b10284 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/overridden.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bgp_templates replaced integration tests connection={{ ansible_connection}} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Override BGP templates configuration with provided configuration + cisco.nxos.nxos_bgp_templates: &id001 + config: + as_number: 65536 + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + route_map: rmap1 + non_exist_map: nemap1 + advertisement_interval: 60 + disable_peer_as_check: true + inherit: + peer_session: psession1 + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65537 + state: overridden + register: result + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - overridden['after'] == result['after'] + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - merged['after'] == result['before'] + + - name: Override device configurations of listed OSPF processes with provided configurarions (idempotent) + register: result + cisco.nxos.nxos_bgp_templates: *id001 + + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + - result.commands|length == 0 + + - name: Assert that before dict is correctly generated + ansible.builtin.assert: + that: + - overridden['after'] == result['before'] + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/parsed.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/parsed.yaml new file mode 100644 index 000000000..0a04fa376 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/parsed.yaml @@ -0,0 +1,14 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bgp_templates parsed integration tests on connection={{ ansible_connection }} + +- name: Parse externally provided BGP templates configuration + register: result + cisco.nxos.nxos_bgp_templates: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that configuration was correctly parsed + ansible.builtin.assert: + that: + - merged['after'] == result['parsed'] diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/rendered.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/rendered.yaml new file mode 100644 index 000000000..411e8761f --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/rendered.yaml @@ -0,0 +1,59 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bgp_templates rendered integration tests on connection={{ ansible_connection }} + +- name: Render platform specific configuration lines with state rendered (without connecting to the device) + cisco.nxos.nxos_bgp_templates: + config: + as_number: 65536 + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + route_map: rmap1 + non_exist_map: nemap1 + advertisement_interval: 60 + disable_peer_as_check: true + bmp_activate_server: 2 + capability: + suppress_4_byte_as: true + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65536 + remote_as: 65001 + + - name: neighbor_tmplt_2 + description: Test_BGP_PEER_TEMPLATE_2 + address_family: + - afi: ipv4 + safi: multicast + advertise_map: + route_map: rmap1 + exist_map: emap1 + as_override: true + filter_list: + inbound: flist1 + outbound: flist2 + inherit: + peer_session: psession1 + timers: + holdtime: 100 + keepalive: 45 + state: rendered + register: result + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" + +- name: Gather BGP templates facts + cisco.nxos.nxos_bgp_templates: + state: gathered + register: result + +- name: Ensure that no configuration changes were made + ansible.builtin.assert: + that: + - result.gathered == {} diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/replaced.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/replaced.yaml new file mode 100644 index 000000000..73bd4b73f --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/tests/common/replaced.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bgp_templates replaced integration tests connection={{ ansible_connection}} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Replace BGP templates configuration with provided configuration + cisco.nxos.nxos_bgp_templates: &id001 + config: + as_number: 65536 + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + route_map: rmap1 + non_exist_map: nemap1 + advertisement_interval: 60 + disable_peer_as_check: true + inherit: + peer_session: psession1 + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65537 + state: replaced + register: result + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - replaced['after'] == result['after'] + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - merged['after'] == result['before'] + + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) + register: result + cisco.nxos.nxos_bgp_templates: *id001 + + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + - result.commands|length == 0 + + - name: Assert that before dict is correctly generated + ansible.builtin.assert: + that: + - replaced['after'] == result['before'] + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/vars/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/vars/main.yml new file mode 100644 index 000000000..77acf1516 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_bgp_templates/vars/main.yml @@ -0,0 +1,142 @@ +--- +merged: + commands: + - router bgp 65536 + - template peer neighbor_tmplt_2 + - description Test_BGP_PEER_TEMPLATE_2 + - inherit peer-session psession1 + - timers 45 100 + - address-family ipv4 multicast + - advertise-map rmap1 exist-map emap1 + - as-override + - filter-list flist1 in + - filter-list flist2 out + - template peer neighbor_tmplt_1 + - bmp-activate-server 2 + - capability suppress 4-byte-as + - description Test_BGP_PEER_TEMPLATE_1 + - local-as 65536 + - remote-as 65001 + - address-family ipv4 unicast + - advertise-map rmap1 non-exist-map nemap1 + - advertisement-interval 60 + - disable-peer-as-check + + after: + as_number: "65536" + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + non_exist_map: nemap1 + route_map: rmap1 + advertisement_interval: 60 + disable_peer_as_check: true + bmp_activate_server: 2 + capability: + suppress_4_byte_as: true + description: Test_BGP_PEER_TEMPLATE_1 + local_as: "65536" + remote_as: "65001" + + - name: neighbor_tmplt_2 + description: Test_BGP_PEER_TEMPLATE_2 + address_family: + - afi: ipv4 + safi: multicast + advertise_map: + exist_map: emap1 + route_map: rmap1 + as_override: true + filter_list: + inbound: flist1 + outbound: flist2 + inherit: + peer_session: psession1 + timers: + holdtime: 100 + keepalive: 45 + +replaced: + commands: + - router bgp 65536 + - template peer neighbor_tmplt_1 + - no bmp-activate-server 2 + - no capability suppress 4-byte-as + - inherit peer-session psession1 + - local-as 65537 + - no remote-as 65001 + + after: + as_number: "65536" + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + non_exist_map: nemap1 + route_map: rmap1 + advertisement_interval: 60 + disable_peer_as_check: true + description: Test_BGP_PEER_TEMPLATE_1 + inherit: + peer_session: psession1 + local_as: "65537" + + - name: neighbor_tmplt_2 + description: Test_BGP_PEER_TEMPLATE_2 + address_family: + - afi: ipv4 + safi: multicast + advertise_map: + exist_map: emap1 + route_map: rmap1 + as_override: true + filter_list: + inbound: flist1 + outbound: flist2 + inherit: + peer_session: psession1 + timers: + holdtime: 100 + keepalive: 45 + +overridden: + commands: + - router bgp 65536 + - template peer neighbor_tmplt_1 + - no bmp-activate-server 2 + - no capability suppress 4-byte-as + - inherit peer-session psession1 + - local-as 65537 + - no remote-as 65001 + - no template peer neighbor_tmplt_2 + + after: + as_number: "65536" + neighbor: + - name: neighbor_tmplt_1 + address_family: + - afi: ipv4 + safi: unicast + advertise_map: + non_exist_map: nemap1 + route_map: rmap1 + advertisement_interval: 60 + disable_peer_as_check: true + description: Test_BGP_PEER_TEMPLATE_1 + inherit: + peer_session: psession1 + local_as: "65537" + +deleted: + commands: + - router bgp 65536 + - no template peer neighbor_tmplt_1 + - no template peer neighbor_tmplt_2 + + after: + as_number: "65536" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tests/cli/sanity.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tests/cli/sanity.yaml index 74c777bd5..bb8a3db43 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tests/cli/sanity.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_command/tests/cli/sanity.yaml @@ -26,10 +26,11 @@ - name: Configure BGP defaults register: result - cisco.nxos.nxos_bgp: - asn: 65535 - router_id: 192.0.2.1 - state: present + cisco.nxos.nxos_bgp_global: + config: + as_number: 65535 + router_id: 192.0.2.1 + state: merged - ansible.builtin.assert: that: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli_config.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli_config.yaml index 4c960185d..79b7f90ab 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli_config.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/cli_config.yaml @@ -10,7 +10,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test case (connection=ansible.netcommon.network_cli) +- name: Run test case with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/redirection.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/redirection.yaml index 0ef757aef..dde1662ea 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/redirection.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tasks/redirection.yaml @@ -10,7 +10,7 @@ ansible.builtin.set_fact: test_items: "{{ shortname_test_cases.files | map(attribute='path') | list }}" -- name: Run test case (connection=ansible.netcommon.network_cli) +- name: Run test case with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/templates/basic/acl_config.j2 b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/templates/basic/acl_config.j2 new file mode 100644 index 000000000..ec03c24a2 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/templates/basic/acl_config.j2 @@ -0,0 +1,5 @@ +ip access-list test + 10 permit ip 192.0.2.1/32 any log + 20 permit ip 192.0.2.2/32 any log + 30 permit ip 192.0.2.3/32 any log + 40 permit ip 192.0.2.4/32 any log diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tests/cli/replace_block.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tests/cli/replace_block.yaml new file mode 100644 index 000000000..deb79b940 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_config/tests/cli/replace_block.yaml @@ -0,0 +1,35 @@ +--- +- ansible.builtin.debug: msg="START cli/replace_block.yaml on connection={{ ansible_connection }}" + +- name: "setup" + cisco.nxos.nxos_config: + lines: + - "no ip access-list test" + ignore_errors: true + +- name: "Populate nxos acls configuration with replace block and lines options" + register: result1 + cisco.nxos.nxos_config: + lines: "{{ lookup('template', 'basic/acl_config.j2') }}" + replace: block + +- ansible.builtin.assert: + that: + - result1.changed == true + +- name: "setup" + cisco.nxos.nxos_config: + lines: + - "no ip access-list test" + ignore_errors: true + +- name: "Populate acl configuration with replace block and src options" + register: result2 + cisco.nxos.nxos_config: + src: basic/acl_config.j2 + replace: block + +- ansible.builtin.assert: + that: + - result2.changed == true + - result1.commands == result2.commands diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_devicealias/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_devicealias/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_devicealias/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_devicealias/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index cce7c66a0..7aece91d1 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -18,6 +18,7 @@ - result.ansible_facts.ansible_net_filesystems is defined - result.ansible_facts.ansible_net_interfaces is defined - result.ansible_facts.ansible_net_config is defined + - result.ansible_facts.ansible_net_cpu_utilization is defined - result.ansible_facts.ansible_net_model is defined - result.ansible_facts.ansible_net_memfree_mb > 1 - result.ansible_facts.ansible_net_memtotal_mb > 1 @@ -26,16 +27,12 @@ register: result cisco.nxos.nxos_facts: available_network_resources: true - gather_network_resources: all - name: Assert that correct available_network_resources returned ansible.builtin.assert: that: - result.changed == false - - >- - {{ result['ansible_facts']['available_network_resources'] | - symmetric_difference(result['ansible_facts']['ansible_net_gather_network_resources']) | - length == 0 }} + - "{{ result['ansible_facts']['available_network_resources'] | symmetric_difference(available_network_resources) | length == 0 }}" - ansible.builtin.debug: msg: END connection={{ ansible_connection }}/all_facts.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/vars/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/vars/main.yml new file mode 100644 index 000000000..5965c4191 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_facts/vars/main.yml @@ -0,0 +1,30 @@ +--- +available_network_resources: + - acl_interfaces + - acls + - bfd_interfaces + - bgp_address_family + - bgp_global + - bgp_neighbor_address_family + - bgp_templates + - hostname + - hsrp_interfaces + - interfaces + - l2_interfaces + - l3_interfaces + - lacp + - lacp_interfaces + - lag_interfaces + - lldp_global + - lldp_interfaces + - logging_global + - ntp_global + - ospf_interfaces + - ospfv2 + - ospfv3 + - prefix_lists + - route_maps + - snmp_server + - static_routes + - telemetry + - vlans diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_feature/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/cli.yaml index 311e39414..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/cli.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml index 9aa0d8690..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml @@ -23,11 +23,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml index 555aa8358..acefd4a4c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml @@ -10,11 +10,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (ansible_connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml index 476745353..df97b28bc 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml @@ -10,11 +10,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (ansible_connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tests/common/overridden.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tests/common/overridden.yaml new file mode 100644 index 000000000..d6eb4fb93 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp/tests/common/overridden.yaml @@ -0,0 +1,104 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_lacp overridden integration tests connection={{ ansible_connection }} + +- name: Enable 'feature lacp' + cisco.nxos.nxos_feature: + feature: lacp + +- name: Set a fact for 'mac1' and 'mac2' + ansible.builtin.set_fact: + mac1: lacp system-mac 00c1.4c00.bd20 role primary + mac2: + address: 00c1.4c00.bd15 + role: secondary + when: platform is search('N9K') and imagetag is not search('I[2-6]') + +- block: + - name: Setup1 + cisco.nxos.nxos_config: + lines: lacp system-priority 11 + + - name: Setup2 + cisco.nxos.nxos_config: + lines: "{{ mac1|default(omit) }}" + + - name: Gather lacp facts + cisco.nxos.nxos_facts: &id001 + gather_subset: + - "!all" + - "!min" + gather_network_resources: lacp + + - name: Run overridden test + register: result + cisco.nxos.nxos_lacp: &id002 + config: + system: + priority: 12 + mac: "{{ mac2|default(omit) }}" + state: overridden + + - ansible.builtin.assert: + that: + - ansible_facts.network_resources.lacp == result.before + - result.changed == true + - result.commands|length == 2 + - "'no lacp system-priority' in result.commands" + - "'lacp system-priority 12' in result.commands" + when: platform is not search('N9K') + + - ansible.builtin.assert: + that: + - ansible_facts.network_resources.lacp == result.before + - result.changed == true + - "'no lacp system-priority' in result.commands" + - "'no lacp system-mac' in result.commands" + - "'lacp system-priority 12' in result.commands" + - "'lacp system-mac 00c1.4c00.bd15 role secondary' in result.commands" + - result.commands|length == 4 + when: platform is search('N9K') and imagetag is not search('I[2-6]') + + - name: Gather lacp interfaces post facts + cisco.nxos.nxos_facts: *id001 + + - ansible.builtin.assert: + that: + - ansible_facts.network_resources.lacp == result.after + when: platform is search('N9K') and imagetag is not search('I[2-6]') + + - name: Idempotence - overridden + register: result + cisco.nxos.nxos_lacp: *id002 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Setup3 + cisco.nxos.nxos_config: + lines: "{{ mac1|default(omit) }}" + + - name: overridden + register: result + when: platform is search('N9K') and imagetag is not search('I[2-6]') + cisco.nxos.nxos_lacp: + config: + system: + priority: 1 + state: overridden + + - ansible.builtin.assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'no lacp system-mac' in result.commands" + - "'no lacp system-priority' in result.commands" + - "'lacp system-priority 1' in result.commands" + when: platform is search('N9K') and imagetag is not search('I[2-6]') + always: + - name: Teardown + cisco.nxos.nxos_feature: + feature: lacp + state: disabled diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml index 96b74273d..3a8e78976 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml @@ -35,9 +35,9 @@ - name: port-channel10 members: - member: "{{ test_int1 }}" - - member: "{{ test_int2 }}" - mode: true + mode: on # noqa yaml[truthy] + force: true state: merged - ansible.builtin.assert: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml index f2bafafb2..92c357f1d 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml @@ -92,7 +92,7 @@ that: - "result.changed == True" - "'interface Ethernet1/9' in result.commands" - - "'channel-group 20 force mode active' in result.commands" + - "'channel-group 20 force mode active' in result.commands" always: - name: Teardown diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml index 3bff52013..bb0e65506 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml index e0ebc3f54..59a0777c5 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tests/common/overridden.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tests/common/overridden.yml new file mode 100644 index 000000000..58c41c1f8 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_global/tests/common/overridden.yml @@ -0,0 +1,92 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_lldp_global overridden integration tests connection = {{ansible_connection}} + +- block: + - name: Set a fact for 'port_id' and 'tlv_power_mgmt' + ansible.builtin.set_fact: + port_id: 1 + tlv_power_mgmt: + power_management: false + when: platform is not search('N[567]K') and imagetag is not search("I[2345]") + + - name: Feature off to cleanup lldp + cisco.nxos.nxos_feature: &id002 + feature: lldp + state: disabled + + - name: Enable lldp feature + cisco.nxos.nxos_feature: + feature: lldp + state: enabled + + - name: Setup + cisco.nxos.nxos_config: + lines: + - "lldp holdtime 125" + - "lldp tlv-select system-name" + - "no lldp tlv-select port-vlan" + + - name: Setup2 + when: port_id is defined + cisco.nxos.nxos_config: + lines: + - "lldp portid-subtype 1" + - "no lldp tlv-select power-management" + + - name: Run overridden tests + register: result + cisco.nxos.nxos_lldp_global: &id001 + config: + holdtime: 125 + timer: 35 + tlv_select: + system: + name: false + description: false + port: + vlan: false + dcbxp: false + state: overridden + + - ansible.builtin.assert: + that: + - result.changed == true + - "'lldp timer 35' in result.commands" + - "'no lldp tlv-select system-name' in result.commands" + - "'no lldp tlv-select system-description' in result.commands" + - "'no lldp tlv-select dcbxp' in result.commands" + + - ansible.builtin.assert: + that: + - "'no lldp portid-subtype 1' in result.commands" + when: port_id is defined + + - ansible.builtin.assert: + that: + - "'lldp tlv-select power-management' in result.commands" + when: tlv_power_mgmt is defined + + - name: Gather lldp_global post facts + cisco.nxos.nxos_facts: + gather_subset: + - "!all" + - "!min" + gather_network_resources: lldp_global + + - ansible.builtin.assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + + - name: Idempotence - overridden + register: result + cisco.nxos.nxos_lldp_global: *id001 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + always: + - name: Teardown + cisco.nxos.nxos_feature: *id002 + when: platform is not search('N35') diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml index c34726ef5..3e5e72a07 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml index e0ebc3f54..59a0777c5 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml index 25cdd4904..0b2e4f778 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml @@ -22,20 +22,18 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" -- name: Run test cases (connection=local) + +- name: Run test cases with connection local ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: local - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml index 57e91e216..cdee9a584 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: @@ -30,4 +30,3 @@ tags: nxapi_httpapi vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/cli.yaml index 1fa8d4e11..b335e711c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/cli.yaml @@ -28,14 +28,13 @@ transport: cli authorize: true -- name: Run test cases (connection=network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: network_cli - connection: "{{ cli }}" # Temporarily disabling connection=local tests for CI issues # - name: run test cases (connection=local) @@ -47,9 +46,8 @@ # loop_control: # loop_var: test_case_to_run -- name: Run test cases (connection=network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ role_path }}/tests/common/caching.yaml" vars: ansible_connection: ansible.netcommon.network_cli ansible_network_single_user_mode: true - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml index f3a565f93..52aa1a100 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml @@ -22,14 +22,13 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: httpapi - connection: "{{ nxapi }}" # Temporarily disabling connection=local tests for CI issues # - name: run test cases (connection=local) # ansible.builtin.include_tasks: "{{ test_case_to_run }} diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index cb885dee9..b46cbf998 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -6,7 +6,7 @@ - name: Grep admin user SNMP localized key ansible.builtin.set_fact: - # noqa var-spacing + # noqa jinja[spacing] admin_snmp_passwd: "{{ result['stdout'][0] | regex_search('snmp-server user admin network-admin auth (md5|sha|sha-256) (\\S+)', '\\2') }}" - name: Find admin user SNMP localized key @@ -15,7 +15,7 @@ - name: Grep admin user SNMP localized key (second) ansible.builtin.set_fact: - admin_snmp_passwd_2: "{{ result['stdout'][0] | regex_search('snmp-server user admin auth (md5|sha|sha-256) (\\S+)', '\\2') }}" # noqa var-spacing + admin_snmp_passwd_2: "{{ result['stdout'][0] | regex_search('snmp-server user admin auth (md5|sha|sha-256) (\\S+)', '\\2') }}" # noqa jinja[spacing] - name: Find admin user SNMP localized key (second) ansible.builtin.set_fact: @@ -23,7 +23,7 @@ - name: Grep admin user SNMP engineid (second) ansible.builtin.set_fact: - # noqa var-spacing + # # noqa jinja[spacing] admin_snmp_engineid_2: "{{ result['stdout'][0] | regex_search('admin auth (md5|sha|sha-256) (\\S+) priv (\\S+) localizedkey engineID (\\S+)', '\\4') }}" - name: Find admin user SNMP engineid (second) diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/cli.yaml index e22d5c622..fd8d12e79 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/main.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/main.yaml index 159ffa2b9..10be7ff19 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/main.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tasks/main.yaml @@ -1,4 +1,19 @@ --- +- name: Fetch vrf confext management output + cisco.nxos.nxos_command: + commands: show running-config | section 'vrf context management' + register: vrf_conf + +- name: Parse the config to structured data + cisco.nxos.nxos_static_routes: + state: parsed + running_config: "{{ vrf_conf['stdout'][0] }}" + register: vrf_mgmt + +- name: Setting booleans facts of management vrf + ansible.builtin.set_fact: + var_vrf_mgmt: "{{ vrf_mgmt['parsed'][0] }}" + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml index 67c89cc33..fbf316b41 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml @@ -46,36 +46,5 @@ - "'no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1' in result.commands" - "result.commands | length == 3" - - ansible.builtin.include_tasks: _remove_config.yaml - - - ansible.builtin.include_tasks: _populate_config.yaml - - - name: Deleted (all routes) - cisco.nxos.nxos_static_routes: &deleted - state: deleted - register: result - - - name: Gather static_routes post facts - cisco.nxos.nxos_facts: *facts - - - ansible.builtin.assert: - that: - - "'vrf context trial_vrf' in result.commands" - - "'no ip route 192.0.2.64/28 192.0.2.22 tag 4' in result.commands" - - "'no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1' in result.commands" - - "'configure terminal' in result.commands" - - "'no ip route 192.0.2.16/28 192.0.2.24 name new_route' in result.commands" - - "'no ip route 192.0.2.80/28 192.0.2.26 tag 12' in result.commands" - - "result.changed == true" - - "result.commands | length == 6" - - - name: Idempotence - deleted - cisco.nxos.nxos_static_routes: *deleted - register: result - - - ansible.builtin.assert: - that: - - "result.changed == false" - always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/merged.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/merged.yml index 6ba0a1b6a..11b748793 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/merged.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/merged.yml @@ -18,11 +18,9 @@ next_hops: - forward_router_address: 192.0.2.22 tag: 4 - - forward_router_address: 192.0.2.23 route_name: merged_route admin_distance: 1 - - address_families: - afi: ipv4 routes: @@ -30,7 +28,6 @@ next_hops: - forward_router_address: 192.0.2.24 route_name: new_route - - dest: 192.0.2.80/28 next_hops: - forward_router_address: 192.0.2.26 @@ -41,13 +38,12 @@ - ansible.builtin.assert: that: - "result.changed == true" - - "'configure terminal' in result.commands" - "'ip route 192.0.2.16/28 192.0.2.24 name new_route' in result.commands" - "'ip route 192.0.2.80/28 192.0.2.26 tag 12' in result.commands" - "'vrf context trial_vrf' in result.commands" - "'ip route 192.0.2.64/28 192.0.2.22 tag 4' in result.commands" - "'ip route 192.0.2.64/28 192.0.2.23 name merged_route 1' in result.commands" - - "result.commands | length == 6" + - "result.commands | length == 5" - name: Idempotence - merged cisco.nxos.nxos_static_routes: *merged diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml index ae03e947f..e90c3cfbb 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml @@ -26,12 +26,11 @@ - forward_router_address: 192.0.2.23 route_name: overridden_route1 admin_distance: 3 - - forward_router_address: 192.0.2.45 route_name: overridden_route2 dest_vrf: destinationVRF interface: "{{ nxos_int2 }}" - + - "{{ var_vrf_mgmt }}" state: overridden register: result @@ -43,10 +42,9 @@ - "'no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1' in result.commands" - "'ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3' in result.commands" - "'ip route 192.0.2.16/28 {{ nxos_int2 }} 192.0.2.45 vrf destinationVRF name overridden_route2' in result.commands" - - "'configure terminal' in result.commands" - "'no ip route 192.0.2.16/28 192.0.2.24 name new_route' in result.commands" - "'no ip route 192.0.2.80/28 192.0.2.26 tag 12' in result.commands" - - "result.commands | length == 8" + - "result.commands | length == 7" - name: Idempotence - overridden cisco.nxos.nxos_static_routes: *overridden diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml index 32cd5bd83..8590c4e3f 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: "Start nxos_static_routes parsed tests connection={{ ansible_connection }}" -- name: Parsed +- name: Parsed test cisco.nxos.nxos_static_routes: &parsed running_config: | ip route 192.0.2.16/28 192.0.2.24 name new_route @@ -13,14 +13,8 @@ state: parsed register: result -- ansible.builtin.assert: +- name: Assert parsed test + ansible.builtin.assert: that: - "result.changed == false" - "result.parsed == parsed" - -- name: Idempotence - parsed - cisco.nxos.nxos_static_routes: *parsed - register: result - -- ansible.builtin.assert: - that: "result.changed == false" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml index 2348a64b6..99581bb11 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml @@ -14,7 +14,6 @@ - forward_router_address: 2001:db8::1001 route_name: rendered_route admin_distance: 3 - - address_families: - afi: ipv4 routes: @@ -22,7 +21,6 @@ next_hops: - forward_router_address: 192.0.2.24 route_name: new_route - - dest: 192.0.2.80/28 next_hops: - forward_router_address: 192.0.2.26 @@ -33,12 +31,11 @@ - ansible.builtin.assert: that: - "result.changed == false" - - "'configure terminal' in result.rendered" - "'ip route 192.0.2.16/28 192.0.2.24 name new_route' in result.rendered" - "'ip route 192.0.2.80/28 192.0.2.26 tag 12' in result.rendered" - "'vrf context trial_vrf' in result.rendered" - "'ipv6 route 2001:db8:12::/32 2001:db8::1001 name rendered_route 3' in result.rendered" - - "result.rendered | length == 5" + - "result.rendered | length == 4" - name: Idempotence - rendered nxos_static_routes: *rendered diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml index 73c122198..ca61c48e5 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml @@ -23,7 +23,6 @@ - forward_router_address: 192.0.2.23 route_name: replaced_route1 admin_distance: 3 - - forward_router_address: 192.0.2.45 route_name: replaced_route2 dest_vrf: destinationVRF @@ -34,7 +33,6 @@ - ansible.builtin.assert: that: - "result.changed == true" - - "'configure terminal' in result.commands" - "'no ip route 192.0.2.16/28 192.0.2.24 name new_route' in result.commands" - "'ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3' in result.commands" - "'ip route 192.0.2.16/28 {{ nxos_int2 }} 192.0.2.45 vrf destinationVRF name replaced_route2' in result.commands" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml index 1ee36a936..24b9fe9cf 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml @@ -16,11 +16,9 @@ - forward_router_address: 192.0.2.32 route_name: test_route1 tag: 14 - - forward_router_address: 192.0.2.48 route_name: test_route2 admin_distance: 2 - - vrf: trial_vrf address_families: - afi: ipv4 @@ -51,6 +49,7 @@ - forward_router_address: 192.0.2.55 tag: 1 admin_distance: 1 + - "{{ var_vrf_mgmt }}" state: overridden register: result @@ -58,13 +57,12 @@ ansible.builtin.assert: that: - "result.changed == true" - - "'configure terminal' in result.commands" - "'no ip route 192.0.2.36/30 192.0.2.32 name test_route1 tag 14' in result.commands" - "'no ip route 192.0.2.36/30 192.0.2.48 name test_route2 2'" - "'ip route 192.0.2.44/30 192.0.2.55 tag 1 1' in result.commands" - "'vrf context trial_vrf' in result.commands" - "'no ip route 192.0.2.32/30 192.0.2.105 vrf test_dest_vrf' in result.commands" - - "result.commands | length == 6" + - "result.commands | length == 5" - name: Revert back to base configuration cisco.nxos.nxos_static_routes: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/vars/main.yml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/vars/main.yml index 958773252..82b180899 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/vars/main.yml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_static_routes/vars/main.yml @@ -1,24 +1,24 @@ --- -"parsed": - - "address_families": - - "afi": "ipv4" - "routes": - - "dest": "192.0.2.64/28" - "next_hops": - - "forward_router_address": "192.0.2.22" - "tag": 4 - - "admin_distance": 1 - "forward_router_address": "192.0.2.23" - "route_name": "merged_route" - "vrf": "trial_vrf" - - "address_families": - - "afi": "ipv4" - "routes": - - "dest": "192.0.2.16/28" - "next_hops": - - "forward_router_address": "192.0.2.24" - "route_name": "new_route" - - "dest": "192.0.2.80/28" - "next_hops": - - "forward_router_address": "192.0.2.26" - "tag": 12 +parsed: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/28 + next_hops: + - forward_router_address: 192.0.2.24 + route_name: new_route + - dest: 192.0.2.80/28 + next_hops: + - forward_router_address: 192.0.2.26 + tag: 12 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.64/28 + next_hops: + - forward_router_address: 192.0.2.22 + tag: 4 + - admin_distance: 1 + forward_router_address: 192.0.2.23 + route_name: merged_route + vrf: trial_vrf diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_system/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/cli.yaml index 311e39414..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/cli.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml @@ -22,7 +22,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_user/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/cli.yaml @@ -23,7 +23,7 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml index f6096901f..988ef2894 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml index f6096901f..988ef2894 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vsan/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vsan/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vsan/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vsan/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml index b4ed55204..6a7129481 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.httpapi) +- name: Run test cases with connection httpapi ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - connection: "{{ nxapi }}" diff --git a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/ansible_collections/cisco/nxos/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml +++ b/ansible_collections/cisco/nxos/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml @@ -22,11 +22,10 @@ ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test cases with connection network_cli ansible.builtin.include_tasks: "{{ test_case_to_run }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.network_cli - connection: "{{ cli }}" diff --git a/ansible_collections/cisco/nxos/tests/sanity/ignore-2.17.txt b/ansible_collections/cisco/nxos/tests/sanity/ignore-2.17.txt new file mode 100644 index 000000000..46cfbc643 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/sanity/ignore-2.17.txt @@ -0,0 +1 @@ +plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` diff --git a/ansible_collections/cisco/nxos/tests/sanity/ignore-2.9.txt b/ansible_collections/cisco/nxos/tests/sanity/ignore-2.9.txt index 245bf89fc..ada896a7b 100644 --- a/ansible_collections/cisco/nxos/tests/sanity/ignore-2.9.txt +++ b/ansible_collections/cisco/nxos/tests/sanity/ignore-2.9.txt @@ -1,14 +1,6 @@ plugins/modules/nxos_logging.py validate-modules:deprecation-mismatch # 2.9 expects METADATA plugins/modules/nxos_logging.py validate-modules:invalid-documentation # removed_at_date not plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` -plugins/modules/nxos_bgp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_bgp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_bgp_neighbor.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_bgp_neighbor.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_bgp_af.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_bgp_af.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_bgp_neighbor_af.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_bgp_neighbor_af.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict plugins/modules/nxos_ntp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA plugins/modules/nxos_ntp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict plugins/modules/nxos_ntp_auth.py validate-modules:deprecation-mismatch # 2.9 expects METADATA diff --git a/ansible_collections/cisco/nxos/tests/unit/mock/loader.py b/ansible_collections/cisco/nxos/tests/unit/mock/loader.py index ebff16f63..0fc53edcd 100644 --- a/ansible_collections/cisco/nxos/tests/unit/mock/loader.py +++ b/ansible_collections/cisco/nxos/tests/unit/mock/loader.py @@ -31,7 +31,7 @@ from ansible.parsing.dataloader import DataLoader class DictDataLoader(DataLoader): def __init__(self, file_mapping=None): file_mapping = {} if file_mapping is None else file_mapping - assert type(file_mapping) == dict + assert isinstance(file_mapping, dict) super(DictDataLoader, self).__init__() diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/__init__.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/__init__.py +++ /dev/null diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_acls.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_acls.py index 6436e065b..b7c0e8663 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -105,7 +105,9 @@ class TestNxosAclsModule(TestNxosModule): source=dict(prefix="2002:1:1:1::/64"), sequence=30, protocol="icmp", - protocol_options=dict(icmp=dict(echo_request=True)), + protocol_options=dict( + icmp=dict(echo_request=True), + ), ), ], ), @@ -421,7 +423,11 @@ class TestNxosAclsModule(TestNxosModule): "10 permit sctp any any", ] result = self.execute_module(changed=False) - self.assertEqual(sorted(result["rendered"]), sorted(commands), result["rendered"]) + self.assertEqual( + sorted(result["rendered"]), + sorted(commands), + result["rendered"], + ) def test_nxos_acls_parsed(self): set_module_args( @@ -631,6 +637,7 @@ class TestNxosAclsModule(TestNxosModule): """\ ip access-list TEST_RESEQUENCE 10 permit ip 10.0.0.0/24 any + 11 permit tcp 1.1.1.1/32 range 7111 9111 192.168.0.0/24 established 20 deny tcp any eq ftp-data any eq domain 25 permit icmp any any echo-reply 27 permit icmp any any port-unreachable @@ -740,6 +747,19 @@ class TestNxosAclsModule(TestNxosModule): "destination": {"any": True}, }, { + "sequence": 11, + "grant": "permit", + "protocol": "tcp", + "protocol_options": {"tcp": {"established": True}}, + "source": { + "host": "1.1.1.1", + "port_protocol": { + "range": {"end": "9111", "start": "7111"}, + }, + }, + "destination": {"prefix": "192.168.0.0/24"}, + }, + { "sequence": 20, "grant": "deny", "protocol": "tcp", @@ -853,3 +873,90 @@ class TestNxosAclsModule(TestNxosModule): ] result = self.execute_module(changed=True) self.assertEqual(result["commands"], commands) + + def test_nxos_acls_ranges(self): + self.execute_show_command.return_value = dedent( + """\ + ip access-list acl1 + 10 permit tcp any any range ftp-data ftp + 20 permit tcp any range ftp-data ftp any range telnet time + 30 permit tcp any range ftp-data ftp any + """, + ) + set_module_args( + dict( + state="gathered", + ), + ) + + gathered = [ + { + "acls": [ + { + "name": "acl1", + "aces": [ + { + "sequence": 10, + "grant": "permit", + "protocol": "tcp", + "source": { + "any": True, + }, + "destination": { + "any": True, + "port_protocol": { + "range": { + "start": "ftp-data", + "end": "ftp", + }, + }, + }, + }, + { + "sequence": 20, + "grant": "permit", + "protocol": "tcp", + "source": { + "any": True, + "port_protocol": { + "range": { + "start": "ftp-data", + "end": "ftp", + }, + }, + }, + "destination": { + "any": True, + "port_protocol": { + "range": { + "start": "telnet", + "end": "time", + }, + }, + }, + }, + { + "sequence": 30, + "grant": "permit", + "protocol": "tcp", + "source": { + "any": True, + "port_protocol": { + "range": { + "start": "ftp-data", + "end": "ftp", + }, + }, + }, + "destination": { + "any": True, + }, + }, + ], + }, + ], + "afi": "ipv4", + }, + ] + result = self.execute_module(changed=False) + self.assertEqual(result["gathered"], gathered) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp.py deleted file mode 100644 index 9c57817ca..000000000 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp.py +++ /dev/null @@ -1,150 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosBgpModule(TestNxosModule): - module = nxos_bgp - - def setUp(self): - super(TestNxosBgpModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosBgpModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture("nxos_bgp", "config.cfg") - self.load_config.return_value = [] - - def test_nxos_bgp(self): - set_module_args(dict(asn=65535, router_id="192.0.2.1")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["router bgp 65535", "router-id 192.0.2.1"]) - - def test_nxos_bgp_change_nothing(self): - set_module_args(dict(asn=65535, router_id="192.168.1.1")) - self.execute_module(changed=False) - - def test_nxos_bgp_wrong_asn(self): - set_module_args(dict(asn=10, router_id="192.168.1.1")) - result = self.execute_module(failed=True) - self.assertEqual(result["msg"], "Another BGP ASN already exists.") - - def test_nxos_bgp_remove(self): - set_module_args(dict(asn=65535, state="absent")) - self.execute_module(changed=True, commands=["no router bgp 65535"]) - - def test_nxos_bgp_remove_vrf(self): - set_module_args(dict(asn=65535, vrf="test2", state="absent")) - self.execute_module(changed=True, commands=["router bgp 65535", "no vrf test2"]) - - def test_nxos_bgp_remove_nonexistant_vrf(self): - set_module_args(dict(asn=65535, vrf="foo", state="absent")) - self.execute_module(changed=False) - - def test_nxos_bgp_remove_wrong_asn(self): - set_module_args(dict(asn=10, state="absent")) - self.execute_module(changed=False) - - def test_nxos_bgp_vrf(self): - set_module_args(dict(asn=65535, vrf="test", router_id="192.0.2.1")) - result = self.execute_module( - changed=True, - commands=["router bgp 65535", "vrf test", "router-id 192.0.2.1"], - ) - self.assertEqual(result["warnings"], ["VRF test doesn't exist."]) - - def test_nxos_bgp_global_param(self): - set_module_args(dict(asn=65535, shutdown=True)) - self.execute_module(changed=True, commands=["router bgp 65535", "shutdown"]) - - def test_nxos_bgp_global_param_outside_default(self): - set_module_args(dict(asn=65535, vrf="test", shutdown=True)) - result = self.execute_module(failed=True) - self.assertEqual( - result["msg"], - 'Global params can be modified only under "default" VRF.', - ) - - def test_nxos_bgp_default_value(self): - set_module_args(dict(asn=65535, graceful_restart_timers_restart="default")) - self.execute_module( - changed=True, - commands=["router bgp 65535", "graceful-restart restart-time 120"], - ) - - -class TestNxosBgp32BitsAS(TestNxosModule): - module = nxos_bgp - - def setUp(self): - super(TestNxosBgp32BitsAS, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosBgp32BitsAS, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture("nxos_bgp", "config_32_bits_as.cfg") - self.load_config.return_value = [] - - def test_nxos_bgp_change_nothing(self): - set_module_args(dict(asn="65535.65535", router_id="192.168.1.1")) - self.execute_module(changed=False) - - def test_nxos_bgp_wrong_asn(self): - set_module_args(dict(asn="65535.10", router_id="192.168.1.1")) - result = self.execute_module(failed=True) - self.assertEqual(result["msg"], "Another BGP ASN already exists.") - - def test_nxos_bgp_remove(self): - set_module_args(dict(asn="65535.65535", state="absent")) - self.execute_module(changed=True, commands=["no router bgp 65535.65535"]) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_af.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_af.py deleted file mode 100644 index a72095c8f..000000000 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_af.py +++ /dev/null @@ -1,175 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_af -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosBgpAfModule(TestNxosModule): - module = nxos_bgp_af - - def setUp(self): - super(TestNxosBgpAfModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_af.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_af.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosBgpAfModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture("nxos_bgp", "config.cfg") - self.load_config.return_value = None - - def test_nxos_bgp_af(self): - set_module_args(dict(asn=65535, afi="ipv4", safi="unicast")) - self.execute_module( - changed=True, - sort=False, - commands=["router bgp 65535", "address-family ipv4 unicast"], - ) - - def test_nxos_bgp_af_vrf(self): - set_module_args(dict(asn=65535, vrf="test", afi="ipv4", safi="unicast")) - self.execute_module( - changed=True, - sort=False, - commands=[ - "router bgp 65535", - "vrf test", - "address-family ipv4 unicast", - ], - ) - - def test_nxos_bgp_af_vrf_exists(self): - set_module_args(dict(asn=65535, vrf="test2", afi="ipv4", safi="unicast")) - self.execute_module(changed=False, commands=[]) - - def test_nxos_bgp_af_dampening_routemap(self): - set_module_args( - dict( - asn=65535, - afi="ipv4", - safi="unicast", - dampening_routemap="route-map-a", - ), - ) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "address-family ipv4 unicast", - "dampening route-map route-map-a", - ], - ) - - def test_nxos_bgp_af_dampening_manual(self): - set_module_args( - dict( - asn=65535, - afi="ipv4", - safi="unicast", - dampening_half_time=5, - dampening_suppress_time=2000, - dampening_reuse_time=1900, - dampening_max_suppress_time=10, - ), - ) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "address-family ipv4 unicast", - "dampening 5 1900 2000 10", - ], - ) - - def test_nxos_bgp_af_dampening_mix(self): - set_module_args( - dict( - asn=65535, - afi="ipv4", - safi="unicast", - dampening_routemap="route-map-a", - dampening_half_time=5, - dampening_suppress_time=2000, - dampening_reuse_time=1900, - dampening_max_suppress_time=10, - ), - ) - result = self.execute_module(failed=True) - self.assertEqual( - result["msg"], - "parameters are mutually exclusive: dampening_routemap|dampening_half_time, " - "dampening_routemap|dampening_suppress_time, dampening_routemap|dampening_reuse_time, " - "dampening_routemap|dampening_max_suppress_time", - ) - - def test_nxos_bgp_af_client(self): - set_module_args(dict(asn=65535, afi="ipv4", safi="unicast", client_to_client=False)) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "address-family ipv4 unicast", - "no client-to-client reflection", - ], - ) - - def test_nxos_bgp_af_retain_route_target(self): - set_module_args(dict(asn=65535, afi="l2vpn", safi="evpn", retain_route_target="abc")) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "address-family l2vpn evpn", - "retain route-target route-map abc", - ], - ) - - def test_nxos_bgp_af_retain_route_target_all(self): - set_module_args(dict(asn=65535, afi="l2vpn", safi="evpn", retain_route_target="all")) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "address-family l2vpn evpn", - "retain route-target all", - ], - ) - - def test_nxos_bgp_af_retain_route_target_exists(self): - set_module_args(dict(asn=65535, afi="l2vpn", safi="evpn", retain_route_target="xyz")) - self.execute_module(changed=False, commands=[]) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index c2b2d5db2..22c9378eb 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -89,6 +89,11 @@ class TestNxosBgpGlobalModule(TestNxosModule): remote_as="65537", password=dict(encryption=7, key="12090404011C03162E"), ), + dict( + neighbor_address="2001:4000:4000:fff1::/64", + remote_as_route_map="rmap1", + description="TEST_NBR", + ), ], vrfs=[ dict( @@ -107,6 +112,11 @@ class TestNxosBgpGlobalModule(TestNxosModule): key="13D4D3549493D2877B1DC116EE27A6BE", ), ), + dict( + neighbor_address="2001:4000:5000:fff1::/64", + remote_as_route_map="rmap2", + description="TEST_NBR_2", + ), ], ), dict( @@ -134,6 +144,8 @@ class TestNxosBgpGlobalModule(TestNxosModule): "neighbor 198.51.100.21", "remote-as 65537", "password 7 12090404011C03162E", + "neighbor 2001:4000:4000:fff1::/64 remote-as route-map rmap1", + "description TEST_NBR", "vrf site-1", "local-as 200", "log-neighbor-changes", @@ -143,6 +155,8 @@ class TestNxosBgpGlobalModule(TestNxosModule): "description site-1-nbr-1", "password 3 13D4D3549493D2877B1DC116EE27A6BE", "timers 5 15", + "neighbor 2001:4000:5000:fff1::/64 remote-as route-map rmap2", + "description TEST_NBR_2", "vrf site-2", "local-as 300", "log-neighbor-changes", @@ -308,6 +322,8 @@ class TestNxosBgpGlobalModule(TestNxosModule): neighbor 198.51.100.21 remote-as 65537 password 7 12090404011C03162E + neighbor 2001:4000:4000:fff1::/64 remote-as route-map rmap1 + description TEST_NBR vrf site-1 local-as 200 log-neighbor-changes @@ -344,6 +360,11 @@ class TestNxosBgpGlobalModule(TestNxosModule): remote_as="65537", password=dict(encryption=7, key="12090404011C03162E"), ), + dict( + neighbor_address="2001:4000:4000:fff1::/64", + remote_as_route_map="rmap1", + description="TEST_NBR", + ), ], vrfs=[ dict( @@ -465,6 +486,93 @@ class TestNxosBgpGlobalModule(TestNxosModule): result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) + def test_nxos_bgp_global_overridden(self): + run_cfg = dedent( + """\ + router bgp 65536 + log-neighbor-changes + maxas-limit 20 + router-id 198.51.100.2 + neighbor 198.51.100.20 + remote-as 65537 + affinity-group 161 + description NBR-1 + shutdown + low-memory exempt + neighbor 198.51.100.21 + remote-as 65537 + password 7 12090404011C03162E + vrf site-1 + local-as 200 + log-neighbor-changes + neighbor 192.0.2.10 + affinity-group 170 + remote-as 65538 + description site-1-nbr-1 + password 3 13D4D3549493D2877B1DC116EE27A6BE + vrf site-2 + local-as 300 + log-neighbor-changes + neighbor-down fib-accelerate + """, + ) + self.get_config.return_value = run_cfg + self.cfg_get_config.return_value = run_cfg + + set_module_args( + dict( + config=dict( + as_number="65536", + router_id="198.51.100.212", + log_neighbor_changes=True, + maxas_limit=20, + neighbors=[ + dict( + neighbor_address="198.51.100.20", + neighbor_affinity_group=dict(group_id=161), + remote_as="65537", + description="NBR-1", + low_memory=dict(exempt=True), + ), + ], + vrfs=[ + dict( + vrf="site-1", + local_as="200", + log_neighbor_changes=True, + neighbors=[ + dict( + neighbor_address="192.0.2.10", + neighbor_affinity_group=dict(group_id=190), + remote_as="65538", + description="site-1-nbr-1", + password=dict( + encryption=3, + key="13D4D3549493D2877B1DC116EE27A6BE", + ), + ), + ], + ), + ], + ), + state="overridden", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "router-id 198.51.100.212", + "neighbor 198.51.100.20", + "no shutdown", + "no neighbor 198.51.100.21", + "vrf site-1", + "neighbor 192.0.2.10", + "affinity-group 190", + "no vrf site-2", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + def test_nxos_bgp_global_replaced_idempotent(self): run_cfg = dedent( """\ diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py deleted file mode 100644 index 677e6f7dd..000000000 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py +++ /dev/null @@ -1,138 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_neighbor -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosBgpNeighborModule(TestNxosModule): - module = nxos_bgp_neighbor - - def setUp(self): - super(TestNxosBgpNeighborModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosBgpNeighborModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture("nxos_bgp", "config.cfg") - self.load_config.return_value = [] - - def test_nxos_bgp_neighbor_bfd_1(self): - # None (disable) -> enable - set_module_args(dict(asn=65535, neighbor="1.1.1.1", bfd="enable")) - self.execute_module( - changed=True, - commands=["router bgp 65535", "neighbor 1.1.1.1", "bfd"], - ) - - # enable -> enable (idempotence) - set_module_args(dict(asn=65535, neighbor="1.1.1.2", bfd="enable")) - self.execute_module(changed=False) - - def test_nxos_bgp_neighbor_bfd_2(self): - # enable -> None (disable) - set_module_args(dict(asn=65535, neighbor="1.1.1.2", bfd="disable")) - self.execute_module( - changed=True, - commands=["router bgp 65535", "neighbor 1.1.1.2", "no bfd"], - ) - - # None (disable) -> disable (idempotence) - set_module_args(dict(asn=65535, neighbor="1.1.1.1", bfd="disable")) - self.execute_module(changed=False) - - def test_nxos_bgp_neighbor(self): - set_module_args(dict(asn=65535, neighbor="192.0.2.3", description="some words")) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 192.0.2.3", - "description some words", - ], - ) - - def test_nxos_bgp_neighbor_absent(self): - set_module_args(dict(asn=65535, neighbor="1.1.1.1", state="absent")) - self.execute_module(changed=True, commands=["router bgp 65535", "no neighbor 1.1.1.1"]) - - def test_nxos_bgp_neighbor_remove_private_as(self): - set_module_args(dict(asn=65535, neighbor="3.3.3.4", remove_private_as="all")) - self.execute_module(changed=False, commands=[]) - - def test_nxos_bgp_neighbor_remove_private_as_changed(self): - set_module_args(dict(asn=65535, neighbor="3.3.3.4", remove_private_as="replace-as")) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.4", - "remove-private-as replace-as", - ], - ) - - def test_nxos_bgp_neighbor_peertype_border_leaf(self): - set_module_args(dict(asn=65535, neighbor="192.0.2.3", peer_type="fabric_border_leaf")) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 192.0.2.3", - "peer-type fabric-border-leaf", - ], - ) - - def test_nxos_bgp_neighbor_peertype_external(self): - set_module_args(dict(asn=65535, neighbor="192.0.2.3", peer_type="fabric_external")) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 192.0.2.3", - "peer-type fabric-external", - ], - ) - - def test_nxos_bgp_neighbor_peertype_border_leaf_exists(self): - set_module_args(dict(asn=65535, neighbor="5.5.5.5", peer_type="fabric_border_leaf")) - self.execute_module(changed=False) - - def test_nxos_bgp_neighbor_peertype_external_exists(self): - set_module_args(dict(asn=65535, neighbor="6.6.6.6", peer_type="fabric_external")) - self.execute_module(changed=False) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 8f12a4279..b3943f370 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -2713,3 +2713,64 @@ class TestNxosBGPNeighborAddressFamilyModule(TestNxosModule): ) result = self.execute_module(changed=False) self.assertEqual(result["parsed"], parsed) + + def test_nxos_bgp_nbr_af_rewrite_rt_asn(self): + # test merged for rewrite_rt_asn + self.get_config.return_value = dedent( + """\ + router bgp 65536 + neighbor 192.168.1.1 + vrf site-1 + neighbor 10.0.0.100 + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbors=[ + dict( + neighbor_address="192.168.1.1", + address_family=[ + dict( + afi="ipv4", + safi="mvpn", + rewrite_rt_asn=True, + ), + ], + ), + ], + vrfs=[ + dict( + vrf="site-1", + neighbors=[ + dict( + neighbor_address="10.0.0.100", + address_family=[ + dict( + afi="ipv4", + safi="mvpn", + rewrite_rt_asn=True, + ), + ], + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "neighbor 192.168.1.1", + "address-family ipv4 mvpn", + "rewrite-rt-asn", + "vrf site-1", + "neighbor 10.0.0.100", + "address-family ipv4 mvpn", + "rewrite-rt-asn", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py deleted file mode 100644 index 8b918d0e8..000000000 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py +++ /dev/null @@ -1,259 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_neighbor_af -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosBgpNeighborAfModule(TestNxosModule): - module = nxos_bgp_neighbor_af - - def setUp(self): - super(TestNxosBgpNeighborAfModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor_af.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor_af.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosBgpNeighborAfModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture("nxos_bgp", "config.cfg") - self.load_config.return_value = [] - - def test_nxos_bgp_neighbor_af(self): - set_module_args( - dict( - asn=65535, - neighbor="192.0.2.3", - afi="ipv4", - safi="unicast", - route_reflector_client=True, - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "router bgp 65535", - "neighbor 192.0.2.3", - "address-family ipv4 unicast", - "route-reflector-client", - ], - ) - - def test_nxos_bgp_neighbor_af_exists(self): - set_module_args(dict(asn=65535, neighbor="3.3.3.5", afi="ipv4", safi="unicast")) - self.execute_module(changed=False, commands=[]) - - def test_nxos_bgp_neighbor_af_absent(self): - set_module_args( - dict( - asn=65535, - neighbor="3.3.3.5", - afi="ipv4", - safi="unicast", - state="absent", - ), - ) - self.execute_module( - changed=True, - sort=False, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.5", - "no address-family ipv4 unicast", - ], - ) - - def test_nxos_bgp_neighbor_af_advertise_map(self): - set_module_args( - dict( - asn=65535, - neighbor="3.3.3.5", - afi="ipv4", - safi="unicast", - advertise_map_exist=["my_advertise_map", "my_exist_map"], - ), - ) - self.execute_module( - changed=True, - sort=False, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.5", - "address-family ipv4 unicast", - "advertise-map my_advertise_map exist-map my_exist_map", - ], - ) - - def test_nxos_bgp_neighbor_af_advertise_map_non_exist(self): - set_module_args( - dict( - asn=65535, - neighbor="3.3.3.5", - afi="ipv4", - safi="unicast", - advertise_map_non_exist=[ - "my_advertise_map", - "my_non_exist_map", - ], - ), - ) - self.execute_module( - changed=True, - sort=False, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.5", - "address-family ipv4 unicast", - "advertise-map my_advertise_map non-exist-map my_non_exist_map", - ], - ) - - def test_nxos_bgp_neighbor_af_max_prefix_limit_default(self): - set_module_args( - dict( - asn=65535, - neighbor="3.3.3.5", - afi="ipv4", - safi="unicast", - max_prefix_limit="default", - ), - ) - self.execute_module( - changed=True, - sort=False, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.5", - "address-family ipv4 unicast", - "no maximum-prefix", - ], - ) - - def test_nxos_bgp_neighbor_af_max_prefix(self): - set_module_args( - dict( - asn=65535, - neighbor="3.3.3.5", - afi="ipv4", - safi="unicast", - max_prefix_threshold=20, - max_prefix_limit=20, - ), - ) - self.execute_module( - changed=True, - sort=False, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.5", - "address-family ipv4 unicast", - "maximum-prefix 20 20", - ], - ) - - def test_nxos_bgp_neighbor_af_disable_peer_as_check(self): - set_module_args( - dict( - asn=65535, - neighbor="3.3.3.5", - afi="ipv4", - safi="unicast", - disable_peer_as_check=True, - ), - ) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 3.3.3.5", - "address-family ipv4 unicast", - "disable-peer-as-check", - ], - ) - - def test_nxos_bgp_neighbor_af_rewrite_evpn(self): - set_module_args( - dict( - asn=65535, - neighbor="30.30.30.5", - afi="l2vpn", - safi="evpn", - rewrite_evpn_rt_asn=True, - ), - ) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 30.30.30.5", - "address-family l2vpn evpn", - "rewrite-evpn-rt-asn", - ], - ) - - def test_nxos_bgp_neighbor_af_rewrite_evpn_disable(self): - set_module_args( - dict( - asn=65535, - neighbor="30.30.30.5", - afi="l2vpn", - safi="evpn", - rewrite_evpn_rt_asn=False, - ), - ) - self.execute_module( - changed=True, - commands=[ - "router bgp 65535", - "neighbor 30.30.30.5", - "address-family l2vpn evpn", - "no rewrite-evpn-rt-asn", - ], - ) - - def test_nxos_bgp_neighbor_af_rewrite_evpn_exists(self): - set_module_args( - dict( - asn=65535, - neighbor="7.7.7.7", - afi="l2vpn", - safi="evpn", - rewrite_evpn_rt_asn=True, - ), - ) - self.execute_module(changed=False, commands=[]) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py new file mode 100644 index 000000000..8d2fd74b5 --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py @@ -0,0 +1,865 @@ +# (c) 2021 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +from textwrap import dedent + +from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_templates +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + +from .nxos_module import TestNxosModule, set_module_args + + +ignore_provider_arg = True + + +class TestNxosBgpTemplatesModule(TestNxosModule): + module = nxos_bgp_templates + + def setUp(self): + super(TestNxosBgpTemplatesModule, self).setUp() + + self.mock_get_resource_connection = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", + ) + self.get_resource_connection = self.mock_get_resource_connection.start() + + self.mock_get_config = patch( + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_templates.bgp_templates.Bgp_templatesFacts.get_config", + ) + self.get_config = self.mock_get_config.start() + + def tearDown(self): + super(TestNxosBgpTemplatesModule, self).tearDown() + self.get_resource_connection.stop() + self.get_config.stop() + + def test_nxos_bgp_templates_merged(self): + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + description="test-neighbor-template", + bfd=dict( + singlehop=True, + multihop=dict( + interval=dict( + tx_interval=300, + min_rx_interval=258, + multiplier=12, + ), + ), + ), + bmp_activate_server=12, + capability=dict( + suppress_4_byte_as=True, + ), + disable_connected_check=True, + dont_capability_negotiate=True, + dscp="cs1", + dynamic_capability=True, + ebgp_multihop=5, + graceful_shutdown=dict( + activate=dict( + route_map="rmap1", + ), + ), + inherit=dict(peer_session="peer_sess_1"), + local_as="65535", + log_neighbor_changes=dict( + disable=True, + ), + low_memory=dict( + exempt=True, + ), + password=dict( + encryption=7, + key="095C4F1A0A1218000F", + ), + path_attribute=[ + dict( + action="discard", + type=10, + ), + dict( + action="treat-as-withdraw", + range=dict( + start=10, + end=15, + ), + ), + ], + ), + dict( + name="tmplt_2", + bfd=dict( + set=True, + ), + remote_as="65534", + remove_private_as=dict( + replace_as=True, + ), + shutdown=True, + timers=dict( + keepalive=200, + holdtime=300, + ), + transport=dict(connection_mode=dict(passive=True)), + ttl_security=dict( + hops=10, + ), + update_source="Ethernet1/1", + ), + dict( + name="tmplt_3", + bfd=dict( + multihop=dict( + set=True, + ), + ), + address_family=[ + dict( + afi="l2vpn", + safi="evpn", + send_community="both", + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "template peer tmplt_1", + "bfd singlehop", + "bfd multihop interval 300 min_rx 258 multiplier 12", + "bmp-activate-server 12", + "capability suppress 4-byte-as", + "description test-neighbor-template", + "disable-connected-check", + "dont-capability-negotiate", + "dscp cs1", + "dynamic-capability", + "ebgp-multihop 5", + "graceful-shutdown activate route-map rmap1", + "inherit peer-session peer_sess_1", + "local-as 65535", + "log-neighbor-changes disable", + "low-memory exempt", + "password 7 095C4F1A0A1218000F", + "path-attribute discard 10 in", + "path-attribute treat-as-withdraw range 10 15 in", + "template peer tmplt_2", + "bfd", + "remote-as 65534", + "remove-private-as replace-as", + "shutdown", + "timers 200 300", + "transport connection-mode passive", + "ttl-security hops 10", + "update-source Ethernet1/1", + "template peer tmplt_3", + "bfd multihop", + "address-family l2vpn evpn", + "send-community", + "send-community extended", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_templates_merged_idempotent(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + bfd singlehop + bfd multihop interval 300 min_rx 258 multiplier 12 + bmp-activate-server 12 + capability suppress 4-byte-as + description test-neighbor-template + disable-connected-check + dont-capability-negotiate + dscp cs1 + dynamic-capability + ebgp-multihop 5 + graceful-shutdown activate route-map rmap1 + inherit peer-session peer_sess_1 + local-as 65535 + log-neighbor-changes disable + low-memory exempt + password 7 095C4F1A0A1218000F + path-attribute discard 10 in + path-attribute treat-as-withdraw range 10 15 in + template peer tmplt_2 + bfd + remote-as 65534 + remove-private-as replace-as + shutdown + timers 200 300 + transport connection-mode passive + ttl-security hops 10 + update-source Ethernet1/1 + template peer tmplt_3 + bfd multihop + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + description="test-neighbor-template", + bfd=dict( + singlehop=True, + multihop=dict( + interval=dict( + tx_interval=300, + min_rx_interval=258, + multiplier=12, + ), + ), + ), + bmp_activate_server=12, + capability=dict( + suppress_4_byte_as=True, + ), + disable_connected_check=True, + dont_capability_negotiate=True, + dscp="cs1", + dynamic_capability=True, + ebgp_multihop=5, + graceful_shutdown=dict( + activate=dict( + route_map="rmap1", + ), + ), + inherit=dict(peer_session="peer_sess_1"), + local_as="65535", + log_neighbor_changes=dict( + disable=True, + ), + low_memory=dict( + exempt=True, + ), + password=dict( + encryption=7, + key="095C4F1A0A1218000F", + ), + path_attribute=[ + dict( + action="discard", + type=10, + ), + dict( + action="treat-as-withdraw", + range=dict( + start=10, + end=15, + ), + ), + ], + ), + dict( + name="tmplt_2", + bfd=dict( + set=True, + ), + remote_as="65534", + remove_private_as=dict( + replace_as=True, + ), + shutdown=True, + timers=dict( + keepalive=200, + holdtime=300, + ), + transport=dict(connection_mode=dict(passive=True)), + ttl_security=dict( + hops=10, + ), + update_source="Ethernet1/1", + ), + dict( + name="tmplt_3", + bfd=dict( + multihop=dict( + set=True, + ), + ), + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_nxos_bgp_templates_deleted_single(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + bfd singlehop + bfd multihop interval 300 min_rx 258 multiplier 12 + bmp-activate-server 12 + template peer tmplt_2 + bfd + remote-as 65534 + remove-private-as replace-as + """, + ) + set_module_args( + dict( + config=dict(as_number="65536", neighbor=[dict(name="tmplt_1")]), + state="deleted", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "no template peer tmplt_1", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_templates_deleted_all(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + bfd singlehop + bfd multihop interval 300 min_rx 258 multiplier 12 + bmp-activate-server 12 + template peer tmplt_2 + bfd + remote-as 65534 + remove-private-as replace-as + """, + ) + set_module_args( + dict( + state="deleted", + ), + ignore_provider_arg, + ) + commands = ["router bgp 65536", "no template peer tmplt_1", "no template peer tmplt_2"] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_templates_overridden(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + bfd singlehop + bfd multihop interval 300 min_rx 258 multiplier 12 + template peer tmplt_2 + bfd + remote-as 65534 + remove-private-as replace-as + path-attribute discard 10 in + path-attribute treat-as-withdraw range 10 15 in + template peer tmplt_3 + remote-as 65533 + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + bfd=dict( + singlehop=True, + multihop=dict( + interval=dict( + tx_interval=300, + min_rx_interval=258, + multiplier=12, + ), + ), + ), + ), + dict( + name="tmplt_2", + remote_as="65534", + path_attribute=[ + dict( + action="discard", + type=10, + ), + ], + ), + ], + ), + state="overridden", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "no template peer tmplt_3", + "template peer tmplt_2", + "no bfd", + "no remove-private-as replace-as", + "no path-attribute treat-as-withdraw range 10 15 in", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_templates_gathered(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + bfd singlehop + bfd multihop interval 300 min_rx 258 multiplier 12 + template peer tmplt_2 + bfd + remote-as 65534 + remove-private-as replace-as + path-attribute discard 10 in + """, + ) + set_module_args( + dict( + state="gathered", + ), + ignore_provider_arg, + ) + gathered = dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + bfd=dict( + singlehop=True, + multihop=dict( + interval=dict( + tx_interval=300, + min_rx_interval=258, + multiplier=12, + ), + ), + ), + ), + dict( + name="tmplt_2", + bfd=dict( + set=True, + ), + remote_as="65534", + path_attribute=[ + dict( + action="discard", + type=10, + ), + ], + remove_private_as=dict( + replace_as=True, + ), + ), + ], + ) + result = self.execute_module(changed=False) + self.assertEqual(result["gathered"], gathered) + + def test_nxos_bgp_templates_parsed(self): + run_cfg = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + bfd singlehop + bfd multihop interval 300 min_rx 258 multiplier 12 + template peer tmplt_2 + bfd + remote-as 65534 + remove-private-as replace-as + path-attribute discard 10 in + """, + ) + set_module_args( + dict( + running_config=run_cfg, + state="parsed", + ), + ignore_provider_arg, + ) + parsed = dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + bfd=dict( + singlehop=True, + multihop=dict( + interval=dict( + tx_interval=300, + min_rx_interval=258, + multiplier=12, + ), + ), + ), + ), + dict( + name="tmplt_2", + bfd=dict( + set=True, + ), + remote_as="65534", + path_attribute=[ + dict( + action="discard", + type=10, + ), + ], + remove_private_as=dict( + replace_as=True, + ), + ), + ], + ) + result = self.execute_module(changed=False) + self.assertEqual(result["parsed"], parsed) + + def test_nxos_bgp_templates_af(self): + self.get_config.return_value = dedent( + """\ + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + description="test-neighbor-template", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + advertise_map=dict( + route_map="rmap1", + exist_map="rmap2", + ), + advertisement_interval=100, + allowas_in=dict( + max_occurences=10, + ), + as_override=True, + capability=dict( + additional_paths=dict( + receive="disable", + send="disable", + ), + ), + default_originate=dict( + route_map="rmap1", + ), + disable_peer_as_check=True, + filter_list=dict( + inbound="flist1", + outbound="flist2", + ), + inherit=dict( + peer_policy="tmplt_policy_1", + ), + ), + dict( + afi="ipv4", + safi="multicast", + maximum_prefix=dict( + max_prefix_limit=10, + generate_warning_threshold=80, + restart_interval=60, + warning_only=True, + ), + next_hop_self=dict( + all_routes=True, + ), + next_hop_third_party=True, + prefix_list=dict( + inbound="plist1", + outbound="plist2", + ), + ), + ], + ), + dict( + name="tmplt_2", + description="test-neighbor-template-2", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + route_map=dict( + inbound="rmap1", + outbound="rmap2", + ), + route_reflector_client=True, + soft_reconfiguration_inbound=dict( + always=True, + ), + soo="test", + suppress_inactive=True, + unsuppress_map="rmap1", + weight=2, + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "template peer tmplt_1", + "description test-neighbor-template", + "address-family ipv4 unicast", + "advertise-map rmap1 exist-map rmap2", + "advertisement-interval 100", + "allowas-in 10", + "as-override", + "capability additional-paths receive disable", + "capability additional-paths send disable", + "default-originate route-map rmap1", + "disable-peer-as-check", + "filter-list flist1 in", + "filter-list flist2 out", + "inherit peer-policy tmplt_policy_1", + "address-family ipv4 multicast", + "maximum-prefix 10 80 restart 60 warning-only", + "next-hop-self all", + "next-hop-third-party", + "prefix-list plist1 in", + "prefix-list plist2 out", + "template peer tmplt_2", + "description test-neighbor-template-2", + "address-family ipv4 unicast", + "route-map rmap1 in", + "route-map rmap2 out", + "route-reflector-client", + "soft-reconfiguration inbound always", + "soo test", + "suppress-inactive", + "unsuppress-map rmap1", + "weight 2", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_templates_af_idempotent(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + description test-neighbor-template + address-family ipv4 unicast + advertise-map rmap1 exist-map rmap2 + advertisement-interval 100 + allowas-in 10 + as-override + capability additional-paths receive disable + capability additional-paths send disable + default-originate route-map rmap1 + disable-peer-as-check + filter-list flist1 in + filter-list flist2 out + inherit peer-policy tmplt_policy_1 + address-family ipv4 multicast + maximum-prefix 10 80 restart 60 warning-only + next-hop-self all + no next-hop-third-party + prefix-list plist1 in + prefix-list plist2 out + template peer tmplt_2 + description test-neighbor-template-2 + address-family ipv4 unicast + route-map rmap1 in + route-map rmap2 out + route-reflector-client + soft-reconfiguration inbound always + soo test + suppress-inactive + unsuppress-map rmap1 + weight 2 + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + description="test-neighbor-template", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + advertise_map=dict( + route_map="rmap1", + exist_map="rmap2", + ), + advertisement_interval=100, + allowas_in=dict( + max_occurences=10, + ), + as_override=True, + capability=dict( + additional_paths=dict( + receive="disable", + send="disable", + ), + ), + default_originate=dict( + route_map="rmap1", + ), + disable_peer_as_check=True, + filter_list=dict( + inbound="flist1", + outbound="flist2", + ), + inherit=dict( + peer_policy="tmplt_policy_1", + ), + ), + dict( + afi="ipv4", + safi="multicast", + maximum_prefix=dict( + max_prefix_limit=10, + generate_warning_threshold=80, + restart_interval=60, + warning_only=True, + ), + next_hop_self=dict( + all_routes=True, + ), + next_hop_third_party=False, + prefix_list=dict( + inbound="plist1", + outbound="plist2", + ), + ), + ], + ), + dict( + name="tmplt_2", + description="test-neighbor-template-2", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + route_map=dict( + inbound="rmap1", + outbound="rmap2", + ), + route_reflector_client=True, + soft_reconfiguration_inbound=dict( + always=True, + ), + soo="test", + suppress_inactive=True, + unsuppress_map="rmap1", + weight=2, + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_nxos_bgp_templates_send_comm(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + address-family ipv4 unicast + send-community + send-community extended + template peer tmplt_2 + address-family l2vpn evpn + send-community extended + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + send_community="both", + ), + ], + ), + dict( + name="tmplt_2", + address_family=[ + dict( + afi="l2vpn", + safi="evpn", + send_community="standard", + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "template peer tmplt_2", + "address-family l2vpn evpn", + "no send-community extended", + "send-community", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_config.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_config.py index 83e58722a..ce5c987c7 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_config.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_config.py @@ -181,6 +181,47 @@ class TestNxosConfigModule(TestNxosModule): self.assertEqual(config, result["commands"], result["commands"]) + def test_nxos_replace_block_src(self): + src = load_fixture("nxos_config", "candidate.cfg") + args = dict(src=src, replace="block") + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff(src, self.running_config), + ) + set_module_args(args) + + result = self.execute_module(changed=True) + config = [ + "hostname switch01", + "interface Ethernet1", + "description test interface", + "no shutdown", + "ip routing", + ] + + self.assertEqual(sorted(config), sorted(result["commands"]), result["commands"]) + + def test_nxos_replace_block_lines(self): + lines = ["ip address 1.2.3.4/5", "no shutdown"] + parents = ["interface Ethernet10"] + args = dict(lines=lines, parents=parents, replace="block") + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + "\n".join(parents + lines), + self.running_config, + path=parents, + ), + ) + set_module_args(args) + + result = self.execute_module(changed=True) + config = [ + "interface Ethernet10", + "ip address 1.2.3.4/5", + "no shutdown", + ] + + self.assertEqual(config, result["commands"], result["commands"]) + def test_nxos_config_src_and_lines_fails(self): args = dict(src="foo", lines="foo") set_module_args(args) @@ -201,7 +242,7 @@ class TestNxosConfigModule(TestNxosModule): set_module_args(args) result = self.execute_module(failed=True) - def test_nxos_config_replace_block_requires_lines(self): + def test_nxos_config_replace_block_requires_lines_or_src(self): args = dict(replace="block") set_module_args(args) result = self.execute_module(failed=True) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_devicealias.py index a35896fbe..640bcd150 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_devicealias.py @@ -9,11 +9,11 @@ __metaclass__ = type import pytest -from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_devicealias +from ansible_collections.cisco.nxos.plugins.modules import nxos_devicealias from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson -from ..nxos_module import TestNxosModule, load_fixture, set_module_args +from .nxos_module import TestNxosModule, load_fixture, set_module_args class TestNxosDeviceAliasModule(TestNxosModule): @@ -21,7 +21,7 @@ class TestNxosDeviceAliasModule(TestNxosModule): def setUp(self): super(TestNxosDeviceAliasModule, self).setUp() - module_path = "ansible_collections.cisco.nxos.plugins.modules.storage.nxos_devicealias." + module_path = "ansible_collections.cisco.nxos.plugins.modules.nxos_devicealias." self.mock_run_commands = patch(module_path + "run_commands") self.run_commands = self.mock_run_commands.start() diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py new file mode 100644 index 000000000..098a5b7ff --- /dev/null +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py @@ -0,0 +1,1744 @@ +# (c) 2023 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish + + +# remove purge +# add non fc interfaces to the sh run +# check else statements in config file + + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +from textwrap import dedent + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + allowed_port_modes, + allowed_speed_values, +) +from ansible_collections.cisco.nxos.plugins.modules import nxos_fc_interfaces +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + +from .nxos_module import TestNxosModule, set_module_args + + +ignore_provider_arg = True + +sh_run = """ +interface mgmt0 + ip address 10.126.94.175 255.255.255.0 + no switchport description + switchport speed auto + switchport duplex auto + snmp trap link-status + no shutdown + lldp transmit + lldp receive + cdp enable + spanning-tree port-priority 128 + spanning-tree cost auto + spanning-tree link-type auto + no spanning-tree bpduguard + no spanning-tree bpdufilter + +interface vsan1 + no shutdown + ip address 111.111.111.175 255.255.255.0 + spanning-tree port-priority 128 + spanning-tree cost auto + spanning-tree link-type auto + no spanning-tree bpduguard + no spanning-tree bpdufilter + + +interface fc1/1 + no out-of-service force + switchport speed auto + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description This is a sample line + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc1/2 + no out-of-service force + switchport speed 1000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode E + no switchport description + switchport vl-credit default + switchport trunk mode off + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no errdisable detect cause link-down + no errdisable detect cause trustsec-violation + no errdisable detect cause bit-errors + no errdisable detect cause signal-loss + no errdisable detect cause sync-loss + no errdisable detect cause link-reset + no errdisable detect cause credit-loss + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc1/3 + no out-of-service force + switchport speed 2000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode F + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/1 + no out-of-service force + switchport speed 4000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode Fx + no switchport description + switchport vl-credit default + switchport trunk mode auto + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/2 + no out-of-service force + switchport speed 8000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode NP + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/3 + no out-of-service force + switchport speed 10000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode SD + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/4 + no out-of-service force + switchport speed 16000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/5 + no out-of-service force + switchport speed 32000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/6 + no out-of-service force + switchport speed 64000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/7 + no out-of-service force + switchport speed auto max 2000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/8 + no out-of-service force + switchport speed auto max 4000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/9 + no out-of-service force + switchport speed auto max 8000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description sample description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/10 + no out-of-service force + analytics type fc-nvme + switchport speed auto max 16000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description $ + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + shutdown + +interface fc18/11 + no out-of-service force + analytics type fc-scsi + switchport speed auto max 32000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description a + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + shutdown + +interface fc18/12 + no out-of-service force + analytics type fc-scsi + analytics type fc-nvme + switchport speed auto max 64000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description 1 + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/13 + no out-of-service force + analytics type fc-scsi + analytics type fc-nvme + switchport speed auto max 64000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description 1 + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + """ + +gath_val = [ + { + "name": "fc1/1", + "speed": "auto", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "This is a sample line", + }, + { + "name": "fc1/2", + "speed": "1000", + "mode": "E", + "trunk_mode": "off", + "enabled": True, + }, + { + "name": "fc1/3", + "speed": "2000", + "mode": "F", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/1", + "speed": "4000", + "mode": "Fx", + "trunk_mode": "auto", + "enabled": True, + }, + { + "name": "fc18/2", + "speed": "8000", + "mode": "NP", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/3", + "speed": "10000", + "mode": "SD", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/4", + "speed": "16000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/5", + "speed": "32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/6", + "speed": "64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/7", + "speed": "auto max 2000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/8", + "speed": "auto max 4000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/9", + "speed": "auto max 8000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "sample description", + }, + { + "name": "fc18/10", + "speed": "auto max 16000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "$", + "analytics": "fc-nvme", + }, + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-scsi", + }, + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-all", + }, + { + "name": "fc18/13", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-all", + }, +] + + +class TestNxosFcInterfacesModule(TestNxosModule): + module = nxos_fc_interfaces + + def setUp(self): + super(TestNxosFcInterfacesModule, self).setUp() + + self.mock_get_resource_connection = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", + ) + self.get_resource_connection = self.mock_get_resource_connection.start() + + self.mock_get_config = patch( + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.fc_interfaces.fc_interfaces.Fc_interfacesFacts.get_interfaces_data", + ) + self.get_config = self.mock_get_config.start() + self.get_config.return_value = dedent(sh_run) + + self.maxDiff = None + + def tearDown(self): + super(TestNxosFcInterfacesModule, self).tearDown() + self.get_resource_connection.stop() + self.get_config.stop() + + def test_analytics_no_to_all_3_types(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-scsi", + "mode": "E", + }, + { + "name": "fc1/2", + "analytics": "fc-nvme", + }, + { + "name": "fc1/3", + "analytics": "fc-all", + }, + { + "name": "fc18/12", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "switchport mode E", + "analytics type fc-scsi", + "interface fc1/2", + "analytics type fc-nvme", + "interface fc1/3", + "analytics type fc-all", + ], + ) + + def test_gathered(self): + # test gathered for config + set_module_args(dict(state="gathered"), ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["gathered"], gath_val) + + def test_parsed(self): + # test parsed for config + set_module_args(dict(state="parsed", running_config=sh_run), ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["parsed"], gath_val) + + def test_idempotency(self): + args = dict( + config=gath_val, + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_analytics_all_to_scsi(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual( + result["commands"], + [], + ) + + def test_analytics_all_to_scsi_replaced(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-scsi", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/12", "no analytics type fc-all", "analytics type fc-scsi"], + ) + + def test_analytics_all_to_nvme(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-nvme", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual( + result["commands"], + [], + ) + + def test_analytics_all_to_nvme_replaced(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-nvme", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/12", "no analytics type fc-all", "analytics type fc-nvme"], + ) + + def test_analytics_all_to_none_checkthis(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_analytics_all_to_none_desc_change(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "2", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc18/12", "switchport description 2"]) + + def test_analytics_scsi_to_nvme(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-nvme", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/11", "analytics type fc-nvme"], + ) + + def test_analytics_scsi_to_nvme_replaced(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-nvme", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/11", "no analytics type fc-all", "analytics type fc-nvme"], + ) + + def test_analytics_scsi_to_all(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc18/11", "analytics type fc-all"]) + + def test_analytics_scsi_to_all_replaced(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-all", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/11", "analytics type fc-all"], + ) + + def test_analytics_scsi_to_none_checkthis(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_analytics_nvme_to_scsi(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/10", "analytics type fc-scsi"], + ) + + def test_analytics_nvme_to_scsi_replaced(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-scsi", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + "analytics type fc-scsi", + ], + ) + + def test_analytics_nvme_to_all(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/10", "analytics type fc-all"], + ) + + def test_analytics_nvme_to_all_replaced(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-all", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-all", + ], + ) + + def test_analytics_none_to_scsi(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc1/1", "analytics type fc-scsi"]) + + def test_analytics_none_to_scsi_replaced(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-scsi", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-scsi", + ], + ) + + def test_analytics_none_to_nvme(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-nvme", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc1/1", "analytics type fc-nvme"]) + + def test_analytics_none_to_nvme_replaced(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-nvme", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-nvme", + ], + ) + + def test_analytics_none_to_nvme_overridden(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-nvme", + }, + ], + state="overridden", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/2", + "no switchport speed 1000", + "no switchport mode E", + "switchport trunk mode on", + "shutdown", + "interface fc1/3", + "no switchport speed 2000", + "no switchport mode F", + "switchport trunk mode on", + "shutdown", + "interface fc18/1", + "no switchport speed 4000", + "no switchport mode Fx", + "switchport trunk mode on", + "shutdown", + "interface fc18/2", + "no switchport speed 8000", + "no switchport mode NP", + "switchport trunk mode on", + "shutdown", + "interface fc18/3", + "no switchport speed 10000", + "no switchport mode SD", + "switchport trunk mode on", + "shutdown", + "interface fc18/4", + "no switchport speed 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/5", + "no switchport speed 32000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/6", + "no switchport speed 64000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/7", + "no switchport speed auto max 2000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/8", + "no switchport speed auto max 4000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/9", + "no switchport description", + "no switchport speed auto max 8000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + "interface fc18/11", + "no switchport description", + "no switchport speed auto max 32000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + "interface fc18/12", + "no switchport description", + "no switchport speed auto max 64000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + "interface fc18/13", + "no switchport description", + "no switchport speed auto max 64000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-nvme", + ], + ) + + def test_analytics_none_to_all(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc1/1", "analytics type fc-all"]) + + def test_analytics_none_to_all_replaced(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-all", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-all", + ], + ) + + def test_analytics_nvme_to_none_checkthis(self): + args = dict( + config=[ + { + "name": "fc18/10", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_description_change_from_one_to_another(self): + args = dict( + config=[ + { + "name": "fc18/9", + "description": "changed from sample description to new description", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/9", + "switchport description changed from sample description to new description", + ], + ) + + def test_description_change_from_none_to_new(self): + args = dict( + config=[ + { + "name": "fc18/8", + "description": "new sample description", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/8", + "switchport description new sample description", + ], + ) + + def test_shut_to_noshut(self): + args = dict( + config=[ + { + "name": "fc18/10", + "enabled": True, + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no shutdown", + ], + ) + + def test_noshut_to_shut(self): + args = dict( + config=[ + { + "name": "fc18/6", + "enabled": False, + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/6", "shutdown"], + ) + + def test_trunkmode_auto_to_off(self): + args = dict( + config=[ + { + "name": "fc18/1", + "trunk_mode": "off", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/1", "switchport trunk mode off"], + ) + + def test_trunkmode_auto_to_on(self): + args = dict( + config=[ + { + "name": "fc18/1", + "trunk_mode": "on", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/1", "switchport trunk mode on"], + ) + + def test_trunkmode_on_to_off(self): + args = dict( + config=[ + { + "name": "fc1/1", + "trunk_mode": "off", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/1", "switchport trunk mode off"], + ) + + def test_trunkmode_on_to_auto(self): + args = dict( + config=[ + { + "name": "fc1/1", + "trunk_mode": "auto", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/1", "switchport trunk mode auto"], + ) + + def test_trunkmode_off_to_on(self): + args = dict( + config=[ + { + "name": "fc1/2", + "trunk_mode": "on", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/2", "switchport trunk mode on"], + ) + + def test_trunkmode_off_to_auto(self): + args = dict( + config=[ + { + "name": "fc1/2", + "trunk_mode": "auto", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/2", "switchport trunk mode auto"], + ) + + def test_speed_combinations(self): + port_speed = "auto" + port_name = "fc1/1" + for each_speed in allowed_speed_values: + args = dict( + config=[ + { + "name": port_name, + "speed": each_speed, + }, + ], + state="merged", + ) + if each_speed == port_speed: + changed = False + cmds = [] + else: + changed = True + cmds = [f"interface {port_name}", f"switchport speed {each_speed}"] + + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=changed) + self.assertEqual( + result["commands"], + cmds, + ) + + def test_port_mode_combinations(self): + port_mode = "auto" + port_name = "fc1/1" + for each_mode in allowed_port_modes: + args = dict( + config=[ + { + "name": port_name, + "mode": each_mode, + }, + ], + state="merged", + ) + if each_mode == port_mode: + changed = False + cmds = [] + else: + changed = True + cmds = [f"interface {port_name}", f"switchport mode {each_mode}"] + + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=changed) + self.assertEqual( + result["commands"], + cmds, + ) + + def test_deleted_1(self): + # before- trunk mode on + args = dict( + config=[ + { + "name": "fc1/2", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/2", + "no switchport speed 1000", + "no switchport mode E", + "switchport trunk mode on", + "shutdown", + ], + ) + + def test_deleted_2(self): + # before- trunk mode off + args = dict( + config=[ + { + "name": "fc1/3", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/3", + "no switchport speed 2000", + "no switchport mode F", + "switchport trunk mode on", + "shutdown", + ], + ) + + def test_deleted_3(self): + # before- port shut and with description and analytics config + args = dict( + config=[ + { + "name": "fc18/10", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + ], + ) + + def test_replaced_move_to_def(self): + args = dict( + config=[ + { + "name": "fc18/10", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + ], + ) + + def test_deleted_combined(self): + args = dict( + config=[ + { + "name": "fc1/2", + }, + { + "name": "fc1/3", + }, + { + "name": "fc18/10", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/2", + "no switchport speed 1000", + "no switchport mode E", + "switchport trunk mode on", + "shutdown", + "interface fc1/3", + "no switchport speed 2000", + "no switchport mode F", + "switchport trunk mode on", + "shutdown", + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + ], + ) + + def test_most_of_them_combined(self): + args = dict( + config=[ + { + "name": "fc18/13", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-all", + }, + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-scsi", + }, + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-all", + }, + { + "name": "fc18/10", + "analytics": "fc-scsi", + "enabled": True, + }, + { + "name": "fc18/9", + "description": "changed from sample description to new description", + }, + { + "name": "fc18/8", + "description": "new sample description", + }, + { + "name": "fc18/6", + "enabled": False, + }, + { + "name": "fc18/1", + "trunk_mode": "off", + }, + { + "name": "fc1/1", + "trunk_mode": "auto", + "analytics": "fc-all", + }, + { + "name": "fc1/2", + "trunk_mode": "on", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "switchport trunk mode auto", + "analytics type fc-all", + ] + + [ + "interface fc1/2", + "switchport trunk mode on", + ] + + [ + "interface fc18/1", + "switchport trunk mode off", + ] + + [ + "interface fc18/6", + "shutdown", + ] + + [ + "interface fc18/8", + "switchport description new sample description", + ] + + [ + "interface fc18/9", + "switchport description changed from sample description to new description", + ] + + [ + "interface fc18/10", + "no shutdown", + # "no analytics type fc-all", + "analytics type fc-scsi", + ] + + [ + "interface fc18/11", + "analytics type fc-all", + ], + # + [ + # "interface fc18/12", + # # "no analytics type fc-all", + # "analytics type fc-scsi", + # ], + ) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 7dac77c98..fb8dae234 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -772,3 +772,49 @@ class TestNxosInterfacesModule(TestNxosModule): playbook["state"] = "merged" set_module_args(playbook, ignore_provider_arg) self.execute_module(changed=True, commands=merged) + + def test_mode_mtu(self): + # test mode change with MTU + sysdefs = dedent( + """\ + ! + ! Interfaces default to L3 !! + ! + no system default switchport + """, + ) + intf = dedent( + """\ + interface Ethernet1/28 + description Auto_Cable_Testing + mtu 9216 + """, + ) + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} + self.get_system_defaults.return_value = sysdefs + + playbook = dict( + config=[ + dict( + name="Ethernet1/28", + description="Ansible Port Turn Up1", + mode="layer2", + mtu="9216", + speed="1000", + duplex="full", + enabled=True, + ), + ], + ) + replaced = [ + "interface Ethernet1/28", + "description Ansible Port Turn Up1", + "switchport", + "mtu 9216", + "speed 1000", + "duplex full", + "no shutdown", + ] + playbook["state"] = "replaced" + set_module_args(playbook, ignore_provider_arg) + self.execute_module(changed=True, commands=replaced) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_pim_interface.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_pim_interface.py index 886a77940..b746b8b46 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_pim_interface.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_pim_interface.py @@ -63,7 +63,7 @@ class TestNxosIPInterfaceModule(TestNxosModule): output = list() for command in commands: - if type(command) == dict: + if isinstance(command, dict): command = command["command"] filename = str(command).split(" | ", 1)[0].replace(" ", "_").replace("/", "_") output.append(load_fixture(module_name, filename)) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_ping.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_ping.py index 73535f89e..bdaabe881 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_ping.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_ping.py @@ -32,7 +32,7 @@ ignore_provider_arg = True class TestNxosPingModule(TestNxosModule): - """Class used for Unit Tests agains ios_ping module""" + """Class used for Unit Tests against nxos_ping module""" module = nxos_ping diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_route_maps.py index 53069a1e9..06d76fe38 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -1415,3 +1415,81 @@ class TestNxosRouteMapsModule(TestNxosModule): ] result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_route_maps_extcomm_rt(self): + # test for extcommunity.rt + self.get_config.return_value = dedent( + """\ + route-map test-1 permit 10 + set extcommunity rt additive + route-map test-2 permit 11 + set extcommunity rt 65000:516590 65000:516591 65000:516592 additive + """, + ) + set_module_args( + dict( + config=[ + dict( + route_map="test-1", + entries=[ + dict( + action="permit", + sequence=10, + set=dict( + extcommunity=dict( + rt=dict( + extcommunity_numbers=[ + "65000:516586", + ], + additive=True, + ), + ), + ), + ), + ], + ), + ], + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "route-map test-1 permit 10", + "set extcommunity rt 65000:516586 additive", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + set_module_args( + dict( + config=[ + dict( + route_map="test-2", + entries=[ + dict( + action="permit", + sequence=11, + set=dict( + extcommunity=dict( + rt=dict( + extcommunity_numbers=[ + "65000:516590", + ], + ), + ), + ), + ), + ], + ), + ], + state="replaced", + ), + ignore_provider_arg, + ) + commands = [ + "route-map test-2 permit 11", + "no set extcommunity rt 65000:516590 65000:516591 65000:516592 additive", + "set extcommunity rt 65000:516590", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 1b66d6455..1b7672775 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -793,10 +793,8 @@ class TestNxosSnmpServerModule(TestNxosModule): ignore_provider_arg, ) commands = [ - "no snmp-server user user2 network-admin auth md5 0x5632724fb8ac3699296af262 priv" - " 0x5632724fb8ac3699296af262 localizedkey engineID 2:2:2:2:2", - "no snmp-server user user3 network-admin auth md5 0x5632724fb8ac3699296af262 priv" - " aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3", + "no snmp-server user user2", + "no snmp-server user user3", "snmp-server user user4 network-admin auth md5 0x5632724fb8ac3699296af262 priv aes-128" " 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3", ] diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_static_routes.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_static_routes.py index 69f5f74bd..76ed4a3a9 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_static_routes.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_static_routes.py @@ -8,11 +8,15 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +from textwrap import dedent + from ansible_collections.cisco.nxos.plugins.modules import nxos_static_routes from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import set_module_args -from .nxos_module import TestNxosModule +from .nxos_module import TestNxosModule, set_module_args + + +ignore_provider_arg = True class TestNxosStaticRoutesModule(TestNxosModule): @@ -21,275 +25,685 @@ class TestNxosStaticRoutesModule(TestNxosModule): def setUp(self): super(TestNxosStaticRoutesModule, self).setUp() - self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", - ) - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", - ) - self.get_resource_connection_config = self.mock_get_resource_connection_config.start() - - self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", - ) - self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() - - self.mock_edit_config = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.static_routes.static_routes.Static_routes.edit_config", + self.mock_get_resource_connection = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) - self.edit_config = self.mock_edit_config.start() + self.get_resource_connection = self.mock_get_resource_connection.start() self.mock_execute_show_command = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.static_routes.static_routes.Static_routesFacts.get_device_data", + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.static_routes.static_routes.Static_routesFacts.get_static_routes_data", ) self.execute_show_command = self.mock_execute_show_command.start() def tearDown(self): super(TestNxosStaticRoutesModule, self).tearDown() - self.mock_get_resource_connection_config.stop() - self.mock_get_resource_connection_facts.stop() - self.mock_edit_config.stop() - self.mock_get_config.stop() - self.mock_load_config.stop() + self.get_resource_connection.stop() self.mock_execute_show_command.stop() - def load_fixtures(self, commands=None, device=""): - def load_from_file(*args, **kwargs): - non_vrf_data = ["ip route 192.0.2.16/28 192.0.2.24 name initial_route"] - vrf_data = [ - "vrf context test\n ip route 192.0.2.96/28 192.0.2.122 vrf dest_vrf" - "\n ip route static bfd Vlan100 192.168.1.100\n ipv6 route 2001:db8:12::/32 2001:db8::1001 name ipv6_route 3\n", - ] + def test_nxos_static_routes_all_idempotent(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.80/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) - output = non_vrf_data + vrf_data - return output + config = [ + { + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", + }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", + }, + ], + "dest": "192.0.2.16/28", + }, + { + "next_hops": [{"forward_router_address": "192.0.2.26", "tag": 12}], + "dest": "192.0.2.80/28", + }, + ], + }, + ], + }, + { + "vrf": "Test", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.13"}, + { + "forward_router_address": "192.0.2.14", + "admin_distance": 5, + }, + ], + "dest": "192.0.2.48/28", + }, + ], + }, + ], + }, + { + "vrf": "management", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [{"forward_router_address": "192.168.255.1"}], + "dest": "0.0.0.0/0", + }, + ], + }, + ], + }, + { + "vrf": "newvrf", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "10.0.10.3", + "admin_distance": 11, + "tag": 22323, + "route_name": "test_name", + }, + ], + "dest": "10.0.10.0/25", + }, + { + "next_hops": [ + { + "forward_router_address": "10.0.11.10", + "admin_distance": 11, + "tag": 22, + }, + { + "forward_router_address": "10.0.11.12", + "admin_distance": 11, + "dest_vrf": "Test", + "tag": 22, + }, + ], + "dest": "10.0.11.0/25", + }, + { + "next_hops": [ + { + "interface": "loopback22", + "forward_router_address": "192.0.2.13", + }, + ], + "dest": "192.0.2.48/28", + }, + ], + }, + { + "afi": "ipv6", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "2048:ae12::1", + "admin_distance": 5, + "dest_vrf": "dest", + }, + { + "interface": "mgmt0", + "forward_router_address": "2048:ae12::1", + "admin_distance": 11, + "tag": 22, + }, + { + "interface": "port-channel22", + "forward_router_address": "2048:ae12::1", + }, + { + "interface": "Ethernet2/1", + "forward_router_address": "2048:ae12::1", + "admin_distance": 22, + "route_name": "test_name2", + }, + ], + "dest": "2200:10::/36", + }, + ], + }, + ], + }, + { + "vrf": "trial_vrf", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.22", "tag": 4}, + { + "forward_router_address": "192.0.2.23", + "admin_distance": 1, + "route_name": "merged_route", + }, + ], + "dest": "192.0.2.64/28", + }, + ], + }, + ], + }, + ] - self.execute_show_command.side_effect = load_from_file + for state in ["merged", "replaced", "overridden"]: + set_module_args({"config": config, "state": state}) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) def test_nxos_static_routes_merged(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3 + """, + ) set_module_args( dict( config=[ - dict( - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.32/28", - next_hops=[ - dict( - forward_router_address="192.0.2.40", - interface="Ethernet1/2", - admin_distance=5, - ), + { + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", + }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", + }, ], - ), + "dest": "192.0.2.16/28", + }, + { + "next_hops": [ + {"forward_router_address": "192.0.2.26", "tag": 12}, + ], + "dest": "192.0.2.80/28", + }, ], - ), + }, ], - ), - ], - state="merged", - ), - ) - commands = [ - "configure terminal", - "ip route 192.0.2.32/28 Ethernet1/2 192.0.2.40 5", - ] - self.execute_module(changed=True, commands=commands) - - def test_nxos_static_routes_merged_idempotent(self): - set_module_args( - dict( - config=[ - dict( - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.16/28", - next_hops=[ - dict( - forward_router_address="192.0.2.24", - route_name="initial_route", - ), + }, + { + "vrf": "Test", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.13"}, + { + "forward_router_address": "192.0.2.14", + "admin_distance": 5, + }, ], - ), + "dest": "192.0.2.48/28", + }, ], - ), + }, ], - ), - ], - state="merged", - ), - ) - self.execute_module(changed=False, commands=[]) - - def test_nxos_static_routes_replaced(self): - set_module_args( - dict( - config=[ - dict( - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.16/28", - next_hops=[ - dict( - forward_router_address="192.0.2.50", - tag=12, - route_name="replaced_route", - ), + }, + { + "vrf": "management", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [{"forward_router_address": "192.168.255.1"}], + "dest": "0.0.0.0/0", + }, + ], + }, + ], + }, + { + "vrf": "newvrf", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "10.0.10.3", + "admin_distance": 11, + "tag": 22323, + "route_name": "test_name", + }, ], - ), + "dest": "10.0.10.0/25", + }, + { + "next_hops": [ + { + "forward_router_address": "10.0.11.10", + "admin_distance": 11, + "tag": 22, + }, + { + "forward_router_address": "10.0.11.12", + "admin_distance": 11, + "dest_vrf": "Test", + "tag": 22, + }, + ], + "dest": "10.0.11.0/25", + }, + { + "next_hops": [ + { + "interface": "loopback22", + "forward_router_address": "192.0.2.13", + }, + ], + "dest": "192.0.2.48/28", + }, ], - ), + }, + { + "afi": "ipv6", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "2048:ae12::1", + "admin_distance": 5, + "dest_vrf": "dest", + }, + { + "interface": "mgmt0", + "forward_router_address": "2048:ae12::1", + "admin_distance": 11, + "tag": 22, + }, + { + "interface": "port-channel22", + "forward_router_address": "2048:ae12::1", + }, + { + "interface": "Ethernet2/1", + "forward_router_address": "2048:ae12::1", + "admin_distance": 22, + "route_name": "test_name2", + }, + ], + "dest": "2200:10::/36", + }, + ], + }, ], - ), + }, + { + "vrf": "trial_vrf", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.22", "tag": 4}, + { + "forward_router_address": "192.0.2.23", + "admin_distance": 1, + "route_name": "merged_route", + }, + ], + "dest": "192.0.2.64/28", + }, + ], + }, + ], + }, ], - state="replaced", + state="merged", ), ) commands = [ - "configure terminal", - "no ip route 192.0.2.16/28 192.0.2.24 name initial_route", - "ip route 192.0.2.16/28 192.0.2.50 name replaced_route tag 12", + "ip route 192.0.2.80/28 192.0.2.26 tag 12", + "ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2", + "vrf context newvrf", + "ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11", + "ip route 10.0.11.0/25 10.0.11.10 tag 22 11", + "ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11", + "ip route 192.0.2.48/28 loopback22 192.0.2.13", + "ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5", + "ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11", + "ipv6 route 2200:10::/36 port-channel22 2048:ae12::1", + "ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22", + "vrf context Test", + "ip route 192.0.2.48/28 192.0.2.13", + "ip route 192.0.2.48/28 192.0.2.14 5", + "vrf context trial_vrf", + "ip route 192.0.2.64/28 192.0.2.22 tag 4", + "ip route 192.0.2.64/28 192.0.2.23 name merged_route 1", + "vrf context management", + "ip route 0.0.0.0/0 192.168.255.1", ] self.execute_module(changed=True, commands=commands) - def test_nxos_static_routes_replaced_idempotent(self): + def test_nxos_static_routes_replaced(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.80/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) set_module_args( dict( config=[ - dict( - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.16/28", - next_hops=[ - dict( - forward_router_address="192.0.2.24", - route_name="initial_route", - ), + { + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", + }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", + }, ], - ), + "dest": "192.0.2.16/28", + }, + { + "next_hops": [ + {"forward_router_address": "192.0.2.27", "tag": 13}, + ], + "dest": "192.0.2.80/28", + }, ], - ), + }, ], - ), - ], - state="replaced", - ), - ) - self.execute_module(changed=False, commands=[]) - - def test_nxos_static_routes_overridden(self): - set_module_args( - dict( - config=[ - dict( - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.112/28", - next_hops=[ - dict( - forward_router_address="192.0.2.68", - route_name="overridden_route", - dest_vrf="end_vrf", - ), + }, + { + "vrf": "trial_vrf", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 1, + "route_name": "merged_route", + }, ], - ), + "dest": "192.0.2.0/28", + }, ], - ), + }, ], - ), + }, ], - state="overridden", + state="replaced", ), ) commands = [ - "configure terminal", - "no ip route 192.0.2.16/28 192.0.2.24 name initial_route", - "ip route 192.0.2.112/28 192.0.2.68 vrf end_vrf name overridden_route", - "vrf context test", - "no ipv6 route 2001:db8:12::/32 2001:db8::1001 name ipv6_route 3", - "no ip route 192.0.2.96/28 192.0.2.122 vrf dest_vrf", + "ip route 192.0.2.80/28 192.0.2.27 tag 13", + "no ip route 192.0.2.80/28 192.0.2.26 tag 12", + "vrf context trial_vrf", + "ip route 192.0.2.0/28 192.0.2.23 name merged_route 1", + "no ip route 192.0.2.64/28 192.0.2.22 tag 4", + "no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1", ] - self.execute_module(changed=True, commands=commands) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) - def test_nxos_static_routes_overridden_idempotent(self): + def test_nxos_static_routes_overridden(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.79/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) set_module_args( dict( config=[ - dict( - vrf="test", - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.96/28", - next_hops=[ - dict( - forward_router_address="192.0.2.122", - dest_vrf="dest_vrf", - ), + { + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", + }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", + }, ], - ), + "dest": "192.0.2.16/28", + }, + { + "next_hops": [ + {"forward_router_address": "192.0.2.27", "tag": 13}, + ], + "dest": "192.0.2.80/28", + }, ], - ), + }, ], - ), - dict( - address_families=[ - dict( - afi="ipv4", - routes=[ - dict( - dest="192.0.2.16/28", - next_hops=[ - dict( - forward_router_address="192.0.2.24", - route_name="initial_route", - ), + }, + { + "vrf": "trial_vrf", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 1, + "route_name": "merged_route", + }, ], - ), + "dest": "192.0.2.0/28", + }, ], - ), + }, ], - ), + }, ], state="overridden", ), ) - self.execute_module(changed=False, commands=[]) + commands = [ + "ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3", + "ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2", + "ip route 192.0.2.80/28 192.0.2.27 tag 13", + "no ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3", + "no ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2", + "no ip route 192.0.2.79/28 192.0.2.26 tag 12", + "vrf context trial_vrf", + "ip route 192.0.2.0/28 192.0.2.23 name merged_route 1", + "no ip route 192.0.2.64/28 192.0.2.22 tag 4", + "no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1", + "vrf context Test", + "no ip route 192.0.2.48/28 192.0.2.13", + "no ip route 192.0.2.48/28 192.0.2.14 5", + "vrf context management", + "no ip route 0.0.0.0/0 192.168.255.1", + "vrf context newvrf", + "no ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11", + "no ip route 10.0.11.0/25 10.0.11.10 tag 22 11", + "no ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11", + "no ip route 192.0.2.48/28 loopback22 192.0.2.13", + "no ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5", + "no ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11", + "no ipv6 route 2200:10::/36 port-channel22 2048:ae12::1", + "no ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22", + ] + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) def test_nxos_static_routes_deletedvrf(self): - set_module_args(dict(config=[dict(vrf="test")], state="deleted")) + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.79/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) + set_module_args(dict(config=[dict(vrf="Test")], state="deleted")) commands = [ - "vrf context test", - "no ip route 192.0.2.96/28 192.0.2.122 vrf dest_vrf", - "no ipv6 route 2001:db8:12::/32 2001:db8::1001 name ipv6_route 3", + "vrf context Test", + "no ip route 192.0.2.48/28 192.0.2.13", + "no ip route 192.0.2.48/28 192.0.2.14 5", ] - self.execute_module(changed=True, commands=commands) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) def test_nxos_static_routes_deletedafi(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.79/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) set_module_args( dict( config=[dict(address_families=[dict(afi="ipv4")])], @@ -297,62 +711,152 @@ class TestNxosStaticRoutesModule(TestNxosModule): ), ) commands = [ - "configure terminal", - "no ip route 192.0.2.16/28 192.0.2.24 name initial_route", + "no ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3", + "no ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2", + "no ip route 192.0.2.79/28 192.0.2.26 tag 12", ] - self.execute_module(changed=True, commands=commands) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) def test_nxos_static_routes_deleteddest(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.79/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) set_module_args( dict( config=[ dict( - vrf="test", - address_families=[dict(afi="ipv4", routes=[dict(dest="192.0.2.96/28")])], + vrf="Test", + address_families=[dict(afi="ipv4", routes=[dict(dest="192.0.2.48/28")])], ), ], state="deleted", ), ) commands = [ - "vrf context test", - "no ip route 192.0.2.96/28 192.0.2.122 vrf dest_vrf", + "vrf context Test", + "no ip route 192.0.2.48/28 192.0.2.13", + "no ip route 192.0.2.48/28 192.0.2.14 5", ] - self.execute_module(changed=True, commands=commands) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) def test_nxos_static_routes_deletedroute(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.79/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) set_module_args( dict( config=[ - dict( - vrf="test", - address_families=[ - dict( - afi="ipv6", - routes=[ - dict( - dest="2001:db8:12::/32", - next_hops=[ - dict( - forward_router_address="2001:db8::1001", - route_name="ipv6_route", - admin_distance=3, - ), + { + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", + }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", + }, ], - ), + "dest": "192.0.2.16/28", + }, + { + "next_hops": [ + {"forward_router_address": "192.0.2.26", "tag": 12}, + ], + "dest": "192.0.2.80/28", + }, ], - ), + }, ], - ), + }, + { + "vrf": "Test", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.13"}, + { + "forward_router_address": "192.0.2.14", + "admin_distance": 5, + }, + ], + "dest": "192.0.2.48/28", + }, + ], + }, + ], + }, ], state="deleted", ), ) commands = [ - "vrf context test", - "no ipv6 route 2001:db8:12::/32 2001:db8::1001 name ipv6_route 3", + "no ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3", + "no ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2", + "no ip route 192.0.2.79/28 192.0.2.26 tag 12", + "vrf context Test", + "no ip route 192.0.2.48/28 192.0.2.13", + "no ip route 192.0.2.48/28 192.0.2.14 5", ] - self.execute_module(changed=True, commands=commands) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) def test_nxos_static_routes_rendered(self): set_module_args( @@ -369,7 +873,7 @@ class TestNxosStaticRoutesModule(TestNxosModule): next_hops=[ dict( forward_router_address="2048:ae12::/64", - interface="Eth1/4", + interface="Ethernet1/4", admin_distance=5, ), ], @@ -387,128 +891,386 @@ class TestNxosStaticRoutesModule(TestNxosModule): "ipv6 route 1200:10::/64 Ethernet1/4 2048:ae12::/64 5", ] result = self.execute_module(changed=False) - self.assertEqual(sorted(result["rendered"]), sorted(commands), result["rendered"]) + self.assertEqual(result["rendered"], commands) def test_nxos_static_routes_parsed(self): set_module_args( dict( - running_config="""ip route 192.0.2.16/28 192.0.2.24 name initial_route - vrf context test - ip route 192.0.2.96/28 192.0.2.122 vrf dest_vrf - ipv6 route 2001:db8:12::/32 2001:db8::1001 name ipv6_route 3""", + running_config=dedent( + """\ + ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.80/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ), state="parsed", ), ) result = self.execute_module(changed=False) compare_list = [ { - "vrf": "test", "address_families": [ { + "afi": "ipv4", "routes": [ { - "dest": "192.0.2.96/28", "next_hops": [ { - "dest_vrf": "dest_vrf", - "forward_router_address": "192.0.2.122", + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", + }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", }, ], + "dest": "192.0.2.16/28", + }, + { + "next_hops": [{"forward_router_address": "192.0.2.26", "tag": 12}], + "dest": "192.0.2.80/28", + }, + ], + }, + ], + }, + { + "vrf": "Test", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.13"}, + {"forward_router_address": "192.0.2.14", "admin_distance": 5}, + ], + "dest": "192.0.2.48/28", }, ], + }, + ], + }, + { + "vrf": "management", + "address_families": [ + { "afi": "ipv4", + "routes": [ + { + "next_hops": [{"forward_router_address": "192.168.255.1"}], + "dest": "0.0.0.0/0", + }, + ], }, + ], + }, + { + "vrf": "newvrf", + "address_families": [ { + "afi": "ipv4", "routes": [ { - "dest": "2001:db8:12::/32", "next_hops": [ { - "route_name": "ipv6_route", - "forward_router_address": "2001:db8::1001", - "admin_distance": 3, + "forward_router_address": "10.0.10.3", + "admin_distance": 11, + "tag": 22323, + "route_name": "test_name", + }, + ], + "dest": "10.0.10.0/25", + }, + { + "next_hops": [ + { + "forward_router_address": "10.0.11.10", + "admin_distance": 11, + "tag": 22, + }, + { + "forward_router_address": "10.0.11.12", + "admin_distance": 11, + "dest_vrf": "Test", + "tag": 22, + }, + ], + "dest": "10.0.11.0/25", + }, + { + "next_hops": [ + { + "interface": "loopback22", + "forward_router_address": "192.0.2.13", }, ], + "dest": "192.0.2.48/28", }, ], + }, + { "afi": "ipv6", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "2048:ae12::1", + "admin_distance": 5, + "dest_vrf": "dest", + }, + { + "interface": "mgmt0", + "forward_router_address": "2048:ae12::1", + "admin_distance": 11, + "tag": 22, + }, + { + "interface": "port-channel22", + "forward_router_address": "2048:ae12::1", + }, + { + "interface": "Ethernet2/1", + "forward_router_address": "2048:ae12::1", + "admin_distance": 22, + "route_name": "test_name2", + }, + ], + "dest": "2200:10::/36", + }, + ], }, ], }, { + "vrf": "trial_vrf", "address_families": [ { + "afi": "ipv4", "routes": [ { - "dest": "192.0.2.16/28", "next_hops": [ + {"forward_router_address": "192.0.2.22", "tag": 4}, { - "route_name": "initial_route", - "forward_router_address": "192.0.2.24", + "forward_router_address": "192.0.2.23", + "admin_distance": 1, + "route_name": "merged_route", }, ], + "dest": "192.0.2.64/28", }, ], - "afi": "ipv4", }, ], }, ] - self.assertEqual(result["parsed"], compare_list, result["parsed"]) + self.assertEqual(result["parsed"], compare_list) def test_nxos_static_routes_gathered(self): + self.execute_show_command.return_value = dedent( + """\ + ip route 192.0.2.17/28 192.0.2.23 name replaced_route1 3 + ip route 192.0.2.17/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2 + ip route 192.0.2.79/28 192.0.2.26 tag 12 + vrf context Test + ip route 192.0.2.48/28 192.0.2.13 + ip route 192.0.2.48/28 192.0.2.14 5 + vrf context management + ip name-server 192.168.255.1 + ip route 0.0.0.0/0 192.168.255.1 + vrf context newvrf + ip route 10.0.10.0/25 10.0.10.3 name test_name tag 22323 11 + ip route 10.0.11.0/25 10.0.11.10 tag 22 11 + ip route 10.0.11.0/25 10.0.11.12 vrf Test tag 22 11 + ip route 192.0.2.48/28 loopback22 192.0.2.13 + ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + ipv6 route 2200:10::/36 mgmt0 2048:ae12::1 tag 22 11 + ipv6 route 2200:10::/36 port-channel22 2048:ae12::1 + ipv6 route 2200:10::/36 Ethernet2/1 2048:ae12::1 name test_name2 22 + vrf context trial_vrf + ip route 192.0.2.64/28 192.0.2.22 tag 4 + ip route 192.0.2.64/28 192.0.2.23 name merged_route 1 + """, + ) set_module_args(dict(config=[], state="gathered")) result = self.execute_module(changed=False) compare_list = [ { - "vrf": "test", "address_families": [ { + "afi": "ipv4", "routes": [ { - "dest": "192.0.2.96/28", "next_hops": [ { - "dest_vrf": "dest_vrf", - "forward_router_address": "192.0.2.122", + "forward_router_address": "192.0.2.23", + "admin_distance": 3, + "route_name": "replaced_route1", }, + { + "interface": "Ethernet1/2", + "forward_router_address": "192.0.2.45", + "dest_vrf": "destinationVRF", + "route_name": "replaced_route2", + }, + ], + "dest": "192.0.2.17/28", + }, + { + "next_hops": [{"forward_router_address": "192.0.2.26", "tag": 12}], + "dest": "192.0.2.79/28", + }, + ], + }, + ], + }, + { + "vrf": "Test", + "address_families": [ + { + "afi": "ipv4", + "routes": [ + { + "next_hops": [ + {"forward_router_address": "192.0.2.13"}, + {"forward_router_address": "192.0.2.14", "admin_distance": 5}, ], + "dest": "192.0.2.48/28", }, ], + }, + ], + }, + { + "vrf": "management", + "address_families": [ + { "afi": "ipv4", + "routes": [ + { + "next_hops": [{"forward_router_address": "192.168.255.1"}], + "dest": "0.0.0.0/0", + }, + ], }, + ], + }, + { + "vrf": "newvrf", + "address_families": [ { + "afi": "ipv4", "routes": [ { - "dest": "2001:db8:12::/32", "next_hops": [ { - "route_name": "ipv6_route", - "forward_router_address": "2001:db8::1001", - "admin_distance": 3, + "forward_router_address": "10.0.10.3", + "admin_distance": 11, + "tag": 22323, + "route_name": "test_name", + }, + ], + "dest": "10.0.10.0/25", + }, + { + "next_hops": [ + { + "forward_router_address": "10.0.11.10", + "admin_distance": 11, + "tag": 22, + }, + { + "forward_router_address": "10.0.11.12", + "admin_distance": 11, + "dest_vrf": "Test", + "tag": 22, + }, + ], + "dest": "10.0.11.0/25", + }, + { + "next_hops": [ + { + "interface": "loopback22", + "forward_router_address": "192.0.2.13", }, ], + "dest": "192.0.2.48/28", }, ], + }, + { "afi": "ipv6", + "routes": [ + { + "next_hops": [ + { + "forward_router_address": "2048:ae12::1", + "admin_distance": 5, + "dest_vrf": "dest", + }, + { + "interface": "mgmt0", + "forward_router_address": "2048:ae12::1", + "admin_distance": 11, + "tag": 22, + }, + { + "interface": "port-channel22", + "forward_router_address": "2048:ae12::1", + }, + { + "interface": "Ethernet2/1", + "forward_router_address": "2048:ae12::1", + "admin_distance": 22, + "route_name": "test_name2", + }, + ], + "dest": "2200:10::/36", + }, + ], }, ], }, { + "vrf": "trial_vrf", "address_families": [ { + "afi": "ipv4", "routes": [ { - "dest": "192.0.2.16/28", "next_hops": [ + {"forward_router_address": "192.0.2.22", "tag": 4}, { - "route_name": "initial_route", - "forward_router_address": "192.0.2.24", + "forward_router_address": "192.0.2.23", + "admin_distance": 1, + "route_name": "merged_route", }, ], + "dest": "192.0.2.64/28", }, ], - "afi": "ipv4", }, ], }, diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_vsan.py index db79f8668..af9ee7ad3 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_vsan.py @@ -9,11 +9,11 @@ __metaclass__ = type import pytest -from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_vsan +from ansible_collections.cisco.nxos.plugins.modules import nxos_vsan from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson -from ..nxos_module import TestNxosModule, load_fixture, set_module_args +from .nxos_module import TestNxosModule, load_fixture, set_module_args class TestNxosVsanModule(TestNxosModule): @@ -21,7 +21,7 @@ class TestNxosVsanModule(TestNxosModule): def setUp(self): super(TestNxosVsanModule, self).setUp() - module_path = "ansible_collections.cisco.nxos.plugins.modules.storage.nxos_vsan." + module_path = "ansible_collections.cisco.nxos.plugins.modules.nxos_vsan." self.mock_run_commands = patch(module_path + "run_commands") self.run_commands = self.mock_run_commands.start() diff --git a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_zone_zoneset.py index b49dbf2fd..6afe78a5b 100644 --- a/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py +++ b/ansible_collections/cisco/nxos/tests/unit/modules/network/nxos/test_nxos_zone_zoneset.py @@ -8,10 +8,10 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_zone_zoneset +from ansible_collections.cisco.nxos.plugins.modules import nxos_zone_zoneset from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ..nxos_module import TestNxosModule, load_fixture, set_module_args +from .nxos_module import TestNxosModule, load_fixture, set_module_args class TestNxosZoneZonesetModule(TestNxosModule): @@ -19,7 +19,7 @@ class TestNxosZoneZonesetModule(TestNxosModule): def setUp(self): super(TestNxosZoneZonesetModule, self).setUp() - module_path = "ansible_collections.cisco.nxos.plugins.modules.storage.nxos_zone_zoneset." + module_path = "ansible_collections.cisco.nxos.plugins.modules.nxos_zone_zoneset." self.mock_run_commands = patch(module_path + "run_commands") self.run_commands = self.mock_run_commands.start() @@ -34,7 +34,9 @@ class TestNxosZoneZonesetModule(TestNxosModule): ) self.execute_show_cmd_zoneset = self.mock_execute_show_cmd_zoneset.start() - self.mock_execute_show_cmd_zone = patch(module_path + "ShowZone.execute_show_zone_vsan_cmd") + self.mock_execute_show_cmd_zone = patch( + module_path + "ShowZone.execute_show_zone_vsan_cmd", + ) self.execute_show_cmd_zone = self.mock_execute_show_cmd_zone.start() self.mock_execute_show_cmd_zone_status = patch( @@ -213,13 +215,20 @@ class TestNxosZoneZonesetModule(TestNxosModule): # Test zone add/removal def test_zone_add_rem(self): - a = dict(zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneB", remove=True)])]) + a = dict( + zone_zoneset_details=[ + dict(vsan=923, zone=[dict(name="zoneB", remove=True)]), + ], + ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -232,13 +241,20 @@ class TestNxosZoneZonesetModule(TestNxosModule): ) def test_zone_add_rem_1(self): - a = dict(zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneC", remove=True)])]) + a = dict( + zone_zoneset_details=[ + dict(vsan=923, zone=[dict(name="zoneC", remove=True)]), + ], + ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=False, failed=False) m = "zone 'zoneC' is not present in vsan 923" assert m in str(result["messages"]) @@ -251,7 +267,10 @@ class TestNxosZoneZonesetModule(TestNxosModule): "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -270,7 +289,10 @@ class TestNxosZoneZonesetModule(TestNxosModule): "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=False, failed=False) m = "zone 'zoneB' is already present in vsan 923" assert m in str(result["messages"]) @@ -293,7 +315,10 @@ class TestNxosZoneZonesetModule(TestNxosModule): "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -312,14 +337,19 @@ class TestNxosZoneZonesetModule(TestNxosModule): mem1 = {"pwwn": "11:11:11:11:11:11:11:11", "remove": True} mem2 = {"device_alias": "test123", "remove": True} a = dict( - zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneA", members=[mem1, mem2])])], + zone_zoneset_details=[ + dict(vsan=923, zone=[dict(name="zoneA", members=[mem1, mem2])]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -338,14 +368,19 @@ class TestNxosZoneZonesetModule(TestNxosModule): mem1 = {"pwwn": "11:11:11:11:11:11:11:11", "remove": True} mem2 = {"device_alias": "test123", "remove": True} a = dict( - zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneA1", members=[mem1, mem2])])], + zone_zoneset_details=[ + dict(vsan=923, zone=[dict(name="zoneA1", members=[mem1, mem2])]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", "shzonestatus_1.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_0.cfg", + ) result = self.execute_module(changed=False, failed=False) m = "zone 'zoneA1' is not present in vsan 923 , hence cannot remove the members" assert m in str(result["messages"]) @@ -369,7 +404,10 @@ class TestNxosZoneZonesetModule(TestNxosModule): "nxos_zone_zoneset", "shzonestatus_0.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_1.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_1.cfg", + ) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -387,13 +425,20 @@ class TestNxosZoneZonesetModule(TestNxosModule): def test_zonemem_add_rem_4(self): mem2 = {"device_alias": "test123", "devtype": "both", "remove": True} - a = dict(zone_zoneset_details=[dict(vsan=922, zone=[dict(name="zoneA", members=[mem2])])]) + a = dict( + zone_zoneset_details=[ + dict(vsan=922, zone=[dict(name="zoneA", members=[mem2])]), + ], + ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", "shzonestatus_0.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_1.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_1.cfg", + ) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -408,7 +453,9 @@ class TestNxosZoneZonesetModule(TestNxosModule): # Test zoneset add/removal def test_zoneset_add_rem(self): a = dict( - zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", remove=True)])], + zone_zoneset_details=[ + dict(vsan=922, zoneset=[dict(name="zsetname21", remove=True)]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( @@ -430,7 +477,9 @@ class TestNxosZoneZonesetModule(TestNxosModule): ) def test_zoneset_add_rem_1(self): - a = dict(zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21New")])]) + a = dict( + zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21New")])], + ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", @@ -451,7 +500,9 @@ class TestNxosZoneZonesetModule(TestNxosModule): ) def test_zoneset_add_rem_2(self): - a = dict(zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21")])]) + a = dict( + zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21")])], + ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", @@ -570,7 +621,9 @@ class TestNxosZoneZonesetModule(TestNxosModule): # Test zoneset activate/deactivate def test_zoneset_activate_deactivate(self): a = dict( - zone_zoneset_details=[dict(vsan=221, zoneset=[dict(name="zsv221", action="activate")])], + zone_zoneset_details=[ + dict(vsan=221, zoneset=[dict(name="zsv221", action="activate")]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( @@ -659,14 +712,19 @@ class TestNxosZoneZonesetModule(TestNxosModule): mem1 = {"pwwn": "21:01:00:1b:32:a1:c0:a8", "remove": True} mem2 = {"pwwn": "50:06:01:6a:47:e4:6e:59", "remove": True} a = dict( - zone_zoneset_details=[dict(vsan=221, zone=[dict(name="zv221", members=[mem1, mem2])])], + zone_zoneset_details=[ + dict(vsan=221, zone=[dict(name="zv221", members=[mem1, mem2])]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( "nxos_zone_zoneset", "shzonestatus_4.cfg", ) - self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_2.cfg") + self.execute_show_cmd_zone.return_value = load_fixture( + "nxos_zone_zoneset", + "shzone_2.cfg", + ) self.execute_show_cmd_zoneset_active.return_value = load_fixture( "nxos_zone_zoneset", "shzonesetactive_0.cfg", |