From a1a6906f770a84af989a9b3f1e36d9fe3c5df8d0 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 19 May 2022 09:53:54 -0700 Subject: [PATCH 001/166] Add .virl and collections to gitignore (#513) Add .virl and collections to gitignore These two entries are necessary as a result of the new testing strategy. The collection folder is created with linked contents by the pytest-ansible-units plugin The .virl directory is a result of using virl within the source root Reviewed-by: Nilashish Chakraborty --- .gitignore | 7 +++++++ changelogs/fragments/513.yaml | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 changelogs/fragments/513.yaml diff --git a/.gitignore b/.gitignore index 45d94ba47..1f9858c45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +# CML/virl lab cache +.virl/ + +# A collection directory, resulting from the use of the pytest-ansible-units plugin +collections/ + + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/changelogs/fragments/513.yaml b/changelogs/fragments/513.yaml new file mode 100644 index 000000000..77005db85 --- /dev/null +++ b/changelogs/fragments/513.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Add collections and .virl to .gitignore From eadd06e3552f77df7280278c845952cdf0b6e7a5 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Tue, 24 May 2022 04:59:42 -0700 Subject: [PATCH 002/166] Github action for running `ansible-test sanity` and `ansible-test units` (#459) --- .github/workflows/test.yml | 36 +++++++++++++++++++++++++++++++++++ changelogs/fragments/459.yaml | 3 +++ pyproject.toml | 7 +++++++ test-requirements.txt | 1 + 4 files changed, 47 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 changelogs/fragments/459.yaml create mode 100644 pyproject.toml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..fb2a838f8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test collection +on: + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + changelog: + uses: ansible-network/github_actions/.github/workflows/changelog.yml@main + sanity: + uses: ansible-network/github_actions/.github/workflows/sanity.yml@main + unit-galaxy: + uses: ansible-network/github_actions/.github/workflows/unit_galaxy.yml@main + unit-source: + uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main + with: + collection_pre_install: >- + git+https://github.com/ansible-collections/ansible.utils.git + git+https://github.com/ansible-collections/ansible.netcommon.git + + all_green: + if: ${{ always() }} + needs: + - changelog + - sanity + - unit-galaxy + - unit-source + runs-on: ubuntu-latest + steps: + - run: >- + python -c "assert set([ + '${{ needs.changelog.result }}', + '${{ needs.sanity.result }}', + '${{ needs.unit-galaxy.result }}', + '${{ needs.unit-source.result }}' + ]) == {'success'}" diff --git a/changelogs/fragments/459.yaml b/changelogs/fragments/459.yaml new file mode 100644 index 000000000..2d667e470 --- /dev/null +++ b/changelogs/fragments/459.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Enable unit and sanity tests using Github actions diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..4b00287ea --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[tool.black] +line-length = 79 + +[tool.pytest.ini_options] +addopts = ["-vvv", "-n", "2", "--log-level", "WARNING", "--color", "yes"] +testpaths = ["tests"] +filterwarnings = ['ignore:AnsibleCollectionFinder has already been configured'] diff --git a/test-requirements.txt b/test-requirements.txt index 67655f3da..fa48b68f8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,6 @@ black==22.3.0 ; python_version > '3.5' flake8 +git+https://github.com/ansible-community/pytest-ansible-units.git mock ; python_version < '3.5' pexpect pytest-xdist From c8add15876369c3ca09302178276716ce5c272e5 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Tue, 24 May 2022 07:58:11 -0700 Subject: [PATCH 003/166] Capitalize acronyms (#514) * Fix acronyms --- changelogs/fragments/514.yaml | 3 ++ .../targets/nxos_aaa_server/tasks/cli.yaml | 2 +- .../targets/nxos_aaa_server/tasks/main.yaml | 4 +- .../targets/nxos_aaa_server/tasks/nxapi.yaml | 2 +- .../nxos_aaa_server/tests/common/tacacs.yaml | 16 +++--- .../nxos_aaa_server_host/tasks/cli.yaml | 2 +- .../nxos_aaa_server_host/tasks/main.yaml | 4 +- .../nxos_aaa_server_host/tasks/nxapi.yaml | 2 +- .../tests/common/tacacs.yaml | 28 +++++----- .../targets/nxos_acl/tasks/cli.yaml | 2 +- .../targets/nxos_acl/tasks/main.yaml | 4 +- .../targets/nxos_acl/tasks/nxapi.yaml | 2 +- .../targets/nxos_acl/tests/common/sanity.yaml | 8 +-- .../targets/nxos_acl_interface/tasks/cli.yaml | 2 +- .../nxos_acl_interface/tasks/main.yaml | 4 +- .../nxos_acl_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 14 ++--- .../nxos_acl_interfaces/tasks/cli.yaml | 2 +- .../nxos_acl_interfaces/tasks/main.yaml | 4 +- .../nxos_acl_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/deleted.yml | 2 +- .../tests/common/empty_config.yml | 10 ++-- .../tests/common/gathered.yml | 2 +- .../tests/common/merged.yml | 2 +- .../tests/common/parsed.yml | 2 +- .../tests/common/remove_config.yaml | 10 ++-- .../nxos_acl_interfaces/tests/common/rtt.yml | 2 +- .../targets/nxos_acls/tasks/cli.yaml | 2 +- .../targets/nxos_acls/tasks/main.yaml | 4 +- .../targets/nxos_acls/tasks/nxapi.yaml | 2 +- .../targets/nxos_acls/tests/common/merged.yml | 2 +- .../nxos_acls/tests/common/remove_config.yaml | 2 +- .../targets/nxos_banner/tasks/cli.yaml | 2 +- .../targets/nxos_banner/tasks/main.yaml | 4 +- .../targets/nxos_banner/tasks/nxapi.yaml | 2 +- .../nxos_banner/tests/common/sanity.yaml | 8 +-- .../targets/nxos_bfd_global/tasks/cli.yaml | 2 +- .../targets/nxos_bfd_global/tasks/main.yaml | 4 +- .../targets/nxos_bfd_global/tasks/nxapi.yaml | 2 +- .../nxos_bfd_global/tests/common/sanity.yaml | 2 +- .../nxos_bfd_interfaces/tasks/cli.yaml | 2 +- .../nxos_bfd_interfaces/tasks/main.yaml | 4 +- .../nxos_bfd_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 4 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/deleted.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/overridden.yaml | 2 +- .../tests/common/parsed.yaml | 2 +- .../tests/common/replaced.yaml | 2 +- .../targets/nxos_bgp/tasks/cli.yaml | 2 +- .../targets/nxos_bgp/tasks/main.yaml | 4 +- .../targets/nxos_bgp/tasks/nxapi.yaml | 2 +- .../nxos_bgp/tests/common/dis_policy.yaml | 6 +-- .../targets/nxos_bgp/tests/common/hels.yaml | 6 +-- .../nxos_bgp/tests/common/isolate.yaml | 6 +-- .../targets/nxos_bgp/tests/common/param.yaml | 14 ++--- .../targets/nxos_bgp/tests/common/sanity.yaml | 16 +++--- .../nxos_bgp/tests/common/supp_fib.yaml | 10 ++-- .../nxos_bgp_address_family/tasks/cli.yaml | 2 +- .../nxos_bgp_address_family/tasks/main.yaml | 8 +-- .../nxos_bgp_address_family/tasks/nxapi.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/deleted.yaml | 6 +-- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/gathered.yaml | 2 +- .../tests/common/overridden.yaml | 4 +- .../tests/common/parsed.yaml | 4 +- .../tests/common/rendered.yaml | 2 +- .../tests/common/replaced.yaml | 2 +- .../targets/nxos_bgp_af/tasks/cli.yaml | 2 +- .../targets/nxos_bgp_af/tasks/main.yaml | 4 +- .../targets/nxos_bgp_af/tasks/nxapi.yaml | 2 +- .../nxos_bgp_af/tests/common/multisite.yaml | 20 +++---- .../nxos_bgp_af/tests/common/sanity.yaml | 38 ++++++------- .../targets/nxos_bgp_global/tasks/cli.yaml | 2 +- .../targets/nxos_bgp_global/tasks/main.yaml | 8 +-- .../targets/nxos_bgp_global/tasks/nxapi.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../nxos_bgp_global/tests/common/deleted.yaml | 4 +- .../tests/common/deleted_af.yaml | 20 +++---- .../tests/common/empty_config.yaml | 8 +-- .../tests/common/gathered.yaml | 2 +- .../nxos_bgp_global/tests/common/parsed.yaml | 4 +- .../nxos_bgp_global/tests/common/purged.yaml | 4 +- .../tests/common/rendered.yaml | 2 +- .../tests/common/replaced.yaml | 4 +- .../tests/common/replaced_af.yaml | 20 +++---- .../nxos_bgp_global/tests/common/sanity.yaml | 4 +- .../targets/nxos_bgp_neighbor/tasks/cli.yaml | 2 +- .../targets/nxos_bgp_neighbor/tasks/main.yaml | 4 +- .../nxos_bgp_neighbor/tasks/nxapi.yaml | 2 +- .../tests/common/multisite.yaml | 10 ++-- .../tests/common/sanity.yaml | 36 ++++++------- .../tasks/cli.yaml | 2 +- .../tasks/main.yaml | 8 +-- .../tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/deleted.yaml | 6 +-- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/gathered.yaml | 2 +- .../tests/common/overridden.yaml | 4 +- .../tests/common/parsed.yaml | 4 +- .../tests/common/rendered.yaml | 2 +- .../tests/common/replaced.yaml | 2 +- .../nxos_bgp_neighbor_af/tasks/cli.yaml | 2 +- .../nxos_bgp_neighbor_af/tasks/main.yaml | 4 +- .../nxos_bgp_neighbor_af/tasks/nxapi.yaml | 2 +- .../tests/common/multisite.yaml | 20 +++---- .../tests/common/sanity.yaml | 34 ++++++------ .../targets/nxos_command/tasks/cli.yaml | 2 +- .../targets/nxos_command/tasks/main.yaml | 4 +- .../targets/nxos_command/tasks/nxapi.yaml | 2 +- .../nxos_command/tests/cli/sanity.yaml | 12 ++--- .../tests/common/greaterthan.yaml | 2 +- .../tests/common/greaterthanorequal.yaml | 2 +- .../nxos_command/tests/common/lessthan.yaml | 2 +- .../tests/common/lessthanorequal.yaml | 2 +- .../nxos_command/tests/common/notequal.yaml | 2 +- .../nxos_command/tests/nxapi/sanity.yaml | 12 ++--- .../targets/nxos_config/tasks/cli.yaml | 2 +- .../targets/nxos_config/tasks/main.yaml | 4 +- .../targets/nxos_config/tasks/nxapi.yaml | 2 +- .../nxos_config/tasks/redirection.yaml | 2 +- .../targets/nxos_config/tests/cli/diff.yaml | 2 +- .../nxos_config/tests/cli/multilevel.yaml | 6 +-- .../tests/cli_config/cli_backup.yaml | 2 +- .../tests/cli_config/cli_basic.yaml | 6 +-- .../nxos_config/tests/common/backup.yaml | 2 +- .../nxos_config/tests/common/save.yaml | 2 +- .../nxos_config/tests/common/src_basic.yaml | 4 +- .../tests/common/src_match_none.yaml | 4 +- .../targets/nxos_devicealias/tasks/cli.yaml | 2 +- .../targets/nxos_devicealias/tasks/main.yaml | 6 +-- .../nxos_devicealias/tests/common/sanity.yaml | 2 +- .../targets/nxos_evpn_global/tasks/cli.yaml | 2 +- .../targets/nxos_evpn_global/tasks/main.yaml | 4 +- .../targets/nxos_evpn_global/tasks/nxapi.yaml | 2 +- .../nxos_evpn_global/tests/common/sanity.yaml | 16 +++--- .../targets/nxos_evpn_vni/tasks/cli.yaml | 2 +- .../targets/nxos_evpn_vni/tasks/main.yaml | 4 +- .../targets/nxos_evpn_vni/tasks/nxapi.yaml | 2 +- .../nxos_evpn_vni/tests/common/sanity.yaml | 6 +-- .../targets/nxos_facts/tasks/cli.yaml | 2 +- .../targets/nxos_facts/tasks/main.yaml | 4 +- .../targets/nxos_facts/tasks/nxapi.yaml | 2 +- .../nxos_facts/tests/common/sanity.yaml | 4 +- .../targets/nxos_feature/tasks/cli.yaml | 2 +- .../targets/nxos_feature/tasks/main.yaml | 4 +- .../targets/nxos_feature/tasks/nxapi.yaml | 2 +- .../nxos_feature/tests/common/configure.yaml | 8 +-- .../targets/nxos_file_copy/tasks/cli.yaml | 2 +- .../targets/nxos_file_copy/tasks/main.yaml | 6 +-- .../targets/nxos_file_copy/tasks/nxapi.yaml | 2 +- .../nxos_file_copy/tests/cli/negative.yaml | 2 +- .../nxos_file_copy/tests/cli/sanity.yaml | 8 +-- .../tests/nxapi/badtransport.yaml | 2 +- .../targets/nxos_gir/tasks/cli.yaml | 2 +- .../targets/nxos_gir/tasks/main.yaml | 4 +- .../targets/nxos_gir/tasks/nxapi.yaml | 2 +- .../tasks/cli.yaml | 2 +- .../tasks/main.yaml | 4 +- .../tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 4 +- .../targets/nxos_hostname/tasks/cli.yaml | 2 +- .../targets/nxos_hostname/tasks/main.yaml | 4 +- .../targets/nxos_hostname/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../nxos_hostname/tests/common/parsed.yaml | 2 +- .../targets/nxos_hsrp/tasks/cli.yaml | 2 +- .../targets/nxos_hsrp/tasks/main.yaml | 4 +- .../targets/nxos_hsrp/tasks/nxapi.yaml | 2 +- .../nxos_hsrp/tests/common/sanity.yaml | 14 ++--- .../nxos_hsrp_interfaces/tasks/cli.yaml | 2 +- .../nxos_hsrp_interfaces/tasks/main.yaml | 4 +- .../nxos_hsrp_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 4 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/parsed.yaml | 2 +- .../targets/nxos_igmp/tasks/cli.yaml | 2 +- .../targets/nxos_igmp/tasks/main.yaml | 4 +- .../targets/nxos_igmp/tasks/nxapi.yaml | 2 +- .../nxos_igmp/tests/common/sanity.yaml | 16 +++--- .../nxos_igmp_interface/tasks/cli.yaml | 2 +- .../nxos_igmp_interface/tasks/main.yaml | 4 +- .../nxos_igmp_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 34 ++++++------ .../targets/nxos_igmp_snooping/tasks/cli.yaml | 2 +- .../nxos_igmp_snooping/tasks/main.yaml | 4 +- .../nxos_igmp_snooping/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 8 +-- .../upgrade/copy_kick_system_images.yaml | 2 +- .../tasks/upgrade/enable_scp_server.yaml | 2 +- .../tasks/upgrade/install_os.yaml | 2 +- .../tasks/upgrade/install_system.yaml | 4 +- .../tasks/upgrade/install_with_kick.yaml | 4 +- .../tests/common/upgrade_n5k_730_N11.yaml | 2 +- .../tests/common/upgrade_n5k_733_N11.yaml | 2 +- .../tests/common/upgrade_n7k_atherton.yaml | 2 +- .../tests/common/upgrade_n7k_helsinki.yaml | 2 +- .../tests/common/upgrade_n9k_greensboro.yaml | 2 +- .../common/upgrade_n9k_greensboro_force.yaml | 2 +- .../tests/common/upgrade_n9k_hamilton.yaml | 2 +- .../targets/nxos_interface/tasks/cli.yaml | 2 +- .../targets/nxos_interface/tasks/main.yaml | 4 +- .../targets/nxos_interface/tasks/nxapi.yaml | 2 +- .../nxos_interface/tests/common/sanity.yaml | 16 +++--- .../nxos_interface_ospf/tasks/cli.yaml | 2 +- .../nxos_interface_ospf/tasks/main.yaml | 4 +- .../nxos_interface_ospf/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 14 ++--- .../targets/nxos_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_interfaces/tasks/main.yaml | 4 +- .../targets/nxos_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 4 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../nxos_interfaces/tests/common/parsed.yaml | 2 +- .../nxos_interfaces/tests/common/rtt.yaml | 2 +- .../targets/nxos_l2_interface/tasks/cli.yaml | 2 +- .../targets/nxos_l2_interface/tasks/main.yaml | 4 +- .../nxos_l2_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 16 +++--- .../targets/nxos_l2_interfaces/tasks/cli.yaml | 2 +- .../nxos_l2_interfaces/tasks/main.yaml | 4 +- .../nxos_l2_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/parsed.yaml | 2 +- .../nxos_l2_interfaces/tests/common/rtt.yaml | 2 +- .../targets/nxos_l3_interface/tasks/cli.yaml | 2 +- .../targets/nxos_l3_interface/tasks/main.yaml | 4 +- .../nxos_l3_interface/tasks/nxapi.yaml | 2 +- .../targets/nxos_l3_interfaces/tasks/cli.yaml | 2 +- .../nxos_l3_interfaces/tasks/main.yaml | 4 +- .../nxos_l3_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 4 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/multisite.yaml | 12 ++--- .../tests/common/overridden.yaml | 2 +- .../tests/common/parsed.yaml | 2 +- .../nxos_l3_interfaces/tests/common/rtt.yaml | 4 +- .../targets/nxos_lacp/tasks/cli.yaml | 2 +- .../targets/nxos_lacp/tasks/main.yaml | 4 +- .../targets/nxos_lacp/tasks/nxapi.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../nxos_lacp/tests/common/deleted.yaml | 2 +- .../nxos_lacp/tests/common/empty_config.yaml | 8 +-- .../nxos_lacp/tests/common/parsed.yaml | 2 +- .../nxos_lacp/tests/common/replaced.yaml | 2 +- .../nxos_lacp_interfaces/tasks/cli.yaml | 2 +- .../nxos_lacp_interfaces/tasks/main.yaml | 4 +- .../nxos_lacp_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/deleted.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/merged.yaml | 2 +- .../tests/common/overridden.yaml | 2 +- .../tests/common/parsed.yaml | 2 +- .../nxos_lag_interfaces/tasks/cli.yaml | 2 +- .../nxos_lag_interfaces/tasks/main.yaml | 4 +- .../nxos_lag_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/deleted.yaml | 4 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/merged.yaml | 4 +- .../tests/common/overridden.yaml | 4 +- .../tests/common/parsed.yaml | 2 +- .../tests/common/replaced.yaml | 4 +- .../targets/nxos_linkagg/tasks/cli.yaml | 2 +- .../targets/nxos_linkagg/tasks/main.yaml | 4 +- .../targets/nxos_linkagg/tasks/nxapi.yaml | 2 +- .../nxos_linkagg/tests/common/sanity.yaml | 14 ++--- .../targets/nxos_lldp/tasks/cli.yaml | 2 +- .../targets/nxos_lldp/tasks/main.yaml | 4 +- .../targets/nxos_lldp/tasks/nxapi.yaml | 2 +- .../targets/nxos_lldp_global/tasks/cli.yaml | 2 +- .../targets/nxos_lldp_global/tasks/main.yaml | 4 +- .../targets/nxos_lldp_global/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yml | 2 +- .../tests/common/_remove_config.yml | 2 +- .../nxos_lldp_global/tests/common/deleted.yml | 2 +- .../nxos_lldp_global/tests/common/parsed.yml | 2 +- .../nxos_lldp_interfaces/tasks/cli.yaml | 2 +- .../nxos_lldp_interfaces/tasks/main.yaml | 4 +- .../nxos_lldp_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/deleted.yml | 2 +- .../tests/common/gathered.yml | 2 +- .../tests/common/overridden.yml | 2 +- .../tests/common/replaced.yml | 2 +- .../nxos_lldp_interfaces/tests/common/rtt.yml | 2 +- .../targets/nxos_logging/tasks/cli.yaml | 2 +- .../targets/nxos_logging/tasks/main.yaml | 4 +- .../targets/nxos_logging/tasks/nxapi.yaml | 2 +- .../nxos_logging_global/tasks/cli.yaml | 2 +- .../nxos_logging_global/tasks/main.yaml | 4 +- .../nxos_logging_global/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/parsed.yaml | 2 +- .../targets/nxos_ntp/tasks/cli.yaml | 2 +- .../targets/nxos_ntp/tasks/main.yaml | 4 +- .../targets/nxos_ntp/tasks/nxapi.yaml | 2 +- .../targets/nxos_ntp/tests/common/sanity.yaml | 4 +- .../targets/nxos_ntp_auth/tasks/cli.yaml | 2 +- .../targets/nxos_ntp_auth/tasks/main.yaml | 4 +- .../targets/nxos_ntp_auth/tasks/nxapi.yaml | 2 +- .../nxos_ntp_auth/tests/common/sanity.yaml | 2 +- .../targets/nxos_ntp_global/tasks/cli.yaml | 2 +- .../targets/nxos_ntp_global/tasks/main.yaml | 4 +- .../targets/nxos_ntp_global/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../nxos_ntp_global/tests/common/parsed.yaml | 2 +- .../targets/nxos_ntp_options/tasks/cli.yaml | 2 +- .../targets/nxos_ntp_options/tasks/main.yaml | 4 +- .../targets/nxos_ntp_options/tasks/nxapi.yaml | 2 +- .../nxos_ntp_options/tests/common/sanity.yaml | 4 +- .../targets/nxos_nxapi/tasks/cli.yaml | 2 +- .../targets/nxos_nxapi/tasks/main.yaml | 4 +- .../targets/nxos_nxapi/tasks/nxapi.yaml | 2 +- .../nxos_nxapi/tests/cli/configure.yaml | 22 ++++---- .../targets/nxos_nxapi/tests/cli/disable.yaml | 8 +-- .../targets/nxos_nxapi/tests/cli/enable.yaml | 10 ++-- .../nxos_nxapi/tests/cli/nxapi_ssl.yaml | 54 +++++++++---------- .../nxos_nxapi/tests/nxapi/badtransport.yaml | 2 +- .../targets/nxos_ospf/tasks/cli.yaml | 2 +- .../targets/nxos_ospf/tasks/main.yaml | 4 +- .../targets/nxos_ospf/tasks/nxapi.yaml | 2 +- .../nxos_ospf/tests/common/sanity.yaml | 8 +-- .../nxos_ospf_interfaces/tasks/cli.yaml | 2 +- .../nxos_ospf_interfaces/tasks/main.yaml | 8 +-- .../nxos_ospf_interfaces/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/deleted.yaml | 8 +-- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/gathered.yaml | 2 +- .../tests/common/overridden.yaml | 4 +- .../tests/common/parsed.yaml | 4 +- .../tests/common/replaced.yaml | 4 +- .../targets/nxos_ospf_vrf/tasks/cli.yaml | 2 +- .../targets/nxos_ospf_vrf/tasks/main.yaml | 4 +- .../targets/nxos_ospf_vrf/tasks/nxapi.yaml | 2 +- .../nxos_ospf_vrf/tests/common/sanity.yaml | 10 ++-- .../targets/nxos_ospfv2/tasks/cli.yaml | 2 +- .../targets/nxos_ospfv2/tasks/main.yaml | 8 +-- .../targets/nxos_ospfv2/tasks/nxapi.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../nxos_ospfv2/tests/common/deleted.yaml | 8 +-- .../nxos_ospfv2/tests/common/overridden.yaml | 4 +- .../nxos_ospfv2/tests/common/parsed.yaml | 4 +- .../nxos_ospfv2/tests/common/replaced.yaml | 4 +- .../targets/nxos_ospfv3/tasks/cli.yaml | 2 +- .../targets/nxos_ospfv3/tasks/main.yaml | 8 +-- .../targets/nxos_ospfv3/tasks/nxapi.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../nxos_ospfv3/tests/common/deleted.yaml | 6 +-- .../tests/common/empty_config.yaml | 10 ++-- .../nxos_ospfv3/tests/common/overridden.yaml | 2 +- .../nxos_ospfv3/tests/common/parsed.yaml | 4 +- .../nxos_ospfv3/tests/common/replaced.yaml | 2 +- .../nxos_overlay_global/tasks/cli.yaml | 2 +- .../nxos_overlay_global/tasks/main.yaml | 4 +- .../nxos_overlay_global/tasks/nxapi.yaml | 2 +- .../tasks/platform/n7k/cleanup.yaml | 4 +- .../tasks/platform/n7k/setup.yaml | 8 +-- .../tests/common/sanity.yaml | 10 ++-- .../targets/nxos_pim/tasks/cli.yaml | 2 +- .../targets/nxos_pim/tasks/main.yaml | 4 +- .../targets/nxos_pim/tasks/nxapi.yaml | 2 +- .../targets/nxos_pim/tests/common/sanity.yaml | 4 +- .../targets/nxos_pim_interface/tasks/cli.yaml | 2 +- .../nxos_pim_interface/tasks/main.yaml | 4 +- .../nxos_pim_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 4 +- .../nxos_pim_rp_address/tasks/cli.yaml | 2 +- .../nxos_pim_rp_address/tasks/main.yaml | 4 +- .../nxos_pim_rp_address/tasks/nxapi.yaml | 2 +- .../tests/common/configure.yaml | 6 +-- .../targets/nxos_prefix_lists/tasks/cli.yaml | 2 +- .../targets/nxos_prefix_lists/tasks/main.yaml | 4 +- .../nxos_prefix_lists/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/deleted.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../tests/common/parsed.yaml | 2 +- .../targets/nxos_reboot/tasks/cli.yaml | 2 +- .../targets/nxos_reboot/tasks/main.yaml | 4 +- .../targets/nxos_reboot/tasks/nxapi.yaml | 2 +- .../targets/nxos_rollback/tasks/cli.yaml | 2 +- .../targets/nxos_rollback/tasks/main.yaml | 4 +- .../targets/nxos_rollback/tasks/nxapi.yaml | 2 +- .../targets/nxos_route_maps/tasks/cli.yaml | 2 +- .../targets/nxos_route_maps/tasks/main.yaml | 4 +- .../targets/nxos_route_maps/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../nxos_route_maps/tests/common/parsed.yaml | 2 +- .../targets/nxos_rpm/tasks/cli.yaml | 2 +- .../targets/nxos_rpm/tasks/main.yaml | 4 +- .../targets/nxos_rpm/tasks/nxapi.yaml | 2 +- .../targets/nxos_smoke/tasks/cli.yaml | 2 +- .../targets/nxos_smoke/tasks/main.yaml | 4 +- .../targets/nxos_smoke/tasks/nxapi.yaml | 2 +- .../nxos_smoke/tests/common/caching.yaml | 8 +-- .../tests/common/common_config.yaml | 2 +- .../targets/nxos_snapshot/tasks/cli.yaml | 2 +- .../targets/nxos_snapshot/tasks/main.yaml | 4 +- .../targets/nxos_snapshot/tasks/nxapi.yaml | 2 +- .../nxos_snapshot/tests/common/sanity.yaml | 8 +-- .../nxos_snmp_community/tasks/cli.yaml | 2 +- .../nxos_snmp_community/tasks/main.yaml | 4 +- .../nxos_snmp_community/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 4 +- .../targets/nxos_snmp_contact/tasks/cli.yaml | 2 +- .../targets/nxos_snmp_contact/tasks/main.yaml | 4 +- .../nxos_snmp_contact/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 6 +-- .../targets/nxos_snmp_host/tasks/cli.yaml | 2 +- .../targets/nxos_snmp_host/tasks/main.yaml | 4 +- .../targets/nxos_snmp_host/tasks/nxapi.yaml | 2 +- .../tests/common/sanity_snmp_v1_trap.yaml | 2 +- .../tests/common/sanity_snmp_v2_inform.yaml | 2 +- .../tests/common/sanity_snmp_v3_inform.yaml | 2 +- .../tests/common/sanity_snmp_v3_trap.yaml | 2 +- .../targets/nxos_snmp_location/tasks/cli.yaml | 2 +- .../nxos_snmp_location/tasks/main.yaml | 4 +- .../nxos_snmp_location/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 6 +-- .../targets/nxos_snmp_server/tasks/cli.yaml | 2 +- .../targets/nxos_snmp_server/tasks/main.yaml | 18 +++---- .../targets/nxos_snmp_server/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/empty_config.yaml | 10 ++-- .../nxos_snmp_server/tests/common/parsed.yaml | 2 +- .../targets/nxos_snmp_traps/tasks/cli.yaml | 2 +- .../targets/nxos_snmp_traps/tasks/main.yaml | 4 +- .../targets/nxos_snmp_traps/tasks/nxapi.yaml | 2 +- .../nxos_snmp_traps/tests/common/sanity.yaml | 6 +-- .../targets/nxos_snmp_user/tasks/cli.yaml | 2 +- .../targets/nxos_snmp_user/tasks/main.yaml | 4 +- .../targets/nxos_snmp_user/tasks/nxapi.yaml | 2 +- .../nxos_snmp_user/tests/common/sanity.yaml | 6 +-- .../targets/nxos_static_route/tasks/cli.yaml | 2 +- .../targets/nxos_static_route/tasks/main.yaml | 4 +- .../nxos_static_route/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 2 +- .../targets/nxos_static_routes/tasks/cli.yaml | 2 +- .../nxos_static_routes/tasks/main.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../tests/common/deleted.yml | 4 +- .../targets/nxos_system/tasks/cli.yaml | 2 +- .../targets/nxos_system/tasks/main.yaml | 4 +- .../targets/nxos_system/tasks/nxapi.yaml | 2 +- .../nxos_system/tests/common/sanity.yaml | 2 +- .../targets/nxos_telemetry/tasks/cli.yaml | 2 +- .../targets/nxos_telemetry/tasks/main.yaml | 10 ++-- .../targets/nxos_telemetry/tasks/nxapi.yaml | 2 +- .../nxos_telemetry/tests/common/replaced.yaml | 8 +-- .../targets/nxos_udld/tasks/cli.yaml | 2 +- .../targets/nxos_udld/tasks/main.yaml | 4 +- .../targets/nxos_udld/tasks/nxapi.yaml | 2 +- .../nxos_udld/tests/common/sanity.yaml | 4 +- .../nxos_udld_interface/tasks/cli.yaml | 2 +- .../nxos_udld_interface/tasks/main.yaml | 4 +- .../nxos_udld_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 4 +- .../targets/nxos_user/tasks/cli.yaml | 2 +- .../targets/nxos_user/tasks/main.yaml | 4 +- .../targets/nxos_user/tasks/nxapi.yaml | 2 +- .../targets/nxos_vlan/tasks/cli.yaml | 2 +- .../targets/nxos_vlan/tasks/main.yaml | 4 +- .../targets/nxos_vlan/tasks/nxapi.yaml | 2 +- .../targets/nxos_vlan/tests/common/agg.yaml | 6 +-- .../nxos_vlan/tests/common/interface.yaml | 16 +++--- .../nxos_vlan/tests/common/sanity.yaml | 22 ++++---- .../targets/nxos_vlans/tasks/cli.yaml | 2 +- .../targets/nxos_vlans/tasks/main.yaml | 4 +- .../targets/nxos_vlans/tasks/nxapi.yaml | 2 +- .../tests/common/_populate_config.yaml | 2 +- .../tests/common/_remove_config.yaml | 2 +- .../nxos_vlans/tests/common/empty_config.yaml | 10 ++-- .../nxos_vlans/tests/common/overridden.yaml | 2 +- .../nxos_vlans/tests/common/parsed.yaml | 2 +- .../targets/nxos_vlans/tests/common/rtt.yaml | 4 +- .../targets/nxos_vpc/tasks/cli.yaml | 2 +- .../targets/nxos_vpc/tasks/main.yaml | 4 +- .../targets/nxos_vpc/tasks/nxapi.yaml | 2 +- .../targets/nxos_vpc/tests/common/sanity.yaml | 20 +++---- .../targets/nxos_vpc_interface/tasks/cli.yaml | 2 +- .../nxos_vpc_interface/tasks/main.yaml | 4 +- .../nxos_vpc_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 10 ++-- .../targets/nxos_vrf/tasks/cli.yaml | 2 +- .../targets/nxos_vrf/tasks/main.yaml | 4 +- .../targets/nxos_vrf/tasks/nxapi.yaml | 2 +- .../targets/nxos_vrf/tests/common/intent.yaml | 24 ++++----- .../targets/nxos_vrf/tests/common/sanity.yaml | 18 +++---- .../targets/nxos_vrf_af/tasks/cli.yaml | 2 +- .../targets/nxos_vrf_af/tasks/main.yaml | 4 +- .../targets/nxos_vrf_af/tasks/nxapi.yaml | 2 +- .../nxos_vrf_af/tests/common/sanity.yaml | 30 +++++------ .../targets/nxos_vrf_interface/tasks/cli.yaml | 2 +- .../nxos_vrf_interface/tasks/main.yaml | 4 +- .../nxos_vrf_interface/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 8 +-- .../targets/nxos_vrrp/tasks/cli.yaml | 2 +- .../targets/nxos_vrrp/tasks/main.yaml | 4 +- .../targets/nxos_vrrp/tasks/nxapi.yaml | 2 +- .../nxos_vrrp/tests/common/sanity.yaml | 8 +-- .../targets/nxos_vsan/tasks/cli.yaml | 2 +- .../targets/nxos_vsan/tasks/main.yaml | 6 +-- .../nxos_vsan/tests/common/sanity.yaml | 6 +-- .../targets/nxos_vtp_domain/tasks/cli.yaml | 2 +- .../targets/nxos_vtp_domain/tasks/main.yaml | 4 +- .../targets/nxos_vtp_domain/tasks/nxapi.yaml | 2 +- .../nxos_vtp_domain/tests/common/sanity.yaml | 10 ++-- .../targets/nxos_vtp_password/tasks/cli.yaml | 2 +- .../targets/nxos_vtp_password/tasks/main.yaml | 4 +- .../nxos_vtp_password/tasks/nxapi.yaml | 2 +- .../tests/common/sanity.yaml | 14 ++--- .../targets/nxos_vtp_version/tasks/cli.yaml | 2 +- .../targets/nxos_vtp_version/tasks/main.yaml | 4 +- .../targets/nxos_vtp_version/tasks/nxapi.yaml | 2 +- .../nxos_vtp_version/tests/common/sanity.yaml | 12 ++--- .../targets/nxos_vxlan_vtep/tasks/cli.yaml | 2 +- .../targets/nxos_vxlan_vtep/tasks/main.yaml | 4 +- .../targets/nxos_vxlan_vtep/tasks/nxapi.yaml | 2 +- .../tasks/platform/n7k/cleanup.yaml | 4 +- .../tasks/platform/n7k/setup.yaml | 6 +-- .../tests/common/multisite.yaml | 10 ++-- .../nxos_vxlan_vtep/tests/common/sanity.yaml | 10 ++-- .../nxos_vxlan_vtep_vni/tasks/cli.yaml | 2 +- .../nxos_vxlan_vtep_vni/tasks/main.yaml | 4 +- .../nxos_vxlan_vtep_vni/tasks/nxapi.yaml | 2 +- .../tests/common/multisite.yaml | 10 ++-- .../tests/common/sanity.yaml | 16 +++--- .../targets/nxos_zone_zoneset/tasks/cli.yaml | 2 +- .../targets/nxos_zone_zoneset/tasks/main.yaml | 6 +-- .../tests/common/sanity.yaml | 6 +-- .../prepare_nxos_tests/tasks/prepare.yml | 2 +- 548 files changed, 1238 insertions(+), 1235 deletions(-) create mode 100644 changelogs/fragments/514.yaml diff --git a/changelogs/fragments/514.yaml b/changelogs/fragments/514.yaml new file mode 100644 index 000000000..243b9b0b7 --- /dev/null +++ b/changelogs/fragments/514.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Uppercase acronyms, unabbreviated abbreviations, and quoted features diff --git a/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml b/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml +++ b/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_aaa_server/tasks/main.yaml b/tests/integration/targets/nxos_aaa_server/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_aaa_server/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_aaa_server/tests/common/tacacs.yaml b/tests/integration/targets/nxos_aaa_server/tests/common/tacacs.yaml index d3bac4030..7063cc61f 100644 --- a/tests/integration/targets/nxos_aaa_server/tests/common/tacacs.yaml +++ b/tests/integration/targets/nxos_aaa_server/tests/common/tacacs.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_aaa_server tacacs.yaml sanity test -- name: Enable feature tacacs+ +- name: Enable 'feature tacacs+' cisco.nxos.nxos_feature: feature: tacacs+ state: enabled @@ -17,7 +17,7 @@ state: default - block: - - name: Configure tacacs server defaults + - name: Configure TACACS server defaults register: result cisco.nxos.nxos_aaa_server: &id001 server_type: tacacs @@ -31,7 +31,7 @@ that: - result.changed == false - - name: Configure tacacs server non defaults + - name: Configure TACACS server non defaults register: result cisco.nxos.nxos_aaa_server: &id002 server_type: tacacs @@ -50,13 +50,13 @@ - ansible.builtin.assert: *id003 - - name: Remove tacacs server configuration + - name: Remove TACACS server configuration register: result cisco.nxos.nxos_aaa_server: *id004 - ansible.builtin.assert: *id005 - - name: Configure tacacs server with global key + - name: Configure TACACS server with global key register: result cisco.nxos.nxos_aaa_server: &id006 server_type: tacacs @@ -72,7 +72,7 @@ - ansible.builtin.assert: *id003 - - name: Remove tacacs server configuration + - name: Remove TACACS server configuration register: result cisco.nxos.nxos_aaa_server: &id007 server_type: tacacs @@ -93,11 +93,11 @@ - ansible.builtin.debug: msg: connection={{ ansible_connection }} nxos_aaa_server failure detected always: - - name: Remove tacacs server configuration + - name: Remove TACACS server configuration register: result cisco.nxos.nxos_aaa_server: *id004 - - name: Disable feature tacacs+ + - name: Disable 'feature tacacs+' cisco.nxos.nxos_feature: feature: tacacs+ state: disabled diff --git a/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml b/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml +++ b/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_aaa_server_host/tasks/main.yaml b/tests/integration/targets/nxos_aaa_server_host/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tasks/main.yaml +++ b/tests/integration/targets/nxos_aaa_server_host/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml b/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml b/tests/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml index 04fdf684c..0258db28b 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml +++ b/tests/integration/targets/nxos_aaa_server_host/tests/common/tacacs.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_aaa_server_host tacacs.yaml sanity test -- name: Enable feature tacacs+ +- name: Enable 'feature tacacs+' cisco.nxos.nxos_feature: feature: tacacs+ state: enabled @@ -15,7 +15,7 @@ state: absent - block: - - name: Configure tacacs server defaults + - name: Configure TACACS server defaults register: result cisco.nxos.nxos_aaa_server_host: &id001 server_type: tacacs @@ -34,7 +34,7 @@ that: - result.changed == false - - name: Remove tacacs server configuration + - name: Remove TACACS server configuration register: result cisco.nxos.nxos_aaa_server_host: *id002 @@ -46,7 +46,7 @@ - ansible.builtin.assert: *id004 - - name: Configure tacacs server non defaults + - name: Configure TACACS server non defaults register: result cisco.nxos.nxos_aaa_server_host: &id005 server_type: tacacs @@ -63,7 +63,7 @@ - ansible.builtin.assert: *id004 - - name: Configure some defaults on tacacs server + - name: Configure some defaults on TACACS server register: result cisco.nxos.nxos_aaa_server_host: &id006 server_type: tacacs @@ -80,14 +80,14 @@ - ansible.builtin.assert: *id004 - - name: Configure tacacs server with clear text pwd + - name: Configure TACACS server with clear text pwd register: result cisco.nxos.nxos_aaa_server_host: &id007 server_type: tacacs address: 8.8.8.8 host_timeout: 25 tacacs_port: default - encrypt_type: 00 + encrypt_type: 0 key: hello state: present @@ -99,13 +99,13 @@ - ansible.builtin.assert: *id003 - - name: Remove tacacs server configuration + - name: Remove TACACS server configuration register: result cisco.nxos.nxos_aaa_server_host: *id002 - ansible.builtin.assert: *id003 - - name: Configure tacacs server with type 7 encryption + - name: Configure TACACS server with type 7 encryption register: result cisco.nxos.nxos_aaa_server_host: &id008 server_type: tacacs @@ -124,7 +124,7 @@ - ansible.builtin.assert: *id004 - - name: Configure tacacs server with new type 7 encryption key + - name: Configure TACACS server with new type 7 encryption key register: result cisco.nxos.nxos_aaa_server_host: &id009 server_type: tacacs @@ -146,7 +146,7 @@ - ansible.builtin.assert: *id004 - - name: Configure tacacs server with default key + - name: Configure TACACS server with default key register: result cisco.nxos.nxos_aaa_server_host: &id010 server_type: tacacs @@ -165,7 +165,7 @@ - ansible.builtin.assert: *id004 - - name: Configure tacacs server with all def + - name: Configure TACACS server with all def register: result cisco.nxos.nxos_aaa_server_host: &id011 server_type: tacacs @@ -186,11 +186,11 @@ - ansible.builtin.debug: msg: connection={{ ansible_connection }} nxos_aaa_server_host failure detected always: - - name: Remove tacacs server configuration + - name: Remove TACACS server configuration register: result cisco.nxos.nxos_aaa_server_host: *id002 - - name: Disable feature tacacs+ + - name: Disable 'feature tacacs+' cisco.nxos.nxos_feature: feature: tacacs+ state: disabled diff --git a/tests/integration/targets/nxos_acl/tasks/cli.yaml b/tests/integration/targets/nxos_acl/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_acl/tasks/cli.yaml +++ b/tests/integration/targets/nxos_acl/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_acl/tasks/main.yaml b/tests/integration/targets/nxos_acl/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_acl/tasks/main.yaml +++ b/tests/integration/targets/nxos_acl/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_acl/tasks/nxapi.yaml b/tests/integration/targets/nxos_acl/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_acl/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_acl/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_acl/tests/common/sanity.yaml b/tests/integration/targets/nxos_acl/tests/common/sanity.yaml index c9ec083bf..59670ca1d 100644 --- a/tests/integration/targets/nxos_acl/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_acl/tests/common/sanity.yaml @@ -141,7 +141,7 @@ - ansible.builtin.assert: *id004 -- name: Change ace 30 options +- name: Change ACE 30 options register: result cisco.nxos.nxos_acl: &id008 name: TEST_ACL @@ -183,7 +183,7 @@ - ansible.builtin.assert: *id004 -- name: Change ace 40 +- name: Change ACE 40 register: result cisco.nxos.nxos_acl: &id010 name: TEST_ACL @@ -203,7 +203,7 @@ - ansible.builtin.assert: *id004 -- name: Remove ace 30 +- name: Remove ACE 30 register: result cisco.nxos.nxos_acl: &id011 name: TEST_ACL @@ -218,7 +218,7 @@ - ansible.builtin.assert: *id004 -- name: Remove acl +- name: Remove ACL register: result cisco.nxos.nxos_acl: *id012 diff --git a/tests/integration/targets/nxos_acl_interface/tasks/cli.yaml b/tests/integration/targets/nxos_acl_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_acl_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_acl_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_acl_interface/tasks/main.yaml b/tests/integration/targets/nxos_acl_interface/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_acl_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_acl_interface/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml index 11cc26177..3b7804ce2 100644 --- a/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml @@ -25,14 +25,14 @@ - interface {{ intname }} match: none -- name: "Setup: cleanup possibly existing acl" +- name: "Setup: cleanup possibly existing ACL" ignore_errors: true cisco.nxos.nxos_acl: &id008 name: ANSIBLE_ACL seq: 10 state: delete_acl -- name: Configure supporting acl +- name: Configure supporting ACL cisco.nxos.nxos_acl: name: ANSIBLE_ACL seq: 10 @@ -42,7 +42,7 @@ dest: any - block: - - name: Configure acl interface egress + - name: Configure ACL interface egress register: result cisco.nxos.nxos_acl_interface: &id001 name: ANSIBLE_ACL @@ -62,7 +62,7 @@ that: - result.changed == false - - name: Configure acl interface ingress + - name: Configure ACL interface ingress register: result cisco.nxos.nxos_acl_interface: &id003 name: ANSIBLE_ACL @@ -78,7 +78,7 @@ - ansible.builtin.assert: *id004 - - name: Cleanup acl interface egress + - name: Cleanup ACL interface egress register: result cisco.nxos.nxos_acl_interface: &id005 name: ANSIBLE_ACL @@ -94,7 +94,7 @@ - ansible.builtin.assert: *id004 - - name: Cleanup acl interface ingress + - name: Cleanup ACL interface ingress register: result cisco.nxos.nxos_acl_interface: &id006 name: ANSIBLE_ACL @@ -114,7 +114,7 @@ ignore_errors: true cisco.nxos.nxos_config: *id007 always: - - name: Remove possible configured acl + - name: Remove possible configured ACL ignore_errors: true cisco.nxos.nxos_acl: *id008 diff --git a/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml index b551048ee..f41fb7360 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_acl_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_acl_interfaces/tasks/main.yaml index 3b432ce65..4384d22ce 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tasks/main.yaml @@ -4,12 +4,12 @@ lines: "no system default switchport" connection: ansible.netcommon.network_cli -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml index c787c9fb9..86c82adda 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/deleted.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/deleted.yml index b0e8739f8..2f5ff4da4 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/deleted.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/deleted.yml @@ -31,7 +31,7 @@ config: state: deleted - - name: Gather acl interfaces facts + - name: Gather ACL interfaces facts cisco.nxos.nxos_facts: &id001 gather_subset: - "!all" diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/empty_config.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/empty_config.yml index 9e50577d3..35b54f476 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/empty_config.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/empty_config.yml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_acl_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_acl_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_acl_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_acl_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_acl_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_acl_interfaces: diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/gathered.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/gathered.yml index d8b26d58b..f0130fe7d 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/gathered.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/gathered.yml @@ -5,7 +5,7 @@ - ansible.builtin.include_tasks: populate_config.yaml - block: - - name: Gather acl interfaces facts + - name: Gather ACL interfaces facts cisco.nxos.nxos_facts: gather_subset: - "!all" diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/merged.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/merged.yml index 1f9a195eb..0874a0bdf 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/merged.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/merged.yml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: populate_acl.yaml - block: - - name: Gather acl interfaces facts + - name: Gather ACL interfaces facts cisco.nxos.nxos_facts: gather_subset: - "!all" diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/parsed.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/parsed.yml index 3046e18ef..0617a97b3 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/parsed.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/parsed.yml @@ -3,7 +3,7 @@ msg: Start nxos_acl_interfaces parsed integration tests connection={{ansible_connection}}" - block: - - name: Gather acl interfaces facts + - name: Gather ACL interfaces facts cisco.nxos.nxos_facts: gather_subset: - "!all" diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml index 91ad65dec..3cad7ce53 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config - 1 +- name: Remove configuration - 1 cisco.nxos.nxos_config: lines: - "no ip access-list ACL1v4" @@ -11,7 +11,7 @@ - " no ipv6 traffic-filter ACL1v6 in" ignore_errors: true -- name: Remove config - 2 +- name: Remove configuration - 2 cisco.nxos.nxos_config: lines: - no ip access-group ACL1v4 out @@ -19,21 +19,21 @@ parents: interface Ethernet1/5 ignore_errors: true -- name: Remove config - 3 +- name: Remove configuration - 3 cisco.nxos.nxos_config: lines: - no ip access-group ACL1v4 out parents: interface Ethernet1/3 ignore_errors: true -- name: Remove config - 4 +- name: Remove configuration - 4 cisco.nxos.nxos_config: lines: - no ip access-group NewACLv4 out parents: interface Ethernet1/4 ignore_errors: true -- name: Remove config - 5 +- name: Remove configuration - 5 cisco.nxos.nxos_config: lines: - no switchport diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml b/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml index b86613085..90f72fb39 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/rtt.yml @@ -89,7 +89,7 @@ config: "{{ ansible_facts['network_resources']['acl_interfaces'] }}" state: overridden - - name: Assert that config was reverted + - name: Assert that configuration was reverted ansible.builtin.assert: that: - result.changed==True diff --git a/tests/integration/targets/nxos_acls/tasks/cli.yaml b/tests/integration/targets/nxos_acls/tasks/cli.yaml index 95d6a016b..c34726ef5 100644 --- a/tests/integration/targets/nxos_acls/tasks/cli.yaml +++ b/tests/integration/targets/nxos_acls/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_acls/tasks/main.yaml b/tests/integration/targets/nxos_acls/tasks/main.yaml index c41f7b939..f900849c2 100644 --- a/tests/integration/targets/nxos_acls/tasks/main.yaml +++ b/tests/integration/targets/nxos_acls/tasks/main.yaml @@ -6,12 +6,12 @@ - "system default switchport shutdown" connection: ansible.netcommon.network_cli -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_acls/tasks/nxapi.yaml b/tests/integration/targets/nxos_acls/tasks/nxapi.yaml index fe9d48a7c..e0ebc3f54 100644 --- a/tests/integration/targets/nxos_acls/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_acls/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_acls/tests/common/merged.yml b/tests/integration/targets/nxos_acls/tests/common/merged.yml index 2f8945eb4..874a2ad9d 100644 --- a/tests/integration/targets/nxos_acls/tests/common/merged.yml +++ b/tests/integration/targets/nxos_acls/tests/common/merged.yml @@ -80,7 +80,7 @@ that: - result.changed == false - - name: Update one parameter of an existing ace with state merged (should fail) + - name: Update one parameter of an existing ACE with state merged (should fail) register: result cisco.nxos.nxos_acls: config: diff --git a/tests/integration/targets/nxos_acls/tests/common/remove_config.yaml b/tests/integration/targets/nxos_acls/tests/common/remove_config.yaml index 24f7b9d02..17c6b5bc4 100644 --- a/tests/integration/targets/nxos_acls/tests/common/remove_config.yaml +++ b/tests/integration/targets/nxos_acls/tests/common/remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "no ip access-list ACL1v4" diff --git a/tests/integration/targets/nxos_banner/tasks/cli.yaml b/tests/integration/targets/nxos_banner/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_banner/tasks/cli.yaml +++ b/tests/integration/targets/nxos_banner/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_banner/tasks/main.yaml b/tests/integration/targets/nxos_banner/tasks/main.yaml index 352048df1..865cff2cb 100644 --- a/tests/integration/targets/nxos_banner/tasks/main.yaml +++ b/tests/integration/targets/nxos_banner/tasks/main.yaml @@ -4,12 +4,12 @@ banner_exec_image_ok: false banner_motd_image_ok: false -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_banner/tasks/nxapi.yaml b/tests/integration/targets/nxos_banner/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_banner/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_banner/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_banner/tests/common/sanity.yaml b/tests/integration/targets/nxos_banner/tests/common/sanity.yaml index 2ee7b9a52..93d0963b7 100644 --- a/tests/integration/targets/nxos_banner/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_banner/tests/common/sanity.yaml @@ -47,12 +47,12 @@ when: banner_exec_image_ok == True - block: - - name: Setup motd + - name: Setup MOTD cisco.nxos.nxos_banner: &id004 banner: motd state: absent - - name: Set motd + - name: Set MOTD register: result cisco.nxos.nxos_banner: &id003 banner: motd @@ -64,7 +64,7 @@ - result.changed == true - "'banner motd @\nJunk motd banner\nover multiple lines\n@' in result.commands" - - name: Set motd again (idempotent) + - name: Set MOTD again (idempotent) register: result cisco.nxos.nxos_banner: *id003 @@ -72,7 +72,7 @@ that: - result.changed == false - - name: Teardown motd + - name: Teardown MOTD cisco.nxos.nxos_banner: *id004 when: banner_motd_image_ok == True diff --git a/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml b/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bfd_global/tasks/main.yaml b/tests/integration/targets/nxos_bfd_global/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_bfd_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bfd_global/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bfd_global/tests/common/sanity.yaml b/tests/integration/targets/nxos_bfd_global/tests/common/sanity.yaml index fa720b318..48322a822 100644 --- a/tests/integration/targets/nxos_bfd_global/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_bfd_global/tests/common/sanity.yaml @@ -87,7 +87,7 @@ lines: interface loopback1 match: none -- name: Feature bfd init +- name: "'feature bfd' init" delay: 3 retries: 1 register: result diff --git a/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml index ba1eff1cd..9aa0d8690 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml index 697b31185..6c260fafb 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config - 1 +- name: Populate configuration - 1 cisco.nxos.nxos_config: lines: - "feature bfd" @@ -7,7 +7,7 @@ - " no switchport" - " no bfd" -- name: Populate config - 2 +- name: Populate configuration - 2 cisco.nxos.nxos_config: lines: - "interface {{ nxos_int2 }}" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml index 37c4a3d4d..b1fa61c19 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "no feature bfd" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml index af98b6c9f..7c07064b9 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml @@ -26,7 +26,7 @@ - "interface {{ test_int1 }}" - " no switchport" - - name: Setup initial bfd state + - name: Setup initial BFD state cisco.nxos.nxos_bfd_interfaces: config: - name: "{{ test_int1 }}" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml index 3f1459db0..037de3892 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_bfd_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bfd_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bfd_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bfd_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bfd_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bfd_interfaces: diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml index 1d939a725..8b3a66d4a 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml @@ -38,7 +38,7 @@ - "{{ test_int1 }}" - "{{ test_int2 }}" - - name: Setup initial bfd state + - name: Setup initial BFD state cisco.nxos.nxos_bfd_interfaces: config: - name: "{{ test_int1 }}" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml index 188bc1551..4cc9c6b38 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_bfd_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml index ed97d9c8d..498ee7d9c 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml @@ -26,7 +26,7 @@ - "interface {{ test_int1 }}" - " no switchport" - - name: Setup initial bfd state + - name: Setup initial BFD state cisco.nxos.nxos_bfd_interfaces: config: - name: "{{ test_int1 }}" diff --git a/tests/integration/targets/nxos_bgp/tasks/cli.yaml b/tests/integration/targets/nxos_bgp/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_bgp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp/tasks/main.yaml b/tests/integration/targets/nxos_bgp/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_bgp/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml b/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml index 548e2d894..0f4bd883e 100644 --- a/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml +++ b/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml @@ -15,13 +15,13 @@ bgp_disable_policy: true when: imagetag is not search("A8|D1") -- name: Disable feature bgp +- name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp @@ -75,7 +75,7 @@ - ansible.builtin.debug: msg: Tests can fail on A8 or helsinki images always: - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_bgp/tests/common/hels.yaml b/tests/integration/targets/nxos_bgp/tests/common/hels.yaml index c052cf65c..65b7c7251 100644 --- a/tests/integration/targets/nxos_bgp/tests/common/hels.yaml +++ b/tests/integration/targets/nxos_bgp/tests/common/hels.yaml @@ -15,14 +15,14 @@ test_helsinki: true when: imagetag is not search("D1") -- name: Disable feature bgp +- name: Disable 'feature bgp' ignore_errors: true when: test_helsinki cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true when: test_helsinki cisco.nxos.nxos_feature: @@ -90,7 +90,7 @@ - ansible.builtin.debug: msg: Tests can fail on helsinki images always: - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true when: test_helsinki cisco.nxos.nxos_feature: diff --git a/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml b/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml index d46d4fd75..de4bafb11 100644 --- a/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml +++ b/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml @@ -15,13 +15,13 @@ bgp_isolate: true when: imagetag is not search("A8") -- name: Disable feature bgp +- name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp @@ -71,7 +71,7 @@ - ansible.builtin.debug: msg: Tests can fail on A8 images always: - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_bgp/tests/common/param.yaml b/tests/integration/targets/nxos_bgp/tests/common/param.yaml index ed2d3942a..a4d7c2ffa 100644 --- a/tests/integration/targets/nxos_bgp/tests/common/param.yaml +++ b/tests/integration/targets/nxos_bgp/tests/common/param.yaml @@ -2,20 +2,20 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_bgp parameter test -- name: Disable feature bgp +- name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: enabled - block: - - name: Set multi vrf params + - name: Set multi VRF params with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp: &id001 @@ -46,7 +46,7 @@ that: - result.changed == false - - name: Reset multi vrf params + - name: Reset multi VRF params with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp: &id003 @@ -209,7 +209,7 @@ - ansible.builtin.assert: *id004 - - name: Set default vrf params + - name: Set default VRF params register: result cisco.nxos.nxos_bgp: &id013 asn: 65535 @@ -230,7 +230,7 @@ - ansible.builtin.assert: *id004 - - name: Reset default vrf params + - name: Reset default VRF params register: result cisco.nxos.nxos_bgp: &id014 asn: 65535 @@ -248,7 +248,7 @@ - ansible.builtin.assert: *id004 always: - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml index a9cfadbf5..dc2b018cc 100644 --- a/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml @@ -17,7 +17,7 @@ isolate: false when: platform is not match("N35") -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp @@ -31,7 +31,7 @@ state: absent - block: - - name: Configure bgp defaults + - name: Configure BGP defaults register: result cisco.nxos.nxos_bgp: &id001 asn: 65535 @@ -50,7 +50,7 @@ that: - result.changed == false - - name: Remove bgp + - name: Remove BGP register: result cisco.nxos.nxos_bgp: *id002 @@ -62,7 +62,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp non defaults + - name: Configure BGP non defaults register: result cisco.nxos.nxos_bgp: &id005 asn: 65535 @@ -107,7 +107,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP register: result cisco.nxos.nxos_bgp: *id002 @@ -119,16 +119,16 @@ - ansible.builtin.assert: *id004 - - name: Disable feature bgp + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled rescue: - - name: Cleanup bgp + - name: Cleanup BGP ignore_errors: true cisco.nxos.nxos_bgp: *id002 - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml b/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml index 0238c8738..ead5a515e 100644 --- a/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml +++ b/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml @@ -20,13 +20,13 @@ bgp_suppress_fib_supported: true when: imagetag is not search("A8|D1|I2|I4") -- name: Disable feature bgp +- name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp @@ -73,7 +73,7 @@ - ansible.builtin.assert: *id004 when: bgp_best_path_limit - - name: Set suppress fib + - name: Set suppress FIB register: result cisco.nxos.nxos_bgp: &id005 asn: 65535 @@ -90,7 +90,7 @@ - ansible.builtin.assert: *id004 when: bgp_suppress_fib_supported - - name: Reset suppress fib + - name: Reset suppress FIB register: result cisco.nxos.nxos_bgp: &id006 asn: 65535 @@ -110,7 +110,7 @@ - ansible.builtin.debug: msg: Tests can fail on I2/I4/A8/Fretta or helsinki images always: - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml b/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml index 55f769a3b..269a6496c 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml @@ -1,23 +1,23 @@ --- -- name: Enable bgp feature +- name: Enable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp vars: ansible_connection: ansible.netcommon.network_cli - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi always: - - name: Disable bgp feature + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled diff --git a/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/_remove_config.yaml index 9831b3d41..af7092576 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove pre-existing bgp configurations +- name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: lines: - no router bgp 65536 diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/deleted.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/deleted.yaml index 2b10e4f8a..5f068d665 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/deleted.yaml @@ -18,7 +18,7 @@ ansible_connection: ansible.netcommon.network_cli - block: - - name: Delete bgp configs handled by this module + - name: Delete BGP configs handled by this module cisco.nxos.nxos_bgp_address_family: config: as_number: 65536 @@ -53,7 +53,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - - name: Delete all bgp configs handled by this module + - name: Delete all BGP configs handled by this module cisco.nxos.nxos_bgp_address_family: &id001 state: deleted register: result @@ -73,7 +73,7 @@ that: - deleted_all['after'] == result['after'] - - name: Delete all bgp configs handled by this module (idempotent) + - name: Delete all BGP configs handled by this module (idempotent) cisco.nxos.nxos_bgp_address_family: *id001 register: result diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/empty_config.yaml index 46fd2c30a..5b9ff2f70 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_bgp_address_family empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_address_family: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_address_family: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_address_family: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_address_family: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_address_family: diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/gathered.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/gathered.yaml index ab493f7f2..bc7e63c64 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/gathered.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/gathered.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Gather bgp facts using gathered + - name: Gather BGP facts using gathered register: result cisco.nxos.nxos_bgp_address_family: state: gathered diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/overridden.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/overridden.yaml index 5ff613ab0..8aa99e45f 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/overridden.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Override all bgp af configuration with provided configuration + - name: Override all BGP AF configuration with provided configuration cisco.nxos.nxos_bgp_address_family: &overridden config: as_number: 65536 @@ -43,7 +43,7 @@ - "{{ overridden['after']['address_family'] | symmetric_difference(result['after']['address_family']) |length == 0 }}" - overridden['after']['as_number'] == result['after']['as_number'] - - name: Replace device configurations of listed ospf processes with provided configurarions (idempotent) + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result cisco.nxos.nxos_bgp_address_family: *overridden diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/parsed.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/parsed.yaml index 670f0d8ab..6636605aa 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/parsed.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxos_bgp_address_family parsed integration tests on connection={{ ansible_connection }} -- name: Parse externally provided bgp config +- name: Parse externally provided BGP configuration register: result cisco.nxos.nxos_bgp_address_family: running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after']['address_family'] | symmetric_difference(result['parsed']['address_family']) |length == 0 }}" diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/rendered.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/rendered.yaml index 47b6e583b..2f405b283 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/rendered.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/rendered.yaml @@ -45,7 +45,7 @@ that: - "{{ merged['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" -- name: Gather bgp facts +- name: Gather BGP facts cisco.nxos.nxos_bgp_address_family: state: gathered register: result diff --git a/tests/integration/targets/nxos_bgp_address_family/tests/common/replaced.yaml b/tests/integration/targets/nxos_bgp_address_family/tests/common/replaced.yaml index aa2e6967b..d6cb9d3dc 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tests/common/replaced.yaml @@ -48,7 +48,7 @@ - "{{ replaced['after']['address_family'] | symmetric_difference(result['after']['address_family']) |length == 0 }}" - replaced['after']['as_number'] == result['after']['as_number'] - - name: Replace device configurations of listed ospf processes with provided configurarions (idempotent) + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result cisco.nxos.nxos_bgp_address_family: *replaced diff --git a/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_af/tasks/main.yaml b/tests/integration/targets/nxos_bgp_af/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_bgp_af/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_af/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml b/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml index e53b8675f..93eb7654c 100644 --- a/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_bgp_af multisite sanity test -- name: Enable feature bgp - multisite +- name: Enable 'feature bgp' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: enabled -- name: Enable feature nv overlay - multisite +- name: Enable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay @@ -20,7 +20,7 @@ asn: 65535 state: absent -- name: Enable nv overlay evpn - multisite +- name: Enable NV overlay EVPN - multisite when: platform is search('N9K') ignore_errors: true cisco.nxos.nxos_config: @@ -35,7 +35,7 @@ - evpn multisite border-gateway 10 - block: - - name: Configure bgp_af route target name + - name: Configure BGP_AF route target name register: result cisco.nxos.nxos_bgp_af: &id001 asn: 65535 @@ -56,7 +56,7 @@ that: - result.changed == false - - name: Configure bgp_af route target default + - name: Configure BGP_AF route target default register: result cisco.nxos.nxos_bgp_af: &id003 asn: 65535 @@ -73,7 +73,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp_af 1 route target all + - name: Configure BGP_AF 1 route target all register: result cisco.nxos.nxos_bgp_af: &id005 asn: 65535 @@ -90,7 +90,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp - route target + - name: Remove BGP - route target register: result cisco.nxos.nxos_bgp_af: asn: 65535 @@ -107,13 +107,13 @@ - no evpn multisite border-gateway 10 when: multiout is not search("Invalid command") -- name: Disable feature bgp - multisite +- name: Disable 'feature bgp' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Disable feature nv overlay - multisite +- name: Disable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay @@ -122,7 +122,7 @@ - ansible.builtin.pause: seconds: 5 -- name: Remove nv overlay evpn - multisite +- name: Remove NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml index 0a9c13573..fa06c19f9 100644 --- a/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml @@ -7,13 +7,13 @@ advertise_l2vpn_evpn: true when: platform is search('N9K') -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: enabled -- name: Enable feature nv overlay +- name: Enable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay @@ -26,13 +26,13 @@ state: absent - block: - - name: Enable nv overlay evpn + - name: Enable NV overlay EVPN when: platform is search('N9K') cisco.nxos.nxos_config: lines: - nv overlay evpn - - name: Configure bgp_af 1 + - name: Configure BGP_AF 1 register: result cisco.nxos.nxos_bgp_af: &id001 asn: 65535 @@ -54,7 +54,7 @@ that: - result.changed == false - - name: Remove bgp + - name: Remove BGP register: result cisco.nxos.nxos_bgp_af: asn: 65535 @@ -65,7 +65,7 @@ - ansible.builtin.assert: *id002 - - name: Configure bgp_af 2 + - name: Configure BGP_AF 2 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id003 @@ -91,7 +91,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp_af def2 + - name: Configure BGP_AF def2 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id005 @@ -117,7 +117,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id008 @@ -129,7 +129,7 @@ - ansible.builtin.assert: *id002 - - name: Configure bgp_af 3 + - name: Configure BGP_AF 3 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id006 @@ -159,7 +159,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp_af def3 + - name: Configure BGP_AF def3 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id007 @@ -189,14 +189,14 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: *id008 - ansible.builtin.assert: *id002 - - name: Configure bgp_af 4 + - name: Configure BGP_AF 4 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id009 @@ -241,7 +241,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp_af 5 + - name: Configure BGP_AF 5 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id010 @@ -273,7 +273,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp_af def5 + - name: Configure BGP_AF def5 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: &id011 @@ -300,7 +300,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_af: *id008 @@ -314,16 +314,16 @@ - ansible.builtin.assert: *id004 rescue: - - name: Cleanup bgp + - name: Cleanup BGP ignore_errors: true cisco.nxos.nxos_bgp: *id012 always: - - name: Disable feature bgp + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled - - name: Disable feature nv overlay + - name: Disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay @@ -332,7 +332,7 @@ - ansible.builtin.pause: seconds: 5 - - name: Remove nv overlay evpn + - name: Remove NV overlay EVPN when: platform is search('N9K') cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index 9d9af9c38..91bc82705 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Enable bgp feature +- name: Enable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp vars: @@ -10,18 +10,18 @@ lines: feature fabric forwarding - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi always: - - name: Disable bgp feature + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled diff --git a/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/_remove_config.yaml index 9831b3d41..af7092576 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove pre-existing bgp configurations +- name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: lines: - no router bgp 65536 diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/deleted.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/deleted.yaml index fc98c5968..9f9f4dd87 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/deleted.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Delete bgp configs handled by this module + - name: Delete BGP configs handled by this module cisco.nxos.nxos_bgp_global: &id001 state: deleted register: result @@ -30,7 +30,7 @@ that: - deleted['after'] == result['after'] - - name: Delete bgp configs handled by this module (idempotent) + - name: Delete BGP configs handled by this module (idempotent) register: result cisco.nxos.nxos_bgp_global: *id001 diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/deleted_af.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/deleted_af.yaml index 750cc5365..32ee63728 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/deleted_af.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/deleted_af.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: Start nxos_bgp_global deleted_af integration tests connection={{ ansible_connection}} -- name: Remove pre-existing bgp configurations +- name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: &remove lines: - no router bgp 65536 ignore_errors: true -- name: "Setup - 1 (add neighbor with af config)" +- name: "Setup - 1 (add neighbor with AF config)" cisco.nxos.nxos_config: lines: - "router bgp 65536" @@ -26,7 +26,7 @@ - " remote-as 65537" - block: - - name: Remove a neighbor having af configurations (should fail) + - name: Remove a neighbor having AF configurations (should fail) cisco.nxos.nxos_bgp_global: &deleted state: deleted register: result @@ -38,11 +38,11 @@ - result.failed == True - "'Neighbor 203.0.113.2 has address-family configurations. Please use the nxos_bgp_neighbor_af module to remove those first.' in result.msg" - - name: Remove pre-existing bgp configurations + - name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: *remove ignore_errors: true - - name: "Setup - 2 (add neighbor with af config under a vrf)" + - name: "Setup - 2 (add neighbor with AF configuration under a vrf)" cisco.nxos.nxos_config: lines: - "router bgp 65536" @@ -61,7 +61,7 @@ - " low-memory exempt" - " neighbor-down fib-accelerate" - - name: Remove a neighbor under a vrf having af configurations (should fail) + - name: Remove a neighbor under a VRF having AF configurations (should fail) cisco.nxos.nxos_bgp_global: *deleted register: result ignore_errors: true @@ -72,11 +72,11 @@ - result.failed == True - "'VRF site-1 has address-family configurations. Please use the nxos_bgp_af module to remove those first.' in result.msg" - - name: Remove pre-existing bgp configurations + - name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: *remove ignore_errors: true - - name: "Setup - 3 (add a vrf with af config)" + - name: "Setup - 3 (add a VRF with AF config)" cisco.nxos.nxos_config: lines: - "router bgp 65536" @@ -97,7 +97,7 @@ - "vrf site-2" - " neighbor-down fib-accelerate" - - name: Remove a neighbor under a vrf having af configurations (should fail) + - name: Remove a neighbor under a VRF having AF configurations (should fail) cisco.nxos.nxos_bgp_global: *deleted register: result ignore_errors: true @@ -109,5 +109,5 @@ - "'VRF site-1 has address-family configurations. Please use the nxos_bgp_af module to remove those first.' in result.msg" always: - - name: Remove pre-existing bgp configurations + - name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: *remove diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/empty_config.yaml index 0305bd0cd..05b95e484 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_bgp_global empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_global: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_global: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_global: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_global: diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/gathered.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/gathered.yaml index 073df3341..7b4d28a51 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/gathered.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/gathered.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Gather bgp facts using gathered + - name: Gather BGP facts using gathered register: result cisco.nxos.nxos_bgp_global: state: gathered diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/parsed.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/parsed.yaml index f27bf52ab..73da9ca88 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/parsed.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxos_bgp_global parsed integration tests on connection={{ ansible_connection }} -- name: Parse externally provided bgp config +- name: Parse externally provided BGP configuration register: result cisco.nxos.nxos_bgp_global: running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - merged['after'] == result['parsed'] diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/purged.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/purged.yaml index eaffe33ce..c0288a5bc 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/purged.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/purged.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Delete all bgp config from the device + - name: Delete all BGP configuration from the device cisco.nxos.nxos_bgp_global: &id001 state: purged register: result @@ -28,7 +28,7 @@ that: - result['after'] == {} - - name: Delete all bgp config from the device (idempotent) + - name: Delete all BGP configuration from the device (idempotent) register: result cisco.nxos.nxos_bgp_global: *id001 diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/rendered.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/rendered.yaml index dc50866d4..af3505fbe 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/rendered.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/rendered.yaml @@ -60,7 +60,7 @@ that: - merged['commands'] == result['rendered'] -- name: Gather bgp facts +- name: Gather BGP facts cisco.nxos.nxos_bgp_global: state: gathered register: result diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/replaced.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/replaced.yaml index 3dbc13f6e..62ea0ca50 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/replaced.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Replace bgp configuration with provided configuration + - name: Replace BGP configuration with provided configuration cisco.nxos.nxos_bgp_global: &id001 config: as_number: 65536 @@ -58,7 +58,7 @@ that: - merged['after'] == result['before'] - - name: Replace device configurations of listed ospf processes with provided configurarions (idempotent) + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result cisco.nxos.nxos_bgp_global: *id001 diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml index ff4c0c27e..c6e280686 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: Start nxos_bgp_global replaced_af integration tests connection={{ ansible_connection}} -- name: Remove pre-existing bgp configurations +- name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: &remove lines: - no router bgp 65536 ignore_errors: true -- name: "Setup - 1 (add neighbor with af config)" +- name: "Setup - 1 (add neighbor with AF config)" cisco.nxos.nxos_config: lines: - "router bgp 65536" @@ -26,7 +26,7 @@ - " remote-as 65537" - block: - - name: Remove a neighbor having af configurations (should fail) + - name: Remove a neighbor having AF configurations (should fail) cisco.nxos.nxos_bgp_global: config: as_number: 65536 @@ -46,11 +46,11 @@ - result.failed == True - "'Neighbor 203.0.113.2 has address-family configurations. Please use the nxos_bgp_neighbor_af module to remove those first.' in result.msg" - - name: Remove pre-existing bgp configurations + - name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: *remove ignore_errors: true - - name: "Setup - 2 (add neighbor with af config under a vrf)" + - name: "Setup - 2 (add neighbor with AF configuration under a vrf)" cisco.nxos.nxos_config: lines: - "router bgp 65536" @@ -69,7 +69,7 @@ - " low-memory exempt" - " neighbor-down fib-accelerate" - - name: Remove a neighbor under a vrf having af configurations (should fail) + - name: Remove a neighbor under a VRF having AF configurations (should fail) cisco.nxos.nxos_bgp_global: config: as_number: 65536 @@ -93,11 +93,11 @@ - result.failed == True - "'Neighbor 203.0.113.2 has address-family configurations. Please use the nxos_bgp_neighbor_af module to remove those first.' in result.msg" - - name: Remove pre-existing bgp configurations + - name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: *remove ignore_errors: true - - name: "Setup - 3 (add a vrf with af config)" + - name: "Setup - 3 (add a VRF with AF config)" cisco.nxos.nxos_config: lines: - "router bgp 65536" @@ -117,7 +117,7 @@ - "vrf site-2" - " neighbor-down fib-accelerate" - - name: Remove a vrf having af configurations (should fail) + - name: Remove a VRF having AF configurations (should fail) cisco.nxos.nxos_bgp_global: config: as_number: 65536 @@ -142,5 +142,5 @@ - "'VRF site-1 has address-family configurations. Please use the nxos_bgp_af module to remove those first.' in result.msg" always: - - name: Remove pre-existing bgp configurations + - name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: *remove diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/sanity.yaml index 64c76ea95..8ed423f3d 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/sanity.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Replace bgp configuration with different asn (should fail) + - name: Replace BGP configuration with different asn (should fail) cisco.nxos.nxos_bgp_global: config: as_number: "65538" @@ -24,7 +24,7 @@ - result.failed == True - "'BGP is already configured with ASN 65536. Please remove it with state purged before configuring new ASN' in result.msg" - - name: Merge bgp configuration with different asn (should fail) + - name: Merge BGP configuration with different asn (should fail) cisco.nxos.nxos_bgp_global: config: as_number: "65538" diff --git a/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml b/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml b/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml index d3a8b68b6..f567a6e04 100644 --- a/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml @@ -26,7 +26,7 @@ feature: "{{ item }}" state: enabled -- name: Enable nv overlay evpn - multisite +- name: Enable NV overlay EVPN - multisite when: platform is search('N9K') ignore_errors: true cisco.nxos.nxos_config: @@ -41,7 +41,7 @@ - evpn multisite border-gateway 10 - block: - - name: Configure bgp neighbor1 - multisite + - name: Configure BGP neighbor1 - multisite register: result cisco.nxos.nxos_bgp_neighbor: &id001 asn: 65535 @@ -64,7 +64,7 @@ that: - result.changed == false - - name: Configure bgp neighbor2 - multisite + - name: Configure BGP neighbor2 - multisite register: result cisco.nxos.nxos_bgp_neighbor: &id003 asn: 65535 @@ -79,7 +79,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor3 - multisite + - name: Configure BGP neighbor3 - multisite register: result cisco.nxos.nxos_bgp_neighbor: &id005 asn: 65535 @@ -113,7 +113,7 @@ - ansible.builtin.pause: seconds: 5 -- name: Remove nv overlay evpn - multisite +- name: Remove NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml index a342920e4..c2fff45a0 100644 --- a/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml @@ -47,7 +47,7 @@ state: enabled - block: - - name: Configure bgp neighbor1 + - name: Configure BGP neighbor1 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id001 @@ -84,7 +84,7 @@ that: - result.changed == false - - name: Configure bgp neighbor2 + - name: Configure BGP neighbor2 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id003 @@ -117,7 +117,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id005 @@ -135,7 +135,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor3 + - name: Configure BGP neighbor3 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id006 @@ -155,7 +155,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor4 + - name: Configure BGP neighbor4 with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id007 @@ -175,14 +175,14 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: *id005 - ansible.builtin.assert: *id002 - - name: Configure bgp neighbor 3des password + - name: Configure BGP neighbor 3des password with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id008 @@ -202,14 +202,14 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - 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 + - name: Configure BGP neighbor type 7 password with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id009 @@ -229,7 +229,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp neighbor password + - name: Remove BGP neighbor password with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id010 @@ -249,14 +249,14 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - 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 + - name: Configure BGP neighbor transport type passive with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id011 @@ -275,7 +275,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor transport type default + - name: Configure BGP neighbor transport type default with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id012 @@ -294,7 +294,7 @@ - ansible.builtin.assert: *id004 - - name: Remove bgp + - name: Remove BGP with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_bgp_neighbor: &id013 @@ -312,7 +312,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bfd enable + - name: Configure BFD enable register: result cisco.nxos.nxos_bgp_neighbor: &id014 asn: 65535 @@ -322,13 +322,13 @@ - ansible.builtin.assert: *id002 - - name: Check bfd enable idempotence + - name: Check BFD enable idempotence register: result cisco.nxos.nxos_bgp_neighbor: *id014 - ansible.builtin.assert: *id004 - - name: Configure bfd disable idempotence + - name: Configure BFD disable idempotence register: result cisco.nxos.nxos_bgp_neighbor: &id015 asn: 65535 @@ -338,7 +338,7 @@ - ansible.builtin.assert: *id002 - - name: Check bfd disable idempotence + - name: Check BFD disable idempotence register: result cisco.nxos.nxos_bgp_neighbor: *id015 diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml index 55f769a3b..14bbca726 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml @@ -1,23 +1,23 @@ --- -- name: Enable bgp feature +- name: Enable BGP feature cisco.nxos.nxos_feature: feature: bgp vars: ansible_connection: ansible.netcommon.network_cli - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi always: - - name: Disable bgp feature + - name: Disable BGP feature cisco.nxos.nxos_feature: feature: bgp state: disabled diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_populate_config.yaml index 77e88dec7..15c070713 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_bgp_neighbor_address_family: config: as_number: 65536 diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_remove_config.yaml index 9831b3d41..af7092576 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove pre-existing bgp configurations +- name: Remove pre-existing BGP configurations cisco.nxos.nxos_config: lines: - no router bgp 65536 diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/deleted.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/deleted.yaml index 03c826ae7..7428ad835 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/deleted.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Delete bgp configs handled by this module + - name: Delete BGP configs handled by this module cisco.nxos.nxos_bgp_neighbor_address_family: config: as_number: 65536 @@ -49,7 +49,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - - name: Delete all bgp neighbor af configs handled by this module + - name: Delete all BGP neighbor AF configs handled by this module cisco.nxos.nxos_bgp_neighbor_address_family: &deleted_all state: deleted register: result @@ -64,7 +64,7 @@ that: - deleted_all['after'] == result['after'] - - name: Delete all bgp neighbor af configs (idempotent) + - name: Delete all BGP neighbor AF configs (idempotent) cisco.nxos.nxos_bgp_neighbor_address_family: *deleted_all register: result diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/empty_config.yaml index efb9bbcf0..5128d38cd 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_bgp_neighbor_address_family empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_neighbor_address_family: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_neighbor_address_family: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_neighbor_address_family: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_neighbor_address_family: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_bgp_neighbor_address_family: diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/gathered.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/gathered.yaml index 330e340e7..05bce177a 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/gathered.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/gathered.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Gather bgp facts using gathered + - name: Gather BGP facts using gathered register: result cisco.nxos.nxos_bgp_neighbor_address_family: state: gathered diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/overridden.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/overridden.yaml index cd6ece9a0..c83481b22 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/overridden.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Override all bgp af configuration with provided configuration + - name: Override all BGP AF configuration with provided configuration cisco.nxos.nxos_bgp_neighbor_address_family: &overridden config: as_number: 65536 @@ -48,7 +48,7 @@ - "{{ overridden['after']['vrfs'] | symmetric_difference(result['after']['vrfs']) |length == 0 }}" - overridden['after']['as_number'] == result['after']['as_number'] - - name: Override all bgp af configuration with provided configuration (idempotent) + - name: Override all BGP AF configuration with provided configuration (idempotent) register: result cisco.nxos.nxos_bgp_neighbor_address_family: *overridden diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/parsed.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/parsed.yaml index a98b646bf..299c0e099 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/parsed.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxos_bgp_neighbor_address_family parsed integration tests on connection={{ ansible_connection }} -- name: Parse externally provided bgp config +- name: Parse externally provided BGP configuration register: result cisco.nxos.nxos_bgp_neighbor_address_family: running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after']['neighbors'] | symmetric_difference(result['parsed']['neighbors']) |length == 0 }}" diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/rendered.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/rendered.yaml index af6681a65..5b2c47de7 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/rendered.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/rendered.yaml @@ -53,7 +53,7 @@ that: - "{{ merged['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" -- name: Gather bgp facts +- name: Gather BGP facts cisco.nxos.nxos_bgp_neighbor_address_family: state: gathered register: result diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/replaced.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/replaced.yaml index cf61ef724..1b90933b1 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tests/common/replaced.yaml @@ -63,7 +63,7 @@ - "{{ replaced['after']['vrfs'] | symmetric_difference(result['after']['vrfs']) |length == 0 }}" - replaced['after']['as_number'] == result['after']['as_number'] - - name: Replace device configurations of listed ospf processes with provided configurarions (idempotent) + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result cisco.nxos.nxos_bgp_neighbor_address_family: *replaced diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml index 35b67ecac..12c31f7a2 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml @@ -7,25 +7,25 @@ soft_reconfiguration_ina: always when: imagetag is not search("D1|N1") -- name: Disable feature bgp - multisite +- name: Disable 'feature bgp' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Enable feature bgp - multisite +- name: Enable 'feature bgp' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: enabled -- name: Enable feature nv overlay - multisite +- name: Enable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay state: enabled -- name: Enable nv overlay evpn - multisite +- name: Enable NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: @@ -39,13 +39,13 @@ - evpn multisite border-gateway 10 - block: - - name: Configure ebgp - multisite + - name: Configure EBGP - multisite cisco.nxos.nxos_bgp_neighbor: asn: 65535 neighbor: 192.0.2.3 remote_as: 2 - - name: Configure bgp neighbor - multisite + - name: Configure BGP neighbor - multisite register: result cisco.nxos.nxos_bgp_neighbor_af: &id001 asn: 65535 @@ -68,7 +68,7 @@ that: - result.changed == false - - name: Configure bgp neighbor 1 - multisite + - name: Configure BGP neighbor 1 - multisite register: result cisco.nxos.nxos_bgp_neighbor_af: &id003 asn: 65535 @@ -93,12 +93,12 @@ - no evpn multisite border-gateway 10 when: multiout is not search("Invalid command") -- name: Disable feature bgp - multisite +- name: Disable 'feature bgp' - multisite cisco.nxos.nxos_feature: feature: bgp state: disabled -- name: Disable feature nv overlay - multisite +- name: Disable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay @@ -107,7 +107,7 @@ - ansible.builtin.pause: seconds: 5 -- name: Remove nv overlay evpn - multisite +- name: Remove NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml index 64f018b77..3b680ad59 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml @@ -7,20 +7,20 @@ soft_reconfiguration_ina: always when: imagetag is not search("D1|N1") -- name: Disable feature bgp +- name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: &id013 feature: bgp state: disabled -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: enabled - block: - - name: Configure bgp neighbor address-family + - name: Configure BGP neighbor address-family register: result cisco.nxos.nxos_bgp_neighbor_af: &id001 asn: 65535 @@ -63,7 +63,7 @@ that: - result.changed == false - - name: Configure bgp neighbor address-family def1 + - name: Configure BGP neighbor address-family def1 register: result cisco.nxos.nxos_bgp_neighbor_af: &id003 asn: 65535 @@ -100,7 +100,7 @@ - ansible.builtin.assert: *id004 - - name: "Setup: remove bgp config" + - name: "Setup: remove BGP configuration" register: result cisco.nxos.nxos_bgp_neighbor_af: &id005 asn: 65535 @@ -117,7 +117,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor address-family + - name: Configure BGP neighbor address-family register: result cisco.nxos.nxos_bgp_neighbor_af: &id006 asn: 65535 @@ -144,7 +144,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor address-family def2 + - name: Configure BGP neighbor address-family def2 register: result cisco.nxos.nxos_bgp_neighbor_af: &id007 asn: 65535 @@ -169,7 +169,7 @@ - ansible.builtin.assert: *id004 - - name: "Setup: remove bgp config" + - name: "Setup: remove BGP configuration" register: result cisco.nxos.nxos_bgp_neighbor_af: *id005 @@ -181,14 +181,14 @@ - ansible.builtin.assert: *id004 - - name: Configure ebgp + - 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 + - name: Configure BGP neighbor 3 register: result cisco.nxos.nxos_bgp_neighbor_af: &id008 asn: 65535 @@ -213,7 +213,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor def3 + - name: Configure BGP neighbor def3 register: result cisco.nxos.nxos_bgp_neighbor_af: &id009 asn: 65535 @@ -236,7 +236,7 @@ - ansible.builtin.assert: *id004 - - name: "Setup: remove bgp config" + - name: "Setup: remove BGP configuration" register: result cisco.nxos.nxos_bgp: &id012 asn: 65535 @@ -244,13 +244,13 @@ - ansible.builtin.assert: *id002 - - name: Configure bgp neighbor af route_reflector_client + - 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 + - name: Configure BGP neighbor 4 register: result cisco.nxos.nxos_bgp_neighbor_af: &id010 asn: 65535 @@ -267,7 +267,7 @@ - ansible.builtin.assert: *id004 - - name: Configure bgp neighbor def4 + - name: Configure BGP neighbor def4 register: result cisco.nxos.nxos_bgp_neighbor_af: &id011 asn: 65535 @@ -284,11 +284,11 @@ - ansible.builtin.assert: *id004 always: - - name: Cleanup bgp + - name: Cleanup BGP ignore_errors: true cisco.nxos.nxos_bgp: *id012 - - name: Disable feature bgp + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: *id013 - ansible.builtin.debug: diff --git a/tests/integration/targets/nxos_command/tasks/cli.yaml b/tests/integration/targets/nxos_command/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_command/tasks/cli.yaml +++ b/tests/integration/targets/nxos_command/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_command/tasks/main.yaml b/tests/integration/targets/nxos_command/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_command/tasks/main.yaml +++ b/tests/integration/targets/nxos_command/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_command/tasks/nxapi.yaml b/tests/integration/targets/nxos_command/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_command/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_command/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_command/tests/cli/sanity.yaml b/tests/integration/targets/nxos_command/tests/cli/sanity.yaml index 97a38df02..74c777bd5 100644 --- a/tests/integration/targets/nxos_command/tests/cli/sanity.yaml +++ b/tests/integration/targets/nxos_command/tests/cli/sanity.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START cli/sanity.yaml on connection={{ ansible_connection }} -- name: Disable feature bgp +- name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled - block: - - name: Run show running-config bgp - should fail + - name: Run show running-config BGP - should fail ignore_errors: true register: result cisco.nxos.nxos_command: @@ -19,12 +19,12 @@ that: - result.failed == true - - name: Enable feature bgp + - name: Enable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: enabled - - name: Configure bgp defaults + - name: Configure BGP defaults register: result cisco.nxos.nxos_bgp: asn: 65535 @@ -35,7 +35,7 @@ that: - result.changed == true - - name: Run show running-config bgp - should pass + - name: Run show running-config BGP - should pass register: result cisco.nxos.nxos_command: commands: @@ -58,7 +58,7 @@ - ansible.builtin.debug: msg: nxos_command sanity test failure detected always: - - name: Disable feature bgp + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled diff --git a/tests/integration/targets/nxos_command/tests/common/greaterthan.yaml b/tests/integration/targets/nxos_command/tests/common/greaterthan.yaml index 958b33121..dcdee7b47 100644 --- a/tests/integration/targets/nxos_command/tests/common/greaterthan.yaml +++ b/tests/integration/targets/nxos_command/tests/common/greaterthan.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START common/greaterthan.yaml on connection={{ ansible_connection }} -- name: Test gt operator +- name: Test 'gt' operator register: result cisco.nxos.nxos_command: commands: diff --git a/tests/integration/targets/nxos_command/tests/common/greaterthanorequal.yaml b/tests/integration/targets/nxos_command/tests/common/greaterthanorequal.yaml index efb68d6c4..6446e6b80 100644 --- a/tests/integration/targets/nxos_command/tests/common/greaterthanorequal.yaml +++ b/tests/integration/targets/nxos_command/tests/common/greaterthanorequal.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START common/greaterthanorequal.yaml on connection={{ ansible_connection }} -- name: Test ge operator +- name: Test 'ge' operator register: result cisco.nxos.nxos_command: commands: diff --git a/tests/integration/targets/nxos_command/tests/common/lessthan.yaml b/tests/integration/targets/nxos_command/tests/common/lessthan.yaml index f5ec2951c..dd01ecc7f 100644 --- a/tests/integration/targets/nxos_command/tests/common/lessthan.yaml +++ b/tests/integration/targets/nxos_command/tests/common/lessthan.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START common/lessthan.yaml on connection={{ ansible_connection }} -- name: Test lt operator +- name: Test 'lt' operator register: result cisco.nxos.nxos_command: commands: diff --git a/tests/integration/targets/nxos_command/tests/common/lessthanorequal.yaml b/tests/integration/targets/nxos_command/tests/common/lessthanorequal.yaml index 34f544eb3..04748f522 100644 --- a/tests/integration/targets/nxos_command/tests/common/lessthanorequal.yaml +++ b/tests/integration/targets/nxos_command/tests/common/lessthanorequal.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START common/lessthanorequal.yaml on connection={{ ansible_connection }} -- name: Test le operator +- name: Test 'le' operator register: result cisco.nxos.nxos_command: commands: diff --git a/tests/integration/targets/nxos_command/tests/common/notequal.yaml b/tests/integration/targets/nxos_command/tests/common/notequal.yaml index 90a97b876..c2fe39577 100644 --- a/tests/integration/targets/nxos_command/tests/common/notequal.yaml +++ b/tests/integration/targets/nxos_command/tests/common/notequal.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START common/notequal.yaml on connection={{ ansible_connection }} -- name: Test neq operator +- name: Test 'neq' operator register: result cisco.nxos.nxos_command: commands: diff --git a/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml b/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml index a7cfae72e..e9f2f162c 100644 --- a/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml +++ b/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxapi/sanity.yaml on connection={{ ansible_connection }} -- name: Disable feature bgp +- name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled - block: - - name: Run show running-config bgp - should fail + - name: Run show running-config BGP - should fail ignore_errors: true register: result cisco.nxos.nxos_command: @@ -19,12 +19,12 @@ that: - result.failed == true - - name: Enable feature bgp + - name: Enable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: enabled - - name: Configure bgp defaults + - name: Configure BGP defaults register: result cisco.nxos.nxos_bgp: asn: 65535 @@ -35,7 +35,7 @@ that: - result.changed == true - - name: Run show running-config bgp - should pass + - name: Run show running-config BGP - should pass register: result cisco.nxos.nxos_command: commands: @@ -58,7 +58,7 @@ - ansible.builtin.debug: msg: nxos_command sanity test failure detected always: - - name: Disable feature bgp + - name: Disable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: disabled diff --git a/tests/integration/targets/nxos_config/tasks/cli.yaml b/tests/integration/targets/nxos_config/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_config/tasks/cli.yaml +++ b/tests/integration/targets/nxos_config/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_config/tasks/main.yaml b/tests/integration/targets/nxos_config/tasks/main.yaml index 1b303bb42..31c8f31e9 100644 --- a/tests/integration/targets/nxos_config/tasks/main.yaml +++ b/tests/integration/targets/nxos_config/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_config/tasks/nxapi.yaml b/tests/integration/targets/nxos_config/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_config/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_config/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_config/tasks/redirection.yaml b/tests/integration/targets/nxos_config/tasks/redirection.yaml index 46b7cfea1..0ef757aef 100644 --- a/tests/integration/targets/nxos_config/tasks/redirection.yaml +++ b/tests/integration/targets/nxos_config/tasks/redirection.yaml @@ -1,5 +1,5 @@ --- -- name: Collect all redirection cli test cases +- name: Collect all redirection CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/redirection/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_config/tests/cli/diff.yaml b/tests/integration/targets/nxos_config/tests/cli/diff.yaml index d20b92378..e8999c849 100644 --- a/tests/integration/targets/nxos_config/tests/cli/diff.yaml +++ b/tests/integration/targets/nxos_config/tests/cli/diff.yaml @@ -6,7 +6,7 @@ cisco.nxos.nxos_config: lines: hostname switch -- name: Nxos_config diff against retrieved config +- name: Nxos_config diff against retrieved configuration diff: true register: result cisco.nxos.nxos_config: diff --git a/tests/integration/targets/nxos_config/tests/cli/multilevel.yaml b/tests/integration/targets/nxos_config/tests/cli/multilevel.yaml index 9c8565f8f..277f10d5a 100644 --- a/tests/integration/targets/nxos_config/tests/cli/multilevel.yaml +++ b/tests/integration/targets/nxos_config/tests/cli/multilevel.yaml @@ -2,17 +2,17 @@ - ansible.builtin.debug: msg: START cli/mulitlevel.yaml -- name: Get config +- name: Get configuration register: config cisco.nxos.nxos_command: commands: show running-config -- name: Enable feature bgp +- name: Enable 'feature bgp' when: "'feature bgp' not in config.stdout[0]" cisco.nxos.nxos_config: lines: feature bgp -- name: Remove bgp +- name: Remove BGP when: "'router bgp 1' in config.stdout[0]" cisco.nxos.nxos_config: lines: no router bgp 1 diff --git a/tests/integration/targets/nxos_config/tests/cli_config/cli_backup.yaml b/tests/integration/targets/nxos_config/tests/cli_config/cli_backup.yaml index 376f12faf..8f21457e7 100644 --- a/tests/integration/targets/nxos_config/tests/cli_config/cli_backup.yaml +++ b/tests/integration/targets/nxos_config/tests/cli_config/cli_backup.yaml @@ -32,7 +32,7 @@ state: absent with_items: "{{backup_files.files|default([])}}" -- name: Take config backup +- name: Take configuration backup become: "{{ can_become }}" register: result ansible.netcommon.cli_config: diff --git a/tests/integration/targets/nxos_config/tests/cli_config/cli_basic.yaml b/tests/integration/targets/nxos_config/tests/cli_config/cli_basic.yaml index d0572f4e2..a2492af26 100644 --- a/tests/integration/targets/nxos_config/tests/cli_config/cli_basic.yaml +++ b/tests/integration/targets/nxos_config/tests/cli_config/cli_basic.yaml @@ -7,7 +7,7 @@ config: "interface loopback1\nno description\nno shutdown\n" diff_match: none -- name: Configure device with config +- name: Configure device with configuration register: result ansible.netcommon.cli_config: &id001 config: "{{ lookup('template', 'basic/config.j2') }}" @@ -24,10 +24,10 @@ that: - result.changed == false -- name: Remove config +- name: Remove configuration ansible.netcommon.cli_config: *id002 -- name: Configure device with config +- name: Configure device with configuration register: result ansible.netcommon.cli_config: config: "{{ lookup('template', 'basic/config.j2') }}" diff --git a/tests/integration/targets/nxos_config/tests/common/backup.yaml b/tests/integration/targets/nxos_config/tests/common/backup.yaml index 770252383..e1aecb6b5 100644 --- a/tests/integration/targets/nxos_config/tests/common/backup.yaml +++ b/tests/integration/targets/nxos_config/tests/common/backup.yaml @@ -28,7 +28,7 @@ state: absent with_items: "{{backup_files.files|default([])}}" -- name: Configure device with config +- name: Configure device with configuration register: result cisco.nxos.nxos_config: commands: diff --git a/tests/integration/targets/nxos_config/tests/common/save.yaml b/tests/integration/targets/nxos_config/tests/common/save.yaml index 59a26ce08..9300247ae 100644 --- a/tests/integration/targets/nxos_config/tests/common/save.yaml +++ b/tests/integration/targets/nxos_config/tests/common/save.yaml @@ -15,7 +15,7 @@ - interface {{ intname }} match: none -- name: Save config +- name: Save configuration register: result cisco.nxos.nxos_config: save_when: always diff --git a/tests/integration/targets/nxos_config/tests/common/src_basic.yaml b/tests/integration/targets/nxos_config/tests/common/src_basic.yaml index b549fbaf9..176b679c5 100644 --- a/tests/integration/targets/nxos_config/tests/common/src_basic.yaml +++ b/tests/integration/targets/nxos_config/tests/common/src_basic.yaml @@ -15,7 +15,7 @@ - interface {{ intname }} match: none -- name: Configure device with config +- name: Configure device with configuration register: result cisco.nxos.nxos_config: src: basic/config.j2 @@ -26,7 +26,7 @@ - result.changed == true - result.updates is defined -- name: Check device with config +- name: Check device with configuration register: result cisco.nxos.nxos_config: src: basic/config.j2 diff --git a/tests/integration/targets/nxos_config/tests/common/src_match_none.yaml b/tests/integration/targets/nxos_config/tests/common/src_match_none.yaml index f25afa64f..a9b94ac50 100644 --- a/tests/integration/targets/nxos_config/tests/common/src_match_none.yaml +++ b/tests/integration/targets/nxos_config/tests/common/src_match_none.yaml @@ -15,7 +15,7 @@ - interface {{ intname }} match: none -- name: Configure device with config +- name: Configure device with configuration register: result cisco.nxos.nxos_config: commands: @@ -31,7 +31,7 @@ - result.changed == true - result.updates is defined -- name: Check device with config +- name: Check device with configuration register: result cisco.nxos.nxos_config: commands: diff --git a/tests/integration/targets/nxos_devicealias/tasks/cli.yaml b/tests/integration/targets/nxos_devicealias/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_devicealias/tasks/cli.yaml +++ b/tests/integration/targets/nxos_devicealias/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_devicealias/tasks/main.yaml b/tests/integration/targets/nxos_devicealias/tasks/main.yaml index eb055621b..477fbd41f 100644 --- a/tests/integration/targets/nxos_devicealias/tasks/main.yaml +++ b/tests/integration/targets/nxos_devicealias/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Check platform type and skip if not mds +- name: Check platform type and skip if not MDS register: result cisco.nxos.nxos_command: commands: show version | grep MDS @@ -8,12 +8,12 @@ ansible.builtin.set_fact: skip_test: false -- name: Set skip_test flag to true if not mds +- name: Set skip_test flag to true if not MDS ansible.builtin.set_fact: skip_test: true when: result.stdout[0] is not search('MDS') -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: cli when: not skip_test diff --git a/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml b/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml index fb61300ad..c9429b170 100644 --- a/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml @@ -44,7 +44,7 @@ that: - result.commands == [] always: - - name: Remove device alias config + - name: Remove device alias configuration cisco.nxos.nxos_devicealias: *id002 - ansible.builtin.debug: diff --git a/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml b/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_evpn_global/tasks/main.yaml b/tests/integration/targets/nxos_evpn_global/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_evpn_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_evpn_global/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_evpn_global/tests/common/sanity.yaml b/tests/integration/targets/nxos_evpn_global/tests/common/sanity.yaml index 804bd6371..92feff4de 100644 --- a/tests/integration/targets/nxos_evpn_global/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_evpn_global/tests/common/sanity.yaml @@ -8,20 +8,20 @@ lines: no nv overlay evpn match: none -- name: Disable feature nv overlay +- name: Disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: &id006 feature: nv overlay state: disabled - block: - - name: Enable feature nv overlay + - name: Enable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay state: enabled - - name: Enable nv overlay evpn + - name: Enable NV overlay EVPN register: result cisco.nxos.nxos_evpn_global: &id001 nv_overlay_evpn: true @@ -30,7 +30,7 @@ that: - result.changed == true - - name: Check idempotence - enable nv overlay evpn + - name: Check idempotence - enable NV overlay EVPN register: result cisco.nxos.nxos_evpn_global: *id001 @@ -38,14 +38,14 @@ that: - result.changed == false - - name: Disable nv overlay evpn + - name: Disable NV overlay EVPN register: result cisco.nxos.nxos_evpn_global: &id003 nv_overlay_evpn: false - ansible.builtin.assert: *id002 - - name: Check dempotence - disable nv overlay evpn + - name: Check dempotence - disable NV overlay EVPN register: result cisco.nxos.nxos_evpn_global: *id003 @@ -55,11 +55,11 @@ - ansible.builtin.debug: msg: connection={{ ansible_connection }} nxos_evpn_global sanity test - FALURE ENCOUNTERED always: - - name: Cleanup - disable nv overlay evpn + - name: Cleanup - disable NV overlay EVPN ignore_errors: true cisco.nxos.nxos_config: *id005 - - name: Cleanup - disable feature nv overlay + - name: Cleanup - disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: *id006 diff --git a/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml b/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml +++ b/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_evpn_vni/tasks/main.yaml b/tests/integration/targets/nxos_evpn_vni/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_evpn_vni/tasks/main.yaml +++ b/tests/integration/targets/nxos_evpn_vni/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml b/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml b/tests/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml index 206a437c7..344fe3749 100644 --- a/tests/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_evpn_vni/tests/common/sanity.yaml @@ -14,12 +14,12 @@ match: none - block: - - name: Enable feature bgp + - name: Enable 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: enabled - - name: Enable nv overlay evpn + - name: Enable NV overlay EVPN cisco.nxos.nxos_config: lines: nv overlay evpn match: none @@ -102,7 +102,7 @@ ignore_errors: true cisco.nxos.nxos_config: *id007 - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_facts/tasks/cli.yaml b/tests/integration/targets/nxos_facts/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_facts/tasks/cli.yaml +++ b/tests/integration/targets/nxos_facts/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_facts/tasks/main.yaml b/tests/integration/targets/nxos_facts/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_facts/tasks/main.yaml +++ b/tests/integration/targets/nxos_facts/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml index 338a4d5ff..1861fa4a7 100644 --- a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml @@ -17,7 +17,7 @@ - result.ansible_facts.ansible_net_memfree_mb > 1 - result.ansible_facts.ansible_net_memtotal_mb > 1 -- name: Nxos_facts gather config facts +- name: Nxos_facts gather configuration facts register: result cisco.nxos.nxos_facts: gather_subset: config @@ -30,7 +30,7 @@ - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_config is defined -- name: Nxos_facts gather config and hardware facts +- name: Nxos_facts gather configuration and hardware facts register: result cisco.nxos.nxos_facts: gather_subset: diff --git a/tests/integration/targets/nxos_feature/tasks/cli.yaml b/tests/integration/targets/nxos_feature/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_feature/tasks/cli.yaml +++ b/tests/integration/targets/nxos_feature/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_feature/tasks/main.yaml b/tests/integration/targets/nxos_feature/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_feature/tasks/main.yaml +++ b/tests/integration/targets/nxos_feature/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_feature/tasks/nxapi.yaml b/tests/integration/targets/nxos_feature/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_feature/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_feature/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_feature/tests/common/configure.yaml b/tests/integration/targets/nxos_feature/tests/common/configure.yaml index 1263ce2c8..bc73f56e7 100644 --- a/tests/integration/targets/nxos_feature/tests/common/configure.yaml +++ b/tests/integration/targets/nxos_feature/tests/common/configure.yaml @@ -9,7 +9,7 @@ - no feature fabric forwarding match: none -- name: Enable bgp +- name: Enable BGP register: result cisco.nxos.nxos_feature: feature: bgp @@ -19,7 +19,7 @@ that: - result.changed == true -- name: Verify bgp +- name: Verify BGP register: result cisco.nxos.nxos_feature: feature: bgp @@ -29,7 +29,7 @@ that: - result.changed == false -- name: Disable bgp +- name: Disable BGP register: result cisco.nxos.nxos_feature: feature: bgp @@ -39,7 +39,7 @@ that: - result.changed == true -- name: Verify bgp +- name: Verify BGP register: result cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_file_copy/tasks/cli.yaml b/tests/integration/targets/nxos_file_copy/tasks/cli.yaml index 959a86621..311e39414 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/cli.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_file_copy/tasks/main.yaml b/tests/integration/targets/nxos_file_copy/tasks/main.yaml index db61568c3..52da2b002 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/main.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/main.yaml @@ -4,7 +4,7 @@ commands: show interface mgmt 0 | json register: result -- name: Store mgmt interface ip address +- name: Store mgmt interface IP address ansible.builtin.set_fact: mgmt0_ip: "{{ result['stdout'][0]['TABLE_interface']['ROW_interface']['eth_ip_addr'] }}" @@ -20,12 +20,12 @@ configured_password: "{{ temp_passwd }}" - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml b/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml index c5f0e9199..18bf1b6ef 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml b/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml index 0b8d8ef9f..98d64eac3 100644 --- a/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml @@ -56,7 +56,7 @@ # file_pull_timeout > 30s has no effect in this case, since the device # shell gives up connecting to the bad IP after 30s and the response # on the shell triggers a standard error regex. -- name: Try and copy file using an invalid remote scp server ip address +- name: Try and copy file using an invalid remote scp server IP address register: result ignore_errors: true cisco.nxos.nxos_file_copy: diff --git a/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml b/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml index 3ec2145a6..6645dd3bc 100644 --- a/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml @@ -23,12 +23,12 @@ - rmdir dir1/dir2 - rmdir dir1 -- name: Setup - turn on feature scp-server +- name: Setup - turn on 'feature scp-server' cisco.nxos.nxos_feature: feature: scp-server state: enabled -- name: Setup - turn on feature sftp-server +- name: Setup - turn on 'feature sftp-server' cisco.nxos.nxos_feature: feature: sftp-server state: enabled @@ -184,12 +184,12 @@ no_log: true when: ansible_user != "admin" - - name: Turn off feature scp-server + - name: Turn off 'feature scp-server' cisco.nxos.nxos_feature: feature: scp-server state: disabled - - name: Turn off feature sftp-server + - name: Turn off 'feature sftp-server' cisco.nxos.nxos_feature: feature: sftp-server state: disabled diff --git a/tests/integration/targets/nxos_file_copy/tests/nxapi/badtransport.yaml b/tests/integration/targets/nxos_file_copy/tests/nxapi/badtransport.yaml index 3af96ed0e..aca1e195e 100644 --- a/tests/integration/targets/nxos_file_copy/tests/nxapi/badtransport.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/nxapi/badtransport.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxapi/badtransport.yaml -- name: Sending transport other than cli should fail +- name: Sending transport other than CLI should fail register: result ignore_errors: true cisco.nxos.nxos_file_copy: diff --git a/tests/integration/targets/nxos_gir/tasks/cli.yaml b/tests/integration/targets/nxos_gir/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_gir/tasks/cli.yaml +++ b/tests/integration/targets/nxos_gir/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_gir/tasks/main.yaml b/tests/integration/targets/nxos_gir/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_gir/tasks/main.yaml +++ b/tests/integration/targets/nxos_gir/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_gir/tasks/nxapi.yaml b/tests/integration/targets/nxos_gir/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_gir/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_gir/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml b/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml +++ b/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_gir_profile_management/tasks/main.yaml b/tests/integration/targets/nxos_gir_profile_management/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_gir_profile_management/tasks/main.yaml +++ b/tests/integration/targets/nxos_gir_profile_management/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml b/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_gir_profile_management/tests/common/sanity.yaml b/tests/integration/targets/nxos_gir_profile_management/tests/common/sanity.yaml index 8bc62c398..ae6c4b07a 100644 --- a/tests/integration/targets/nxos_gir_profile_management/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_gir_profile_management/tests/common/sanity.yaml @@ -14,7 +14,7 @@ mode: normal state: absent -- name: Setup - turn on feature eigrp +- name: Setup - turn on 'feature eigrp' ignore_errors: true cisco.nxos.nxos_feature: feature: eigrp @@ -93,7 +93,7 @@ - name: Remove maintenance mode profile cisco.nxos.nxos_gir_profile_management: *id005 - - name: Turn off feature eigrp + - name: Turn off 'feature eigrp' cisco.nxos.nxos_feature: feature: eigrp state: disabled diff --git a/tests/integration/targets/nxos_hostname/tasks/cli.yaml b/tests/integration/targets/nxos_hostname/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_hostname/tasks/cli.yaml +++ b/tests/integration/targets/nxos_hostname/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_hostname/tasks/main.yaml b/tests/integration/targets/nxos_hostname/tasks/main.yaml index 116fbdd20..263b60438 100644 --- a/tests/integration/targets/nxos_hostname/tasks/main.yaml +++ b/tests/integration/targets/nxos_hostname/tasks/main.yaml @@ -14,12 +14,12 @@ when: hname_result.stdout[0] != "" - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml b/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_hostname/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_hostname/tests/common/_populate_config.yaml index d77990556..67028c546 100644 --- a/tests/integration/targets/nxos_hostname/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_hostname/tests/common/_populate_config.yaml @@ -1,4 +1,4 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: "hostname {{ current_hostname }}" diff --git a/tests/integration/targets/nxos_hostname/tests/common/empty_config.yaml b/tests/integration/targets/nxos_hostname/tests/common/empty_config.yaml index cbcac8458..58ba11014 100644 --- a/tests/integration/targets/nxos_hostname/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_hostname/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_hostname empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hostname: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hostname: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hostname: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hostname: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hostname: diff --git a/tests/integration/targets/nxos_hostname/tests/common/parsed.yaml b/tests/integration/targets/nxos_hostname/tests/common/parsed.yaml index 9c669f3e1..b1ab1d992 100644 --- a/tests/integration/targets/nxos_hostname/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_hostname/tests/common/parsed.yaml @@ -8,7 +8,7 @@ running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after'] == result['parsed'] }}" diff --git a/tests/integration/targets/nxos_hsrp/tasks/cli.yaml b/tests/integration/targets/nxos_hsrp/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_hsrp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_hsrp/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_hsrp/tasks/main.yaml b/tests/integration/targets/nxos_hsrp/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_hsrp/tasks/main.yaml +++ b/tests/integration/targets/nxos_hsrp/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml b/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_hsrp/tests/common/sanity.yaml b/tests/integration/targets/nxos_hsrp/tests/common/sanity.yaml index da751337c..a4c774787 100644 --- a/tests/integration/targets/nxos_hsrp/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_hsrp/tests/common/sanity.yaml @@ -11,7 +11,7 @@ intname2: "{{ nxos_int2 }}" - block: - - name: Enable feature hsrp + - name: Enable 'feature hsrp' cisco.nxos.nxos_feature: feature: hsrp state: enabled @@ -48,7 +48,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_hsrp: *id001 @@ -70,7 +70,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_hsrp: *id003 @@ -90,7 +90,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_hsrp: *id005 @@ -108,7 +108,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_hsrp: *id006 @@ -126,7 +126,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_hsrp: *id007 @@ -147,7 +147,7 @@ - ansible.builtin.assert: *id004 always: - - name: Disable feature hsrp + - name: Disable 'feature hsrp' ignore_errors: true cisco.nxos.nxos_feature: feature: hsrp diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml index ba1eff1cd..9aa0d8690 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_populate_config.yaml index cfeb56095..404430235 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config - 1 +- name: Populate configuration - 1 cisco.nxos.nxos_config: lines: - "feature hsrp" @@ -8,7 +8,7 @@ - " no switchport" - " hsrp bfd" -- name: Populate config - 2 +- name: Populate configuration - 2 cisco.nxos.nxos_config: lines: - "interface {{ nxos_int2 }}" diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_remove_config.yaml index 002d42eb5..d55e828d5 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "no feature bfd" diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/empty_config.yaml index 6e38467bc..f80fd63b7 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_hsrp_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hsrp_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hsrp_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hsrp_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hsrp_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_hsrp_interfaces: diff --git a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/parsed.yaml index 275510df7..eeee8871b 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_hsrp_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_hsrp_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_igmp/tasks/cli.yaml b/tests/integration/targets/nxos_igmp/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_igmp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_igmp/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_igmp/tasks/main.yaml b/tests/integration/targets/nxos_igmp/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_igmp/tasks/main.yaml +++ b/tests/integration/targets/nxos_igmp/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml b/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_igmp/tests/common/sanity.yaml b/tests/integration/targets/nxos_igmp/tests/common/sanity.yaml index 0fd4a53ff..7c8704aea 100644 --- a/tests/integration/targets/nxos_igmp/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_igmp/tests/common/sanity.yaml @@ -8,7 +8,7 @@ when: platform is not match("N35") - block: - - name: Configure igmp with non-default values + - name: Configure IGMP with non-default values register: result cisco.nxos.nxos_igmp: &id001 flush_routes: true @@ -20,7 +20,7 @@ that: - result.changed == true - - name: Check idempotence - configure igmp interface with non-default values + - name: Check idempotence - configure IGMP interface with non-default values register: result cisco.nxos.nxos_igmp: *id001 @@ -28,7 +28,7 @@ that: - result.changed == false - - name: Configure igmp defaults + - name: Configure IGMP defaults register: result cisco.nxos.nxos_igmp: &id003 flush_routes: false @@ -38,30 +38,30 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp with defaults + - name: Check idempotence - configure IGMP with defaults register: result cisco.nxos.nxos_igmp: *id003 - ansible.builtin.assert: *id004 - - name: Configure igmp non-defaults again + - name: Configure IGMP non-defaults again register: result cisco.nxos.nxos_igmp: *id001 - - name: Configure igmp state as values + - name: Configure IGMP state as values register: result cisco.nxos.nxos_igmp: &id005 state: default - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp with state default + - name: Check idempotence - configure IGMP with state default register: result cisco.nxos.nxos_igmp: *id005 - ansible.builtin.assert: *id004 always: - - name: Configure igmp with default values + - name: Configure IGMP with default values register: result ignore_errors: true cisco.nxos.nxos_igmp: *id005 diff --git a/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml b/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_igmp_interface/tasks/main.yaml b/tests/integration/targets/nxos_igmp_interface/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_igmp_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_igmp_interface/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_igmp_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_igmp_interface/tests/common/sanity.yaml index c5d00df19..56b658afc 100644 --- a/tests/integration/targets/nxos_igmp_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_igmp_interface/tests/common/sanity.yaml @@ -11,7 +11,7 @@ restart: true when: platform is not match("N35") -- name: Enable feature pim +- name: Enable 'feature pim' ignore_errors: true cisco.nxos.nxos_feature: feature: pim @@ -25,7 +25,7 @@ match: none - block: - - name: Put interface in l3 and enable pim + - name: Put interface in layer 3 and enable PIM cisco.nxos.nxos_config: commands: - no switchport @@ -34,7 +34,7 @@ - interface {{ intname }} match: none - - name: Configure igmp interface with non-default values + - name: Configure IGMP interface with non-default values register: result cisco.nxos.nxos_igmp_interface: &id001 interface: "{{ intname }}" @@ -59,7 +59,7 @@ that: - result.changed == true - - name: Check idempotence - configure igmp interface with non-default values + - name: Check idempotence - configure IGMP interface with non-default values register: result cisco.nxos.nxos_igmp_interface: *id001 @@ -67,7 +67,7 @@ that: - result.changed == false - - name: Configure igmp interface with some default values + - name: Configure IGMP interface with some default values register: result cisco.nxos.nxos_igmp_interface: &id003 interface: "{{ intname }}" @@ -92,18 +92,18 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp interface with some default values + - name: Check idempotence - configure IGMP interface with some default values register: result cisco.nxos.nxos_igmp_interface: *id003 - ansible.builtin.assert: *id004 - - name: Restart igmp + - name: Restart IGMP cisco.nxos.nxos_igmp_interface: interface: "{{ intname }}" restart: "{{restart|default(omit)}}" - - name: Configure igmp interface with default oif_ps + - name: Configure IGMP interface with default oif_ps register: result cisco.nxos.nxos_igmp_interface: &id005 interface: "{{ intname }}" @@ -112,13 +112,13 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp interface with default oif_ps + - name: Check idempotence - configure IGMP interface with default oif_ps register: result cisco.nxos.nxos_igmp_interface: *id005 - ansible.builtin.assert: *id004 - - name: Configure igmp interface with oif_routemap + - name: Configure IGMP interface with oif_routemap register: result cisco.nxos.nxos_igmp_interface: &id006 interface: "{{ intname }}" @@ -131,13 +131,13 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp interface with oif_routemap + - name: Check idempotence - configure IGMP interface with oif_routemap register: result cisco.nxos.nxos_igmp_interface: *id006 - ansible.builtin.assert: *id004 - - name: Configure igmp interface with default state + - name: Configure IGMP interface with default state register: result cisco.nxos.nxos_igmp_interface: &id007 interface: "{{ intname }}" @@ -145,13 +145,13 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp interface with default state + - name: Check idempotence - configure IGMP interface with default state register: result cisco.nxos.nxos_igmp_interface: *id007 - ansible.builtin.assert: *id004 - - name: Configure igmp interface with absent state + - name: Configure IGMP interface with absent state register: result cisco.nxos.nxos_igmp_interface: &id008 interface: "{{ intname }}" @@ -159,13 +159,13 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence - configure igmp interface with absent state + - name: Check idempotence - configure IGMP interface with absent state register: result cisco.nxos.nxos_igmp_interface: *id008 - ansible.builtin.assert: *id004 always: - - name: Configure igmp interface with absent state + - name: Configure IGMP interface with absent state register: result cisco.nxos.nxos_igmp_interface: *id008 @@ -175,7 +175,7 @@ - default interface {{ intname }} match: none - - name: Disable feature pim + - name: Disable 'feature pim' ignore_errors: true cisco.nxos.nxos_feature: feature: pim diff --git a/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml b/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml +++ b/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_igmp_snooping/tasks/main.yaml b/tests/integration/targets/nxos_igmp_snooping/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_igmp_snooping/tasks/main.yaml +++ b/tests/integration/targets/nxos_igmp_snooping/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml b/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_igmp_snooping/tests/common/sanity.yaml b/tests/integration/targets/nxos_igmp_snooping/tests/common/sanity.yaml index e719a4c8d..e57fc978a 100644 --- a/tests/integration/targets/nxos_igmp_snooping/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_igmp_snooping/tests/common/sanity.yaml @@ -28,7 +28,7 @@ state: default - block: - - name: Configure igmp snooping with non-default values + - name: Configure IGMP snooping with non-default values register: result cisco.nxos.nxos_igmp_snooping: &id001 snooping: false @@ -81,7 +81,7 @@ - assert: *id004 when: gt_run - - name: Configure igmp snooping with default group timeout + - name: Configure IGMP snooping with default group timeout register: result cisco.nxos.nxos_igmp_snooping: &id005 group_timeout: "{{def_group_timeout|default(omit)}}" @@ -98,7 +98,7 @@ - assert: *id004 when: (imagetag and imagetag is not search("D1")) - - name: Configure igmp snooping with default values + - name: Configure IGMP snooping with default values register: result cisco.nxos.nxos_igmp_snooping: *id006 @@ -112,7 +112,7 @@ - assert: *id004 when: (imagetag and imagetag is not search("D1")) always: - - name: Configure igmp snooping with default values + - name: Configure IGMP snooping with default values register: result cisco.nxos.nxos_igmp_snooping: *id006 diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index 9f8115756..b6073d332 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -10,7 +10,7 @@ - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml -- name: Remove ssh known_hosts file before scp of image file +- name: Remove SSH known_hosts file before scp of image file ignore_errors: true cisco.nxos.nxos_command: commands: run bash rm /var/home/admin/.ssh/known_hosts diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml index 8900c60ce..c429f33ac 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml @@ -1,5 +1,5 @@ --- -- name: Setup - turn on feature scp-server +- name: Setup - turn on 'feature scp-server' cisco.nxos.nxos_feature: feature: scp-server state: enabled diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml index bfc3d737b..63fbb7f36 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml @@ -13,7 +13,7 @@ - ansible.builtin.meta: reset_connection -- name: Check installed os for newly installed version {{ tv }} +- name: Check installed OS for newly installed version {{ tv }} register: output cisco.nxos.nxos_command: commands: diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml index cb2eb5867..d9687c6e2 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml @@ -1,5 +1,5 @@ --- -- name: Install os image {{ si }} +- name: Install OS image {{ si }} check_mode: "{{ checkmode }}" register: result when: not force @@ -17,7 +17,7 @@ - no boot system match: line -- name: Set os image {{ si }} boot pointers +- name: Set OS image {{ si }} boot pointers when: force cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml index 9d2d1cff2..79b1dbfb0 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml @@ -1,5 +1,5 @@ --- -- name: Install os image {{ si }} +- name: Install OS image {{ si }} check_mode: "{{ checkmode }}" register: result when: not force @@ -8,7 +8,7 @@ kickstart_image_file: "{{ ki }}" issu: "{{ issu }}" -- name: Set os image {{ si }} boot pointers +- name: Set OS image {{ si }} boot pointers when: force cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml index f93575f1e..3bab0b296 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml @@ -40,5 +40,5 @@ ansible.builtin.set_fact: ki: n6000-uk9-kickstart.7.3.0.N1.1.bin -- name: Upgrade n5k device to 7.3(0)n1(1) release image +- name: Upgrade N5K device to 7.3(0)n1(1) release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml index 9d5c85621..d79e33652 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml @@ -40,5 +40,5 @@ ansible.builtin.set_fact: ki: n6000-uk9-kickstart.7.3.3.N1.1.bin -- name: Upgrade n5k device to 7.3(3)n1(1) release image +- name: Upgrade N5K device to 7.3(3)n1(1) release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml index 753cb3bf6..feea9c139 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml @@ -40,5 +40,5 @@ ansible.builtin.set_fact: ki: n7000-s2-kickstart.8.0.1.bin -- name: Upgrade n7k device to atherton release image +- name: Upgrade N7K device to atherton release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml index e99db34bc..134edce69 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml @@ -40,5 +40,5 @@ ansible.builtin.set_fact: ki: n7000-s2-kickstart.7.3.0.D1.1.bin -- name: Upgrade n7k device to helsinki release image +- name: Upgrade N7K device to helsinki release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml index e2d353814..bf9c1c93f 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml @@ -46,5 +46,5 @@ ansible.builtin.set_fact: si: nxos.7.0.3.I7.4.bin -- name: Upgrade n9k device to greensboro release image +- name: Upgrade N9K device to greensboro release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml index df04c5ae4..73369ad1f 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml @@ -46,5 +46,5 @@ ansible.builtin.set_fact: si: nxos.7.0.3.I7.4.bin -- name: Upgrade n9k device to greensboro release image +- name: Upgrade N9K device to greensboro release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml index cfb7b0029..d1b3c66c4 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml @@ -44,5 +44,5 @@ ansible.builtin.set_fact: si: nxos.9.2.1.bin -- name: Upgrade n9k device to hamilton release image +- name: Upgrade N9K device to hamilton release image ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_interface/tasks/cli.yaml b/tests/integration/targets/nxos_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_interface/tasks/main.yaml b/tests/integration/targets/nxos_interface/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_interface/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_interface/tests/common/sanity.yaml index bb53672ed..5ae20dae4 100644 --- a/tests/integration/targets/nxos_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_interface/tests/common/sanity.yaml @@ -6,7 +6,7 @@ ansible.builtin.set_fact: testint: "{{ nxos_int1 }}" -- name: "Setup: enable feature interface-vlan" +- name: "Setup: enable 'feature interface-vlan'" ignore_errors: true cisco.nxos.nxos_feature: feature: interface-vlan @@ -18,7 +18,7 @@ lines: - default interface {{ testint }} -- name: "Setup: remove possibly existing vlan interfaces" +- name: "Setup: remove possibly existing VLAN interfaces" ignore_errors: true cisco.nxos.nxos_config: &id009 lines: @@ -66,7 +66,7 @@ - ansible.builtin.assert: *id004 - - name: Create vlan interfaces + - name: Create VLAN interfaces with_items: &id005 - os_svi_int: vlan2 os_svi_desc: SVI_VLAN2 @@ -86,7 +86,7 @@ - ansible.builtin.assert: *id002 - - name: Configure required svi + - name: Configure required SVI register: result cisco.nxos.nxos_l3_interface: &id007 aggregate: @@ -104,14 +104,14 @@ - ansible.builtin.assert: *id002 - - name: Create vlan interfaces idempotence check + - name: Create VLAN interfaces idempotence check with_items: *id005 register: result cisco.nxos.nxos_interface: *id006 - ansible.builtin.assert: *id004 - - name: Configure required svi idempotence check + - name: Configure required SVI idempotence check register: result cisco.nxos.nxos_l3_interface: *id007 @@ -121,10 +121,10 @@ ignore_errors: true cisco.nxos.nxos_config: *id008 - - name: Remove vlan interfaces + - name: Remove VLAN interfaces cisco.nxos.nxos_config: *id009 - - name: "Setup: disable feature interface-vlan" + - name: "Setup: disable 'feature interface-vlan'" ignore_errors: true cisco.nxos.nxos_feature: feature: interface-vlan diff --git a/tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml +++ b/tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml +++ b/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml b/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml index e964da31c..cb33c0b8a 100644 --- a/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml @@ -29,7 +29,7 @@ lines: - default interface {{ testint }} -- name: Remove switchport config +- name: Remove switchport configuration ignore_errors: true cisco.nxos.nxos_config: commands: @@ -47,7 +47,7 @@ - no interface loopback77 - block: - - name: Configure ospf interface + - name: Configure OSPF interface register: result cisco.nxos.nxos_interface_ospf: &id001 interface: "{{ nxos_int1|upper }}" @@ -175,7 +175,7 @@ parents: - interface {{ item }} - - name: Configure ospf interface port-channel10 + - name: Configure OSPF interface port-channel10 register: result cisco.nxos.nxos_interface_ospf: &id008 interface: Port-channel10 @@ -195,7 +195,7 @@ - ansible.builtin.assert: *id004 - - name: Configure ospf interface port-channel11 using lower case name + - name: Configure OSPF interface port-channel11 using lower case name register: result cisco.nxos.nxos_interface_ospf: &id009 interface: port-channel11 @@ -215,7 +215,7 @@ - ansible.builtin.assert: *id004 - - name: Configure ospf interface loopback55 + - name: Configure OSPF interface loopback55 register: result cisco.nxos.nxos_interface_ospf: &id010 interface: LOOPBACK55 @@ -234,7 +234,7 @@ - ansible.builtin.assert: *id004 - - name: Configure ospf interface loopback77 using lower case name + - name: Configure OSPF interface loopback77 using lower case name register: result cisco.nxos.nxos_interface_ospf: &id011 interface: loopback77 @@ -253,7 +253,7 @@ - ansible.builtin.assert: *id004 - - name: Remove ospf interface config + - name: Remove OSPF interface configuration register: result cisco.nxos.nxos_interface_ospf: &id012 interface: "{{ testint }}" diff --git a/tests/integration/targets/nxos_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_interfaces/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_interfaces/tasks/main.yaml index 6d298eacb..926add4de 100644 --- a/tests/integration/targets/nxos_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_interfaces/tasks/main.yaml @@ -4,12 +4,12 @@ lines: "no system default switchport\nsystem default switchport shutdown\n" connection: ansible.netcommon.network_cli -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_interfaces/tests/common/_populate_config.yaml index c17fc4711..15c559f7e 100644 --- a/tests/integration/targets/nxos_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: "Populate config - {{ nxos_int1 }}" +- name: "Populate configuration - {{ nxos_int1 }}" cisco.nxos.nxos_config: lines: - "description outbound-intf" @@ -7,7 +7,7 @@ - "no shutdown" parents: "interface {{ nxos_int1 }}" -- name: "Populate config - {{ nxos_int2 }}" +- name: "Populate configuration - {{ nxos_int2 }}" cisco.nxos.nxos_config: lines: - "description intf-l3" diff --git a/tests/integration/targets/nxos_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_interfaces/tests/common/_remove_config.yaml index 37ee536cf..7ff47cc75 100644 --- a/tests/integration/targets/nxos_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_interfaces/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "default interface {{ nxos_int1 }}" diff --git a/tests/integration/targets/nxos_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_interfaces/tests/common/empty_config.yaml index 6efc913a6..2e1311f91 100644 --- a/tests/integration/targets/nxos_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_interfaces: diff --git a/tests/integration/targets/nxos_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_interfaces/tests/common/parsed.yaml index e37c4bdb0..b228595bc 100644 --- a/tests/integration/targets/nxos_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_interfaces/tests/common/rtt.yaml b/tests/integration/targets/nxos_interfaces/tests/common/rtt.yaml index 9f895fedb..98b70b4b9 100644 --- a/tests/integration/targets/nxos_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/nxos_interfaces/tests/common/rtt.yaml @@ -61,7 +61,7 @@ - result.commands|length == 9 - result.changed == true - - name: Revert back to base config using facts round trip + - name: Revert back to base configuration using facts round trip register: revert cisco.nxos.nxos_interfaces: config: "{{ ansible_facts['network_resources']['interfaces'] }}" diff --git a/tests/integration/targets/nxos_l2_interface/tasks/cli.yaml b/tests/integration/targets/nxos_l2_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_l2_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_l2_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l2_interface/tasks/main.yaml b/tests/integration/targets/nxos_l2_interface/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_l2_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_l2_interface/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml index f5cd8826c..1e06eb5f5 100644 --- a/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml @@ -31,7 +31,7 @@ name: "{{ intname }}" state: unconfigured - - name: Ensure interface is configured for access vlan 20 + - name: Ensure interface is configured for access VLAN 20 register: result cisco.nxos.nxos_l2_interface: &id001 name: "{{ intname }}" @@ -46,7 +46,7 @@ ansible.builtin.wait_for: timeout=2 when: platform is match("N9K-F") - - name: Access vlan idempotence + - name: Access VLAN idempotence register: result cisco.nxos.nxos_l2_interface: *id001 @@ -64,7 +64,7 @@ - ansible.builtin.assert: *id002 - - name: Trunk vlan idempotence + - name: Trunk VLAN idempotence register: result cisco.nxos.nxos_l2_interface: *id003 @@ -80,13 +80,13 @@ - ansible.builtin.assert: *id002 - - name: Tag vlan idempotence + - name: Tag VLAN idempotence register: result cisco.nxos.nxos_l2_interface: *id005 - ansible.builtin.assert: *id004 - - name: Remove full trunk vlan range 2-50 + - name: Remove full trunk VLAN range 2-50 register: result cisco.nxos.nxos_l2_interface: &id006 name: "{{ intname }}" @@ -96,7 +96,7 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence remove full trunk vlan range 2-50 + - name: Check idempotence remove full trunk VLAN range 2-50 register: result cisco.nxos.nxos_l2_interface: *id006 @@ -114,7 +114,7 @@ - ansible.builtin.assert: *id004 - - name: Remove partial trunk vlan range 30-4094 are removed + - name: Remove partial trunk VLAN range 30-4094 are removed register: result cisco.nxos.nxos_l2_interface: &id007 name: "{{ intname }}" @@ -124,7 +124,7 @@ - ansible.builtin.assert: *id002 - - name: Check idempotence remove partial trunk vlan range 30-4094 are removed + - name: Check idempotence remove partial trunk VLAN range 30-4094 are removed register: result cisco.nxos.nxos_l2_interface: *id007 diff --git a/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l2_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_l2_interfaces/tasks/main.yaml index b42cad3e3..8d0b94337 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tasks/main.yaml @@ -1,9 +1,9 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml index 381c780dc..0f222dbbf 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_lacp empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l2_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l2_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l2_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l2_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l2_interfaces: diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml index 379a5aa90..05a60aa63 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_l2_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml index 6f18297aa..5ef0b101c 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml @@ -58,7 +58,7 @@ that: - result.changed == true - - name: Revert back to base config using facts round trip + - name: Revert back to base configuration using facts round trip register: revert cisco.nxos.nxos_l2_interfaces: config: "{{ ansible_facts['network_resources']['l2_interfaces'] }}" diff --git a/tests/integration/targets/nxos_l3_interface/tasks/cli.yaml b/tests/integration/targets/nxos_l3_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_l3_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_l3_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l3_interface/tasks/main.yaml b/tests/integration/targets/nxos_l3_interface/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_l3_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_l3_interface/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml index fefcfa15b..a3cb83f5c 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml @@ -4,11 +4,11 @@ rsvd_intf: "{{ rsvd_intf|default('mgmt0') }}" - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/_populate_config.yaml index 4d18e39e2..d0a293408 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config - 1 +- name: Populate configuration - 1 cisco.nxos.nxos_config: lines: - "interface {{ nxos_int1 }}" @@ -7,7 +7,7 @@ - " ip redirects" - " ip address 192.0.2.100/24" -- name: Populate config - 2 +- name: Populate configuration - 2 cisco.nxos.nxos_config: lines: - "interface {{ nxos_int2 }}" diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/_remove_config.yaml index 7abe42d8c..d7e662244 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "default interface {{ nxos_int1 }}" diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/empty_config.yaml index 8ff0e2557..4c2d37d70 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l3_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l3_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l3_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l3_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_l3_interfaces: diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml index 0be80cedf..c361da1e7 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml @@ -10,14 +10,14 @@ - ansible.builtin.include_tasks: _remove_config.yaml -- name: Enable feature nv overlay - multisite +- name: Enable 'feature nv overlay' - multisite cisco.nxos.nxos_config: commands: - no feature nv overlay - feature nv overlay match: none -- name: Enable nv overlay evpn - multisite +- name: Enable NV overlay EVPN - multisite when: platform is search('N9K') ignore_errors: true cisco.nxos.nxos_config: @@ -239,7 +239,7 @@ - "!min" gather_network_resources: l3_interfaces - - name: Store reserved interface ip config + - name: Store reserved interface IP configuration ansible.builtin.set_fact: mgmt: "{{ ansible_facts.network_resources.l3_interfaces|selectattr('name', 'equalto', rsvd_intf)|list }}" overriden_config: @@ -335,7 +335,7 @@ - ansible.builtin.include_tasks: _remove_config.yaml # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_l3_interfaces: running_config: | @@ -358,7 +358,7 @@ when: multiout is not search("Invalid command") -- name: Disable nv overlay evpn +- name: Disable NV overlay EVPN when: platform is search('N9K') ignore_errors: true cisco.nxos.nxos_config: @@ -366,7 +366,7 @@ - no nv overlay evpn match: none -- name: Disable feature nv overlay +- name: Disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nve diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml index 2c8d5f203..c716b5c4b 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml @@ -39,7 +39,7 @@ - "!min" gather_network_resources: l3_interfaces - - name: Store reserved interface ip config + - name: Store reserved interface IP configuration ansible.builtin.set_fact: mgmt: "{{ ansible_facts.network_resources.l3_interfaces|selectattr('name', 'equalto', rsvd_intf)|list }}" overriden_config: diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/parsed.yaml index 8bbeac4a3..ecf23ce05 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_l3_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml index 0253292d0..887876f0d 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml @@ -44,7 +44,7 @@ gather_network_resources: - l3_interfaces - - name: Set reserved interface ip config and config to revert + - name: Set reserved interface IP configuration and configuration to revert ansible.builtin.set_fact: mgmt: "{{ ansible_facts.network_resources.l3_interfaces|selectattr('name', 'equalto', rsvd_intf)|list }}" config_to_revert: @@ -73,7 +73,7 @@ that: - result.changed == true - - name: Revert back to base config using facts round trip + - name: Revert back to base configuration using facts round trip register: revert cisco.nxos.nxos_l3_interfaces: config: "{{ ansible_facts['network_resources']['l3_interfaces'] }}" diff --git a/tests/integration/targets/nxos_lacp/tasks/cli.yaml b/tests/integration/targets/nxos_lacp/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_lacp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_lacp/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lacp/tasks/main.yaml b/tests/integration/targets/nxos_lacp/tasks/main.yaml index b42cad3e3..8d0b94337 100644 --- a/tests/integration/targets/nxos_lacp/tasks/main.yaml +++ b/tests/integration/targets/nxos_lacp/tasks/main.yaml @@ -1,9 +1,9 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml b/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lacp/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_lacp/tests/common/_remove_config.yaml index b4d9edd85..47b880452 100644 --- a/tests/integration/targets/nxos_lacp/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_lacp/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove existing lacp config +- name: Remove existing lacp configuration cisco.nxos.nxos_config: lines: - "no lacp system-priority" diff --git a/tests/integration/targets/nxos_lacp/tests/common/deleted.yaml b/tests/integration/targets/nxos_lacp/tests/common/deleted.yaml index 8d2fa3ab5..b2183ea07 100644 --- a/tests/integration/targets/nxos_lacp/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_lacp/tests/common/deleted.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: Start nxos_lacp deleted integration tests connection={{ ansible_connection }} -- name: Enable lacp feature +- name: Enable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp diff --git a/tests/integration/targets/nxos_lacp/tests/common/empty_config.yaml b/tests/integration/targets/nxos_lacp/tests/common/empty_config.yaml index 27a82ae72..04f9a86af 100644 --- a/tests/integration/targets/nxos_lacp/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_lacp/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_lacp empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp: diff --git a/tests/integration/targets/nxos_lacp/tests/common/parsed.yaml b/tests/integration/targets/nxos_lacp/tests/common/parsed.yaml index 421a4183d..b75141762 100644 --- a/tests/integration/targets/nxos_lacp/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_lacp/tests/common/parsed.yaml @@ -3,7 +3,7 @@ msg: START nxos_lacp parsed integration tests on connection={{ ansible_connection }} - block: - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_lacp: running_config: | diff --git a/tests/integration/targets/nxos_lacp/tests/common/replaced.yaml b/tests/integration/targets/nxos_lacp/tests/common/replaced.yaml index dec861b7c..d48d2d854 100644 --- a/tests/integration/targets/nxos_lacp/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_lacp/tests/common/replaced.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: Start nxos_lacp replaced integration tests connection={{ ansible_connection }} -- name: Enable lacp feature +- name: Enable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp diff --git a/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lacp_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_lacp_interfaces/tasks/main.yaml index b42cad3e3..8d0b94337 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tasks/main.yaml @@ -1,9 +1,9 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml index c5f0e9199..18bf1b6ef 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/_populate_config.yaml index 431ed3bf7..3e3f94acb 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "feature lacp" diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/_remove_config.yaml index 6dff8b166..e579913ae 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "no interface port-channel5" diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml index 79595dcde..bdc9ab171 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml @@ -24,7 +24,7 @@ - "interface port-channel10" - " lacp max-bundle 10" - - name: Setup3 - l2 for mode command + - name: Setup3 - layer 2 for mode command when: mode is defined cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/empty_config.yaml index 668d8b034..80634f8c6 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_lacp_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lacp_interfaces: diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml index 9cb9c7404..db91aad02 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml @@ -20,7 +20,7 @@ lines: - "feature lacp" - - name: Setup3 - l2 for mode command + - name: Setup3 - layer 2 for mode command when: mode is defined cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml index 791a25fa9..3ebc4f2b4 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml @@ -25,7 +25,7 @@ - "interface port-channel5" - " lacp max-bundle 10" - - name: Setup3 - l2 for mode command + - name: Setup3 - layer 2 for mode command when: mode is defined cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/parsed.yaml index 1dbadb579..37f24b208 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Ethernet interface used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_lacp_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lag_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_lag_interfaces/tasks/main.yaml index cd57deb3a..bf71b9995 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tasks/main.yaml @@ -4,11 +4,11 @@ lines: "system default switchport" connection: ansible.netcommon.network_cli -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml index c5f0e9199..18bf1b6ef 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/_populate_config.yaml index f06d82fc4..4715592ee 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "feature lacp" diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/_remove_config.yaml index fd3b74fc7..59c0f3b35 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "default interface {{ nxos_int1 }}" diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/deleted.yaml index 4b1c6220c..e1deb531e 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/deleted.yaml @@ -12,7 +12,7 @@ - ansible.builtin.include_tasks: _remove_config.yaml -- name: Enable feature lacp +- name: Enable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp @@ -61,7 +61,7 @@ always: - ansible.builtin.include_tasks: _remove_config.yaml - - name: Disable feature lacp + - name: Disable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp state: disabled diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/empty_config.yaml index f98231617..558f53eb4 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lag_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lag_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lag_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lag_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_lag_interfaces: diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml index 251692d1d..96b74273d 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml @@ -10,7 +10,7 @@ ansible.builtin.set_fact: test_int2: "{{ nxos_int2 }}" -- name: Enable feature lacp +- name: Enable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp @@ -99,7 +99,7 @@ ignore_errors: true cisco.nxos.nxos_lag_interfaces: *id003 - - name: Disable feature lacp + - name: Disable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp state: disabled diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml index 7617fc1fb..f2bafafb2 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml @@ -8,7 +8,7 @@ test_int2: "{{ nxos_int2 }}" test_int3: "{{ nxos_int3 }}" -- name: Enable feature lacp +- name: Enable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp @@ -99,7 +99,7 @@ ignore_errors: true cisco.nxos.nxos_lag_interfaces: *id003 - - name: Disable feature lacp + - name: Disable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp state: disabled diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/parsed.yaml index a5d2eb488..681902bbe 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/parsed.yaml @@ -4,7 +4,7 @@ - block: # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_lag_interfaces: running_config: | diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/replaced.yaml index 63d7f824d..5461c2c17 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/replaced.yaml @@ -10,7 +10,7 @@ ansible.builtin.set_fact: test_int2: "{{ nxos_int2 }}" -- name: Enable feature lacp +- name: Enable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp @@ -78,7 +78,7 @@ ignore_errors: true cisco.nxos.nxos_lag_interfaces: *id003 - - name: Disable feature lacp + - name: Disable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp state: disabled diff --git a/tests/integration/targets/nxos_linkagg/tasks/cli.yaml b/tests/integration/targets/nxos_linkagg/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_linkagg/tasks/cli.yaml +++ b/tests/integration/targets/nxos_linkagg/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_linkagg/tasks/main.yaml b/tests/integration/targets/nxos_linkagg/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_linkagg/tasks/main.yaml +++ b/tests/integration/targets/nxos_linkagg/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml b/tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml b/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml index 0d81d16cf..961e99ee0 100644 --- a/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml @@ -10,19 +10,19 @@ ansible.builtin.set_fact: testint2: "{{ nxos_int2 }}" -- name: Enable feature lacp +- name: Enable 'feature lacp' ignore_errors: true cisco.nxos.nxos_feature: feature: lacp state: enabled -- name: Setup - remove config used in test(part1) +- name: Setup - remove configuration used in test(part1) cisco.nxos.nxos_config: lines: - no interface port-channel 20 - no interface port-channel 100 -- name: Setup - remove config used in test(part2) +- name: Setup - remove configuration used in test(part2) ignore_errors: true loop: - interface {{ testint1 }} @@ -32,7 +32,7 @@ - no channel-group 20 parents: "{{ item }}" -- name: Put interface in l2 mode +- name: Put interface in layer 2 mode when: platform is match("N35") cisco.nxos.nxos_interface: aggregate: @@ -179,13 +179,13 @@ that: - result.changed == false -- name: Teardown - remove config used in test(part1) +- name: Teardown - remove configuration used in test(part1) cisco.nxos.nxos_config: lines: - no interface port-channel 20 - no interface port-channel 100 -- name: Teardown - remove config used in test(part2) +- name: Teardown - remove configuration used in test(part2) ignore_errors: true loop: - interface {{ testint1 }} @@ -195,7 +195,7 @@ - no channel-group 20 parents: "{{ item }}" -- name: Disable feature lacp +- name: Disable 'feature lacp' cisco.nxos.nxos_feature: feature: lacp state: disabled diff --git a/tests/integration/targets/nxos_lldp/tasks/cli.yaml b/tests/integration/targets/nxos_lldp/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_lldp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_lldp/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lldp/tasks/main.yaml b/tests/integration/targets/nxos_lldp/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_lldp/tasks/main.yaml +++ b/tests/integration/targets/nxos_lldp/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_lldp/tasks/nxapi.yaml b/tests/integration/targets/nxos_lldp/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_lldp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_lldp/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml b/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml index 040f8eab4..3bff52013 100644 --- a/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_lldp_global/tasks/main.yaml b/tests/integration/targets/nxos_lldp_global/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_lldp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_lldp_global/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml index fe9d48a7c..e0ebc3f54 100644 --- a/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_lldp_global/tests/common/_populate_config.yml b/tests/integration/targets/nxos_lldp_global/tests/common/_populate_config.yml index f8fb81428..a0d64f354 100644 --- a/tests/integration/targets/nxos_lldp_global/tests/common/_populate_config.yml +++ b/tests/integration/targets/nxos_lldp_global/tests/common/_populate_config.yml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "feature lldp" diff --git a/tests/integration/targets/nxos_lldp_global/tests/common/_remove_config.yml b/tests/integration/targets/nxos_lldp_global/tests/common/_remove_config.yml index 5a37b064b..42a64ce43 100644 --- a/tests/integration/targets/nxos_lldp_global/tests/common/_remove_config.yml +++ b/tests/integration/targets/nxos_lldp_global/tests/common/_remove_config.yml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_feature: feature: lldp state: disabled diff --git a/tests/integration/targets/nxos_lldp_global/tests/common/deleted.yml b/tests/integration/targets/nxos_lldp_global/tests/common/deleted.yml index 6cf03dae7..581197d7f 100644 --- a/tests/integration/targets/nxos_lldp_global/tests/common/deleted.yml +++ b/tests/integration/targets/nxos_lldp_global/tests/common/deleted.yml @@ -13,7 +13,7 @@ feature: lldp state: disabled - - name: Enable lldp feature + - name: Enable 'feature lldp' cisco.nxos.nxos_feature: feature: lldp state: enabled diff --git a/tests/integration/targets/nxos_lldp_global/tests/common/parsed.yml b/tests/integration/targets/nxos_lldp_global/tests/common/parsed.yml index 7d9cf94cd..ce8de23ab 100644 --- a/tests/integration/targets/nxos_lldp_global/tests/common/parsed.yml +++ b/tests/integration/targets/nxos_lldp_global/tests/common/parsed.yml @@ -3,7 +3,7 @@ msg: START nxos_lldp_global parsed integration tests on connection={{ ansible_connection }} - block: - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_lldp_global: running_config: | diff --git a/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml index 95d6a016b..c34726ef5 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_lldp_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_lldp_interfaces/tasks/main.yaml index b42cad3e3..8d0b94337 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_lldp_interfaces/tasks/main.yaml @@ -1,9 +1,9 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml index fe9d48a7c..e0ebc3f54 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yml" diff --git a/tests/integration/targets/nxos_lldp_interfaces/tests/common/deleted.yml b/tests/integration/targets/nxos_lldp_interfaces/tests/common/deleted.yml index 37513bb1e..639254f52 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tests/common/deleted.yml +++ b/tests/integration/targets/nxos_lldp_interfaces/tests/common/deleted.yml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: Start nxos_lldp_interfaces deleted integration tests connection = {{ ansible_connection }} -- name: Enable lldp feature +- name: Enable 'feature lldp' cisco.nxos.nxos_feature: feature: lldp state: enabled diff --git a/tests/integration/targets/nxos_lldp_interfaces/tests/common/gathered.yml b/tests/integration/targets/nxos_lldp_interfaces/tests/common/gathered.yml index 08acbb878..f9d3e6032 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tests/common/gathered.yml +++ b/tests/integration/targets/nxos_lldp_interfaces/tests/common/gathered.yml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: Start nxos_lldp_interfaces gathered integration tests connection={{ansible_connection}}" -- name: Enable lldp feature +- name: Enable 'feature lldp' cisco.nxos.nxos_feature: feature: lldp state: enabled diff --git a/tests/integration/targets/nxos_lldp_interfaces/tests/common/overridden.yml b/tests/integration/targets/nxos_lldp_interfaces/tests/common/overridden.yml index d336115c4..cb54a42a1 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tests/common/overridden.yml +++ b/tests/integration/targets/nxos_lldp_interfaces/tests/common/overridden.yml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: Start nxos_lldp_interfaces overridden tests connection={{ ansible_connection }} -- name: Enable lldp feature +- name: Enable 'feature lldp' cisco.nxos.nxos_feature: feature: lldp state: enabled diff --git a/tests/integration/targets/nxos_lldp_interfaces/tests/common/replaced.yml b/tests/integration/targets/nxos_lldp_interfaces/tests/common/replaced.yml index 34d443178..601950528 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tests/common/replaced.yml +++ b/tests/integration/targets/nxos_lldp_interfaces/tests/common/replaced.yml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: Start nxos_lldp_interfaces replaced integration tests connection = {{ansible_connection}} -- name: Enable lldp feature +- name: Enable 'feature lldp' cisco.nxos.nxos_feature: feature: lldp state: enabled diff --git a/tests/integration/targets/nxos_lldp_interfaces/tests/common/rtt.yml b/tests/integration/targets/nxos_lldp_interfaces/tests/common/rtt.yml index 69a313720..516fb3fe8 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tests/common/rtt.yml +++ b/tests/integration/targets/nxos_lldp_interfaces/tests/common/rtt.yml @@ -59,7 +59,7 @@ config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" state: overridden - - name: Assert that config was reverted + - name: Assert that configuration was reverted ansible.builtin.assert: that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: diff --git a/tests/integration/targets/nxos_logging/tasks/cli.yaml b/tests/integration/targets/nxos_logging/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_logging/tasks/cli.yaml +++ b/tests/integration/targets/nxos_logging/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_logging/tasks/main.yaml b/tests/integration/targets/nxos_logging/tasks/main.yaml index e7f88d7b4..4e16b2ade 100644 --- a/tests/integration/targets/nxos_logging/tasks/main.yaml +++ b/tests/integration/targets/nxos_logging/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_logging/tasks/nxapi.yaml b/tests/integration/targets/nxos_logging/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_logging/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_logging/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_logging_global/tasks/cli.yaml b/tests/integration/targets/nxos_logging_global/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_logging_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_logging_global/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_logging_global/tasks/main.yaml b/tests/integration/targets/nxos_logging_global/tasks/main.yaml index 490861ca1..b62ef52ee 100644 --- a/tests/integration/targets/nxos_logging_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_logging_global/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_logging_global/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_logging_global/tests/common/_populate_config.yaml index cba00c59c..532e4e058 100644 --- a/tests/integration/targets/nxos_logging_global/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_logging_global/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "logging console 3" diff --git a/tests/integration/targets/nxos_logging_global/tests/common/empty_config.yaml b/tests/integration/targets/nxos_logging_global/tests/common/empty_config.yaml index 408b461f3..22a95f77e 100644 --- a/tests/integration/targets/nxos_logging_global/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_logging_global/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_logging_global empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_logging_global: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_logging_global: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_logging_global: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_logging_global: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_logging_global: diff --git a/tests/integration/targets/nxos_logging_global/tests/common/parsed.yaml b/tests/integration/targets/nxos_logging_global/tests/common/parsed.yaml index 2a14a83be..d959f00a6 100644 --- a/tests/integration/targets/nxos_logging_global/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_logging_global/tests/common/parsed.yaml @@ -8,7 +8,7 @@ running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after'] == result['parsed'] }}" diff --git a/tests/integration/targets/nxos_ntp/tasks/cli.yaml b/tests/integration/targets/nxos_ntp/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_ntp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ntp/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp/tasks/main.yaml b/tests/integration/targets/nxos_ntp/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_ntp/tasks/main.yaml +++ b/tests/integration/targets/nxos_ntp/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp/tests/common/sanity.yaml b/tests/integration/targets/nxos_ntp/tests/common/sanity.yaml index 20a4400ad..f22c99f55 100644 --- a/tests/integration/targets/nxos_ntp/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_ntp/tests/common/sanity.yaml @@ -53,7 +53,7 @@ - ansible.builtin.assert: *id004 - - name: Remove ntp config + - name: Remove ntp configuration register: result cisco.nxos.nxos_ntp: *id005 @@ -107,7 +107,7 @@ - ansible.builtin.assert: *id004 always: - - name: Remove ntp config + - name: Remove ntp configuration cisco.nxos.nxos_ntp: *id005 - ansible.builtin.debug: diff --git a/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml b/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp_auth/tasks/main.yaml b/tests/integration/targets/nxos_ntp_auth/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_ntp_auth/tasks/main.yaml +++ b/tests/integration/targets/nxos_ntp_auth/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp_auth/tests/common/sanity.yaml b/tests/integration/targets/nxos_ntp_auth/tests/common/sanity.yaml index e43f5191c..3ceb9e122 100644 --- a/tests/integration/targets/nxos_ntp_auth/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_ntp_auth/tests/common/sanity.yaml @@ -125,7 +125,7 @@ - ansible.builtin.assert: *id004 always: - - name: Cleanup ntp auth config + - name: Cleanup ntp auth configuration ignore_errors: true cisco.nxos.nxos_ntp_auth: *id009 diff --git a/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml b/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp_global/tasks/main.yaml b/tests/integration/targets/nxos_ntp_global/tasks/main.yaml index 490861ca1..b62ef52ee 100644 --- a/tests/integration/targets/nxos_ntp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_ntp_global/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp_global/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_ntp_global/tests/common/_populate_config.yaml index e4a77143a..2c2e860cb 100644 --- a/tests/integration/targets/nxos_ntp_global/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_ntp_global/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "ntp authenticate" diff --git a/tests/integration/targets/nxos_ntp_global/tests/common/empty_config.yaml b/tests/integration/targets/nxos_ntp_global/tests/common/empty_config.yaml index 048c53d21..16c6144a8 100644 --- a/tests/integration/targets/nxos_ntp_global/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_ntp_global/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_ntp_global empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ntp_global: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ntp_global: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ntp_global: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ntp_global: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ntp_global: diff --git a/tests/integration/targets/nxos_ntp_global/tests/common/parsed.yaml b/tests/integration/targets/nxos_ntp_global/tests/common/parsed.yaml index ab7c5ab38..321c2a9fb 100644 --- a/tests/integration/targets/nxos_ntp_global/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_ntp_global/tests/common/parsed.yaml @@ -8,7 +8,7 @@ running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after'] == result['parsed'] }}" diff --git a/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml b/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp_options/tasks/main.yaml b/tests/integration/targets/nxos_ntp_options/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_ntp_options/tasks/main.yaml +++ b/tests/integration/targets/nxos_ntp_options/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ntp_options/tests/common/sanity.yaml b/tests/integration/targets/nxos_ntp_options/tests/common/sanity.yaml index aef6442c3..1ee9433ef 100644 --- a/tests/integration/targets/nxos_ntp_options/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_ntp_options/tests/common/sanity.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_ntp_options sanity test -- name: Apply default ntp config +- name: Apply default ntp configuration ignore_errors: true cisco.nxos.nxos_ntp_options: &id007 state: absent @@ -91,7 +91,7 @@ - ansible.builtin.assert: *id004 always: - - name: Cleanup ntp config + - name: Cleanup ntp configuration register: result cisco.nxos.nxos_ntp_options: *id007 diff --git a/tests/integration/targets/nxos_nxapi/tasks/cli.yaml b/tests/integration/targets/nxos_nxapi/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_nxapi/tasks/cli.yaml +++ b/tests/integration/targets/nxos_nxapi/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_nxapi/tasks/main.yaml b/tests/integration/targets/nxos_nxapi/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_nxapi/tasks/main.yaml +++ b/tests/integration/targets/nxos_nxapi/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml b/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml index 8a869025c..25cdd4904 100644 --- a/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml b/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml index af6b23f65..990ab8e38 100644 --- a/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml @@ -7,12 +7,12 @@ nxapi_sandbox_option: true when: platform is search('N7K') -- name: Setup - put nxapi in stopped state +- name: Setup - put NX-API in stopped state cisco.nxos.nxos_nxapi: state: absent - block: - - name: Configure nxapi https + - name: Configure NX-API https register: result cisco.nxos.nxos_nxapi: &id001 enable_http: false @@ -34,7 +34,7 @@ - ansible.builtin.include: tasks/platform/default/assert_changes_https.yaml when: platform is not search('N35|N5K|N6K|N7K') - - name: Configure nxapi https again + - name: Configure NX-API https again register: result cisco.nxos.nxos_nxapi: *id001 @@ -43,7 +43,7 @@ that: - result.changed == false - - name: Configure nxapi https & http + - name: Configure NX-API https & http register: result cisco.nxos.nxos_nxapi: &id002 enable_http: true @@ -65,14 +65,14 @@ - ansible.builtin.include: tasks/platform/default/assert_changes_https_http.yaml when: platform is not search('N35|N5K|N6K|N7K') - - name: Configure nxapi https & http again + - name: Configure NX-API https & http again register: result cisco.nxos.nxos_nxapi: *id002 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure different nxapi https & http ports + - name: Configure different NX-API https & http ports register: result cisco.nxos.nxos_nxapi: &id004 enable_http: true @@ -95,14 +95,14 @@ - ansible.builtin.include: tasks/platform/default/assert_changes_https_http_ports.yaml when: platform is not search('N35|N5K|N6K|N7K') - - name: Configure different nxapi https & http ports again + - name: Configure different NX-API https & http ports again register: result cisco.nxos.nxos_nxapi: *id004 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi http + - name: Configure NX-API http register: result cisco.nxos.nxos_nxapi: &id005 enable_http: true @@ -123,19 +123,19 @@ - ansible.builtin.include: tasks/platform/default/assert_changes_http.yaml when: platform is not search('N35|N5K|N6K|N7K') - - name: Configure nxapi http again + - name: Configure NX-API http again register: result cisco.nxos.nxos_nxapi: *id005 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 always: - - name: Cleanup - disable nxapi + - name: Cleanup - disable NX-API register: result cisco.nxos.nxos_nxapi: state: absent - - name: Cleanup - re-enable nxapi + - name: Cleanup - re-enable NX-API register: result cisco.nxos.nxos_nxapi: state: present diff --git a/tests/integration/targets/nxos_nxapi/tests/cli/disable.yaml b/tests/integration/targets/nxos_nxapi/tests/cli/disable.yaml index 8b232ad25..54eea69ab 100644 --- a/tests/integration/targets/nxos_nxapi/tests/cli/disable.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/cli/disable.yaml @@ -2,22 +2,22 @@ - ansible.builtin.debug: msg: START cli/disable.yaml -- name: Disable nxapi +- name: Disable NX-API register: result cisco.nxos.nxos_nxapi: state: absent -- name: Check nxapi state +- name: Check NX-API state register: result cisco.nxos.nxos_command: commands: - show feature | grep nxapi -- name: Assert nxapi is disabled +- name: Assert NX-API is disabled ansible.builtin.assert: that: result.stdout[0] is search('disabled') -- name: Disable nxapi again +- name: Disable NX-API again register: result cisco.nxos.nxos_nxapi: state: absent diff --git a/tests/integration/targets/nxos_nxapi/tests/cli/enable.yaml b/tests/integration/targets/nxos_nxapi/tests/cli/enable.yaml index 13c5e95b0..267d075d4 100644 --- a/tests/integration/targets/nxos_nxapi/tests/cli/enable.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/cli/enable.yaml @@ -2,27 +2,27 @@ - ansible.builtin.debug: msg: START cli/enable.yaml -- name: Setup - put nxapi in stopped state +- name: Setup - put NX-API in stopped state register: result cisco.nxos.nxos_nxapi: state: absent -- name: Enable nxapi +- name: Enable NX-API register: result cisco.nxos.nxos_nxapi: state: present -- name: Check nxapi state +- name: Check NX-API state register: result cisco.nxos.nxos_command: commands: - show feature | grep nxapi -- name: Assert nxapi is enabled +- name: Assert NX-API is enabled ansible.builtin.assert: that: result.stdout[0] is search('enabled') -- name: Enable nxapi again +- name: Enable NX-API again register: result cisco.nxos.nxos_nxapi: diff --git a/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml b/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml index 01d232066..810537664 100644 --- a/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml @@ -3,7 +3,7 @@ - ansible.builtin.debug: msg: START cli/nxapi_ssl.yaml - - name: Configure nxapi https w/weak ciphers + - name: Configure NX-API https w/weak ciphers register: result cisco.nxos.nxos_nxapi: &id001 enable_https: true @@ -20,7 +20,7 @@ that: - result.stdout_lines[0][0] == 'nxapi ssl ciphers weak' - - name: Configure nxapi http w/weak ciphers again + - name: Configure NX-API http w/weak ciphers again register: result cisco.nxos.nxos_nxapi: *id001 @@ -29,7 +29,7 @@ that: - result.changed == false - - name: Configure nxapi https w/strong ciphers + - name: Configure NX-API https w/strong ciphers register: result cisco.nxos.nxos_nxapi: &id002 enable_https: true @@ -46,14 +46,14 @@ that: - result.stdout_lines[0][0] == 'no nxapi ssl ciphers weak' - - name: Configure nxapi https w/strong ciphers again + - name: Configure NX-API https w/strong ciphers again register: result cisco.nxos.nxos_nxapi: *id002 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https w/default tlsv1 + - name: Configure NX-API https w/default tlsv1 register: result cisco.nxos.nxos_nxapi: &id004 enable_https: true @@ -64,19 +64,19 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/default tlsv1 configuration + - name: Assert NX-API https w/default tlsv1 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1' - - name: Configure nxapi https w/default again + - name: Configure NX-API https w/default again register: result cisco.nxos.nxos_nxapi: *id004 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https tlsv1.1 -default tlsv1 + - name: Configure NX-API https tlsv1.1 -default tlsv1 register: result cisco.nxos.nxos_nxapi: &id005 enable_https: true @@ -89,19 +89,19 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/tlsv1.1 configuration + - name: Assert NX-API https w/tlsv1.1 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1.1' - - name: Configure nxapi https w/tlsv1.1 -default tlsv1 again + - name: Configure NX-API https w/tlsv1.1 -default tlsv1 again register: result cisco.nxos.nxos_nxapi: *id005 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https tlsv1.2 -default tlsv1 + - name: Configure NX-API https tlsv1.2 -default tlsv1 register: result cisco.nxos.nxos_nxapi: &id006 enable_https: true @@ -114,19 +114,19 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/tlsv1.2 configuration + - name: Assert NX-API https w/tlsv1.2 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1.2' - - name: Configure nxapi https w/tlsv1.2 -default tlsv1 again + - name: Configure NX-API https w/tlsv1.2 -default tlsv1 again register: result cisco.nxos.nxos_nxapi: *id006 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https w/tls1.2 +default tlsv1 + - name: Configure NX-API https w/tls1.2 +default tlsv1 register: result cisco.nxos.nxos_nxapi: &id007 enable_https: true @@ -139,19 +139,19 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/tls1.2 +default tlsv1 configuration + - name: Assert NX-API https w/tls1.2 +default tlsv1 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1 TLSv1.2' - - name: Configure nxapi https w/tls1.2 again + - name: Configure NX-API https w/tls1.2 again register: result cisco.nxos.nxos_nxapi: *id007 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https w/tls1.2 tls1.1 -default tlsv1 + - name: Configure NX-API https w/tls1.2 tls1.1 -default tlsv1 register: result cisco.nxos.nxos_nxapi: &id008 enable_https: true @@ -166,19 +166,19 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/tls1.2 tls1.2 -default tlsv1 configuration + - name: Assert NX-API https w/tls1.2 tls1.2 -default tlsv1 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1.1 TLSv1.2' - - name: Configure nxapi https w/tls1.2 tls1.1 -default tlsv1 again + - name: Configure NX-API https w/tls1.2 tls1.1 -default tlsv1 again register: result cisco.nxos.nxos_nxapi: *id008 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https w/tls1.2 tls1.1 +default tlsv1 + - name: Configure NX-API https w/tls1.2 tls1.1 +default tlsv1 register: result cisco.nxos.nxos_nxapi: &id009 enable_https: true @@ -192,19 +192,19 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/tls1.2 tls1.1 +default tlsv1 configuration + - name: Assert NX-API https w/tls1.2 tls1.1 +default tlsv1 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1 TLSv1.1 TLSv1.2' - - name: Configure nxapi https w/tls1.2 tls1.1 +default tlsv1 again + - name: Configure NX-API https w/tls1.2 tls1.1 +default tlsv1 again register: result cisco.nxos.nxos_nxapi: *id009 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 - - name: Configure nxapi https with explicit tls1.2 tls1.1 tlsv1 + - name: Configure NX-API https with explicit tls1.2 tls1.1 tlsv1 register: result cisco.nxos.nxos_nxapi: &id010 enable_https: true @@ -219,24 +219,24 @@ commands: - show run all | inc nxapi | inc protocols - - name: Assert nxapi https w/tls1.2 tls1.2 tlsv1 configuration + - name: Assert NX-API https w/tls1.2 tls1.2 tlsv1 configuration ansible.builtin.assert: that: - result.stdout_lines[0][0] == 'nxapi ssl protocols TLSv1 TLSv1.1 TLSv1.2' - - name: Configure nxapi https w/tls1.2 tls1.1 tlsv1 again + - name: Configure NX-API https w/tls1.2 tls1.1 tlsv1 again register: result cisco.nxos.nxos_nxapi: *id010 - name: Assert configuration is idempotent ansible.builtin.assert: *id003 always: - - name: Cleanup - disable nxapi + - name: Cleanup - disable NX-API register: result cisco.nxos.nxos_nxapi: state: absent - - name: Cleanup - re-enable nxapi + - name: Cleanup - re-enable NX-API register: result cisco.nxos.nxos_nxapi: state: present diff --git a/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml b/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml index 7e4875eea..1916114b1 100644 --- a/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxapi/badtransport.yaml -- name: Sending transport other than cli should fail +- name: Sending transport other than CLI should fail register: result ignore_errors: true cisco.nxos.nxos_nxapi: diff --git a/tests/integration/targets/nxos_ospf/tasks/cli.yaml b/tests/integration/targets/nxos_ospf/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_ospf/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ospf/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospf/tasks/main.yaml b/tests/integration/targets/nxos_ospf/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_ospf/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospf/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_ospf/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospf/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_ospf/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ospf/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml b/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml index 110ed3189..e778c704b 100644 --- a/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml @@ -2,14 +2,14 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_ospf sanity test -- name: Enable feature ospf +- name: Enable 'feature ospf' ignore_errors: true cisco.nxos.nxos_feature: feature: ospf state: enabled - block: - - name: Configure ospf + - name: Configure OSPF register: result cisco.nxos.nxos_ospf: &id001 ospf: 1 @@ -27,13 +27,13 @@ that: - result.changed == false rescue: - - name: Disable feature ospf + - name: Disable 'feature ospf' ignore_errors: true cisco.nxos.nxos_feature: feature: ospf state: disabled always: - - name: Unconfigure ospf + - name: Unconfigure OSPF register: result cisco.nxos.nxos_ospf: &id003 ospf: 1 diff --git a/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml index 9f3d5d1dc..96d84552a 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Enable ospf v2 and v3 features +- name: Enable OSPF v2 and v3 features cisco.nxos.nxos_config: lines: - feature ospf @@ -8,18 +8,18 @@ ansible_connection: ansible.netcommon.network_cli - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi always: - - name: Disable ospf v2 and v3 features + - name: Disable OSPF v2 and v3 features cisco.nxos.nxos_config: lines: - feature ospf diff --git a/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/_populate_config.yaml index 377c527d0..d3cae2c42 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "interface {{ nxos_int1 }}" diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/deleted.yaml index 32c90432b..93835760f 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/deleted.yaml @@ -18,7 +18,7 @@ name: "{{ nxos_int3 }}" - block: - - name: Delete ospf config from a single interface + - name: Delete OSPF configuration from a single interface cisco.nxos.nxos_ospf_interfaces: &id001 config: - name: "{{ nxos_int1 }}" @@ -51,7 +51,7 @@ - result["after"][1] == merged["after"][1] - result["after"][2] == merged["after"][2] - - name: Delete ospf config from a single interface (idempotent) + - name: Delete OSPF configuration from a single interface (idempotent) register: result cisco.nxos.nxos_ospf_interfaces: *id001 @@ -63,7 +63,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - - name: Delete ospf config from all interfaces + - name: Delete OSPF configuration from all interfaces cisco.nxos.nxos_ospf_interfaces: &id002 state: deleted register: result @@ -87,7 +87,7 @@ - result["after"][1] == int2 - result["after"][2] == int3 - - name: Delete ospf config from all interfaces (idempotent) + - name: Delete OSPF configuration from all interfaces (idempotent) register: result cisco.nxos.nxos_ospf_interfaces: *id002 diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/empty_config.yaml index d1d05439a..485e94cbb 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_ospf_interfaces empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospf_interfaces: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospf_interfaces: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospf_interfaces: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospf_interfaces: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospf_interfaces: diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/gathered.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/gathered.yaml index 15f8a6b4b..39cca32a4 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/gathered.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/gathered.yaml @@ -9,7 +9,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Gather ospf interfaces facts using gathered + - name: Gather OSPF interfaces facts using gathered register: result cisco.nxos.nxos_ospf_interfaces: state: gathered diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/overridden.yaml index 564d58a22..9f4941c81 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/overridden.yaml @@ -9,7 +9,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Override all ospf interfaces configuration with provided configuration + - name: Override all OSPF interfaces configuration with provided configuration cisco.nxos.nxos_ospf_interfaces: &id001 config: - name: Ethernet1/1 @@ -44,7 +44,7 @@ - result['after'][1] == overridden['after'][1] - result['after'][2] == overridden['after'][2] - - name: Override all ospf interfaces configuration with provided configuration (idempotent) + - name: Override all OSPF interfaces configuration with provided configuration (idempotent) register: result cisco.nxos.nxos_ospf_interfaces: *id001 diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/parsed.yaml index 6e2769fae..eb94fcdc9 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/parsed.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxos_ospf_interfaces parsed integration tests on connection={{ ansible_connection }} -- name: Parse externally provided ospf interfaces config +- name: Parse externally provided OSPF interfaces configuration register: result cisco.nxos.nxos_ospf_interfaces: running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after'] | symmetric_difference(result['parsed']) |length == 0 }}" diff --git a/tests/integration/targets/nxos_ospf_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_ospf_interfaces/tests/common/replaced.yaml index a63b195b5..ace52da02 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tests/common/replaced.yaml @@ -9,7 +9,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Replace ospf configurations of listed interfaces with provided configurations + - name: Replace OSPF configurations of listed interfaces with provided configurations cisco.nxos.nxos_ospf_interfaces: &id001 config: - name: "{{ nxos_int1 }}" @@ -45,7 +45,7 @@ - result['after'][1] == replaced['after'][1] - result['after'][2] == replaced['after'][2] - - name: Replace ospf configurations of listed interfaces with provided configurations (idempotent) + - name: Replace OSPF configurations of listed interfaces with provided configurations (idempotent) register: result cisco.nxos.nxos_ospf_interfaces: *id001 diff --git a/tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml b/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml index 2d562a751..49a6b9ed7 100644 --- a/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml @@ -25,7 +25,7 @@ state: enabled - block: - - name: Configure ospf vrf + - name: Configure OSPF VRF register: result cisco.nxos.nxos_ospf_vrf: &id001 ospf: 1 @@ -53,7 +53,7 @@ that: - result.changed == false - - name: Configure ospf vrf + - name: Configure OSPF VRF register: result cisco.nxos.nxos_ospf_vrf: &id003 ospf: 2 @@ -76,7 +76,7 @@ - ansible.builtin.assert: *id004 - - name: Configure ospf vrf + - name: Configure OSPF VRF register: result cisco.nxos.nxos_ospf_vrf: &id005 ospf: 2 @@ -96,7 +96,7 @@ - ansible.builtin.assert: *id004 - - name: Unconfigure ospf vrf + - name: Unconfigure OSPF VRF register: result cisco.nxos.nxos_ospf_vrf: &id006 ospf: 2 @@ -112,7 +112,7 @@ - ansible.builtin.assert: *id004 when: def_met_default is defined - - name: Unconfigure ospf vrf + - name: Unconfigure OSPF VRF register: result cisco.nxos.nxos_ospf_vrf: &id007 ospf: 1 diff --git a/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml b/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospfv2/tasks/main.yaml b/tests/integration/targets/nxos_ospfv2/tasks/main.yaml index 2dfea601a..9932f222c 100644 --- a/tests/integration/targets/nxos_ospfv2/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospfv2/tasks/main.yaml @@ -1,23 +1,23 @@ --- -- name: Enable ospf feature +- name: Enable 'feature ospf' cisco.nxos.nxos_feature: feature: ospf vars: ansible_connection: ansible.netcommon.network_cli - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi always: - - name: Disable ospf feature + - name: Disable 'feature ospf' cisco.nxos.nxos_feature: feature: ospf state: disabled diff --git a/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/_remove_config.yaml index b0b8884bb..3a3248e65 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove pre-existing ospf processes +- name: Remove pre-existing OSPF processes cisco.nxos.nxos_config: lines: - no router ospf 100 diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml index 919564354..23fab8f35 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Delete a single ospf process + - name: Delete a single OSPF process cisco.nxos.nxos_ospfv2: &id001 config: processes: @@ -31,7 +31,7 @@ that: - "{{ deleted['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" - - name: Delete a single ospf process (idempotent) + - name: Delete a single OSPF process (idempotent) register: result cisco.nxos.nxos_ospfv2: *id001 @@ -48,7 +48,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - - name: Delete all ospf processes from the device + - name: Delete all OSPF processes from the device cisco.nxos.nxos_ospfv2: &id002 state: deleted register: result @@ -70,7 +70,7 @@ that: - "{{ result['after'] == {} }}" - - name: Delete all ospf processes from the device (idempotent) + - name: Delete all OSPF processes from the device (idempotent) register: result cisco.nxos.nxos_ospfv2: *id002 diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml index cbb5de455..c98483e75 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Override all ospf configuration with provided configuration + - name: Override all OSPF configuration with provided configuration cisco.nxos.nxos_ospfv2: &id001 config: processes: @@ -34,7 +34,7 @@ that: - "{{ overridden['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" - - name: Override all ospf configuration with provided configuration (idempotent) + - name: Override all OSPF configuration with provided configuration (idempotent) register: result cisco.nxos.nxos_ospfv2: *id001 diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/parsed.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/parsed.yaml index 7d6c5bf3a..8606c5d72 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/parsed.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxos_ospfv2 parsed integration tests on connection={{ ansible_connection }} -- name: Parse externally provided ospfv2 config +- name: Parse externally provided ospfv2 configuration register: result cisco.nxos.nxos_ospfv2: running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['parsed']['processes']) |length == 0 }}" diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml index b8f6b35ca..f59f487c8 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Replace device configurations of listed ospf processes with provided configurations + - name: Replace device configurations of listed OSPF processes with provided configurations cisco.nxos.nxos_ospfv2: &id001 config: processes: @@ -60,7 +60,7 @@ that: - "{{ replaced['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" - - name: Replace device configurations of listed ospf processes with provided configurarions (idempotent) + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result cisco.nxos.nxos_ospfv2: *id001 diff --git a/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml b/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml +++ b/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospfv3/tasks/main.yaml b/tests/integration/targets/nxos_ospfv3/tasks/main.yaml index 61d5c1b2b..8a734c77e 100644 --- a/tests/integration/targets/nxos_ospfv3/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospfv3/tasks/main.yaml @@ -1,23 +1,23 @@ --- -- name: Enable ospfv3 feature +- name: Enable 'feature ospfv3' cisco.nxos.nxos_feature: feature: ospfv3 vars: ansible_connection: ansible.netcommon.network_cli - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi always: - - name: Disable ospfv3 feature + - name: Disable 'feature ospfv3' cisco.nxos.nxos_feature: feature: ospfv3 state: disabled diff --git a/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/_remove_config.yaml index e01aa8325..5ea2b6dc2 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove pre-existing ospf processes +- name: Remove pre-existing OSPF processes cisco.nxos.nxos_config: lines: - no router ospfv3 100 diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/deleted.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/deleted.yaml index 9ecea72bd..bf860b012 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/deleted.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Delete a single ospf process + - name: Delete a single OSPF process cisco.nxos.nxos_ospfv3: &id001 config: processes: @@ -31,7 +31,7 @@ that: - "{{ deleted['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" - - name: Delete a single ospf process (idempotent) + - name: Delete a single OSPF process (idempotent) register: result cisco.nxos.nxos_ospfv3: *id001 @@ -70,7 +70,7 @@ that: - "{{ result['after'] == {} }}" - - name: Delete all ospf processes from the device (idempotent) + - name: Delete all OSPF processes from the device (idempotent) register: result cisco.nxos.nxos_ospfv3: *id002 diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/empty_config.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/empty_config.yaml index c2fd15274..34996cf3f 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_ospfv3 empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospfv3: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospfv3: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospfv3: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospfv3: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_ospfv3: diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml index 3338bbcdb..7d9bc6c9b 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml @@ -34,7 +34,7 @@ that: - "{{ overridden['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" - - name: Override all ospf configuration with provided configuration (idempotent) + - name: Override all OSPF configuration with provided configuration (idempotent) register: result cisco.nxos.nxos_ospfv3: *id001 diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/parsed.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/parsed.yaml index 7dd384969..3f4c2d2a2 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/parsed.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START nxos_ospfv3 parsed integration tests on connection={{ ansible_connection }} -- name: Parse externally provided ospfv3 config +- name: Parse externally provided ospfv3 configuration register: result cisco.nxos.nxos_ospfv3: running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['parsed']['processes']) |length == 0 }}" diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml index 7d0ff642c..f819c559a 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml @@ -56,7 +56,7 @@ that: - "{{ replaced['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" - - name: Replace device configurations of listed ospf processes with provided configurarions (idempotent) + - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result cisco.nxos.nxos_ospfv3: *id001 diff --git a/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml b/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_overlay_global/tasks/main.yaml b/tests/integration/targets/nxos_overlay_global/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml index ea15558fc..92fffe748 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml @@ -1,5 +1,5 @@ --- -- name: Unconfigure vdc setting limit-resource module-type f3 +- name: Unconfigure VDC setting limit-resource module-type f3 ignore_errors: true cisco.nxos.nxos_config: commands: @@ -10,7 +10,7 @@ ansible.builtin.pause: seconds: 45 -- name: Configure vdc setting allocate interface unallocated-interfaces +- name: Configure VDC setting allocate interface unallocated-interfaces ignore_errors: true cisco.nxos.nxos_config: commands: diff --git a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml index e7cee7b2e..39ed917f2 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml @@ -1,5 +1,5 @@ --- -- name: Get default vdc id +- name: Get default VDC id register: vdcout cisco.nxos.nxos_command: commands: @@ -9,7 +9,7 @@ ansible.builtin.set_fact: vdcid: "{{ vdcout.stdout_lines[0].name }}" -- name: Configure vdc setting limit-resource module-type f3 +- name: Configure VDC setting limit-resource module-type f3 ignore_errors: true cisco.nxos.nxos_config: commands: @@ -20,7 +20,7 @@ ansible.builtin.pause: seconds: 45 -- name: Configure vdc setting allocate interface unallocated-interfaces +- name: Configure VDC setting allocate interface unallocated-interfaces ignore_errors: true cisco.nxos.nxos_config: commands: @@ -31,7 +31,7 @@ ansible.builtin.pause: seconds: 45 -- name: Configure additional n7k requiste features +- name: Configure additional N7K requiste features cisco.nxos.nxos_config: commands: - feature-set fabric diff --git a/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml b/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml index 2fcb3c099..2296290b5 100644 --- a/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml @@ -16,15 +16,15 @@ when: overlay_global_supported - block: - - name: Enable nv overlay evpn + - name: Enable NV overlay EVPN cisco.nxos.nxos_evpn_global: nv_overlay_evpn: true - - name: Apply n7k specific setup config + - name: Apply N7K specific setup configuration ansible.builtin.include: tasks/platform/n7k/setup.yaml when: platform is match('N7K') - - name: Configure additional n7k requiste features + - name: Configure additional N7K requiste features when: platform is match('N7K') cisco.nxos.nxos_config: commands: @@ -83,11 +83,11 @@ - ansible.builtin.assert: *id004 when: overlay_global_supported always: - - name: Apply n7k specific cleanup config + - name: Apply N7K specific cleanup configuration ansible.builtin.include: tasks/platform/n7k/cleanup.yaml when: platform is match('N7K') - - name: Disable nv overlay evpn + - name: Disable NV overlay EVPN ignore_errors: true when: overlay_global_supported cisco.nxos.nxos_evpn_global: diff --git a/tests/integration/targets/nxos_pim/tasks/cli.yaml b/tests/integration/targets/nxos_pim/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_pim/tasks/cli.yaml +++ b/tests/integration/targets/nxos_pim/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_pim/tasks/main.yaml b/tests/integration/targets/nxos_pim/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_pim/tasks/main.yaml +++ b/tests/integration/targets/nxos_pim/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_pim/tasks/nxapi.yaml b/tests/integration/targets/nxos_pim/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_pim/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_pim/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_pim/tests/common/sanity.yaml b/tests/integration/targets/nxos_pim/tests/common/sanity.yaml index c3b46f55e..5b7525644 100644 --- a/tests/integration/targets/nxos_pim/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_pim/tests/common/sanity.yaml @@ -24,7 +24,7 @@ ssm_range: none - block: - - name: Initial config from none + - name: Initial configuration from none register: result cisco.nxos.nxos_pim: &id001 bfd: enable @@ -36,7 +36,7 @@ that: - result.changed == true - - name: Initial config idempotence + - name: Initial configuration idempotence register: result cisco.nxos.nxos_pim: *id001 diff --git a/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml b/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_pim_interface/tasks/main.yaml b/tests/integration/targets/nxos_pim_interface/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_pim_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_pim_interface/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml index e8d32d2a1..86a6c0c46 100644 --- a/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml @@ -107,7 +107,7 @@ - ansible.builtin.assert: *id002 - - name: Configure pim other params + - name: Configure PIM other params register: result cisco.nxos.nxos_pim_interface: &id006 interface: "{{ testint }}" @@ -187,7 +187,7 @@ - ansible.builtin.assert: *id004 always: - - name: Disable feature pim + - name: Disable 'feature pim' loop: - pim - bfd diff --git a/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml b/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml +++ b/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_pim_rp_address/tasks/main.yaml b/tests/integration/targets/nxos_pim_rp_address/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_pim_rp_address/tasks/main.yaml +++ b/tests/integration/targets/nxos_pim_rp_address/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml b/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml b/tests/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml index c681b9b7c..62298058d 100644 --- a/tests/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml +++ b/tests/integration/targets/nxos_pim_rp_address/tests/common/configure.yaml @@ -23,12 +23,12 @@ when: platform is not search('N3L|N7K') - block: - - name: Disable feature pim + - name: Disable 'feature pim' cisco.nxos.nxos_feature: &id014 feature: pim state: disabled - - name: Enable feature pim + - name: Enable 'feature pim' cisco.nxos.nxos_feature: feature: pim state: enabled @@ -216,7 +216,7 @@ - ansible.builtin.assert: *id004 always: - - name: Disable feature pim + - name: Disable 'feature pim' cisco.nxos.nxos_feature: *id014 - ansible.builtin.debug: diff --git a/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml b/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_prefix_lists/tasks/main.yaml b/tests/integration/targets/nxos_prefix_lists/tasks/main.yaml index 490861ca1..b62ef52ee 100644 --- a/tests/integration/targets/nxos_prefix_lists/tasks/main.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml b/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_prefix_lists/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_prefix_lists/tests/common/_populate_config.yaml index 07dc57df2..0b99bb816 100644 --- a/tests/integration/targets/nxos_prefix_lists/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "ipv6 prefix-list AllowIPv6Prefix description allows engineering IPv6 networks" diff --git a/tests/integration/targets/nxos_prefix_lists/tests/common/deleted.yaml b/tests/integration/targets/nxos_prefix_lists/tests/common/deleted.yaml index a88b68fe4..c5647aebe 100644 --- a/tests/integration/targets/nxos_prefix_lists/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tests/common/deleted.yaml @@ -7,7 +7,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - block: - - name: Delete all prefix-lists for an afi + - name: Delete all prefix-lists for an AFI cisco.nxos.nxos_prefix_lists: config: - afi: ipv4 diff --git a/tests/integration/targets/nxos_prefix_lists/tests/common/empty_config.yaml b/tests/integration/targets/nxos_prefix_lists/tests/common/empty_config.yaml index f9619ceff..aca1e30da 100644 --- a/tests/integration/targets/nxos_prefix_lists/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_prefix_lists empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_prefix_lists: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_prefix_lists: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_prefix_lists: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_prefix_lists: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_prefix_lists: diff --git a/tests/integration/targets/nxos_prefix_lists/tests/common/parsed.yaml b/tests/integration/targets/nxos_prefix_lists/tests/common/parsed.yaml index d7404df44..260fe12e9 100644 --- a/tests/integration/targets/nxos_prefix_lists/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_prefix_lists/tests/common/parsed.yaml @@ -8,7 +8,7 @@ running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after'][0] == result['parsed'][0] }}" diff --git a/tests/integration/targets/nxos_reboot/tasks/cli.yaml b/tests/integration/targets/nxos_reboot/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_reboot/tasks/cli.yaml +++ b/tests/integration/targets/nxos_reboot/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_reboot/tasks/main.yaml b/tests/integration/targets/nxos_reboot/tasks/main.yaml index 605600c6a..cbbbcb242 100644 --- a/tests/integration/targets/nxos_reboot/tasks/main.yaml +++ b/tests/integration/targets/nxos_reboot/tasks/main.yaml @@ -1,8 +1,8 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: nxapi diff --git a/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml b/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml index df9e12782..57e91e216 100644 --- a/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_rollback/tasks/cli.yaml b/tests/integration/targets/nxos_rollback/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_rollback/tasks/cli.yaml +++ b/tests/integration/targets/nxos_rollback/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_rollback/tasks/main.yaml b/tests/integration/targets/nxos_rollback/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_rollback/tasks/main.yaml +++ b/tests/integration/targets/nxos_rollback/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml b/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_route_maps/tasks/cli.yaml b/tests/integration/targets/nxos_route_maps/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_route_maps/tasks/cli.yaml +++ b/tests/integration/targets/nxos_route_maps/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_route_maps/tasks/main.yaml b/tests/integration/targets/nxos_route_maps/tasks/main.yaml index 490861ca1..b62ef52ee 100644 --- a/tests/integration/targets/nxos_route_maps/tasks/main.yaml +++ b/tests/integration/targets/nxos_route_maps/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml b/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_route_maps/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_route_maps/tests/common/_populate_config.yaml index 2780daeab..3bcd50a70 100644 --- a/tests/integration/targets/nxos_route_maps/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_route_maps/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "route-map rmap1 permit 10" diff --git a/tests/integration/targets/nxos_route_maps/tests/common/empty_config.yaml b/tests/integration/targets/nxos_route_maps/tests/common/empty_config.yaml index 93178b888..898bea2da 100644 --- a/tests/integration/targets/nxos_route_maps/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_route_maps/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_route_maps empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_route_maps: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_route_maps: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_route_maps: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_route_maps: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_route_maps: diff --git a/tests/integration/targets/nxos_route_maps/tests/common/parsed.yaml b/tests/integration/targets/nxos_route_maps/tests/common/parsed.yaml index 9d80c2146..68b6e4104 100644 --- a/tests/integration/targets/nxos_route_maps/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_route_maps/tests/common/parsed.yaml @@ -8,7 +8,7 @@ running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ merged['after'] | symmetric_difference(result['parsed']) |length == 0 }}" diff --git a/tests/integration/targets/nxos_rpm/tasks/cli.yaml b/tests/integration/targets/nxos_rpm/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_rpm/tasks/cli.yaml +++ b/tests/integration/targets/nxos_rpm/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_rpm/tasks/main.yaml b/tests/integration/targets/nxos_rpm/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_rpm/tasks/main.yaml +++ b/tests/integration/targets/nxos_rpm/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml b/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_smoke/tasks/cli.yaml b/tests/integration/targets/nxos_smoke/tasks/cli.yaml index ca596aeb1..f7c86a15a 100644 --- a/tests/integration/targets/nxos_smoke/tasks/cli.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_smoke/tasks/main.yaml b/tests/integration/targets/nxos_smoke/tasks/main.yaml index 33f5864f6..d4c726ce7 100644 --- a/tests/integration/targets/nxos_smoke/tasks/main.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/main.yaml @@ -3,11 +3,11 @@ # This block/always ensures the hostname gets changed back to # the correct name. - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - "cli" - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - "nxapi" diff --git a/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml index 9009e1058..1f1604aa3 100644 --- a/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_smoke/tests/common/caching.yaml b/tests/integration/targets/nxos_smoke/tests/common/caching.yaml index 727b4577f..f0a95deb1 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/caching.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/caching.yaml @@ -42,7 +42,7 @@ that: - result.changed == False - - name: Merge l2 interfaces configuration + - name: Merge layer 2 interfaces configuration register: result cisco.nxos.nxos_l2_interfaces: &mergedl2 config: @@ -59,7 +59,7 @@ - '"switchport trunk allowed vlan 2,4,15" in result.commands' - result.commands|length == 3 - - name: Merge l2 interfaces configuration (idempotent) + - name: Merge layer 2 interfaces configuration (idempotent) register: result cisco.nxos.nxos_l2_interfaces: *mergedl2 @@ -67,7 +67,7 @@ that: - result.changed == False - - name: Merge l3 interfaces configuration + - name: Merge layer 3 interfaces configuration register: result cisco.nxos.nxos_l3_interfaces: &mergedl3 config: @@ -82,7 +82,7 @@ - '"ip address 203.0.113.1/24" in result.commands' - result.commands|length == 2 - - name: Merge l3 interfaces configuration (idempotent) + - name: Merge layer 3 interfaces configuration (idempotent) register: result cisco.nxos.nxos_l3_interfaces: *mergedl3 diff --git a/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml b/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml index b4be2399a..82530fa8b 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml @@ -37,7 +37,7 @@ state: absent with_items: "{{backup_files.files|default([])}}" -- name: Configure device with config +- name: Configure device with configuration cisco.nxos.nxos_config: commands: - description this is a test diff --git a/tests/integration/targets/nxos_snapshot/tasks/cli.yaml b/tests/integration/targets/nxos_snapshot/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snapshot/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snapshot/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snapshot/tasks/main.yaml b/tests/integration/targets/nxos_snapshot/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_snapshot/tasks/main.yaml +++ b/tests/integration/targets/nxos_snapshot/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml b/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snapshot/tests/common/sanity.yaml b/tests/integration/targets/nxos_snapshot/tests/common/sanity.yaml index e518f2864..7def15904 100644 --- a/tests/integration/targets/nxos_snapshot/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_snapshot/tests/common/sanity.yaml @@ -38,7 +38,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_snapshot: *id001 @@ -79,7 +79,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_snapshot: *id005 @@ -102,7 +102,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_snapshot: *id006 @@ -115,7 +115,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_snapshot: *id007 diff --git a/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_community/tasks/main.yaml b/tests/integration/targets/nxos_snmp_community/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_snmp_community/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_community/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_community/tests/common/sanity.yaml b/tests/integration/targets/nxos_snmp_community/tests/common/sanity.yaml index acfc423e3..c83ec6176 100644 --- a/tests/integration/targets/nxos_snmp_community/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_snmp_community/tests/common/sanity.yaml @@ -106,7 +106,7 @@ - ansible.builtin.assert: *id004 - - name: Change acl + - name: Change ACL register: result cisco.nxos.nxos_snmp_community: &id008 community: TESTING7 @@ -122,7 +122,7 @@ - ansible.builtin.assert: *id004 - - name: Remove acl + - name: Remove ACL register: result cisco.nxos.nxos_snmp_community: &id009 community: TESTING7 diff --git a/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_contact/tasks/main.yaml b/tests/integration/targets/nxos_snmp_contact/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_snmp_contact/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_contact/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_contact/tests/common/sanity.yaml b/tests/integration/targets/nxos_snmp_contact/tests/common/sanity.yaml index 3cf3ea6c6..a5757c89b 100644 --- a/tests/integration/targets/nxos_snmp_contact/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_snmp_contact/tests/common/sanity.yaml @@ -8,7 +8,7 @@ state: absent - block: - - name: Configure snmp contact + - name: Configure SNMP contact register: result cisco.nxos.nxos_snmp_contact: &id001 contact: Testing @@ -26,7 +26,7 @@ that: - result.changed == false - - name: Change snmp contact + - name: Change SNMP contact register: result cisco.nxos.nxos_snmp_contact: &id003 contact: Test @@ -40,7 +40,7 @@ - ansible.builtin.assert: *id004 - - name: Remove snmp contact + - name: Remove SNMP contact register: result cisco.nxos.nxos_snmp_contact: *id005 diff --git a/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_host/tasks/main.yaml b/tests/integration/targets/nxos_snmp_host/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_snmp_host/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_host/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml index 50cc754b6..f0420f99d 100644 --- a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml +++ b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml @@ -29,7 +29,7 @@ state: absent - block: - - name: Configure snmp host + - name: Configure SNMP host register: result cisco.nxos.nxos_snmp_host: &id001 snmp_host: 192.0.2.3 diff --git a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml index 87a1849d0..664bea9eb 100644 --- a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml +++ b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v2_inform.yaml @@ -29,7 +29,7 @@ state: absent - block: - - name: Configure snmp host + - name: Configure SNMP host register: result cisco.nxos.nxos_snmp_host: &id001 snmp_host: 192.0.2.3 diff --git a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml index e860ac4d7..03dcbd333 100644 --- a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml +++ b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_inform.yaml @@ -42,7 +42,7 @@ state: absent - block: - - name: Configure snmp host + - name: Configure SNMP host register: result cisco.nxos.nxos_snmp_host: &id001 snmp_host: 192.0.2.3 diff --git a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml index 9ef332044..a77318d32 100644 --- a/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml +++ b/tests/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v3_trap.yaml @@ -34,7 +34,7 @@ state: absent - block: - - name: Configure snmp host + - name: Configure SNMP host register: result cisco.nxos.nxos_snmp_host: &id001 snmp_host: 192.0.2.3 diff --git a/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_location/tasks/main.yaml b/tests/integration/targets/nxos_snmp_location/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_snmp_location/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_location/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_location/tests/common/sanity.yaml b/tests/integration/targets/nxos_snmp_location/tests/common/sanity.yaml index d83085543..4e8ecf0b2 100644 --- a/tests/integration/targets/nxos_snmp_location/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_snmp_location/tests/common/sanity.yaml @@ -8,7 +8,7 @@ state: absent - block: - - name: Configure snmp location + - name: Configure SNMP location register: result cisco.nxos.nxos_snmp_location: &id001 location: Testing @@ -26,7 +26,7 @@ that: - result.changed == false - - name: Change snmp location + - name: Change SNMP location register: result cisco.nxos.nxos_snmp_location: &id003 location: Test @@ -40,7 +40,7 @@ - ansible.builtin.assert: *id004 - - name: Remove snmp location + - name: Remove SNMP location register: result cisco.nxos.nxos_snmp_location: *id005 diff --git a/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index b4e4ac99c..173354b42 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -1,39 +1,39 @@ --- -- name: Get admin user snmp data +- name: Get admin user SNMP data cisco.nxos.nxos_command: commands: show running | section '^snmp-server user' register: result -- name: Grep admin user snmp localized key +- name: Grep admin user SNMP localized key ansible.builtin.set_fact: admin_snmp_passwd: "{{ result['stdout'][0] | regex_search('snmp-server user admin network-admin auth (md5|sha) (\\S+)', '\\2') }}" -- name: Find admin user snmp localized key +- name: Find admin user SNMP localized key ansible.builtin.set_fact: admin_snmp_passwd: "{{ admin_snmp_passwd[0] }}" -- name: Grep admin user snmp localized key (second) +- 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) (\\S+)', '\\2') }}" -- name: Find admin user snmp localized key (second) +- name: Find admin user SNMP localized key (second) ansible.builtin.set_fact: admin_snmp_passwd_2: "{{ admin_snmp_passwd_2[0] }}" -- name: Grep admin user snmp engineid (second) +- name: Grep admin user SNMP engineid (second) ansible.builtin.set_fact: admin_snmp_engineid_2: "{{ result['stdout'][0] | regex_search('admin auth (md5|sha) (\\S+) priv (\\S+) localizedkey engineID (\\S+)', '\\4') }}" -- name: Find admin user snmp engineid (second) +- name: Find admin user SNMP engineid (second) ansible.builtin.set_fact: admin_snmp_engineid_2: "{{ admin_snmp_engineid_2[0] }}" -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli.yaml -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml index 2e452bb6a..5cb76e671 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/_populate_config.yaml index 7aa4cd8af..08cf504a4 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - snmp-server contact nxosswitchadmin@localhost diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml index db53f4e09..f770d3c45 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml @@ -22,6 +22,6 @@ - no snmp-server host 192.0.3.2 informs version 3 auth NMS ignore_errors: true -- name: Remove remaining config +- name: Remove remaining configuration cisco.nxos.nxos_snmp_server: state: deleted diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/empty_config.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/empty_config.yaml index 0e125fd40..b83d1f940 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_snmp_server empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_snmp_server: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_snmp_server: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_snmp_server: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_snmp_server: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_snmp_server: diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/parsed.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/parsed.yaml index c2b16b497..aecccf9b3 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/parsed.yaml @@ -8,7 +8,7 @@ running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" state: parsed -- name: Assert that config was correctly parsed +- name: Assert that configuration was correctly parsed ansible.builtin.assert: that: - "{{ parsed == result['parsed'] }}" diff --git a/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml b/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_traps/tests/common/sanity.yaml b/tests/integration/targets/nxos_snmp_traps/tests/common/sanity.yaml index 6d0d8d9ed..787d223b3 100644 --- a/tests/integration/targets/nxos_snmp_traps/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_snmp_traps/tests/common/sanity.yaml @@ -8,7 +8,7 @@ state: disabled - block: - - name: Configure one snmp trap group + - name: Configure one SNMP trap group register: result cisco.nxos.nxos_snmp_traps: &id001 group: bridge @@ -26,7 +26,7 @@ that: - result.changed == false - - name: Remove snmp trap group + - name: Remove SNMP trap group register: result cisco.nxos.nxos_snmp_traps: &id003 group: bridge @@ -40,7 +40,7 @@ - ansible.builtin.assert: *id004 - - name: Configure all snmp trap groups + - name: Configure all SNMP trap groups register: result cisco.nxos.nxos_snmp_traps: &id005 group: all diff --git a/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml +++ b/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_user/tasks/main.yaml b/tests/integration/targets/nxos_snmp_user/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_snmp_user/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_user/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_snmp_user/tests/common/sanity.yaml b/tests/integration/targets/nxos_snmp_user/tests/common/sanity.yaml index 15f518c11..ed6ca2c94 100644 --- a/tests/integration/targets/nxos_snmp_user/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_snmp_user/tests/common/sanity.yaml @@ -16,7 +16,7 @@ delete_last_user_allowed: false when: platform is search('N5K|N6K|N9K-F') -- name: Remove snmp user +- name: Remove SNMP user ignore_errors: true when: platform is not search('N5K|N6K|N9K-F') cisco.nxos.nxos_snmp_user: &id006 @@ -34,7 +34,7 @@ seconds: 5 - block: - - name: Create snmp user + - name: Create SNMP user register: result cisco.nxos.nxos_snmp_user: user: ntc @@ -102,7 +102,7 @@ - assert: *id004 when: delete_last_user_allowed always: - - name: Delete snmp user + - name: Delete SNMP user when: platform is not search('N5K|N6K|N9K-F') cisco.nxos.nxos_snmp_user: *id006 diff --git a/tests/integration/targets/nxos_static_route/tasks/cli.yaml b/tests/integration/targets/nxos_static_route/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_static_route/tasks/cli.yaml +++ b/tests/integration/targets/nxos_static_route/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_static_route/tasks/main.yaml b/tests/integration/targets/nxos_static_route/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_static_route/tasks/main.yaml +++ b/tests/integration/targets/nxos_static_route/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_static_route/tasks/nxapi.yaml b/tests/integration/targets/nxos_static_route/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_static_route/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_static_route/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml b/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml index c3f405c74..68a135e23 100644 --- a/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml @@ -67,7 +67,7 @@ that: - result.changed == true - - name: Conf static idempotence + - name: Configure static idempotence with_items: "{{ vrfs }}" register: result cisco.nxos.nxos_static_route: *id001 diff --git a/tests/integration/targets/nxos_static_routes/tasks/cli.yaml b/tests/integration/targets/nxos_static_routes/tasks/cli.yaml index 3adda1dad..e22d5c622 100644 --- a/tests/integration/targets/nxos_static_routes/tasks/cli.yaml +++ b/tests/integration/targets/nxos_static_routes/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_static_routes/tasks/main.yaml b/tests/integration/targets/nxos_static_routes/tasks/main.yaml index 09b5ab67b..159ffa2b9 100644 --- a/tests/integration/targets/nxos_static_routes/tasks/main.yaml +++ b/tests/integration/targets/nxos_static_routes/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - "cli" diff --git a/tests/integration/targets/nxos_static_routes/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_static_routes/tests/common/_populate_config.yaml index d0a8d79a2..e4de1e60e 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_static_routes/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "ip route 192.0.2.16/28 192.0.2.24 name new_route" diff --git a/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml index ea1626ce4..4ea8351c6 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "no ip route 192.0.2.16/28 192.0.2.24 name new_route" diff --git a/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml b/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml index 452883205..67c89cc33 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml +++ b/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml @@ -12,7 +12,7 @@ - "!min" gather_network_resources: static_routes - - name: Delete all routes based on vrf + - name: Delete all routes based on VRF cisco.nxos.nxos_static_routes: config: - vrf: trial_vrf @@ -29,7 +29,7 @@ - ansible.builtin.include_tasks: _populate_config.yaml - - name: Delete routes based on afi in a vrf + - name: Delete routes based on AFI in a VRF cisco.nxos.nxos_static_routes: config: - vrf: trial_vrf diff --git a/tests/integration/targets/nxos_system/tasks/cli.yaml b/tests/integration/targets/nxos_system/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_system/tasks/cli.yaml +++ b/tests/integration/targets/nxos_system/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_system/tasks/main.yaml b/tests/integration/targets/nxos_system/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_system/tasks/main.yaml +++ b/tests/integration/targets/nxos_system/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_system/tasks/nxapi.yaml b/tests/integration/targets/nxos_system/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_system/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_system/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_system/tests/common/sanity.yaml b/tests/integration/targets/nxos_system/tests/common/sanity.yaml index c361d173b..ffd325c0b 100644 --- a/tests/integration/targets/nxos_system/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_system/tests/common/sanity.yaml @@ -48,7 +48,7 @@ - ansible.builtin.assert: *id004 - - name: Configure name servers with vrf support + - name: Configure name servers with VRF support register: result cisco.nxos.nxos_system: &id005 name_servers: diff --git a/tests/integration/targets/nxos_telemetry/tasks/cli.yaml b/tests/integration/targets/nxos_telemetry/tasks/cli.yaml index 959a86621..311e39414 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/cli.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_telemetry/tasks/main.yaml b/tests/integration/targets/nxos_telemetry/tasks/main.yaml index 486d1f83b..f5ad5c61b 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/main.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/main.yaml @@ -18,7 +18,7 @@ commands: show interface mgmt 0 | json register: result -- name: Store mgmt interface ip address +- name: Store mgmt interface IP address ansible.builtin.set_fact: mgmt0_ip: "{{ result['stdout'][0]['TABLE_interface']['ROW_interface']['eth_ip_addr'] }}" @@ -34,7 +34,7 @@ configured_password: "{{ temp_passwd }}" no_log: true -- name: Setup - turn on feature scp-server +- name: Setup - turn on 'feature scp-server' cisco.nxos.nxos_feature: feature: scp-server state: enabled @@ -67,12 +67,12 @@ ansible_connection: ansible.netcommon.network_cli - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: cli when: run_test - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: nxapi when: run_test @@ -82,7 +82,7 @@ name: temp_user state: absent - - name: Turn off feature scp-server + - name: Turn off 'feature scp-server' cisco.nxos.nxos_feature: feature: scp-server state: disabled diff --git a/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml b/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml index c5f0e9199..18bf1b6ef 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_telemetry/tests/common/replaced.yaml b/tests/integration/targets/nxos_telemetry/tests/common/replaced.yaml index 679463a28..e3b6ce0fc 100644 --- a/tests/integration/targets/nxos_telemetry/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_telemetry/tests/common/replaced.yaml @@ -25,22 +25,22 @@ dict_facts_length: 7 when: imagetag and (major_version is version_compare('9.1', 'ge')) -- name: Setup - disable feature telemetry +- name: Setup - disable 'feature telemetry' ignore_errors: true cisco.nxos.nxos_feature: &id003 feature: telemetry state: disabled -- name: Setup - enable feature telemetry +- name: Setup - enable 'feature telemetry' cisco.nxos.nxos_feature: feature: telemetry state: enabled -- name: Setup - add initial telemetry config +- name: Setup - add initial telemetry configuration cisco.nxos.nxos_config: src: populate_config.cfg -- name: Setup - add initial source-interface telemetry config +- name: Setup - add initial source-interface telemetry configuration when: imagetag and (major_version is version_compare('9.1', 'ge')) cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_udld/tasks/cli.yaml b/tests/integration/targets/nxos_udld/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_udld/tasks/cli.yaml +++ b/tests/integration/targets/nxos_udld/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_udld/tasks/main.yaml b/tests/integration/targets/nxos_udld/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_udld/tasks/main.yaml +++ b/tests/integration/targets/nxos_udld/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_udld/tasks/nxapi.yaml b/tests/integration/targets/nxos_udld/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_udld/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_udld/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_udld/tests/common/sanity.yaml b/tests/integration/targets/nxos_udld/tests/common/sanity.yaml index e24c40973..114792d0a 100644 --- a/tests/integration/targets/nxos_udld/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_udld/tests/common/sanity.yaml @@ -17,7 +17,7 @@ when: titanium - block: - - name: Enable feature udld + - name: Enable 'feature udld' cisco.nxos.nxos_feature: feature: udld state: enabled @@ -76,7 +76,7 @@ - ansible.builtin.assert: *id002 - - name: Remove udld config + - name: Remove udld configuration register: result cisco.nxos.nxos_udld: &id006 state: absent diff --git a/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml b/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_udld_interface/tasks/main.yaml b/tests/integration/targets/nxos_udld_interface/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_udld_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_udld_interface/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_udld_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_udld_interface/tests/common/sanity.yaml index 549e3acd5..9ad5f697e 100644 --- a/tests/integration/targets/nxos_udld_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_udld_interface/tests/common/sanity.yaml @@ -30,7 +30,7 @@ intname: "{{ nxos_int1 }}" - block: - - name: Enable feature udld + - name: Enable 'feature udld' cisco.nxos.nxos_feature: feature: udld state: enabled @@ -104,7 +104,7 @@ - assert: *id004 when: udld_enable - - name: Remove the config + - name: Remove the configuration cisco.nxos.nxos_udld_interface: interface: "{{ intname }}" mode: enabled diff --git a/tests/integration/targets/nxos_user/tasks/cli.yaml b/tests/integration/targets/nxos_user/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_user/tasks/cli.yaml +++ b/tests/integration/targets/nxos_user/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_user/tasks/main.yaml b/tests/integration/targets/nxos_user/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_user/tasks/main.yaml +++ b/tests/integration/targets/nxos_user/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_user/tasks/nxapi.yaml b/tests/integration/targets/nxos_user/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_user/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_user/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vlan/tasks/cli.yaml b/tests/integration/targets/nxos_vlan/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vlan/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vlan/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vlan/tasks/main.yaml b/tests/integration/targets/nxos_vlan/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vlan/tasks/main.yaml +++ b/tests/integration/targets/nxos_vlan/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vlan/tasks/nxapi.yaml b/tests/integration/targets/nxos_vlan/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vlan/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vlan/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vlan/tests/common/agg.yaml b/tests/integration/targets/nxos_vlan/tests/common/agg.yaml index aefb383f2..57ee9459d 100644 --- a/tests/integration/targets/nxos_vlan/tests/common/agg.yaml +++ b/tests/integration/targets/nxos_vlan/tests/common/agg.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }}/agg.yaml -- name: Setup - remove vlan used in test +- name: Setup - remove VLAN used in test ignore_errors: true cisco.nxos.nxos_config: &id005 lines: @@ -10,7 +10,7 @@ - no vlan 103 - no vlan 104 -- name: Configure vlan with aggregate +- name: Configure VLAN with aggregate register: result cisco.nxos.nxos_vlan: &id001 aggregate: @@ -38,7 +38,7 @@ that: - result.changed == false -- name: Change property of existing vlan - admin_state down +- name: Change property of existing VLAN - admin_state down register: result cisco.nxos.nxos_vlan: &id002 aggregate: diff --git a/tests/integration/targets/nxos_vlan/tests/common/interface.yaml b/tests/integration/targets/nxos_vlan/tests/common/interface.yaml index 1e6fdc7fa..e1cbe3bbd 100644 --- a/tests/integration/targets/nxos_vlan/tests/common/interface.yaml +++ b/tests/integration/targets/nxos_vlan/tests/common/interface.yaml @@ -7,31 +7,31 @@ ansible.builtin.set_fact: testint2: "{{ nxos_int2 }}" -- name: Setup - remove vlan used in test +- name: Setup - remove VLAN used in test ignore_errors: true cisco.nxos.nxos_config: lines: - no vlan 100 -- name: Setup - remove vlan from interfaces used in test(part1) +- name: Setup - remove VLAN from interfaces used in test(part1) cisco.nxos.nxos_config: lines: - no switchport access vlan 100 parents: switchport before: interface {{ testint1 }} -- name: Setup - remove vlan from interfaces used in test(part2) +- name: Setup - remove VLAN from interfaces used in test(part2) cisco.nxos.nxos_config: lines: - no switchport access vlan 100 parents: switchport before: interface {{ testint2 }} -- name: Create vlan +- name: Create VLAN cisco.nxos.nxos_vlan: vlan_id: 100 -- name: Add interfaces to vlan and check intent (config + intent) +- name: Add interfaces to VLAN and check intent (config + intent) register: result cisco.nxos.nxos_vlan: &id001 vlan_id: 100 @@ -86,7 +86,7 @@ that: - result.failed == True -- name: Remove interface from vlan +- name: Remove interface from VLAN register: result cisco.nxos.nxos_vlan: &id002 vlan_id: 100 @@ -114,14 +114,14 @@ lines: - no vlan 100 -- name: Teardown - remove vlan from interfaces used in test(part1) +- name: Teardown - remove VLAN from interfaces used in test(part1) cisco.nxos.nxos_config: lines: - no switchport access vlan 100 parents: switchport before: interface {{ testint1 }} -- name: Teardown - remove vlan from interfaces used in test(part2) +- name: Teardown - remove VLAN from interfaces used in test(part2) cisco.nxos.nxos_config: lines: - no switchport access vlan 100 diff --git a/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml b/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml index db260a1f0..2ffcf0d5e 100644 --- a/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml @@ -11,14 +11,14 @@ testint2: "{{ nxos_int2 }}" - block: - - name: Install and enable fabricpath feature set + - name: Install and enable 'feature-set fabricpath' when: platform is search('N5K|N7K') cisco.nxos.nxos_config: lines: - install feature-set fabricpath - feature-set fabricpath - - name: Enable feature vn segment + - name: Enable 'feature vn-segment-vlan-based' when: platform is search('N9K') cisco.nxos.nxos_config: commands: @@ -48,7 +48,7 @@ that: - result.changed == false - - name: Ensure vlan 50 exists with the name web and is in the shutdown state + - name: Ensure VLAN 50 exists with the name web and is in the shutdown state register: result when: platform is search('N9K') cisco.nxos.nxos_vlan: &id003 @@ -90,7 +90,7 @@ - ansible.builtin.assert: *id004 when: platform is search('N9K') - - name: Ensure vlan 50 exists with the name web and is in the shutdown state + - name: Ensure VLAN 50 exists with the name web and is in the shutdown state register: result when: platform is search('N3K|N7K') cisco.nxos.nxos_vlan: &id006 @@ -166,7 +166,7 @@ - ansible.builtin.assert: *id004 when: platform is search('N5K|N7K') - - name: Ensure vlan is not on the device + - name: Ensure VLAN is not on the device register: result cisco.nxos.nxos_vlan: &id010 vlan_id: 50 @@ -174,13 +174,13 @@ - ansible.builtin.assert: *id002 - - name: No vlan idempotence + - name: No VLAN idempotence register: result cisco.nxos.nxos_vlan: *id010 - ansible.builtin.assert: *id004 - - name: Add interfaces to vlan + - name: Add interfaces to VLAN register: result cisco.nxos.nxos_vlan: &id011 vlan_id: 101 @@ -197,7 +197,7 @@ - ansible.builtin.assert: *id004 - - name: Remove interfaces from vlan + - name: Remove interfaces from VLAN register: result cisco.nxos.nxos_vlan: &id012 vlan_id: 101 @@ -211,15 +211,15 @@ - ansible.builtin.assert: *id004 always: - - name: Remove int from vlan + - name: Remove int from VLAN ignore_errors: true cisco.nxos.nxos_vlan: *id012 - - name: Vlan teardown final + - name: VLAN teardown final ignore_errors: true cisco.nxos.nxos_vlan: *id013 - - name: Disable feature vn segement + - name: Disable 'feature vn-segment-vlan-based' ignore_errors: true when: platform is search('N9K') cisco.nxos.nxos_feature: diff --git a/tests/integration/targets/nxos_vlans/tasks/cli.yaml b/tests/integration/targets/nxos_vlans/tasks/cli.yaml index 507d803cb..9e4fb34bc 100644 --- a/tests/integration/targets/nxos_vlans/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vlans/tasks/cli.yaml @@ -7,7 +7,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vlans/tasks/main.yaml b/tests/integration/targets/nxos_vlans/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vlans/tasks/main.yaml +++ b/tests/integration/targets/nxos_vlans/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml b/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vlans/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_vlans/tests/common/_populate_config.yaml index 6a991317b..63d297e15 100644 --- a/tests/integration/targets/nxos_vlans/tests/common/_populate_config.yaml +++ b/tests/integration/targets/nxos_vlans/tests/common/_populate_config.yaml @@ -1,5 +1,5 @@ --- -- name: Populate config +- name: Populate configuration cisco.nxos.nxos_config: lines: - "feature vn-segment-vlan-based" diff --git a/tests/integration/targets/nxos_vlans/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_vlans/tests/common/_remove_config.yaml index 7f0413d30..0fc5ff730 100644 --- a/tests/integration/targets/nxos_vlans/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_vlans/tests/common/_remove_config.yaml @@ -1,5 +1,5 @@ --- -- name: Remove config +- name: Remove configuration cisco.nxos.nxos_config: lines: - "no vlan 2-100" diff --git a/tests/integration/targets/nxos_vlans/tests/common/empty_config.yaml b/tests/integration/targets/nxos_vlans/tests/common/empty_config.yaml index a9275a39e..1f8b10420 100644 --- a/tests/integration/targets/nxos_vlans/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_vlans/tests/common/empty_config.yaml @@ -2,7 +2,7 @@ - ansible.builtin.debug: msg: START nxos_vlans empty_config integration tests on connection={{ ansible_connection }} -- name: Merged with empty config should give appropriate error message +- name: Merged with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_vlans: @@ -13,7 +13,7 @@ that: - result.msg == 'value of config parameter must not be empty for state merged' -- name: Replaced with empty config should give appropriate error message +- name: Replaced with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_vlans: @@ -24,7 +24,7 @@ that: - result.msg == 'value of config parameter must not be empty for state replaced' -- name: Overridden with empty config should give appropriate error message +- name: Overridden with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_vlans: @@ -35,7 +35,7 @@ that: - result.msg == 'value of config parameter must not be empty for state overridden' -- name: Rendered with empty config should give appropriate error message +- name: Rendered with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_vlans: @@ -46,7 +46,7 @@ that: - result.msg == 'value of config parameter must not be empty for state rendered' -- name: Parsed with empty config should give appropriate error message +- name: Parsed with empty configuration should give appropriate error message register: result ignore_errors: true cisco.nxos.nxos_vlans: diff --git a/tests/integration/targets/nxos_vlans/tests/common/overridden.yaml b/tests/integration/targets/nxos_vlans/tests/common/overridden.yaml index f2c7c9f9f..386907949 100644 --- a/tests/integration/targets/nxos_vlans/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_vlans/tests/common/overridden.yaml @@ -23,7 +23,7 @@ - "!min" gather_network_resources: vlans - - name: Set default vlan (vlan1) config and config to revert + - name: Set default VLAN (vlan1) configuration and configuration to revert ansible.builtin.set_fact: default_vlan: "{{ ansible_facts.network_resources.vlans|selectattr('vlan_id', 'equalto', 1)|list }}" config_to_override: diff --git a/tests/integration/targets/nxos_vlans/tests/common/parsed.yaml b/tests/integration/targets/nxos_vlans/tests/common/parsed.yaml index 306f5f8ce..4bb03d422 100644 --- a/tests/integration/targets/nxos_vlans/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_vlans/tests/common/parsed.yaml @@ -3,7 +3,7 @@ msg: START nxos_vlans parsed integration tests on connection={{ ansible_connection }} - block: - - name: Use parsed state to convert externally supplied config to structured format + - name: Use parsed state to convert externally supplied configuration to structured format register: result cisco.nxos.nxos_vlans: running_config: "{{ lookup('file', '{{ role_path }}/fixtures/parsed.cfg') }}" diff --git a/tests/integration/targets/nxos_vlans/tests/common/rtt.yaml b/tests/integration/targets/nxos_vlans/tests/common/rtt.yaml index 17e335127..fc5a66043 100644 --- a/tests/integration/targets/nxos_vlans/tests/common/rtt.yaml +++ b/tests/integration/targets/nxos_vlans/tests/common/rtt.yaml @@ -27,7 +27,7 @@ gather_network_resources: - "vlans" - - name: Set default vlan (vlan1) config and config to revert + - name: Set default VLAN (vlan1) configuration and configuration to revert ansible.builtin.set_fact: default_vlan: "{{ ansible_facts.network_resources.vlans|selectattr('vlan_id', 'equalto', 1)|list }}" config_to_revert: @@ -49,7 +49,7 @@ that: - result.changed == true - - name: Revert back to base config using facts round trip + - name: Revert back to base configuration using facts round trip register: revert cisco.nxos.nxos_vlans: config: "{{ ansible_facts['network_resources']['vlans'] }}" diff --git a/tests/integration/targets/nxos_vpc/tasks/cli.yaml b/tests/integration/targets/nxos_vpc/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vpc/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vpc/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vpc/tasks/main.yaml b/tests/integration/targets/nxos_vpc/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_vpc/tasks/main.yaml +++ b/tests/integration/targets/nxos_vpc/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml b/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vpc/tests/common/sanity.yaml b/tests/integration/targets/nxos_vpc/tests/common/sanity.yaml index 5ca2998c4..fb073afb3 100644 --- a/tests/integration/targets/nxos_vpc/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vpc/tests/common/sanity.yaml @@ -13,17 +13,17 @@ when: platform is not search("N35|N5K|N6K") - block: - - name: Disable vpc for initial vpc config cleanup + - name: Disable vpc for initial vpc configuration cleanup cisco.nxos.nxos_feature: feature: vpc state: disabled - - name: Enable feature vpc + - name: Enable 'feature vpc' cisco.nxos.nxos_feature: feature: vpc state: enabled - - name: Ensure ntc vrf exists on switch + - name: Ensure NTC VRF exists on switch cisco.nxos.nxos_vrf: vrf: ntc @@ -40,7 +40,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vpc: *id001 @@ -62,7 +62,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vpc: *id003 @@ -111,7 +111,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence auto-recovery reload-delay + - name: Configure idempotence auto-recovery reload-delay register: result cisco.nxos.nxos_vpc: *id007 @@ -131,7 +131,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vpc: *id008 @@ -146,7 +146,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vpc: *id009 @@ -166,13 +166,13 @@ - ansible.builtin.assert: *id004 always: - - name: Remove vrf + - name: Remove VRF ignore_errors: true cisco.nxos.nxos_vrf: vrf: ntc state: absent - - name: Disable feature vpc + - name: Disable 'feature vpc' ignore_errors: true cisco.nxos.nxos_feature: feature: vpc diff --git a/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml b/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml b/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml index e51ddf92c..e74930c73 100644 --- a/tests/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml @@ -3,7 +3,7 @@ msg: START connection={{ ansible_connection }} nxos_vpc_interface sanity test - block: - - name: Enable feature vpc + - name: Enable 'feature vpc' cisco.nxos.nxos_feature: feature: vpc state: enabled @@ -43,7 +43,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vpc_interface: *id001 @@ -61,7 +61,7 @@ - ansible.builtin.assert: *id002 when: image_version != "7.0(3)I5(1)" - - name: Conf idempotence + - name: Configure idempotence register: result when: image_version != "7.0(3)I5(1)" cisco.nxos.nxos_vpc_interface: *id003 @@ -79,7 +79,7 @@ - ansible.builtin.assert: *id002 when: image_version != "7.0(3)I5(1)" - - name: Conf idempotence + - name: Configure idempotence register: result when: image_version != "7.0(3)I5(1)" cisco.nxos.nxos_vpc_interface: *id005 @@ -129,7 +129,7 @@ - no interface port-channel11 match: none - - name: Disable feature vpc + - name: Disable 'feature vpc' cisco.nxos.nxos_feature: feature: vpc state: disabled diff --git a/tests/integration/targets/nxos_vrf/tasks/cli.yaml b/tests/integration/targets/nxos_vrf/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vrf/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vrf/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrf/tasks/main.yaml b/tests/integration/targets/nxos_vrf/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vrf/tasks/main.yaml +++ b/tests/integration/targets/nxos_vrf/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrf/tests/common/intent.yaml b/tests/integration/targets/nxos_vrf/tests/common/intent.yaml index 5bc90aede..f95da2fb9 100644 --- a/tests/integration/targets/nxos_vrf/tests/common/intent.yaml +++ b/tests/integration/targets/nxos_vrf/tests/common/intent.yaml @@ -10,7 +10,7 @@ ansible.builtin.set_fact: testint2: "{{ nxos_int2 }}" -- name: Setup - remove vrf from interfaces used in test(part1) +- name: Setup - remove VRF from interfaces used in test(part1) ignore_errors: true cisco.nxos.nxos_config: lines: @@ -18,7 +18,7 @@ parents: no switchport before: interface {{ testint1 }} -- name: Setup - remove vrf from interfaces used in test(part2) +- name: Setup - remove VRF from interfaces used in test(part2) ignore_errors: true cisco.nxos.nxos_config: lines: @@ -26,13 +26,13 @@ parents: no switchport before: interface {{ testint2 }} -- name: Setup - delete vrf test1 used in test +- name: Setup - delete VRF test1 used in test ignore_errors: true cisco.nxos.nxos_config: lines: - no vrf context test1 -- name: Setup - remove vrf test2 used in test +- name: Setup - remove VRF test2 used in test ignore_errors: true cisco.nxos.nxos_config: lines: @@ -67,7 +67,7 @@ that: - result.changed == false -- name: Assign interfaces to vrf (config + intent) +- name: Assign interfaces to VRF (config + intent) register: result cisco.nxos.nxos_vrf: &id002 name: test1 @@ -95,7 +95,7 @@ that: - result.changed == false -- name: Check interfaces assigned to vrf (intent) +- name: Check interfaces assigned to VRF (intent) register: result cisco.nxos.nxos_vrf: name: test1 @@ -107,7 +107,7 @@ that: - result.failed == false -- name: Assign interfaces to vrf (intent fail) +- name: Assign interfaces to VRF (intent fail) register: result ignore_errors: true cisco.nxos.nxos_vrf: @@ -119,7 +119,7 @@ that: - result.failed == True -- name: Remove interface from vrf +- name: Remove interface from VRF register: result cisco.nxos.nxos_vrf: &id003 name: test1 @@ -166,7 +166,7 @@ that: - result.changed == false -- name: Setup - remove vrf from interfaces used in test(part1) +- name: Setup - remove VRF from interfaces used in test(part1) ignore_errors: true cisco.nxos.nxos_config: lines: @@ -174,7 +174,7 @@ parents: no switchport before: interface {{ testint1 }} -- name: Setup - remove vrf from interfaces used in test(part2) +- name: Setup - remove VRF from interfaces used in test(part2) ignore_errors: true cisco.nxos.nxos_config: lines: @@ -182,13 +182,13 @@ parents: no switchport before: interface {{ testint2 }} -- name: Setup - delete vrf test1 used in test +- name: Setup - delete VRF test1 used in test ignore_errors: true cisco.nxos.nxos_config: lines: - no vrf context test1 -- name: Setup - remove vrf test2 used in test +- name: Setup - remove VRF test2 used in test ignore_errors: true cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml b/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml index 93dbcc1e1..86c1609d0 100644 --- a/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml @@ -30,13 +30,13 @@ vnid: default when: platform is not match("N35|N7K|N3L") -- name: Enable feature bgp +- name: Enable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp state: enabled -- name: "Setup: enable nv overlay evpn" +- name: "Setup: enable NV overlay EVPN" ignore_errors: true when: platform is match("N5K|N6K") cisco.nxos.nxos_config: @@ -45,7 +45,7 @@ provider: "{{ connection }}" - block: - - name: Ensure ntc vrf exists on switch + - name: Ensure NTC VRF exists on switch register: result cisco.nxos.nxos_vrf: &id001 vrf: ntc @@ -61,7 +61,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf: *id001 @@ -72,7 +72,7 @@ - ansible.builtin.pause: seconds: 30 - - name: Remove config + - name: Remove configuration register: result cisco.nxos.nxos_vrf: &id003 vrf: ntc @@ -83,13 +83,13 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf: *id003 - ansible.builtin.assert: *id004 - - name: Ensure ntc vrf does not exist on switch + - name: Ensure NTC VRF does not exist on switch register: result cisco.nxos.nxos_vrf: &id005 vrf: ntc @@ -106,7 +106,7 @@ - ansible.builtin.assert: *id004 always: - - name: "Setup: disable nv overlay evpn" + - name: "Setup: disable NV overlay EVPN" ignore_errors: true when: platform is match("N5K|N6K") cisco.nxos.nxos_config: @@ -114,7 +114,7 @@ - no nv overlay evpn provider: "{{ connection }}" - - name: Disable feature bgp + - name: Disable 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml b/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrf_af/tasks/main.yaml b/tests/integration/targets/nxos_vrf_af/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_vrf_af/tasks/main.yaml +++ b/tests/integration/targets/nxos_vrf_af/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrf_af/tests/common/sanity.yaml b/tests/integration/targets/nxos_vrf_af/tests/common/sanity.yaml index 124c4c187..3e276fa19 100644 --- a/tests/integration/targets/nxos_vrf_af/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vrf_af/tests/common/sanity.yaml @@ -2,23 +2,23 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_vrf_af sanity test -- name: Configure feature bgp +- name: Configure 'feature bgp' cisco.nxos.nxos_feature: feature: bgp state: enabled -- name: Configure feature nv overlay +- name: Configure 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_config: commands: feature nv overlay -- name: Configure nv overlay evpn +- name: Configure NV overlay EVPN ignore_errors: true cisco.nxos.nxos_config: commands: nv overlay evpn - block: - - name: Configure vrf af ipv4 + - name: Configure VRF AF ipv4 register: result cisco.nxos.nxos_vrf_af: &id001 vrf: ansible @@ -29,7 +29,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf_af: *id001 @@ -37,7 +37,7 @@ that: - result.changed == false - - name: Configure vrf af ipv6 + - name: Configure VRF AF ipv6 register: result cisco.nxos.nxos_vrf_af: &id003 vrf: ansible @@ -46,7 +46,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf_af: *id003 @@ -61,7 +61,7 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf_af: *id005 @@ -76,13 +76,13 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf_af: *id006 - ansible.builtin.assert: *id004 - - name: Remove vrf af v6 + - name: Remove VRF AF v6 register: result cisco.nxos.nxos_vrf_af: &id007 vrf: ansible @@ -101,7 +101,7 @@ - ansible.builtin.assert: *id004 - - name: Remove vrf af v4 + - name: Remove VRF AF v4 register: result cisco.nxos.nxos_vrf_af: &id008 vrf: ansible @@ -121,22 +121,22 @@ - ansible.builtin.assert: *id004 when: not platform is search("N35|N3L") always: - - name: Remove vrf + - name: Remove VRF ignore_errors: true cisco.nxos.nxos_config: commands: no vrf context ansible - - name: Remove nv overlay evpn + - name: Remove NV overlay EVPN ignore_errors: true cisco.nxos.nxos_config: commands: no nv overlay evpn - - name: Remove feature nv overlay + - name: Remove 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_config: commands: no feature nv overlay - - name: Remove feature bgp + - name: Remove 'feature bgp' ignore_errors: true cisco.nxos.nxos_feature: feature: bgp diff --git a/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml b/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml b/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrf_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_vrf_interface/tests/common/sanity.yaml index 5d1ce4a6b..dbe8baf93 100644 --- a/tests/integration/targets/nxos_vrf_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vrf_interface/tests/common/sanity.yaml @@ -7,7 +7,7 @@ intname: "{{ nxos_int1 }}" - block: - - name: Put interface in l3 + - name: Put interface in layer 3 cisco.nxos.nxos_config: commands: - no switchport @@ -15,7 +15,7 @@ - interface {{ intname }} match: none - - name: Ensure vrf ntc exists on interface + - name: Ensure VRF NTC exists on interface register: result cisco.nxos.nxos_vrf_interface: &id001 vrf: ntc @@ -26,7 +26,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrf_interface: *id001 @@ -34,7 +34,7 @@ that: - result.changed == false - - name: Ensure ntc vrf does not exist on interface + - name: Ensure NTC VRF does not exist on interface register: result cisco.nxos.nxos_vrf_interface: &id003 vrf: ntc diff --git a/tests/integration/targets/nxos_vrrp/tasks/cli.yaml b/tests/integration/targets/nxos_vrrp/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vrrp/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vrrp/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrrp/tasks/main.yaml b/tests/integration/targets/nxos_vrrp/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vrrp/tasks/main.yaml +++ b/tests/integration/targets/nxos_vrrp/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vrrp/tests/common/sanity.yaml b/tests/integration/targets/nxos_vrrp/tests/common/sanity.yaml index 577baecea..4e3ba70fa 100644 --- a/tests/integration/targets/nxos_vrrp/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vrrp/tests/common/sanity.yaml @@ -13,7 +13,7 @@ feature: vrrp state: enabled - - name: Create int vlan 10 + - name: Create int VLAN 10 cisco.nxos.nxos_config: commands: int vlan 10 @@ -29,7 +29,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrrp: *id001 @@ -47,13 +47,13 @@ - ansible.builtin.assert: *id002 - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vrrp: *id003 - ansible.builtin.assert: *id004 - - name: Ensure removal of the vrrp group config + - name: Ensure removal of the vrrp group configuration register: result cisco.nxos.nxos_vrrp: &id005 interface: vlan10 diff --git a/tests/integration/targets/nxos_vsan/tasks/cli.yaml b/tests/integration/targets/nxos_vsan/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vsan/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vsan/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vsan/tasks/main.yaml b/tests/integration/targets/nxos_vsan/tasks/main.yaml index eb055621b..477fbd41f 100644 --- a/tests/integration/targets/nxos_vsan/tasks/main.yaml +++ b/tests/integration/targets/nxos_vsan/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Check platform type and skip if not mds +- name: Check platform type and skip if not MDS register: result cisco.nxos.nxos_command: commands: show version | grep MDS @@ -8,12 +8,12 @@ ansible.builtin.set_fact: skip_test: false -- name: Set skip_test flag to true if not mds +- name: Set skip_test flag to true if not MDS ansible.builtin.set_fact: skip_test: true when: result.stdout[0] is not search('MDS') -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: cli when: not skip_test diff --git a/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml b/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml index 34e899be1..ce8eba064 100644 --- a/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml @@ -6,7 +6,7 @@ msg: Using vsans {{ vsan1 }}, {{ vsan2 }} for running this sanity test, please make sure these are not used in the setup, these will be deleted after the tests - block: - - name: Setup - remove vsan if configured + - name: Setup - remove VSAN if configured ignore_errors: true cisco.nxos.nxos_vsan: &id002 vsan: @@ -16,7 +16,7 @@ - id: "{{ vsan2 | int }}" remove: true - - name: Configure vsan + - name: Configure VSAN register: result cisco.nxos.nxos_vsan: &id001 vsan: @@ -54,5 +54,5 @@ that: - result.commands == [] always: - - name: Remove vsan config + - name: Remove VSAN configuration cisco.nxos.nxos_vsan: *id002 diff --git a/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml b/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vtp_domain/tasks/main.yaml b/tests/integration/targets/nxos_vtp_domain/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vtp_domain/tasks/main.yaml +++ b/tests/integration/targets/nxos_vtp_domain/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml b/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vtp_domain/tests/common/sanity.yaml b/tests/integration/targets/nxos_vtp_domain/tests/common/sanity.yaml index 413c00427..6c2a43f49 100644 --- a/tests/integration/targets/nxos_vtp_domain/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vtp_domain/tests/common/sanity.yaml @@ -12,18 +12,18 @@ when: platform is search('N3K-F|N9K-F') - block: - - name: Disable feature vtp + - name: Disable 'feature vtp' ignore_errors: true cisco.nxos.nxos_feature: feature: vtp state: disabled - - name: Enable feature vtp + - name: Enable 'feature vtp' cisco.nxos.nxos_feature: feature: vtp state: enabled - - name: Configure vtp domain + - name: Configure VTP domain register: result cisco.nxos.nxos_vtp_domain: &id001 domain: ntc @@ -32,7 +32,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vtp_domain: *id001 @@ -41,7 +41,7 @@ - result.changed == false when: vtp_run always: - - name: Disable feature vtp + - name: Disable 'feature vtp' cisco.nxos.nxos_feature: feature: vtp state: disabled diff --git a/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml b/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vtp_password/tasks/main.yaml b/tests/integration/targets/nxos_vtp_password/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_vtp_password/tasks/main.yaml +++ b/tests/integration/targets/nxos_vtp_password/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml b/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vtp_password/tests/common/sanity.yaml b/tests/integration/targets/nxos_vtp_password/tests/common/sanity.yaml index 0f0f5323c..a0f0e1f2c 100644 --- a/tests/integration/targets/nxos_vtp_password/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vtp_password/tests/common/sanity.yaml @@ -12,22 +12,22 @@ when: platform is search('N3K-F|N9K-F') - block: - - name: Disable feature vtp + - name: Disable 'feature vtp' ignore_errors: true cisco.nxos.nxos_feature: feature: vtp state: disabled - - name: Enable feature vtp + - name: Enable 'feature vtp' cisco.nxos.nxos_feature: feature: vtp state: enabled - - name: Configure vtp domain + - name: Configure VTP domain cisco.nxos.nxos_vtp_domain: domain: testing - - name: Configure vtp password + - name: Configure VTP password register: result cisco.nxos.nxos_vtp_password: &id001 vtp_password: ntc @@ -37,7 +37,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vtp_password: *id001 @@ -45,7 +45,7 @@ that: - result.changed == false - - name: Remove vtp password + - name: Remove VTP password register: result cisco.nxos.nxos_vtp_password: &id003 vtp_password: ntc @@ -60,7 +60,7 @@ - ansible.builtin.assert: *id004 when: vtp_run always: - - name: Disable feature vtp + - name: Disable 'feature vtp' cisco.nxos.nxos_feature: feature: vtp state: disabled diff --git a/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml b/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vtp_version/tasks/main.yaml b/tests/integration/targets/nxos_vtp_version/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vtp_version/tasks/main.yaml +++ b/tests/integration/targets/nxos_vtp_version/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml b/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vtp_version/tests/common/sanity.yaml b/tests/integration/targets/nxos_vtp_version/tests/common/sanity.yaml index 08d9fa901..248c5c475 100644 --- a/tests/integration/targets/nxos_vtp_version/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vtp_version/tests/common/sanity.yaml @@ -12,22 +12,22 @@ when: platform is search('N3K-F|N9K-F') - block: - - name: Disable feature vtp + - name: Disable 'feature vtp' ignore_errors: true cisco.nxos.nxos_feature: feature: vtp state: disabled - - name: Enable feature vtp + - name: Enable 'feature vtp' cisco.nxos.nxos_feature: feature: vtp state: enabled - - name: Configure supporting vtp domain + - name: Configure supporting VTP domain cisco.nxos.nxos_vtp_domain: domain: foo - - name: Configure vtp version + - name: Configure VTP version register: result cisco.nxos.nxos_vtp_version: &id001 version: 2 @@ -36,7 +36,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vtp_version: *id001 @@ -45,7 +45,7 @@ - result.changed == false when: vtp_run | bool always: - - name: Disable feature vtp + - name: Disable 'feature vtp' cisco.nxos.nxos_feature: feature: vtp state: disabled diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/main.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/main.yaml index 62e44ffda..a1da90e57 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/main.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/main.yaml @@ -1,10 +1,10 @@ --- -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli -- name: Include the nx-api tasks +- name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml index ea15558fc..92fffe748 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml @@ -1,5 +1,5 @@ --- -- name: Unconfigure vdc setting limit-resource module-type f3 +- name: Unconfigure VDC setting limit-resource module-type f3 ignore_errors: true cisco.nxos.nxos_config: commands: @@ -10,7 +10,7 @@ ansible.builtin.pause: seconds: 45 -- name: Configure vdc setting allocate interface unallocated-interfaces +- name: Configure VDC setting allocate interface unallocated-interfaces ignore_errors: true cisco.nxos.nxos_config: commands: diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml index 499b275f8..3883f2b8a 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml @@ -1,5 +1,5 @@ --- -- name: Get default vdc id +- name: Get default VDC id register: vdcout cisco.nxos.nxos_command: commands: @@ -9,7 +9,7 @@ ansible.builtin.set_fact: vdcid: "{{ vdcout.stdout_lines[0].name }}" -- name: Configure vdc setting limit-resource module-type f3 +- name: Configure VDC setting limit-resource module-type f3 ignore_errors: true cisco.nxos.nxos_config: commands: @@ -20,7 +20,7 @@ ansible.builtin.pause: seconds: 45 -- name: Configure vdc setting allocate interface unallocated-interfaces +- name: Configure VDC setting allocate interface unallocated-interfaces ignore_errors: true cisco.nxos.nxos_config: commands: diff --git a/tests/integration/targets/nxos_vxlan_vtep/tests/common/multisite.yaml b/tests/integration/targets/nxos_vxlan_vtep/tests/common/multisite.yaml index ff9f8a844..b2ffc5a1d 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tests/common/multisite.yaml @@ -2,13 +2,13 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_vxlan_vtep multisite sanity test -- name: Enable feature nv overlay - multisite +- name: Enable 'feature nv overlay' - multisite cisco.nxos.nxos_config: commands: - feature nv overlay match: none -- name: Enable nv overlay evpn - multisite +- name: Enable NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: @@ -38,7 +38,7 @@ that: - result.changed == true - - name: Conf idempotence + - name: Configure idempotence register: result cisco.nxos.nxos_vxlan_vtep: *id001 @@ -95,7 +95,7 @@ - no evpn multisite border-gateway 10 when: multiout is not search("Invalid command") -- name: Disable nv overlay evpn +- name: Disable NV overlay EVPN when: platform is search('N9K') ignore_errors: true cisco.nxos.nxos_config: @@ -103,7 +103,7 @@ - no nv overlay evpn match: none -- name: Disable feature nv overlay +- name: Disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nve diff --git a/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml b/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml index b35b236b9..69e5e0f1d 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml @@ -37,11 +37,11 @@ when: platform is search('N9K') and (major_version is version('9.2', 'ge')) - block: - - name: Apply n7k specific setup config + - name: Apply N7K specific setup configuration ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml when: platform is match('N7K') - - name: Enable feature nv overlay + - name: Enable 'feature nv overlay' cisco.nxos.nxos_config: commands: - feature nv overlay @@ -198,18 +198,18 @@ - result.changed == false when: (platform is search("N7K|N9K")) always: - - name: Apply n7k specific cleanup config + - name: Apply N7K specific cleanup configuration ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml when: platform is match('N7K') - - name: Disable nv overlay evpn + - name: Disable NV overlay EVPN ignore_errors: true cisco.nxos.nxos_config: commands: - no nv overlay evpn match: none - - name: Disable feature nv overlay + - name: Disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nve diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml index 7631f52fe..d476f905a 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml @@ -1,11 +1,11 @@ --- - block: - - name: Include the cli tasks + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: - cli always: - - name: Include the nx-api tasks + - name: Include the NX-API tasks ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml index cedab80f1..b4ed55204 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect nxapi test cases +- name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/multisite.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/multisite.yaml index 3d76704e3..13ab21fd8 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/multisite.yaml @@ -2,19 +2,19 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} nxos_vxlan_vtep_vni multisite sanity test -- name: Disable feature nv overlay - multisite +- name: Disable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay state: disabled -- name: Enable feature nv overlay - multisite +- name: Enable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay state: enabled -- name: Enable nv overlay evpn - multisite +- name: Enable NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: @@ -88,7 +88,7 @@ - no evpn multisite border-gateway 10 when: multiout is not search("Invalid command") -- name: Disable feature nv overlay - multisite +- name: Disable 'feature nv overlay' - multisite ignore_errors: true cisco.nxos.nxos_feature: feature: nv overlay @@ -97,7 +97,7 @@ - ansible.builtin.pause: seconds: 5 -- name: Remove nv overlay evpn - multisite +- name: Remove NV overlay EVPN - multisite when: platform is search('N9K') cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml index 808662125..fa095fa5d 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml @@ -3,11 +3,11 @@ msg: START connection={{ ansible_connection }} nxos_vxlan_vtep_vni sanity test - block: - - name: Apply n7k specific setup config + - name: Apply N7K specific setup configuration ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml when: platform is match('N7K') - - name: Enable feature nv overlay + - name: Enable 'feature nv overlay' cisco.nxos.nxos_config: commands: - feature nv overlay @@ -29,7 +29,7 @@ that: - result.changed == true - - name: Conf 1 idempotence + - name: Configure 1 idempotence register: result cisco.nxos.nxos_vxlan_vtep_vni: *id001 @@ -61,7 +61,7 @@ - ansible.builtin.assert: *id002 - - name: Conf 3 idempotence + - name: Configure 3 idempotence register: result cisco.nxos.nxos_vxlan_vtep_vni: *id003 @@ -76,13 +76,13 @@ - ansible.builtin.assert: *id002 - - name: Conf 4 idempotence + - name: Configure 4 idempotence register: result cisco.nxos.nxos_vxlan_vtep_vni: *id005 - ansible.builtin.assert: *id004 - - name: Remove config + - name: Remove configuration cisco.nxos.nxos_vxlan_vtep_vni: &id013 interface: nve1 vni: 8000 @@ -229,7 +229,7 @@ when: (platform is search('N9K')) when: (platform is search("N7K|N9K")) always: - - name: Apply n7k specific cleanup config + - name: Apply N7K specific cleanup configuration ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml when: platform is match('N7K') @@ -240,7 +240,7 @@ shutdown: true state: absent - - name: Disable feature nv overlay + - name: Disable 'feature nv overlay' ignore_errors: true cisco.nxos.nxos_feature: feature: nve diff --git a/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml b/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml index 90342e6b1..f6096901f 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml +++ b/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml @@ -6,7 +6,7 @@ connection: local register: test_cases -- name: Collect cli test cases +- name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" diff --git a/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml b/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml index eb055621b..477fbd41f 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml +++ b/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Check platform type and skip if not mds +- name: Check platform type and skip if not MDS register: result cisco.nxos.nxos_command: commands: show version | grep MDS @@ -8,12 +8,12 @@ ansible.builtin.set_fact: skip_test: false -- name: Set skip_test flag to true if not mds +- name: Set skip_test flag to true if not MDS ansible.builtin.set_fact: skip_test: true when: result.stdout[0] is not search('MDS') -- name: Include the cli tasks +- name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: cli when: not skip_test diff --git a/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml b/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml index fdcce0473..7137c91d3 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml @@ -6,7 +6,7 @@ msg: Using vsans {{ vsan1 }}, {{ vsan2 }} for running this sanity test, please make sure these are not used in the setup, these will be deleted after the tests - always: - - name: Remove vsan config + - name: Remove VSAN configuration cisco.nxos.nxos_vsan: vsan: - id: "{{ vsan1 | int }}" @@ -15,7 +15,7 @@ - id: "{{ vsan2 | int }}" remove: true block: - - name: Setup - remove vsan if configured + - name: Setup - remove VSAN if configured ignore_errors: true cisco.nxos.nxos_vsan: vsan: @@ -25,7 +25,7 @@ - id: "{{ vsan2 | int }}" remove: true - - name: Configure vsan + - name: Configure VSAN cisco.nxos.nxos_vsan: vsan: - id: "{{ vsan1 | int }}" diff --git a/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml b/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml index 052e40d7f..4f916279a 100644 --- a/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml +++ b/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml @@ -6,7 +6,7 @@ lines: - feature privilege -- name: Enable feature nxapi +- name: Enable feature NX-API connection: ansible.netcommon.network_cli cisco.nxos.nxos_nxapi: state: present From c0b6166800fddf108fdd6bd7570bf1c4d661abd2 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Wed, 25 May 2022 10:12:45 -0700 Subject: [PATCH 004/166] Roundtrip test yaml files (#515) --- changelogs/fragments/515.yaml | 3 + .../tests/common/radius.yaml | 2 +- .../targets/nxos_bfd_interfaces/vars/main.yml | 1 + .../nxos_bgp_address_family/meta/main.yml | 1 + .../nxos_bgp_address_family/vars/main.yml | 20 ++--- .../targets/nxos_bgp_global/meta/main.yml | 1 + .../meta/main.yml | 1 + .../vars/main.yml | 10 +-- .../nxos_hsrp_interfaces/vars/main.yml | 1 + .../targets/nxos_interfaces/vars/main.yml | 3 +- .../targets/nxos_l2_interfaces/vars/main.yml | 1 + .../targets/nxos_l3_interfaces/vars/main.yml | 17 +++-- .../targets/nxos_lacp/vars/main.yml | 1 + .../nxos_lacp_interfaces/vars/main.yml | 1 + .../targets/nxos_lag_interfaces/vars/main.yml | 1 + .../targets/nxos_lldp_global/vars/main.yml | 3 +- .../nxos_logging/tests/common/basic.yaml | 2 +- .../tests/common/net_logging.yaml | 6 +- .../nxos_logging/tests/common/purge.yaml | 4 +- .../targets/nxos_ntp_global/vars/main.yml | 10 +-- .../nxos_ospf_interfaces/vars/main.yml | 12 +-- .../targets/nxos_ospfv2/meta/main.yml | 1 + .../targets/nxos_ospfv2/vars/main.yml | 4 +- .../targets/nxos_ospfv3/meta/main.yml | 1 + .../targets/nxos_ospfv3/vars/main.yml | 4 +- .../targets/nxos_route_maps/vars/main.yml | 4 +- .../targets/nxos_smoke/meta/main.yml | 1 + .../targets/nxos_snmp_server/vars/main.yml | 30 ++++---- .../targets/nxos_static_routes/meta/main.yml | 1 + .../targets/nxos_static_routes/vars/main.yml | 75 ++++++------------- .../nxos_telemetry/tests/common/deleted.yaml | 6 +- .../nxos_telemetry/tests/common/merged.yaml | 12 +-- .../targets/nxos_telemetry/vars/main.yaml | 1 + .../targets/nxos_vlans/vars/main.yml | 17 +++-- 34 files changed, 125 insertions(+), 133 deletions(-) create mode 100644 changelogs/fragments/515.yaml diff --git a/changelogs/fragments/515.yaml b/changelogs/fragments/515.yaml new file mode 100644 index 000000000..be7e07f60 --- /dev/null +++ b/changelogs/fragments/515.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Round trip with ruamel again, non task files diff --git a/tests/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml b/tests/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml index 77645e39a..c52dd80d4 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml +++ b/tests/integration/targets/nxos_aaa_server_host/tests/common/radius.yaml @@ -85,7 +85,7 @@ host_timeout: 25 auth_port: default acct_port: 2084 - encrypt_type: 00 + encrypt_type: 0 key: hello state: present diff --git a/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml b/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml index 29552637f..eec612c56 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml @@ -1,3 +1,4 @@ +--- gathered: - name: "{{ nxos_int1 }}" bfd: disable diff --git a/tests/integration/targets/nxos_bgp_address_family/meta/main.yml b/tests/integration/targets/nxos_bgp_address_family/meta/main.yml index e69de29bb..ed97d539c 100644 --- a/tests/integration/targets/nxos_bgp_address_family/meta/main.yml +++ b/tests/integration/targets/nxos_bgp_address_family/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/tests/integration/targets/nxos_bgp_address_family/vars/main.yml b/tests/integration/targets/nxos_bgp_address_family/vars/main.yml index 21a533329..bc245dad7 100644 --- a/tests/integration/targets/nxos_bgp_address_family/vars/main.yml +++ b/tests/integration/targets/nxos_bgp_address_family/vars/main.yml @@ -32,11 +32,11 @@ merged: safi: unicast vrf: site-1 default_information: - originate: True + originate: true aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv6 safi: multicast vrf: site-1 @@ -73,8 +73,8 @@ replaced: non_critical_delay: 180 aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: unicast @@ -116,8 +116,8 @@ overridden: route_map: rmap1 aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: unicast vrf: site-1 @@ -142,11 +142,11 @@ deleted: safi: unicast vrf: site-1 default_information: - originate: True + originate: true aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: multicast diff --git a/tests/integration/targets/nxos_bgp_global/meta/main.yml b/tests/integration/targets/nxos_bgp_global/meta/main.yml index e69de29bb..ed97d539c 100644 --- a/tests/integration/targets/nxos_bgp_global/meta/main.yml +++ b/tests/integration/targets/nxos_bgp_global/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/meta/main.yml b/tests/integration/targets/nxos_bgp_neighbor_address_family/meta/main.yml index e69de29bb..ed97d539c 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/meta/main.yml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/vars/main.yml b/tests/integration/targets/nxos_bgp_neighbor_address_family/vars/main.yml index 13ce69a47..894dcbd07 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/vars/main.yml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/vars/main.yml @@ -59,7 +59,7 @@ merged: - afi: ipv4 safi: multicast send_community: - standard: True + standard: true - afi: ipv6 safi: unicast @@ -106,7 +106,7 @@ replaced: - afi: ipv4 safi: multicast send_community: - standard: True + standard: true - afi: ipv6 safi: unicast @@ -140,9 +140,9 @@ overridden: address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true deleted: commands: @@ -181,7 +181,7 @@ deleted: - afi: ipv4 safi: multicast send_community: - standard: True + standard: true deleted_all: commands: diff --git a/tests/integration/targets/nxos_hsrp_interfaces/vars/main.yml b/tests/integration/targets/nxos_hsrp_interfaces/vars/main.yml index 3956fbfef..1a741272f 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_hsrp_interfaces/vars/main.yml @@ -1,3 +1,4 @@ +--- gathered: - name: "{{ nxos_int1 }}" bfd: enable diff --git a/tests/integration/targets/nxos_interfaces/vars/main.yml b/tests/integration/targets/nxos_interfaces/vars/main.yml index b80e0cb91..bba0dd5c5 100644 --- a/tests/integration/targets/nxos_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_interfaces/vars/main.yml @@ -1,8 +1,9 @@ +--- gathered: - name: "{{ nxos_int1 }}" description: outbound-intf mode: layer2 - enabled: True + enabled: true - name: "{{ nxos_int2 }}" description: intf-l3 speed: "1000" diff --git a/tests/integration/targets/nxos_l2_interfaces/vars/main.yml b/tests/integration/targets/nxos_l2_interfaces/vars/main.yml index ee4af5daa..fa6cc810e 100644 --- a/tests/integration/targets/nxos_l2_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_l2_interfaces/vars/main.yml @@ -1,3 +1,4 @@ +--- gathered: - name: "{{ nxos_int1 }}" access: diff --git a/tests/integration/targets/nxos_l3_interfaces/vars/main.yml b/tests/integration/targets/nxos_l3_interfaces/vars/main.yml index cfd79b1ce..db2e9700d 100644 --- a/tests/integration/targets/nxos_l3_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_l3_interfaces/vars/main.yml @@ -1,3 +1,4 @@ +--- gathered: - name: "{{ nxos_int1 }}" ipv4: @@ -7,8 +8,8 @@ gathered: - address: 203.0.113.10/24 ipv6: - address: 2001:db8::1/32 - redirects: False - unreachables: True + redirects: false + unreachables: true rendered: - "interface Ethernet1/800" @@ -23,14 +24,14 @@ parsed: - address: 192.168.1.100/24 tag: 5 - address: 10.1.1.1/24 - secondary: True + secondary: true tag: 10 - redirects: False + redirects: false - name: Ethernet1/801 ipv6: - address: fd5d:12c9:2201:2::1/64 tag: 6 - unreachables: True + unreachables: true - name: mgmt0 ipv4: - address: dhcp @@ -50,15 +51,15 @@ parsed_multi: - address: 192.168.1.100/24 tag: 5 - address: 10.1.1.1/24 - secondary: True + secondary: true tag: 10 - redirects: False + redirects: false evpn_multisite_tracking: fabric-tracking - name: Ethernet1/801 ipv6: - address: fd5d:12c9:2201:2::1/64 tag: 6 - unreachables: True + unreachables: true evpn_multisite_tracking: dci-tracking - name: mgmt0 ipv4: diff --git a/tests/integration/targets/nxos_lacp/vars/main.yml b/tests/integration/targets/nxos_lacp/vars/main.yml index 7c9f248d3..8b5bd3dbb 100644 --- a/tests/integration/targets/nxos_lacp/vars/main.yml +++ b/tests/integration/targets/nxos_lacp/vars/main.yml @@ -1,3 +1,4 @@ +--- # The CI NX-OS image doesn't support `lacp system-mac` gathered: system: diff --git a/tests/integration/targets/nxos_lacp_interfaces/vars/main.yml b/tests/integration/targets/nxos_lacp_interfaces/vars/main.yml index bbb0687bf..633e5a08c 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_lacp_interfaces/vars/main.yml @@ -1,3 +1,4 @@ +--- gathered: - name: "{{ nxos_int1 }}" port_priority: 5 diff --git a/tests/integration/targets/nxos_lag_interfaces/vars/main.yml b/tests/integration/targets/nxos_lag_interfaces/vars/main.yml index 9791dea47..a82857b95 100644 --- a/tests/integration/targets/nxos_lag_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_lag_interfaces/vars/main.yml @@ -1,3 +1,4 @@ +--- gathered: - name: port-channel10 members: diff --git a/tests/integration/targets/nxos_lldp_global/vars/main.yml b/tests/integration/targets/nxos_lldp_global/vars/main.yml index 7bca43e23..4a3dc8100 100644 --- a/tests/integration/targets/nxos_lldp_global/vars/main.yml +++ b/tests/integration/targets/nxos_lldp_global/vars/main.yml @@ -1,9 +1,10 @@ +--- gathered: reinit: 5 timer: 35 tlv_select: system: - name: False + name: false holdtime: 129 rendered: diff --git a/tests/integration/targets/nxos_logging/tests/common/basic.yaml b/tests/integration/targets/nxos_logging/tests/common/basic.yaml index 577a95165..72bf146d1 100644 --- a/tests/integration/targets/nxos_logging/tests/common/basic.yaml +++ b/tests/integration/targets/nxos_logging/tests/common/basic.yaml @@ -16,7 +16,7 @@ register: result cisco.nxos.nxos_logging: &id001 dest: console - dest_level: 00 + dest_level: 0 state: present - ansible.builtin.assert: diff --git a/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml b/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml index fc0ff0acb..a2a8548cc 100644 --- a/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml +++ b/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml @@ -6,14 +6,14 @@ register: result ansible.netcommon.net_logging: dest: console - dest_level: 00 + dest_level: 0 state: absent - name: Set up console logging using platform agnostic module register: result ansible.netcommon.net_logging: dest: console - dest_level: 00 + dest_level: 0 state: present - ansible.builtin.assert: @@ -25,7 +25,7 @@ register: result ansible.netcommon.net_logging: dest: console - dest_level: 00 + dest_level: 0 state: absent - ansible.builtin.debug: diff --git a/tests/integration/targets/nxos_logging/tests/common/purge.yaml b/tests/integration/targets/nxos_logging/tests/common/purge.yaml index 6badf4a67..fa773b58a 100644 --- a/tests/integration/targets/nxos_logging/tests/common/purge.yaml +++ b/tests/integration/targets/nxos_logging/tests/common/purge.yaml @@ -11,7 +11,7 @@ register: result cisco.nxos.nxos_logging: dest: console - dest_level: 00 + dest_level: 0 state: present - ansible.builtin.assert: @@ -87,7 +87,7 @@ cisco.nxos.nxos_logging: aggregate: - dest: console - dest_level: 00 + dest_level: 0 - dest: monitor dest_level: 3 diff --git a/tests/integration/targets/nxos_ntp_global/vars/main.yml b/tests/integration/targets/nxos_ntp_global/vars/main.yml index e65524fc0..65b3d6e52 100644 --- a/tests/integration/targets/nxos_ntp_global/vars/main.yml +++ b/tests/integration/targets/nxos_ntp_global/vars/main.yml @@ -17,8 +17,8 @@ merged: - access_list: PeerAcl1 serve: - access_list: ServeAcl1 - authenticate: True - logging: True + authenticate: true + logging: true master: stratum: 2 peers: @@ -29,7 +29,7 @@ merged: vrf: default - peer: 192.0.2.2 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -55,7 +55,7 @@ replaced: - access_list: PeerAcl2 serve: - access_list: ServeAcl2 - logging: True + logging: true master: stratum: 2 peers: @@ -66,7 +66,7 @@ replaced: vrf: default - peer: 192.0.2.5 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 diff --git a/tests/integration/targets/nxos_ospf_interfaces/vars/main.yml b/tests/integration/targets/nxos_ospf_interfaces/vars/main.yml index 5d2f6c140..29df4d48f 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_ospf_interfaces/vars/main.yml @@ -44,12 +44,12 @@ merged: address_family: - afi: ipv4 authentication: - enable: True + enable: true key_chain: test-1 cost: 100 - afi: ipv6 network: broadcast - shutdown: True + shutdown: true - name: "{{ nxos_int3 }}" address_family: - afi: ipv4 @@ -74,19 +74,19 @@ replaced: - process_id: "100" area: area_id: 1.1.1.1 - secondaries: False + secondaries: false multi_areas: - 11.11.11.12 - name: "{{ nxos_int2 }}" address_family: - afi: ipv4 authentication: - enable: True + enable: true key_chain: test-1 cost: 100 - afi: ipv6 network: broadcast - shutdown: True + shutdown: true - name: "{{ nxos_int3 }}" overridden: commands: @@ -113,7 +113,7 @@ overridden: - process_id: "100" area: area_id: 1.1.1.1 - secondaries: False + secondaries: false multi_areas: - 11.11.11.12 - name: "{{ nxos_int2 }}" diff --git a/tests/integration/targets/nxos_ospfv2/meta/main.yml b/tests/integration/targets/nxos_ospfv2/meta/main.yml index e69de29bb..ed97d539c 100644 --- a/tests/integration/targets/nxos_ospfv2/meta/main.yml +++ b/tests/integration/targets/nxos_ospfv2/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/tests/integration/targets/nxos_ospfv2/vars/main.yml b/tests/integration/targets/nxos_ospfv2/vars/main.yml index a9192261d..25419c857 100644 --- a/tests/integration/targets/nxos_ospfv2/vars/main.yml +++ b/tests/integration/targets/nxos_ospfv2/vars/main.yml @@ -57,7 +57,7 @@ merged: no_summary: true - area_id: 0.0.0.103 nssa: - no_summary: True + no_summary: true translate: type7: always: true @@ -150,7 +150,7 @@ overridden: router_id: 203.0.113.20 - process_id: "102" router_id: 198.51.100.1 - shutdown: True + shutdown: true deleted: after: processes: diff --git a/tests/integration/targets/nxos_ospfv3/meta/main.yml b/tests/integration/targets/nxos_ospfv3/meta/main.yml index e69de29bb..ed97d539c 100644 --- a/tests/integration/targets/nxos_ospfv3/meta/main.yml +++ b/tests/integration/targets/nxos_ospfv3/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/tests/integration/targets/nxos_ospfv3/vars/main.yml b/tests/integration/targets/nxos_ospfv3/vars/main.yml index 1b31b9874..ddfd096b8 100644 --- a/tests/integration/targets/nxos_ospfv3/vars/main.yml +++ b/tests/integration/targets/nxos_ospfv3/vars/main.yml @@ -54,7 +54,7 @@ merged: no_summary: true - area_id: 0.0.0.103 nssa: - no_summary: True + no_summary: true translate: type7: always: true @@ -131,7 +131,7 @@ overridden: router_id: 203.0.113.20 - process_id: "102" router_id: 198.51.100.1 - shutdown: True + shutdown: true address_family: afi: ipv6 safi: unicast diff --git a/tests/integration/targets/nxos_route_maps/vars/main.yml b/tests/integration/targets/nxos_route_maps/vars/main.yml index 8a191eecf..7e14dc286 100644 --- a/tests/integration/targets/nxos_route_maps/vars/main.yml +++ b/tests/integration/targets/nxos_route_maps/vars/main.yml @@ -129,7 +129,7 @@ replaced: - AllowPrefix1 set: community: - local_as: True + local_as: true - route_map: rmap2 entries: @@ -202,7 +202,7 @@ overridden: - AllowPrefix1 set: community: - local_as: True + local_as: true deleted: commands: diff --git a/tests/integration/targets/nxos_smoke/meta/main.yml b/tests/integration/targets/nxos_smoke/meta/main.yml index ae741cbdc..f504a6ab2 100644 --- a/tests/integration/targets/nxos_smoke/meta/main.yml +++ b/tests/integration/targets/nxos_smoke/meta/main.yml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_snmp_server/vars/main.yml b/tests/integration/targets/nxos_snmp_server/vars/main.yml index 76a6f1dfd..fb04c030f 100644 --- a/tests/integration/targets/nxos_snmp_server/vars/main.yml +++ b/tests/integration/targets/nxos_snmp_server/vars/main.yml @@ -8,7 +8,7 @@ merged: authentication: algorithm: md5 password: "{{ admin_snmp_passwd }}" - localized_key: True + localized_key: true priv: privacy_password: "{{ admin_snmp_passwd }}" - authentication: @@ -123,16 +123,16 @@ replaced: location: serverroom-2 traps: aaa: - server_state_change: True + server_state_change: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: "1" community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.3.2 - informs: True + informs: true version: "3" auth: NMS users: @@ -142,7 +142,7 @@ replaced: authentication: algorithm: md5 password: "{{ admin_snmp_passwd }}" - localized_key: True + localized_key: true priv: privacy_password: "{{ admin_snmp_passwd }}" @@ -160,17 +160,17 @@ replaced: authentication: algorithm: md5 password: "0x5632724fb8ac3699296af26281e1d0f1" - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: "0x5632724fb8ac3699296af26281e1d0f1" - localized_key: True + localized_key: true priv: privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -188,18 +188,18 @@ parsed: location: serverroom-1 traps: aaa: - server_state_change: True + server_state_change: true system: - clock_change_notification: True + clock_change_notification: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: "1" community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.2.2 - informs: True + informs: true version: "3" auth: NMS users: @@ -209,16 +209,16 @@ parsed: authentication: algorithm: md5 password: "0x5632724fb8ac3699296af26281e1d0f1" - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: "0x5632724fb8ac3699296af26281e1d0f1" - localized_key: True + localized_key: true priv: privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 diff --git a/tests/integration/targets/nxos_static_routes/meta/main.yml b/tests/integration/targets/nxos_static_routes/meta/main.yml index ae741cbdc..f504a6ab2 100644 --- a/tests/integration/targets/nxos_static_routes/meta/main.yml +++ b/tests/integration/targets/nxos_static_routes/meta/main.yml @@ -1,2 +1,3 @@ +--- dependencies: - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_static_routes/vars/main.yml b/tests/integration/targets/nxos_static_routes/vars/main.yml index b0c6d454a..958773252 100644 --- a/tests/integration/targets/nxos_static_routes/vars/main.yml +++ b/tests/integration/targets/nxos_static_routes/vars/main.yml @@ -1,53 +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 }], - }, - ], - }, - ], - }, - ] + - "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 diff --git a/tests/integration/targets/nxos_telemetry/tests/common/deleted.yaml b/tests/integration/targets/nxos_telemetry/tests/common/deleted.yaml index 4c2aacd2e..3c9556b92 100644 --- a/tests/integration/targets/nxos_telemetry/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_telemetry/tests/common/deleted.yaml @@ -65,7 +65,7 @@ data_source: NX-API path: name: '"show bgp l2vpn evpn summary"' - depth: 00 + depth: 0 query_condition: foo filter_condition: foo @@ -81,7 +81,7 @@ data_source: DME path: name: sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11] - depth: 00 + depth: 0 query_condition: foo filter_condition: foo @@ -89,7 +89,7 @@ data_source: DME path: name: sys/ospf - depth: 00 + depth: 0 query_condition: foo filter_condition: or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up")) subscriptions: diff --git a/tests/integration/targets/nxos_telemetry/tests/common/merged.yaml b/tests/integration/targets/nxos_telemetry/tests/common/merged.yaml index 384156c92..37109e9ee 100644 --- a/tests/integration/targets/nxos_telemetry/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_telemetry/tests/common/merged.yaml @@ -75,7 +75,7 @@ data_source: NX-API path: name: '"show bgp l2vpn evpn summary"' - depth: 00 + depth: 0 query_condition: foo filter_condition: foo @@ -91,7 +91,7 @@ data_source: DME path: name: sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11] - depth: 00 + depth: 0 query_condition: foo filter_condition: foo @@ -99,7 +99,7 @@ data_source: DME path: name: sys/ospf - depth: 00 + depth: 0 query_condition: foo filter_condition: or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up")) subscriptions: @@ -226,7 +226,7 @@ data_source: NX-API path: name: '"show bgp l2vpn evpn summary"' - depth: 00 + depth: 0 query_condition: foo filter_condition: foo @@ -242,7 +242,7 @@ data_source: DME path: name: sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11] - depth: 00 + depth: 0 query_condition: foo filter_condition: foo @@ -250,7 +250,7 @@ data_source: DME path: name: sys/ospf - depth: 00 + depth: 0 query_condition: foo filter_condition: or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up")) subscriptions: diff --git a/tests/integration/targets/nxos_telemetry/vars/main.yaml b/tests/integration/targets/nxos_telemetry/vars/main.yaml index fa3a93dd1..92825d4df 100644 --- a/tests/integration/targets/nxos_telemetry/vars/main.yaml +++ b/tests/integration/targets/nxos_telemetry/vars/main.yaml @@ -1,3 +1,4 @@ +--- gathered: destination_groups: - destination: diff --git a/tests/integration/targets/nxos_vlans/vars/main.yml b/tests/integration/targets/nxos_vlans/vars/main.yml index ff08ef416..8e7fb87b8 100644 --- a/tests/integration/targets/nxos_vlans/vars/main.yml +++ b/tests/integration/targets/nxos_vlans/vars/main.yml @@ -1,23 +1,24 @@ +--- gathered: - vlan_id: 1 - enabled: True + enabled: true mode: "ce" state: active name: default - vlan_id: 5 - enabled: True + enabled: true mode: "ce" name: "vlan5" state: suspend - vlan_id: 6 - enabled: True + enabled: true mode: "ce" state: active - vlan_id: 7 - enabled: False + enabled: false mode: "ce" name: "vlan7" state: active @@ -25,24 +26,24 @@ gathered: parsed: - vlan_id: 1 - enabled: True + enabled: true mode: "ce" state: active name: default - vlan_id: 5 - enabled: True + enabled: true mode: "ce" name: "vlan5" state: suspend - vlan_id: 6 - enabled: True + enabled: true mode: "ce" state: active - vlan_id: 7 - enabled: True + enabled: true mode: "ce" name: "vlan7" state: active From c148d3f666f6a499c33e99d503f9222f7f1053cb Mon Sep 17 00:00:00 2001 From: BX48uth <105424180+BX48uth@users.noreply.github.com> Date: Wed, 25 May 2022 21:41:59 +0200 Subject: [PATCH 005/166] `nxos_snmp_server` - Add support for sha-256 based user authetication (#503) * `nxos_snmp_server` - Add support for sha-256 based based user authentication. --- changelogs/fragments/snmp_server.yaml | 3 ++ docs/cisco.nxos.nxos_snmp_server_module.rst | 1 + .../nxos/argspec/snmp_server/snmp_server.py | 6 +++- .../network/nxos/rm_templates/snmp_server.py | 2 +- plugins/modules/nxos_snmp_server.py | 2 +- .../targets/nxos_snmp_server/tasks/main.yaml | 6 ++-- .../network/nxos/test_nxos_snmp_server.py | 31 +++++++++++++++++++ 7 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/snmp_server.yaml diff --git a/changelogs/fragments/snmp_server.yaml b/changelogs/fragments/snmp_server.yaml new file mode 100644 index 000000000..7eaeeaec7 --- /dev/null +++ b/changelogs/fragments/snmp_server.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_snmp_server` - Add support for sha-256 based based user authentication." diff --git a/docs/cisco.nxos.nxos_snmp_server_module.rst b/docs/cisco.nxos.nxos_snmp_server_module.rst index b4bad7e15..c09b297e6 100644 --- a/docs/cisco.nxos.nxos_snmp_server_module.rst +++ b/docs/cisco.nxos.nxos_snmp_server_module.rst @@ -3290,6 +3290,7 @@ Parameters
    Choices:
  • md5
  • sha
  • +
  • sha-256
diff --git a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py index 73a48e287..b520af4b4 100644 --- a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py @@ -368,7 +368,11 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "options": { "algorithm": { "type": "str", - "choices": ["md5", "sha"], + "choices": [ + "md5", + "sha", + "sha-256", + ], }, "password": { "type": "str", diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index 490cf93d9..ce8dcf509 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -1410,7 +1410,7 @@ def __init__(self, lines=None, module=None): ^snmp-server \suser\s(?P\S+) (\s(?P[^auth]\S+))? - (\sauth\s(?Pmd5|sha)\s(?P\S+))? + (\sauth\s(?Pmd5|sha|sha-256)\s(?P\S+))? (\spriv(\s(?Paes-128))?\s(?P\S+))? (\s(?Plocalizedkey))? (\sengineID\s(?P\S+))? diff --git a/plugins/modules/nxos_snmp_server.py b/plugins/modules/nxos_snmp_server.py index 033777183..a57622507 100644 --- a/plugins/modules/nxos_snmp_server.py +++ b/plugins/modules/nxos_snmp_server.py @@ -579,7 +579,7 @@ algorithm: description: Select algorithm for authentication. type: str - choices: ["md5", "sha"] + choices: ["md5", "sha", "sha-256"] password: description: - Authentication password for user (Max Size 127). diff --git a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index 173354b42..9dc7823ff 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -6,7 +6,7 @@ - name: Grep admin user SNMP localized key ansible.builtin.set_fact: - admin_snmp_passwd: "{{ result['stdout'][0] | regex_search('snmp-server user admin network-admin auth (md5|sha) (\\S+)', '\\2') }}" + 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 ansible.builtin.set_fact: @@ -14,7 +14,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) (\\S+)', '\\2') }}" + admin_snmp_passwd_2: "{{ result['stdout'][0] | regex_search('snmp-server user admin auth (md5|sha|sha-256) (\\S+)', '\\2') }}" - name: Find admin user SNMP localized key (second) ansible.builtin.set_fact: @@ -22,7 +22,7 @@ - name: Grep admin user SNMP engineid (second) ansible.builtin.set_fact: - admin_snmp_engineid_2: "{{ result['stdout'][0] | regex_search('admin auth (md5|sha) (\\S+) priv (\\S+) localizedkey engineID (\\S+)', '\\4') }}" + 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) ansible.builtin.set_fact: diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index dda41cbe8..43d19e0a0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -674,6 +674,20 @@ def test_nxos_snmp_server_users_merged(self): localized_key=True, ), ), + dict( + user="snmp_user_4", + group="network-admin", + authentication=dict( + algorithm="sha-256", + password="0x5632724fb8ac3699296af26281e1d0f1", + engine_id="4:4:4:4:4", + priv=dict( + privacy_password="0x5632724fb8ac3699296af26281e1d0f1", + aes_128=True, + ), + localized_key=True, + ), + ), ] ) ), @@ -688,6 +702,8 @@ def test_nxos_snmp_server_users_merged(self): " 0x5632724fb8ac3699296af26281e1d0f1 localizedkey engineID 3:3:3:3:3", "snmp-server user snmp_user_1 network-admin auth md5 0x5632724fb8ac3699296af26281e1d0f1" " localizedkey engineID 1:1:1:1:1", + "snmp-server user snmp_user_4 network-admin auth sha-256 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128" + " 0x5632724fb8ac3699296af26281e1d0f1 localizedkey engineID 4:4:4:4:4", ] result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) @@ -699,6 +715,7 @@ def test_nxos_snmp_server_users_merged(self): snmp-server user user2 network-admin auth md5 0x5632724fb8ac3699296af262 priv 0x5632724fb8ac3699296af262 localizedkey engineID 2:2:2:2:2 snmp-server user user3 network-admin auth md5 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3 snmp-server user user1 network-admin auth md5 0x5632724fb8ac3699296af262 localizedkey engineID 1:1:1:1:1 + snmp-server user user4 network-admin auth sha-256 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 4:4:4:4:4 """ ) set_module_args( @@ -743,6 +760,20 @@ def test_nxos_snmp_server_users_merged(self): localized_key=True, ), ), + dict( + user="user4", + group="network-admin", + authentication=dict( + algorithm="sha-256", + password="0x5632724fb8ac3699296af262", + engine_id="4:4:4:4:4", + priv=dict( + privacy_password="0x5632724fb8ac3699296af262", + aes_128=True, + ), + localized_key=True, + ), + ), ] ) ), From 5fd4f0c09e132b62f1e94f3c04dfddeeed6ba44f Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 26 May 2022 03:25:55 -0700 Subject: [PATCH 006/166] Limit concurrency for github actions for a single PR (#516) * Limit concurrency * Add changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 5 +++++ changelogs/fragments/516.yaml | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/516.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb2a838f8..12a7ea846 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,9 @@ name: Test collection + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + on: pull_request: branches: [main] diff --git a/changelogs/fragments/516.yaml b/changelogs/fragments/516.yaml new file mode 100644 index 000000000..ed204becb --- /dev/null +++ b/changelogs/fragments/516.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Enable concurrency check for PRs & GHA From c1d4eb4a26dcc12fc5274f55c9916d7d0c99bd74 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 31 May 2022 18:54:10 +0530 Subject: [PATCH 007/166] [snmp_server] support localizedv2_key (#519) Signed-off-by: NilashishC --- .../fragments/snmp_server_localized.yaml | 3 +++ docs/cisco.nxos.nxos_snmp_server_module.rst | 23 +++++++++++++++++++ .../nxos/argspec/snmp_server/snmp_server.py | 1 + .../network/nxos/rm_templates/snmp_server.py | 4 ++++ plugins/modules/nxos_snmp_server.py | 3 +++ .../network/nxos/test_nxos_snmp_server.py | 8 +++---- 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/snmp_server_localized.yaml diff --git a/changelogs/fragments/snmp_server_localized.yaml b/changelogs/fragments/snmp_server_localized.yaml new file mode 100644 index 000000000..0c2c841c8 --- /dev/null +++ b/changelogs/fragments/snmp_server_localized.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_snmp_server` - Add support for localizedV2key (https://github.com/ansible-collections/cisco.nxos/issues/415)." diff --git a/docs/cisco.nxos.nxos_snmp_server_module.rst b/docs/cisco.nxos.nxos_snmp_server_module.rst index c09b297e6..74912ec4c 100644 --- a/docs/cisco.nxos.nxos_snmp_server_module.rst +++ b/docs/cisco.nxos.nxos_snmp_server_module.rst @@ -3340,6 +3340,29 @@ Parameters
Specifies whether the passwords are in localized key format.
+ + + + + + +
+ localizedv2_key + +
+ boolean +
+ + +
    Choices: +
  • no
  • +
  • yes
  • +
+ + +
Specifies whether the passwords are in localized V2 key format.
+ + diff --git a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py index b520af4b4..970afc755 100644 --- a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py @@ -380,6 +380,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "engine_id": {"type": "str"}, "localized_key": {"type": "bool"}, + "localizedv2_key": {"type": "bool"}, "priv": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index ce8dcf509..fca32f9af 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -66,6 +66,8 @@ def _tmplt_users_auth(data): cmd += " {0}".format(priv["privacy_password"]) if auth.get("localized_key", False): cmd += " localizedkey" + elif auth.get("localizedv2_key", False): + cmd += " localizedV2key" if "engine_id" in auth: cmd += " engineID {0}".format(auth["engine_id"]) @@ -1413,6 +1415,7 @@ def __init__(self, lines=None, module=None): (\sauth\s(?Pmd5|sha|sha-256)\s(?P\S+))? (\spriv(\s(?Paes-128))?\s(?P\S+))? (\s(?Plocalizedkey))? + (\s(?PlocalizedV2key))? (\sengineID\s(?P\S+))? $""", re.VERBOSE), "setval": _tmplt_users_auth, @@ -1427,6 +1430,7 @@ def __init__(self, lines=None, module=None): "password": "'{{ password }}'", "engine_id": "'{{ engine_id }}'", "localized_key": "{{ not not localized_key }}", + "localizedv2_key": "{{ not not localizedv2_key }}", "priv": { "privacy_password": "'{{ privacy_password }}'", "aes_128": "{{ not not aes_128 }}", diff --git a/plugins/modules/nxos_snmp_server.py b/plugins/modules/nxos_snmp_server.py index a57622507..7c5165dad 100644 --- a/plugins/modules/nxos_snmp_server.py +++ b/plugins/modules/nxos_snmp_server.py @@ -593,6 +593,9 @@ localized_key: description: Specifies whether the passwords are in localized key format. type: bool + localizedv2_key: + description: Specifies whether the passwords are in localized V2 key format. + type: bool priv: description: Encryption parameters for the user. type: dict diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 43d19e0a0..a877d2ab6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -657,7 +657,7 @@ def test_nxos_snmp_server_users_merged(self): priv=dict( privacy_password="0x5632724fb8ac3699296af26281e1d0f1" ), - localized_key=True, + localizedv2_key=True, ), ), dict( @@ -699,7 +699,7 @@ def test_nxos_snmp_server_users_merged(self): "snmp-server user snmp_user_2 network-admin auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv 0x5632724fb8ac3699296af26281e1d0f1" " localizedkey engineID 2:2:2:2:2", "snmp-server user snmp_user_3 network-admin auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128" - " 0x5632724fb8ac3699296af26281e1d0f1 localizedkey engineID 3:3:3:3:3", + " 0x5632724fb8ac3699296af26281e1d0f1 localizedV2key engineID 3:3:3:3:3", "snmp-server user snmp_user_1 network-admin auth md5 0x5632724fb8ac3699296af26281e1d0f1" " localizedkey engineID 1:1:1:1:1", "snmp-server user snmp_user_4 network-admin auth sha-256 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128" @@ -712,7 +712,7 @@ def test_nxos_snmp_server_users_merged(self): # test merged for users self.get_config.return_value = dedent( """\ - snmp-server user user2 network-admin auth md5 0x5632724fb8ac3699296af262 priv 0x5632724fb8ac3699296af262 localizedkey engineID 2:2:2:2:2 + snmp-server user user2 network-admin auth md5 0x5632724fb8ac3699296af262 priv 0x5632724fb8ac3699296af262 localizedV2key engineID 2:2:2:2:2 snmp-server user user3 network-admin auth md5 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3 snmp-server user user1 network-admin auth md5 0x5632724fb8ac3699296af262 localizedkey engineID 1:1:1:1:1 snmp-server user user4 network-admin auth sha-256 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 4:4:4:4:4 @@ -743,7 +743,7 @@ def test_nxos_snmp_server_users_merged(self): priv=dict( privacy_password="0x5632724fb8ac3699296af262" ), - localized_key=True, + localizedv2_key=True, ), ), dict( From 951ef3fb95ac9ef97467fc414473694205039569 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Wed, 1 Jun 2022 00:28:55 -0700 Subject: [PATCH 008/166] Fix issues reported by ansible-lint (#518) * Fix issues reported by ansible-lint * Changelog * Indent ACL --- changelogs/fragments/518.yaml | 3 ++ .../targets/nxos_acls/tests/common/parsed.yml | 16 ++++-- .../nxos_bgp_address_family/tasks/main.yaml | 3 +- .../targets/nxos_bgp_global/tasks/main.yaml | 3 +- .../tasks/main.yaml | 3 +- .../targets/nxos_config/tasks/main.yaml | 3 +- .../nxos_devicealias/tests/common/sanity.yaml | 11 +++- .../nxos_facts/tests/common/all_facts.yaml | 6 ++- .../targets/nxos_file_copy/tasks/main.yaml | 3 +- .../nxos_file_copy/tests/cli/sanity.yaml | 5 +- .../targets/nxos_hostname/tasks/main.yaml | 5 +- .../targets/nxos_hsrp/tasks/main.yaml | 3 +- .../upgrade/clear_persistent_sockets.yaml | 5 +- .../upgrade/copy_kick_system_images.yaml | 14 ++--- .../tasks/upgrade/delete_files.yaml | 2 +- .../tasks/upgrade/install_os.yaml | 14 ++--- .../tasks/upgrade/install_system.yaml | 13 +++-- .../tasks/upgrade/install_with_kick.yaml | 11 ++-- .../tasks/upgrade/main_os_install.yaml | 8 +-- .../nxos_interface_ospf/tasks/main.yaml | 3 +- .../nxos_l3_interfaces/tasks/main.yaml | 3 +- .../tests/common/deleted.yaml | 6 ++- .../tests/common/merged.yaml | 6 ++- .../tests/common/overridden.yaml | 6 ++- .../tests/common/replaced.yaml | 6 ++- .../targets/nxos_logging/tasks/main.yaml | 3 +- .../targets/nxos_ntp/tasks/main.yaml | 3 +- .../nxos_nxapi/tests/cli/nxapi_ssl.yaml | 9 ++-- .../targets/nxos_ospf/tasks/main.yaml | 3 +- .../nxos_ospf_interfaces/tasks/main.yaml | 3 +- .../targets/nxos_ospf_vrf/tasks/main.yaml | 3 +- .../targets/nxos_ospfv2/tasks/main.yaml | 3 +- .../targets/nxos_ospfv3/tasks/main.yaml | 3 +- .../nxos_overlay_global/tasks/main.yaml | 3 +- .../tasks/platform/n7k/cleanup.yaml | 4 +- .../tasks/platform/n7k/setup.yaml | 4 +- .../targets/nxos_pim/tasks/main.yaml | 3 +- .../nxos_pim_interface/tasks/main.yaml | 3 +- .../targets/nxos_smoke/tasks/cli.yaml | 10 ++-- .../targets/nxos_smoke/tasks/main.yaml | 3 +- .../targets/nxos_smoke/tasks/nxapi.yaml | 8 +-- .../nxos_snmp_community/tasks/main.yaml | 3 +- .../targets/nxos_snmp_host/tasks/main.yaml | 3 +- .../nxos_snmp_location/tasks/main.yaml | 3 +- .../targets/nxos_snmp_traps/tasks/main.yaml | 3 +- .../targets/nxos_snmp_user/tasks/main.yaml | 3 +- .../targets/nxos_static_route/tasks/main.yaml | 3 +- .../tests/common/_remove_config.yaml | 2 +- .../targets/nxos_telemetry/tasks/main.yaml | 5 +- .../targets/nxos_udld/tasks/main.yaml | 3 +- .../nxos_udld_interface/tasks/main.yaml | 3 +- .../targets/nxos_user/tests/common/auth.yaml | 16 ++++-- .../targets/nxos_vpc/tasks/main.yaml | 3 +- .../nxos_vpc_interface/tasks/main.yaml | 3 +- .../targets/nxos_vrf_af/tasks/main.yaml | 3 +- .../nxos_vrf_interface/tasks/main.yaml | 3 +- .../nxos_vsan/tests/common/sanity.yaml | 21 ++++++-- .../targets/nxos_vsan/vars/main.yml | 4 +- .../targets/nxos_vtp_password/tasks/main.yaml | 3 +- .../tasks/platform/n7k/cleanup.yaml | 4 +- .../tasks/platform/n7k/setup.yaml | 4 +- .../nxos_vxlan_vtep_vni/tasks/main.yaml | 3 +- .../tests/common/sanity.yaml | 54 +++++++++++++++---- .../targets/nxos_zone_zoneset/vars/main.yml | 4 +- .../prepare_nxos_tests/tasks/prepare.yml | 13 +++-- 65 files changed, 275 insertions(+), 123 deletions(-) create mode 100644 changelogs/fragments/518.yaml diff --git a/changelogs/fragments/518.yaml b/changelogs/fragments/518.yaml new file mode 100644 index 000000000..e36d8543b --- /dev/null +++ b/changelogs/fragments/518.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix errors reported by ansible-lint diff --git a/tests/integration/targets/nxos_acls/tests/common/parsed.yml b/tests/integration/targets/nxos_acls/tests/common/parsed.yml index 306c4fbff..b408fecf0 100644 --- a/tests/integration/targets/nxos_acls/tests/common/parsed.yml +++ b/tests/integration/targets/nxos_acls/tests/common/parsed.yml @@ -15,10 +15,18 @@ - name: Parsed register: result cisco.nxos.nxos_acls: &id001 - running_config: - "ip access-list ACL1v4\n10 permit ip any any\n20 deny udp any any\nip access-list ACL2v4\n10 permit ahp 192.0.2.0 0.0.0.255 any\nipv6 access-list\ - \ ACL1v6\n10 permit sctp any any\n20 remark IPv6 ACL\nipv6 access-list ACL2v6\n10 deny ipv6 any 2001:db8:3000::36/128\n20 permit tcp 2001:db8:2000:2::2/128\ - \ 2001:db8:2000:ab::2/128\n" + running_config: >- + ip access-list ACL1v4 + 10 permit ip any any + 20 deny udp any any + ip access-list ACL2v4 + 10 permit ahp 192.0.2.0 0.0.0.255 any + ipv6 access-list ACL1v6 + 10 permit sctp any any + 20 remark IPv6 ACL + ipv6 access-list ACL2v6 + 10 deny ipv6 any 2001:db8:3000::36/128 + 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 state: parsed - ansible.builtin.assert: diff --git a/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml b/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml index 269a6496c..026b6e477 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_address_family/tasks/main.yaml @@ -5,7 +5,8 @@ vars: ansible_connection: ansible.netcommon.network_cli -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index 91bc82705..7e1c3b635 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -9,7 +9,8 @@ cisco.nxos.nxos_config: lines: feature fabric forwarding -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml index 14bbca726..13eaed64c 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/main.yaml @@ -5,7 +5,8 @@ vars: ansible_connection: ansible.netcommon.network_cli -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_config/tasks/main.yaml b/tests/integration/targets/nxos_config/tasks/main.yaml index 31c8f31e9..34b09ebba 100644 --- a/tests/integration/targets/nxos_config/tasks/main.yaml +++ b/tests/integration/targets/nxos_config/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml b/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml index c9429b170..61d8a02df 100644 --- a/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_devicealias/tests/common/sanity.yaml @@ -29,8 +29,15 @@ - ansible.builtin.assert: that: - - result.commands == ["terminal dont-ask", "device-alias database", "device-alias name ansible_test1_add pwwn 57:bb:cc:dd:ee:ff:11:67", "device-alias name - ansible_test2_add pwwn 65:22:21:20:19:18:1a:0d", "device-alias commit", "no terminal dont-ask"] + - result.commands == desired + vars: + desired: + - "terminal dont-ask" + - "device-alias database" + - "device-alias name ansible_test1_add pwwn 57:bb:cc:dd:ee:ff:11:67" + - "device-alias name ansible_test2_add pwwn 65:22:21:20:19:18:1a:0d" + - "device-alias commit" + - "no terminal dont-ask" - name: Idempotence check register: result diff --git a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index 0dd9d8ead..cce7c66a0 100644 --- a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -32,8 +32,10 @@ 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(result['ansible_facts']['ansible_net_gather_network_resources']) | + length == 0 }} - ansible.builtin.debug: msg: END connection={{ ansible_connection }}/all_facts.yaml diff --git a/tests/integration/targets/nxos_file_copy/tasks/main.yaml b/tests/integration/targets/nxos_file_copy/tasks/main.yaml index 52da2b002..510f642fa 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/main.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/main.yaml @@ -19,7 +19,8 @@ name: temp_user configured_password: "{{ temp_passwd }}" -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml b/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml index 6645dd3bc..70c450c39 100644 --- a/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml @@ -147,7 +147,10 @@ - ansible.builtin.assert: *id006 - - name: Initiate copy with sftp from nxos device to copy /bootflash/{{ test_destination_file }} to bootflash:dir2/dir2/dir3/{{ test_destination_file }}_another_copy + - name: >- + Initiate copy with sftp from nxos device to copy + /bootflash/{{ test_destination_file }} to + bootflash:dir2/dir2/dir3/{{ test_destination_file }}_another_copy register: result cisco.nxos.nxos_file_copy: file_pull: true diff --git a/tests/integration/targets/nxos_hostname/tasks/main.yaml b/tests/integration/targets/nxos_hostname/tasks/main.yaml index 263b60438..5d9d82223 100644 --- a/tests/integration/targets/nxos_hostname/tasks/main.yaml +++ b/tests/integration/targets/nxos_hostname/tasks/main.yaml @@ -5,7 +5,7 @@ register: hname_result - name: Set current hostname (default) - set_fact: + ansible.builtin.set_fact: current_hostname: "switch" - name: Set current hostname @@ -13,7 +13,8 @@ current_hostname: "{{ hname_result['stdout'][0].split(' ')[1] }}" when: hname_result.stdout[0] != "" -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_hsrp/tasks/main.yaml b/tests/integration/targets/nxos_hsrp/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_hsrp/tasks/main.yaml +++ b/tests/integration/targets/nxos_hsrp/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/clear_persistent_sockets.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/clear_persistent_sockets.yaml index d0947d0d6..9cb4efc3b 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/clear_persistent_sockets.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/clear_persistent_sockets.yaml @@ -6,11 +6,12 @@ delegate_to: 127.0.0.1 - name: Display socket info after delete - ansible.builtin.shell: /bin/ls {{ home }}/.ansible + ansible.builtin.shell: /bin/ls {{ home }}/.ansible # noqa command-instead-of-shell no-changed-when args: executable: /bin/bash delegate_to: 127.0.0.1 register: output -- ansible.builtin.debug: +- name: Debug output the local socket information + ansible.builtin.debug: msg: Local Socket Info {{ output['stdout_lines'] }} diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index b6073d332..45b01d749 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -8,14 +8,14 @@ ignore_errors_httpapi: true when: ansible_connection == 'ansible.netcommon.httpapi' -- ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml +- ansible.builtin.include: enable_scp_server.yaml - name: Remove SSH known_hosts file before scp of image file - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_command: commands: run bash rm /var/home/admin/.ssh/known_hosts -- name: Copy {{ si }} to bootflash +- name: Copy {{ si }} to bootflash # noqa var-spacing register: result cisco.nxos.nxos_file_copy: file_pull: true @@ -25,11 +25,12 @@ remote_scp_server_user: "{{ remote_scp_user }}" remote_scp_server_password: "{{ remote_scp_password }}" -- ansible.builtin.debug: +- name: Debug output the result from the image copy + ansible.builtin.debug: msg: "{{ item.key }} {{ item.value }}" with_dict: "{{ result }}" -- name: Copy {{ ki }} to bootflash +- name: Copy {{ ki }} to bootflash # noqa var-spacing when: ki is defined register: result cisco.nxos.nxos_file_copy: @@ -40,7 +41,8 @@ remote_scp_server_user: "{{ remote_scp_user }}" remote_scp_server_password: "{{ remote_scp_password }}" -- ansible.builtin.debug: +- name: Debug out the result from the image copy + ansible.builtin.debug: msg: "{{ item.key }} {{ item.value }}" with_dict: "{{ result }}" when: ki is defined diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml index 2bfd69f64..d382c3c0e 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml @@ -1,6 +1,6 @@ --- - name: Delete files to make room on bootflash - ignore_errors: true + ignore_errors: true # noqa ignore-errors with_items: "{{ delete_image_list }}" cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml index 63fbb7f36..412d233e4 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml @@ -1,17 +1,18 @@ --- -- ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/delete_files.yaml +- ansible.builtin.include: delete_files.yaml when: delete_files -- ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml ansible_connection=ansible.netcommon.network_cli connection={{ cli }} +- ansible.builtin.include: copy_kick_system_images.yaml ansible_connection=ansible.netcommon.network_cli connection={{ cli }} when: copy_images -- ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml +- ansible.builtin.include: install_with_kick.yaml when: ki is defined -- ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/install_system.yaml +- ansible.builtin.include: install_system.yaml when: ki is undefined -- ansible.builtin.meta: reset_connection +- name: Reset the connection + ansible.builtin.meta: reset_connection - name: Check installed OS for newly installed version {{ tv }} register: output @@ -19,5 +20,6 @@ commands: - show version | json -- ansible.builtin.debug: +- name: Debug output the version detected + ansible.builtin.debug: msg: Version detected {{ output['stdout_lines'][0]['kickstart_ver_str'] }} diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml index d9687c6e2..a45453fa0 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml @@ -8,7 +8,7 @@ issu: "{{ issu }}" - name: Remove old boot pointers if any - ignore_errors: true + ignore_errors: true # noqa ignore-errors when: force cisco.nxos.nxos_config: lines: @@ -26,14 +26,15 @@ match: line - name: Boot image {{ si }} using reload - ignore_errors: true + ignore_errors: true # noqa ignore-errors when: force cisco.nxos.nxos_config: lines: - terminal dont-ask - reload -- ansible.builtin.debug: +- name: Debug output the result from the image installation + ansible.builtin.debug: msg: " {{ result['install_state'] }}" when: not force @@ -46,10 +47,12 @@ host: "{{ inventory_hostname }}" when: result.changed and not checkmode -- ansible.builtin.debug: +- name: Debug output a warning about the 5 minute wait + ansible.builtin.debug: msg: Wait 5 mins to allow system to stabilize when: result.changed and not checkmode -- ansible.builtin.pause: +- name: Wait for device to come back up with new image + ansible.builtin.pause: seconds: 300 when: result.changed and not checkmode diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml index 79b1dbfb0..7116671d7 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml @@ -20,12 +20,13 @@ match: line - name: Boot image {{ si }} using reload - ignore_errors: true + ignore_errors: true # noqa ignore-errors when: force cisco.nxos.nxos_command: commands: terminal dont-ask ; reload -- ansible.builtin.debug: +- name: Debug output the result from the image installation + ansible.builtin.debug: msg: " {{ result['install_state'] }}" when: not force @@ -38,10 +39,12 @@ host: "{{ inventory_hostname }}" when: result.changed and not checkmode -- ansible.builtin.debug: +- name: Debug output a warning about the 5 minute wait + ansible.builtin.debug: msg: Wait 5 mins to allow system to stabilize when: result.changed and not checkmode -- ansible.builtin.pause: +- name: Wait for device to come back up with new image + ansible.builtin.pause: seconds: 300 when: result.changed and not checkmode diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml index 6c96c364e..b9da7285b 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml @@ -1,7 +1,9 @@ --- -- ansible.builtin.debug: +- name: Debug output a warning about meta endplay + ansible.builtin.debug: msg: "***WARNING*** Remove meta end_play to verify this module ***WARNING***" -- ansible.builtin.meta: end_play +- name: End the play + ansible.builtin.meta: end_play -- ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/install_os.yaml +- ansible.builtin.include: install_os.yaml diff --git a/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml +++ b/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml index a3cb83f5c..85daeeff3 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml @@ -3,7 +3,8 @@ ansible.builtin.set_fact: rsvd_intf: "{{ rsvd_intf|default('mgmt0') }}" -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml index bdc9ab171..c38b3ef21 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/deleted.yaml @@ -5,7 +5,11 @@ - name: Set a fact for 'mode' ansible.builtin.set_fact: mode: delay - when: platform is not search('N3K|N5K|N6K|N7K') and imagetag is not search('A8|I2') and image_version is not search ('9.2') and chassis_type is not search('C95') + when: >- + platform is not search('N3K|N5K|N6K|N7K') and + imagetag is not search('A8|I2') and + image_version is not search ('9.2') and + chassis_type is not search('C95') - name: Setup1 cisco.nxos.nxos_config: &id002 diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml index db91aad02..ee01bc24d 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/merged.yaml @@ -5,7 +5,11 @@ - name: Set a fact for 'mode' ansible.builtin.set_fact: mode: delay - when: platform is not search('N3K|N5K|N6K|N7K') and imagetag is not search('A8|I2') and image_version is not search ('9.2') and chassis_type is not search('C95') + when: >- + platform is not search('N3K|N5K|N6K|N7K') and + imagetag is not search('A8|I2') and + image_version is not search ('9.2') and + chassis_type is not search('C95') - name: Setup1 cisco.nxos.nxos_config: &id002 diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml index 3ebc4f2b4..e3dfb8385 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/overridden.yaml @@ -5,7 +5,11 @@ - name: Set a fact for 'mode' ansible.builtin.set_fact: mode: delay - when: platform is not search('N3K|N5K|N6K|N7K') and imagetag is not search('A8|I2') and image_version is not search ('9.2') and chassis_type is not search('C95') + when: >- + platform is not search('N3K|N5K|N6K|N7K') and + imagetag is not search('A8|I2') and + image_version is not search ('9.2') and + chassis_type is not search('C95') - name: Setup1 cisco.nxos.nxos_config: &id003 diff --git a/tests/integration/targets/nxos_lacp_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_lacp_interfaces/tests/common/replaced.yaml index fb707b6cf..f76274787 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_lacp_interfaces/tests/common/replaced.yaml @@ -5,7 +5,11 @@ - name: Set a fact for 'mode' ansible.builtin.set_fact: mode: delay - when: platform is not search('N3K|N5K|N6K|N7K') and imagetag is not search('A8|I2') and image_version is not search ('9.2') and chassis_type is not search('C95') + when: >- + platform is not search('N3K|N5K|N6K|N7K') and + imagetag is not search('A8|I2') and + image_version is not search ('9.2') and + chassis_type is not search('C95') - name: Setup1 cisco.nxos.nxos_config: &id003 diff --git a/tests/integration/targets/nxos_logging/tasks/main.yaml b/tests/integration/targets/nxos_logging/tasks/main.yaml index 4e16b2ade..ccb324f33 100644 --- a/tests/integration/targets/nxos_logging/tasks/main.yaml +++ b/tests/integration/targets/nxos_logging/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_ntp/tasks/main.yaml b/tests/integration/targets/nxos_ntp/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_ntp/tasks/main.yaml +++ b/tests/integration/targets/nxos_ntp/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml b/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml index 810537664..6e4a8c21c 100644 --- a/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/cli/nxapi_ssl.yaml @@ -243,6 +243,9 @@ - ansible.builtin.debug: msg: END cli/nxapi_ssl.yaml - when: - (platform is match("N9K") or platform is match("N3K") or platform is match("N9K-F") or platform is match("N35") or platform is match("N3L")) and major_version - is version('9.2', '>=') + when: >- + (platform is match("N9K") or + platform is match("N3K") or + platform is match("N9K-F") or + platform is match("N35") or + platform is match("N3L")) and major_version is version('9.2', '>=') diff --git a/tests/integration/targets/nxos_ospf/tasks/main.yaml b/tests/integration/targets/nxos_ospf/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_ospf/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospf/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml index 96d84552a..1621aacab 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospf_interfaces/tasks/main.yaml @@ -7,7 +7,8 @@ vars: ansible_connection: ansible.netcommon.network_cli -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_ospfv2/tasks/main.yaml b/tests/integration/targets/nxos_ospfv2/tasks/main.yaml index 9932f222c..4e36581ee 100644 --- a/tests/integration/targets/nxos_ospfv2/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospfv2/tasks/main.yaml @@ -5,7 +5,8 @@ vars: ansible_connection: ansible.netcommon.network_cli -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_ospfv3/tasks/main.yaml b/tests/integration/targets/nxos_ospfv3/tasks/main.yaml index 8a734c77e..8be45e21c 100644 --- a/tests/integration/targets/nxos_ospfv3/tasks/main.yaml +++ b/tests/integration/targets/nxos_ospfv3/tasks/main.yaml @@ -5,7 +5,8 @@ vars: ansible_connection: ansible.netcommon.network_cli -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_overlay_global/tasks/main.yaml b/tests/integration/targets/nxos_overlay_global/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml index 92fffe748..6de2a7ac2 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml @@ -1,6 +1,6 @@ --- - name: Unconfigure VDC setting limit-resource module-type f3 - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; no limit-resource module-type f3 @@ -11,7 +11,7 @@ seconds: 45 - name: Configure VDC setting allocate interface unallocated-interfaces - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; allocate interface unallocated-interfaces diff --git a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml index 39ed917f2..856dae1ff 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml +++ b/tests/integration/targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml @@ -10,7 +10,7 @@ vdcid: "{{ vdcout.stdout_lines[0].name }}" - name: Configure VDC setting limit-resource module-type f3 - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; limit-resource module-type f3 @@ -21,7 +21,7 @@ seconds: 45 - name: Configure VDC setting allocate interface unallocated-interfaces - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; allocate interface unallocated-interfaces diff --git a/tests/integration/targets/nxos_pim/tasks/main.yaml b/tests/integration/targets/nxos_pim/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_pim/tasks/main.yaml +++ b/tests/integration/targets/nxos_pim/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_pim_interface/tasks/main.yaml b/tests/integration/targets/nxos_pim_interface/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_pim_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_pim_interface/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_smoke/tasks/cli.yaml b/tests/integration/targets/nxos_smoke/tasks/cli.yaml index f7c86a15a..ddee44927 100644 --- a/tests/integration/targets/nxos_smoke/tasks/cli.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/cli.yaml @@ -38,11 +38,11 @@ connection: "{{ cli }}" # Temporarily disabling connection=local tests for CI issues -#- name: run test cases (connection=local) -# include: "{{ test_case_to_run }} ansible_connection=local connection={{ cli }}" -# with_items: "{{ test_items }}" -# loop_control: -# loop_var: test_case_to_run +# - name: run test cases (connection=local) +# include: "{{ test_case_to_run }} ansible_connection=local connection={{ cli }}" +# with_items: "{{ test_items }}" +# loop_control: +# loop_var: test_case_to_run - name: Run test cases (connection=network_cli) ansible.builtin.include: diff --git a/tests/integration/targets/nxos_smoke/tasks/main.yaml b/tests/integration/targets/nxos_smoke/tasks/main.yaml index d4c726ce7..2d03cb9fa 100644 --- a/tests/integration/targets/nxos_smoke/tasks/main.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/main.yaml @@ -2,7 +2,8 @@ # Some of the tests in this suite change the hostname to switch. # This block/always ensures the hostname gets changed back to # the correct name. -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml index 1f1604aa3..56f500768 100644 --- a/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml @@ -31,8 +31,8 @@ ansible_connection: httpapi connection: "{{ nxapi }}" # Temporarily disabling connection=local tests for CI issues -#- name: run test cases (connection=local) -# include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}" -# with_items: "{{ test_items }}" -# loop_control: +# - name: run test cases (connection=local) +# include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}" +# with_items: "{{ test_items }}" +# loop_control: # loop_var: test_case_to_run diff --git a/tests/integration/targets/nxos_snmp_community/tasks/main.yaml b/tests/integration/targets/nxos_snmp_community/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_snmp_community/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_community/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_snmp_host/tasks/main.yaml b/tests/integration/targets/nxos_snmp_host/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_snmp_host/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_host/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_snmp_location/tasks/main.yaml b/tests/integration/targets/nxos_snmp_location/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_snmp_location/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_location/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml b/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_traps/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_snmp_user/tasks/main.yaml b/tests/integration/targets/nxos_snmp_user/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_snmp_user/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_user/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_static_route/tasks/main.yaml b/tests/integration/targets/nxos_static_route/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_static_route/tasks/main.yaml +++ b/tests/integration/targets/nxos_static_route/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml index 4ea8351c6..dcc3f18aa 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_static_routes/tests/common/_remove_config.yaml @@ -12,4 +12,4 @@ - "no vrf context trial_vrf" - "default interface {{ nxos_int2 }}" ignore_errors: true - #error is thrown if we deleted trial_vrf when it is not present already. ignore_errors circumvents it + # error is thrown if we deleted trial_vrf when it is not present already. ignore_errors circumvents it diff --git a/tests/integration/targets/nxos_telemetry/tasks/main.yaml b/tests/integration/targets/nxos_telemetry/tasks/main.yaml index f5ad5c61b..c1a0e9d3c 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/main.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/main.yaml @@ -66,7 +66,8 @@ vars: ansible_connection: ansible.netcommon.network_cli -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: cli @@ -88,7 +89,7 @@ state: disabled - name: Setup - remove existing file - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_command: commands: - terminal dont-ask diff --git a/tests/integration/targets/nxos_udld/tasks/main.yaml b/tests/integration/targets/nxos_udld/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_udld/tasks/main.yaml +++ b/tests/integration/targets/nxos_udld/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_udld_interface/tasks/main.yaml b/tests/integration/targets/nxos_udld_interface/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_udld_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_udld_interface/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_user/tests/common/auth.yaml b/tests/integration/targets/nxos_user/tests/common/auth.yaml index f092eeaa3..99903b6bc 100644 --- a/tests/integration/targets/nxos_user/tests/common/auth.yaml +++ b/tests/integration/targets/nxos_user/tests/common/auth.yaml @@ -9,16 +9,24 @@ - name: Test login ansible.builtin.expect: - command: - ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no + command: >- + ssh auth_user@{{ ansible_ssh_host }} + -p {{ ansible_ssh_port|default(22) }} + -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no + -o PubkeyAuthentication=no show version responses: (?i)password: pasS!123 - name: Test login with invalid password (should fail) ansible.builtin.expect: - command: - ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no + command: >- + ssh auth_user@{{ ansible_ssh_host }} + -p {{ ansible_ssh_port|default(22) }} + -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no + -o PubkeyAuthentication=no show version responses: (?i)password: badpass diff --git a/tests/integration/targets/nxos_vpc/tasks/main.yaml b/tests/integration/targets/nxos_vpc/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_vpc/tasks/main.yaml +++ b/tests/integration/targets/nxos_vpc/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml b/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_vpc_interface/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_vrf_af/tasks/main.yaml b/tests/integration/targets/nxos_vrf_af/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_vrf_af/tasks/main.yaml +++ b/tests/integration/targets/nxos_vrf_af/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml b/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml +++ b/tests/integration/targets/nxos_vrf_interface/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml b/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml index ce8eba064..fd6a1f21e 100644 --- a/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vsan/tests/common/sanity.yaml @@ -3,7 +3,10 @@ msg: "START nxos_vsan sanity test with connection={{ ansible_connection }} " - ansible.builtin.debug: - msg: Using vsans {{ vsan1 }}, {{ vsan2 }} for running this sanity test, please make sure these are not used in the setup, these will be deleted after the tests + msg: >- + Using vsans {{ vsan1 }}, {{ vsan2 }} for running this sanity test, + please make sure these are not used in the setup, + these will be deleted after the tests - block: - name: Setup - remove VSAN if configured @@ -39,8 +42,20 @@ - ansible.builtin.assert: that: - - result.commands == ["terminal dont-ask", "vsan database", "vsan 922", "vsan 922 name vsan-SAN-A", "vsan 922 suspend", "vsan 922 interface fc1/1", "vsan - 923", "vsan 923 name vsan-SAN-B", "no vsan 923 suspend", "vsan 923 interface fc1/2", "no terminal dont-ask"] + - result.commands == desired + vars: + desired: + - "terminal dont-ask" + - "vsan database" + - "vsan 922" + - "vsan 922 name vsan-SAN-A" + - "vsan 922 suspend" + - "vsan 922 interface fc1/1" + - "vsan 923" + - "vsan 923 name vsan-SAN-B" + - "no vsan 923 suspend" + - "vsan 923 interface fc1/2" + - "no terminal dont-ask" - name: Idempotence check register: result diff --git a/tests/integration/targets/nxos_vsan/vars/main.yml b/tests/integration/targets/nxos_vsan/vars/main.yml index 9c8077a47..41b2fdb0d 100644 --- a/tests/integration/targets/nxos_vsan/vars/main.yml +++ b/tests/integration/targets/nxos_vsan/vars/main.yml @@ -1,5 +1,5 @@ --- vsan1: 922 vsan2: 923 -intA1: fc1/1 -intB1: fc1/2 +intA1: fc1/1 # noqa var-naming +intB1: fc1/2 # noqa var-naming diff --git a/tests/integration/targets/nxos_vtp_password/tasks/main.yaml b/tests/integration/targets/nxos_vtp_password/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_vtp_password/tasks/main.yaml +++ b/tests/integration/targets/nxos_vtp_password/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml index 92fffe748..6de2a7ac2 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml @@ -1,6 +1,6 @@ --- - name: Unconfigure VDC setting limit-resource module-type f3 - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; no limit-resource module-type f3 @@ -11,7 +11,7 @@ seconds: 45 - name: Configure VDC setting allocate interface unallocated-interfaces - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; allocate interface unallocated-interfaces diff --git a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml index 3883f2b8a..52a8aad85 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml @@ -10,7 +10,7 @@ vdcid: "{{ vdcout.stdout_lines[0].name }}" - name: Configure VDC setting limit-resource module-type f3 - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; limit-resource module-type f3 @@ -21,7 +21,7 @@ seconds: 45 - name: Configure VDC setting allocate interface unallocated-interfaces - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: commands: - terminal dont-ask ; vdc {{ vdcid }} ; allocate interface unallocated-interfaces diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml index d476f905a..c9e70304e 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/main.yaml @@ -1,5 +1,6 @@ --- -- block: +- name: Run the CLI and NX-API tests + block: - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml b/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml index 7137c91d3..a0b5948c7 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_zone_zoneset/tests/common/sanity.yaml @@ -3,7 +3,10 @@ msg: "START nxos_zone_zoneset sanity test with connection={{ ansible_connection }} " - ansible.builtin.debug: - msg: Using vsans {{ vsan1 }}, {{ vsan2 }} for running this sanity test, please make sure these are not used in the setup, these will be deleted after the tests + msg: >- + Using vsans {{ vsan1 }}, {{ vsan2 }} for running this sanity test, + please make sure these are not used in the setup, + these will be deleted after the tests - always: - name: Remove VSAN configuration @@ -110,12 +113,35 @@ - ansible.builtin.assert: that: - - result.commands == ["terminal dont-ask", "zone mode enhanced vsan 922", "zone name zoneA vsan 922", "member pwwn 11:11:11:11:11:11:11:11", "member device-alias - test123", "zone name zoneB vsan 922", "member pwwn 10:11:11:11:11:11:11:11", "member pwwn 62:62:62:62:21:21:21:21", "zoneset name zsetname1 vsan 922", - "member zoneA", "member zoneB", "zoneset activate name zsetname1 vsan 922", "zone commit vsan 922", "zone smart-zoning enable vsan 923", "zone name zone21A - vsan 923", "member pwwn 11:11:11:11:11:11:11:11 both", "member pwwn 62:62:62:62:12:12:12:12", "zone name zone21B vsan 923", "member pwwn 10:11:11:11:11:11:11:11", - "member pwwn 62:62:62:62:21:21:21:21", "member device-alias somedummyname", "zoneset name zsetname21 vsan 923", "member zone21A", "member zone21B", "zoneset - activate name zsetname21 vsan 923", "no terminal dont-ask"] + - result.commands == desired + vars: + desired: + - "terminal dont-ask" + - "zone mode enhanced vsan 922" + - "zone name zoneA vsan 922" + - "member pwwn 11:11:11:11:11:11:11:11" + - "member device-alias test123" + - "zone name zoneB vsan 922" + - "member pwwn 10:11:11:11:11:11:11:11" + - "member pwwn 62:62:62:62:21:21:21:21" + - "zoneset name zsetname1 vsan 922" + - "member zoneA" + - "member zoneB" + - "zoneset activate name zsetname1 vsan 922" + - "zone commit vsan 922" + - "zone smart-zoning enable vsan 923" + - "zone name zone21A vsan 923" + - "member pwwn 11:11:11:11:11:11:11:11 both" + - "member pwwn 62:62:62:62:12:12:12:12" + - "zone name zone21B vsan 923" + - "member pwwn 10:11:11:11:11:11:11:11" + - "member pwwn 62:62:62:62:21:21:21:21" + - "member device-alias somedummyname" + - "zoneset name zsetname21 vsan 923" + - "member zone21A" + - "member zone21B" + - "zoneset activate name zsetname21 vsan 923" + - "no terminal dont-ask" - name: Idempotence check register: result @@ -175,8 +201,18 @@ - ansible.builtin.assert: that: - - result.commands == ["terminal dont-ask", "no zone name zoneA vsan 922", "no zone name zoneB vsan 922", "no zoneset name zsetname1 vsan 922", "zone commit - vsan 922", "no zone name zone21A vsan 923", "no zone name zone21B vsan 923", "no zoneset name zsetname21 vsan 923", "no terminal dont-ask"] + - result.commands == desired + vars: + desired: + - "terminal dont-ask" + - "no zone name zoneA vsan 922" + - "no zone name zoneB vsan 922" + - "no zoneset name zsetname1 vsan 922" + - "zone commit vsan 922" + - "no zone name zone21A vsan 923" + - "no zone name zone21B vsan 923" + - "no zoneset name zsetname21 vsan 923" + - "no terminal dont-ask" - name: Idempotence check for zone/zoneset removal register: result diff --git a/tests/integration/targets/nxos_zone_zoneset/vars/main.yml b/tests/integration/targets/nxos_zone_zoneset/vars/main.yml index 9c8077a47..41b2fdb0d 100644 --- a/tests/integration/targets/nxos_zone_zoneset/vars/main.yml +++ b/tests/integration/targets/nxos_zone_zoneset/vars/main.yml @@ -1,5 +1,5 @@ --- vsan1: 922 vsan2: 923 -intA1: fc1/1 -intB1: fc1/2 +intA1: fc1/1 # noqa var-naming +intB1: fc1/2 # noqa var-naming diff --git a/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml b/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml index 4f916279a..073e0d7bf 100644 --- a/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml +++ b/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml @@ -1,7 +1,7 @@ --- - name: Enable feature privilege connection: ansible.netcommon.network_cli - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: lines: - feature privilege @@ -13,7 +13,7 @@ - name: Enable lldp connection: ansible.netcommon.network_cli - ignore_errors: true + ignore_errors: true # noqa ignore-errors cisco.nxos.nxos_config: lines: - feature lldp @@ -148,13 +148,16 @@ imagemr: "{{ image_version[11:12] }}" when: image_version is search("\d\.\d\(\d\)\S\S\S\S\(\d\)") -- ansible.builtin.debug: +- name: Debug output the image version + ansible.builtin.debug: msg: IMAGE VERSION {{ image_version }} -- ansible.builtin.debug: +- name: Debug output the image tag + ansible.builtin.debug: msg: IMAGE TAG {{ imagetag }} -- ansible.builtin.debug: +- name: Debug output the image maintenance release + ansible.builtin.debug: msg: IMAGE MR {{ imagemr }} - name: Set a fact for 'ipv6_supported' From 56d70ef8db9e9dccba36d86ec4e6375a8fa16b67 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 1 Jun 2022 19:18:23 +0530 Subject: [PATCH 009/166] [interfaces] Enable virtual interfaces with enable set to True (#378) * [interfaces] Enable virtual interfaces with enable set to True Signed-off-by: NilashishC * Update test case Signed-off-by: NilashishC --- changelogs/fragments/nxos_interfaces.yaml | 3 ++ .../nxos/config/interfaces/interfaces.py | 9 +++-- .../network/nxos/test_nxos_interfaces.py | 37 ++++++++++++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/nxos_interfaces.yaml diff --git a/changelogs/fragments/nxos_interfaces.yaml b/changelogs/fragments/nxos_interfaces.yaml new file mode 100644 index 000000000..be7070695 --- /dev/null +++ b/changelogs/fragments/nxos_interfaces.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True (https://github.com/ansible-collections/cisco.nxos/issues/335)." diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index 2ab550401..abc89fabf 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -412,8 +412,6 @@ def diff_of_dicts(self, w, obj): def add_commands(self, d, obj_in_have=None): commands = [] - if not d: - return commands if obj_in_have is None: obj_in_have = {} # mode/switchport changes should occur before other changes @@ -433,8 +431,11 @@ def add_commands(self, d, obj_in_have=None): if "duplex" in d: commands.append("duplex " + d["duplex"]) if "enabled" in d: - have_enabled = obj_in_have.get( - "enabled", self.default_enabled(d, obj_in_have) + have_enabled = ( + obj_in_have.get( + "enabled", self.default_enabled(d, obj_in_have) + ) + or False ) if d["enabled"] is False and have_enabled is True: commands.append("shutdown") diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 08b49e955..140b19ecb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -310,7 +310,6 @@ def test_2(self): dict(name="Ethernet1/3", enabled=True), dict(name="loopback3", enabled=True), dict(name="port-channel3", enabled=True), - # Set default state on non-existent objs; no state changes but need to create intf dict(name="loopback4", enabled=True), dict(name="port-channel4", enabled=True), dict(name="Ethernet1/4.101"), @@ -329,7 +328,9 @@ def test_2(self): "interface port-channel3", "no shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", ] playbook["state"] = "merged" @@ -367,7 +368,9 @@ def test_2(self): "interface port-channel3", "no shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", ] playbook["state"] = "replaced" @@ -392,7 +395,9 @@ def test_2(self): "interface loopback1", "shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", ] playbook["state"] = "overridden" @@ -468,7 +473,9 @@ def test_3(self): "interface port-channel3", "no shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", ] playbook["state"] = "merged" @@ -490,7 +497,9 @@ def test_3(self): "interface port-channel3", "no shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", ] self.execute_module( @@ -528,13 +537,35 @@ def test_3(self): "interface port-channel3", "no shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", ] playbook["state"] = "replaced" set_module_args(playbook, ignore_provider_arg) self.execute_module(changed=True, commands=replaced) + playbook = dict( + config=[ + # Set non-default states on existing objs + dict(name="Ethernet1/1", mode="layer3", enabled=True), + dict(name="loopback1", enabled=False), + # Set default states on existing objs + dict(name="Ethernet1/2", enabled=False), + dict(name="loopback2", enabled=True), + # Set explicit default state on existing objs (no chg) + dict(name="Ethernet1/3", enabled=False), + dict(name="loopback3", enabled=True), + dict(name="port-channel3", enabled=True), + # Set default state on non-existent objs; no state changes but need to create intf + dict(name="loopback4", enabled=True), + dict(name="port-channel4", enabled=True), + dict(name="Ethernet1/4.101", enabled=False), + dict(name="Ethernet1/4.102", enabled=True), + ] + ) + overridden = [ "interface Ethernet1/2", "switchport", @@ -553,8 +584,12 @@ def test_3(self): "interface loopback1", "shutdown", "interface loopback4", + "no shutdown", "interface port-channel4", + "no shutdown", "interface Ethernet1/4.101", + "interface Ethernet1/4.102", + "no shutdown", ] playbook["state"] = "overridden" set_module_args(playbook, ignore_provider_arg) From 9be5f8a6a02698e9e5173c4e18c39c09b0cc214e Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Wed, 1 Jun 2022 12:27:51 -0700 Subject: [PATCH 010/166] Add isort, increase black line length (#517) --- .isort.cfg | 6 + .pre-commit-config.yaml | 7 +- changelogs/fragments/517.yaml | 3 + plugins/action/nxos.py | 83 +++----- plugins/cliconf/nxos.py | 104 +++------ plugins/doc_fragments/nxos.py | 1 + plugins/httpapi/nxos.py | 23 +- .../argspec/acl_interfaces/acl_interfaces.py | 1 + .../network/nxos/argspec/acls/acls.py | 201 +++++------------- .../argspec/bfd_interfaces/bfd_interfaces.py | 1 + .../bgp_address_family/bgp_address_family.py | 17 +- .../nxos/argspec/bgp_global/bgp_global.py | 33 +-- .../bgp_neighbor_address_family.py | 49 ++--- .../network/nxos/argspec/facts/facts.py | 1 + .../network/nxos/argspec/hostname/hostname.py | 1 + .../hsrp_interfaces/hsrp_interfaces.py | 1 + .../nxos/argspec/interfaces/interfaces.py | 1 + .../argspec/l2_interfaces/l2_interfaces.py | 1 + .../argspec/l3_interfaces/l3_interfaces.py | 1 + .../network/nxos/argspec/lacp/lacp.py | 1 + .../lacp_interfaces/lacp_interfaces.py | 1 + .../argspec/lag_interfaces/lag_interfaces.py | 1 + .../nxos/argspec/lldp_global/lldp_global.py | 1 + .../lldp_interfaces/lldp_interfaces.py | 1 + .../argspec/logging_global/logging_global.py | 5 +- .../nxos/argspec/ntp_global/ntp_global.py | 1 + .../ospf_interfaces/ospf_interfaces.py | 5 +- .../network/nxos/argspec/ospfv2/ospfv2.py | 145 ++++--------- .../network/nxos/argspec/ospfv3/ospfv3.py | 121 +++-------- .../nxos/argspec/prefix_lists/prefix_lists.py | 1 + .../nxos/argspec/route_maps/route_maps.py | 65 ++---- .../nxos/argspec/snmp_server/snmp_server.py | 29 +-- .../argspec/static_routes/static_routes.py | 5 +- .../nxos/argspec/telemetry/telemetry.py | 1 + .../network/nxos/argspec/vlans/vlans.py | 1 + .../nxos/cmdref/telemetry/telemetry.py | 1 + .../config/acl_interfaces/acl_interfaces.py | 67 ++---- .../network/nxos/config/acls/acls.py | 194 +++++------------ .../config/bfd_interfaces/bfd_interfaces.py | 40 ++-- .../bgp_address_family/bgp_address_family.py | 47 ++-- .../nxos/config/bgp_global/bgp_global.py | 45 ++-- .../bgp_neighbor_address_family.py | 29 +-- .../network/nxos/config/hostname/hostname.py | 6 +- .../config/hsrp_interfaces/hsrp_interfaces.py | 35 +-- .../nxos/config/interfaces/interfaces.py | 59 ++--- .../config/l2_interfaces/l2_interfaces.py | 52 ++--- .../config/l3_interfaces/l3_interfaces.py | 82 ++----- .../network/nxos/config/lacp/lacp.py | 12 +- .../config/lacp_interfaces/lacp_interfaces.py | 39 ++-- .../config/lag_interfaces/lag_interfaces.py | 47 ++-- .../nxos/config/lldp_global/lldp_global.py | 26 +-- .../config/lldp_interfaces/lldp_interfaces.py | 41 ++-- .../config/logging_global/logging_global.py | 18 +- .../nxos/config/ntp_global/ntp_global.py | 14 +- .../config/ospf_interfaces/ospf_interfaces.py | 53 ++--- .../network/nxos/config/ospfv2/ospfv2.py | 57 ++--- .../network/nxos/config/ospfv3/ospfv3.py | 53 ++--- .../nxos/config/prefix_lists/prefix_lists.py | 34 +-- .../nxos/config/route_maps/route_maps.py | 24 +-- .../nxos/config/snmp_server/snmp_server.py | 21 +- .../config/static_routes/static_routes.py | 135 ++++-------- .../nxos/config/telemetry/telemetry.py | 188 +++++----------- .../network/nxos/config/vlans/vlans.py | 18 +- .../facts/acl_interfaces/acl_interfaces.py | 16 +- .../network/nxos/facts/acls/acls.py | 28 +-- .../facts/bfd_interfaces/bfd_interfaces.py | 25 +-- .../bgp_address_family/bgp_address_family.py | 26 +-- .../nxos/facts/bgp_global/bgp_global.py | 22 +- .../bgp_neighbor_address_family.py | 27 +-- .../module_utils/network/nxos/facts/facts.py | 104 +++++---- .../network/nxos/facts/hostname/hostname.py | 18 +- .../facts/hsrp_interfaces/hsrp_interfaces.py | 15 +- .../nxos/facts/interfaces/interfaces.py | 29 +-- .../nxos/facts/l2_interfaces/l2_interfaces.py | 19 +- .../nxos/facts/l3_interfaces/l3_interfaces.py | 27 +-- .../network/nxos/facts/lacp/lacp.py | 15 +- .../facts/lacp_interfaces/lacp_interfaces.py | 15 +- .../facts/lag_interfaces/lag_interfaces.py | 15 +- .../network/nxos/facts/legacy/base.py | 91 +++----- .../nxos/facts/lldp_global/lldp_global.py | 19 +- .../facts/lldp_interfaces/lldp_interfaces.py | 11 +- .../facts/logging_global/logging_global.py | 22 +- .../nxos/facts/ntp_global/ntp_global.py | 18 +- .../facts/ospf_interfaces/ospf_interfaces.py | 18 +- .../network/nxos/facts/ospfv2/ospfv2.py | 16 +- .../network/nxos/facts/ospfv3/ospfv3.py | 10 +- .../nxos/facts/prefix_lists/prefix_lists.py | 26 +-- .../nxos/facts/route_maps/route_maps.py | 18 +- .../nxos/facts/snmp_server/snmp_server.py | 22 +- .../nxos/facts/static_routes/static_routes.py | 48 ++--- .../network/nxos/facts/telemetry/telemetry.py | 64 ++---- .../network/nxos/facts/vlans/vlans.py | 29 +-- plugins/module_utils/network/nxos/nxos.py | 192 +++++------------ .../nxos/rm_templates/bgp_address_family.py | 6 +- .../network/nxos/rm_templates/bgp_global.py | 6 +- .../bgp_neighbor_address_family.py | 6 +- .../network/nxos/rm_templates/hostname.py | 6 +- .../nxos/rm_templates/logging_global.py | 10 +- .../network/nxos/rm_templates/ntp_global.py | 6 +- .../nxos/rm_templates/ospf_interfaces.py | 6 +- .../network/nxos/rm_templates/ospfv2.py | 10 +- .../network/nxos/rm_templates/ospfv3.py | 18 +- .../network/nxos/rm_templates/prefix_lists.py | 6 +- .../network/nxos/rm_templates/route_maps.py | 6 +- .../network/nxos/rm_templates/snmp_server.py | 6 +- .../network/nxos/utils/telemetry/telemetry.py | 38 ++-- .../module_utils/network/nxos/utils/utils.py | 9 +- plugins/modules/nxos_aaa_server.py | 58 ++--- plugins/modules/nxos_aaa_server_host.py | 34 +-- plugins/modules/nxos_acl.py | 64 ++---- plugins/modules/nxos_acl_interface.py | 20 +- plugins/modules/nxos_acl_interfaces.py | 2 + plugins/modules/nxos_acls.py | 10 +- plugins/modules/nxos_banner.py | 16 +- plugins/modules/nxos_bfd_global.py | 16 +- plugins/modules/nxos_bfd_interfaces.py | 2 + plugins/modules/nxos_bgp.py | 59 ++--- plugins/modules/nxos_bgp_address_family.py | 2 + plugins/modules/nxos_bgp_af.py | 133 +++--------- plugins/modules/nxos_bgp_global.py | 2 + plugins/modules/nxos_bgp_neighbor.py | 46 ++-- .../nxos_bgp_neighbor_address_family.py | 2 + plugins/modules/nxos_bgp_neighbor_af.py | 93 +++----- plugins/modules/nxos_command.py | 12 +- plugins/modules/nxos_config.py | 60 ++---- plugins/modules/nxos_evpn_global.py | 14 +- plugins/modules/nxos_evpn_vni.py | 33 ++- plugins/modules/nxos_facts.py | 16 +- plugins/modules/nxos_feature.py | 19 +- plugins/modules/nxos_file_copy.py | 70 ++---- plugins/modules/nxos_gir.py | 59 ++--- .../modules/nxos_gir_profile_management.py | 16 +- plugins/modules/nxos_hostname.py | 2 + plugins/modules/nxos_hsrp.py | 75 ++----- plugins/modules/nxos_hsrp_interfaces.py | 2 + plugins/modules/nxos_igmp.py | 16 +- plugins/modules/nxos_igmp_interface.py | 83 ++------ plugins/modules/nxos_igmp_snooping.py | 28 +-- plugins/modules/nxos_install_os.py | 32 +-- plugins/modules/nxos_interface.py | 123 +++-------- plugins/modules/nxos_interface_ospf.py | 104 +++------ plugins/modules/nxos_interfaces.py | 2 + plugins/modules/nxos_l2_interface.py | 88 +++----- plugins/modules/nxos_l2_interfaces.py | 2 + plugins/modules/nxos_l3_interface.py | 10 +- plugins/modules/nxos_l3_interfaces.py | 2 + plugins/modules/nxos_lacp.py | 6 +- plugins/modules/nxos_lacp_interfaces.py | 2 + plugins/modules/nxos_lag_interfaces.py | 2 + plugins/modules/nxos_linkagg.py | 111 +++------- plugins/modules/nxos_lldp.py | 8 +- plugins/modules/nxos_lldp_global.py | 2 + plugins/modules/nxos_lldp_interfaces.py | 2 + plugins/modules/nxos_logging.py | 100 +++------ plugins/modules/nxos_logging_global.py | 2 + plugins/modules/nxos_ntp.py | 36 +--- plugins/modules/nxos_ntp_auth.py | 35 +-- plugins/modules/nxos_ntp_global.py | 2 + plugins/modules/nxos_ntp_options.py | 12 +- plugins/modules/nxos_nxapi.py | 44 ++-- plugins/modules/nxos_ospf.py | 21 +- plugins/modules/nxos_ospf_interfaces.py | 2 + plugins/modules/nxos_ospf_vrf.py | 69 ++---- plugins/modules/nxos_ospfv2.py | 2 + plugins/modules/nxos_ospfv3.py | 2 + plugins/modules/nxos_overlay_global.py | 34 ++- plugins/modules/nxos_pim.py | 20 +- plugins/modules/nxos_pim_interface.py | 88 +++----- plugins/modules/nxos_pim_rp_address.py | 24 +-- plugins/modules/nxos_ping.py | 20 +- plugins/modules/nxos_prefix_lists.py | 2 + plugins/modules/nxos_reboot.py | 10 +- plugins/modules/nxos_rollback.py | 8 +- plugins/modules/nxos_route_maps.py | 2 + plugins/modules/nxos_rpm.py | 59 ++--- plugins/modules/nxos_smu.py | 16 +- plugins/modules/nxos_snapshot.py | 28 +-- plugins/modules/nxos_snmp_community.py | 13 +- plugins/modules/nxos_snmp_contact.py | 12 +- plugins/modules/nxos_snmp_host.py | 40 ++-- plugins/modules/nxos_snmp_location.py | 12 +- plugins/modules/nxos_snmp_server.py | 2 + plugins/modules/nxos_snmp_traps.py | 36 +--- plugins/modules/nxos_snmp_user.py | 15 +- plugins/modules/nxos_static_route.py | 41 ++-- plugins/modules/nxos_static_routes.py | 6 +- plugins/modules/nxos_system.py | 19 +- plugins/modules/nxos_telemetry.py | 6 +- plugins/modules/nxos_udld.py | 26 +-- plugins/modules/nxos_udld_interface.py | 32 +-- plugins/modules/nxos_user.py | 31 ++- plugins/modules/nxos_vlan.py | 81 +++---- plugins/modules/nxos_vlans.py | 6 +- plugins/modules/nxos_vpc.py | 31 +-- plugins/modules/nxos_vpc_interface.py | 27 +-- plugins/modules/nxos_vrf.py | 59 ++--- plugins/modules/nxos_vrf_af.py | 50 ++--- plugins/modules/nxos_vrf_interface.py | 29 +-- plugins/modules/nxos_vrrp.py | 28 +-- plugins/modules/nxos_vtp_domain.py | 19 +- plugins/modules/nxos_vtp_password.py | 28 +-- plugins/modules/nxos_vtp_version.py | 23 +- plugins/modules/nxos_vxlan_vtep.py | 66 ++---- plugins/modules/nxos_vxlan_vtep_vni.py | 72 ++----- plugins/modules/storage/nxos_devicealias.py | 95 +++------ plugins/modules/storage/nxos_vsan.py | 63 ++---- plugins/modules/storage/nxos_zone_zoneset.py | 187 ++++------------ plugins/netconf/nxos.py | 5 +- plugins/terminal/nxos.py | 22 +- pyproject.toml | 2 +- tests/unit/compat/builtins.py | 1 + tests/unit/compat/mock.py | 6 +- tests/unit/compat/unittest.py | 2 + tests/unit/mock/loader.py | 3 +- tests/unit/mock/path.py | 8 +- tests/unit/mock/procenv.py | 9 +- tests/unit/mock/vault_helper.py | 6 +- tests/unit/mock/yaml_helper.py | 34 +-- tests/unit/modules/conftest.py | 20 +- .../unit/modules/network/nxos/nxos_module.py | 15 +- .../nxos/storage/test_nxos_devicealias.py | 141 ++++-------- .../network/nxos/storage/test_nxos_vsan.py | 95 +++------ .../nxos/storage/test_nxos_zone_zoneset.py | 158 ++++---------- tests/unit/modules/network/nxos/test_nxos.py | 15 +- .../modules/network/nxos/test_nxos_acl.py | 16 +- .../network/nxos/test_nxos_acl_interface.py | 12 +- .../network/nxos/test_nxos_acl_interfaces.py | 39 +--- .../modules/network/nxos/test_nxos_acls.py | 46 ++-- .../modules/network/nxos/test_nxos_banner.py | 4 +- .../network/nxos/test_nxos_bfd_global.py | 31 ++- .../network/nxos/test_nxos_bfd_interfaces.py | 44 ++-- .../modules/network/nxos/test_nxos_bgp.py | 28 +-- .../nxos/test_nxos_bgp_address_family.py | 113 +++------- .../modules/network/nxos/test_nxos_bgp_af.py | 34 +-- .../network/nxos/test_nxos_bgp_global.py | 29 +-- .../network/nxos/test_nxos_bgp_neighbor.py | 38 +--- .../test_nxos_bgp_neighbor_address_family.py | 119 +++-------- .../network/nxos/test_nxos_bgp_neighbor_af.py | 8 +- .../modules/network/nxos/test_nxos_command.py | 20 +- .../modules/network/nxos/test_nxos_config.py | 57 ++--- .../network/nxos/test_nxos_evpn_global.py | 12 +- .../network/nxos/test_nxos_evpn_vni.py | 12 +- .../modules/network/nxos/test_nxos_feature.py | 20 +- .../network/nxos/test_nxos_hostname.py | 14 +- .../modules/network/nxos/test_nxos_hsrp.py | 4 +- .../network/nxos/test_nxos_hsrp_interfaces.py | 44 ++-- .../network/nxos/test_nxos_interface.py | 23 +- .../network/nxos/test_nxos_interface_ospf.py | 68 ++---- .../network/nxos/test_nxos_interfaces.py | 52 ++--- .../network/nxos/test_nxos_l3_interface.py | 44 ++-- .../network/nxos/test_nxos_l3_interfaces.py | 87 +++----- .../network/nxos/test_nxos_lacp_interfaces.py | 21 +- .../network/nxos/test_nxos_lldp_interfaces.py | 31 +-- .../network/nxos/test_nxos_logging_global.py | 52 ++--- .../network/nxos/test_nxos_ntp_global.py | 29 +-- .../modules/network/nxos/test_nxos_nxapi.py | 8 +- .../modules/network/nxos/test_nxos_ospf.py | 4 +- .../network/nxos/test_nxos_ospf_interfaces.py | 129 +++-------- .../network/nxos/test_nxos_ospf_vrf.py | 4 +- .../modules/network/nxos/test_nxos_ospfv2.py | 59 ++--- .../modules/network/nxos/test_nxos_ospfv3.py | 95 +++------ .../network/nxos/test_nxos_overlay_global.py | 8 +- .../modules/network/nxos/test_nxos_pim.py | 16 +- .../network/nxos/test_nxos_pim_interface.py | 15 +- .../network/nxos/test_nxos_pim_rp_address.py | 16 +- .../modules/network/nxos/test_nxos_ping.py | 33 +-- .../network/nxos/test_nxos_prefix_lists.py | 26 +-- .../network/nxos/test_nxos_route_maps.py | 91 +++----- .../network/nxos/test_nxos_snmp_server.py | 107 +++------- .../network/nxos/test_nxos_static_route.py | 30 +-- .../network/nxos/test_nxos_static_routes.py | 33 +-- .../modules/network/nxos/test_nxos_system.py | 12 +- .../network/nxos/test_nxos_telemetry.py | 167 +++++---------- .../modules/network/nxos/test_nxos_user.py | 13 +- .../modules/network/nxos/test_nxos_vlan.py | 8 +- .../modules/network/nxos/test_nxos_vlans.py | 24 +-- .../modules/network/nxos/test_nxos_vpc.py | 44 ++-- .../network/nxos/test_nxos_vpc_interface.py | 12 +- .../modules/network/nxos/test_nxos_vrf.py | 16 +- .../modules/network/nxos/test_nxos_vrf_af.py | 36 +--- .../network/nxos/test_nxos_vxlan_vtep.py | 12 +- .../network/nxos/test_nxos_vxlan_vtep_vni.py | 16 +- tests/unit/modules/utils.py | 6 +- tox.ini | 4 +- 284 files changed, 3013 insertions(+), 6577 deletions(-) create mode 100644 .isort.cfg create mode 100644 changelogs/fragments/517.yaml diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 000000000..be4904528 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,6 @@ +[settings] +known_first_party=ansible_collections.cisco.nxos +line_length=100 +lines_after_imports=2 +lines_between_types=1 +profile=black diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 356dbb80a..7e5c026a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,11 +36,16 @@ repos: - prettier - prettier-plugin-toml + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + name: Sort import statements using isort + - repo: https://github.com/psf/black rev: 22.3.0 hooks: - id: black - args: [-l, "79"] - repo: https://github.com/ansible-network/collection_prep rev: 1.0.0 diff --git a/changelogs/fragments/517.yaml b/changelogs/fragments/517.yaml new file mode 100644 index 000000000..bfe6c7e97 --- /dev/null +++ b/changelogs/fragments/517.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Add isort to pre-commit, increase black line length diff --git a/plugins/action/nxos.py b/plugins/action/nxos.py index d113c75c9..184f816ae 100644 --- a/plugins/action/nxos.py +++ b/plugins/action/nxos.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type import copy @@ -25,17 +26,17 @@ import sys from ansible import constants as C +from ansible.module_utils.connection import Connection +from ansible.utils.display import Display from ansible_collections.ansible.netcommon.plugins.action.network import ( ActionModule as ActionNetworkModule, ) -from ansible.module_utils.connection import Connection from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( load_provider, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_provider_spec, -) -from ansible.utils.display import Display + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_provider_spec + display = Display() @@ -45,9 +46,7 @@ def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect module_name = self._task.action.split(".")[-1] - self._config_module = ( - True if module_name in ["nxos_config", "config"] else False - ) + self._config_module = True if module_name in ["nxos_config", "config"] else False persistent_connection = self._play_context.connection.split(".")[-1] warnings = [] @@ -58,8 +57,7 @@ def run(self, tmp=None, task_vars=None): ) and module_name in ("nxos_file_copy", "nxos_nxapi"): return { "failed": True, - "msg": "Transport type 'nxapi' is not valid for '%s' module." - % (module_name), + "msg": "Transport type 'nxapi' is not valid for '%s' module." % (module_name), } if module_name == "nxos_file_copy": @@ -79,9 +77,7 @@ def run(self, tmp=None, task_vars=None): connect_ssh_port = self._task.args.get("connect_ssh_port", 22) if file_pull: - conn.set_option( - "persistent_command_timeout", file_pull_timeout - ) + conn.set_option("persistent_command_timeout", file_pull_timeout) conn.set_option("port", connect_ssh_port) if module_name == "nxos_install_os": @@ -90,30 +86,19 @@ def run(self, tmp=None, task_vars=None): persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT else: - persistent_command_timeout = connection.get_option( - "persistent_command_timeout" - ) - persistent_connect_timeout = connection.get_option( - "persistent_connect_timeout" - ) + persistent_command_timeout = connection.get_option("persistent_command_timeout") + persistent_connect_timeout = connection.get_option("persistent_connect_timeout") display.vvvv( - "PERSISTENT_COMMAND_TIMEOUT is %s" - % str(persistent_command_timeout), + "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout), self._play_context.remote_addr, ) display.vvvv( - "PERSISTENT_CONNECT_TIMEOUT is %s" - % str(persistent_connect_timeout), + "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout), self._play_context.remote_addr, ) - if ( - persistent_command_timeout < 600 - or persistent_connect_timeout < 600 - ): - msg = ( - "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT" - ) + if persistent_command_timeout < 600 or persistent_connect_timeout < 600: + msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT" msg += " must be set to 600 seconds or higher when using nxos_install_os module." msg += " Current persistent_command_timeout setting:" + str( persistent_command_timeout @@ -134,16 +119,11 @@ def run(self, tmp=None, task_vars=None): if module_name == "nxos_gir": conn = Connection(self._connection.socket_path) - persistent_command_timeout = conn.get_option( - "persistent_command_timeout" - ) + persistent_command_timeout = conn.get_option("persistent_command_timeout") gir_timeout = 200 if persistent_command_timeout < gir_timeout: conn.set_option("persistent_command_timeout", gir_timeout) - msg = ( - "timeout value extended to %ss for nxos_gir" - % gir_timeout - ) + msg = "timeout value extended to %ss for nxos_gir" % gir_timeout display.warning(msg) elif self._play_context.connection == "local": @@ -159,22 +139,11 @@ def run(self, tmp=None, task_vars=None): pc = copy.deepcopy(self._play_context) pc.connection = "ansible.netcommon.network_cli" pc.network_os = "cisco.nxos.nxos" - pc.remote_addr = ( - provider["host"] or self._play_context.remote_addr - ) - pc.port = int( - provider["port"] or self._play_context.port or 22 - ) - pc.remote_user = ( - provider["username"] or self._play_context.connection_user - ) - pc.password = ( - provider["password"] or self._play_context.password - ) - pc.private_key_file = ( - provider["ssh_keyfile"] - or self._play_context.private_key_file - ) + pc.remote_addr = provider["host"] or self._play_context.remote_addr + pc.port = int(provider["port"] or self._play_context.port or 22) + pc.remote_user = provider["username"] or self._play_context.connection_user + pc.password = provider["password"] or self._play_context.password + pc.private_key_file = provider["ssh_keyfile"] or self._play_context.private_key_file pc.become = provider["authorize"] or False if pc.become: pc.become_method = "enable" @@ -205,9 +174,7 @@ def run(self, tmp=None, task_vars=None): if provider["timeout"] else connection.get_option("persistent_command_timeout") ) - connection.set_options( - direct={"persistent_command_timeout": command_timeout} - ) + connection.set_options(direct={"persistent_command_timeout": command_timeout}) socket_path = connection.run() display.vvvv("socket_path: %s" % socket_path, pc.remote_addr) @@ -221,9 +188,7 @@ def run(self, tmp=None, task_vars=None): task_vars["ansible_socket"] = socket_path else: - self._task.args[ - "provider" - ] = ActionModule.nxapi_implementation( + self._task.args["provider"] = ActionModule.nxapi_implementation( provider, self._play_context ) warnings.append( diff --git a/plugins/cliconf/nxos.py b/plugins/cliconf/nxos.py index ace8267fc..758cc41ab 100644 --- a/plugins/cliconf/nxos.py +++ b/plugins/cliconf/nxos.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -54,9 +55,7 @@ NetworkConfig, dumps, ) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list from ansible_collections.ansible.netcommon.plugins.plugin_utils.cliconf_base import ( CliconfBase, enable_mode, @@ -88,42 +87,28 @@ def get_device_info(self): reply = self.get("show version") platform_reply = self.get("show inventory") - match_sys_ver = re.search( - r"\s+system:\s+version\s*(\S+)", reply, re.M - ) + match_sys_ver = re.search(r"\s+system:\s+version\s*(\S+)", reply, re.M) if match_sys_ver: device_info["network_os_version"] = match_sys_ver.group(1) else: - match_kick_ver = re.search( - r"\s+kickstart:\s+version\s*(\S+)", reply, re.M - ) + match_kick_ver = re.search(r"\s+kickstart:\s+version\s*(\S+)", reply, re.M) if match_kick_ver: device_info["network_os_version"] = match_kick_ver.group(1) if "network_os_version" not in device_info: - match_sys_ver = re.search( - r"\s+NXOS:\s+version\s*(\S+)", reply, re.M - ) + match_sys_ver = re.search(r"\s+NXOS:\s+version\s*(\S+)", reply, re.M) if match_sys_ver: device_info["network_os_version"] = match_sys_ver.group(1) - match_chassis_id = re.search( - r"Hardware\n\s+cisco(.+)$", reply, re.M - ) + match_chassis_id = re.search(r"Hardware\n\s+cisco(.+)$", reply, re.M) if match_chassis_id: - device_info["network_os_model"] = match_chassis_id.group( - 1 - ).strip() + device_info["network_os_model"] = match_chassis_id.group(1).strip() - match_host_name = re.search( - r"\s+Device name:\s*(\S+)", reply, re.M - ) + match_host_name = re.search(r"\s+Device name:\s*(\S+)", reply, re.M) if match_host_name: device_info["network_os_hostname"] = match_host_name.group(1) - match_isan_file_name = re.search( - r"\s+system image file is:\s*(\S+)", reply, re.M - ) + match_isan_file_name = re.search(r"\s+system image file is:\s*(\S+)", reply, re.M) if match_isan_file_name: device_info["network_os_image"] = match_isan_file_name.group(1) else: @@ -131,18 +116,12 @@ def get_device_info(self): r"\s+kickstart image file is:\s*(\S+)", reply, re.M ) if match_kick_file_name: - device_info[ - "network_os_image" - ] = match_kick_file_name.group(1) + device_info["network_os_image"] = match_kick_file_name.group(1) if "network_os_image" not in device_info: - match_isan_file_name = re.search( - r"\s+NXOS image file is:\s*(\S+)", reply, re.M - ) + match_isan_file_name = re.search(r"\s+NXOS image file is:\s*(\S+)", reply, re.M) if match_isan_file_name: - device_info[ - "network_os_image" - ] = match_isan_file_name.group(1) + device_info["network_os_image"] = match_isan_file_name.group(1) match_os_platform = re.search( r'NAME: "Chassis",\s*DESCR:.*\n' r"PID:\s*(\S+)", @@ -170,9 +149,7 @@ def get_diff( option_values = self.get_option_values() if candidate is None and device_operations["supports_generate_diff"]: - raise ValueError( - "candidate configuration is required to generate diff" - ) + raise ValueError("candidate configuration is required to generate diff") if diff_match not in option_values["diff_match"]: raise ValueError( @@ -192,9 +169,7 @@ def get_diff( if running and diff_match != "none" and diff_replace != "config": # running configuration - running_obj = NetworkConfig( - indent=2, contents=running, ignore_lines=diff_ignore_lines - ) + running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) configdiffobjs = candidate_obj.difference( running_obj, path=path, match=diff_match, replace=diff_replace ) @@ -202,9 +177,7 @@ def get_diff( else: configdiffobjs = candidate_obj.items - diff["config_diff"] = ( - dumps(configdiffobjs, "commands") if configdiffobjs else "" - ) + diff["config_diff"] = dumps(configdiffobjs, "commands") if configdiffobjs else "" return diff def get_config(self, source="running", format="text", flags=None): @@ -217,9 +190,7 @@ def get_config(self, source="running", format="text", flags=None): lookup = {"running": "running-config", "startup": "startup-config"} if source not in lookup: - raise ValueError( - "fetching configuration from %s is not supported" % source - ) + raise ValueError("fetching configuration from %s is not supported" % source) cmd = "show {0} ".format(lookup[source]) if format and format != "text": @@ -231,14 +202,10 @@ def get_config(self, source="running", format="text", flags=None): return self.send_command(cmd) - def edit_config( - self, candidate=None, commit=True, replace=None, comment=None - ): + def edit_config(self, candidate=None, commit=True, replace=None, comment=None): resp = {} operations = self.get_device_operations() - self.check_edit_config_capability( - operations, candidate, commit, replace, comment - ) + self.check_edit_config_capability(operations, candidate, commit, replace, comment) results = [] requests = [] @@ -300,9 +267,7 @@ def run_commands(self, commands=None, check_rc=True): output = cmd.pop("output", None) if output: - cmd["command"] = self._get_command_with_output( - cmd["command"], output - ) + cmd["command"] = self._get_command_with_output(cmd["command"], output) try: out = self.send_command(**cmd) @@ -316,8 +281,7 @@ def run_commands(self, commands=None, check_rc=True): out = to_text(out, errors="surrogate_or_strict").strip() except UnicodeError: raise ConnectionError( - message="Failed to decode output from %s: %s" - % (cmd, to_text(out)) + message="Failed to decode output from %s: %s" % (cmd, to_text(out)) ) try: @@ -370,15 +334,11 @@ def pull_file(self, command, remotepassword=None): re.compile(rb"(?i)Could not resolve hostname"), re.compile(rb"(?i)Too many authentication failures"), re.compile(rb"Access Denied"), - re.compile( - rb"(?i)Copying to\/from this server name is not permitted" - ), + re.compile(rb"(?i)Copying to\/from this server name is not permitted"), ] # set error regex for copy command - current_stderr_re = self._connection._get_terminal_std_re( - "terminal_stderr_re" - ) + current_stderr_re = self._connection._get_terminal_std_re("terminal_stderr_re") current_stderr_re.extend(possible_errors_re) # do not change the ordering of this list @@ -390,9 +350,7 @@ def pull_file(self, command, remotepassword=None): # set stdout regex for copy command to handle optional user prompts # based on different match conditions - current_stdout_re = self._connection._get_terminal_std_re( - "terminal_stdout_re" - ) + current_stdout_re = self._connection._get_terminal_std_re("terminal_stdout_re") current_stdout_re.extend(possible_prompts_re) retry = 1 @@ -407,14 +365,10 @@ def pull_file(self, command, remotepassword=None): output = self.send_command(command="y", strip_prompt=False) if possible_prompts_re[1].search(to_bytes(output)): - output = self.send_command( - command="yes", strip_prompt=False - ) + output = self.send_command(command="yes", strip_prompt=False) if possible_prompts_re[2].search(to_bytes(output)): - output = self.send_command( - command=remotepassword, strip_prompt=False - ) + output = self.send_command(command=remotepassword, strip_prompt=False) if "Copy complete" in output: file_pulled = True return file_pulled @@ -440,12 +394,8 @@ def set_cli_prompt_context(self): # Match prompts ending in )# except those with (maint-mode)# config_prompt = re.compile(r"^.*\((?!maint-mode).*\)#$") - while config_prompt.match( - to_text(out, errors="surrogate_then_replace").strip() - ): - self._connection.queue_message( - "vvvv", "wrong context, sending exit to device" - ) + while config_prompt.match(to_text(out, errors="surrogate_then_replace").strip()): + self._connection.queue_message("vvvv", "wrong context, sending exit to device") self._connection.send_command("exit") out = self._connection.get_prompt() diff --git a/plugins/doc_fragments/nxos.py b/plugins/doc_fragments/nxos.py index 1cda905da..fde64c59f 100644 --- a/plugins/doc_fragments/nxos.py +++ b/plugins/doc_fragments/nxos.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # Copyright: (c) 2015, Peter Sprygada diff --git a/plugins/httpapi/nxos.py b/plugins/httpapi/nxos.py index be56a80ea..19b623d17 100644 --- a/plugins/httpapi/nxos.py +++ b/plugins/httpapi/nxos.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -15,18 +16,14 @@ version_added: 1.0.0 """ +import collections import json import re -import collections from ansible.module_utils._text import to_text from ansible.module_utils.connection import ConnectionError -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, -) -from ansible_collections.ansible.netcommon.plugins.plugin_utils.httpapi_base import ( - HttpApiBase, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list +from ansible_collections.ansible.netcommon.plugins.plugin_utils.httpapi_base import HttpApiBase OPTIONS = { @@ -105,9 +102,7 @@ def _run_queue(self, queue, output): response_data = json.loads(to_text(response_data.getvalue())) except ValueError: raise ConnectionError( - "Response was not valid JSON, got {0}".format( - to_text(response_data.getvalue()) - ) + "Response was not valid JSON, got {0}".format(to_text(response_data.getvalue())) ) results = handle_response(response_data) @@ -120,9 +115,7 @@ def get_device_info(self): device_info = {} device_info["network_os"] = "nxos" - reply, platform_reply = self.send_request( - ["show version", "show inventory"] - ) + reply, platform_reply = self.send_request(["show version", "show inventory"]) find_os_version = [ r"\s+system:\s+version\s*(\S+)", @@ -135,9 +128,7 @@ def get_device_info(self): device_info["network_os_version"] = match_ver.group(1) break - match_chassis_id = re.search( - r"Hardware\n\s+cisco\s*(\S+\s+\S+)", reply, re.M - ) + match_chassis_id = re.search(r"Hardware\n\s+cisco\s*(\S+\s+\S+)", reply, re.M) if match_chassis_id: device_info["network_os_model"] = match_chassis_id.group(1) diff --git a/plugins/module_utils/network/nxos/argspec/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/argspec/acl_interfaces/acl_interfaces.py index 64a9e7aa6..ad2d59d33 100644 --- a/plugins/module_utils/network/nxos/argspec/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/acl_interfaces/acl_interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/acls/acls.py b/plugins/module_utils/network/nxos/argspec/acls/acls.py index 28dfa6b0e..1c1b2d49a 100644 --- a/plugins/module_utils/network/nxos/argspec/acls/acls.py +++ b/plugins/module_utils/network/nxos/argspec/acls/acls.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -75,13 +76,9 @@ class AclsArgs(object): # pylint: disable=R0903 "range": { "options": { "end": {"type": "str"}, - "start": { - "type": "str" - }, + "start": {"type": "str"}, }, - "required_together": [ - ["start", "end"] - ], + "required_together": [["start", "end"]], "type": "dict", }, }, @@ -90,9 +87,7 @@ class AclsArgs(object): # pylint: disable=R0903 "prefix": {"type": "str"}, "wildcard_bits": {"type": "str"}, }, - "required_together": [ - ["address", "wildcard_bits"] - ], + "required_together": [["address", "wildcard_bits"]], "type": "dict", }, "dscp": {"type": "str"}, @@ -105,143 +100,57 @@ class AclsArgs(object): # pylint: disable=R0903 "precedence": {"type": "str"}, "protocol": {"type": "str"}, "protocol_options": { - "mutually_exclusive": [ - ["icmp", "igmp", "tcp"] - ], + "mutually_exclusive": [["icmp", "igmp", "tcp"]], "options": { "icmp": { "options": { - "administratively_prohibited": { - "type": "bool" - }, - "alternate_address": { - "type": "bool" - }, - "conversion_error": { - "type": "bool" - }, - "dod_host_prohibited": { - "type": "bool" - }, - "dod_net_prohibited": { - "type": "bool" - }, + "administratively_prohibited": {"type": "bool"}, + "alternate_address": {"type": "bool"}, + "conversion_error": {"type": "bool"}, + "dod_host_prohibited": {"type": "bool"}, + "dod_net_prohibited": {"type": "bool"}, "echo": {"type": "bool"}, "echo_reply": {"type": "bool"}, - "echo_request": { - "type": "bool" - }, - "general_parameter_problem": { - "type": "bool" - }, - "host_isolated": { - "type": "bool" - }, - "host_precedence_unreachable": { - "type": "bool" - }, - "host_redirect": { - "type": "bool" - }, - "host_tos_redirect": { - "type": "bool" - }, - "host_tos_unreachable": { - "type": "bool" - }, - "host_unknown": { - "type": "bool" - }, - "host_unreachable": { - "type": "bool" - }, - "information_reply": { - "type": "bool" - }, - "information_request": { - "type": "bool" - }, + "echo_request": {"type": "bool"}, + "general_parameter_problem": {"type": "bool"}, + "host_isolated": {"type": "bool"}, + "host_precedence_unreachable": {"type": "bool"}, + "host_redirect": {"type": "bool"}, + "host_tos_redirect": {"type": "bool"}, + "host_tos_unreachable": {"type": "bool"}, + "host_unknown": {"type": "bool"}, + "host_unreachable": {"type": "bool"}, + "information_reply": {"type": "bool"}, + "information_request": {"type": "bool"}, "mask_reply": {"type": "bool"}, - "mask_request": { - "type": "bool" - }, - "message_code": { - "type": "int" - }, - "message_type": { - "type": "int" - }, - "mobile_redirect": { - "type": "bool" - }, - "net_redirect": { - "type": "bool" - }, - "net_tos_redirect": { - "type": "bool" - }, - "net_tos_unreachable": { - "type": "bool" - }, - "net_unreachable": { - "type": "bool" - }, - "network_unknown": { - "type": "bool" - }, - "no_room_for_option": { - "type": "bool" - }, - "option_missing": { - "type": "bool" - }, - "packet_too_big": { - "type": "bool" - }, - "parameter_problem": { - "type": "bool" - }, - "port_unreachable": { - "type": "bool" - }, - "precedence_unreachable": { - "type": "bool" - }, - "protocol_unreachable": { - "type": "bool" - }, - "reassembly_timeout": { - "type": "bool" - }, + "mask_request": {"type": "bool"}, + "message_code": {"type": "int"}, + "message_type": {"type": "int"}, + "mobile_redirect": {"type": "bool"}, + "net_redirect": {"type": "bool"}, + "net_tos_redirect": {"type": "bool"}, + "net_tos_unreachable": {"type": "bool"}, + "net_unreachable": {"type": "bool"}, + "network_unknown": {"type": "bool"}, + "no_room_for_option": {"type": "bool"}, + "option_missing": {"type": "bool"}, + "packet_too_big": {"type": "bool"}, + "parameter_problem": {"type": "bool"}, + "port_unreachable": {"type": "bool"}, + "precedence_unreachable": {"type": "bool"}, + "protocol_unreachable": {"type": "bool"}, + "reassembly_timeout": {"type": "bool"}, "redirect": {"type": "bool"}, - "router_advertisement": { - "type": "bool" - }, - "router_solicitation": { - "type": "bool" - }, - "source_quench": { - "type": "bool" - }, - "source_route_failed": { - "type": "bool" - }, - "time_exceeded": { - "type": "bool" - }, - "timestamp_reply": { - "type": "bool" - }, - "timestamp_request": { - "type": "bool" - }, + "router_advertisement": {"type": "bool"}, + "router_solicitation": {"type": "bool"}, + "source_quench": {"type": "bool"}, + "source_route_failed": {"type": "bool"}, + "time_exceeded": {"type": "bool"}, + "timestamp_reply": {"type": "bool"}, + "timestamp_request": {"type": "bool"}, "traceroute": {"type": "bool"}, - "ttl_exceeded": { - "type": "bool" - }, - "unreachable": { - "type": "bool" - }, + "ttl_exceeded": {"type": "bool"}, + "unreachable": {"type": "bool"}, }, "type": "dict", }, @@ -256,18 +165,14 @@ class AclsArgs(object): # pylint: disable=R0903 "options": { "dvmrp": {"type": "bool"}, "host_query": {"type": "bool"}, - "host_report": { - "type": "bool" - }, + "host_report": {"type": "bool"}, }, "type": "dict", }, "tcp": { "options": { "ack": {"type": "bool"}, - "established": { - "type": "bool" - }, + "established": {"type": "bool"}, "fin": {"type": "bool"}, "psh": {"type": "bool"}, "rst": {"type": "bool"}, @@ -308,9 +213,7 @@ class AclsArgs(object): # pylint: disable=R0903 "range": { "options": { "end": {"type": "str"}, - "start": { - "type": "str" - }, + "start": {"type": "str"}, }, "type": "dict", }, @@ -320,9 +223,7 @@ class AclsArgs(object): # pylint: disable=R0903 "prefix": {"type": "str"}, "wildcard_bits": {"type": "str"}, }, - "required_together": [ - ["address", "wildcard_bits"] - ], + "required_together": [["address", "wildcard_bits"]], "type": "dict", }, }, diff --git a/plugins/module_utils/network/nxos/argspec/bfd_interfaces/bfd_interfaces.py b/plugins/module_utils/network/nxos/argspec/bfd_interfaces/bfd_interfaces.py index dcc0b2dbe..6c47d2e57 100644 --- a/plugins/module_utils/network/nxos/argspec/bfd_interfaces/bfd_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/bfd_interfaces/bfd_interfaces.py @@ -23,6 +23,7 @@ ############################################# from __future__ import absolute_import, division, print_function + __metaclass__ = type """ diff --git a/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py index f5feb90a1..10c9ddec6 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -134,27 +135,19 @@ class Bgp_address_familyArgs(object): # pylint: disable=R0903 "parallel_paths": {"type": "int"}, "ibgp": { "type": "dict", - "options": { - "parallel_paths": {"type": "int"} - }, + "options": {"parallel_paths": {"type": "int"}}, }, "eibgp": { "type": "dict", - "options": { - "parallel_paths": {"type": "int"} - }, + "options": {"parallel_paths": {"type": "int"}}, }, "local": { "type": "dict", - "options": { - "parallel_paths": {"type": "int"} - }, + "options": {"parallel_paths": {"type": "int"}}, }, "mixed": { "type": "dict", - "options": { - "parallel_paths": {"type": "int"} - }, + "options": {"parallel_paths": {"type": "int"}}, }, }, }, diff --git a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py index c3519a2be..f476512f9 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -143,9 +144,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "tx_interval": {"type": "int"}, - "min_rx_interval": { - "type": "int" - }, + "min_rx_interval": {"type": "int"}, "multiplier": {"type": "int"}, }, }, @@ -160,9 +159,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "bmp_activate_server": {"type": "int"}, "capability": { "type": "dict", - "options": { - "suppress_4_byte_as": {"type": "bool"} - }, + "options": {"suppress_4_byte_as": {"type": "bool"}}, }, "description": {"type": "str"}, "disable_connected_check": {"type": "bool"}, @@ -276,9 +273,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "nexthop": { "type": "dict", - "options": { - "suppress_default_resolution": {"type": "bool"} - }, + "options": {"suppress_default_resolution": {"type": "bool"}}, }, "rd": { "type": "dict", @@ -383,15 +378,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "interval": { "type": "dict", "options": { - "tx_interval": { - "type": "int" - }, - "min_rx_interval": { - "type": "int" - }, - "multiplier": { - "type": "int" - }, + "tx_interval": {"type": "int"}, + "min_rx_interval": {"type": "int"}, + "multiplier": {"type": "int"}, }, }, }, @@ -405,9 +394,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "bmp_activate_server": {"type": "int"}, "capability": { "type": "dict", - "options": { - "suppress_4_byte_as": {"type": "bool"} - }, + "options": {"suppress_4_byte_as": {"type": "bool"}}, }, "description": {"type": "str"}, "disable_connected_check": {"type": "bool"}, @@ -504,9 +491,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "connection_mode": { "type": "dict", - "options": { - "passive": {"type": "bool"} - }, + "options": {"passive": {"type": "bool"}}, } }, }, diff --git a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 48515536a..4dcffe7b9 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -136,9 +137,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "max_prefix_limit": {"type": "int"}, - "generate_warning_threshold": { - "type": "int" - }, + "generate_warning_threshold": {"type": "int"}, "restart_interval": {"type": "int"}, "warning_only": {"type": "bool"}, }, @@ -243,21 +242,15 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "required": True, }, "exist_map": {"type": "str"}, - "non_exist_map": { - "type": "str" - }, + "non_exist_map": {"type": "str"}, }, }, - "advertisement_interval": { - "type": "int" - }, + "advertisement_interval": {"type": "int"}, "allowas_in": { "type": "dict", "options": { "set": {"type": "bool"}, - "max_occurences": { - "type": "int" - }, + "max_occurences": {"type": "int"}, }, }, "as_override": {"type": "bool"}, @@ -292,9 +285,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "route_map": {"type": "str"}, }, }, - "disable_peer_as_check": { - "type": "bool" - }, + "disable_peer_as_check": {"type": "bool"}, "filter_list": { "type": "dict", "options": { @@ -312,18 +303,10 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "maximum_prefix": { "type": "dict", "options": { - "max_prefix_limit": { - "type": "int" - }, - "generate_warning_threshold": { - "type": "int" - }, - "restart_interval": { - "type": "int" - }, - "warning_only": { - "type": "bool" - }, + "max_prefix_limit": {"type": "int"}, + "generate_warning_threshold": {"type": "int"}, + "restart_interval": {"type": "int"}, + "warning_only": {"type": "bool"}, }, }, "next_hop_self": { @@ -333,9 +316,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "all_routes": {"type": "bool"}, }, }, - "next_hop_third_party": { - "type": "bool" - }, + "next_hop_third_party": {"type": "bool"}, "prefix_list": { "type": "dict", "options": { @@ -343,9 +324,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "outbound": {"type": "str"}, }, }, - "rewrite_evpn_rt_asn": { - "type": "bool" - }, + "rewrite_evpn_rt_asn": {"type": "bool"}, "route_map": { "type": "dict", "options": { @@ -353,9 +332,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "outbound": {"type": "str"}, }, }, - "route_reflector_client": { - "type": "bool" - }, + "route_reflector_client": {"type": "bool"}, "send_community": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/argspec/facts/facts.py b/plugins/module_utils/network/nxos/argspec/facts/facts.py index f2b716c40..ae12a8d60 100644 --- a/plugins/module_utils/network/nxos/argspec/facts/facts.py +++ b/plugins/module_utils/network/nxos/argspec/facts/facts.py @@ -5,6 +5,7 @@ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type """ The arg spec for the nxos facts module. diff --git a/plugins/module_utils/network/nxos/argspec/hostname/hostname.py b/plugins/module_utils/network/nxos/argspec/hostname/hostname.py index 9327e0471..3a7120719 100644 --- a/plugins/module_utils/network/nxos/argspec/hostname/hostname.py +++ b/plugins/module_utils/network/nxos/argspec/hostname/hostname.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/nxos/argspec/hsrp_interfaces/hsrp_interfaces.py b/plugins/module_utils/network/nxos/argspec/hsrp_interfaces/hsrp_interfaces.py index 436348ed0..ac3026367 100644 --- a/plugins/module_utils/network/nxos/argspec/hsrp_interfaces/hsrp_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/hsrp_interfaces/hsrp_interfaces.py @@ -23,6 +23,7 @@ ############################################# from __future__ import absolute_import, division, print_function + __metaclass__ = type """ diff --git a/plugins/module_utils/network/nxos/argspec/interfaces/interfaces.py b/plugins/module_utils/network/nxos/argspec/interfaces/interfaces.py index d7104c922..ba8d7923d 100644 --- a/plugins/module_utils/network/nxos/argspec/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/interfaces/interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py index 81f9b8214..4e9aaf10f 100644 --- a/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py index cccc0b748..038e16d96 100644 --- a/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/lacp/lacp.py b/plugins/module_utils/network/nxos/argspec/lacp/lacp.py index 48e6b9ce3..f5965aaa9 100644 --- a/plugins/module_utils/network/nxos/argspec/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/argspec/lacp/lacp.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/lacp_interfaces/lacp_interfaces.py b/plugins/module_utils/network/nxos/argspec/lacp_interfaces/lacp_interfaces.py index cc74faaa5..119432bf7 100644 --- a/plugins/module_utils/network/nxos/argspec/lacp_interfaces/lacp_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/lacp_interfaces/lacp_interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/argspec/lag_interfaces/lag_interfaces.py index 8a2f86618..12330b84f 100644 --- a/plugins/module_utils/network/nxos/argspec/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/lag_interfaces/lag_interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py b/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py index f2e885855..8fad5eba7 100644 --- a/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/nxos/argspec/lldp_interfaces/lldp_interfaces.py index 7f4db6d30..0552901ef 100644 --- a/plugins/module_utils/network/nxos/argspec/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/lldp_interfaces/lldp_interfaces.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py b/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py index 2c8cd71e4..340374458 100644 --- a/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -245,9 +246,7 @@ class Logging_globalArgs(object): # pylint: disable=R0903 "options": { "trustpoint": { "type": "dict", - "options": { - "client_identity": {"type": "str"} - }, + "options": {"client_identity": {"type": "str"}}, } }, }, diff --git a/plugins/module_utils/network/nxos/argspec/ntp_global/ntp_global.py b/plugins/module_utils/network/nxos/argspec/ntp_global/ntp_global.py index 89f160625..a680e58d6 100644 --- a/plugins/module_utils/network/nxos/argspec/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/nxos/argspec/ntp_global/ntp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/nxos/argspec/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/argspec/ospf_interfaces/ospf_interfaces.py index 1be1c77b7..30d65035f 100644 --- a/plugins/module_utils/network/nxos/argspec/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/ospf_interfaces/ospf_interfaces.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -40,9 +41,7 @@ class Ospf_interfacesArgs(object): # pylint: disable=R0903 "address_family": { "type": "list", "elements": "dict", - "mutually_exclusive": [ - ["passive_interface", "default_passive_interface"] - ], + "mutually_exclusive": [["passive_interface", "default_passive_interface"]], "options": { "afi": { "type": "str", diff --git a/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py b/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py index ae34b122f..d03320b01 100644 --- a/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py @@ -24,6 +24,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -80,28 +81,18 @@ class Ospfv2Args(object): # pylint: disable=R0903 }, "nssa": { "options": { - "default_information_originate": { - "type": "bool" - }, + "default_information_originate": {"type": "bool"}, "no_redistribution": {"type": "bool"}, "no_summary": {"type": "bool"}, "set": {"type": "bool"}, "translate": { "options": { "type7": { - "mutually_exclusive": [ - ["always", "never"] - ], + "mutually_exclusive": [["always", "never"]], "options": { - "always": { - "type": "bool" - }, - "never": { - "type": "bool" - }, - "supress_fa": { - "type": "bool" - }, + "always": {"type": "bool"}, + "never": {"type": "bool"}, + "supress_fa": {"type": "bool"}, }, "type": "dict", } @@ -200,9 +191,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "options": { "external_lsa": { "options": { - "max_metric_value": { - "type": "int" - }, + "max_metric_value": {"type": "int"}, "set": {"type": "bool"}, }, "type": "dict", @@ -211,9 +200,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "on_startup": { "options": { "set": {"type": "bool"}, - "wait_for_bgp_asn": { - "type": "int" - }, + "wait_for_bgp_asn": {"type": "int"}, "wait_period": {"type": "int"}, }, "type": "dict", @@ -221,9 +208,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "set": {"type": "bool"}, "summary_lsa": { "options": { - "max_metric_value": { - "type": "int" - }, + "max_metric_value": {"type": "int"}, "set": {"type": "bool"}, }, "type": "dict", @@ -242,9 +227,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "areas": { "type": "list", "elements": "dict", - "options": { - "area_id": {"type": "str"} - }, + "options": {"area_id": {"type": "str"}}, }, "multicast_intact": {"type": "bool"}, "router_id": {"type": "str"}, @@ -310,29 +293,17 @@ class Ospfv2Args(object): # pylint: disable=R0903 "options": { "lsa": { "options": { - "hold_interval": { - "type": "int" - }, - "max_interval": { - "type": "int" - }, - "start_interval": { - "type": "int" - }, + "hold_interval": {"type": "int"}, + "max_interval": {"type": "int"}, + "start_interval": {"type": "int"}, }, "type": "dict", }, "spf": { "options": { - "initial_spf_delay": { - "type": "int" - }, - "max_wait_time": { - "type": "int" - }, - "min_hold_time": { - "type": "int" - }, + "initial_spf_delay": {"type": "int"}, + "max_wait_time": {"type": "int"}, + "min_hold_time": {"type": "int"}, }, "type": "dict", }, @@ -365,9 +336,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "authentication": { "options": { "set": {"type": "bool"}, - "message_digest": { - "type": "bool" - }, + "message_digest": {"type": "bool"}, }, "type": "dict", }, @@ -389,12 +358,8 @@ class Ospfv2Args(object): # pylint: disable=R0903 }, "nssa": { "options": { - "default_information_originate": { - "type": "bool" - }, - "no_redistribution": { - "type": "bool" - }, + "default_information_originate": {"type": "bool"}, + "no_redistribution": {"type": "bool"}, "no_summary": {"type": "bool"}, "set": {"type": "bool"}, "translate": { @@ -407,15 +372,9 @@ class Ospfv2Args(object): # pylint: disable=R0903 ] ], "options": { - "always": { - "type": "bool" - }, - "never": { - "type": "bool" - }, - "supress_fa": { - "type": "bool" - }, + "always": {"type": "bool"}, + "never": {"type": "bool"}, + "supress_fa": {"type": "bool"}, }, "type": "dict", } @@ -429,9 +388,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "elements": "dict", "options": { "cost": {"type": "int"}, - "not_advertise": { - "type": "bool" - }, + "not_advertise": {"type": "bool"}, "prefix": { "type": "str", "required": True, @@ -527,41 +484,25 @@ class Ospfv2Args(object): # pylint: disable=R0903 "options": { "external_lsa": { "options": { - "max_metric_value": { - "type": "int" - }, - "set": { - "type": "bool" - }, + "max_metric_value": {"type": "int"}, + "set": {"type": "bool"}, }, "type": "dict", }, - "include_stub": { - "type": "bool" - }, + "include_stub": {"type": "bool"}, "on_startup": { "options": { - "set": { - "type": "bool" - }, - "wait_for_bgp_asn": { - "type": "int" - }, - "wait_period": { - "type": "int" - }, + "set": {"type": "bool"}, + "wait_for_bgp_asn": {"type": "int"}, + "wait_period": {"type": "int"}, }, "type": "dict", }, "set": {"type": "bool"}, "summary_lsa": { "options": { - "max_metric_value": { - "type": "int" - }, - "set": { - "type": "bool" - }, + "max_metric_value": {"type": "int"}, + "set": {"type": "bool"}, }, "type": "dict", }, @@ -635,29 +576,17 @@ class Ospfv2Args(object): # pylint: disable=R0903 "options": { "lsa": { "options": { - "hold_interval": { - "type": "int" - }, - "max_interval": { - "type": "int" - }, - "start_interval": { - "type": "int" - }, + "hold_interval": {"type": "int"}, + "max_interval": {"type": "int"}, + "start_interval": {"type": "int"}, }, "type": "dict", }, "spf": { "options": { - "initial_spf_delay": { - "type": "int" - }, - "max_wait_time": { - "type": "int" - }, - "min_hold_time": { - "type": "int" - }, + "initial_spf_delay": {"type": "int"}, + "max_wait_time": {"type": "int"}, + "min_hold_time": {"type": "int"}, }, "type": "dict", }, diff --git a/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py index 1dcc07829..ba9f19d2d 100644 --- a/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -83,9 +84,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "required": True, }, "cost": {"type": "int"}, - "not_advertise": { - "type": "bool" - }, + "not_advertise": {"type": "bool"}, }, }, }, @@ -161,15 +160,9 @@ class Ospfv3Args(object): # pylint: disable=R0903 "spf": { "type": "dict", "options": { - "initial_spf_delay": { - "type": "int" - }, - "min_hold_time": { - "type": "int" - }, - "max_wait_time": { - "type": "int" - }, + "initial_spf_delay": {"type": "int"}, + "min_hold_time": {"type": "int"}, + "max_wait_time": {"type": "int"}, }, } }, @@ -187,9 +180,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - "default_information_originate": { - "type": "bool" - }, + "default_information_originate": {"type": "bool"}, "no_redistribution": {"type": "bool"}, "no_summary": {"type": "bool"}, "route_map": {"type": "str"}, @@ -199,15 +190,9 @@ class Ospfv3Args(object): # pylint: disable=R0903 "type7": { "type": "dict", "options": { - "always": { - "type": "bool" - }, - "never": { - "type": "bool" - }, - "supress_fa": { - "type": "bool" - }, + "always": {"type": "bool"}, + "never": {"type": "bool"}, + "supress_fa": {"type": "bool"}, }, } }, @@ -280,9 +265,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - "max_metric_value": { - "type": "int" - }, + "max_metric_value": {"type": "int"}, }, }, "stub_prefix_lsa": {"type": "bool"}, @@ -291,18 +274,14 @@ class Ospfv3Args(object): # pylint: disable=R0903 "options": { "set": {"type": "bool"}, "wait_period": {"type": "int"}, - "wait_for_bgp_asn": { - "type": "int" - }, + "wait_for_bgp_asn": {"type": "int"}, }, }, "inter_area_prefix_lsa": { "type": "dict", "options": { "set": {"type": "bool"}, - "max_metric_value": { - "type": "int" - }, + "max_metric_value": {"type": "int"}, }, }, }, @@ -328,15 +307,9 @@ class Ospfv3Args(object): # pylint: disable=R0903 "lsa": { "type": "dict", "options": { - "start_interval": { - "type": "int" - }, - "hold_interval": { - "type": "int" - }, - "max_interval": { - "type": "int" - }, + "start_interval": {"type": "int"}, + "hold_interval": {"type": "int"}, + "max_interval": {"type": "int"}, }, } }, @@ -359,12 +332,8 @@ class Ospfv3Args(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - "default_information_originate": { - "type": "bool" - }, - "no_redistribution": { - "type": "bool" - }, + "default_information_originate": {"type": "bool"}, + "no_redistribution": {"type": "bool"}, "no_summary": {"type": "bool"}, "route_map": {"type": "str"}, "translate": { @@ -373,15 +342,9 @@ class Ospfv3Args(object): # pylint: disable=R0903 "type7": { "type": "dict", "options": { - "always": { - "type": "bool" - }, - "never": { - "type": "bool" - }, - "supress_fa": { - "type": "bool" - }, + "always": {"type": "bool"}, + "never": {"type": "bool"}, + "supress_fa": {"type": "bool"}, }, } }, @@ -451,40 +414,24 @@ class Ospfv3Args(object): # pylint: disable=R0903 "external_lsa": { "type": "dict", "options": { - "set": { - "type": "bool" - }, - "max_metric_value": { - "type": "int" - }, + "set": {"type": "bool"}, + "max_metric_value": {"type": "int"}, }, }, - "stub_prefix_lsa": { - "type": "bool" - }, + "stub_prefix_lsa": {"type": "bool"}, "on_startup": { "type": "dict", "options": { - "set": { - "type": "bool" - }, - "wait_period": { - "type": "int" - }, - "wait_for_bgp_asn": { - "type": "int" - }, + "set": {"type": "bool"}, + "wait_period": {"type": "int"}, + "wait_for_bgp_asn": {"type": "int"}, }, }, "inter_area_prefix_lsa": { "type": "dict", "options": { - "set": { - "type": "bool" - }, - "max_metric_value": { - "type": "int" - }, + "set": {"type": "bool"}, + "max_metric_value": {"type": "int"}, }, }, }, @@ -509,15 +456,9 @@ class Ospfv3Args(object): # pylint: disable=R0903 "lsa": { "type": "dict", "options": { - "start_interval": { - "type": "int" - }, - "hold_interval": { - "type": "int" - }, - "max_interval": { - "type": "int" - }, + "start_interval": {"type": "int"}, + "hold_interval": {"type": "int"}, + "max_interval": {"type": "int"}, }, } }, diff --git a/plugins/module_utils/network/nxos/argspec/prefix_lists/prefix_lists.py b/plugins/module_utils/network/nxos/argspec/prefix_lists/prefix_lists.py index 396f38616..c29e03757 100644 --- a/plugins/module_utils/network/nxos/argspec/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/nxos/argspec/prefix_lists/prefix_lists.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py index 0602a9897..5b28c49c6 100644 --- a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -117,29 +118,19 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "source": {"type": "str"}, "group": { "type": "dict", - "options": { - "prefix": { - "type": "str" - } - }, + "options": {"prefix": {"type": "str"}}, }, "group_range": { "type": "dict", "options": { - "first": { - "type": "str" - }, - "last": { - "type": "str" - }, + "first": {"type": "str"}, + "last": {"type": "str"}, }, }, "rp": { "type": "dict", "options": { - "prefix": { - "type": "str" - }, + "prefix": {"type": "str"}, "rp_type": { "type": "str", "choices": [ @@ -190,29 +181,19 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "source": {"type": "str"}, "group": { "type": "dict", - "options": { - "prefix": { - "type": "str" - } - }, + "options": {"prefix": {"type": "str"}}, }, "group_range": { "type": "dict", "options": { - "first": { - "type": "str" - }, - "last": { - "type": "str" - }, + "first": {"type": "str"}, + "last": {"type": "str"}, }, }, "rp": { "type": "dict", "options": { - "prefix": { - "type": "str" - }, + "prefix": {"type": "str"}, "rp_type": { "type": "str", "choices": [ @@ -316,9 +297,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "options": { "half_life": {"type": "int"}, "start_reuse_route": {"type": "int"}, - "start_suppress_route": { - "type": "int" - }, + "start_suppress_route": {"type": "int"}, "max_suppress_time": {"type": "int"}, }, }, @@ -335,14 +314,10 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "options": { "gateway_ip": { "type": "dict", - "mutually_exclusive": [ - ["ip", "use_nexthop"] - ], + "mutually_exclusive": [["ip", "use_nexthop"]], "options": { "ip": {"type": "str"}, - "use_nexthop": { - "type": "bool" - }, + "use_nexthop": {"type": "bool"}, }, } }, @@ -355,9 +330,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "options": { "address": { "type": "dict", - "options": { - "prefix_list": {"type": "str"} - }, + "options": {"prefix_list": {"type": "str"}}, }, "precedence": {"type": "str"}, }, @@ -367,9 +340,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "options": { "address": { "type": "dict", - "options": { - "prefix_list": {"type": "str"} - }, + "options": {"prefix_list": {"type": "str"}}, }, "precedence": {"type": "str"}, }, @@ -389,12 +360,8 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "options": { "bandwidth": {"type": "int"}, "igrp_delay_metric": {"type": "int"}, - "igrp_reliability_metric": { - "type": "int" - }, - "igrp_effective_bandwidth_metric": { - "type": "int" - }, + "igrp_reliability_metric": {"type": "int"}, + "igrp_effective_bandwidth_metric": {"type": "int"}, "igrp_mtu": {"type": "int"}, }, }, diff --git a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py index 970afc755..4570d0af3 100644 --- a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -131,16 +132,12 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "enable": {"type": "bool"}, - "cefcMIBEnableStatusNotification": { - "type": "bool" - }, + "cefcMIBEnableStatusNotification": {"type": "bool"}, "entity_fan_status_change": {"type": "bool"}, "entity_mib_change": {"type": "bool"}, "entity_module_inserted": {"type": "bool"}, "entity_module_removed": {"type": "bool"}, - "entity_module_status_change": { - "type": "bool" - }, + "entity_module_status_change": {"type": "bool"}, "entity_power_out_change": {"type": "bool"}, "entity_power_status_change": {"type": "bool"}, "entity_sensor": {"type": "bool"}, @@ -168,22 +165,16 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "options": { "enable": {"type": "bool"}, "notify_license_expiry": {"type": "bool"}, - "notify_license_expiry_warning": { - "type": "bool" - }, + "notify_license_expiry_warning": {"type": "bool"}, "notify_licensefile_missing": {"type": "bool"}, - "notify_no_license_for_feature": { - "type": "bool" - }, + "notify_no_license_for_feature": {"type": "bool"}, }, }, "link": { "type": "dict", "options": { "enable": {"type": "bool"}, - "cErrDisableInterfaceEventRev1": { - "type": "bool" - }, + "cErrDisableInterfaceEventRev1": {"type": "bool"}, "cieLinkDown": {"type": "bool"}, "cieLinkUp": {"type": "bool"}, "cisco_xcvr_mon_status_chg": {"type": "bool"}, @@ -263,9 +254,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "enable": {"type": "bool"}, - "cseFailSwCoreNotifyExtended": { - "type": "bool" - }, + "cseFailSwCoreNotifyExtended": {"type": "bool"}, }, }, "system": { @@ -280,9 +269,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "options": { "enable": {"type": "bool"}, "upgradeJobStatusNotify": {"type": "bool"}, - "upgradeOpNotifyOnCompletion": { - "type": "bool" - }, + "upgradeOpNotifyOnCompletion": {"type": "bool"}, }, }, "vtp": { diff --git a/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py b/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py index d0e32819a..58a669bd5 100644 --- a/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -53,9 +54,7 @@ class Static_routesArgs(object): # pylint: disable=R0903 "options": { "admin_distance": {"type": "int"}, "dest_vrf": {"type": "str"}, - "forward_router_address": { - "type": "str" - }, + "forward_router_address": {"type": "str"}, "interface": {"type": "str"}, "route_name": {"type": "str"}, "tag": {"type": "int"}, diff --git a/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py b/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py index f376f4f70..8ea952cb0 100644 --- a/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py @@ -27,6 +27,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/argspec/vlans/vlans.py b/plugins/module_utils/network/nxos/argspec/vlans/vlans.py index dcdd3b592..4f915f092 100644 --- a/plugins/module_utils/network/nxos/argspec/vlans/vlans.py +++ b/plugins/module_utils/network/nxos/argspec/vlans/vlans.py @@ -27,6 +27,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py b/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py index 187a2c42f..7f00fd5a4 100644 --- a/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py @@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type TMS_GLOBAL = """ diff --git a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py index aa97b3304..883b64bcc 100644 --- a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py @@ -12,24 +12,24 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, - remove_empties, dict_diff, + remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, - search_obj_in_list, get_interface_type, normalize_interface, + search_obj_in_list, ) @@ -54,9 +54,7 @@ def get_acl_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - acl_interfaces_facts = facts["ansible_network_resources"].get( - "acl_interfaces" - ) + acl_interfaces_facts = facts["ansible_network_resources"].get("acl_interfaces") if not acl_interfaces_facts: return [] return acl_interfaces_facts @@ -139,14 +137,9 @@ def set_state(self, want, have): :returns: the commands necessary to migrate the current configuration to the desired configuration """ - if ( - self.state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if self.state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - self.state - ) + msg="value of config parameter must not be empty for state {0}".format(self.state) ) commands = [] @@ -192,9 +185,7 @@ def _state_replaced(self, want, have): for ag in obj_in_have["access_groups"]: want_afi = [] if want.get("access_groups"): - want_afi = search_obj_in_list( - ag["afi"], want["access_groups"], "afi" - ) + want_afi = search_obj_in_list(ag["afi"], want["access_groups"], "afi") if not want_afi: # whatever in have is not in want del_dict["access_groups"].append(ag) @@ -207,18 +198,12 @@ def _state_replaced(self, want, have): else: del_acl.append(acl) afi = want_afi["afi"] - del_dict["access_groups"].append( - {"afi": afi, "acls": del_acl} - ) + del_dict["access_groups"].append({"afi": afi, "acls": del_acl}) commands.extend(self._state_deleted([del_dict], have)) commands.extend(self._state_merged(want, have)) new_commands.append(commands[0]) - commands = [ - commands[i] - for i in range(1, len(commands)) - if commands[i] != commands[0] - ] + commands = [commands[i] for i in range(1, len(commands)) if commands[i] != commands[0]] new_commands.extend(commands) return new_commands @@ -256,36 +241,26 @@ def set_commands(self, want, have, deleted=False): ip = "ipv6" if w_afi["afi"] == "ipv4": ip = "ip" - have_afi = search_obj_in_list( - w_afi["afi"], have_name["access_groups"], "afi" - ) + have_afi = search_obj_in_list(w_afi["afi"], have_name["access_groups"], "afi") if have_afi: new_acls = [] if deleted: if w_afi.get("acls") and have_afi.get("acls"): new_acls = [ - acl - for acl in w_afi.get("acls") - if acl in have_afi.get("acls") + acl for acl in w_afi.get("acls") if acl in have_afi.get("acls") ] elif "acls" not in w_afi.keys(): new_acls = have_afi.get("acls") else: if w_afi.get("acls"): new_acls = [ - acl - for acl in w_afi["acls"] - if acl not in have_afi["acls"] + acl for acl in w_afi["acls"] if acl not in have_afi["acls"] ] - commands.extend( - self.process_acl(new_acls, ip, deleted) - ) + commands.extend(self.process_acl(new_acls, ip, deleted)) else: if not deleted: if w_afi.get("acls"): - commands.extend( - self.process_acl(w_afi["acls"], ip) - ) + commands.extend(self.process_acl(w_afi["acls"], ip)) else: # only name is given to delete if deleted and "access_groups" in have_name.keys(): @@ -320,9 +295,7 @@ def process_acl(self, acls, ip, deleted=False): ag = " access-group " if ip == "ipv6": ag = " traffic-filter " - commands.append( - no + ip + port + ag + acl["name"] + " " + acl["direction"] - ) + commands.append(no + ip + port + ag + acl["name"] + " " + acl["direction"]) return commands def _state_deleted(self, main_want, have): @@ -340,9 +313,7 @@ def _state_deleted(self, main_want, have): commands.extend(self.set_commands(h, have, deleted=True)) else: for want in main_want: - commands.extend( - self.set_commands(want, have, deleted=True) - ) + commands.extend(self.set_commands(want, have, deleted=True)) else: for h in have: commands.extend(self.set_commands(h, have, deleted=True)) diff --git a/plugins/module_utils/network/nxos/config/acls/acls.py b/plugins/module_utils/network/nxos/config/acls/acls.py index 0e983b446..0ab27d611 100644 --- a/plugins/module_utils/network/nxos/config/acls/acls.py +++ b/plugins/module_utils/network/nxos/config/acls/acls.py @@ -12,26 +12,26 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acls.acls import ( AclsArgs, ) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( search_obj_in_list, ) @@ -222,57 +222,37 @@ def convert_values(self, want): ace["dscp"] = ace["dscp"].lower() if "precedence" in ace.keys(): if ace["precedence"].isdigit(): - ace["precedence"] = precedence[ - int(ace["precedence"]) - ] + ace["precedence"] = precedence[int(ace["precedence"])] if ( "protocol" in ace.keys() and ace["protocol"].isdigit() and int(ace["protocol"]) in protocol.keys() ): - ace["protocol"] = protocol[ - int(ace["protocol"]) - ] + ace["protocol"] = protocol[int(ace["protocol"])] # convert number to name - if "protocol" in ace.keys() and ace[ - "protocol" - ] in ["tcp", "udp"]: + if "protocol" in ace.keys() and ace["protocol"] in ["tcp", "udp"]: for x in ["source", "destination"]: if "port_protocol" in ace[x].keys(): - key = list( - ace[x]["port_protocol"].keys() - )[0] + key = list(ace[x]["port_protocol"].keys())[0] # key could be eq,gt,lt,neq or range if key != "range": val = ace[x]["port_protocol"][key] - if ( - val.isdigit() - and int(val) - in port_protocol.keys() - ): - ace[x]["port_protocol"][ - key - ] = port_protocol[int(val)] + if val.isdigit() and int(val) in port_protocol.keys(): + ace[x]["port_protocol"][key] = port_protocol[ + int(val) + ] else: - st = int( - ace[x]["port_protocol"][ - "range" - ]["start"] - ) - end = int( - ace[x]["port_protocol"][ - "range" - ]["end"] - ) + st = int(ace[x]["port_protocol"]["range"]["start"]) + end = int(ace[x]["port_protocol"]["range"]["end"]) if st in port_protocol.keys(): - ace[x]["port_protocol"][ - "range" - ]["start"] = port_protocol[st] + ace[x]["port_protocol"]["range"][ + "start" + ] = port_protocol[st] if end in port_protocol.keys(): - ace[x]["port_protocol"][ - "range" - ]["end"] = port_protocol[end] + ace[x]["port_protocol"]["range"][ + "end" + ] = port_protocol[end] return want def set_state(self, want, have): @@ -337,19 +317,11 @@ def _state_replaced(self, want, have): if w["name"] not in have_names: # creates new ACL in replaced state merge_dict = {"afi": want["afi"], "acls": [w]} - commands.extend( - self._state_merged(merge_dict, have) - ) + commands.extend(self._state_merged(merge_dict, have)) else: # acl in want exists in have - have_name = search_obj_in_list( - w["name"], have_afi["acls"], "name" - ) - have_aces = ( - have_name.get("aces") - if have_name.get("aces") - else [] - ) + have_name = search_obj_in_list(w["name"], have_afi["acls"], "name") + have_aces = have_name.get("aces") if have_name.get("aces") else [] merge_aces = [] del_aces = [] w_aces = w.get("aces") if w.get("aces") else [] @@ -362,23 +334,15 @@ def _state_replaced(self, want, have): merge_aces.append(ace) merge_dict = { "afi": want["afi"], - "acls": [ - {"name": w["name"], "aces": merge_aces} - ], + "acls": [{"name": w["name"], "aces": merge_aces}], } del_dict = { "afi": want["afi"], - "acls": [ - {"name": w["name"], "aces": del_aces} - ], + "acls": [{"name": w["name"], "aces": del_aces}], } if del_dict["acls"]: - acl_commands.extend( - self._state_deleted([del_dict], have) - ) - acl_commands.extend( - self._state_merged(merge_dict, have) - ) + acl_commands.extend(self._state_deleted([del_dict], have)) + acl_commands.extend(self._state_merged(merge_dict, have)) for i in range(1, len(acl_commands)): if acl_commands[i] == acl_commands[0]: @@ -413,9 +377,7 @@ def _state_overridden(self, want, have): if h["afi"] in want_afi: w = search_obj_in_list(h["afi"], want, "afi") for h_acl in h["acls"]: - w_acl = search_obj_in_list( - h_acl["name"], w["acls"], "name" - ) + w_acl = search_obj_in_list(h_acl["name"], w["acls"], "name") if not w_acl: del_dict = { "afi": h["afi"], @@ -455,10 +417,7 @@ def _state_deleted(self, want, have): if have_afi: if w.get("acls"): for acl in w["acls"]: - if ( - "aces" in acl.keys() - and self.state != "deleted" - ): + if "aces" in acl.keys() and self.state != "deleted": have_name = search_obj_in_list( acl["name"], have_afi["acls"], "name" ) @@ -470,32 +429,20 @@ def _state_deleted(self, want, have): # only sequence number is specified to be deleted if "aces" in have_name.keys(): for h_ace in have_name["aces"]: - if ( - h_ace["sequence"] - == ace["sequence"] - ): + if h_ace["sequence"] == ace["sequence"]: ace_commands.append( - "no " - + str( - ace["sequence"] - ) + "no " + str(ace["sequence"]) ) flag = 1 else: if "aces" in have_name.keys(): for h_ace in have_name["aces"]: # when want['ace'] does not have seq number - if ( - "sequence" - not in ace.keys() - ): + if "sequence" not in ace.keys(): del h_ace["sequence"] if ace == h_ace: ace_commands.append( - "no " - + self.process_ace( - ace - ) + "no " + self.process_ace(ace) ) flag = 1 if flag: @@ -510,9 +457,7 @@ def _state_deleted(self, want, have): if h["name"] == acl["name"]: acl_names.append(acl["name"]) for name in acl_names: - commands.append( - "no " + ip + " access-list " + name - ) + commands.append("no " + ip + " access-list " + name) else: # 'only afi is given' @@ -520,9 +465,7 @@ def _state_deleted(self, want, have): for h in have_afi["acls"]: acl_names.append(h["name"]) for name in acl_names: - commands.append( - "no " + ip + " access-list " + name - ) + commands.append("no " + ip + " access-list " + name) else: v6 = [] v4 = [] @@ -565,9 +508,7 @@ def set_commands(self, want, have): if have_afi: if want.get("acls"): for w_acl in want["acls"]: - have_acl = search_obj_in_list( - w_acl["name"], have_afi["acls"], "name" - ) + have_acl = search_obj_in_list(w_acl["name"], have_afi["acls"], "name") name = w_acl["name"] flag = 0 ace_commands = [] @@ -581,9 +522,7 @@ def set_commands(self, want, have): # For replaced and overridden, rule is deleted in the state's config) ace_list = [ - item - for item in w_acl["aces"] - if "sequence" not in item.keys() + item for item in w_acl["aces"] if "sequence" not in item.keys() ] # case 1 want_seq = [ @@ -592,21 +531,15 @@ def set_commands(self, want, have): if "sequence" in item.keys() ] - have_seq = [ - item["sequence"] - for item in have_acl["aces"] - ] + have_seq = [item["sequence"] for item in have_acl["aces"]] new_seq = list(set(want_seq) - set(have_seq)) - common_seq = list( - set(want_seq).intersection(set(have_seq)) - ) + common_seq = list(set(want_seq).intersection(set(have_seq))) temp_list = [ item for item in w_acl["aces"] - if "sequence" in item.keys() - and item["sequence"] in new_seq + if "sequence" in item.keys() and item["sequence"] in new_seq ] # case 2 ace_list.extend(temp_list) for w in w_acl["aces"]: @@ -627,10 +560,7 @@ def set_commands(self, want, have): ] }, ) - if ( - "sequence" in w.keys() - and w["sequence"] in common_seq - ): + if "sequence" in w.keys() and w["sequence"] in common_seq: temp_obj = search_obj_in_list( w["sequence"], have_acl["aces"], @@ -650,23 +580,17 @@ def set_commands(self, want, have): # 'have' has ACL defined without any ACE ace_list = list(w_acl["aces"]) for w_ace in ace_list: - ace_commands.append( - self.process_ace(w_ace).strip() - ) + ace_commands.append(self.process_ace(w_ace).strip()) flag = 1 if flag: - ace_commands.insert( - 0, ip + "access-list " + name - ) + ace_commands.insert(0, ip + "access-list " + name) else: commands.append(ip + "access-list " + name) if "aces" in w_acl.keys(): for w_ace in w_acl["aces"]: - commands.append( - self.process_ace(w_ace).strip() - ) + commands.append(self.process_ace(w_ace).strip()) commands.extend(ace_commands) else: if want.get("acls"): @@ -689,16 +613,12 @@ def process_ace(self, w_ace): if "protocol" in ace_keys: command += w_ace["protocol"] + " " src = self.get_address(w_ace["source"], w_ace["protocol"]) - dest = self.get_address( - w_ace["destination"], w_ace["protocol"] - ) + dest = self.get_address(w_ace["destination"], w_ace["protocol"]) command += src + dest if "protocol_options" in ace_keys: pro = list(w_ace["protocol_options"].keys())[0] if pro != w_ace["protocol"]: - self._module.fail_json( - msg="protocol and protocol_options mismatch" - ) + self._module.fail_json(msg="protocol and protocol_options mismatch") flags = "" for k in w_ace["protocol_options"][pro].keys(): k = re.sub("_", "-", k) @@ -721,13 +641,9 @@ def get_address(self, endpoint, pro=""): keys = list(endpoint.keys()) if "address" in keys: if "wildcard_bits" not in keys: - self._module.fail_json( - msg="wildcard bits not specified for address" - ) + self._module.fail_json(msg="wildcard bits not specified for address") else: - ret_addr = ( - endpoint["address"] + " " + endpoint["wildcard_bits"] + " " - ) + ret_addr = endpoint["address"] + " " + endpoint["wildcard_bits"] + " " elif "any" in keys: ret_addr = "any " elif "host" in keys: @@ -745,13 +661,7 @@ def get_options(self, item): com = "" subkey = list(item.keys()) if "range" in subkey: - com = ( - "range " - + item["range"]["start"] - + " " - + item["range"]["end"] - + " " - ) + com = "range " + item["range"]["start"] + " " + item["range"]["end"] + " " else: com = subkey[0] + " " + item[subkey[0]] + " " return com diff --git a/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py b/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py index d167b0c2f..33eb7da68 100644 --- a/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py +++ b/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py @@ -11,9 +11,11 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) @@ -21,9 +23,8 @@ dict_diff, to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, search_obj_in_list, @@ -52,9 +53,7 @@ def get_bfd_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - bfd_interfaces_facts = facts["ansible_network_resources"].get( - "bfd_interfaces", [] - ) + bfd_interfaces_facts = facts["ansible_network_resources"].get("bfd_interfaces", []) platform = facts.get("ansible_net_platform", "") return bfd_interfaces_facts, platform @@ -81,9 +80,7 @@ def execute_module(self): existing_bfd_interfaces_facts, platform = [], "" if self.state in self.ACTION_STATES or self.state == "rendered": - commands.extend( - self.set_config(existing_bfd_interfaces_facts, platform) - ) + commands.extend(self.set_config(existing_bfd_interfaces_facts, platform)) if commands and self.state in self.ACTION_STATES: if not self._module.check_mode: @@ -108,9 +105,7 @@ def execute_module(self): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"], platform = self.get_bfd_interfaces_facts( - data=running_config - ) + result["parsed"], platform = self.get_bfd_interfaces_facts(data=running_config) if self.state in self.ACTION_STATES: result["before"] = existing_bfd_interfaces_facts @@ -161,14 +156,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) cmds = list() @@ -222,9 +212,7 @@ def _state_overridden(self, want, have): for h in have: # Clean up bfd attrs for any interfaces not listed in the play h = flatten_dict(h) - obj_in_want = flatten_dict( - search_obj_in_list(h["name"], want, "name") - ) + obj_in_want = flatten_dict(search_obj_in_list(h["name"], want, "name")) if obj_in_want: # Let the 'want' loop handle all vals for this interface continue @@ -258,9 +246,7 @@ def _state_deleted(self, want, have): cmds = [] if want: for w in want: - obj_in_have = flatten_dict( - search_obj_in_list(w["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(w["name"], have, "name")) cmds.extend(self.del_attribs(obj_in_have)) else: for h in have: @@ -314,9 +300,7 @@ def add_commands(self, want): def set_commands(self, want, have): cmds = [] - obj_in_have = flatten_dict( - search_obj_in_list(want["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(want["name"], have, "name")) if not obj_in_have: cmds = self.add_commands(want) else: diff --git a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py index 96751926e..e4ecae678 100644 --- a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,25 +18,23 @@ created. """ +import re + from copy import deepcopy -import re from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, + remove_empties, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_address_family import ( Bgp_address_familyTemplate, ) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_empties, -) class Bgp_address_family(ResourceModule): @@ -117,18 +116,14 @@ def generate_commands(self): # if state is overridden or deleted, remove superfluos config if self.state in ["deleted", "overridden"]: - if ( - haved and haved["as_number"] == wantd.get("as_number") - ) or not wantd: + if (haved and haved["as_number"] == wantd.get("as_number")) or not wantd: remove = True if self.state == "deleted" else False purge = True if not wantd else False self._remove_af(want_af, have_af, remove=remove, purge=purge) for k, hvrf in iteritems(hvrfs): wvrf = wvrfs.get(k, {}) - self._remove_af( - wvrf, hvrf, vrf=k, remove=remove, purge=purge - ) + self._remove_af(wvrf, hvrf, vrf=k, remove=remove, purge=purge) if self.state in ["merged", "replaced", "overridden", "rendered"]: for k, want in iteritems(want_af): @@ -147,9 +142,7 @@ def generate_commands(self): self.commands.insert(cur_ptr, "vrf {0}".format(wk)) if self.commands: - self.commands.insert( - 0, "router bgp {as_number}".format(**haved or wantd) - ) + self.commands.insert(0, "router bgp {as_number}".format(**haved or wantd)) def _compare(self, want, have): """Leverages the base class `compare()` method and @@ -205,19 +198,13 @@ def _build_key(data): # transform parameters which are # list of dicts to dict of dicts for item in entry.get("address_family", []): - item["aggregate_address"] = { - x["prefix"]: x for x in item.get("aggregate_address", []) - } + item["aggregate_address"] = {x["prefix"]: x for x in item.get("aggregate_address", [])} item["inject_map"] = { - (x["route_map"], x["exist_map"]): x - for x in item.get("inject_map", []) - } - item["networks"] = { - x["prefix"]: x for x in item.get("networks", []) + (x["route_map"], x["exist_map"]): x for x in item.get("inject_map", []) } + item["networks"] = {x["prefix"]: x for x in item.get("networks", [])} item["redistribute"] = { - (x.get("id"), x["protocol"]): x - for x in item.get("redistribute", []) + (x.get("id"), x["protocol"]): x for x in item.get("redistribute", []) } # transform all entries under @@ -249,9 +236,7 @@ def _build_key(data): # final structure: https://gist.github.com/NilashishC/628dae5fe39a4908e87c9e833bfbe57d - def _remove_af( - self, want_af, have_af, vrf=None, remove=False, purge=False - ): + def _remove_af(self, want_af, have_af, vrf=None, remove=False, purge=False): cur_ptr = len(self.commands) for k, v in iteritems(have_af): # first conditional is for deleted with config provided diff --git a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py index 09ca1ddee..c16ed3f8a 100644 --- a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,15 +21,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_global import ( Bgp_globalTemplate, ) @@ -134,15 +134,11 @@ def generate_commands(self): # if state is deleted, clean up global params if self.state == "deleted": - if not self.want or ( - self.have.get("as_number") == self.want.get("as_number") - ): + if not self.want or (self.have.get("as_number") == self.want.get("as_number")): self._compare(want={}, have=self.have) elif self.state == "purged": - if not self.want or ( - self.have.get("as_number") == self.want.get("as_number") - ): + if not self.want or (self.have.get("as_number") == self.want.get("as_number")): self.addcmd(self.have or {}, "as_number", True) else: @@ -170,9 +166,7 @@ def _compare(self, want, have, vrf=None): begin, self._tmplt.render( want or have, - "vrf" - if "vrf" in (want.keys() or have.keys()) - else "as_number", + "vrf" if "vrf" in (want.keys() or have.keys()) else "as_number", False, ), ) @@ -243,9 +237,7 @@ def _compare_neighbors(self, want, have, vrf=None): self._compare_path_attribute(entry, have_nbr) if len(self.commands) != begin: - self.commands.insert( - begin, self._tmplt.render(entry, "neighbor_address", False) - ) + self.commands.insert(begin, self._tmplt.render(entry, "neighbor_address", False)) # cleanup remaining neighbors # but do not negate it entirely @@ -255,9 +247,7 @@ def _compare_neighbors(self, want, have, vrf=None): if self._has_af(vrf=vrf, neighbor=name): self._module.fail_json( msg="Neighbor {0} has address-family configurations. " - "Please use the nxos_bgp_neighbor_af module to remove those first.".format( - name - ) + "Please use the nxos_bgp_neighbor_af module to remove those first.".format(name) ) else: self.addcmd(entry, "neighbor_address", True) @@ -298,9 +288,7 @@ def _vrfs_compare(self, want, have): if self._has_af(vrf=name): self._module.fail_json( msg="VRF {0} has address-family configurations. " - "Please use the nxos_bgp_af module to remove those first.".format( - name - ) + "Please use the nxos_bgp_af module to remove those first.".format(name) ) else: self.addcmd(entry, "vrf", True) @@ -329,13 +317,10 @@ def _build_key(x): for x in entry["neighbors"]: if "path_attribute" in x: x["path_attribute"] = { - _build_key(item): item - for item in x.get("path_attribute", []) + _build_key(item): item for item in x.get("path_attribute", []) } - entry["neighbors"] = { - x["neighbor_address"]: x for x in entry.get("neighbors", []) - } + entry["neighbors"] = {x["neighbor_address"]: x for x in entry.get("neighbors", [])} if "vrfs" in entry: entry["vrfs"] = {x["vrf"]: x for x in entry.get("vrfs", [])} @@ -343,9 +328,7 @@ def _build_key(x): self._bgp_list_to_dict(vrf) def _get_config(self): - return self._connection.get( - "show running-config | section '^router bgp'" - ) + return self._connection.get("show running-config | section '^router bgp'") def _build_af_data(self): """Build a dictionary with AF related information diff --git a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 5e436a987..f553e6e7c 100644 --- a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -19,15 +20,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_neighbor_address_family import ( Bgp_neighbor_address_familyTemplate, ) @@ -123,9 +123,7 @@ def generate_commands(self): self._compare(want=wantd, have=haved) if self.commands: - self.commands.insert( - 0, "router bgp {as_number}".format(**haved or wantd) - ) + self.commands.insert(0, "router bgp {as_number}".format(**haved or wantd)) def _compare(self, want, have, vrf=""): """Leverages the base class `compare()` method and @@ -172,9 +170,7 @@ def _compare(self, want, have, vrf=""): self.addcmd(have_af, "address_family", True) if len(self.commands) != begin: - self.commands.insert( - begin, "neighbor {0}".format(w_nbr["neighbor_address"]) - ) + self.commands.insert(begin, "neighbor {0}".format(w_nbr["neighbor_address"])) if self.state in ["overridden", "deleted"]: for k, h_nbr in iteritems(h_nbrs): @@ -184,9 +180,7 @@ def _compare(self, want, have, vrf=""): for k, have_af in iteritems(have_afs): self.addcmd(have_af, "address_family", True) if len(self.commands) != begin: - self.commands.insert( - begin, "neighbor {0}".format(h_nbr["neighbor_address"]) - ) + self.commands.insert(begin, "neighbor {0}".format(h_nbr["neighbor_address"])) if vrf: if len(self.commands) != begin_vrf: @@ -209,12 +203,9 @@ def _bgp_list_to_dict(self, data): for nbr in data["neighbors"]: if "address_family" in nbr: nbr["address_family"] = { - (x["afi"], x.get("safi")): x - for x in nbr["address_family"] + (x["afi"], x.get("safi")): x for x in nbr["address_family"] } - data["neighbors"] = { - x["neighbor_address"]: x for x in data["neighbors"] - } + data["neighbors"] = {x["neighbor_address"]: x for x in data["neighbors"]} if "vrfs" in data: for vrf in data["vrfs"]: diff --git a/plugins/module_utils/network/nxos/config/hostname/hostname.py b/plugins/module_utils/network/nxos/config/hostname/hostname.py index d7305dd2d..42ed06946 100644 --- a/plugins/module_utils/network/nxos/config/hostname/hostname.py +++ b/plugins/module_utils/network/nxos/config/hostname/hostname.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,9 +21,8 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.hostname import ( HostnameTemplate, ) diff --git a/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py b/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py index 9c4adce56..749266f48 100644 --- a/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py @@ -11,6 +11,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( @@ -18,12 +19,11 @@ ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, get_interface_type, @@ -54,9 +54,7 @@ def get_hsrp_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - hsrp_interfaces_facts = facts["ansible_network_resources"].get( - "hsrp_interfaces", [] - ) + hsrp_interfaces_facts = facts["ansible_network_resources"].get("hsrp_interfaces", []) return hsrp_interfaces_facts def edit_config(self, commands): @@ -100,9 +98,7 @@ def execute_module(self): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"] = self.get_hsrp_interfaces_facts( - data=running_config - ) + result["parsed"] = self.get_hsrp_interfaces_facts(data=running_config) if self.state in self.ACTION_STATES: result["before"] = existing_hsrp_interfaces_facts @@ -144,14 +140,9 @@ def set_state(self, want, have): """ state = self._module.params["state"] # check for 'config' keyword in play - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) cmds = list() @@ -239,9 +230,7 @@ def _state_deleted(self, want, have): cmds = [] if want: for w in want: - obj_in_have = flatten_dict( - search_obj_in_list(w["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(w["name"], have, "name")) cmds.extend(self.del_attribs(obj_in_have)) else: for h in have: @@ -279,11 +268,7 @@ def add_commands(self, want, obj_in_have): if want["bfd"] == "enable": cmd = "hsrp bfd" cmds.append(cmd) - elif ( - want["bfd"] == "disable" - and obj_in_have - and obj_in_have.get("bfd") == "enable" - ): + elif want["bfd"] == "disable" and obj_in_have and obj_in_have.get("bfd") == "enable": cmd = "no hsrp bfd" cmds.append(cmd) diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index abc89fabf..3a23e9eb4 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -13,31 +13,30 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from copy import deepcopy import re +from copy import deepcopy + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + default_intf_enabled, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( normalize_interface, - search_obj_in_list, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( remove_rsvd_interfaces, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - default_intf_enabled, + search_obj_in_list, ) @@ -65,9 +64,7 @@ def get_interfaces_facts(self, data=None): self.facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - interfaces_facts = self.facts["ansible_network_resources"].get( - "interfaces" - ) + interfaces_facts = self.facts["ansible_network_resources"].get("interfaces") return interfaces_facts @@ -81,9 +78,7 @@ def get_system_defaults(self): """Wrapper method for `_connection.get()` This method exists solely to allow the unit test framework to mock device connection calls. """ - return self._connection.get( - "show running-config all | incl 'system default switchport'" - ) + return self._connection.get("show running-config all | incl 'system default switchport'") def edit_config(self, commands): """Wrapper method for `_connection.edit_config()` @@ -185,14 +180,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() @@ -363,9 +353,7 @@ def default_enabled(self, want=None, have=None, action=""): or intf_def_enabled is None ): # L2-L3 is changing or this is a new virtual intf. Get new default. - intf_def_enabled = default_intf_enabled( - name=name, sysdefs=sysdefs, mode=want_mode - ) + intf_def_enabled = default_intf_enabled(name=name, sysdefs=sysdefs, mode=want_mode) return intf_def_enabled def del_attribs(self, obj): @@ -431,12 +419,7 @@ def add_commands(self, d, obj_in_have=None): if "duplex" in d: commands.append("duplex " + d["duplex"]) if "enabled" in d: - have_enabled = ( - obj_in_have.get( - "enabled", self.default_enabled(d, obj_in_have) - ) - or False - ) + have_enabled = obj_in_have.get("enabled", self.default_enabled(d, obj_in_have)) or False if d["enabled"] is False and have_enabled is True: commands.append("shutdown") elif d["enabled"] is True and have_enabled is False: @@ -479,9 +462,7 @@ def render_interface_defaults(self, config, intfs): Run through the gathered interfaces and tag their default enabled state. """ intf_defs = {} - L3_enabled = ( - True if re.search("N[356]K", self.get_platform()) else False - ) + L3_enabled = True if re.search("N[356]K", self.get_platform()) else False intf_defs = { "sysdefs": { "mode": None, @@ -492,16 +473,12 @@ def render_interface_defaults(self, config, intfs): pat = "(no )*system default switchport$" m = re.search(pat, config, re.MULTILINE) if m: - intf_defs["sysdefs"]["mode"] = ( - "layer3" if "no " in m.groups() else "layer2" - ) + intf_defs["sysdefs"]["mode"] = "layer3" if "no " in m.groups() else "layer2" pat = "(no )*system default switchport shutdown$" m = re.search(pat, config, re.MULTILINE) if m: - intf_defs["sysdefs"]["L2_enabled"] = ( - True if "no " in m.groups() else False - ) + intf_defs["sysdefs"]["L2_enabled"] = True if "no " in m.groups() else False for item in intfs: intf_defs[item["name"]] = default_intf_enabled( diff --git a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py index 2096bd611..4f2668b3d 100644 --- a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py @@ -13,26 +13,27 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, normalize_interface, search_obj_in_list, - vlan_range_to_list, vlan_list_to_range, + vlan_range_to_list, ) @@ -59,9 +60,7 @@ def get_l2_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - l2_interfaces_facts = facts["ansible_network_resources"].get( - "l2_interfaces" - ) + l2_interfaces_facts = facts["ansible_network_resources"].get("l2_interfaces") if not l2_interfaces_facts: return [] return l2_interfaces_facts @@ -104,9 +103,7 @@ def execute_module(self): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"] = self.get_l2_interfaces_facts( - data=running_config - ) + result["parsed"] = self.get_l2_interfaces_facts(data=running_config) if self.state in self.ACTION_STATES: result["before"] = existing_l2_interfaces_facts @@ -161,14 +158,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() @@ -181,9 +173,7 @@ def set_state(self, want, have): if state in ["merged", "rendered"]: commands.extend(self._state_merged(flatten_dict(w), have)) elif state == "replaced": - commands.extend( - self._state_replaced(flatten_dict(w), have) - ) + commands.extend(self._state_replaced(flatten_dict(w), have)) return commands def _state_replaced(self, w, have): @@ -227,9 +217,7 @@ def _state_overridden(self, want, have): commands = [] for h in have: h = flatten_dict(h) - obj_in_want = flatten_dict( - search_obj_in_list(h["name"], want, "name") - ) + obj_in_want = flatten_dict(search_obj_in_list(h["name"], want, "name")) if h == obj_in_want: continue for w in want: @@ -264,9 +252,7 @@ def _state_deleted(self, want, have): commands = [] if want: for w in want: - obj_in_have = flatten_dict( - search_obj_in_list(w["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(w["name"], have, "name")) commands.extend(self.del_attribs(obj_in_have)) else: if not have: @@ -312,13 +298,9 @@ def add_commands(self, d, vlan_exists=False): commands.append(cmd + "access vlan " + str(d["vlan"])) if "allowed_vlans" in d: if vlan_exists: - commands.append( - cmd + "trunk allowed vlan add " + str(d["allowed_vlans"]) - ) + commands.append(cmd + "trunk allowed vlan add " + str(d["allowed_vlans"])) else: - commands.append( - cmd + "trunk allowed vlan " + str(d["allowed_vlans"]) - ) + commands.append(cmd + "trunk allowed vlan " + str(d["allowed_vlans"])) if "native_vlan" in d: commands.append(cmd + "trunk native vlan " + str(d["native_vlan"])) if commands: @@ -347,9 +329,7 @@ def set_commands(self, w, have, replace=False): if w_vlans in have_vlans: vlan_tobe_added.pop(vlan_tobe_added.index(w_vlans)) if vlan_tobe_added: - diff.update( - {"allowed_vlans": ",".join(vlan_tobe_added)} - ) + diff.update({"allowed_vlans": ",".join(vlan_tobe_added)}) if have_vlans: commands = self.add_commands(diff, True) else: diff --git a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py index f7f80b358..77f6d256a 100644 --- a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py @@ -13,28 +13,27 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re from copy import deepcopy + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + get_interface_type, normalize_interface, - search_obj_in_list, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( remove_rsvd_interfaces, - get_interface_type, + search_obj_in_list, ) @@ -65,9 +64,7 @@ def get_l3_interfaces_facts(self, data=None): self.gather_subset, self.gather_network_resources, data=data ) - l3_interfaces_facts = facts["ansible_network_resources"].get( - "l3_interfaces" - ) + l3_interfaces_facts = facts["ansible_network_resources"].get("l3_interfaces") self.platform = facts.get("ansible_net_platform", "") return l3_interfaces_facts @@ -113,9 +110,7 @@ def execute_module(self): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"] = self.get_l3_interfaces_facts( - data=running_config - ) + result["parsed"] = self.get_l3_interfaces_facts(data=running_config) if self.state in self.ACTION_STATES: result["before"] = existing_l3_interfaces_facts @@ -157,14 +152,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = [] @@ -196,21 +186,15 @@ def _state_replaced(self, want, have): have_v6 = obj_in_have.pop("ipv6", []) if obj_in_have else [] # Process lists of dicts separately - v4_cmds = self._v4_cmds( - want.pop("ipv4", []), have_v4, state="replaced" - ) - v6_cmds = self._v6_cmds( - want.pop("ipv6", []), have_v6, state="replaced" - ) + v4_cmds = self._v4_cmds(want.pop("ipv4", []), have_v4, state="replaced") + v6_cmds = self._v6_cmds(want.pop("ipv6", []), have_v6, state="replaced") # Process remaining attrs if obj_in_have: # Find 'want' changes first diff = self.diff_of_dicts(want, obj_in_have) rmv = {"name": name} - haves_not_in_want = ( - set(obj_in_have.keys()) - set(want.keys()) - set(diff.keys()) - ) + haves_not_in_want = set(obj_in_have.keys()) - set(want.keys()) - set(diff.keys()) for i in haves_not_in_want: rmv[i] = obj_in_have[i] cmds.extend(self.generate_delete_commands(rmv)) @@ -310,9 +294,7 @@ def _v4_cmds(self, want, have, state=None): sec_to_rmv = [] sec_diff = self.diff_list_of_dicts(sec_h, sec_w) for i in sec_diff: - if overridden or [ - w for w in sec_w if w["address"] == i["address"] - ]: + if overridden or [w for w in sec_w if w["address"] == i["address"]]: sec_to_rmv.append(i["address"]) # Check if new primary is currently a secondary @@ -430,9 +412,7 @@ def generate_delete_commands(self, obj): if "evpn_multisite_tracking" in obj: have = self.existing_facts.get(name, {}) if have.get("evpn_multisite_tracking", False) is not False: - cmd = "no evpn multisite %s" % have.get( - "evpn_multisite_tracking" - ) + cmd = "no evpn multisite %s" % have.get("evpn_multisite_tracking") commands.append(cmd) return commands @@ -491,15 +471,11 @@ def add_commands(self, diff, name=""): commands.append(no_cmd + "ip redirects") self.cmd_order_fixup(commands, name) if "unreachables" in diff: - if diff["unreachables"] != self.check_existing( - name, "unreachables" - ): + if diff["unreachables"] != self.check_existing(name, "unreachables"): no_cmd = "no " if diff["unreachables"] is False else "" commands.append(no_cmd + "ip unreachables") if "evpn_multisite_tracking" in diff: - commands.append( - "evpn multisite " + str(diff["evpn_multisite_tracking"]) - ) + commands.append("evpn multisite " + str(diff["evpn_multisite_tracking"])) if "ipv4" in diff: commands.extend(self.generate_afi_commands(diff["ipv4"])) if "ipv6" in diff: @@ -511,11 +487,7 @@ def add_commands(self, diff, name=""): def generate_afi_commands(self, diff): cmds = [] for i in diff: - cmd = ( - "ipv6 address " - if re.search("::", i["address"]) - else "ip address " - ) + cmd = "ipv6 address " if re.search("::", i["address"]) else "ip address " cmd += i["address"] if i.get("secondary"): cmd += " secondary" @@ -532,12 +504,8 @@ def set_commands(self, w, have): commands = self.add_commands(w, name=name) else: # lists of dicts must be processed separately from non-list attrs - v4_cmds = self._v4_cmds( - w.pop("ipv4", []), obj_in_have.pop("ipv4", []), state="merged" - ) - v6_cmds = self._v6_cmds( - w.pop("ipv6", []), obj_in_have.pop("ipv6", []), state="merged" - ) + v4_cmds = self._v4_cmds(w.pop("ipv4", []), obj_in_have.pop("ipv4", []), state="merged") + v6_cmds = self._v6_cmds(w.pop("ipv6", []), obj_in_have.pop("ipv6", []), state="merged") # diff remaining attrs diff = self.diff_of_dicts(w, obj_in_have) @@ -551,14 +519,10 @@ def set_commands(self, w, have): def cmd_order_fixup(self, cmds, name): """Inserts 'interface ' config at the beginning of populated command list; reorders dependent commands that must process after others.""" if cmds: - if name and not [ - item for item in cmds if item.startswith("interface") - ]: + if name and not [item for item in cmds if item.startswith("interface")]: cmds.insert(0, "interface " + name) - redirects = [ - item for item in cmds if re.match("(no )*ip redirects", item) - ] + redirects = [item for item in cmds if re.match("(no )*ip redirects", item)] if redirects: # redirects should occur after ipv4 commands, just move to end of list redirects = redirects.pop() diff --git a/plugins/module_utils/network/nxos/config/lacp/lacp.py b/plugins/module_utils/network/nxos/config/lacp/lacp.py index 015469d1e..862cdb006 100644 --- a/plugins/module_utils/network/nxos/config/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/config/lacp/lacp.py @@ -12,6 +12,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( @@ -19,12 +20,11 @@ ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts class Lacp(ConfigBase): @@ -130,9 +130,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() diff --git a/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py b/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py index 61eddc9e2..4c4e59721 100644 --- a/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py @@ -12,24 +12,24 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, dict_diff, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, - search_obj_in_list, get_interface_type, normalize_interface, + search_obj_in_list, ) @@ -56,9 +56,7 @@ def get_lacp_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - lacp_interfaces_facts = facts["ansible_network_resources"].get( - "lacp_interfaces" - ) + lacp_interfaces_facts = facts["ansible_network_resources"].get("lacp_interfaces") if not lacp_interfaces_facts: return [] return lacp_interfaces_facts @@ -101,9 +99,7 @@ def execute_module(self): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"] = self.get_lacp_interfaces_facts( - data=running_config - ) + result["parsed"] = self.get_lacp_interfaces_facts(data=running_config) if self.state in self.ACTION_STATES: result["before"] = existing_lacp_interfaces_facts @@ -151,14 +147,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() @@ -171,9 +162,7 @@ def set_state(self, want, have): if state in ["merged", "rendered"]: commands.extend(self._state_merged(flatten_dict(w), have)) elif state == "replaced": - commands.extend( - self._state_replaced(flatten_dict(w), have) - ) + commands.extend(self._state_replaced(flatten_dict(w), have)) return commands def _state_replaced(self, w, have): @@ -214,9 +203,7 @@ def _state_overridden(self, want, have): commands = [] for h in have: h = flatten_dict(h) - obj_in_want = flatten_dict( - search_obj_in_list(h["name"], want, "name") - ) + obj_in_want = flatten_dict(search_obj_in_list(h["name"], want, "name")) if h == obj_in_want: continue for w in want: @@ -251,9 +238,7 @@ def _state_deleted(self, want, have): commands = [] if want: for w in want: - obj_in_have = flatten_dict( - search_obj_in_list(w["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(w["name"], have, "name")) commands.extend(self.del_attribs(obj_in_have)) else: if not have: diff --git a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py index 39f632ace..1edf64fa3 100644 --- a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py @@ -12,20 +12,20 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, - remove_empties, dict_diff, + remove_empties, search_obj_in_list, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( normalize_interface, ) @@ -52,9 +52,7 @@ def get_lag_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - lag_interfaces_facts = facts["ansible_network_resources"].get( - "lag_interfaces" - ) + lag_interfaces_facts = facts["ansible_network_resources"].get("lag_interfaces") if not lag_interfaces_facts: return [] return lag_interfaces_facts @@ -103,9 +101,7 @@ def execute_module(self): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"] = self.get_lag_interfaces_facts( - data=running_config - ) + result["parsed"] = self.get_lag_interfaces_facts(data=running_config) if self.state in self.ACTION_STATES: result["before"] = existing_lag_interfaces_facts @@ -132,9 +128,7 @@ def set_config(self, existing_lag_interfaces_facts): w.update(remove_empties(w)) if "members" in w and w["members"]: for item in w["members"]: - item.update( - {"member": normalize_interface(item["member"])} - ) + item.update({"member": normalize_interface(item["member"])}) have = existing_lag_interfaces_facts resp = self.set_state(want, have) return to_list(resp) @@ -149,14 +143,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() @@ -198,9 +187,7 @@ def _state_overridden(self, want, have): for h in have: obj_in_want = search_obj_in_list(h["name"], want, "name") if obj_in_want: - diff = self.diff_list_of_dicts( - h.get("members", []), obj_in_want["members"] - ) + diff = self.diff_list_of_dicts(h.get("members", []), obj_in_want["members"]) if not diff: continue commands.extend(self.del_all_commands(h)) @@ -245,9 +232,7 @@ def diff_list_of_dicts(self, want, have): diff = [] for w_item in want: - h_item = ( - search_obj_in_list(w_item["member"], have, key="member") or {} - ) + h_item = search_obj_in_list(w_item["member"], have, key="member") or {} delta = dict_diff(h_item, w_item) if delta: if h_item: @@ -306,9 +291,7 @@ def set_commands(self, w, have): else: if "members" not in obj_in_have: obj_in_have["members"] = None - diff = self.diff_list_of_dicts( - w["members"], obj_in_have["members"] - ) + diff = self.diff_list_of_dicts(w["members"], obj_in_have["members"]) commands = self.add_commands(diff, w["name"]) return commands @@ -325,9 +308,7 @@ def del_intf_commands(self, w, have): commands = [] obj_in_have = search_obj_in_list(w["name"], have, "name") if obj_in_have: - lst_to_del = self.intersect_list_of_dicts( - w["members"], obj_in_have["members"] - ) + lst_to_del = self.intersect_list_of_dicts(w["members"], obj_in_have["members"]) if lst_to_del: for item in lst_to_del: commands.append("interface" + " " + item["member"]) diff --git a/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py b/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py index f338589b7..cfbe9af73 100644 --- a/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py @@ -12,19 +12,19 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_empties, dict_diff, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, + remove_empties, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts + class Lldp_global(ConfigBase): """ @@ -47,9 +47,7 @@ def get_lldp_global_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - lldp_global_facts = facts["ansible_network_resources"].get( - "lldp_global" - ) + lldp_global_facts = facts["ansible_network_resources"].get("lldp_global") if not lldp_global_facts: return {} return lldp_global_facts @@ -130,9 +128,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() @@ -175,9 +171,7 @@ def delete_nested_dict(self, have, want): return inner_dict else: if key in want.keys(): - outer_dict.update( - {key: self.delete_nested_dict(val, want[key])} - ) + outer_dict.update({key: self.delete_nested_dict(val, want[key])}) else: outer_dict.update({key: val}) return outer_dict @@ -193,11 +187,7 @@ def find_delete_params(self, have, want): else: if key == "tlv_select": delete_dict.update( - { - key: self.delete_nested_dict( - have["tlv_select"], want["tlv_select"] - ) - } + {key: self.delete_nested_dict(have["tlv_select"], want["tlv_select"])} ) return delete_dict diff --git a/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py index f96f027c9..40ebba28f 100644 --- a/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py @@ -12,24 +12,24 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, - remove_empties, dict_diff, + remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, - search_obj_in_list, get_interface_type, normalize_interface, + search_obj_in_list, ) @@ -54,9 +54,7 @@ def get_lldp_interfaces_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - lldp_interfaces_facts = facts["ansible_network_resources"].get( - "lldp_interfaces" - ) + lldp_interfaces_facts = facts["ansible_network_resources"].get("lldp_interfaces") if not lldp_interfaces_facts: return [] return lldp_interfaces_facts @@ -154,9 +152,7 @@ def set_state(self, want, have): if state == "merged": commands.extend(self._state_merged(flatten_dict(w), have)) elif state == "replaced": - commands.extend( - self._state_replaced(flatten_dict(w), have) - ) + commands.extend(self._state_replaced(flatten_dict(w), have)) return commands def _state_parsed(self, want): @@ -189,9 +185,7 @@ def _state_replaced(self, want, have): commands = [] del_commands = [] delete_dict = {} - obj_in_have = flatten_dict( - search_obj_in_list(want["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(want["name"], have, "name")) for k1 in obj_in_have.keys(): if k1 not in want.keys(): delete_dict.update({k1: obj_in_have[k1]}) @@ -256,9 +250,7 @@ def _state_deleted(self, want, have): commands = [] if want: for w in want: - obj_in_have = flatten_dict( - search_obj_in_list(w["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(w["name"], have, "name")) commands.extend(self.del_commands(obj_in_have)) else: if not have: @@ -269,9 +261,7 @@ def _state_deleted(self, want, have): def set_commands(self, want, have): commands = [] - obj_in_have = flatten_dict( - search_obj_in_list(want["name"], have, "name") - ) + obj_in_have = flatten_dict(search_obj_in_list(want["name"], have, "name")) if not obj_in_have: commands = self.add_commands(flatten_dict(want)) else: @@ -297,9 +287,7 @@ def add_commands(self, d): else: commands.append("no lldp receive") if "management_address" in d: - commands.append( - "lldp tlv-set management-address " + d["management_address"] - ) + commands.append("lldp tlv-set management-address " + d["management_address"]) if "vlan" in d: commands.append("lldp tlv-set vlan " + str(d["vlan"])) @@ -315,10 +303,7 @@ def del_commands(self, obj): if "receive" in obj: commands.append("lldp receive") if "management_address" in obj: - commands.append( - "no lldp tlv-set management-address " - + obj["management_address"] - ) + commands.append("no lldp tlv-set management-address " + obj["management_address"]) if "vlan" in obj: commands.append("no lldp tlv-set vlan " + str(obj["vlan"])) diff --git a/plugins/module_utils/network/nxos/config/logging_global/logging_global.py b/plugins/module_utils/network/nxos/config/logging_global/logging_global.py index 2de0607bf..91fe7ff29 100644 --- a/plugins/module_utils/network/nxos/config/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/config/logging_global/logging_global.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,22 +21,21 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, - get_from_dict, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - get_logging_sevmap, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, + get_from_dict, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.logging_global import ( Logging_globalTemplate, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + get_logging_sevmap, +) class Logging_global(ResourceModule): diff --git a/plugins/module_utils/network/nxos/config/ntp_global/ntp_global.py b/plugins/module_utils/network/nxos/config/ntp_global/ntp_global.py index 7b485f6de..57a1a58d9 100644 --- a/plugins/module_utils/network/nxos/config/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/nxos/config/ntp_global/ntp_global.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,15 +21,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ntp_global import ( Ntp_globalTemplate, ) @@ -148,9 +148,7 @@ def _ntp_list_to_dict(self, data): if "access_group" in tmp: for x in ["peer", "query_only", "serve", "serve_only"]: if x in tmp["access_group"]: - tmp["access_group"][x] = { - i["access_list"]: i for i in tmp["access_group"][x] - } + tmp["access_group"][x] = {i["access_list"]: i for i in tmp["access_group"][x]} pkey = { "authentication_keys": "id", "peers": "peer", diff --git a/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py index d2084edd8..5897c7f50 100644 --- a/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,15 +21,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospf_interfaces import ( Ospf_interfacesTemplate, ) @@ -92,9 +92,7 @@ def generate_commands(self): # if state is deleted, empty out wantd and set haved to wantd if self.state == "deleted": - haved = { - k: v for k, v in iteritems(haved) if k in wantd or not wantd - } + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} wantd = {} # remove superfluous config for overridden and deleted @@ -115,9 +113,7 @@ def _compare(self, want, have): begin = len(self.commands) self._compare_ospf_interfaces(want, have) if len(self.commands) != begin: - self.commands.insert( - begin, self._tmplt.render(want or have, "interface", False) - ) + self.commands.insert(begin, self._tmplt.render(want or have, "interface", False)) def _compare_ospf_interfaces(self, want, have): waf = want.get("address_family", {}) @@ -136,15 +132,10 @@ def _compare_ospf_interfaces(self, want, have): # this ensures that the "no" form of "ip ospf passive-interface" # command is executed even when there is no existing config - if ( - witem.get("passive_interface") is False - and "passive_interface" not in hitem - ): + if witem.get("passive_interface") is False and "passive_interface" not in hitem: hitem["passive_interface"] = True - if "passive_interface" in hitem and witem.get( - "default_passive_interface" - ): + if "passive_interface" in hitem and witem.get("default_passive_interface"): self.commands.append(self._generate_passive_intf(witem)) self.compare(parsers=self.parsers, want=witem, have=hitem) @@ -152,20 +143,14 @@ def _compare_ospf_interfaces(self, want, have): # compare top-level `multi_areas` config for area in witem.get("multi_areas", []): if area not in hitem.get("multi_areas", []): - self.addcmd( - {"afi": afi, "area": area}, "multi_areas", negate=False - ) + self.addcmd({"afi": afi, "area": area}, "multi_areas", negate=False) # remove superfluous top-level `multi_areas` config for area in hitem.get("multi_areas", []): if area not in witem.get("multi_areas", []): - self.addcmd( - {"afi": afi, "area": area}, "multi_areas", negate=True - ) + self.addcmd({"afi": afi, "area": area}, "multi_areas", negate=True) # compare config->address_family->processes - self._compare_processes( - afi, witem.get("processes", {}), hitem.get("processes", {}) - ) + self._compare_processes(afi, witem.get("processes", {}), hitem.get("processes", {})) def _compare_processes(self, afi, want, have): # add and update config->address_family->processes @@ -182,16 +167,12 @@ def _compare_processes(self, afi, want, have): for area in wproc.get("multi_areas", []): if area not in hproc.get("multi_areas", []): marea_dict["area"] = area - self.addcmd( - marea_dict, "processes_multi_areas", negate=False - ) + self.addcmd(marea_dict, "processes_multi_areas", negate=False) # remove superfluous processes->multi_areas config for area in hproc.get("multi_areas", []): if area not in wproc.get("multi_areas", []): marea_dict["area"] = area - self.addcmd( - marea_dict, "processes_multi_areas", negate=True - ) + self.addcmd(marea_dict, "processes_multi_areas", negate=True) # remove superflous config->address_family->processes for hproc in have.values(): @@ -210,12 +191,10 @@ def _list_to_dict(self, entry): for item in entry.values(): for ag in item.get("address_family", []): ag["processes"] = { - subentry["process_id"]: subentry - for subentry in ag.get("processes", []) + subentry["process_id"]: subentry for subentry in ag.get("processes", []) } item["address_family"] = { - subentry["afi"]: subentry - for subentry in item.get("address_family", []) + subentry["afi"]: subentry for subentry in item.get("address_family", []) } def _generate_passive_intf(self, data): diff --git a/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py b/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py index 0d67e9127..d90a806df 100644 --- a/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,23 +16,21 @@ created """ from copy import deepcopy + from ansible.module_utils.six import iteritems -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospfv2 import ( - Ospfv2Template, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, get_from_dict, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospfv2 import ( + Ospfv2Template, +) + class Ospfv2(ResourceModule): """ @@ -93,14 +92,8 @@ def gen_config(self): :returns: the commands necessary to migrate the current configuration to the desired configuration """ - wantd = { - (entry["process_id"]): entry - for entry in self.want.get("processes", []) - } - haved = { - (entry["process_id"]): entry - for entry in self.have.get("processes", []) - } + wantd = {(entry["process_id"]): entry for entry in self.want.get("processes", [])} + haved = {(entry["process_id"]): entry for entry in self.have.get("processes", [])} # turn all lists of dicts into dicts prior to merge for entry in wantd, haved: @@ -112,9 +105,7 @@ def gen_config(self): # if state is deleted, empty out wantd and set haved to wantd if self.state == "deleted": - haved = { - k: v for k, v in iteritems(haved) if k in wantd or not wantd - } + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} wantd = {} # if state is overridden, first remove processes that are in have but not in want @@ -138,9 +129,7 @@ def _compare(self, want, have): begin, self._tmplt.render( want or have, - "vrf" - if "vrf" in (want.keys() or have.keys()) - else "process_id", + "vrf" if "vrf" in (want.keys() or have.keys()) else "process_id", False, ), ) @@ -205,34 +194,24 @@ def _vrfs_compare(self, want, have): def _ospf_list_to_dict(self, entry): for _pid, proc in iteritems(entry): for area in proc.get("areas", []): - area["ranges"] = { - entry["prefix"]: entry for entry in area.get("ranges", []) - } + area["ranges"] = {entry["prefix"]: entry for entry in area.get("ranges", [])} area["filter_list"] = { - entry["direction"]: entry - for entry in area.get("filter_list", []) + entry["direction"]: entry for entry in area.get("filter_list", []) } mpls_areas = { entry["area_id"]: entry - for entry in proc.get("mpls", {}) - .get("traffic_eng", {}) - .get("areas", []) + for entry in proc.get("mpls", {}).get("traffic_eng", {}).get("areas", []) } if mpls_areas: proc["mpls"]["traffic_eng"]["areas"] = mpls_areas - proc["areas"] = { - entry["area_id"]: entry for entry in proc.get("areas", []) - } + proc["areas"] = {entry["area_id"]: entry for entry in proc.get("areas", [])} proc["summary_address"] = { - entry["prefix"]: entry - for entry in proc.get("summary_address", []) + entry["prefix"]: entry for entry in proc.get("summary_address", []) } proc["redistribute"] = { (entry.get("id"), entry["protocol"]): entry for entry in proc.get("redistribute", []) } if "vrfs" in proc: - proc["vrfs"] = { - entry["vrf"]: entry for entry in proc.get("vrfs", []) - } + proc["vrfs"] = {entry["vrf"]: entry for entry in proc.get("vrfs", [])} self._ospf_list_to_dict(proc["vrfs"]) diff --git a/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py index 464f7f07a..663326a6c 100644 --- a/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,16 +21,15 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, - get_from_dict, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, + get_from_dict, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospfv3 import ( Ospfv3Template, ) @@ -83,14 +83,8 @@ def generate_commands(self): """Generate configuration commands to send based on want, have and desired state. """ - wantd = { - (entry["process_id"]): entry - for entry in self.want.get("processes", []) - } - haved = { - (entry["process_id"]): entry - for entry in self.have.get("processes", []) - } + wantd = {(entry["process_id"]): entry for entry in self.want.get("processes", [])} + haved = {(entry["process_id"]): entry for entry in self.have.get("processes", [])} # turn all lists of dicts into dicts prior to merge for entry in wantd, haved: @@ -102,9 +96,7 @@ def generate_commands(self): # if state is deleted, empty out wantd and set haved to wantd if self.state == "deleted": - haved = { - k: v for k, v in iteritems(haved) if k in wantd or not wantd - } + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} wantd = {} # if state is overridden, first remove processes that are in have but not in want @@ -133,9 +125,7 @@ def _compare(self, want, have): begin, self._tmplt.render( want or have, - "vrf" - if "vrf" in (want.keys() or have.keys()) - else "process_id", + "vrf" if "vrf" in (want.keys() or have.keys()) else "process_id", False, ), ) @@ -221,33 +211,22 @@ def _af_compare_lists(self, want, have): def _ospfv3_list_to_dict(self, entry): for _pid, proc in iteritems(entry): - proc["areas"] = { - entry["area_id"]: entry for entry in proc.get("areas", []) - } + proc["areas"] = {entry["area_id"]: entry for entry in proc.get("areas", [])} af = proc.get("address_family") if af: for area in af.get("areas", []): - area["ranges"] = { - entry["prefix"]: entry - for entry in area.get("ranges", []) - } + area["ranges"] = {entry["prefix"]: entry for entry in area.get("ranges", [])} area["filter_list"] = { - entry["direction"]: entry - for entry in area.get("filter_list", []) + entry["direction"]: entry for entry in area.get("filter_list", []) } - af["areas"] = { - entry["area_id"]: entry for entry in af.get("areas", []) - } + af["areas"] = {entry["area_id"]: entry for entry in af.get("areas", [])} af["summary_address"] = { - entry["prefix"]: entry - for entry in af.get("summary_address", []) + entry["prefix"]: entry for entry in af.get("summary_address", []) } af["redistribute"] = { (entry.get("id"), entry["protocol"]): entry for entry in af.get("redistribute", []) } if "vrfs" in proc: - proc["vrfs"] = { - entry["vrf"]: entry for entry in proc.get("vrfs", []) - } + proc["vrfs"] = {entry["vrf"]: entry for entry in proc.get("vrfs", [])} self._ospfv3_list_to_dict(proc["vrfs"]) diff --git a/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py b/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py index 4bfdae8b4..fafa16591 100644 --- a/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -18,15 +19,14 @@ """ from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.prefix_lists import ( Prefix_listsTemplate, ) @@ -74,18 +74,14 @@ def generate_commands(self): # if state is deleted, empty out wantd and set haved to wantd if self.state == "deleted": - haved = { - k: v for k, v in iteritems(haved) if k in wantd or not wantd - } + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} for key, hvalue in iteritems(haved): wvalue = wantd.pop(key, {}) if wvalue: wplists = wvalue.get("prefix_lists", {}) hplists = hvalue.get("prefix_lists", {}) hvalue["prefix_lists"] = { - k: v - for k, v in iteritems(hplists) - if k in wplists or not wplists + k: v for k, v in iteritems(hplists) if k in wplists or not wplists } # remove superfluous config for overridden and deleted @@ -109,17 +105,13 @@ def _compare(self, want, have): hentry = hplists.pop(wk, {}) self.compare(["description"], want=wentry, have=hentry) # compare sequences - self._compare_seqs( - wentry.pop("entries", {}), hentry.pop("entries", {}) - ) + self._compare_seqs(wentry.pop("entries", {}), hentry.pop("entries", {})) if self.state in ["overridden", "deleted"]: # remove remaining prefix lists for h in hplists.values(): self.commands.append( - "no {0} prefix-list {1}".format( - h["afi"].replace("ipv4", "ip"), h["name"] - ) + "no {0} prefix-list {1}".format(h["afi"].replace("ipv4", "ip"), h["name"]) ) def _compare_seqs(self, want, have): @@ -149,9 +141,5 @@ def _prefix_list_transform(self, entry): if "entries" in plist: for seq in plist["entries"]: seq.update({"afi": afi, "name": plist["name"]}) - plist["entries"] = { - x["sequence"]: x for x in plist["entries"] - } - value["prefix_lists"] = { - entry["name"]: entry for entry in value["prefix_lists"] - } + plist["entries"] = {x["sequence"]: x for x in plist["entries"]} + value["prefix_lists"] = {entry["name"]: entry for entry in value["prefix_lists"]} diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index 12d98ce12..28881745f 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -20,16 +21,15 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, - get_from_dict, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, + get_from_dict, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.route_maps import ( Route_mapsTemplate, ) @@ -127,9 +127,7 @@ def generate_commands(self): # if state is deleted, empty out wantd and set haved to wantd if self.state == "deleted": - haved = { - k: v for k, v in iteritems(haved) if k in wantd or not wantd - } + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} wantd = {} # remove superfluous config for overridden and deleted @@ -137,9 +135,7 @@ def generate_commands(self): for k, have in iteritems(haved): if k not in wantd: for _hk, hentry in iteritems(have.get("entries", {})): - self.commands.append( - self._tmplt.render(hentry, "route_map", True) - ) + self.commands.append(self._tmplt.render(hentry, "route_map", True)) for wk, want in iteritems(wantd): self._compare(want=want, have=haved.pop(wk, {})) @@ -163,9 +159,7 @@ def _compare_entries(self, want, have): self.compare(parsers=self.linear_parsers, want=wentry, have=hentry) if len(self.commands) != begin: - self.commands.insert( - begin, self._tmplt.render(wentry, "route_map", False) - ) + self.commands.insert(begin, self._tmplt.render(wentry, "route_map", False)) # remove superfluos entries from have for _hk, hentry in iteritems(have): self.commands.append(self._tmplt.render(hentry, "route_map", True)) diff --git a/plugins/module_utils/network/nxos/config/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/config/snmp_server/snmp_server.py index cfda84e7c..472e7285f 100644 --- a/plugins/module_utils/network/nxos/config/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/config/snmp_server/snmp_server.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -18,17 +19,17 @@ """ from copy import deepcopy + from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_merge, - get_from_dict, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, + get_from_dict, ) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.snmp_server import ( Snmp_serverTemplate, ) @@ -229,14 +230,10 @@ def _build_key(x): tmp = deepcopy(data) if "communities" in tmp: - tmp["communities"] = { - _build_key(entry): entry for entry in tmp["communities"] - } + tmp["communities"] = {_build_key(entry): entry for entry in tmp["communities"]} if "users" in tmp: if "auth" in tmp["users"]: - tmp["users"]["auth"] = { - _build_key(entry): entry for entry in tmp["users"]["auth"] - } + tmp["users"]["auth"] = {_build_key(entry): entry for entry in tmp["users"]["auth"]} if "use_acls" in tmp["users"]: tmp["users"]["use_acls"] = { entry["user"]: entry for entry in tmp["users"]["use_acls"] diff --git a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py index 59cd58399..8df5cc42d 100644 --- a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py @@ -12,25 +12,26 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type +from copy import deepcopy + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, - remove_empties, dict_diff, + remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) -from copy import deepcopy + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, - search_obj_in_list, get_interface_type, normalize_interface, + search_obj_in_list, ) @@ -55,9 +56,7 @@ def get_static_routes_facts(self, data=None): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - static_routes_facts = facts["ansible_network_resources"].get( - "static_routes" - ) + static_routes_facts = facts["ansible_network_resources"].get("static_routes") if not static_routes_facts: return [] @@ -181,14 +180,10 @@ def _state_replaced(self, want, have): if len(want_afi_list) > 0: for h in obj_in_have["address_families"]: if h["afi"] in want_afi_list: - want_afi = search_obj_in_list( - h["afi"], want["address_families"], "afi" - ) + want_afi = search_obj_in_list(h["afi"], want["address_families"], "afi") want_dest_list = [] if "routes" in want_afi.keys(): - want_dest_list = [ - w["dest"] for w in want_afi["routes"] - ] + want_dest_list = [w["dest"] for w in want_afi["routes"]] if len(want_dest_list) > 0: for ro in h["routes"]: if ro["dest"] in want_dest_list: @@ -197,9 +192,7 @@ def _state_replaced(self, want, have): ) want_next_hops = [] if "next_hops" in want_dest.keys(): - want_next_hops = list( - want_dest["next_hops"] - ) + want_next_hops = list(want_dest["next_hops"]) if len(want_next_hops) > 0: for next_hop in ro["next_hops"]: if next_hop not in want_next_hops: @@ -211,21 +204,15 @@ def _state_replaced(self, want, have): "afi": h["afi"], "routes": [ { - "dest": ro[ - "dest" - ], - "next_hops": [ - next_hop - ], + "dest": ro["dest"], + "next_hops": [next_hop], } ], } ], } delete_commands.extend( - self.del_commands( - [delete_dict] - ) + self.del_commands([delete_dict]) ) else: # want has no next_hops, so delete all next_hops under that dest @@ -237,22 +224,14 @@ def _state_replaced(self, want, have): "afi": h["afi"], "routes": [ { - "dest": ro[ - "dest" - ], - "next_hops": ro[ - "next_hops" - ], + "dest": ro["dest"], + "next_hops": ro["next_hops"], } ], } ], } - delete_commands.extend( - self.del_commands( - [delete_dict] - ) - ) + delete_commands.extend(self.del_commands([delete_dict])) else: if state == "overridden": delete_dict = { @@ -263,17 +242,13 @@ def _state_replaced(self, want, have): "routes": [ { "dest": ro["dest"], - "next_hops": ro[ - "next_hops" - ], + "next_hops": ro["next_hops"], } ], } ], } - delete_commands.extend( - self.del_commands([delete_dict]) - ) + delete_commands.extend(self.del_commands([delete_dict])) else: if ( @@ -289,9 +264,7 @@ def _state_replaced(self, want, have): } ], } - delete_commands.extend( - self.del_commands([delete_dict]) - ) + delete_commands.extend(self.del_commands([delete_dict])) else: if ( state == "overridden" @@ -300,9 +273,7 @@ def _state_replaced(self, want, have): self.del_commands( [ { - "address_families": list( - obj_in_have["address_families"] - ), + "address_families": list(obj_in_have["address_families"]), "vrf": obj_in_have["vrf"], } ] @@ -315,9 +286,7 @@ def _state_replaced(self, want, have): # if there are two afis, 'vrf context..' is added twice fom del_commands. The above code removes the redundant 'vrf context ..' merged_commands = self.set_commands(want, have) if merged_commands: - cmds = set(final_delete_commands).intersection( - set(merged_commands) - ) + cmds = set(final_delete_commands).intersection(set(merged_commands)) for c in cmds: merged_commands.remove(c) @@ -396,20 +365,14 @@ def _state_deleted(self, want, have): "afi": w1["afi"], "routes": [ { - "dest": w2[ - "dest" - ], + "dest": w2["dest"], "next_hops": hops, } ], } ], } - commands.extend( - self.del_commands( - [delete_dict] - ) - ) + commands.extend(self.del_commands([delete_dict])) else: # case when only afi given for delete delete_dict = { @@ -421,9 +384,7 @@ def _state_deleted(self, want, have): } ], } - commands.extend( - self.del_commands([delete_dict]) - ) + commands.extend(self.del_commands([delete_dict])) else: commands.extend( self.del_commands( @@ -476,19 +437,9 @@ def del_commands(self, have): def del_next_hop(self, af, route, next_hop): command = "" if af["afi"] == "ipv4": - command = ( - "no ip route " - + route["dest"] - + " " - + self.add_commands(next_hop) - ) + command = "no ip route " + route["dest"] + " " + self.add_commands(next_hop) else: - command = ( - "no ipv6 route " - + route["dest"] - + " " - + self.add_commands(next_hop) - ) + command = "no ipv6 route " + route["dest"] + " " + self.add_commands(next_hop) return command def add_commands(self, want): @@ -547,25 +498,19 @@ def set_commands(self, want, have): if "next_hops" in ro.keys(): for nh in ro["next_hops"]: if "interface" in nh.keys(): - nh[ - "interface" - ] = normalize_interface( + nh["interface"] = normalize_interface( nh["interface"] ) if nh not in next_hop_list: # no match for next hop in have - commands = ( - self.set_next_hop( - want, - h2, - nh, - ro, - commands, - ) - ) - vrf_list.append( - want["vrf"] + commands = self.set_next_hop( + want, + h2, + nh, + ro, + commands, ) + vrf_list.append(want["vrf"]) else: # no match for dest if "next_hops" in ro.keys(): @@ -578,18 +523,14 @@ def set_commands(self, want, have): if "routes" in af.keys(): for ro in af["routes"]: for nh in ro["next_hops"]: - commands = self.set_next_hop( - want, af, nh, ro, commands - ) + commands = self.set_next_hop(want, af, nh, ro, commands) else: # no match for vrf vrf_list.append(want["vrf"]) for af in want["address_families"]: for ro in af["routes"]: for nh in ro["next_hops"]: - commands = self.set_next_hop( - want, af, nh, ro, commands - ) + commands = self.set_next_hop(want, af, nh, ro, commands) return commands def set_next_hop(self, want, h2, nh, ro, commands): diff --git a/plugins/module_utils/network/nxos/config/telemetry/telemetry.py b/plugins/module_utils/network/nxos/config/telemetry/telemetry.py index f66580447..38749af58 100644 --- a/plugins/module_utils/network/nxos/config/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/config/telemetry/telemetry.py @@ -12,42 +12,34 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.cmdref.telemetry.telemetry import ( - TMS_GLOBAL, TMS_DESTGROUP, + TMS_GLOBAL, TMS_SENSORGROUP, TMS_SUBSCRIPTION, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import NxosCmdRef from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.telemetry.telemetry import ( - normalize_data, - remove_duplicate_context, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.telemetry.telemetry import ( - valiate_input, + get_module_params_subsection, get_setval_path, massage_data, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.telemetry.telemetry import ( - get_module_params_subsection, + normalize_data, remove_duplicate_commands, + remove_duplicate_context, + valiate_input, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( normalize_interface, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - NxosCmdRef, -) class Telemetry(ConfigBase): @@ -89,24 +81,18 @@ def execute_module(self): state = self._module.params["state"] if "overridden" in state: - self._module.fail_json( - msg="State is invalid for this module." - ) + self._module.fail_json(msg="State is invalid for this module.") # When state is 'deleted', the module_params should not contain data # under the 'config' key if "deleted" in state and self._module.params.get("config"): - self._module.fail_json( - msg="Remove config key from playbook when state is " - ) + self._module.fail_json(msg="Remove config key from playbook when state is ") if self._module.params["config"] is None: self._module.params["config"] = {} # Normalize interface name. int = self._module.params["config"].get("source_interface") if int: - self._module.params["config"][ - "source_interface" - ] = normalize_interface(int) + self._module.params["config"]["source_interface"] = normalize_interface(int) if self.state in self.ACTION_STATES: existing_telemetry_facts = self.get_telemetry_facts() @@ -181,12 +167,8 @@ def set_state(self, want, have): # Build Telemetry Global NxosCmdRef Object cmd_ref["TMS_GLOBAL"]["ref"] = [] - self._module.params["config"] = get_module_params_subsection( - ALL_MP, "TMS_GLOBAL" - ) - cmd_ref["TMS_GLOBAL"]["ref"].append( - NxosCmdRef(self._module, TMS_GLOBAL) - ) + self._module.params["config"] = get_module_params_subsection(ALL_MP, "TMS_GLOBAL") + cmd_ref["TMS_GLOBAL"]["ref"].append(NxosCmdRef(self._module, TMS_GLOBAL)) ref = cmd_ref["TMS_GLOBAL"]["ref"][0] ref.set_context() ref.get_existing() @@ -204,25 +186,17 @@ def build_cmdref_objects(td): saved_ids.append(playvals["id"]) resource_key = td["cmd"].format(playvals["id"]) # Only build the NxosCmdRef object for the td['name'] module parameters. - self._module.params[ - "config" - ] = get_module_params_subsection( + self._module.params["config"] = get_module_params_subsection( ALL_MP, td["type"], playvals["id"] ) - cmd_ref[td["type"]]["ref"].append( - NxosCmdRef(self._module, td["obj"]) - ) + cmd_ref[td["type"]]["ref"].append(NxosCmdRef(self._module, td["obj"])) ref = cmd_ref[td["type"]]["ref"][-1] ref.set_context([resource_key]) - if td["type"] == "TMS_SENSORGROUP" and get_setval_path( - self._module - ): + if td["type"] == "TMS_SENSORGROUP" and get_setval_path(self._module): # Sensor group path setting can contain optional values. # Call get_setval_path helper function to process any # optional setval keys. - ref._ref["path"]["setval"] = get_setval_path( - self._module - ) + ref._ref["path"]["setval"] = get_setval_path(self._module) ref.get_existing(device_cache) ref.get_playvals() if td["type"] == "TMS_DESTGROUP": @@ -276,9 +250,7 @@ def _state_replaced(want, have): ref["tms_global"] = NxosCmdRef([], TMS_GLOBAL, ref_only=True) ref["tms_destgroup"] = NxosCmdRef([], TMS_DESTGROUP, ref_only=True) ref["tms_sensorgroup"] = NxosCmdRef([], TMS_SENSORGROUP, ref_only=True) - ref["tms_subscription"] = NxosCmdRef( - [], TMS_SUBSCRIPTION, ref_only=True - ) + ref["tms_subscription"] = NxosCmdRef([], TMS_SUBSCRIPTION, ref_only=True) # Order matters for state replaced. # First remove all subscriptions, followed by sensor-groups and destination-groups. @@ -377,28 +349,20 @@ def _state_replaced(want, have): have_resources = massaged_have.get("destination_groups") if resource == "TMS_SENSORGROUP": name = "sensor-group" - global_ctx = ref["tms_sensorgroup"]._ref["_template"][ - "context" - ] + global_ctx = ref["tms_sensorgroup"]._ref["_template"]["context"] setval = {} - setval["data_source"] = ref["tms_sensorgroup"]._ref[ - "data_source" - ]["setval"] + setval["data_source"] = ref["tms_sensorgroup"]._ref["data_source"]["setval"] setval["path"] = ref["tms_sensorgroup"]._ref["path"]["setval"] want_resources = massaged_want.get("sensor_groups") have_resources = massaged_have.get("sensor_groups") if resource == "TMS_SUBSCRIPTION": name = "subscription" - global_ctx = ref["tms_subscription"]._ref["_template"][ - "context" - ] + global_ctx = ref["tms_subscription"]._ref["_template"]["context"] setval = {} - setval["destination_group"] = ref["tms_subscription"]._ref[ - "destination_group" - ]["setval"] - setval["sensor_group"] = ref["tms_subscription"]._ref[ - "sensor_group" - ]["setval"] + setval["destination_group"] = ref["tms_subscription"]._ref["destination_group"][ + "setval" + ] + setval["sensor_group"] = ref["tms_subscription"]._ref["sensor_group"]["setval"] want_resources = massaged_want.get("subscriptions") have_resources = massaged_have.get("subscriptions") @@ -427,17 +391,11 @@ def _state_replaced(want, have): cmd = {} if item.get("data_source"): cmd["data_source"] = [ - setval["data_source"].format( - item["data_source"] - ) + setval["data_source"].format(item["data_source"]) ] if item.get("path"): - setval["path"] = get_setval_path( - item.get("path") - ) - cmd["path"] = [ - setval["path"].format(**item["path"]) - ] + setval["path"] = get_setval_path(item.get("path")) + cmd["path"] = [setval["path"].format(**item["path"])] add[resource].extend(global_ctx) if property_ctx[0] not in add[resource]: add[resource].extend(property_ctx) @@ -455,17 +413,13 @@ def _state_replaced(want, have): ] if item.get("sensor_group"): cmd["sensor_group"] = [ - setval["sensor_group"].format( - **item["sensor_group"] - ) + setval["sensor_group"].format(**item["sensor_group"]) ] add[resource].extend(global_ctx) if property_ctx[0] not in add[resource]: add[resource].extend(property_ctx) if cmd.get("destination_group"): - add[resource].extend( - cmd["destination_group"] - ) + add[resource].extend(cmd["destination_group"]) if cmd.get("sensor_group"): add[resource].extend(cmd["sensor_group"]) @@ -478,9 +432,7 @@ def _state_replaced(want, have): if item is None: continue # item wanted but does not exist so add it - property_ctx = [ - "{0} {1}".format(name, want_key) - ] + property_ctx = ["{0} {1}".format(name, want_key)] if resource == "TMS_DESTGROUP": cmd = [setval.format(**item[cmd_property])] add[resource].extend(global_ctx) @@ -491,26 +443,16 @@ def _state_replaced(want, have): cmd = {} if item.get("data_source"): cmd["data_source"] = [ - setval["data_source"].format( - item["data_source"] - ) + setval["data_source"].format(item["data_source"]) ] if item.get("path"): - setval["path"] = get_setval_path( - item.get("path") - ) - cmd["path"] = [ - setval["path"].format( - **item["path"] - ) - ] + setval["path"] = get_setval_path(item.get("path")) + cmd["path"] = [setval["path"].format(**item["path"])] add[resource].extend(global_ctx) if property_ctx[0] not in add[resource]: add[resource].extend(property_ctx) if cmd.get("data_source"): - add[resource].extend( - cmd["data_source"] - ) + add[resource].extend(cmd["data_source"]) if cmd.get("path"): add[resource].extend(cmd["path"]) if resource == "TMS_SUBSCRIPTION": @@ -523,21 +465,15 @@ def _state_replaced(want, have): ] if item.get("sensor_group"): cmd["sensor_group"] = [ - setval["sensor_group"].format( - **item["sensor_group"] - ) + setval["sensor_group"].format(**item["sensor_group"]) ] add[resource].extend(global_ctx) if property_ctx[0] not in add[resource]: add[resource].extend(property_ctx) if cmd.get("destination_group"): - add[resource].extend( - cmd["destination_group"] - ) + add[resource].extend(cmd["destination_group"]) if cmd.get("sensor_group"): - add[resource].extend( - cmd["sensor_group"] - ) + add[resource].extend(cmd["sensor_group"]) # process haves: for have_key in have_resources.keys(): @@ -555,14 +491,9 @@ def _state_replaced(want, have): if item is None: continue # have item not wanted so remove it - property_ctx = [ - "{0} {1}".format(name, have_key) - ] + property_ctx = ["{0} {1}".format(name, have_key)] if resource == "TMS_DESTGROUP": - cmd = [ - "no " - + setval.format(**item[cmd_property]) - ] + cmd = ["no " + setval.format(**item[cmd_property])] delete[resource].extend(global_ctx) if property_ctx[0] not in delete[resource]: delete[resource].extend(property_ctx) @@ -572,27 +503,18 @@ def _state_replaced(want, have): if item.get("data_source"): cmd["data_source"] = [ "no " - + setval["data_source"].format( - item["data_source"] - ) + + setval["data_source"].format(item["data_source"]) ] if item.get("path"): - setval["path"] = get_setval_path( - item.get("path") - ) + setval["path"] = get_setval_path(item.get("path")) cmd["path"] = [ - "no " - + setval["path"].format( - **item["path"] - ) + "no " + setval["path"].format(**item["path"]) ] delete[resource].extend(global_ctx) if property_ctx[0] not in delete[resource]: delete[resource].extend(property_ctx) if cmd.get("data_source"): - delete[resource].extend( - cmd["data_source"] - ) + delete[resource].extend(cmd["data_source"]) if cmd.get("path"): delete[resource].extend(cmd["path"]) if resource == "TMS_SUBSCRIPTION": @@ -600,28 +522,22 @@ def _state_replaced(want, have): if item.get("destination_group"): cmd["destination_group"] = [ "no " - + setval[ - "destination_group" - ].format(item["destination_group"]) + + setval["destination_group"].format( + item["destination_group"] + ) ] if item.get("sensor_group"): cmd["sensor_group"] = [ "no " - + setval["sensor_group"].format( - **item["sensor_group"] - ) + + setval["sensor_group"].format(**item["sensor_group"]) ] delete[resource].extend(global_ctx) if property_ctx[0] not in delete[resource]: delete[resource].extend(property_ctx) if cmd.get("destination_group"): - delete[resource].extend( - cmd["destination_group"] - ) + delete[resource].extend(cmd["destination_group"]) if cmd.get("sensor_group"): - delete[resource].extend( - cmd["sensor_group"] - ) + delete[resource].extend(cmd["sensor_group"]) add[resource] = remove_duplicate_context(add[resource]) delete[resource] = remove_duplicate_context(delete[resource]) diff --git a/plugins/module_utils/network/nxos/config/vlans/vlans.py b/plugins/module_utils/network/nxos/config/vlans/vlans.py index ca572ef45..4141cc320 100644 --- a/plugins/module_utils/network/nxos/config/vlans/vlans.py +++ b/plugins/module_utils/network/nxos/config/vlans/vlans.py @@ -13,20 +13,21 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - to_list, remove_empties, + to_list, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, -) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( search_obj_in_list, ) @@ -147,14 +148,9 @@ def set_state(self, want, have): to the desired configuration """ state = self._module.params["state"] - if ( - state in ("overridden", "merged", "replaced", "rendered") - and not want - ): + if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format( - state - ) + msg="value of config parameter must not be empty for state {0}".format(state) ) commands = list() diff --git a/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py index d143ecc3f..4fe468e30 100644 --- a/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py @@ -12,13 +12,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acl_interfaces.acl_interfaces import ( Acl_interfacesArgs, ) @@ -63,9 +65,7 @@ def populate_facts(self, connection, ansible_facts, data=None): for i in range(len(data)): intf = data[i].split("\n") for l in range(1, len(intf)): - if not re.search( - "ip(v6)?( port)? (access-group|traffic-filter)", intf[l] - ): + if not re.search("ip(v6)?( port)? (access-group|traffic-filter)", intf[l]): intf[l] = "" intf = list(filter(None, intf)) resources.append(intf) @@ -80,9 +80,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("acl_interfaces", None) facts = {} if objs: - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) params = utils.remove_empties(params) facts["acl_interfaces"] = params["config"] diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index 9c7c25bbe..217716691 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acls.acls import ( AclsArgs, ) @@ -41,9 +42,7 @@ def __init__(self, module, subspec="config", options="options"): self.generated_spec = utils.generate_dict(facts_argument_spec) def get_device_data(self, connection): - data = connection.get( - "show running-config | section 'ip(v6)* access-list'" - ) + data = connection.get("show running-config | section 'ip(v6)* access-list'") if data == "{}": return "" return data @@ -82,9 +81,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("acls", None) facts = {} if objs: - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) params = utils.remove_empties(params) facts["acls"] = params["config"] @@ -116,9 +113,7 @@ def get_endpoint(self, ace, pro): port_protocol = {} port_pro = re.search(r"(eq|lt|gt|neq) (\w*)", ace) if port_pro: - port_protocol.update( - {port_pro.group(1): port_pro.group(2)} - ) + port_protocol.update({port_pro.group(1): port_pro.group(2)}) ace = re.sub(port_pro.group(1), "", ace, 1) ace = re.sub(port_pro.group(2), "", ace, 1) else: @@ -214,9 +209,7 @@ def render_config(self, spec, conf): acl = acl.split("\n") acl = [a.strip() for a in acl] acl = list(filter(None, acl)) - acls["name"] = re.match( - r"(ip)?(v6)?\s?access-list (.*)", acl[0] - ).group(3) + acls["name"] = re.match(r"(ip)?(v6)?\s?access-list (.*)", acl[0]).group(3) acls["aces"] = [] for ace in list(filter(None, acl[1:])): if re.search(r"^ip(.*)access-list.*", ace): @@ -268,10 +261,7 @@ def render_config(self, spec, conf): for option in protocol_options[pro]: option = re.sub("_", "-", option) if option in ace: - if ( - option == "echo" - and "echo_request" in options - ): + if option == "echo" and "echo_request" in options: continue option = re.sub("-", "_", option) options.update({option: True}) diff --git a/plugins/module_utils/network/nxos/facts/bfd_interfaces/bfd_interfaces.py b/plugins/module_utils/network/nxos/facts/bfd_interfaces/bfd_interfaces.py index 16eb10aea..9d7cceac3 100644 --- a/plugins/module_utils/network/nxos/facts/bfd_interfaces/bfd_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/bfd_interfaces/bfd_interfaces.py @@ -5,6 +5,7 @@ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -12,11 +13,11 @@ Populate the facts tree based on the current device configuration. """ import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bfd_interfaces.bfd_interfaces import ( Bfd_interfacesArgs, ) @@ -53,9 +54,7 @@ def populate_facts(self, connection, ansible_facts, data=None): objs = [] if not data: - data = connection.get( - "show running-config | section '^interface|^feature bfd'" - ) + data = connection.get("show running-config | section '^interface|^feature bfd'") # Some of the bfd attributes if "feature bfd" in data.split("\n"): @@ -73,9 +72,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["bfd_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["bfd_interfaces"].append(utils.remove_empties(cfg)) @@ -101,13 +98,7 @@ def render_config(self, spec, conf): config["name"] = intf # 'bfd'/'bfd echo' do not nvgen when enabled thus set to 'enable' when None. # 'bfd' is not supported on some platforms - config["bfd"] = ( - utils.parse_conf_cmd_arg(conf, "bfd", "enable", "disable") - or "enable" - ) - config["echo"] = ( - utils.parse_conf_cmd_arg(conf, "bfd echo", "enable", "disable") - or "enable" - ) + config["bfd"] = utils.parse_conf_cmd_arg(conf, "bfd", "enable", "disable") or "enable" + config["echo"] = utils.parse_conf_cmd_arg(conf, "bfd echo", "enable", "disable") or "enable" return utils.remove_empties(config) diff --git a/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py index 09cda33d5..97c50ed8c 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,15 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_address_family.bgp_address_family import ( + Bgp_address_familyArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_address_family import ( Bgp_address_familyTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_address_family.bgp_address_family import ( - Bgp_address_familyArgs, -) class Bgp_address_familyFacts(object): @@ -60,9 +60,7 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self._flatten_config(data) # parse native config using the Bgp_address_family template - bgp_address_family_parser = Bgp_address_familyTemplate( - lines=data.splitlines() - ) + bgp_address_family_parser = Bgp_address_familyTemplate(lines=data.splitlines()) objs = bgp_address_family_parser.parse() if objs: nbr = [] @@ -83,9 +81,7 @@ def populate_facts(self, connection, ansible_facts, data=None): key=lambda k, s="prefix": k[s], ) if "networks" in x: - x["networks"] = sorted( - x["networks"], key=lambda k, s="prefix": k[s] - ) + x["networks"] = sorted(x["networks"], key=lambda k, s="prefix": k[s]) if "redistribute" in x: x["redistribute"] = sorted( x["redistribute"], @@ -100,13 +96,9 @@ def populate_facts(self, connection, ansible_facts, data=None): ), ) - ansible_facts["ansible_network_resources"].pop( - "bgp_address_family", None - ) + ansible_facts["ansible_network_resources"].pop("bgp_address_family", None) - params = utils.remove_empties( - utils.validate_config(self.argument_spec, {"config": objs}) - ) + params = utils.remove_empties(utils.validate_config(self.argument_spec, {"config": objs})) facts["bgp_address_family"] = params.get("config", {}) ansible_facts["ansible_network_resources"].update(facts) diff --git a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py index ce48700c0..d0a8a8027 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,15 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_global.bgp_global import ( + Bgp_globalArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_global import ( Bgp_globalTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_global.bgp_global import ( - Bgp_globalArgs, -) class Bgp_globalFacts(object): @@ -59,9 +59,7 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self._flatten_config(data) # parse native config using the Bgp_global template - bgp_global_parser = Bgp_globalTemplate( - lines=data.splitlines(), module=self._module - ) + bgp_global_parser = Bgp_globalTemplate(lines=data.splitlines(), module=self._module) obj = bgp_global_parser.parse() vrfs = obj.get("vrfs", {}) @@ -75,9 +73,7 @@ def populate_facts(self, connection, ansible_facts, data=None): # transform vrfs into a list if vrfs: - obj["vrfs"] = sorted( - list(obj["vrfs"].values()), key=lambda k, sk="vrf": k[sk] - ) + obj["vrfs"] = sorted(list(obj["vrfs"].values()), key=lambda k, sk="vrf": k[sk]) for vrf in obj["vrfs"]: self._post_parse(vrf) @@ -87,9 +83,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("bgp_global", None) params = utils.remove_empties( - bgp_global_parser.validate_config( - self.argument_spec, {"config": obj}, redact=True - ) + bgp_global_parser.validate_config(self.argument_spec, {"config": obj}, redact=True) ) facts["bgp_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 778b18236..681154bce 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,16 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_neighbor_address_family import ( - Bgp_neighbor_address_familyTemplate, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_neighbor_address_family.bgp_neighbor_address_family import ( Bgp_neighbor_address_familyArgs, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_neighbor_address_family import ( + Bgp_neighbor_address_familyTemplate, +) class Bgp_neighbor_address_familyFacts(object): @@ -61,29 +60,21 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self._flatten_config(data) # parse native config using the Bgp_neighbor_address_family template - bgp_neighbor_address_family_parser = ( - Bgp_neighbor_address_familyTemplate(lines=data) - ) + bgp_neighbor_address_family_parser = Bgp_neighbor_address_familyTemplate(lines=data) objs = bgp_neighbor_address_family_parser.parse() if objs: top_lvl_nbrs = objs.get("vrfs", {}).pop("vrf_", {}) - objs["neighbors"] = self._post_parse(top_lvl_nbrs).get( - "neighbors", [] - ) + objs["neighbors"] = self._post_parse(top_lvl_nbrs).get("neighbors", []) if "vrfs" in objs: for vrf in objs["vrfs"].values(): vrf["neighbors"] = self._post_parse(vrf)["neighbors"] objs["vrfs"] = list(objs["vrfs"].values()) - ansible_facts["ansible_network_resources"].pop( - "bgp_neighbor_address_family", None - ) + ansible_facts["ansible_network_resources"].pop("bgp_neighbor_address_family", None) - params = utils.remove_empties( - utils.validate_config(self.argument_spec, {"config": objs}) - ) + params = utils.remove_empties(utils.validate_config(self.argument_spec, {"config": objs})) facts["bgp_neighbor_address_family"] = params.get("config", {}) ansible_facts["ansible_network_resources"].update(facts) diff --git a/plugins/module_utils/network/nxos/facts/facts.py b/plugins/module_utils/network/nxos/facts/facts.py index 3291f2026..04eeb9c40 100644 --- a/plugins/module_utils/network/nxos/facts/facts.py +++ b/plugins/module_utils/network/nxos/facts/facts.py @@ -5,6 +5,7 @@ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type """ The facts class for nxos @@ -14,17 +15,28 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts import ( FactsBase, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.legacy.base import ( - Default, - Legacy, - Hardware, - Config, - Interfaces, - Features, + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acl_interfaces.acl_interfaces import ( + Acl_interfacesFacts, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acls.acls import ( + AclsFacts, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bfd_interfaces.bfd_interfaces import ( Bfd_interfacesFacts, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_address_family.bgp_address_family import ( + Bgp_address_familyFacts, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_global.bgp_global import ( + Bgp_globalFacts, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_neighbor_address_family.bgp_neighbor_address_family import ( + Bgp_neighbor_address_familyFacts, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname import ( + HostnameFacts, +) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hsrp_interfaces.hsrp_interfaces import ( Hsrp_interfacesFacts, ) @@ -34,23 +46,25 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.l2_interfaces.l2_interfaces import ( L2_interfacesFacts, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.l3_interfaces.l3_interfaces import ( + L3_interfacesFacts, +) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lacp.lacp import ( LacpFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.l3_interfaces.l3_interfaces import ( - L3_interfacesFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lacp_interfaces.lacp_interfaces import ( + Lacp_interfacesFacts, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lag_interfaces.lag_interfaces import ( Lag_interfacesFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.telemetry.telemetry import ( - TelemetryFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.vlans.vlans import ( - VlansFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lacp_interfaces.lacp_interfaces import ( - Lacp_interfacesFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.legacy.base import ( + Config, + Default, + Features, + Hardware, + Interfaces, + Legacy, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lldp_global.lldp_global import ( Lldp_globalFacts, @@ -58,14 +72,14 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lldp_interfaces.lldp_interfaces import ( Lldp_interfacesFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acl_interfaces.acl_interfaces import ( - Acl_interfacesFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.logging_global.logging_global import ( + Logging_globalFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acls.acls import ( - AclsFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ntp_global.ntp_global import ( + Ntp_globalFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.static_routes.static_routes import ( - Static_routesFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospf_interfaces.ospf_interfaces import ( + Ospf_interfacesFacts, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospfv2.ospfv2 import ( Ospfv2Facts, @@ -73,35 +87,23 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospfv3.ospfv3 import ( Ospfv3Facts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospf_interfaces.ospf_interfaces import ( - Ospf_interfacesFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_global.bgp_global import ( - Bgp_globalFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_address_family.bgp_address_family import ( - Bgp_address_familyFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_neighbor_address_family.bgp_neighbor_address_family import ( - Bgp_neighbor_address_familyFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.route_maps.route_maps import ( - Route_mapsFacts, -) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.prefix_lists.prefix_lists import ( Prefix_listsFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.logging_global.logging_global import ( - Logging_globalFacts, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ntp_global.ntp_global import ( - Ntp_globalFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.route_maps.route_maps import ( + Route_mapsFacts, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.snmp_server.snmp_server import ( Snmp_serverFacts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname import ( - HostnameFacts, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.static_routes.static_routes import ( + Static_routesFacts, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.telemetry.telemetry import ( + TelemetryFacts, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.vlans.vlans import ( + VlansFacts, ) @@ -153,9 +155,7 @@ class Facts(FactsBase): def __init__(self, module): super(Facts, self).__init__(module) - def get_facts( - self, legacy_facts_type=None, resource_facts_type=None, data=None - ): + def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None): """Collect the facts for nxos :param legacy_facts_type: List of legacy facts types :param resource_facts_type: List of resource fact types @@ -164,13 +164,9 @@ def get_facts( :return: the facts gathered """ if self.VALID_RESOURCE_SUBSETS: - self.get_network_resources_facts( - FACT_RESOURCE_SUBSETS, resource_facts_type, data - ) + self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data) if self.VALID_LEGACY_GATHER_SUBSETS: - self.get_network_legacy_facts( - FACT_LEGACY_SUBSETS, legacy_facts_type - ) + self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type) return self.ansible_facts, self._warnings diff --git a/plugins/module_utils/network/nxos/facts/hostname/hostname.py b/plugins/module_utils/network/nxos/facts/hostname/hostname.py index e38a3ae3b..61666c7fa 100644 --- a/plugins/module_utils/network/nxos/facts/hostname/hostname.py +++ b/plugins/module_utils/network/nxos/facts/hostname/hostname.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,15 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.hostname.hostname import ( + HostnameArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.hostname import ( HostnameTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.hostname.hostname import ( - HostnameArgs, -) class HostnameFacts(object): @@ -58,17 +58,13 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self.get_config(connection) # parse native config using the Hostname template - hostname_parser = HostnameTemplate( - lines=data.splitlines(), module=self._module - ) + hostname_parser = HostnameTemplate(lines=data.splitlines(), module=self._module) objs = hostname_parser.parse() ansible_facts["ansible_network_resources"].pop("hostname", None) params = utils.remove_empties( - hostname_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) ) facts["hostname"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/hsrp_interfaces/hsrp_interfaces.py b/plugins/module_utils/network/nxos/facts/hsrp_interfaces/hsrp_interfaces.py index 644ab3763..d12e32233 100644 --- a/plugins/module_utils/network/nxos/facts/hsrp_interfaces/hsrp_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/hsrp_interfaces/hsrp_interfaces.py @@ -5,6 +5,7 @@ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -12,11 +13,11 @@ Populate the facts tree based on the current device configuration. """ import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.hsrp_interfaces.hsrp_interfaces import ( Hsrp_interfacesArgs, ) @@ -66,9 +67,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["hsrp_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["hsrp_interfaces"].append(utils.remove_empties(cfg)) @@ -92,8 +91,6 @@ def render_config(self, spec, conf): if get_interface_type(intf) == "unknown": return {} config["name"] = intf - config["bfd"] = utils.parse_conf_cmd_arg( - conf, "hsrp bfd", "enable", "disable" - ) + config["bfd"] = utils.parse_conf_cmd_arg(conf, "hsrp bfd", "enable", "disable") return utils.remove_empties(config) diff --git a/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py b/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py index 106f4adcf..9e4462048 100644 --- a/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py @@ -11,23 +11,24 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.interfaces.interfaces import ( InterfacesArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - get_interface_type, -) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( default_intf_enabled, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + get_interface_type, +) class InterfacesFacts(object): @@ -70,9 +71,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} facts["interfaces"] = [] if objs: - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["interfaces"].append(utils.remove_empties(cfg)) @@ -99,20 +98,14 @@ def render_config(self, spec, conf): config["speed"] = utils.parse_conf_arg(conf, "speed") config["mtu"] = utils.parse_conf_arg(conf, "mtu") config["duplex"] = utils.parse_conf_arg(conf, "duplex") - config["mode"] = utils.parse_conf_cmd_arg( - conf, "switchport", "layer2", "layer3" - ) + config["mode"] = utils.parse_conf_cmd_arg(conf, "switchport", "layer2", "layer3") - config["enabled"] = utils.parse_conf_cmd_arg( - conf, "shutdown", False, True - ) + config["enabled"] = utils.parse_conf_cmd_arg(conf, "shutdown", False, True) config["fabric_forwarding_anycast_gateway"] = utils.parse_conf_cmd_arg( conf, "fabric forwarding mode anycast-gateway", True ) - config["ip_forward"] = utils.parse_conf_cmd_arg( - conf, "ip forward", True - ) + config["ip_forward"] = utils.parse_conf_cmd_arg(conf, "ip forward", True) interfaces_cfg = utils.remove_empties(config) return interfaces_cfg diff --git a/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py index 8655be88f..2bd45f7b4 100644 --- a/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.l2_interfaces.l2_interfaces import ( L2_interfacesArgs, ) @@ -67,9 +68,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["l2_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["l2_interfaces"].append(utils.remove_empties(cfg)) @@ -95,14 +94,10 @@ def render_config(self, spec, conf): config["name"] = intf config["mode"] = utils.parse_conf_arg(conf, "switchport mode") config["ip_forward"] = utils.parse_conf_arg(conf, "ip forward") - config["access"]["vlan"] = utils.parse_conf_arg( - conf, "switchport access vlan" - ) + config["access"]["vlan"] = utils.parse_conf_arg(conf, "switchport access vlan") config["trunk"]["allowed_vlans"] = utils.parse_conf_arg( conf, "switchport trunk allowed vlan" ) - config["trunk"]["native_vlan"] = utils.parse_conf_arg( - conf, "switchport trunk native vlan" - ) + config["trunk"]["native_vlan"] = utils.parse_conf_arg(conf, "switchport trunk native vlan") return utils.remove_empties(config) diff --git a/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py index 663ccc669..71c1e1620 100644 --- a/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.l3_interfaces.l3_interfaces import ( L3_interfacesArgs, ) @@ -67,9 +68,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["l3_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["l3_interfaces"].append(utils.remove_empties(cfg)) @@ -92,15 +91,9 @@ def render_config(self, spec, conf): return {} config["name"] = intf config["dot1q"] = utils.parse_conf_arg(conf, "encapsulation dot1[qQ]") - config["redirects"] = utils.parse_conf_cmd_arg( - conf, "no ip redirects", False, True - ) - config["unreachables"] = utils.parse_conf_cmd_arg( - conf, "ip unreachables", True, False - ) - config["evpn_multisite_tracking"] = utils.parse_conf_arg( - conf, "evpn multisite" - ) + config["redirects"] = utils.parse_conf_cmd_arg(conf, "no ip redirects", False, True) + config["unreachables"] = utils.parse_conf_cmd_arg(conf, "ip unreachables", True, False) + config["evpn_multisite_tracking"] = utils.parse_conf_arg(conf, "evpn multisite") ipv4_match = re.compile(r"\n ip address (.*)") matches = ipv4_match.findall(conf) if matches: @@ -117,9 +110,7 @@ def render_config(self, spec, conf): config_dict.update({"secondary": True}) if len(ipv4_conf) == 4: if ipv4_conf[2] == "tag": - config_dict.update( - {"tag": int(ipv4_conf[-1])} - ) + config_dict.update({"tag": int(ipv4_conf[-1])}) elif d == "tag": config_dict.update({"tag": int(ipv4_conf[-1])}) config["ipv4"].append(config_dict) diff --git a/plugins/module_utils/network/nxos/facts/lacp/lacp.py b/plugins/module_utils/network/nxos/facts/lacp/lacp.py index b2c7bd708..51b1413da 100644 --- a/plugins/module_utils/network/nxos/facts/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/facts/lacp/lacp.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lacp.lacp import ( LacpArgs, ) @@ -56,9 +57,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("lacp", None) facts = {} if objs: - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) facts["lacp"] = utils.remove_empties(params["config"]) ansible_facts["ansible_network_resources"].update(facts) return ansible_facts @@ -83,9 +82,7 @@ def render_config(self, spec, conf): if a_match: address = a_match.group(1) config["system"]["mac"]["address"] = address - r_match = re.search( - r"lacp system-mac {0} role (\S+)".format(address), conf, re.M - ) + r_match = re.search(r"lacp system-mac {0} role (\S+)".format(address), conf, re.M) if r_match: config["system"]["mac"]["role"] = r_match.group(1) diff --git a/plugins/module_utils/network/nxos/facts/lacp_interfaces/lacp_interfaces.py b/plugins/module_utils/network/nxos/facts/lacp_interfaces/lacp_interfaces.py index cd5d12380..c60d8abd0 100644 --- a/plugins/module_utils/network/nxos/facts/lacp_interfaces/lacp_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/lacp_interfaces/lacp_interfaces.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lacp_interfaces.lacp_interfaces import ( Lacp_interfacesArgs, ) @@ -68,9 +69,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["lacp_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["lacp_interfaces"].append(utils.remove_empties(cfg)) @@ -94,9 +93,7 @@ def render_config(self, spec, conf): if get_interface_type(intf) == "unknown": return {} config["name"] = intf - config["port_priority"] = utils.parse_conf_arg( - conf, "lacp port-priority" - ) + config["port_priority"] = utils.parse_conf_arg(conf, "lacp port-priority") config["rate"] = utils.parse_conf_arg(conf, "lacp rate") config["mode"] = utils.parse_conf_arg(conf, "lacp mode") suspend_individual = re.search(r"no lacp suspend-individual", conf) diff --git a/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py index 5253923a5..f8c0db797 100644 --- a/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lag_interfaces.lag_interfaces import ( Lag_interfacesArgs, ) @@ -62,9 +63,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["lag_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["lag_interfaces"].append(utils.remove_empties(cfg)) @@ -101,9 +100,7 @@ def render_config(self, spec, conf, connection): member.update(match_line.groupdict()) if member and member.get("port_channel", None): - port_channel = "port-channel{0}".format( - member.pop("port_channel") - ) + port_channel = "port-channel{0}".format(member.pop("port_channel")) for x in result: if x["name"] == port_channel: x["members"].append(utils.remove_empties(member)) diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index 5619db82d..87052dbcf 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -4,21 +4,23 @@ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type import platform import re +from ansible.module_utils.six import iteritems + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - run_commands, - get_config, get_capabilities, + get_config, + run_commands, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( get_interface_type, normalize_interface, ) -from ansible.module_utils.six import iteritems g_config = None @@ -42,8 +44,7 @@ def run(self, command, output="text"): return resp[0] except IndexError: self.warnings.append( - "command %s failed, facts for this command will not be populated" - % command_string + "command %s failed, facts for this command will not be populated" % command_string ) return None @@ -139,12 +140,8 @@ def populate(self): if data: if isinstance(data, dict): - self.facts["memtotal_mb"] = ( - int(data["memory_usage_total"]) / 1024 - ) - self.facts["memfree_mb"] = ( - int(data["memory_usage_free"]) / 1024 - ) + self.facts["memtotal_mb"] = int(data["memory_usage_total"]) / 1024 + self.facts["memfree_mb"] = int(data["memory_usage_free"]) / 1024 else: self.facts["memtotal_mb"] = self.parse_memtotal_mb(data) self.facts["memfree_mb"] = self.parse_memfree_mb(data) @@ -191,13 +188,9 @@ class Interfaces(FactsBase): ] ) - INTERFACE_IPV4_MAP = frozenset( - [("eth_ip_addr", "address"), ("eth_ip_mask", "masklen")] - ) + INTERFACE_IPV4_MAP = frozenset([("eth_ip_addr", "address"), ("eth_ip_mask", "masklen")]) - INTERFACE_SVI_IPV4_MAP = frozenset( - [("svi_ip_addr", "address"), ("svi_ip_mask", "masklen")] - ) + INTERFACE_SVI_IPV4_MAP = frozenset([("svi_ip_addr", "address"), ("svi_ip_mask", "masklen")]) INTERFACE_IPV6_MAP = frozenset([("addr", "address"), ("prefix", "subnet")]) @@ -221,9 +214,7 @@ def populate(self): if data: if isinstance(data, dict): - self.facts["interfaces"] = self.populate_structured_interfaces( - data - ) + self.facts["interfaces"] = self.populate_structured_interfaces(data) else: interfaces = self.parse_interfaces(data) self.facts["interfaces"] = self.populate_interfaces(interfaces) @@ -242,22 +233,16 @@ def populate(self): data = self.run("show lldp neighbors", output="json") if data: if isinstance(data, dict): - self.facts["neighbors"].update( - self.populate_structured_neighbors_lldp(data) - ) + self.facts["neighbors"].update(self.populate_structured_neighbors_lldp(data)) else: self.facts["neighbors"].update(self.populate_neighbors(data)) data = self.run("show cdp neighbors detail", output="json") if data: if isinstance(data, dict): - self.facts["neighbors"].update( - self.populate_structured_neighbors_cdp(data) - ) + self.facts["neighbors"].update(self.populate_structured_neighbors_cdp(data)) else: - self.facts["neighbors"].update( - self.populate_neighbors_cdp(data) - ) + self.facts["neighbors"].update(self.populate_neighbors_cdp(data)) self.facts["neighbors"].pop(None, None) # Remove null key @@ -278,15 +263,11 @@ def populate_structured_interfaces(self, data): intf.update(self.transform_dict(item, self.INTERFACE_MAP)) if "eth_ip_addr" in item: - intf["ipv4"] = self.transform_dict( - item, self.INTERFACE_IPV4_MAP - ) + intf["ipv4"] = self.transform_dict(item, self.INTERFACE_IPV4_MAP) self.facts["all_ipv4_addresses"].append(item["eth_ip_addr"]) if "svi_ip_addr" in item: - intf["ipv4"] = self.transform_dict( - item, self.INTERFACE_SVI_IPV4_MAP - ) + intf["ipv4"] = self.transform_dict(item, self.INTERFACE_SVI_IPV4_MAP) self.facts["all_ipv4_addresses"].append(item["svi_ip_addr"]) interfaces[name] = intf @@ -302,15 +283,11 @@ def populate_structured_ipv6_interfaces(self, data): for item in data: name = item["ROW_intf"]["intf-name"] intf = self.facts["interfaces"][name] - intf["ipv6"] = self.transform_dict( - item, self.INTERFACE_IPV6_MAP - ) + intf["ipv6"] = self.transform_dict(item, self.INTERFACE_IPV6_MAP) try: addr = item["ROW_intf"]["addr"] except KeyError: - addr = item["ROW_intf"]["TABLE_addr"]["ROW_addr"][ - "addr" - ] + addr = item["ROW_intf"]["TABLE_addr"]["ROW_addr"]["addr"] self.facts["all_ipv6_addresses"].append(addr) else: return "" @@ -336,9 +313,7 @@ def populate_structured_neighbors_lldp(self, data): def populate_structured_neighbors_cdp(self, data): objects = dict() - data = data["TABLE_cdp_neighbor_detail_info"][ - "ROW_cdp_neighbor_detail_info" - ] + data = data["TABLE_cdp_neighbor_detail_info"]["ROW_cdp_neighbor_detail_info"] if isinstance(data, dict): data = [data] @@ -369,9 +344,7 @@ def parse_interfaces(self, data): match = re.match(r"^(\S+)", line) if match: key = match.group(1) - if not key.startswith("admin") or not key.startswith( - "IPv6 Interface" - ): + if not key.startswith("admin") or not key.startswith("IPv6 Interface"): parsed[key] = line return parsed @@ -381,18 +354,12 @@ def populate_interfaces(self, interfaces): intf = dict() if get_interface_type(key) == "svi": intf["state"] = self.parse_state(key, value, intf_type="svi") - intf["macaddress"] = self.parse_macaddress( - value, intf_type="svi" - ) + intf["macaddress"] = self.parse_macaddress(value, intf_type="svi") intf["mtu"] = self.parse_mtu(value, intf_type="svi") - intf["bandwidth"] = self.parse_bandwidth( - value, intf_type="svi" - ) + intf["bandwidth"] = self.parse_bandwidth(value, intf_type="svi") intf["type"] = self.parse_type(value, intf_type="svi") if "Internet Address" in value: - intf["ipv4"] = self.parse_ipv4_address( - value, intf_type="svi" - ) + intf["ipv4"] = self.parse_ipv4_address(value, intf_type="svi") facts[key] = intf else: intf["state"] = self.parse_state(key, value) @@ -616,9 +583,7 @@ def populate(self): data = self.run("show interface", output="json") if data: if isinstance(data, dict): - self.facts[ - "interfaces_list" - ] = self.parse_structured_interfaces(data) + self.facts["interfaces_list"] = self.parse_structured_interfaces(data) else: self.facts["interfaces_list"] = self.parse_interfaces(data) @@ -646,13 +611,9 @@ def populate(self): data = self.run("show environment power", output="json") if data: if isinstance(data, dict): - self.facts[ - "power_supply_info" - ] = self.parse_structured_power_supply_info(data) + self.facts["power_supply_info"] = self.parse_structured_power_supply_info(data) else: - self.facts["power_supply_info"] = self.parse_power_supply_info( - data - ) + self.facts["power_supply_info"] = self.parse_power_supply_info(data) def parse_structured_interfaces(self, data): objects = list() diff --git a/plugins/module_utils/network/nxos/facts/lldp_global/lldp_global.py b/plugins/module_utils/network/nxos/facts/lldp_global/lldp_global.py index c25a9e7ab..6e8aabde2 100644 --- a/plugins/module_utils/network/nxos/facts/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/nxos/facts/lldp_global/lldp_global.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lldp_global.lldp_global import ( Lldp_globalArgs, ) @@ -58,9 +59,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("lldp_global", None) facts = {} if objs: - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) facts["lldp_global"] = params["config"] facts = utils.remove_empties(facts) ansible_facts["ansible_network_resources"].update((facts)) @@ -79,9 +78,7 @@ def render_config(self, spec, conf): config = deepcopy(spec) conf = re.split("\n", conf) for command in conf: - param = re.search( - r"(.*)lldp (\w+(-?)\w+)", command - ) # get the word after 'lldp' + param = re.search(r"(.*)lldp (\w+(-?)\w+)", command) # get the word after 'lldp' if param: # get the nested-dict/value for that param key2 = re.search(r"%s(.*)" % param.group(2), command) @@ -95,9 +92,7 @@ def render_config(self, spec, conf): key2 = key2.split() key2[0] = key2[0].replace("-", "_") if len(key2) == 1: - if ( - "port" in key2[0] or "system" in key2[0] - ): # nested dicts + if "port" in key2[0] or "system" in key2[0]: # nested dicts key2 = key2[0].split("_") # config[tlv_select][system][name]=False config[key1][key2[0]][key2[1]] = False diff --git a/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py index 09ec886ee..f63ee86bb 100644 --- a/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py @@ -11,14 +11,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lldp_interfaces.lldp_interfaces import ( Lldp_interfacesArgs, ) @@ -82,9 +83,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["lldp_interfaces"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["lldp_interfaces"].append(utils.remove_empties(cfg)) diff --git a/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py b/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py index 57b944c45..51b14fe9d 100644 --- a/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,17 +18,16 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - get_logging_sevmap, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.logging_global.logging_global import ( + Logging_globalArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.logging_global import ( Logging_globalTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.logging_global.logging_global import ( - Logging_globalArgs, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + get_logging_sevmap, ) @@ -62,9 +62,7 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self.get_config(connection) # parse native config using the Logging_global template - logging_global_parser = Logging_globalTemplate( - lines=data.splitlines(), module=self._module - ) + logging_global_parser = Logging_globalTemplate(lines=data.splitlines(), module=self._module) objs = logging_global_parser.parse() if objs: @@ -83,9 +81,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("logging_global", None) params = utils.remove_empties( - logging_global_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + logging_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) ) facts["logging_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py b/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py index 81e11fee5..b46955254 100644 --- a/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,15 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ntp_global.ntp_global import ( + Ntp_globalArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ntp_global import ( Ntp_globalTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ntp_global.ntp_global import ( - Ntp_globalArgs, -) class Ntp_globalFacts(object): @@ -58,9 +58,7 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self.get_config(connection) # parse native config using the Ntp_global template - ntp_global_parser = Ntp_globalTemplate( - lines=data.splitlines(), module=self._module - ) + ntp_global_parser = Ntp_globalTemplate(lines=data.splitlines(), module=self._module) objs = ntp_global_parser.parse() if "access_group" in objs: @@ -84,9 +82,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("ntp_global", None) params = utils.remove_empties( - ntp_global_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + ntp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) ) facts["ntp_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py index b5c78ce9b..83ac2186f 100644 --- a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,15 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospf_interfaces.ospf_interfaces import ( + Ospf_interfacesArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospf_interfaces import ( Ospf_interfacesTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospf_interfaces.ospf_interfaces import ( - Ospf_interfacesArgs, -) class Ospf_interfacesFacts(object): @@ -71,15 +71,11 @@ def populate_facts(self, connection, ansible_facts, data=None): af["processes"] = list(af["processes"].values()) if af.get("multi_areas"): af["multi_areas"].sort() - item["address_family"] = sorted( - item["address_family"], key=lambda i: i["afi"] - ) + item["address_family"] = sorted(item["address_family"], key=lambda i: i["afi"]) objs = sorted( objs, - key=lambda i: [ - int(k) if k.isdigit() else k for k in i["name"].split("/") - ], + key=lambda i: [int(k) if k.isdigit() else k for k in i["name"].split("/")], ) ansible_facts["ansible_network_resources"].pop("ospf_interfaces", None) diff --git a/plugins/module_utils/network/nxos/facts/ospfv2/ospfv2.py b/plugins/module_utils/network/nxos/facts/ospfv2/ospfv2.py index f49a46e64..248f3ed49 100644 --- a/plugins/module_utils/network/nxos/facts/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/nxos/facts/ospfv2/ospfv2.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -16,15 +17,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospfv2 import ( - Ospfv2Template, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospfv2.ospfv2 import ( Ospfv2Args, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospfv2 import ( + Ospfv2Template, +) class Ospfv2Facts(object): @@ -48,9 +48,7 @@ def get_config(self, connection): """Wrapper method for `connection.get()` This method exists solely to allow the unit test framework to mock device connection calls. """ - return connection.get( - "show running-config | section '^router ospf .*'" - ) + return connection.get("show running-config | section '^router ospf .*'") def populate_facts(self, connection, ansible_facts, data=None): """Populate the facts for interfaces diff --git a/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py index c739683e4..ead7a4008 100644 --- a/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -16,15 +17,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospfv3.ospfv3 import ( + Ospfv3Args, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.ospfv3 import ( Ospfv3Template, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospfv3.ospfv3 import ( - Ospfv3Args, -) class Ospfv3Facts(object): diff --git a/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py b/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py index 0a9b97d72..0ce50d4e2 100644 --- a/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -14,15 +15,14 @@ based on the configuration. """ -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.prefix_lists.prefix_lists import ( + Prefix_listsArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.prefix_lists import ( Prefix_listsTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.prefix_lists.prefix_lists import ( - Prefix_listsArgs, -) class Prefix_listsFacts(object): @@ -36,9 +36,7 @@ def get_config(self, connection): """Wrapper method for `connection.get()` This method exists solely to allow the unit test framework to mock device connection calls. """ - return connection.get( - "show running-config | section 'ip(.*) prefix-list'" - ) + return connection.get("show running-config | section 'ip(.*) prefix-list'") def populate_facts(self, connection, ansible_facts, data=None): """Populate the facts for Prefix_lists network resource @@ -56,9 +54,7 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self.get_config(connection) # parse native config using the Prefix_lists template - prefix_lists_parser = Prefix_listsTemplate( - lines=data.splitlines(), module=self._module - ) + prefix_lists_parser = Prefix_listsTemplate(lines=data.splitlines(), module=self._module) objs = list(prefix_lists_parser.parse().values()) if objs: @@ -70,16 +66,12 @@ def populate_facts(self, connection, ansible_facts, data=None): ) for x in item["prefix_lists"]: if "entries" in x: - x["entries"] = sorted( - x["entries"], key=lambda k: k["sequence"] - ) + x["entries"] = sorted(x["entries"], key=lambda k: k["sequence"]) objs = sorted(objs, key=lambda k: k["afi"]) ansible_facts["ansible_network_resources"].pop("prefix_lists", None) params = utils.remove_empties( - prefix_lists_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) ) facts["prefix_lists"] = params.get("config", []) ansible_facts["ansible_network_resources"].update(facts) diff --git a/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py b/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py index 4829860f0..637c441be 100644 --- a/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -17,15 +18,14 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.route_maps.route_maps import ( + Route_mapsArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.route_maps import ( Route_mapsTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.route_maps.route_maps import ( - Route_mapsArgs, -) class Route_mapsFacts(object): @@ -58,9 +58,7 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self.get_config(connection) # parse native config using the Route_maps template - route_maps_parser = Route_mapsTemplate( - lines=data.splitlines(), module=self._module - ) + route_maps_parser = Route_mapsTemplate(lines=data.splitlines(), module=self._module) objs = list(route_maps_parser.parse().values()) @@ -70,9 +68,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("route_maps", None) params = utils.remove_empties( - route_maps_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + route_maps_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) ) facts["route_maps"] = params.get("config", []) diff --git a/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py index d958ab28e..3c1405c22 100644 --- a/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -14,15 +15,14 @@ based on the configuration. """ from ansible.module_utils._text import to_text -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.snmp_server.snmp_server import ( + Snmp_serverArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.snmp_server import ( Snmp_serverTemplate, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.snmp_server.snmp_server import ( - Snmp_serverArgs, -) class Snmp_serverFacts(object): @@ -55,15 +55,11 @@ def populate_facts(self, connection, ansible_facts, data=None): data = self.get_config(connection) # parse native config using the Snmp_server template - snmp_server_parser = Snmp_serverTemplate( - lines=data.splitlines(), module=self._module - ) + snmp_server_parser = Snmp_serverTemplate(lines=data.splitlines(), module=self._module) objs = snmp_server_parser.parse() if "communities" in objs: - objs["communities"] = sorted( - objs["communities"], key=lambda k: to_text(k["name"]) - ) + objs["communities"] = sorted(objs["communities"], key=lambda k: to_text(k["name"])) if "users" in objs: if "auth" in objs["users"]: @@ -78,9 +74,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("snmp_server", None) params = utils.remove_empties( - snmp_server_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) ) facts["snmp_server"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py b/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py index 53605fc12..b62d25805 100644 --- a/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py @@ -12,13 +12,15 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.static_routes.static_routes import ( Static_routesArgs, ) @@ -45,12 +47,8 @@ def get_device_data(self, connection, data): vrf_data = [] non_vrf_data = [] if not data: - non_vrf_data = connection.get( - "show running-config | include '^ip(v6)* route'" - ) - vrf_data = connection.get( - "show running-config | section '^vrf context'" - ) + non_vrf_data = connection.get("show running-config | include '^ip(v6)* route'") + vrf_data = connection.get("show running-config | section '^vrf context'") if non_vrf_data: non_vrf_data = non_vrf_data.split("\n") else: @@ -100,9 +98,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("static_routes", None) facts = {} if objs: - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) params = utils.remove_empties(params) for c in params["config"]: if c == {"vrf": "default"}: @@ -120,9 +116,7 @@ def get_inner_dict(self, conf, inner_dict): inner_dict["dest"] = re.match(r"^\s*(\S+\/\d+) .*", conf).group(1) # ethernet1/2/23 - iface = re.match( - r".* (Ethernet|loopback|mgmt|port\-channel)(\S*) .*", conf - ) + iface = re.match(r".* (Ethernet|loopback|mgmt|port\-channel)(\S*) .*", conf) i = ["Ethernet", "loopback", "mgmt", "port-channel"] if iface and iface.group(1) in i: inner_dict["interface"] = (iface.group(1)) + (iface.group(2)) @@ -131,9 +125,7 @@ def get_inner_dict(self, conf, inner_dict): if "." in inner_dict["dest"]: conf = re.sub(inner_dict["dest"], "", conf) inner_dict["afi"] = "ipv4" - ipv4 = re.match( - r".* (\d+\.\d+\.\d+\.\d+\/?\d*).*", conf - ) # gets next hop ip + ipv4 = re.match(r".* (\d+\.\d+\.\d+\.\d+\/?\d*).*", conf) # gets next hop ip if ipv4: inner_dict["forward_router_address"] = ipv4.group(1) conf = re.sub(inner_dict["forward_router_address"], "", conf) @@ -191,9 +183,7 @@ def get_command(self, conf, afi_list, dest_list, af): if inner_dict["dest"] not in dest_list: dest_list.append(inner_dict["dest"]) - af[-1]["routes"].append( - {"dest": inner_dict["dest"], "next_hops": []} - ) + af[-1]["routes"].append({"dest": inner_dict["dest"], "next_hops": []}) # if 'dest' is new, create new list under 'routes' af[-1]["routes"][-1]["next_hops"].append(next_hop) else: @@ -228,21 +218,13 @@ def render_config(self, spec, con): # considering from the second line as first line is 'vrf context..' conf = conf[1:] for c in conf: - if ( - "ip route" in c or "ipv6 route" in c - ) and "bfd" not in c: + if ("ip route" in c or "ipv6 route" in c) and "bfd" not in c: self.get_command(c, afi_list, dest_list, af) config_dict["address_families"] = af config.append(config_dict) else: - if ( - "ip route" in conf or "ipv6 route" in conf - ) and "bfd" not in conf: - self.get_command( - conf, global_afi_list, global_dest_list, global_af - ) + if ("ip route" in conf or "ipv6 route" in conf) and "bfd" not in conf: + self.get_command(conf, global_afi_list, global_dest_list, global_af) if global_af: - config.append( - utils.remove_empties({"address_families": global_af}) - ) + config.append(utils.remove_empties({"address_families": global_af})) return config diff --git a/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py b/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py index 4a766a333..abac23968 100644 --- a/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py @@ -11,33 +11,30 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.telemetry.telemetry import ( TelemetryArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.cmdref.telemetry.telemetry import ( - TMS_GLOBAL, TMS_DESTGROUP, + TMS_GLOBAL, TMS_SENSORGROUP, TMS_SUBSCRIPTION, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import NxosCmdRef from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.telemetry.telemetry import ( - get_instance_data, cr_key_lookup, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.telemetry.telemetry import ( + get_instance_data, normalize_data, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - NxosCmdRef, -) class TelemetryFacts(object): @@ -82,9 +79,7 @@ def populate_facts(self, connection, ansible_facts, data=None): # Get Telemetry Global Data cmd_ref["TMS_GLOBAL"]["ref"] = [] - cmd_ref["TMS_GLOBAL"]["ref"].append( - NxosCmdRef(self._module, TMS_GLOBAL) - ) + cmd_ref["TMS_GLOBAL"]["ref"].append(NxosCmdRef(self._module, TMS_GLOBAL)) ref = cmd_ref["TMS_GLOBAL"]["ref"][0] ref.set_context() ref.get_existing() @@ -100,9 +95,7 @@ def populate_facts(self, connection, ansible_facts, data=None): for line in device_cache_lines: if re.search(r"destination-group", line): resource_key = line.strip() - cmd_ref["TMS_DESTGROUP"]["ref"].append( - NxosCmdRef(self._module, TMS_DESTGROUP) - ) + cmd_ref["TMS_DESTGROUP"]["ref"].append(NxosCmdRef(self._module, TMS_DESTGROUP)) ref = cmd_ref["TMS_DESTGROUP"]["ref"][-1] ref.set_context([resource_key]) ref.get_existing(device_cache) @@ -113,9 +106,7 @@ def populate_facts(self, connection, ansible_facts, data=None): for line in device_cache_lines: if re.search(r"sensor-group", line): resource_key = line.strip() - cmd_ref["TMS_SENSORGROUP"]["ref"].append( - NxosCmdRef(self._module, TMS_SENSORGROUP) - ) + cmd_ref["TMS_SENSORGROUP"]["ref"].append(NxosCmdRef(self._module, TMS_SENSORGROUP)) ref = cmd_ref["TMS_SENSORGROUP"]["ref"][-1] ref.set_context([resource_key]) ref.get_existing(device_cache) @@ -171,39 +162,24 @@ def render_config(self, spec, cmd_ref): for cr in cmd_ref[mo]["ref"]: cr_keys = cr_key_lookup(key, mo) for cr_key in cr_keys: - if cr._ref.get(cr_key) and cr._ref[cr_key].get( - "existing" - ): + if cr._ref.get(cr_key) and cr._ref[cr_key].get("existing"): if isinstance(config[key], dict): for k in config[key].keys(): - for existing_key in cr._ref[cr_key][ - "existing" - ].keys(): - config[key][k] = cr._ref[cr_key][ - "existing" - ][existing_key][k] + for existing_key in cr._ref[cr_key]["existing"].keys(): + config[key][k] = cr._ref[cr_key]["existing"][existing_key][ + k + ] continue if isinstance(config[key], list): - for existing_key in cr._ref[cr_key][ - "existing" - ].keys(): - data = get_instance_data( - key, cr_key, cr, existing_key - ) + for existing_key in cr._ref[cr_key]["existing"].keys(): + data = get_instance_data(key, cr_key, cr, existing_key) config[key].append(data) continue - for existing_key in cr._ref[cr_key][ - "existing" - ].keys(): - config[key] = cr._ref[cr_key]["existing"][ - existing_key - ] + for existing_key in cr._ref[cr_key]["existing"].keys(): + config[key] = cr._ref[cr_key]["existing"][existing_key] elif cr._ref.get(cr_key): data = get_instance_data(key, cr_key, cr, None) - if ( - isinstance(config[key], list) - and data not in config[key] - ): + if isinstance(config[key], list) and data not in config[key]: config[key].append(data) return utils.remove_empties(config) diff --git a/plugins/module_utils/network/nxos/facts/vlans/vlans.py b/plugins/module_utils/network/nxos/facts/vlans/vlans.py index a38c1f3e8..3b35792b6 100644 --- a/plugins/module_utils/network/nxos/facts/vlans/vlans.py +++ b/plugins/module_utils/network/nxos/facts/vlans/vlans.py @@ -12,19 +12,20 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type -import re import ast +import re + from copy import deepcopy -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( - utils, -) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( parse_conf_arg, parse_conf_cmd_arg, ) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.vlans.vlans import ( VlansArgs, ) @@ -74,19 +75,13 @@ def populate_facts(self, connection, ansible_facts, data=None): try: # Not all devices support | json-pretty but is a workaround for # libssh issue https://github.com/ansible/pylibssh/issues/208 - structured = self.get_device_data( - connection, "show vlan | json-pretty" - ) + structured = self.get_device_data(connection, "show vlan | json-pretty") except Exception: # When json-pretty is not supported, we fall back to | json - structured = self.get_device_data( - connection, "show vlan | json" - ) + structured = self.get_device_data(connection, "show vlan | json") # Raw cli config is needed for mapped_vni, which is not included in structured. - run_cfg_output = self.get_device_data( - connection, "show running-config | section ^vlan" - ) + run_cfg_output = self.get_device_data(connection, "show running-config | section ^vlan") else: running_config = data.split("\n\n") structured, run_cfg_output = running_config[0], running_config[1] @@ -103,9 +98,7 @@ def populate_facts(self, connection, ansible_facts, data=None): facts = {} if objs: facts["vlans"] = [] - params = utils.validate_config( - self.argument_spec, {"config": objs} - ) + params = utils.validate_config(self.argument_spec, {"config": objs}) for cfg in params["config"]: facts["vlans"].append(utils.remove_empties(cfg)) ansible_facts["ansible_network_resources"].update(facts) @@ -135,9 +128,7 @@ def render_config(self, spec, vlan): obj["mode"] = vlan["vlanshowinfo-vlanmode"].replace("-vlan", "") # enabled: shutdown, noshutdown - obj["enabled"] = ( - True if "noshutdown" in vlan["vlanshowbr-shutstate"] else False - ) + obj["enabled"] = True if "noshutdown" in vlan["vlanshowbr-shutstate"] else False # state: active, suspend obj["state"] = vlan["vlanshowbr-vlanstate"] diff --git a/plugins/module_utils/network/nxos/nxos.py b/plugins/module_utils/network/nxos/nxos.py index aa1cc8866..9519dbed3 100644 --- a/plugins/module_utils/network/nxos/nxos.py +++ b/plugins/module_utils/network/nxos/nxos.py @@ -28,6 +28,7 @@ # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -35,25 +36,25 @@ import json import re import sys + from copy import deepcopy from ansible.module_utils._text import to_text from ansible.module_utils.basic import env_fallback -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, - ComplexList, -) -from ansible.module_utils.connection import Connection, ConnectionError from ansible.module_utils.common._collections_compat import Mapping +from ansible.module_utils.connection import Connection, ConnectionError +from ansible.module_utils.six import PY2, PY3, iteritems +from ansible.module_utils.urls import fetch_url from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, NetworkConfig, dumps, ) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + ComplexList, + to_list, ) -from ansible.module_utils.six import iteritems, PY2, PY3 -from ansible.module_utils.urls import fetch_url + try: import yaml @@ -76,9 +77,7 @@ nxos_provider_spec = { "host": dict(type="str"), "port": dict(type="int"), - "username": dict( - type="str", fallback=(env_fallback, ["ANSIBLE_NET_USERNAME"]) - ), + "username": dict(type="str", fallback=(env_fallback, ["ANSIBLE_NET_USERNAME"])), "password": dict( type="str", no_log=True, @@ -163,9 +162,7 @@ def get_config(self, flags=None): try: out = connection.get_config(flags=flags) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) cfg = to_text(out, errors="surrogate_then_replace").strip() + "\n" self._device_configs[cmd] = cfg @@ -184,14 +181,11 @@ def run_commands(self, commands, check_rc=True): if network_api == "cliconf" and out: for index, resp in enumerate(out): if ( - "Invalid command at" in resp - or "Ambiguous command at" in resp + "Invalid command at" in resp or "Ambiguous command at" in resp ) and "json" in resp: if commands[index]["output"] == "json": commands[index]["output"] = "text" - out = connection.run_commands( - commands, check_rc - ) + out = connection.run_commands(commands, check_rc) return out except ConnectionError as exc: self._module.fail_json(msg=to_text(exc)) @@ -215,10 +209,7 @@ def load_config(self, config, return_error=False, opts=None, replace=None): responses.append(err) return responses elif code and "no graceful-restart" in err: - if ( - "ISSU/HA will be affected if Graceful Restart is disabled" - in err - ): + if "ISSU/HA will be affected if Graceful Restart is disabled" in err: msg = [""] responses.extend(msg) return responses @@ -250,9 +241,7 @@ def get_diff( diff_replace=diff_replace, ) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) return response def get_capabilities(self): @@ -264,9 +253,7 @@ def get_capabilities(self): try: capabilities = connection.get_capabilities() except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) self._module._capabilities = json.loads(capabilities) return self._module._capabilities @@ -275,9 +262,7 @@ def read_module_context(self, module_key): try: module_context = connection.read_module_context(module_key) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) return module_context @@ -286,9 +271,7 @@ def save_module_context(self, module_key, module_context): try: connection.save_module_context(module_key, module_context) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) return None @@ -330,9 +313,7 @@ def _error(self, msg, **kwargs): kwargs["url"] = self._url self._module.fail_json(msg=msg, **kwargs) - def _request_builder( - self, commands, output, version="1.0", chunk="0", sid=None - ): + def _request_builder(self, commands, output, version="1.0", chunk="0", sid=None): """Encodes a NXAPI JSON request message""" try: command_type = self.OUTPUT_TO_COMMAND_TYPE[output] @@ -413,9 +394,7 @@ def send_request( ) self._nxapi_auth = headers.get("set-cookie") - if opts.get("ignore_timeout") and re.search( - r"(-1|5\d\d)", str(headers["status"]) - ): + if opts.get("ignore_timeout") and re.search(r"(-1|5\d\d)", str(headers["status"])): result.append(headers["status"]) return result elif headers["status"] != 200: @@ -487,9 +466,7 @@ def _send(commands, output): return responses - def load_config( - self, commands, return_error=False, opts=None, replace=None - ): + def load_config(self, commands, return_error=False, opts=None, replace=None): """Sends the ordered set of commands to the device""" if opts is None: @@ -500,9 +477,7 @@ def load_config( if replace: device_info = self.get_device_info() if "9K" not in device_info.get("network_os_platform", ""): - self._module.fail_json( - msg="replace is supported only on Nexus 9K devices" - ) + self._module.fail_json(msg="replace is supported only on Nexus 9K devices") commands = "config replace {0}".format(replace) commands = to_list(commands) @@ -522,10 +497,7 @@ def load_config( responses.append(code) return responses elif code and "no graceful-restart" in err: - if ( - "ISSU/HA will be affected if Graceful Restart is disabled" - in err - ): + if "ISSU/HA will be affected if Graceful Restart is disabled" in err: msg = [""] responses.extend(msg) return responses @@ -556,9 +528,7 @@ def get_diff( if running and diff_match != "none" and diff_replace != "config": # running configuration - running_obj = NetworkConfig( - indent=2, contents=running, ignore_lines=diff_ignore_lines - ) + running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) configdiffobjs = candidate_obj.difference( running_obj, path=path, match=diff_match, replace=diff_replace ) @@ -566,33 +536,23 @@ def get_diff( else: configdiffobjs = candidate_obj.items - diff["config_diff"] = ( - dumps(configdiffobjs, "commands") if configdiffobjs else "" - ) + diff["config_diff"] = dumps(configdiffobjs, "commands") if configdiffobjs else "" return diff def get_device_info(self): device_info = {} device_info["network_os"] = "nxos" - reply = self.run_commands( - {"command": "show version", "output": "json"} - ) + reply = self.run_commands({"command": "show version", "output": "json"}) data = reply[0] - platform_reply = self.run_commands( - {"command": "show inventory", "output": "json"} - ) + platform_reply = self.run_commands({"command": "show inventory", "output": "json"}) platform_info = platform_reply[0] - device_info["network_os_version"] = data.get( - "sys_ver_str" - ) or data.get("kickstart_ver_str") + device_info["network_os_version"] = data.get("sys_ver_str") or data.get("kickstart_ver_str") device_info["network_os_model"] = data["chassis_id"] device_info["network_os_hostname"] = data["host_name"] - device_info["network_os_image"] = data.get( - "isan_file_name" - ) or data.get("kick_file_name") + device_info["network_os_image"] = data.get("isan_file_name") or data.get("kick_file_name") if platform_info: inventory_table = platform_info["TABLE_inv"]["ROW_inv"] @@ -667,9 +627,7 @@ def get_config(self, flags=None): try: out = self._connection.send_request(cmd) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) cfg = to_text(out).strip() self._device_configs[cmd] = cfg @@ -692,9 +650,7 @@ def get_diff( if running and diff_match != "none" and diff_replace != "config": # running configuration - running_obj = NetworkConfig( - indent=2, contents=running, ignore_lines=diff_ignore_lines - ) + running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) configdiffobjs = candidate_obj.difference( running_obj, path=path, match=diff_match, replace=diff_replace ) @@ -702,14 +658,10 @@ def get_diff( else: configdiffobjs = candidate_obj.items - diff["config_diff"] = ( - dumps(configdiffobjs, "commands") if configdiffobjs else "" - ) + diff["config_diff"] = dumps(configdiffobjs, "commands") if configdiffobjs else "" return diff - def load_config( - self, commands, return_error=False, opts=None, replace=None - ): + def load_config(self, commands, return_error=False, opts=None, replace=None): """Sends the ordered set of commands to the device""" if opts is None: opts = {} @@ -727,10 +679,7 @@ def load_config( elif opts.get("catch_clierror") and "400" in code: return [code, err] elif code and "no graceful-restart" in err: - if ( - "ISSU/HA will be affected if Graceful Restart is disabled" - in err - ): + if "ISSU/HA will be affected if Graceful Restart is disabled" in err: msg = [""] responses.extend(msg) return responses @@ -742,9 +691,7 @@ def load_config( responses.extend(resp) return responses - def edit_config( - self, candidate=None, commit=True, replace=None, comment=None - ): + def edit_config(self, candidate=None, commit=True, replace=None, comment=None): resp = list() self.check_edit_config_capability(candidate, commit, replace, comment) @@ -766,21 +713,15 @@ def get_capabilities(self): try: capabilities = self._connection.get_capabilities() except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) return json.loads(capabilities) - def check_edit_config_capability( - self, candidate=None, commit=True, replace=None, comment=None - ): + def check_edit_config_capability(self, candidate=None, commit=True, replace=None, comment=None): operations = self._connection.get_device_operations() if not candidate and not replace: - raise ValueError( - "must provide a candidate or replace to load configuration" - ) + raise ValueError("must provide a candidate or replace to load configuration") if commit not in (True, False): raise ValueError("'commit' must be a bool, got %s" % commit) @@ -795,9 +736,7 @@ def read_module_context(self, module_key): try: module_context = self._connection.read_module_context(module_key) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) return module_context @@ -805,9 +744,7 @@ def save_module_context(self, module_key, module_context): try: self._connection.save_module_context(module_key, module_context) except ConnectionError as exc: - self._module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + self._module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) return None @@ -919,9 +856,7 @@ def get_platform_shortname(self): return None # Supported Platforms: N3K,N5K,N6K,N7K,N9K,N3K-F,N9K-F - m = re.match( - "(?PN[35679][K57])-(?PC35)*", network_os_platform - ) + m = re.match("(?PN[35679][K57])-(?PC35)*", network_os_platform) if not m: return None shortname = m.group("short") @@ -1008,21 +943,13 @@ def pattern_match_existing(self, output, k): if not match: return None if len(match) > 1 and not multiple: - raise ValueError( - "get_existing: multiple matches found for property {0}".format( - k - ) - ) + raise ValueError("get_existing: multiple matches found for property {0}".format(k)) else: match = [m.groups() for m in match_lines if m] if not match: return None if len(match) > 1 and not multiple: - raise ValueError( - "get_existing: multiple matches found for property {0}".format( - k - ) - ) + raise ValueError("get_existing: multiple matches found for property {0}".format(k)) for item in match: index = match.index(item) match[index] = list(item) # tuple to list @@ -1086,10 +1013,7 @@ def get_existing(self, cache_output=None): # We need to remove the last item in context for state absent case. if ref["_state"] in self.absent_states and ref["_context"]: - if ( - ref["_resource_key"] - and ref["_resource_key"] == ref["_context"][-1] - ): + if ref["_resource_key"] and ref["_resource_key"] == ref["_context"][-1]: if ref["_context"][-1] in output: ref["_context"][-1] = "no " + ref["_context"][-1] else: @@ -1122,9 +1046,7 @@ def get_existing(self, cache_output=None): ref[k]["existing"][index] = item[0] else: raise ValueError( - "get_existing: unknown 'kind' value specified for key '{0}'".format( - k - ) + "get_existing: unknown 'kind' value specified for key '{0}'".format(k) ) def get_playvals(self): @@ -1188,15 +1110,9 @@ def build_cmd_set(self, playval, existing, k): else: cmd = ref[k]["setval"].format(playval) else: - raise ValueError( - "get_proposed: unknown 'kind' value specified for key '{0}'".format( - k - ) - ) + raise ValueError("get_proposed: unknown 'kind' value specified for key '{0}'".format(k)) if cmd: - if ref["_state"] in self.absent_states and not re.search( - r"^no", cmd - ): + if ref["_state"] in self.absent_states and not re.search(r"^no", cmd): cmd = "no " + cmd # Commands may require parent commands for proper context. # Global _template context is replaced by parameter context @@ -1226,15 +1142,11 @@ def compare(playval, existing): return False elif playval == existing: return True - elif ( - isinstance(existing, dict) and playval in existing.values() - ): + elif isinstance(existing, dict) and playval in existing.values(): return True if ref["_state"] in self.absent_states: - if isinstance(existing, dict) and all( - x is None for x in existing.values() - ): + if isinstance(existing, dict) and all(x is None for x in existing.values()): existing = None if existing is None or playval not in existing.values(): return True @@ -1254,9 +1166,7 @@ def compare(playval, existing): for ekey, evalue in existing.items(): if isinstance(evalue, dict): # Remove values set to string 'None' from dvalue - evalue = dict( - (k, v) for k, v in evalue.items() if v != "None" - ) + evalue = dict((k, v) for k, v in evalue.items() if v != "None") for pkey, pvalue in playval.items(): if compare(pvalue, evalue): if playval_copy.get(pkey): diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py index 527566bdb..b0eda815b 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) @@ -66,9 +68,7 @@ def _tmplt_redistribute(redis): class Bgp_address_familyTemplate(NetworkTemplate): def __init__(self, lines=None): - super(Bgp_address_familyTemplate, self).__init__( - lines=lines, tmplt=self - ) + super(Bgp_address_familyTemplate, self).__init__(lines=lines, tmplt=self) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py index 33fde2c9a..cdd24c9a7 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) @@ -56,9 +58,7 @@ def _tmplt_bfd(proc): class Bgp_globalTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Bgp_globalTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Bgp_globalTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py index 5960ba33f..38e6f0f3d 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) @@ -34,9 +36,7 @@ def _tmplt_maximum_prefix(data): class Bgp_neighbor_address_familyTemplate(NetworkTemplate): def __init__(self, lines=None): - super(Bgp_neighbor_address_familyTemplate, self).__init__( - lines=lines, tmplt=self - ) + super(Bgp_neighbor_address_familyTemplate, self).__init__(lines=lines, tmplt=self) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/hostname.py b/plugins/module_utils/network/nxos/rm_templates/hostname.py index 47decb3d8..558e0168c 100644 --- a/plugins/module_utils/network/nxos/rm_templates/hostname.py +++ b/plugins/module_utils/network/nxos/rm_templates/hostname.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) @@ -22,9 +24,7 @@ class HostnameTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(HostnameTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(HostnameTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/logging_global.py b/plugins/module_utils/network/nxos/rm_templates/logging_global.py index c2749ebb7..0467ffe61 100644 --- a/plugins/module_utils/network/nxos/rm_templates/logging_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) @@ -22,9 +24,7 @@ def _tmplt_hosts(data): cmd = "logging server {host}" - data["client_identity"] = ( - data.get("secure", {}).get("trustpoint", {}).get("client_identity") - ) + data["client_identity"] = data.get("secure", {}).get("trustpoint", {}).get("client_identity") if "severity" in data: cmd += " {severity}" @@ -44,9 +44,7 @@ def _tmplt_hosts(data): class Logging_globalTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Logging_globalTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Logging_globalTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/ntp_global.py b/plugins/module_utils/network/nxos/rm_templates/ntp_global.py index 85f46e70d..f976e2fa7 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ntp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/ntp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) @@ -22,9 +24,7 @@ class Ntp_globalTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Ntp_globalTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Ntp_globalTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py b/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py index 76edd06ee..9b57d4c85 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) @@ -36,9 +38,7 @@ def _tmplt_authentication(data): class Ospf_interfacesTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Ospf_interfacesTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Ospf_interfacesTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/ospfv2.py b/plugins/module_utils/network/nxos/rm_templates/ospfv2.py index 8aaf41a55..16b00694a 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospfv2.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospfv2.py @@ -1,5 +1,6 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re @@ -20,10 +21,7 @@ def _tmplt_area_range(arange): def _tmplt_default_information(proc): command = "default-information originate" - if ( - "always" in proc["default_information"] - and proc["default_information"]["always"] - ): + if "always" in proc["default_information"] and proc["default_information"]["always"]: command += " always" if "route_map" in proc["default_information"]: command += " route-map" @@ -110,9 +108,7 @@ def _tmplt_max_metric(proc): if on_startup.get("wait_period"): command += " {wait_period}".format(**on_startup) if on_startup.get("wait_for_bgp_asn"): - command += " wait-for bgp {wait_for_bgp_asn}".format( - **on_startup - ) + command += " wait-for bgp {wait_for_bgp_asn}".format(**on_startup) if summary_lsa: command += " summary-lsa" if summary_lsa.get("max_metric_value"): diff --git a/plugins/module_utils/network/nxos/rm_templates/ospfv3.py b/plugins/module_utils/network/nxos/rm_templates/ospfv3.py index f2bd7cad5..9f66a00f3 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospfv3.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospfv3.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) @@ -88,13 +90,9 @@ def _tmplt_max_metric(proc): command = "no {0}".format(command) else: external_lsa = max_metric.get("router_lsa", {}).get("external_lsa", {}) - stub_prefix_lsa = max_metric.get("router_lsa", {}).get( - "stub_prefix_lsa", {} - ) + stub_prefix_lsa = max_metric.get("router_lsa", {}).get("stub_prefix_lsa", {}) on_startup = max_metric.get("router_lsa", {}).get("on_startup", {}) - inter_area_prefix_lsa = max_metric.get("router_lsa", {}).get( - "inter_area_prefix_lsa", {} - ) + inter_area_prefix_lsa = max_metric.get("router_lsa", {}).get("inter_area_prefix_lsa", {}) if external_lsa: command += " external-lsa" if external_lsa.get("max_metric_value"): @@ -106,15 +104,11 @@ def _tmplt_max_metric(proc): if on_startup.get("wait_period"): command += " {wait_period}".format(**on_startup) if on_startup.get("wait_for_bgp_asn"): - command += " wait-for bgp {wait_for_bgp_asn}".format( - **on_startup - ) + command += " wait-for bgp {wait_for_bgp_asn}".format(**on_startup) if inter_area_prefix_lsa: command += " inter-area-prefix-lsa" if inter_area_prefix_lsa.get("max_metric_value"): - command += " {max_metric_value}".format( - **inter_area_prefix_lsa - ) + command += " {max_metric_value}".format(**inter_area_prefix_lsa) return command diff --git a/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py b/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py index 6dd25bd00..162d7dd62 100644 --- a/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py +++ b/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) @@ -22,9 +24,7 @@ class Prefix_listsTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Prefix_listsTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Prefix_listsTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index f9109f357..64a155d2a 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( NetworkTemplate, ) @@ -85,9 +87,7 @@ def _tmplt_set_metric(data): class Route_mapsTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Route_mapsTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Route_mapsTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index fca32f9af..1bf42ff0f 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -15,6 +16,7 @@ """ import re + from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) @@ -93,9 +95,7 @@ def _template_communities(data): class Snmp_serverTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): - super(Snmp_serverTemplate, self).__init__( - lines=lines, tmplt=self, module=module - ) + super(Snmp_serverTemplate, self).__init__(lines=lines, tmplt=self, module=module) # fmt: off PARSERS = [ diff --git a/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py b/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py index 1a270fead..96e0e2fa9 100644 --- a/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py @@ -8,9 +8,11 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy @@ -59,16 +61,16 @@ def valiate_input(playvals, type, module): msg = "Invalid playbook value: {0}.".format(playvals) msg += " Parameter under is required" module.fail_json(msg=msg) - if playvals.get("destination") and not isinstance( - playvals["destination"], dict - ): + if playvals.get("destination") and not isinstance(playvals["destination"], dict): msg = "Invalid playbook value: {0}.".format(playvals) msg += " Parameter under must be a dict" module.fail_json(msg=msg) if not playvals.get("destination") and len(playvals) > 1: msg = "Invalid playbook value: {0}.".format(playvals) msg += " Playbook entry contains unrecongnized parameters." - msg += " Make sure keys under are specified as follows:" + msg += ( + " Make sure keys under are specified as follows:" + ) msg += " destination: {ip: , port: , protocol: , encoding: }}" module.fail_json(msg=msg) @@ -79,9 +81,7 @@ def valiate_input(playvals, type, module): module.fail_json(msg=msg) if playvals.get("path") and "name" not in playvals["path"].keys(): msg = "Invalid playbook value: {0}.".format(playvals) - msg += ( - " Parameter under requires key" - ) + msg += " Parameter under requires key" module.fail_json(msg=msg) @@ -147,9 +147,7 @@ def remove_duplicate_context(cmds): """Helper method to remove duplicate telemetry context commands""" if not cmds: return cmds - feature_indices = [ - i for i, x in enumerate(cmds) if x == "feature telemetry" - ] + feature_indices = [i for i, x in enumerate(cmds) if x == "feature telemetry"] telemetry_indices = [i for i, x in enumerate(cmds) if x == "telemetry"] if len(feature_indices) == 1 and len(telemetry_indices) == 1: return cmds @@ -179,9 +177,7 @@ def get_setval_path(module_or_path_data): if isinstance(module_or_path_data, dict): path = module_or_path_data else: - path = module_or_path_data.params["config"]["sensor_groups"][0].get( - "path" - ) + path = module_or_path_data.params["config"]["sensor_groups"][0].get("path") if path is None: return path @@ -226,17 +222,11 @@ def massage_data(have_or_want): else: if item.get("destination"): if item.get("destination").get("port"): - item["destination"]["port"] = str( - item["destination"]["port"] - ) + item["destination"]["port"] = str(item["destination"]["port"]) if item.get("destination").get("protocol"): - item["destination"]["protocol"] = item["destination"][ - "protocol" - ].lower() + item["destination"]["protocol"] = item["destination"]["protocol"].lower() if item.get("destination").get("encoding"): - item["destination"]["encoding"] = item["destination"][ - "encoding" - ].lower() + item["destination"]["encoding"] = item["destination"]["encoding"].lower() if item.get("path"): for key in [ "filter_condition", @@ -251,9 +241,7 @@ def massage_data(have_or_want): item["destination_group"] = str(item["destination_group"]) if item.get("sensor_group"): if item.get("sensor_group").get("id"): - item["sensor_group"]["id"] = str( - item["sensor_group"]["id"] - ) + item["sensor_group"]["id"] = str(item["sensor_group"]["id"]) if item.get("sensor_group").get("sample_interval"): item["sensor_group"]["sample_interval"] = str( item["sensor_group"]["sample_interval"] diff --git a/plugins/module_utils/network/nxos/utils/utils.py b/plugins/module_utils/network/nxos/utils/utils.py index 1c2610b8b..01468edd5 100644 --- a/plugins/module_utils/network/nxos/utils/utils.py +++ b/plugins/module_utils/network/nxos/utils/utils.py @@ -1,12 +1,15 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import socket -from itertools import groupby, count from functools import total_ordering +from itertools import count, groupby + from ansible.module_utils.six import iteritems + LOGGING_SEVMAP = { 0: "emergency", 1: "alert", @@ -121,9 +124,7 @@ def remove_rsvd_interfaces(interfaces): """Exclude reserved interfaces from user management""" if not interfaces: return [] - return [ - i for i in interfaces if get_interface_type(i["name"]) != "management" - ] + return [i for i in interfaces if get_interface_type(i["name"]) != "management"] def vlan_range_to_list(vlans): diff --git a/plugins/modules/nxos_aaa_server.py b/plugins/modules/nxos_aaa_server.py index 98f747afe..ffdf7f826 100644 --- a/plugins/modules/nxos_aaa_server.py +++ b/plugins/modules/nxos_aaa_server.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -124,14 +125,13 @@ """ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule PARAM_TO_DEFAULT_KEYMAP = { @@ -207,9 +207,7 @@ def config_aaa_server(params, server_type): cmds.append("{0}-server deadtime {1}".format(server_type, deadtime)) if server_timeout is not None: - cmds.append( - "{0}-server timeout {1}".format(server_type, server_timeout) - ) + cmds.append("{0}-server timeout {1}".format(server_type, server_timeout)) if directed_request is not None: if directed_request == "enabled": @@ -218,11 +216,7 @@ def config_aaa_server(params, server_type): cmds.append("no {0}-server directed-request".format(server_type)) if global_key is not None: - cmds.append( - "{0}-server key {1} {2}".format( - server_type, encrypt_type, global_key - ) - ) + cmds.append("{0}-server key {1} {2}".format(server_type, encrypt_type, global_key)) return cmds @@ -236,54 +230,41 @@ def default_aaa_server(existing, params, server_type): global_key = params.get("global_key") existing_key = existing.get("global_key") - if ( - deadtime is not None - and existing.get("deadtime") != PARAM_TO_DEFAULT_KEYMAP["deadtime"] - ): + if deadtime is not None and existing.get("deadtime") != PARAM_TO_DEFAULT_KEYMAP["deadtime"]: cmds.append("no {0}-server deadtime 1".format(server_type)) if ( server_timeout is not None - and existing.get("server_timeout") - != PARAM_TO_DEFAULT_KEYMAP["server_timeout"] + and existing.get("server_timeout") != PARAM_TO_DEFAULT_KEYMAP["server_timeout"] ): cmds.append("no {0}-server timeout 1".format(server_type)) if ( directed_request is not None - and existing.get("directed_request") - != PARAM_TO_DEFAULT_KEYMAP["directed_request"] + and existing.get("directed_request") != PARAM_TO_DEFAULT_KEYMAP["directed_request"] ): cmds.append("no {0}-server directed-request".format(server_type)) if global_key is not None and existing_key is not None: - cmds.append( - "no {0}-server key 7 {1}".format(server_type, existing_key) - ) + cmds.append("no {0}-server key 7 {1}".format(server_type, existing_key)) return cmds def main(): argument_spec = dict( - server_type=dict( - type="str", choices=["radius", "tacacs"], required=True - ), + server_type=dict(type="str", choices=["radius", "tacacs"], required=True), global_key=dict(type="str", no_log=True), encrypt_type=dict(type="str", choices=["0", "7"]), deadtime=dict(type="str"), server_timeout=dict(type="str"), - directed_request=dict( - type="str", choices=["enabled", "disabled", "default"] - ), + directed_request=dict(type="str", choices=["enabled", "disabled", "default"]), state=dict(choices=["default", "present"], default="present"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} @@ -319,18 +300,14 @@ def main(): if int(deadtime) < 0 or int(deadtime) > 1440: raise ValueError except ValueError: - module.fail_json( - msg="deadtime must be an integer between 0 and 1440" - ) + module.fail_json(msg="deadtime must be an integer between 0 and 1440") if server_timeout: try: if int(server_timeout) < 1 or int(server_timeout) > 60: raise ValueError except ValueError: - module.fail_json( - msg="server_timeout must be an integer between 1 and 60" - ) + module.fail_json(msg="server_timeout must be an integer between 1 and 60") delta = dict(set(proposed.items()).difference(existing.items())) if delta: @@ -341,10 +318,7 @@ def main(): elif state == "default": for key, value in proposed.items(): if key != "server_type" and value != "default": - module.fail_json( - msg='Parameters must be set to "default"' - "when state=default" - ) + module.fail_json(msg='Parameters must be set to "default"' "when state=default") command = default_aaa_server(existing, proposed, server_type) if command: commands.append(command) diff --git a/plugins/modules/nxos_aaa_server_host.py b/plugins/modules/nxos_aaa_server_host.py index 96a9d49a4..fd796a218 100644 --- a/plugins/modules/nxos_aaa_server_host.py +++ b/plugins/modules/nxos_aaa_server_host.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -148,15 +149,14 @@ """ import re -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, + load_config, nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -199,24 +199,19 @@ def get_aaa_host_info(module, server_type, address): match = re.search(pattern, body) aaa_host_info["key"] = match.group(1) if aaa_host_info["key"]: - aaa_host_info["key"] = aaa_host_info["key"].replace( - '"', "" - ) + aaa_host_info["key"] = aaa_host_info["key"].replace('"', "") aaa_host_info["encrypt_type"] = "7" aaa_host_info["auth_port"] = match.group(2) aaa_host_info["acct_port"] = match.group(3) aaa_host_info["host_timeout"] = match.group(4) elif "tacacs" in body: pattern = ( - r"\S+ host \S+(?:\s+key 7\s+(\S+))?(?:\s+port (\d+))?" - r"(?:\s+timeout (\d+))?" + r"\S+ host \S+(?:\s+key 7\s+(\S+))?(?:\s+port (\d+))?(?:\s+timeout (\d+))?" ) match = re.search(pattern, body) aaa_host_info["key"] = match.group(1) if aaa_host_info["key"]: - aaa_host_info["key"] = aaa_host_info["key"].replace( - '"', "" - ) + aaa_host_info["key"] = aaa_host_info["key"].replace('"', "") aaa_host_info["encrypt_type"] = "7" aaa_host_info["tacacs_port"] = match.group(2) aaa_host_info["host_timeout"] = match.group(3) @@ -288,9 +283,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -322,15 +315,10 @@ def main(): module.fail_json(msg="encrypt_type must be used with key") if tacacs_port and server_type != "tacacs": - module.fail_json( - msg="tacacs_port can only be used with server_type=tacacs" - ) + module.fail_json(msg="tacacs_port can only be used with server_type=tacacs") if (auth_port or acct_port) and server_type != "radius": - module.fail_json( - msg="auth_port and acct_port can only be used" - "when server_type=radius" - ) + module.fail_json(msg="auth_port and acct_port can only be used" "when server_type=radius") existing = get_aaa_host_info(module, server_type, address) end_state = existing diff --git a/plugins/modules/nxos_acl.py b/plugins/modules/nxos_acl.py index 36c88f909..c5a60b21f 100644 --- a/plugins/modules/nxos_acl.py +++ b/plugins/modules/nxos_acl.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -250,14 +251,13 @@ type: list sample: ["ip access-list ANSIBLE", "10 permit tcp 192.0.2.1/24 any"] """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module, check_rc=True): @@ -316,9 +316,7 @@ def get_acl(module, acl_name, seq_number): temp["action"] = "remark" else: temp["action"] = each.get("permitdeny") - temp["proto"] = str( - each.get("proto", each.get("proto_str", each.get("ip"))) - ) + temp["proto"] = str(each.get("proto", each.get("proto_str", each.get("ip")))) temp["src"] = each.get("src_any", each.get("src_ip_prefix")) temp["src_port_op"] = each.get("src_port_op") temp["src_port1"] = each.get("src_port1_num") @@ -451,15 +449,11 @@ def main(): remark=dict(required=False, type="str"), proto=dict(required=False, type="str"), src=dict(required=False, type="str"), - src_port_op=dict( - required=False, choices=["any", "eq", "gt", "lt", "neq", "range"] - ), + src_port_op=dict(required=False, choices=["any", "eq", "gt", "lt", "neq", "range"]), src_port1=dict(required=False, type="str"), src_port2=dict(required=False, type="str"), dest=dict(required=False, type="str"), - dest_port_op=dict( - required=False, choices=["any", "eq", "gt", "lt", "neq", "range"] - ), + dest_port_op=dict(required=False, choices=["any", "eq", "gt", "lt", "neq", "range"]), dest_port1=dict(required=False, type="str"), dest_port2=dict(required=False, type="str"), log=dict(required=False, choices=["enable"]), @@ -511,16 +505,12 @@ def main(): "ef", ], ), - state=dict( - choices=["absent", "present", "delete_acl"], default="present" - ), + state=dict(choices=["absent", "present", "delete_acl"], default="present"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -536,9 +526,7 @@ def main(): seq = module.params["seq"] if action == "remark" and not remark: - module.fail_json( - msg="when state is action, remark param is also required" - ) + module.fail_json(msg="when state is action, remark param is also required") REQUIRED = ["seq", "name", "action", "proto", "src", "dest"] ABSENT = ["name", "seq"] @@ -555,17 +543,13 @@ def main(): elif state == "absent": for each in ABSENT: if module.params[each] is None: - module.fail_json( - msg="require params when state is absent", params=ABSENT - ) + module.fail_json(msg="require params when state is absent", params=ABSENT) elif state == "delete_acl": if module.params["name"] is None: module.fail_json(msg="param name req'd when state is delete_acl") if dscp and precedence: - module.fail_json( - msg="only one of the params dscp/precedence " "are allowed" - ) + module.fail_json(msg="only one of the params dscp/precedence " "are allowed") OPTIONS_NAMES = [ "log", @@ -626,35 +610,21 @@ def main(): delta_options = {} if not existing_core.get("remark"): - dcore = dict( - set(proposed_core.items()).difference(existing_core.items()) - ) + dcore = dict(set(proposed_core.items()).difference(existing_core.items())) if not dcore: # check the diff in the other way just in case - dcore = dict( - set(existing_core.items()).difference(proposed_core.items()) - ) + dcore = dict(set(existing_core.items()).difference(proposed_core.items())) delta_core = dcore if delta_core: delta_options = proposed_options else: - doptions = dict( - set(proposed_options.items()).difference( - existing_options.items() - ) - ) + doptions = dict(set(proposed_options.items()).difference(existing_options.items())) # check the diff in the other way just in case if not doptions: - doptions = dict( - set(existing_options.items()).difference( - proposed_options.items() - ) - ) + doptions = dict(set(existing_options.items()).difference(proposed_options.items())) delta_options = doptions else: - delta_core = dict( - set(proposed_core.items()).difference(existing_core.items()) - ) + delta_core = dict(set(proposed_core.items()).difference(existing_core.items())) if state == "present": if delta_core or delta_options: diff --git a/plugins/modules/nxos_acl_interface.py b/plugins/modules/nxos_acl_interface.py index 2a65fa327..0e97063e3 100644 --- a/plugins/modules/nxos_acl_interface.py +++ b/plugins/modules/nxos_acl_interface.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -92,14 +93,13 @@ """ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def check_for_acl_int_present(module, name, intf, direction): @@ -107,9 +107,7 @@ def check_for_acl_int_present(module, name, intf, direction): # output has capitalization command = [ { - "command": "show running-config aclmgr | section {0}".format( - intf.title() - ), + "command": "show running-config aclmgr | section {0}".format(intf.title()), "output": "text", } ] @@ -120,9 +118,7 @@ def check_for_acl_int_present(module, name, intf, direction): elif direction == "egress": mdir = "out" - match = re.search( - "ip access-group {0} {1}".format(name, mdir), str(body[0]) - ) + match = re.search("ip access-group {0} {1}".format(name, mdir), str(body[0])) return bool(match) @@ -174,9 +170,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_acl_interfaces.py b/plugins/modules/nxos_acl_interfaces.py index 11835a873..e61746ff3 100644 --- a/plugins/modules/nxos_acl_interfaces.py +++ b/plugins/modules/nxos_acl_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -411,6 +412,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acl_interfaces.acl_interfaces import ( Acl_interfacesArgs, ) diff --git a/plugins/modules/nxos_acls.py b/plugins/modules/nxos_acls.py index bb7eb2272..7f2638300 100644 --- a/plugins/modules/nxos_acls.py +++ b/plugins/modules/nxos_acls.py @@ -27,6 +27,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -794,12 +795,11 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acls.acls import ( AclsArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.acls.acls import ( - Acls, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.acls.acls import Acls def main(): @@ -808,9 +808,7 @@ def main(): :returns: the result form module invocation """ - module = AnsibleModule( - argument_spec=AclsArgs.argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=AclsArgs.argument_spec, supports_check_mode=True) result = Acls(module).execute_module() module.exit_json(**result) diff --git a/plugins/modules/nxos_banner.py b/plugins/modules/nxos_banner.py index b2fe84c61..7f51b739e 100644 --- a/plugins/modules/nxos_banner.py +++ b/plugins/modules/nxos_banner.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # (c) 2017, Ansible by Red Hat, inc @@ -94,16 +95,16 @@ - string """ -from ansible.module_utils.basic import AnsibleModule +import re + from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -import re def execute_show_command(module, command): @@ -214,10 +215,7 @@ def main(): err_str = item["clierror"] else: err_str = item - if ( - "more than 40 lines" in err_str - or "buffer overflowed" in err_str - ): + if "more than 40 lines" in err_str or "buffer overflowed" in err_str: load_config(module, commands) result["changed"] = True diff --git a/plugins/modules/nxos_bfd_global.py b/plugins/modules/nxos_bfd_global.py index a8f8acd9d..4842446ed 100644 --- a/plugins/modules/nxos_bfd_global.py +++ b/plugins/modules/nxos_bfd_global.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -135,16 +136,15 @@ import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( NxosCmdRef, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, + nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule + BFD_CMD_REF = """ # The cmd_ref is a yaml formatted list of module commands. @@ -309,9 +309,7 @@ def main(): fabricpath_vlan=dict(required=False, type="int"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() cmd_ref = NxosCmdRef(module, BFD_CMD_REF) diff --git a/plugins/modules/nxos_bfd_interfaces.py b/plugins/modules/nxos_bfd_interfaces.py index 3988648e3..1790f8e01 100644 --- a/plugins/modules/nxos_bfd_interfaces.py +++ b/plugins/modules/nxos_bfd_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -262,6 +263,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bfd_interfaces.bfd_interfaces import ( Bfd_interfacesArgs, ) diff --git a/plugins/modules/nxos_bgp.py b/plugins/modules/nxos_bgp.py index 7c4244d4e..314026c3c 100644 --- a/plugins/modules/nxos_bgp.py +++ b/plugins/modules/nxos_bgp.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -278,17 +279,16 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) BOOL_PARAMS = [ @@ -397,9 +397,7 @@ def get_value(arg, config): command = PARAM_TO_COMMAND_KEYMAP.get(arg) if command.split()[0] == "event-history": - has_size = re.search( - r"^\s+{0} size\s(?P.*)$".format(command), config, re.M - ) + has_size = re.search(r"^\s+{0} size\s(?P.*)$".format(command), config, re.M) if command == "event-history detail": value = False @@ -423,9 +421,7 @@ def get_value(arg, config): if has_command: value = True else: - command_val_re = re.compile( - r"(?:{0}\s)(?P.*)".format(command), re.M - ) + command_val_re = re.compile(r"(?:{0}\s)(?P.*)".format(command), re.M) value = "" has_command = command_val_re.search(config) @@ -448,13 +444,9 @@ def get_value(arg, config): def get_existing(module, args, warnings): existing = {} - netcfg = CustomNetworkConfig( - indent=2, contents=get_config(module, flags=["bgp all"]) - ) + netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=["bgp all"])) - asn_re = re.compile( - r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S - ) + asn_re = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S) asn_match = asn_re.match(str(netcfg)) if asn_match: @@ -469,21 +461,14 @@ def get_existing(module, args, warnings): config = netcfg.get_section(parents) if config: for arg in args: - if arg != "asn" and ( - module.params["vrf"] == "default" - or arg not in GLOBAL_PARAMS - ): + if arg != "asn" and (module.params["vrf"] == "default" or arg not in GLOBAL_PARAMS): existing[arg] = get_value(arg, config) existing["asn"] = existing_asn if module.params["vrf"] == "default": existing["vrf"] = "default" - if ( - not existing - and module.params["vrf"] != "default" - and module.params["state"] == "present" - ): + if not existing and module.params["vrf"] != "default" and module.params["state"] == "present": msg = "VRF {0} doesn't exist.".format(module.params["vrf"]) warnings.append(msg) @@ -632,12 +617,8 @@ def main(): confederation_id=dict(required=False, type="str"), confederation_peers=dict(required=False, type="list", elements="str"), disable_policy_batching=dict(required=False, type="bool"), - disable_policy_batching_ipv4_prefix_list=dict( - required=False, type="str" - ), - disable_policy_batching_ipv6_prefix_list=dict( - required=False, type="str" - ), + disable_policy_batching_ipv4_prefix_list=dict(required=False, type="str"), + disable_policy_batching_ipv6_prefix_list=dict(required=False, type="str"), enforce_first_as=dict(required=False, type="bool"), event_history_cli=dict( required=False, @@ -692,9 +673,7 @@ def main(): graceful_restart=dict(required=False, type="bool"), graceful_restart_helper=dict(required=False, type="bool"), graceful_restart_timers_restart=dict(required=False, type="str"), - graceful_restart_timers_stalepath_time=dict( - required=False, type="str" - ), + graceful_restart_timers_stalepath_time=dict(required=False, type="str"), isolate=dict(required=False, type="bool"), local_as=dict(required=False, type="str"), log_neighbor_changes=dict(required=False, type="bool"), @@ -707,9 +686,7 @@ def main(): timer_bestpath_limit=dict(required=False, type="str"), timer_bgp_hold=dict(required=False, type="str"), timer_bgp_keepalive=dict(required=False, type="str"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) @@ -744,9 +721,7 @@ def main(): existing_asn=existing.get("asn"), ) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): if key not in ["asn", "vrf"]: diff --git a/plugins/modules/nxos_bgp_address_family.py b/plugins/modules/nxos_bgp_address_family.py index b117d0045..c838d25fa 100644 --- a/plugins/modules/nxos_bgp_address_family.py +++ b/plugins/modules/nxos_bgp_address_family.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -994,6 +995,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_address_family.bgp_address_family import ( Bgp_address_familyArgs, ) diff --git a/plugins/modules/nxos_bgp_af.py b/plugins/modules/nxos_bgp_af.py index d00ce318f..74c29a45e 100644 --- a/plugins/modules/nxos_bgp_af.py +++ b/plugins/modules/nxos_bgp_af.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -252,17 +253,16 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) BOOL_PARAMS = [ @@ -327,9 +327,7 @@ def get_value(arg, config, module): command = PARAM_TO_COMMAND_KEYMAP[arg] - command_val_re = re.compile( - r"(?:{0}\s)(?P.*)$".format(command), re.M - ) + command_val_re = re.compile(r"(?:{0}\s)(?P.*)$".format(command), re.M) has_command_val = command_val_re.search(config) if arg in ["networks", "redistribute", "inject_map"]: @@ -343,9 +341,7 @@ def get_value(arg, config, module): value.append(tl) elif command == "distance": - distance_re = ( - r".*distance\s(?P\w+)\s(?P\w+)\s(?P\w+)" - ) + distance_re = r".*distance\s(?P\w+)\s(?P\w+)\s(?P\w+)" match_distance = re.match(distance_re, config, re.DOTALL) value = "" @@ -388,9 +384,7 @@ def get_value(arg, config, module): value = True elif arg == "table_map": - tm_regex = re.compile( - r"(?:table-map\s)(?P\S+)(\sfilter)?$", re.M - ) + tm_regex = re.compile(r"(?:table-map\s)(?P\S+)(\sfilter)?$", re.M) has_tablemap = tm_regex.search(config) value = "" if has_tablemap: @@ -433,9 +427,7 @@ def get_existing(module, args, warnings): existing = {} netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - asn_regex = re.compile( - r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.DOTALL - ) + asn_regex = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.DOTALL) match_asn = asn_regex.match(str(netcfg)) if match_asn: @@ -444,11 +436,7 @@ def get_existing(module, args, warnings): if module.params["vrf"] != "default": parents.append("vrf {0}".format(module.params["vrf"])) - parents.append( - "address-family {0} {1}".format( - module.params["afi"], module.params["safi"] - ) - ) + parents.append("address-family {0} {1}".format(module.params["afi"], module.params["safi"])) config = netcfg.get_section(parents) if config: @@ -458,10 +446,7 @@ def get_existing(module, args, warnings): if gv: existing[arg] = gv else: - if ( - arg != "client_to_client" - and arg in PARAM_TO_DEFAULT_KEYMAP.keys() - ): + if arg != "client_to_client" and arg in PARAM_TO_DEFAULT_KEYMAP.keys(): existing[arg] = PARAM_TO_DEFAULT_KEYMAP.get(arg) else: existing[arg] = gv @@ -534,31 +519,22 @@ def default_existing(existing_value, key, value): if key == "network": for network in existing_value: if len(network) == 2: - commands.append( - "no network {0} route-map {1}".format( - network[0], network[1] - ) - ) + commands.append("no network {0} route-map {1}".format(network[0], network[1])) elif len(network) == 1: commands.append("no network {0}".format(network[0])) elif key == "inject-map": for maps in existing_value: if len(maps) == 2: - commands.append( - "no inject-map {0} exist-map {1}".format(maps[0], maps[1]) - ) + commands.append("no inject-map {0} exist-map {1}".format(maps[0], maps[1])) elif len(maps) == 3: commands.append( - "no inject-map {0} exist-map {1} " - "copy-attributes".format(maps[0], maps[1]) + "no inject-map {0} exist-map {1} " "copy-attributes".format(maps[0], maps[1]) ) elif key == "redistribute": for maps in existing_value: - commands.append( - "no redistribute {0} route-map {1}".format(maps[0], maps[1]) - ) + commands.append("no redistribute {0} route-map {1}".format(maps[0], maps[1])) elif key == "retain route-target": if existing_value == "all": @@ -589,9 +565,7 @@ def get_network_command(existing, key, value): if len(enet) == 1: command = "no {0} {1}".format(key, enet[0]) elif len(enet) == 2: - command = "no {0} {1} route-map {2}".format( - key, enet[0], enet[1] - ) + command = "no {0} {1} route-map {2}".format(key, enet[0], enet[1]) if command: commands.append(command) return commands @@ -605,26 +579,18 @@ def get_inject_map_command(existing, key, value): maps = [maps] if maps not in existing_maps: if len(maps) == 2: - command = "inject-map {0} exist-map {1}".format( - maps[0], maps[1] - ) + command = "inject-map {0} exist-map {1}".format(maps[0], maps[1]) elif len(maps) == 3: - command = ( - "inject-map {0} exist-map {1} " - "copy-attributes".format(maps[0], maps[1]) - ) + command = "inject-map {0} exist-map {1} " "copy-attributes".format(maps[0], maps[1]) if command: commands.append(command) for emaps in existing_maps: if emaps not in value: if len(emaps) == 2: - command = "no inject-map {0} exist-map {1}".format( - emaps[0], emaps[1] - ) + command = "no inject-map {0} exist-map {1}".format(emaps[0], emaps[1]) elif len(emaps) == 3: - command = ( - "no inject-map {0} exist-map {1} " - "copy-attributes".format(emaps[0], emaps[1]) + command = "no inject-map {0} exist-map {1} " "copy-attributes".format( + emaps[0], emaps[1] ) if command: commands.append(command) @@ -642,9 +608,7 @@ def get_redistribute_command(existing, key, value): commands.append(command) for erule in existing_rules: if erule not in value: - command = "no redistribute {0} route-map {1}".format( - erule[0], erule[1] - ) + command = "no redistribute {0} route-map {1}".format(erule[0], erule[1]) commands.append(command) return commands @@ -709,9 +673,7 @@ def state_present(module, existing, proposed, candidate): commands.append(addr_family_command) elif key.startswith("table-map"): - table_map_commands = get_table_map_command( - module, existing, key, value - ) + table_map_commands = get_table_map_command(module, existing, key, value) if table_map_commands: commands.extend(table_map_commands) @@ -723,23 +685,17 @@ def state_present(module, existing, proposed, candidate): elif value == "default": if key in PARAM_TO_DEFAULT_KEYMAP: - commands.append( - "{0} {1}".format(key, PARAM_TO_DEFAULT_KEYMAP[key]) - ) + commands.append("{0} {1}".format(key, PARAM_TO_DEFAULT_KEYMAP[key])) elif existing_commands.get(key): if key == "table-map-filter": - default_tmf_command = get_default_table_map_filter( - existing - ) + default_tmf_command = get_default_table_map_filter(existing) if default_tmf_command: commands.extend(default_tmf_command) else: existing_value = existing_commands.get(key) - default_command = default_existing( - existing_value, key, value - ) + default_command = default_existing(existing_value, key, value) if default_command: commands.extend(default_command) else: @@ -749,23 +705,17 @@ def state_present(module, existing, proposed, candidate): commands.extend(network_commands) elif key == "inject-map": - inject_map_commands = get_inject_map_command( - existing, key, value - ) + inject_map_commands = get_inject_map_command(existing, key, value) if inject_map_commands: commands.extend(inject_map_commands) elif key == "redistribute": - redistribute_commands = get_redistribute_command( - existing, key, value - ) + redistribute_commands = get_redistribute_command(existing, key, value) if redistribute_commands: commands.extend(redistribute_commands) elif key == "retain route-target": - retain_route_target_commands = get_retain_route_target_command( - existing, key, value - ) + retain_route_target_commands = get_retain_route_target_command(existing, key, value) if retain_route_target_commands: commands.extend(retain_route_target_commands) @@ -793,11 +743,7 @@ def state_absent(module, candidate): if module.params["vrf"] != "default": parents.append("vrf {0}".format(module.params["vrf"])) - commands.append( - "no address-family {0} {1}".format( - module.params["afi"], module.params["safi"] - ) - ) + commands.append("no address-family {0} {1}".format(module.params["afi"], module.params["safi"])) candidate.add(commands, parents=parents) @@ -805,9 +751,7 @@ def main(): argument_spec = dict( asn=dict(required=True, type="str"), vrf=dict(required=False, type="str", default="default"), - safi=dict( - required=True, type="str", choices=["unicast", "multicast", "evpn"] - ), + safi=dict(required=True, type="str", choices=["unicast", "multicast", "evpn"]), afi=dict( required=True, type="str", @@ -840,9 +784,7 @@ def main(): suppress_inactive=dict(required=False, type="bool"), table_map=dict(required=False, type="str"), table_map_filter=dict(required=False, type="bool"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), retain_route_target=dict(required=False, type="str"), ) @@ -885,10 +827,7 @@ def main(): ) if module.params["table_map_filter"] and not module.params["table_map"]: - module.fail_json( - msg="table_map param is needed when using" - " table_map_filter filter." - ) + module.fail_json(msg="table_map param is needed when using" " table_map_filter filter.") args = PARAM_TO_COMMAND_KEYMAP.keys() existing = get_existing(module, args, warnings) @@ -901,9 +840,7 @@ def main(): existing_asn=existing.get("asn"), ) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) for arg in ["networks", "inject_map", "redistribute"]: if proposed_args.get(arg): diff --git a/plugins/modules/nxos_bgp_global.py b/plugins/modules/nxos_bgp_global.py index f6d0c1f83..b3072d66e 100644 --- a/plugins/modules/nxos_bgp_global.py +++ b/plugins/modules/nxos_bgp_global.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1658,6 +1659,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_global.bgp_global import ( Bgp_globalArgs, ) diff --git a/plugins/modules/nxos_bgp_neighbor.py b/plugins/modules/nxos_bgp_neighbor.py index 5c4c39f56..46b657fde 100644 --- a/plugins/modules/nxos_bgp_neighbor.py +++ b/plugins/modules/nxos_bgp_neighbor.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -213,17 +214,16 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) BOOL_PARAMS = [ @@ -274,14 +274,10 @@ def get_value(arg, config): command = PARAM_TO_COMMAND_KEYMAP[arg] has_command = re.search(r"^\s+{0}$".format(command), config, re.M) - has_command_val = re.search( - r"(?:\s+{0}\s*)(?P.*)$".format(command), config, re.M - ) + has_command_val = re.search(r"(?:\s+{0}\s*)(?P.*)$".format(command), config, re.M) if arg == "dynamic_capability": - has_no_command = re.search( - r"\s+no\s{0}\s*$".format(command), config, re.M - ) + has_no_command = re.search(r"\s+no\s{0}\s*$".format(command), config, re.M) value = True if has_no_command: value = False @@ -321,9 +317,7 @@ def get_value(arg, config): if arg in ["timers_keepalive", "pwd_type"]: value = split_value[0] - elif ( - arg in ["timers_holdtime", "pwd"] and len(split_value) == 2 - ): + elif arg in ["timers_holdtime", "pwd"] and len(split_value) == 2: value = split_value[1] return value @@ -333,9 +327,7 @@ def get_existing(module, args, warnings): existing = {} netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - asn_regex = re.compile( - r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S - ) + asn_regex = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S) match_asn = asn_regex.match(str(netcfg)) if match_asn: @@ -356,9 +348,7 @@ def get_existing(module, args, warnings): existing["neighbor"] = module.params["neighbor"] existing["vrf"] = module.params["vrf"] else: - warnings.append( - "The BGP process didn't exist but the task" " just created it." - ) + warnings.append("The BGP process didn't exist but the task" " just created it.") return existing @@ -421,11 +411,7 @@ def state_present(module, existing, proposed, candidate): elif key == "timers": if proposed["timers_keepalive"] != PARAM_TO_DEFAULT_KEYMAP.get( "timers_keepalive" - ) or proposed[ - "timers_holdtime" - ] != PARAM_TO_DEFAULT_KEYMAP.get( - "timers_holdtime" - ): + ) or proposed["timers_holdtime"] != PARAM_TO_DEFAULT_KEYMAP.get("timers_holdtime"): command = "timers {0} {1}".format( proposed["timers_keepalive"], proposed["timers_holdtime"], @@ -514,9 +500,7 @@ def main(): timers_holdtime=dict(required=False, type="str"), transport_passive_only=dict(required=False, type="bool"), update_source=dict(required=False, type="str"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), peer_type=dict( required=False, type="str", @@ -553,9 +537,7 @@ def main(): existing_asn=existing.get("asn"), ) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): if key not in ["asn", "vrf", "neighbor", "pwd_type"]: diff --git a/plugins/modules/nxos_bgp_neighbor_address_family.py b/plugins/modules/nxos_bgp_neighbor_address_family.py index d55199719..967f8ee4e 100644 --- a/plugins/modules/nxos_bgp_neighbor_address_family.py +++ b/plugins/modules/nxos_bgp_neighbor_address_family.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1118,6 +1119,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_neighbor_address_family.bgp_neighbor_address_family import ( Bgp_neighbor_address_familyArgs, ) diff --git a/plugins/modules/nxos_bgp_neighbor_af.py b/plugins/modules/nxos_bgp_neighbor_af.py index 4fdfbb181..faa377208 100644 --- a/plugins/modules/nxos_bgp_neighbor_af.py +++ b/plugins/modules/nxos_bgp_neighbor_af.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -272,17 +273,16 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) BOOL_PARAMS = [ @@ -348,18 +348,14 @@ def get_value(arg, config, module): ] command = PARAM_TO_COMMAND_KEYMAP[arg] has_command = re.search(r"^\s+{0}\s*".format(command), config, re.M) - has_command_val = re.search( - r"(?:{0}\s)(?P.*)$".format(command), config, re.M - ) + has_command_val = re.search(r"(?:{0}\s)(?P.*)$".format(command), config, re.M) value = "" if arg in custom: value = get_custom_value(arg, config, module) elif arg == "next_hop_third_party": - has_no_command = re.search( - r"^\s+no\s+{0}\s*$".format(command), config, re.M - ) + has_no_command = re.search(r"^\s+no\s+{0}\s*$".format(command), config, re.M) value = False if not has_no_command: value = True @@ -372,9 +368,7 @@ def get_value(arg, config, module): elif command.startswith("advertise-map"): value = [] has_adv_map = re.search( - r"{0}\s(?P.*)\s{1}\s(?P.*)$".format( - *command.split() - ), + r"{0}\s(?P.*)\s{1}\s(?P.*)$".format(*command.split()), config, re.M, ) @@ -453,9 +447,7 @@ def get_existing(module, args, warnings): existing = {} netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - asn_regex = re.compile( - r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S - ) + asn_regex = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S) match_asn = asn_regex.match(str(netcfg)) if match_asn: @@ -466,11 +458,7 @@ def get_existing(module, args, warnings): parents.append("vrf {0}".format(module.params["vrf"])) parents.append("neighbor {0}".format(module.params["neighbor"])) - parents.append( - "address-family {0} {1}".format( - module.params["afi"], module.params["safi"] - ) - ) + parents.append("address-family {0} {1}".format(module.params["afi"], module.params["safi"])) config = netcfg.get_section(parents) if config: @@ -484,9 +472,7 @@ def get_existing(module, args, warnings): existing["afi"] = module.params["afi"] existing["safi"] = module.params["safi"] else: - warnings.append( - "The BGP process didn't exist but the task just created it." - ) + warnings.append("The BGP process didn't exist but the task just created it.") return existing @@ -551,10 +537,7 @@ def fix_proposed(module, existing, proposed): elif allowas_in and allowas_in_max: proposed.pop("allowas_in") - if ( - existing.get("send_community") == "none" - and proposed.get("send_community") == "default" - ): + if existing.get("send_community") == "none" and proposed.get("send_community") == "default": proposed.pop("send_community") return proposed @@ -579,17 +562,11 @@ def state_present(module, existing, proposed, candidate): elif key.startswith("maximum-prefix"): if module.params["max_prefix_limit"] != "default": - command = "maximum-prefix {0}".format( - module.params["max_prefix_limit"] - ) + command = "maximum-prefix {0}".format(module.params["max_prefix_limit"]) if module.params["max_prefix_threshold"]: - command += " {0}".format( - module.params["max_prefix_threshold"] - ) + command += " {0}".format(module.params["max_prefix_threshold"]) if module.params["max_prefix_interval"]: - command += " restart {0}".format( - module.params["max_prefix_interval"] - ) + command += " restart {0}".format(module.params["max_prefix_interval"]) elif module.params["max_prefix_warning"]: command += " warning-only" commands.append(command) @@ -600,9 +577,7 @@ def state_present(module, existing, proposed, candidate): commands.append("no {0}".format(key)) elif key == "address-family": commands.append( - "address-family {0} {1}".format( - module.params["afi"], module.params["safi"] - ) + "address-family {0} {1}".format(module.params["afi"], module.params["safi"]) ) elif key.startswith("capability additional-paths"): command = key @@ -611,9 +586,7 @@ def state_present(module, existing, proposed, candidate): commands.append(command) elif key.startswith("advertise-map"): direction = key.split()[1] - commands.append( - "advertise-map {1} {0} {2}".format(direction, *value) - ) + commands.append("advertise-map {1} {0} {2}".format(direction, *value)) elif key.split()[0] in ["filter-list", "prefix-list", "route-map"]: commands.append("{1} {0} {2}".format(value, *key.split())) @@ -641,9 +614,7 @@ def state_present(module, existing, proposed, candidate): parents.append("neighbor {0}".format(module.params["neighbor"])) - af_command = "address-family {0} {1}".format( - module.params["afi"], module.params["safi"] - ) + af_command = "address-family {0} {1}".format(module.params["afi"], module.params["safi"]) parents.append(af_command) if af_command in commands: commands.remove(af_command) @@ -657,11 +628,7 @@ def state_absent(module, existing, candidate): parents.append("vrf {0}".format(module.params["vrf"])) parents.append("neighbor {0}".format(module.params["neighbor"])) - commands.append( - "no address-family {0} {1}".format( - module.params["afi"], module.params["safi"] - ) - ) + commands.append("no address-family {0} {1}".format(module.params["afi"], module.params["safi"])) candidate.add(commands, parents=parents) @@ -675,9 +642,7 @@ def main(): type="str", choices=["ipv4", "ipv6", "vpnv4", "vpnv6", "l2vpn"], ), - safi=dict( - required=True, type="str", choices=["unicast", "multicast", "evpn"] - ), + safi=dict(required=True, type="str", choices=["unicast", "multicast", "evpn"]), additional_paths_receive=dict( required=False, type="str", @@ -689,9 +654,7 @@ def main(): choices=["enable", "disable", "inherit"], ), advertise_map_exist=dict(required=False, type="list", elements="str"), - advertise_map_non_exist=dict( - required=False, type="list", elements="str" - ), + advertise_map_non_exist=dict(required=False, type="list", elements="str"), allowas_in=dict(required=False, type="bool"), allowas_in_max=dict(required=False, type="str"), as_override=dict(required=False, type="bool"), @@ -722,9 +685,7 @@ def main(): suppress_inactive=dict(required=False, type="bool"), unsuppress_map=dict(required=False, type="str"), weight=dict(required=False, type="str"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), rewrite_evpn_rt_asn=dict(required=False, type="bool"), ) argument_spec.update(nxos_argument_spec) @@ -750,9 +711,7 @@ def main(): "max_prefix_threshold", ]: if module.params[key] and not module.params["max_prefix_limit"]: - module.fail_json( - msg="max_prefix_limit is required when using %s" % key - ) + module.fail_json(msg="max_prefix_limit is required when using %s" % key) if module.params["vrf"] == "default" and module.params["soo"]: module.fail_json(msg="SOO is only allowed in non-default VRF") @@ -771,9 +730,7 @@ def main(): if module.params[param] == ["default"]: module.params[param] = "default" - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): diff --git a/plugins/modules/nxos_command.py b/plugins/modules/nxos_command.py index 6cabf9b7a..def8e7c8f 100644 --- a/plugins/modules/nxos_command.py +++ b/plugins/modules/nxos_command.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -139,9 +140,10 @@ FailedConditionalError, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - transform_commands, to_lines, + transform_commands, ) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, run_commands, @@ -183,9 +185,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {"changed": False, "warnings": warnings} @@ -225,9 +225,7 @@ def main(): msg = "One or more conditional statements have not been satisfied" module.fail_json(msg=msg, failed_conditions=failed_conditions) - result.update( - {"stdout": responses, "stdout_lines": list(to_lines(responses))} - ) + result.update({"stdout": responses, "stdout_lines": list(to_lines(responses))}) module.exit_json(**result) diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index 5727c9e9a..13b372358 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -329,17 +330,14 @@ NetworkConfig, dumps, ) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, - load_config, - run_commands, get_connection, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + load_config, nxos_argument_spec, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - to_list, + run_commands, ) @@ -403,18 +401,14 @@ def main(): parents=dict(type="list", elements="str"), before=dict(type="list", elements="str"), after=dict(type="list", elements="str"), - match=dict( - default="line", choices=["line", "strict", "exact", "none"] - ), + match=dict(default="line", choices=["line", "strict", "exact", "none"]), replace=dict(default="line", choices=["line", "block", "config"]), running_config=dict(aliases=["config"]), intended_config=dict(), defaults=dict(type="bool", default=False), backup=dict(type="bool", default=False), backup_options=dict(type="dict", options=backup_spec), - save_when=dict( - choices=["always", "never", "modified", "changed"], default="never" - ), + save_when=dict(choices=["always", "never", "modified", "changed"], default="never"), diff_against=dict(choices=["running", "startup", "intended"]), diff_ignore_lines=dict(type="list", elements="str"), ) @@ -452,13 +446,9 @@ def main(): replace_src = module.params["replace_src"] if replace_src: if module.params["replace"] != "config": - module.fail_json( - msg="replace: config is required with replace_src" - ) + module.fail_json(msg="replace: config is required with replace_src") - if module.params["backup"] or ( - module._diff and module.params["diff_against"] == "running" - ): + if module.params["backup"] or (module._diff and module.params["diff_against"] == "running"): contents = get_config(module, flags=flags) config = NetworkConfig(indent=2, contents=contents) if module.params["backup"]: @@ -489,9 +479,7 @@ def main(): diff_replace=replace, ) except ConnectionError as exc: - module.fail_json( - msg=to_text(exc, errors="surrogate_then_replace") - ) + module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) config_diff = response["config_diff"] if config_diff: @@ -517,16 +505,10 @@ def main(): if module.params["save_when"] == "always": save_config(module, result) elif module.params["save_when"] == "modified": - output = execute_show_commands( - module, ["show running-config", "show startup-config"] - ) + output = execute_show_commands(module, ["show running-config", "show startup-config"]) - running_config = NetworkConfig( - indent=2, contents=output[0], ignore_lines=diff_ignore_lines - ) - startup_config = NetworkConfig( - indent=2, contents=output[1], ignore_lines=diff_ignore_lines - ) + running_config = NetworkConfig(indent=2, contents=output[0], ignore_lines=diff_ignore_lines) + startup_config = NetworkConfig(indent=2, contents=output[1], ignore_lines=diff_ignore_lines) if running_config.sha1 != startup_config.sha1: save_config(module, result) @@ -541,15 +523,11 @@ def main(): contents = running_config # recreate the object in order to process diff_ignore_lines - running_config = NetworkConfig( - indent=2, contents=contents, ignore_lines=diff_ignore_lines - ) + running_config = NetworkConfig(indent=2, contents=contents, ignore_lines=diff_ignore_lines) if module.params["diff_against"] == "running": if module.check_mode: - module.warn( - "unable to perform diff against running-config due to check mode" - ) + module.warn("unable to perform diff against running-config due to check mode") contents = None else: contents = config.config_text @@ -565,9 +543,7 @@ def main(): contents = module.params["intended_config"] if contents is not None: - base_config = NetworkConfig( - indent=2, contents=contents, ignore_lines=diff_ignore_lines - ) + base_config = NetworkConfig(indent=2, contents=contents, ignore_lines=diff_ignore_lines) if running_config.sha1 != base_config.sha1: if module.params["diff_against"] == "intended": @@ -584,9 +560,7 @@ def main(): } ) - if result.get("changed") and any( - (module.params["src"], module.params["lines"]) - ): + if result.get("changed") and any((module.params["src"], module.params["lines"])): msg = ( "To ensure idempotency and correct diff the input configuration lines should be" " similar to how they appear if present in" diff --git a/plugins/modules/nxos_evpn_global.py b/plugins/modules/nxos_evpn_global.py index 15b8cc59a..639bc658a 100644 --- a/plugins/modules/nxos_evpn_global.py +++ b/plugins/modules/nxos_evpn_global.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -54,12 +55,11 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, nxos_argument_spec, ) @@ -69,9 +69,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) result = {"changed": False} @@ -86,9 +84,7 @@ def main(): os_platform = info.get("network_os_platform", "") if "3K" in os_platform: - module.fail_json( - msg="This module is not supported on Nexus 3000 series" - ) + module.fail_json(msg="This module is not supported on Nexus 3000 series") if module.params["nv_overlay_evpn"] is True: if "nv overlay evpn" not in config: diff --git a/plugins/modules/nxos_evpn_vni.py b/plugins/modules/nxos_evpn_vni.py index 023507758..a8fa99c5a 100644 --- a/plugins/modules/nxos_evpn_vni.py +++ b/plugins/modules/nxos_evpn_vni.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -103,17 +104,17 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) PARAM_TO_COMMAND_KEYMAP = { @@ -215,17 +216,13 @@ def state_present(module, existing, proposed): if target == "default": continue if existing: - if target not in existing.get( - key.replace("-", "_").replace(" ", "_") - ): + if target not in existing.get(key.replace("-", "_").replace(" ", "_")): commands.append("{0} {1}".format(key, target)) else: commands.append("{0} {1}".format(key, target)) if existing.get(key.replace("-", "_").replace(" ", "_")): - for exi in existing.get( - key.replace("-", "_").replace(" ", "_") - ): + for exi in existing.get(key.replace("-", "_").replace(" ", "_")): if exi not in value: commands.append("no {0} {1}".format(key, exi)) @@ -256,16 +253,12 @@ def main(): route_target_both=dict(required=False, type="list", elements="str"), route_target_import=dict(required=False, type="list", elements="str"), route_target_export=dict(required=False, type="list", elements="str"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = dict(changed=False, warnings=warnings) @@ -273,9 +266,7 @@ def main(): state = module.params["state"] args = PARAM_TO_COMMAND_KEYMAP.keys() existing = get_existing(module, args) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) commands = [] parents = [] diff --git a/plugins/modules/nxos_facts.py b/plugins/modules/nxos_facts.py index e484222dc..4b5bf2791 100644 --- a/plugins/modules/nxos_facts.py +++ b/plugins/modules/nxos_facts.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -212,16 +213,15 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.facts.facts import ( FactsArgs, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - Facts, FACT_RESOURCE_SUBSETS, + Facts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_argument_spec def main(): @@ -233,17 +233,13 @@ def main(): argument_spec = FactsArgs.argument_spec argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = [] ansible_facts = {} if module.params.get("available_network_resources"): - ansible_facts["available_network_resources"] = sorted( - FACT_RESOURCE_SUBSETS.keys() - ) + ansible_facts["available_network_resources"] = sorted(FACT_RESOURCE_SUBSETS.keys()) result = Facts(module).get_facts() additional_facts, additional_warnings = result ansible_facts.update(additional_facts) diff --git a/plugins/modules/nxos_feature.py b/plugins/modules/nxos_feature.py index 4a42d120f..48df234f3 100644 --- a/plugins/modules/nxos_feature.py +++ b/plugins/modules/nxos_feature.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -79,14 +80,13 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.connection import ConnectionError -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, - get_config, -) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, + get_config, + load_config, nxos_argument_spec, + run_commands, ) @@ -118,10 +118,7 @@ def get_available_features(feature, module): if feature not in available_features: available_features[feature] = state else: - if ( - available_features[feature] == "disabled" - and state == "enabled" - ): + if available_features[feature] == "disabled" and state == "enabled": available_features[feature] = state # certain configurable features do not @@ -274,9 +271,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = dict(changed=False, warnings=warnings) diff --git a/plugins/modules/nxos_file_copy.py b/plugins/modules/nxos_file_copy.py index af689c121..13873a04c 100644 --- a/plugins/modules/nxos_file_copy.py +++ b/plugins/modules/nxos_file_copy.py @@ -18,6 +18,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -222,19 +223,18 @@ sample: true """ -import re -import os import hashlib +import os +import re -from ansible.module_utils._text import to_text, to_bytes +from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network import ( get_resource_connection, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_argument_spec + class FilePush: def __init__(self, module): @@ -245,18 +245,14 @@ def __init__(self, module): def md5sum_check(self, dst, file_system): command = "show file {0}{1} md5sum".format(file_system, dst) remote_filehash = self._connection.run_commands(command)[0] - remote_filehash = to_bytes( - remote_filehash, errors="surrogate_or_strict" - ) + remote_filehash = to_bytes(remote_filehash, errors="surrogate_or_strict") local_file = self._module.params["local_file"] try: with open(local_file, "rb") as f: filecontent = f.read() except (OSError, IOError) as exc: - self._module.fail_json( - "Error reading the file: {0}".format(to_text(exc)) - ) + self._module.fail_json("Error reading the file: {0}".format(to_text(exc))) filecontent = to_bytes(filecontent, errors="surrogate_or_strict") local_filehash = hashlib.md5(filecontent).hexdigest() @@ -288,15 +284,9 @@ def get_flash_size(self, file_system): match = re.search(r"No such file or directory", body) if match: - self._module.fail_json( - "Invalid nxos filesystem {0}".format(file_system) - ) + self._module.fail_json("Invalid nxos filesystem {0}".format(file_system)) else: - self._module.fail_json( - "Unable to determine size of filesystem {0}".format( - file_system - ) - ) + self._module.fail_json("Unable to determine size of filesystem {0}".format(file_system)) def enough_space(self, file, file_system): flash_size = self.get_flash_size(file_system) @@ -311,9 +301,7 @@ def transfer_file_to_device(self, remote_file): file_system = self._module.params["file_system"] if not self.enough_space(local_file, file_system): - self._module.fail_json( - "Could not transfer file. Not enough space on device." - ) + self._module.fail_json("Could not transfer file. Not enough space on device.") # frp = full_remote_path, flp = full_local_path frp = "{0}{1}".format(file_system, remote_file) @@ -323,28 +311,20 @@ def transfer_file_to_device(self, remote_file): source=flp, destination=frp, proto="scp", - timeout=self._connection.get_option( - "persistent_command_timeout" - ), + timeout=self._connection.get_option("persistent_command_timeout"), ) - self.result[ - "transfer_status" - ] = "Sent: File copied to remote device." + self.result["transfer_status"] = "Sent: File copied to remote device." except Exception as exc: self.result["failed"] = True self.result["msg"] = "Exception received : %s" % exc def run(self): local_file = self._module.params["local_file"] - remote_file = self._module.params["remote_file"] or os.path.basename( - local_file - ) + remote_file = self._module.params["remote_file"] or os.path.basename(local_file) file_system = self._module.params["file_system"] if not os.path.isfile(local_file): - self._module.fail_json( - "Local file {0} not found".format(local_file) - ) + self._module.fail_json("Local file {0} not found".format(local_file)) remote_file = remote_file or os.path.basename(local_file) remote_exists = self.remote_file_exists(remote_file, file_system) @@ -353,9 +333,7 @@ def run(self): self.result["changed"] = True file_exists = False else: - self.result[ - "transfer_status" - ] = "No Transfer: File already copied to remote device." + self.result["transfer_status"] = "No Transfer: File already copied to remote device." file_exists = True if not self._module.check_mode and not file_exists: @@ -425,9 +403,7 @@ def copy_file_from_remote(self, local, local_file_directory, file_system): ) self.result["copy_cmd"] = copy_cmd - pulled = self._connection.pull_file( - command=copy_cmd, remotepassword=rserverpassword - ) + pulled = self._connection.pull_file(command=copy_cmd, remotepassword=rserverpassword) if pulled: self.result[ "transfer_status" @@ -438,9 +414,7 @@ def copy_file_from_remote(self, local, local_file_directory, file_system): def run(self): self.result["failed"] = False remote_file = self._module.params["remote_file"] - local_file = ( - self._module.params["local_file"] or remote_file.split("/")[-1] - ) + local_file = self._module.params["local_file"] or remote_file.split("/")[-1] file_system = self._module.params["file_system"] # Note: This is the local file directory on the remote nxos device. local_file_dir = self._module.params["local_file_directory"] @@ -454,9 +428,7 @@ def run(self): else: dir = "" self.result["local_file"] = file_system + dir + "/" + local_file - self.result["remote_scp_server"] = self._module.params[ - "remote_scp_server" - ] + self.result["remote_scp_server"] = self._module.params["remote_scp_server"] self.result["file_system"] = self._module.params["file_system"] if not self.result["failed"]: @@ -491,9 +463,7 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, - required_if=[ - ("file_pull", True, ("remote_file", "remote_scp_server")) - ], + required_if=[("file_pull", True, ("remote_file", "remote_scp_server"))], required_together=[("remote_scp_server", "remote_scp_server_user")], supports_check_mode=True, ) diff --git a/plugins/modules/nxos_gir.py b/plugins/modules/nxos_gir.py index 693bf73a3..4c3c46cd6 100644 --- a/plugins/modules/nxos_gir.py +++ b/plugins/modules/nxos_gir.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -164,14 +165,13 @@ sample: true """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def get_system_mode(module): @@ -204,15 +204,11 @@ def get_commands(module, state, mode): commands = list() if module.params["system_mode_maintenance"] is True and mode == "normal": commands.append("system mode maintenance") - elif ( - module.params["system_mode_maintenance"] is False - and mode == "maintenance" - ): + elif module.params["system_mode_maintenance"] is False and mode == "maintenance": commands.append("no system mode maintenance") elif ( - module.params["system_mode_maintenance_dont_generate_profile"] is True - and mode == "normal" + module.params["system_mode_maintenance_dont_generate_profile"] is True and mode == "normal" ): commands.append("system mode maintenance dont-generate-profile") elif ( @@ -223,65 +219,46 @@ def get_commands(module, state, mode): elif module.params["system_mode_maintenance_timeout"]: timeout = get_maintenance_timeout(module) - if ( - state == "present" - and timeout != module.params["system_mode_maintenance_timeout"] - ): + if state == "present" and timeout != module.params["system_mode_maintenance_timeout"]: commands.append( "system mode maintenance timeout {0}".format( module.params["system_mode_maintenance_timeout"] ) ) - elif ( - state == "absent" - and timeout == module.params["system_mode_maintenance_timeout"] - ): + elif state == "absent" and timeout == module.params["system_mode_maintenance_timeout"]: commands.append( "no system mode maintenance timeout {0}".format( module.params["system_mode_maintenance_timeout"] ) ) - elif ( - module.params["system_mode_maintenance_shutdown"] and mode == "normal" - ): + elif module.params["system_mode_maintenance_shutdown"] and mode == "normal": commands.append("system mode maintenance shutdown") - elif ( - module.params["system_mode_maintenance_shutdown"] is False - and mode == "maintenance" - ): + elif module.params["system_mode_maintenance_shutdown"] is False and mode == "maintenance": commands.append("no system mode maintenance") elif module.params["system_mode_maintenance_on_reload_reset_reason"]: reset_reasons = get_reset_reasons(module) if ( state == "present" - and module.params[ - "system_mode_maintenance_on_reload_reset_reason" - ].lower() + and module.params["system_mode_maintenance_on_reload_reset_reason"].lower() not in reset_reasons.lower() ): commands.append( "system mode maintenance on-reload " "reset-reason {0}".format( - module.params[ - "system_mode_maintenance_on_reload_reset_reason" - ] + module.params["system_mode_maintenance_on_reload_reset_reason"] ) ) elif ( state == "absent" - and module.params[ - "system_mode_maintenance_on_reload_reset_reason" - ].lower() + and module.params["system_mode_maintenance_on_reload_reset_reason"].lower() in reset_reasons.lower() ): commands.append( "no system mode maintenance on-reload " "reset-reason {0}".format( - module.params[ - "system_mode_maintenance_on_reload_reset_reason" - ] + module.params["system_mode_maintenance_on_reload_reset_reason"] ) ) @@ -293,9 +270,7 @@ def get_commands(module, state, mode): def main(): argument_spec = dict( system_mode_maintenance=dict(required=False, type="bool"), - system_mode_maintenance_dont_generate_profile=dict( - required=False, type="bool" - ), + system_mode_maintenance_dont_generate_profile=dict(required=False, type="bool"), system_mode_maintenance_timeout=dict(required=False, type="str"), system_mode_maintenance_shutdown=dict(required=False, type="bool"), system_mode_maintenance_on_reload_reset_reason=dict( @@ -313,9 +288,7 @@ def main(): "maintenance", ], ), - state=dict( - choices=["absent", "present"], default="present", required=False - ), + state=dict(choices=["absent", "present"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) diff --git a/plugins/modules/nxos_gir_profile_management.py b/plugins/modules/nxos_gir_profile_management.py index 7c3f092af..03cc5afef 100644 --- a/plugins/modules/nxos_gir_profile_management.py +++ b/plugins/modules/nxos_gir_profile_management.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -105,17 +106,16 @@ """ +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) def get_existing(module): @@ -173,9 +173,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_hostname.py b/plugins/modules/nxos_hostname.py index 122c49f11..42e45677a 100644 --- a/plugins/modules/nxos_hostname.py +++ b/plugins/modules/nxos_hostname.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -192,6 +193,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.hostname.hostname import ( HostnameArgs, ) diff --git a/plugins/modules/nxos_hsrp.py b/plugins/modules/nxos_hsrp.py index 1ecee4478..d48a0def4 100644 --- a/plugins/modules/nxos_hsrp.py +++ b/plugins/modules/nxos_hsrp.py @@ -1,6 +1,7 @@ #!/usr/bin/python from __future__ import absolute_import, division, print_function + __metaclass__ = type # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -142,18 +143,15 @@ sample: ["interface vlan10", "hsrp version 2", "hsrp 30", "ip 10.30.1.1"] """ -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, - nxos_argument_spec, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_interface_type, + load_config, + nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule PARAM_TO_DEFAULT_KEYMAP = { @@ -218,9 +216,7 @@ def get_hsrp_group(group, interface, module): if "sh_keystring_attr" not in hsrp_table: del hsrp_key["sh_keystring_attr"] if "unknown enum:" in str(hsrp_table): - hsrp_table = get_hsrp_group_unknown_enum( - module, command, hsrp_table - ) + hsrp_table = get_hsrp_group_unknown_enum(module, command, hsrp_table) except (AttributeError, IndexError, TypeError, KeyError): return {} @@ -258,9 +254,7 @@ def get_hsrp_group_unknown_enum(module, command, hsrp_table): if "unknown enum:" in hsrp_table["sh_preempt"]: cmd = {"output": "text", "command": command.split("|")[0]} out = run_commands(module, cmd)[0] - hsrp_table["sh_preempt"] = ( - "enabled" if ("may preempt" in out) else "disabled" - ) + hsrp_table["sh_preempt"] = "enabled" if ("may preempt" in out) else "disabled" return hsrp_table @@ -292,9 +286,7 @@ def get_commands_config_hsrp(delta, interface, args, existing): if priority: if priority == "default": - if existing and existing.get( - "priority" - ) != PARAM_TO_DEFAULT_KEYMAP.get("priority"): + if existing and existing.get("priority") != PARAM_TO_DEFAULT_KEYMAP.get("priority"): delta["priority"] = "no priority" else: del delta["priority"] @@ -303,9 +295,7 @@ def get_commands_config_hsrp(delta, interface, args, existing): if vip: if vip == "default": - if existing and existing.get("vip") != PARAM_TO_DEFAULT_KEYMAP.get( - "vip" - ): + if existing and existing.get("vip") != PARAM_TO_DEFAULT_KEYMAP.get("vip"): delta["vip"] = "no ip" else: del delta["vip"] @@ -331,17 +321,15 @@ def get_commands_config_hsrp(delta, interface, args, existing): auth_string = args["auth_string"] if auth_string != "default": if auth_type == "md5": - command = "authentication md5 key-string {0} {1}".format( - auth_enc, auth_string - ) + command = "authentication md5 key-string {0} {1}".format(auth_enc, auth_string) commands.append(command) elif auth_type == "text": command = "authentication text {0}".format(auth_string) commands.append(command) else: - if existing and existing.get( + if existing and existing.get("auth_string") != PARAM_TO_DEFAULT_KEYMAP.get( "auth_string" - ) != PARAM_TO_DEFAULT_KEYMAP.get("auth_string"): + ): commands.append("no authentication") if commands and not group: @@ -383,9 +371,7 @@ def is_default(interface, module): def validate_config(body, vip, module): new_body = "".join(body) if "invalid ip address" in new_body.lower(): - module.fail_json( - msg="Invalid VIP. Possible duplicate IP address.", vip=vip - ) + module.fail_json(msg="Invalid VIP. Possible duplicate IP address.", vip=vip) def main(): @@ -394,22 +380,16 @@ def main(): interface=dict(required=True), version=dict(choices=["1", "2"], default="1", required=False), priority=dict(type="str", required=False), - preempt=dict( - type="str", choices=["disabled", "enabled"], required=False - ), + preempt=dict(type="str", choices=["disabled", "enabled"], required=False), vip=dict(type="str", required=False), auth_type=dict(choices=["text", "md5"], required=False), auth_string=dict(type="str", required=False), - state=dict( - choices=["absent", "present"], required=False, default="present" - ), + state=dict(choices=["absent", "present"], required=False, default="present"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = dict(changed=False, warnings=warnings) @@ -456,16 +436,14 @@ def main(): mode = get_interface_mode(interface, intf_type, module) if mode == "layer2": module.fail_json( - msg="That interface is a layer2 port.\nMake it " - "a layer 3 port first.", + msg="That interface is a layer2 port.\nMake it " "a layer 3 port first.", interface=interface, ) if auth_type or auth_string: if not (auth_type and auth_string): module.fail_json( - msg="When using auth parameters, you need BOTH " - "auth_type AND auth_string." + msg="When using auth parameters, you need BOTH " "auth_type AND auth_string." ) args = dict( @@ -486,26 +464,19 @@ def main(): # This will enforce better practice with md5 and hsrp version. if proposed.get("auth_type", None) == "md5": if proposed["version"] == "1": - module.fail_json( - msg="It's recommended to use HSRP v2 " "when auth_type=md5" - ) + module.fail_json(msg="It's recommended to use HSRP v2 " "when auth_type=md5") elif not proposed.get("auth_type", None) and existing: - if ( - proposed["version"] == "1" and existing["auth_type"] == "md5" - ) and state == "present": + if (proposed["version"] == "1" and existing["auth_type"] == "md5") and state == "present": module.fail_json( - msg="Existing auth_type is md5. It's recommended " - "to use HSRP v2 when using md5" + msg="Existing auth_type is md5. It's recommended " "to use HSRP v2 when using md5" ) commands = [] if state == "present": delta = dict(set(proposed.items()).difference(existing.items())) if delta: - command = get_commands_config_hsrp( - delta, interface, args, existing - ) + command = get_commands_config_hsrp(delta, interface, args, existing) commands.extend(command) elif state == "absent": diff --git a/plugins/modules/nxos_hsrp_interfaces.py b/plugins/modules/nxos_hsrp_interfaces.py index d425ba61d..e5ac67376 100644 --- a/plugins/modules/nxos_hsrp_interfaces.py +++ b/plugins/modules/nxos_hsrp_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -224,6 +225,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.hsrp_interfaces.hsrp_interfaces import ( Hsrp_interfacesArgs, ) diff --git a/plugins/modules/nxos_igmp.py b/plugins/modules/nxos_igmp.py index 46b5cd9df..7e3a3d134 100644 --- a/plugins/modules/nxos_igmp.py +++ b/plugins/modules/nxos_igmp.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -84,20 +85,17 @@ type: list sample: ["ip igmp flush-routes"] """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def get_current(module): - output = run_commands( - module, {"command": "show running-config", "output": "text"} - ) + output = run_commands(module, {"command": "show running-config", "output": "text"}) return { "flush_routes": "ip igmp flush-routes" in output[0], "enforce_rtr_alert": "ip igmp enforce-router-alert" in output[0], @@ -121,9 +119,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_igmp_interface.py b/plugins/modules/nxos_igmp_interface.py index fd688fd1b..295209819 100644 --- a/plugins/modules/nxos_igmp_interface.py +++ b/plugins/modules/nxos_igmp_interface.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -188,19 +189,16 @@ sample: true """ +import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_interface_type, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_interface_type, -) -from ansible.module_utils.basic import AnsibleModule - -import re def execute_show_command(command, module, command_type="cli_show"): @@ -281,9 +279,7 @@ def get_igmp_interface(module, interface): elif report_llg == "false": igmp["report_llg"] = False - immediate_leave = str( - resource["ImmediateLeave"] - ).lower() # returns en or dis + immediate_leave = str(resource["ImmediateLeave"]).lower() # returns en or dis if re.search(r"^en|^true|^enabled", immediate_leave): igmp["immediate_leave"] = True elif re.search(r"^dis|^false|^disabled", immediate_leave): @@ -294,16 +290,12 @@ def get_igmp_interface(module, interface): # or PREFIX source , etc. command = "show run interface {0} | inc oif".format(interface) - body = execute_show_command( - command, module, command_type="cli_show_ascii" - )[0] + body = execute_show_command(command, module, command_type="cli_show_ascii")[0] staticoif = [] if body: split_body = body.split("\n") - route_map_regex = ( - r".*ip igmp static-oif route-map\s+(?P\S+).*" - ) + route_map_regex = r".*ip igmp static-oif route-map\s+(?P\S+).*" prefix_source_regex = ( r".*ip igmp static-oif\s+(?P" r"((\d+.){3}\d+))(\ssource\s" @@ -319,9 +311,7 @@ def get_igmp_interface(module, interface): route_map = "" try: - match_prefix_source = re.match( - prefix_source_regex, line, re.DOTALL - ) + match_prefix_source = re.match(prefix_source_regex, line, re.DOTALL) prefix_source_group = match_prefix_source.groupdict() prefix = prefix_source_group["prefix"] source = prefix_source_group["source"] @@ -385,9 +375,7 @@ def config_igmp_interface(delta, existing, existing_oif_prefix_source): if "source" in each.keys(): src = each["source"] if src: - commands.append( - CMDS.get("oif_prefix_source").format(pf, src) - ) + commands.append(CMDS.get("oif_prefix_source").format(pf, src)) else: commands.append(CMDS.get("oif_prefix").format(pf)) if existing_oif_prefix_source: @@ -398,14 +386,9 @@ def config_igmp_interface(delta, existing, existing_oif_prefix_source): if "source" in each.keys(): src = each["source"] if src: - commands.append( - "no " - + CMDS.get("oif_prefix_source").format(pf, src) - ) + commands.append("no " + CMDS.get("oif_prefix_source").format(pf, src)) else: - commands.append( - "no " + CMDS.get("oif_prefix").format(pf) - ) + commands.append("no " + CMDS.get("oif_prefix").format(pf)) elif key == "oif_routemap": if value == "default": if existing.get(key): @@ -458,9 +441,7 @@ def get_igmp_interface_defaults(): immediate_leave=immediate_leave, ) - default = dict( - (param, value) for (param, value) in args.items() if value is not None - ) + default = dict((param, value) for (param, value) in args.items() if value is not None) return default @@ -470,9 +451,7 @@ def config_default_igmp_interface(existing, delta): proposed = get_igmp_interface_defaults() delta = dict(set(proposed.items()).difference(existing.items())) if delta: - command = config_igmp_interface( - delta, existing, existing_oif_prefix_source=None - ) + command = config_igmp_interface(delta, existing, existing_oif_prefix_source=None) if command: for each in command: @@ -485,11 +464,7 @@ def config_remove_oif(existing, existing_oif_prefix_source): commands = [] command = None if existing.get("oif_routemap"): - commands.append( - "no ip igmp static-oif route-map {0}".format( - existing.get("oif_routemap") - ) - ) + commands.append("no ip igmp static-oif route-map {0}".format(existing.get("oif_routemap"))) elif existing_oif_prefix_source: for each in existing_oif_prefix_source: if each.get("prefix") and each.get("source"): @@ -497,9 +472,7 @@ def config_remove_oif(existing, existing_oif_prefix_source): each.get("prefix"), each.get("source") ) elif each.get("prefix"): - command = "no ip igmp static-oif {0}".format( - each.get("prefix") - ) + command = "no ip igmp static-oif {0}".format(each.get("prefix")) if command: commands.append(command) command = None @@ -510,9 +483,7 @@ def config_remove_oif(existing, existing_oif_prefix_source): def main(): argument_spec = dict( interface=dict(required=True, type="str"), - version=dict( - required=False, type="str", choices=["2", "3", "default"] - ), + version=dict(required=False, type="str", choices=["2", "3", "default"]), startup_query_interval=dict(required=False, type="str"), startup_query_count=dict(required=False, type="str"), robustness=dict(required=False, type="str"), @@ -527,9 +498,7 @@ def main(): oif_routemap=dict(required=False, type="str"), oif_ps=dict(required=False, type="raw"), restart=dict(type="bool", default=False), - state=dict( - choices=["present", "absent", "default"], default="present" - ), + state=dict(choices=["present", "absent", "default"], default="present"), ) argument_spec.update(nxos_argument_spec) @@ -594,9 +563,7 @@ def main(): changed = False commands = [] - proposed = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) CANNOT_ABSENT = [ "version", @@ -617,9 +584,7 @@ def main(): for each in CANNOT_ABSENT: if each in proposed: module.fail_json( - msg="only params: " - "oif_ps, oif_routemap can be used when " - "state=absent" + msg="only params: " "oif_ps, oif_routemap can be used when " "state=absent" ) # delta check for all params except oif_ps @@ -633,9 +598,7 @@ def main(): if state == "present": if delta: - command = config_igmp_interface( - delta, existing, existing_oif_prefix_source - ) + command = config_igmp_interface(delta, existing, existing_oif_prefix_source) if command: commands.append(command) diff --git a/plugins/modules/nxos_igmp_snooping.py b/plugins/modules/nxos_igmp_snooping.py index 5f6dfafdb..9a8c8e0ca 100644 --- a/plugins/modules/nxos_igmp_snooping.py +++ b/plugins/modules/nxos_igmp_snooping.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -98,14 +99,13 @@ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module, output="text"): @@ -161,9 +161,7 @@ def get_igmp_snooping(module): link_local_grp_supp = str(body.get("glinklocalgrpsup")).lower() if "none" in link_local_grp_supp: - link_local_grp_supp = str( - body.get("GlobalLinkLocalGroupSupression") - ).lower() + link_local_grp_supp = str(body.get("GlobalLinkLocalGroupSupression")).lower() if link_local_grp_supp == "true" or link_local_grp_supp == "enabled": existing["link_local_grp_supp"] = True else: @@ -201,9 +199,7 @@ def config_igmp_snooping(delta, existing, default=False): if value: if default and key == "group_timeout": if existing.get(key): - gt_command = "no " + CMDS.get(key).format( - existing.get(key) - ) + gt_command = "no " + CMDS.get(key).format(existing.get(key)) elif value == "default" and key == "group_timeout": if existing.get(key): command = "no " + CMDS.get(key).format(existing.get(key)) @@ -237,9 +233,7 @@ def get_igmp_snooping_defaults(): group_timeout=group_timeout, ) - default = dict( - (param, value) for (param, value) in args.items() if value is not None - ) + default = dict((param, value) for (param, value) in args.items() if value is not None) return default @@ -271,9 +265,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} @@ -293,9 +285,7 @@ def main(): group_timeout=group_timeout, ) - proposed = dict( - (param, value) for (param, value) in args.items() if value is not None - ) + proposed = dict((param, value) for (param, value) in args.items() if value is not None) existing = get_igmp_snooping(module) diff --git a/plugins/modules/nxos_install_os.py b/plugins/modules/nxos_install_os.py index acd7f3847..126577647 100644 --- a/plugins/modules/nxos_install_os.py +++ b/plugins/modules/nxos_install_os.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -122,15 +123,16 @@ import re + from time import sleep + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule # Output options are 'text' or 'json' @@ -390,9 +392,7 @@ def build_install_cmd_set(issu, image, kick, type, force=True): if kick is None: commands.append("%s nxos %s %s" % (rootcmd, image, issu_cmd)) else: - commands.append( - "%s %s system %s kickstart %s" % (rootcmd, issu_cmd, image, kick) - ) + commands.append("%s %s system %s kickstart %s" % (rootcmd, issu_cmd, image, kick)) return commands @@ -430,10 +430,7 @@ def check_mode_legacy(module, issu, image, kick=None): if target_image["error"]: data["error"] = True data["raw"] = target_image["raw"] - if ( - current["kickstart_ver_str"] != target_image["version"] - and not data["error"] - ): + if current["kickstart_ver_str"] != target_image["version"] and not data["error"]: data["upgrade_needed"] = True data["disruptive"] = True upgrade_msg = "Switch upgraded: system: %s" % tsver @@ -446,10 +443,7 @@ def check_mode_legacy(module, issu, image, kick=None): if target_kick["error"]: data["error"] = True data["raw"] = target_kick["raw"] - if ( - current["kickstart_ver_str"] != target_kick["version"] - and not data["error"] - ): + if current["kickstart_ver_str"] != target_kick["version"] and not data["error"]: data["upgrade_needed"] = True data["disruptive"] = True upgrade_msg = upgrade_msg + " kickstart: %s" % tkver @@ -539,9 +533,7 @@ def do_install_all(module, issu, image, kick=None): if upgrade["invalid_command"] and "force" in commands[1]: # Not all platforms support the 'force' keyword. Check for this # condition and re-try without the 'force' keyword if needed. - commands = build_install_cmd_set( - issu, image, kick, "install", False - ) + commands = build_install_cmd_set(issu, image, kick, "install", False) upgrade = check_install_in_progress(module, commands, opts) upgrade["upgrade_cmd"] = commands @@ -575,9 +567,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_interface.py b/plugins/modules/nxos_interface.py index 6e745cf80..30c3f104e 100644 --- a/plugins/modules/nxos_interface.py +++ b/plugins/modules/nxos_interface.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -340,23 +341,20 @@ from copy import deepcopy -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, - normalize_interface, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_interface_type, -) from ansible.module_utils.basic import AnsibleModule from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( conditional, remove_default_spec, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_interface_type, + load_config, + normalize_interface, + nxos_argument_spec, + run_commands, +) + def execute_show_command(command, module): if "show run" not in command: @@ -487,9 +485,7 @@ def map_obj_to_commands(updates, module): name = w["name"] mode = w["mode"] ip_forward = w["ip_forward"] - fabric_forwarding_anycast_gateway = w[ - "fabric_forwarding_anycast_gateway" - ] + fabric_forwarding_anycast_gateway = w["fabric_forwarding_anycast_gateway"] admin_state = w["admin_state"] state = w["state"] interface_type = w["interface_type"] @@ -500,9 +496,7 @@ def map_obj_to_commands(updates, module): if interface_type: obj_in_have = {} if state in ("present", "default"): - module.fail_json( - msg="The interface_type param can be used only with state absent." - ) + module.fail_json(msg="The interface_type param can be used only with state absent.") else: obj_in_have = search_obj_in_list(name, have) is_default = is_default_interface(name, module) @@ -523,40 +517,23 @@ def map_obj_to_commands(updates, module): # Don't run switchport command for loopback and svi interfaces if get_interface_type(name) in ("ethernet", "portchannel"): if mode == "layer2" and mode != obj_in_have.get("mode"): - add_command_to_interface( - interface, "switchport", commands - ) + add_command_to_interface(interface, "switchport", commands) elif mode == "layer3" and mode != obj_in_have.get("mode"): - add_command_to_interface( - interface, "no switchport", commands - ) + add_command_to_interface(interface, "no switchport", commands) - if admin_state == "up" and admin_state != obj_in_have.get( - "admin_state" - ): - add_command_to_interface( - interface, "no shutdown", commands - ) - elif admin_state == "down" and admin_state != obj_in_have.get( - "admin_state" - ): + if admin_state == "up" and admin_state != obj_in_have.get("admin_state"): + add_command_to_interface(interface, "no shutdown", commands) + elif admin_state == "down" and admin_state != obj_in_have.get("admin_state"): add_command_to_interface(interface, "shutdown", commands) - if ip_forward == "enable" and ip_forward != obj_in_have.get( - "ip_forward" - ): + if ip_forward == "enable" and ip_forward != obj_in_have.get("ip_forward"): add_command_to_interface(interface, "ip forward", commands) - elif ip_forward == "disable" and ip_forward != obj_in_have.get( - "ip forward" - ): - add_command_to_interface( - interface, "no ip forward", commands - ) + elif ip_forward == "disable" and ip_forward != obj_in_have.get("ip forward"): + add_command_to_interface(interface, "no ip forward", commands) if ( fabric_forwarding_anycast_gateway is True - and obj_in_have.get("fabric_forwarding_anycast_gateway") - is False + and obj_in_have.get("fabric_forwarding_anycast_gateway") is False ): add_command_to_interface( interface, @@ -566,8 +543,7 @@ def map_obj_to_commands(updates, module): elif ( fabric_forwarding_anycast_gateway is False - and obj_in_have.get("fabric_forwarding_anycast_gateway") - is True + and obj_in_have.get("fabric_forwarding_anycast_gateway") is True ): add_command_to_interface( interface, @@ -583,13 +559,9 @@ def map_obj_to_commands(updates, module): if name and get_interface_type(name) == "ethernet": if mode != obj_in_have.get("mode"): - admin_state = w.get("admin_state") or obj_in_have.get( - "admin_state" - ) + admin_state = w.get("admin_state") or obj_in_have.get("admin_state") if admin_state: - c1 = "interface {0}".format( - normalize_interface(w["name"]) - ) + c1 = "interface {0}".format(normalize_interface(w["name"])) c2 = get_admin_state(admin_state) commands2.append(c1) commands2.append(c2) @@ -617,9 +589,7 @@ def map_obj_to_commands(updates, module): commands.append("fabric forwarding mode anycast-gateway") elif fabric_forwarding_anycast_gateway is False: - commands.append( - "no fabric forwarding mode anycast-gateway" - ) + commands.append("no fabric forwarding mode anycast-gateway") for item in args: candidate = w.get(item) @@ -630,9 +600,7 @@ def map_obj_to_commands(updates, module): if is_default is False: commands.append("default interface {0}".format(name)) elif is_default == "DNE": - module.exit_json( - msg="interface you are trying to default does not exist" - ) + module.exit_json(msg="interface you are trying to default does not exist") return commands, commands2 @@ -725,9 +693,7 @@ def map_config_to_obj(want, module): obj["mode"] = "layer3" if intf_type == "ethernet": - obj["name"] = normalize_interface( - interface_table.get("interface") - ) + obj["name"] = normalize_interface(interface_table.get("interface")) obj["admin_state"] = interface_table.get("admin_state") obj["description"] = interface_table.get("desc") obj["mtu"] = interface_table.get("eth_mtu") @@ -754,18 +720,10 @@ def map_config_to_obj(want, module): obj["ip_forward"] = "disable" elif intf_type == "svi": - obj["name"] = normalize_interface( - interface_table.get("interface") - ) - attributes = get_vlan_interface_attributes( - obj["name"], intf_type, module - ) - obj["admin_state"] = str( - attributes.get("admin_state", "nxapibug") - ) - obj["description"] = str( - attributes.get("description", "nxapi_bug") - ) + obj["name"] = normalize_interface(interface_table.get("interface")) + attributes = get_vlan_interface_attributes(obj["name"], intf_type, module) + obj["admin_state"] = str(attributes.get("admin_state", "nxapibug")) + obj["description"] = str(attributes.get("description", "nxapi_bug")) obj["mtu"] = interface_table.get("svi_mtu") command = "show run interface {0}".format(obj["name"]) @@ -780,9 +738,7 @@ def map_config_to_obj(want, module): obj["fabric_forwarding_anycast_gateway"] = False elif intf_type in ("loopback", "management", "nve"): - obj["name"] = normalize_interface( - interface_table.get("interface") - ) + obj["name"] = normalize_interface(interface_table.get("interface")) obj["admin_state"] = interface_table.get("admin_state") if obj["admin_state"] is None and intf_type == "loopback": # Some platforms don't have the 'admin_state' key. @@ -792,9 +748,7 @@ def map_config_to_obj(want, module): obj["description"] = interface_table.get("desc") elif intf_type == "portchannel": - obj["name"] = normalize_interface( - interface_table.get("interface") - ) + obj["name"] = normalize_interface(interface_table.get("interface")) obj["admin_state"] = interface_table.get("admin_state") obj["description"] = interface_table.get("desc") obj["mtu"] = interface_table.get("eth_mtu") @@ -870,9 +824,7 @@ def check_declarative_intent_params(module, want): if have_neighbors is None: cmd = [ { - "command": "show lldp neighbors interface {0} detail".format( - w["name"] - ), + "command": "show lldp neighbors interface {0} detail".format(w["name"]), "output": "text", } ] @@ -881,10 +833,7 @@ def check_declarative_intent_params(module, want): have_neighbors = output[0] else: have_neighbors = "" - if ( - have_neighbors - and "Total entries displayed: 0" not in have_neighbors - ): + if have_neighbors and "Total entries displayed: 0" not in have_neighbors: for line in have_neighbors.strip().split("\n"): if line.startswith("Port Description"): have_port.append(line.split(": ")[1]) @@ -921,9 +870,7 @@ def main(): rx_rate=dict(), neighbors=dict(type="list", elements="dict", options=neighbors_spec), delay=dict(default=10, type="int"), - state=dict( - choices=["absent", "present", "default"], default="present" - ), + state=dict(choices=["absent", "present", "default"], default="present"), ) aggregate_spec = deepcopy(element_spec) diff --git a/plugins/modules/nxos_interface_ospf.py b/plugins/modules/nxos_interface_ospf.py index 6e170c9e1..d90a9bc37 100644 --- a/plugins/modules/nxos_interface_ospf.py +++ b/plugins/modules/nxos_interface_ospf.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -165,19 +166,20 @@ import re -import struct import socket +import struct + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) + BOOL_PARAMS = ["passive_interface", "message_digest"] PARAM_TO_COMMAND_KEYMAP = { @@ -201,9 +203,7 @@ def get_value(arg, config, module): command = PARAM_TO_COMMAND_KEYMAP[arg] has_command = re.search(r"\s+{0}\s*$".format(command), config, re.M) - has_command_val = re.search( - r"(?:{0}\s)(?P.*)$".format(command), config, re.M - ) + has_command_val = re.search(r"(?:{0}\s)(?P.*)$".format(command), config, re.M) if command == "ip router ospf": value = "" @@ -231,9 +231,7 @@ def get_value(arg, config, module): elif arg == "message_digest_password": value = value_list[3] elif arg == "passive_interface": - has_no_command = re.search( - r"\s+no\s+{0}\s*$".format(command), config, re.M - ) + has_no_command = re.search(r"\s+no\s+{0}\s*$".format(command), config, re.M) if has_no_command: value = False elif has_command: @@ -258,14 +256,12 @@ def get_value(arg, config, module): def get_existing(module, args): existing = {} netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - if module.params["interface"].startswith("loopback") or module.params[ - "interface" - ].startswith("port-channel"): + if module.params["interface"].startswith("loopback") or module.params["interface"].startswith( + "port-channel" + ): parents = ["interface {0}".format(module.params["interface"])] else: - parents = [ - "interface {0}".format(module.params["interface"].capitalize()) - ] + parents = ["interface {0}".format(module.params["interface"].capitalize())] config = netcfg.get_section(parents) if "ospf" in config: for arg in args: @@ -322,9 +318,7 @@ def get_custom_command(existing_cmd, proposed, key, module): commands = list() if key == "ip router ospf": - command = "{0} {1} area {2}".format( - key, proposed["ospf"], proposed["area"] - ) + command = "{0} {1} area {2}".format(key, proposed["ospf"], proposed["area"]) if command not in existing_cmd: commands.append(command) @@ -335,10 +329,7 @@ def get_custom_command(existing_cmd, proposed, key, module): commands.append(command) elif key.startswith("ip ospf message-digest-key"): - if ( - proposed["message_digest_key_id"] != "default" - and "options" not in key - ): + if proposed["message_digest_key_id"] != "default" and "options" not in key: if proposed["message_digest_encryption_type"] == "3des": encryption_type = "3" elif proposed["message_digest_encryption_type"] == "cisco_type_7": @@ -367,20 +358,16 @@ def state_present(module, existing, proposed, candidate): if existing_commands[key] == value: continue - if key == "ip ospf passive-interface" and module.params.get( - "interface" - ).upper().startswith("LO"): - module.fail_json( - msg="loopback interface does not support passive_interface" - ) + if key == "ip ospf passive-interface" and module.params.get("interface").upper().startswith( + "LO" + ): + module.fail_json(msg="loopback interface does not support passive_interface") if ( key == "ip ospf network" and value == "broadcast" and module.params.get("interface").upper().startswith("LO") ): - module.fail_json( - msg="loopback interface does not support ospf network type broadcast" - ) + module.fail_json(msg="loopback interface does not support ospf network type broadcast") if key == "ip ospf bfd": cmd = key @@ -398,25 +385,17 @@ def state_present(module, existing, proposed, candidate): elif value == "default": if existing_commands.get(key): commands.extend( - get_default_commands( - existing, proposed, existing_commands, key, module - ) + get_default_commands(existing, proposed, existing_commands, key, module) ) else: - if key == "ip router ospf" or key.startswith( - "ip ospf message-digest-key" - ): - commands.extend( - get_custom_command(commands, proposed, key, module) - ) + if key == "ip router ospf" or key.startswith("ip ospf message-digest-key"): + commands.extend(get_custom_command(commands, proposed, key, module)) else: command = "{0} {1}".format(key, value.lower()) commands.append(command) if commands: - parents = [ - "interface {0}".format(module.params["interface"].capitalize()) - ] + parents = ["interface {0}".format(module.params["interface"].capitalize())] candidate.add(commands, parents=parents) @@ -441,10 +420,7 @@ def state_absent(module, existing, proposed, candidate): if "options" not in key: if existing["message_digest_encryption_type"] == "3des": encryption_type = "3" - elif ( - existing["message_digest_encryption_type"] - == "cisco_type_7" - ): + elif existing["message_digest_encryption_type"] == "cisco_type_7": encryption_type = "7" command = "no {0} {1} {2} {3} {4}".format( key, @@ -461,9 +437,7 @@ def state_absent(module, existing, proposed, candidate): if value: commands.append("no {0}".format(key)) elif key == "ip router ospf": - command = "no {0} {1} area {2}".format( - key, proposed["ospf"], proposed["area"] - ) + command = "no {0} {1} area {2}".format(key, proposed["ospf"], proposed["area"]) if command not in commands: commands.append(command) else: @@ -498,23 +472,17 @@ def main(): hello_interval=dict(required=False, type="str"), dead_interval=dict(required=False, type="str"), passive_interface=dict(required=False, type="bool"), - network=dict( - required=False, type="str", choices=["broadcast", "point-to-point"] - ), + network=dict(required=False, type="str", choices=["broadcast", "point-to-point"]), message_digest=dict(required=False, type="bool"), message_digest_key_id=dict(required=False, type="str"), - message_digest_algorithm_type=dict( - required=False, type="str", choices=["md5", "default"] - ), + message_digest_algorithm_type=dict(required=False, type="str", choices=["md5", "default"]), message_digest_encryption_type=dict( required=False, type="str", choices=["cisco_type_7", "3des", "default"], ), message_digest_password=dict(required=False, type="str", no_log=True), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) @@ -563,9 +531,7 @@ def main(): args = PARAM_TO_COMMAND_KEYMAP.keys() existing = get_existing(module, args) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): @@ -580,11 +546,7 @@ def main(): value = str(value).lower() if existing.get(key) or (not existing.get(key) and value): proposed[key] = value - elif ( - "passive_interface" in key - and existing.get(key) is None - and value is False - ): + elif "passive_interface" in key and existing.get(key) is None and value is False: proposed[key] = value proposed["area"] = normalize_area(proposed["area"], module) diff --git a/plugins/modules/nxos_interfaces.py b/plugins/modules/nxos_interfaces.py index c67ba84b5..f03f746bd 100644 --- a/plugins/modules/nxos_interfaces.py +++ b/plugins/modules/nxos_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -415,6 +416,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.interfaces.interfaces import ( InterfacesArgs, ) diff --git a/plugins/modules/nxos_l2_interface.py b/plugins/modules/nxos_l2_interface.py index 6e88238cf..b2f3ccb79 100644 --- a/plugins/modules/nxos_l2_interface.py +++ b/plugins/modules/nxos_l2_interface.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -180,19 +181,18 @@ from copy import deepcopy -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, - get_interface_type, -) from ansible.module_utils.basic import AnsibleModule from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( remove_default_spec, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_interface_type, + load_config, + nxos_argument_spec, + run_commands, +) + def get_interface_mode(name, module): """Gets current mode of interface: layer2 or layer3 @@ -299,9 +299,7 @@ def remove_switchport_config_commands(name, existing, proposed, module): if mode == "access": av_check = existing.get("access_vlan") == proposed.get("access_vlan") if av_check: - command = "no switchport access vlan {0}".format( - existing.get("access_vlan") - ) + command = "no switchport access vlan {0}".format(existing.get("access_vlan")) commands.append(command) elif mode == "trunk": @@ -311,21 +309,13 @@ def remove_switchport_config_commands(name, existing, proposed, module): if vlans_to_remove: proposed_allowed_vlans = proposed.get("trunk_allowed_vlans") - remove_trunk_allowed_vlans = proposed.get( - "trunk_vlans", proposed_allowed_vlans - ) - command = "switchport trunk allowed vlan remove {0}".format( - remove_trunk_allowed_vlans - ) + remove_trunk_allowed_vlans = proposed.get("trunk_vlans", proposed_allowed_vlans) + command = "switchport trunk allowed vlan remove {0}".format(remove_trunk_allowed_vlans) commands.append(command) - native_check = existing.get("native_vlan") == proposed.get( - "native_vlan" - ) + native_check = existing.get("native_vlan") == proposed.get("native_vlan") if native_check and proposed.get("native_vlan"): - command = "no switchport trunk native vlan {0}".format( - existing.get("native_vlan") - ) + command = "no switchport trunk native vlan {0}".format(existing.get("native_vlan")) commands.append(command) if commands: @@ -351,19 +341,13 @@ def get_switchport_config_commands(name, existing, proposed, module): commands.append(command) if proposed_mode == "access": - av_check = str(existing.get("access_vlan")) == str( - proposed.get("access_vlan") - ) + av_check = str(existing.get("access_vlan")) == str(proposed.get("access_vlan")) if not av_check: - command = "switchport access vlan {0}".format( - proposed.get("access_vlan") - ) + command = "switchport access vlan {0}".format(proposed.get("access_vlan")) commands.append(command) elif proposed_mode == "trunk": - tv_check = existing.get("trunk_vlans_list") == proposed.get( - "trunk_vlans_list" - ) + tv_check = existing.get("trunk_vlans_list") == proposed.get("trunk_vlans_list") if not tv_check: if proposed.get("allowed"): @@ -382,13 +366,9 @@ def get_switchport_config_commands(name, existing, proposed, module): ) commands.append(command) - native_check = str(existing.get("native_vlan")) == str( - proposed.get("native_vlan") - ) + native_check = str(existing.get("native_vlan")) == str(proposed.get("native_vlan")) if not native_check and proposed.get("native_vlan"): - command = "switchport trunk native vlan {0}".format( - proposed.get("native_vlan") - ) + command = "switchport trunk native vlan {0}".format(proposed.get("native_vlan")) commands.append(command) if commands: @@ -536,9 +516,7 @@ def main(): native_vlan=dict(type="str"), trunk_vlans=dict(type="str", aliases=["trunk_add_vlans"]), trunk_allowed_vlans=dict(type="str"), - state=dict( - choices=["absent", "present", "unconfigured"], default="present" - ), + state=dict(choices=["absent", "present", "unconfigured"], default="present"), ) aggregate_spec = deepcopy(element_spec) @@ -546,9 +524,7 @@ def main(): # remove default in aggregate spec, to handle common arguments remove_default_spec(aggregate_spec) - argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec) - ) + argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) argument_spec.update(element_spec) argument_spec.update(nxos_argument_spec) @@ -593,14 +569,10 @@ def main(): name = name.lower() if mode == "access" and state == "present" and not access_vlan: - module.fail_json( - msg="access_vlan param is required when mode=access && state=present" - ) + module.fail_json(msg="access_vlan param is required when mode=access && state=present") if mode == "trunk" and access_vlan: - module.fail_json( - msg="access_vlan param not supported when using mode=trunk" - ) + module.fail_json(msg="access_vlan param not supported when using mode=trunk") current_mode = get_interface_mode(name, module) @@ -625,9 +597,7 @@ def main(): # Safeguard check # If there isn't an existing, something is wrong per previous comment if not existing: - module.fail_json( - msg="Make sure you are using the FULL interface name" - ) + module.fail_json(msg="Make sure you are using the FULL interface name") if trunk_vlans or trunk_allowed_vlans: if trunk_vlans: @@ -636,9 +606,7 @@ def main(): trunk_vlans_list = vlan_range_to_list(trunk_allowed_vlans) proposed["allowed"] = True - existing_trunks_list = vlan_range_to_list( - (existing["trunk_vlans"]) - ) + existing_trunks_list = vlan_range_to_list((existing["trunk_vlans"])) existing["trunk_vlans_list"] = existing_trunks_list proposed["trunk_vlans_list"] = trunk_vlans_list @@ -661,9 +629,7 @@ def main(): vlan=native_vlan, ) else: - command = get_switchport_config_commands( - name, existing, proposed, module - ) + command = get_switchport_config_commands(name, existing, proposed, module) commands.append(command) elif state == "unconfigured": is_default = is_switchport_default(existing) @@ -671,9 +637,7 @@ def main(): command = default_switchport_config(name) commands.append(command) elif state == "absent": - command = remove_switchport_config_commands( - name, existing, proposed, module - ) + command = remove_switchport_config_commands(name, existing, proposed, module) commands.append(command) if trunk_vlans or trunk_allowed_vlans: diff --git a/plugins/modules/nxos_l2_interfaces.py b/plugins/modules/nxos_l2_interfaces.py index c4cdc871a..9477e4863 100644 --- a/plugins/modules/nxos_l2_interfaces.py +++ b/plugins/modules/nxos_l2_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -367,6 +368,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.l2_interfaces.l2_interfaces import ( L2_interfacesArgs, ) diff --git a/plugins/modules/nxos_l3_interface.py b/plugins/modules/nxos_l3_interface.py index 499cbf13b..dc329fbdb 100644 --- a/plugins/modules/nxos_l3_interface.py +++ b/plugins/modules/nxos_l3_interface.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -123,13 +124,12 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( remove_default_spec, ) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, normalize_interface, + nxos_argument_spec, ) @@ -251,9 +251,7 @@ def main(): # remove default in aggregate spec, to handle common arguments remove_default_spec(aggregate_spec) - argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec) - ) + argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) argument_spec.update(element_spec) argument_spec.update(nxos_argument_spec) diff --git a/plugins/modules/nxos_l3_interfaces.py b/plugins/modules/nxos_l3_interfaces.py index cd5b34050..860a8faac 100644 --- a/plugins/modules/nxos_l3_interfaces.py +++ b/plugins/modules/nxos_l3_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -367,6 +368,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.l3_interfaces.l3_interfaces import ( L3_interfacesArgs, ) diff --git a/plugins/modules/nxos_lacp.py b/plugins/modules/nxos_lacp.py index 9cd14a124..233491138 100644 --- a/plugins/modules/nxos_lacp.py +++ b/plugins/modules/nxos_lacp.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -239,12 +240,11 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lacp.lacp import ( LacpArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lacp.lacp import ( - Lacp, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lacp.lacp import Lacp def main(): diff --git a/plugins/modules/nxos_lacp_interfaces.py b/plugins/modules/nxos_lacp_interfaces.py index 32242c236..98e5a6339 100644 --- a/plugins/modules/nxos_lacp_interfaces.py +++ b/plugins/modules/nxos_lacp_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -341,6 +342,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lacp_interfaces.lacp_interfaces import ( Lacp_interfacesArgs, ) diff --git a/plugins/modules/nxos_lag_interfaces.py b/plugins/modules/nxos_lag_interfaces.py index 25de937cd..ce06462ed 100644 --- a/plugins/modules/nxos_lag_interfaces.py +++ b/plugins/modules/nxos_lag_interfaces.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -328,6 +329,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lag_interfaces.lag_interfaces import ( Lag_interfacesArgs, ) diff --git a/plugins/modules/nxos_linkagg.py b/plugins/modules/nxos_linkagg.py index c452983c8..d361e0110 100644 --- a/plugins/modules/nxos_linkagg.py +++ b/plugins/modules/nxos_linkagg.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -174,22 +175,20 @@ """ import re + from copy import deepcopy +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( normalize_interface, -) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, + nxos_argument_spec, + run_commands, ) @@ -230,15 +229,11 @@ def map_obj_to_commands(updates, module): if state == "absent": if obj_in_have: - members_to_remove = list( - set(obj_in_have["members"]) - set(members) - ) + members_to_remove = list(set(obj_in_have["members"]) - set(members)) if members_to_remove: for m in members_to_remove: commands.append("interface {0}".format(m)) - commands.append( - "no channel-group {0}".format(obj_in_have["group"]) - ) + commands.append("no channel-group {0}".format(obj_in_have["group"])) commands.append("exit") commands.append("no interface port-channel {0}".format(group)) @@ -252,75 +247,43 @@ def map_obj_to_commands(updates, module): for m in members: commands.append("interface {0}".format(m)) if force: - commands.append( - "channel-group {0} force mode {1}".format( - group, mode - ) - ) + commands.append("channel-group {0} force mode {1}".format(group, mode)) else: - commands.append( - "channel-group {0} mode {1}".format( - group, mode - ) - ) + commands.append("channel-group {0} mode {1}".format(group, mode)) else: if members: if not obj_in_have["members"]: for m in members: - commands.append( - "interface port-channel {0}".format(group) - ) + commands.append("interface port-channel {0}".format(group)) commands.append("exit") commands.append("interface {0}".format(m)) if force: commands.append( - "channel-group {0} force mode {1}".format( - group, mode - ) + "channel-group {0} force mode {1}".format(group, mode) ) else: - commands.append( - "channel-group {0} mode {1}".format( - group, mode - ) - ) + commands.append("channel-group {0} mode {1}".format(group, mode)) elif set(members) != set(obj_in_have["members"]): - missing_members = list( - set(members) - set(obj_in_have["members"]) - ) + missing_members = list(set(members) - set(obj_in_have["members"])) for m in missing_members: - commands.append( - "interface port-channel {0}".format(group) - ) + commands.append("interface port-channel {0}".format(group)) commands.append("exit") commands.append("interface {0}".format(m)) if force: commands.append( - "channel-group {0} force mode {1}".format( - group, mode - ) + "channel-group {0} force mode {1}".format(group, mode) ) else: - commands.append( - "channel-group {0} mode {1}".format( - group, mode - ) - ) + commands.append("channel-group {0} mode {1}".format(group, mode)) - superfluous_members = list( - set(obj_in_have["members"]) - set(members) - ) + superfluous_members = list(set(obj_in_have["members"]) - set(members)) for m in superfluous_members: - commands.append( - "interface port-channel {0}".format(group) - ) + commands.append("interface port-channel {0}".format(group)) commands.append("exit") commands.append("interface {0}".format(m)) - commands.append( - "no channel-group {0}".format(group) - ) + commands.append("no channel-group {0}".format(group)) else: diff = get_diff(w, obj_in_have) @@ -330,24 +293,18 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(i)) if force: commands.append( - "channel-group {0} force mode {1}".format( - group, mode - ) + "channel-group {0} force mode {1}".format(group, mode) ) else: commands.append( - "channel-group {0} mode {1}".format( - group, mode - ) + "channel-group {0} mode {1}".format(group, mode) ) if purge: for h in have: obj_in_want = search_obj_in_list(h["group"], want) if not obj_in_want: - commands.append( - "no interface port-channel {0}".format(h["group"]) - ) + commands.append("no interface port-channel {0}".format(h["group"])) return commands @@ -371,9 +328,7 @@ def map_params_to_obj(module): else: members = None if module.params["members"]: - members = [ - normalize_interface(i) for i in module.params["members"] - ] + members = [normalize_interface(i) for i in module.params["members"]] obj.append( { @@ -405,9 +360,7 @@ def parse_mode(module, m): flags = ["| section interface.{0}".format(m)] config = get_config(module, flags=flags) - match = re.search( - r"channel-group [0-9]+ (force )?mode (\S+)", config, re.M - ) + match = re.search(r"channel-group [0-9]+ (force )?mode (\S+)", config, re.M) if match: mode = match.group(2) @@ -495,13 +448,9 @@ def main(): type="str", ), min_links=dict(required=False, default=None, type="int"), - members=dict( - required=False, default=None, type="list", elements="str" - ), + members=dict(required=False, default=None, type="list", elements="str"), force=dict(required=False, default=False, type="bool"), - state=dict( - required=False, choices=["absent", "present"], default="present" - ), + state=dict(required=False, choices=["absent", "present"], default="present"), ) aggregate_spec = deepcopy(element_spec) diff --git a/plugins/modules/nxos_lldp.py b/plugins/modules/nxos_lldp.py index e48609ca8..5acc301bb 100644 --- a/plugins/modules/nxos_lldp.py +++ b/plugins/modules/nxos_lldp.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -62,11 +63,10 @@ - feature lldp """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) @@ -91,9 +91,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_lldp_global.py b/plugins/modules/nxos_lldp_global.py index a60c81881..3bd3c5539 100644 --- a/plugins/modules/nxos_lldp_global.py +++ b/plugins/modules/nxos_lldp_global.py @@ -26,6 +26,7 @@ """ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -306,6 +307,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lldp_global.lldp_global import ( Lldp_globalArgs, ) diff --git a/plugins/modules/nxos_lldp_interfaces.py b/plugins/modules/nxos_lldp_interfaces.py index 16f9f2b95..cf49a9ac2 100644 --- a/plugins/modules/nxos_lldp_interfaces.py +++ b/plugins/modules/nxos_lldp_interfaces.py @@ -27,6 +27,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -234,6 +235,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lldp_interfaces.lldp_interfaces import ( Lldp_interfacesArgs, ) diff --git a/plugins/modules/nxos_logging.py b/plugins/modules/nxos_logging.py index 3e8ce2f72..aa405edb2 100644 --- a/plugins/modules/nxos_logging.py +++ b/plugins/modules/nxos_logging.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # Copyright: (c) 2017, Ansible by Red Hat, inc @@ -208,21 +209,20 @@ - logging level daemon 0 """ -import re import copy +import re + +from ansible.module_utils.basic import AnsibleModule from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, + normalize_interface, + nxos_argument_spec, + read_module_context, run_commands, save_module_context, - read_module_context, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, - normalize_interface, -) -from ansible.module_utils.basic import AnsibleModule STATIC_CLI = { @@ -267,13 +267,10 @@ def map_obj_to_commands(module, updates): if ( not w["dest"] and not w["facility_link_status"] - and w["facility"] - not in DEFAULT_LOGGING_LEVEL[int(w["facility_level"])] + and w["facility"] not in DEFAULT_LOGGING_LEVEL[int(w["facility_level"])] ): commands.append( - "no logging level {0} {1}".format( - w["facility"], w["facility_level"] - ) + "no logging level {0} {1}".format(w["facility"], w["facility_level"]) ) if w["facility_link_status"] and w["facility"] in ("ethpm"): @@ -291,9 +288,7 @@ def map_obj_to_commands(module, updates): commands.append("no logging {0}".format(w["dest"])) if w["dest"] == "server": - commands.append( - "no logging server {0}".format(w["remote_server"]) - ) + commands.append("no logging server {0}".format(w["remote_server"])) if w["interface"]: commands.append("no logging source-interface") @@ -311,11 +306,7 @@ def map_obj_to_commands(module, updates): if w["facility"] is None: if w["dest"]: if w["dest"] not in ("logfile", "server"): - commands.append( - "logging {0} {1}".format( - w["dest"], w["dest_level"] - ) - ) + commands.append("logging {0} {1}".format(w["dest"], w["dest_level"])) elif w["dest"] == "logfile": if w["file_size"]: @@ -326,9 +317,7 @@ def map_obj_to_commands(module, updates): ) else: commands.append( - "logging logfile {0} {1}".format( - w["name"], w["dest_level"] - ) + "logging logfile {0} {1}".format(w["name"], w["dest_level"]) ) elif w["dest"] == "server": @@ -356,11 +345,7 @@ def map_obj_to_commands(module, updates): ) ) else: - commands.append( - "logging server {0}".format( - w["remote_server"] - ) - ) + commands.append("logging server {0}".format(w["remote_server"])) if w["facility"]: if w["dest"] == "server": @@ -406,20 +391,14 @@ def map_obj_to_commands(module, updates): ) ) else: - if not match_facility_default( - module, w["facility"], w["facility_level"] - ): + if not match_facility_default(module, w["facility"], w["facility_level"]): commands.append( - "logging level {0} {1}".format( - w["facility"], w["facility_level"] - ) + "logging level {0} {1}".format(w["facility"], w["facility_level"]) ) if w["interface"]: commands.append( - "logging source-interface {0} {1}".format( - *split_interface(w["interface"]) - ) + "logging source-interface {0} {1}".format(*split_interface(w["interface"])) ) if w["event"] and w["event"] in STATIC_CLI: @@ -455,11 +434,7 @@ def match_facility_default(module, facility, want_level): facility_data = run_commands(module, cmd) for line in facility_data[0].split("\n"): mo = re.search(regexl, line) - if ( - mo - and int(mo.group(1)) == int(want_level) - and int(mo.group(2)) == int(want_level) - ): + if mo and int(mo.group(1)) == int(want_level) and int(mo.group(2)) == int(want_level): matches_default = True return matches_default @@ -475,9 +450,7 @@ def parse_facility_link_status(line, facility, status): facility_link_status = None if facility is not None: - match = re.search( - r"logging level {0} {1} (\S+)".format(facility, status), line, re.M - ) + match = re.search(r"logging level {0} {1} (\S+)".format(facility, status), line, re.M) if match: facility_link_status = status + "-" + match.group(1) @@ -487,9 +460,7 @@ def parse_facility_link_status(line, facility, status): def parse_event_status(line, event): status = None - match = re.search( - r"logging event {0} (\S+)".format(event + "-status"), line, re.M - ) + match = re.search(r"logging event {0} (\S+)".format(event + "-status"), line, re.M) if match: state = match.group(1) if state: @@ -515,9 +486,7 @@ def parse_event(line): def parse_message(line): message = None - match = re.search( - r"logging message interface type ethernet description", line, re.M - ) + match = re.search(r"logging message interface type ethernet description", line, re.M) if match: message = "add-interface-description" @@ -527,9 +496,7 @@ def parse_message(line): def parse_file_size(line, name, level): file_size = None - match = re.search( - r"logging logfile {0} {1} size (\S+)".format(name, level), line, re.M - ) + match = re.search(r"logging logfile {0} {1} size (\S+)".format(name, level), line, re.M) if match: file_size = match.group(1) if file_size == "8192" or file_size == "4194304": @@ -587,9 +554,7 @@ def parse_match(match): if dest and dest != "server": if dest == "logfile": - match = re.search( - r"logging logfile {0} (\S+)".format(name), line, re.M - ) + match = re.search(r"logging logfile {0} (\S+)".format(name), line, re.M) if match: dest_level = parse_match(match) @@ -614,9 +579,7 @@ def parse_facility_level(line, facility, dest): facility_level = match.group(1) elif facility is not None: - match = re.search( - r"logging level {0} (\S+)".format(facility), line, re.M - ) + match = re.search(r"logging level {0} (\S+)".format(facility), line, re.M) if match: facility_level = match.group(1) @@ -641,9 +604,7 @@ def parse_use_vrf(line, dest): use_vrf = None if dest and dest == "server": - match = re.search( - r"logging server (?:\S+) (?:\d+) use-vrf (\S+)", line, re.M - ) + match = re.search(r"logging server (?:\S+) (?:\d+) use-vrf (\S+)", line, re.M) if match: use_vrf = match.group(1) @@ -706,9 +667,7 @@ def map_config_to_obj(module): if level.isdigit(): facility_level = level else: - facility_link_status = parse_facility_link_status( - line, facility, level - ) + facility_link_status = parse_facility_link_status(line, facility, level) elif match.group(1) == "event" and state == "present": event = parse_event(line) @@ -764,10 +723,7 @@ def map_config_to_obj(module): if match.group(1) == "console" and match.group(2) == "critical": dest_level = "2" flag = True - elif ( - match.group(1) == "monitor" - and match.group(2) == "notifications" - ): + elif match.group(1) == "monitor" and match.group(2) == "notifications": dest_level = "5" flag = True if flag: @@ -968,9 +924,7 @@ def main(): save_module_context(module, merged_wants) if module.params.get("purge"): - pcommands = map_obj_to_commands( - module, (outliers(have, merged_wants), have) - ) + pcommands = map_obj_to_commands(module, (outliers(have, merged_wants), have)) if pcommands: if not module.check_mode: load_config(module, pcommands) diff --git a/plugins/modules/nxos_logging_global.py b/plugins/modules/nxos_logging_global.py index bef6fe78a..7e0e0493d 100644 --- a/plugins/modules/nxos_logging_global.py +++ b/plugins/modules/nxos_logging_global.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -688,6 +689,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.logging_global.logging_global import ( Logging_globalArgs, ) diff --git a/plugins/modules/nxos_ntp.py b/plugins/modules/nxos_ntp.py index 61a366b22..d94de666f 100644 --- a/plugins/modules/nxos_ntp.py +++ b/plugins/modules/nxos_ntp.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -118,6 +119,7 @@ import re from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, nxos_argument_spec, @@ -149,9 +151,7 @@ def get_ntp_source(module): source_type = None source = None command = "show run | inc ntp.source" - output = execute_show_command( - command, module, command_type="cli_show_ascii" - ) + output = execute_show_command(command, module, command_type="cli_show_ascii") if output: try: @@ -170,9 +170,7 @@ def get_ntp_source(module): def get_ntp_peer(module): command = "show run | inc ntp.(server|peer)" ntp_peer_list = [] - response = execute_show_command( - command, module, command_type="cli_show_ascii" - ) + response = execute_show_command(command, module, command_type="cli_show_ascii") if response: if isinstance(response, list): @@ -304,27 +302,17 @@ def config_ntp(delta, existing): if peer_type: if existing.get("peer_type") and existing.get("address"): ntp_cmds.append( - "no ntp {0} {1}".format( - existing.get("peer_type"), existing.get("address") - ) + "no ntp {0} {1}".format(existing.get("peer_type"), existing.get("address")) ) - ntp_cmds.append( - set_ntp_server_peer(peer_type, address, prefer, key_id, vrf_name) - ) + ntp_cmds.append(set_ntp_server_peer(peer_type, address, prefer, key_id, vrf_name)) if source: existing_source_type = existing.get("source_type") existing_source = existing.get("source") if existing_source_type and source_type != existing_source_type: - ntp_cmds.append( - "no ntp {0} {1}".format(existing_source_type, existing_source) - ) + ntp_cmds.append("no ntp {0} {1}".format(existing_source_type, existing_source)) if source == "default": if existing_source_type and existing_source: - ntp_cmds.append( - "no ntp {0} {1}".format( - existing_source_type, existing_source - ) - ) + ntp_cmds.append("no ntp {0} {1}".format(existing_source_type, existing_source)) else: ntp_cmds.append("ntp {0} {1}".format(source_type, source)) @@ -418,9 +406,7 @@ def main(): elif state == "absent": if existing.get("peer_type") and existing.get("address"): - command = "no ntp {0} {1}".format( - existing["peer_type"], existing["address"] - ) + command = "no ntp {0} {1}".format(existing["peer_type"], existing["address"]) if command: commands.append([command]) @@ -432,9 +418,7 @@ def main(): if proposed_source_type: if proposed_source_type == existing_source_type: if proposed_source == existing_source: - command = "no ntp {0} {1}".format( - existing_source_type, existing_source - ) + command = "no ntp {0} {1}".format(existing_source_type, existing_source) if command: commands.append([command]) diff --git a/plugins/modules/nxos_ntp_auth.py b/plugins/modules/nxos_ntp_auth.py index 7ab6b657d..b86050a1e 100644 --- a/plugins/modules/nxos_ntp_auth.py +++ b/plugins/modules/nxos_ntp_auth.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -102,14 +103,13 @@ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -167,8 +167,7 @@ def get_ntp_auth_key(key_id, module): authentication_key = {} command = "show run | inc ntp.authentication-key.{0}".format(key_id) auth_regex = ( - r".*ntp\sauthentication-key\s(?P\d+)\s" - r"md5\s(?P\S+)\s(?P\S+).*" + r".*ntp\sauthentication-key\s(?P\d+)\smd5\s(?P\S+)\s(?P\S+).*" ) body = execute_show_command(command, module)[0] @@ -213,16 +212,12 @@ def auth_type_to_num(auth_type): return "0" -def set_ntp_auth_key( - key_id, md5string, auth_type, trusted_key, authentication -): +def set_ntp_auth_key(key_id, md5string, auth_type, trusted_key, authentication): ntp_auth_cmds = [] if key_id and md5string: auth_type_num = auth_type_to_num(auth_type) ntp_auth_cmds.append( - "ntp authentication-key {0} md5 {1} {2}".format( - key_id, md5string, auth_type_num - ) + "ntp authentication-key {0} md5 {1} {2}".format(key_id, md5string, auth_type_num) ) if trusted_key == "true": @@ -238,16 +233,12 @@ def set_ntp_auth_key( return ntp_auth_cmds -def remove_ntp_auth_key( - key_id, md5string, auth_type, trusted_key, authentication -): +def remove_ntp_auth_key(key_id, md5string, auth_type, trusted_key, authentication): auth_remove_cmds = [] if key_id: auth_type_num = auth_type_to_num(auth_type) auth_remove_cmds.append( - "no ntp authentication-key {0} md5 {1} {2}".format( - key_id, md5string, auth_type_num - ) + "no ntp authentication-key {0} md5 {1} {2}".format(key_id, md5string, auth_type_num) ) if authentication: @@ -267,9 +258,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -318,9 +307,7 @@ def main(): auth_toggle = True if not existing.get("key_id"): key_id = None - command = remove_ntp_auth_key( - key_id, md5string, auth_type, trusted_key, auth_toggle - ) + command = remove_ntp_auth_key(key_id, md5string, auth_type, trusted_key, auth_toggle) if command: commands.append(command) diff --git a/plugins/modules/nxos_ntp_global.py b/plugins/modules/nxos_ntp_global.py index 8833de98f..50a0cbd21 100644 --- a/plugins/modules/nxos_ntp_global.py +++ b/plugins/modules/nxos_ntp_global.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -687,6 +688,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ntp_global.ntp_global import ( Ntp_globalArgs, ) diff --git a/plugins/modules/nxos_ntp_options.py b/plugins/modules/nxos_ntp_options.py index dd9729ab2..c86659aa7 100644 --- a/plugins/modules/nxos_ntp_options.py +++ b/plugins/modules/nxos_ntp_options.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -82,14 +83,13 @@ """ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def get_current(module): @@ -121,9 +121,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_nxapi.py b/plugins/modules/nxos_nxapi.py index 4dca946e9..4fd15055e 100644 --- a/plugins/modules/nxos_nxapi.py +++ b/plugins/modules/nxos_nxapi.py @@ -17,6 +17,7 @@ # pylint: skip-file from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -157,20 +158,15 @@ """ import re -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - Version, -) +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - run_commands, + get_capabilities, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, -) -from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import Version def check_args(module, warnings, capabilities): @@ -255,15 +251,11 @@ def needs_update(x): commands["sandbox"] = "no %s" % commands["sandbox"] if os_platform and os_version: - if (os_platform == "N9K" or os_platform == "N3K") and Version( - os_version - ) >= "9.2": + if (os_platform == "N9K" or os_platform == "N3K") and Version(os_version) >= "9.2": if needs_update("ssl_strong_ciphers"): commands["ssl_strong_ciphers"] = "nxapi ssl ciphers weak" if want["ssl_strong_ciphers"] is True: - commands[ - "ssl_strong_ciphers" - ] = "no nxapi ssl ciphers weak" + commands["ssl_strong_ciphers"] = "no nxapi ssl ciphers weak" have_ssl_protocols = "" want_ssl_protocols = "" @@ -274,9 +266,7 @@ def needs_update(x): }.items(): if needs_update(key): if want.get(key) is True: - want_ssl_protocols = " ".join( - [want_ssl_protocols, value] - ) + want_ssl_protocols = " ".join([want_ssl_protocols, value]) elif have.get(key) is True: have_ssl_protocols = " ".join([have_ssl_protocols, value]) @@ -323,9 +313,7 @@ def parse_https(data): def parse_sandbox(data): - sandbox = [ - item for item in data.split("\n") if re.search(r".*sandbox.*", item) - ] + sandbox = [item for item in data.split("\n") if re.search(r".*sandbox.*", item)] value = False if sandbox and sandbox[0] == "nxapi sandbox": value = True @@ -408,19 +396,13 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() - warning_msg = ( - "Module nxos_nxapi currently defaults to configure 'http port 80'. " - ) + warning_msg = "Module nxos_nxapi currently defaults to configure 'http port 80'. " warning_msg += "Default behavior is changing to configure 'https port 443'" warning_msg += " when params 'http, http_port, https, https_port' are not set in the playbook" - module.deprecate( - msg=warning_msg, date="2022-06-01", collection_name="cisco.nxos" - ) + module.deprecate(msg=warning_msg, date="2022-06-01", collection_name="cisco.nxos") capabilities = get_capabilities(module) diff --git a/plugins/modules/nxos_ospf.py b/plugins/modules/nxos_ospf.py index 86e56bf5c..83f608e8c 100644 --- a/plugins/modules/nxos_ospf.py +++ b/plugins/modules/nxos_ospf.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -69,17 +70,17 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) PARAM_TO_COMMAND_KEYMAP = {"ospf": "router ospf"} @@ -127,16 +128,12 @@ def state_absent(module, proposed, candidate): def main(): argument_spec = dict( ospf=dict(required=True, type="str"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = dict(changed=False, warnings=warnings) diff --git a/plugins/modules/nxos_ospf_interfaces.py b/plugins/modules/nxos_ospf_interfaces.py index 05953ef98..c0a754c76 100644 --- a/plugins/modules/nxos_ospf_interfaces.py +++ b/plugins/modules/nxos_ospf_interfaces.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1418,6 +1419,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospf_interfaces.ospf_interfaces import ( Ospf_interfacesArgs, ) diff --git a/plugins/modules/nxos_ospf_vrf.py b/plugins/modules/nxos_ospf_vrf.py index 17deb8bba..cecd9adf3 100644 --- a/plugins/modules/nxos_ospf_vrf.py +++ b/plugins/modules/nxos_ospf_vrf.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -152,17 +153,17 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) BOOL_PARAMS = ["passive_interface"] @@ -226,25 +227,17 @@ def get_existing(module, args): if "passive" in line: existing["passive_interface"] = True elif "router-id" in line: - existing["router_id"] = re.search( - r"router-id (\S+)", line - ).group(1) + existing["router_id"] = re.search(r"router-id (\S+)", line).group(1) elif "metric" in line: - existing["default_metric"] = re.search( - r"default-metric (\S+)", line - ).group(1) + existing["default_metric"] = re.search(r"default-metric (\S+)", line).group(1) elif "adjacency" in line: - log = re.search( - r"log-adjacency-changes(?: (\S+))?", line - ).group(1) + log = re.search(r"log-adjacency-changes(?: (\S+))?", line).group(1) if log: existing["log_adjacency"] = log else: existing["log_adjacency"] = "log" elif "auto" in line: - cost = re.search( - r"auto-cost reference-bandwidth (\d+) (\S+)", line - ).group(1) + cost = re.search(r"auto-cost reference-bandwidth (\d+) (\S+)", line).group(1) if "Gbps" in line: cost = int(cost) * 1000 existing["auto_cost"] = str(cost) @@ -360,17 +353,11 @@ def state_absent(module, existing, proposed, candidate): elif key == "timers throttle lsa": if ( existing["timer_throttle_lsa_start"] - != PARAM_TO_DEFAULT_KEYMAP.get( - "timer_throttle_lsa_start" - ) + != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_lsa_start") or existing["timer_throttle_lsa_hold"] - != PARAM_TO_DEFAULT_KEYMAP.get( - "timer_throttle_lsa_hold" - ) + != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_lsa_hold") or existing["timer_throttle_lsa_max"] - != PARAM_TO_DEFAULT_KEYMAP.get( - "timer_throttle_lsa_max" - ) + != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_lsa_max") ): command = "no {0} {1} {2} {3}".format( key, @@ -381,17 +368,11 @@ def state_absent(module, existing, proposed, candidate): elif key == "timers throttle spf": if ( existing["timer_throttle_spf_start"] - != PARAM_TO_DEFAULT_KEYMAP.get( - "timer_throttle_spf_start" - ) + != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_spf_start") or existing["timer_throttle_spf_hold"] - != PARAM_TO_DEFAULT_KEYMAP.get( - "timer_throttle_spf_hold" - ) + != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_spf_hold") or existing["timer_throttle_spf_max"] - != PARAM_TO_DEFAULT_KEYMAP.get( - "timer_throttle_spf_max" - ) + != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_spf_max") ): command = "no {0} {1} {2} {3}".format( key, @@ -430,9 +411,7 @@ def main(): ospf=dict(required=True, type="str"), router_id=dict(required=False, type="str"), default_metric=dict(required=False, type="str"), - log_adjacency=dict( - required=False, type="str", choices=["log", "detail", "default"] - ), + log_adjacency=dict(required=False, type="str", choices=["log", "detail", "default"]), timer_throttle_lsa_start=dict(required=False, type="str"), timer_throttle_lsa_hold=dict(required=False, type="str"), timer_throttle_lsa_max=dict(required=False, type="str"), @@ -442,16 +421,12 @@ def main(): auto_cost=dict(required=False, type="str"), bfd=dict(required=False, type="str", choices=["enable", "disable"]), passive_interface=dict(required=False, type="bool"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = dict(changed=False, commands=[], warnings=warnings) @@ -459,9 +434,7 @@ def main(): state = module.params["state"] args = PARAM_TO_COMMAND_KEYMAP.keys() existing = get_existing(module, args) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): diff --git a/plugins/modules/nxos_ospfv2.py b/plugins/modules/nxos_ospfv2.py index 3499abbf0..174640a1e 100644 --- a/plugins/modules/nxos_ospfv2.py +++ b/plugins/modules/nxos_ospfv2.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -1947,6 +1948,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospfv2.ospfv2 import ( Ospfv2Args, ) diff --git a/plugins/modules/nxos_ospfv3.py b/plugins/modules/nxos_ospfv3.py index 706479f17..27d9ff659 100644 --- a/plugins/modules/nxos_ospfv3.py +++ b/plugins/modules/nxos_ospfv3.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1665,6 +1666,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospfv3.ospfv3 import ( Ospfv3Args, ) diff --git a/plugins/modules/nxos_overlay_global.py b/plugins/modules/nxos_overlay_global.py index d62a8ffed..98ff8000f 100644 --- a/plugins/modules/nxos_overlay_global.py +++ b/plugins/modules/nxos_overlay_global.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -57,21 +58,20 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) -PARAM_TO_COMMAND_KEYMAP = { - "anycast_gateway_mac": "fabric forwarding anycast-gateway-mac" -} + +PARAM_TO_COMMAND_KEYMAP = {"anycast_gateway_mac": "fabric forwarding anycast-gateway-mac"} def get_existing(module, args): @@ -80,9 +80,7 @@ def get_existing(module, args): for arg in args: command = PARAM_TO_COMMAND_KEYMAP[arg] - has_command = re.findall( - r"(?:{0}\s)(?P.*)$".format(command), config, re.M - ) + has_command = re.findall(r"(?:{0}\s)(?P.*)$".format(command), config, re.M) value = "" if has_command: value = has_command[0] @@ -157,9 +155,7 @@ def normalize_mac(proposed_mac, module): else: raise ValueError except ValueError: - module.fail_json( - msg="Invalid MAC address format", proposed_mac=proposed_mac - ) + module.fail_json(msg="Invalid MAC address format", proposed_mac=proposed_mac) joined_mac = "".join(splitted_mac) # fmt: off @@ -173,9 +169,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {"changed": False, "commands": [], "warnings": warnings} @@ -183,9 +177,7 @@ def main(): args = PARAM_TO_COMMAND_KEYMAP.keys() existing = get_existing(module, args) - proposed = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) candidate = CustomNetworkConfig(indent=3) get_commands(module, existing, proposed, candidate) diff --git a/plugins/modules/nxos_pim.py b/plugins/modules/nxos_pim.py index 65ead8cf9..c7dee65fd 100644 --- a/plugins/modules/nxos_pim.py +++ b/plugins/modules/nxos_pim.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -78,17 +79,16 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) PARAM_TO_COMMAND_KEYMAP = { @@ -157,16 +157,12 @@ def get_commands(module, existing, proposed, candidate): def main(): argument_spec = dict( bfd=dict(required=False, type="str", choices=["enable", "disable"]), - ssm_range=dict( - required=False, type="list", default=[], elements="str" - ), + ssm_range=dict(required=False, type="list", default=[], elements="str"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {"changed": False, "commands": [], "warnings": warnings} diff --git a/plugins/modules/nxos_pim_interface.py b/plugins/modules/nxos_pim_interface.py index 3d3b31426..e08737a75 100644 --- a/plugins/modules/nxos_pim_interface.py +++ b/plugins/modules/nxos_pim_interface.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -166,17 +167,15 @@ """ import re + from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, + get_interface_type, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_interface_type, + run_commands, ) @@ -315,13 +314,9 @@ def get_pim_interface(module, interface): elif "sparse-mode" in each: pim_interface["sparse"] = True elif "bfd-instance" in each: - m = re.search( - r"ip pim bfd-instance(?P disable)?", each - ) + m = re.search(r"ip pim bfd-instance(?P disable)?", each) if m: - pim_interface["bfd"] = ( - "disable" if m.group("disable") else "enable" - ) + pim_interface["bfd"] = "disable" if m.group("disable") else "enable" elif "border" in each: pim_interface["border"] = True elif "hello-interval" in each: @@ -329,9 +324,7 @@ def get_pim_interface(module, interface): r"ip pim hello-interval (\d+)", body ).group(1) elif "dr-priority" in each: - pim_interface["dr_prio"] = re.search( - r"ip pim dr-priority (\d+)", body - ).group(1) + pim_interface["dr_prio"] = re.search(r"ip pim dr-priority (\d+)", body).group(1) return pim_interface @@ -339,10 +332,7 @@ def get_pim_interface(module, interface): def fix_delta(delta, existing): for key in list(delta): if key in ["dr_prio", "hello_interval", "sparse", "border"]: - if ( - delta.get(key) == PARAM_TO_DEFAULT_KEYMAP.get(key) - and existing.get(key) is None - ): + if delta.get(key) == PARAM_TO_DEFAULT_KEYMAP.get(key) and existing.get(key) is None: delta.pop(key) return delta @@ -356,13 +346,9 @@ def config_pim_interface(delta, existing, jp_bidir, isauth): if jp_bidir: if delta.get("jp_policy_in") or delta.get("jp_policy_out"): if existing.get("jp_type_in") == "prefix": - command = "no ip pim jp-policy prefix-list {0}".format( - existing.get("jp_policy_in") - ) + command = "no ip pim jp-policy prefix-list {0}".format(existing.get("jp_policy_in")) else: - command = "no ip pim jp-policy {0}".format( - existing.get("jp_policy_in") - ) + command = "no ip pim jp-policy {0}".format(existing.get("jp_policy_in")) if command: commands.append(command) @@ -394,9 +380,7 @@ def config_pim_interface(delta, existing, jp_bidir, isauth): "neighbor_type", ]: if k in ["neighbor_policy", "neighbor_type"]: - temp = delta.get("neighbor_policy") or existing.get( - "neighbor_policy" - ) + temp = delta.get("neighbor_policy") or existing.get("neighbor_policy") if delta.get("neighbor_type") == "prefix": command = PARAM_TO_COMMAND_KEYMAP.get(k).format(temp) elif delta.get("neighbor_type") == "routemap": @@ -406,9 +390,7 @@ def config_pim_interface(delta, existing, jp_bidir, isauth): elif existing.get("neighbor_type") == "routemap": command = "ip pim neighbor-policy {0}".format(temp) elif k in ["jp_policy_in", "jp_type_in"]: - temp = delta.get("jp_policy_in") or existing.get( - "jp_policy_in" - ) + temp = delta.get("jp_policy_in") or existing.get("jp_policy_in") if delta.get("jp_type_in") == "prefix": command = PARAM_TO_COMMAND_KEYMAP.get(k).format(temp) elif delta.get("jp_type_in") == "routemap": @@ -418,9 +400,7 @@ def config_pim_interface(delta, existing, jp_bidir, isauth): elif existing.get("jp_type_in") == "routemap": command = "ip pim jp-policy {0} in".format(temp) elif k in ["jp_policy_out", "jp_type_out"]: - temp = delta.get("jp_policy_out") or existing.get( - "jp_policy_out" - ) + temp = delta.get("jp_policy_out") or existing.get("jp_policy_out") if delta.get("jp_type_out") == "prefix": command = PARAM_TO_COMMAND_KEYMAP.get(k).format(temp) elif delta.get("jp_type_out") == "routemap": @@ -451,9 +431,7 @@ def get_pim_interface_defaults(): hello_auth_key=PARAM_TO_DEFAULT_KEYMAP.get("hello_auth_key"), ) - default = dict( - (param, value) for (param, value) in args.items() if value is not None - ) + default = dict((param, value) for (param, value) in args.items() if value is not None) return default @@ -464,9 +442,7 @@ def default_pim_interface_policies(existing, jp_bidir): if jp_bidir: if existing.get("jp_policy_in") or existing.get("jp_policy_out"): if existing.get("jp_type_in") == "prefix": - command = "no ip pim jp-policy prefix-list {0}".format( - existing.get("jp_policy_in") - ) + command = "no ip pim jp-policy prefix-list {0}".format(existing.get("jp_policy_in")) if command: commands.append(command) @@ -476,22 +452,16 @@ def default_pim_interface_policies(existing, jp_bidir): if k == "jp_policy_in": if existing.get("jp_policy_in"): if existing.get("jp_type_in") == "prefix": - command = ( - "no ip pim jp-policy prefix-list {0} in".format( - existing.get("jp_policy_in") - ) - ) - else: - command = "no ip pim jp-policy {0} in".format( + command = "no ip pim jp-policy prefix-list {0} in".format( existing.get("jp_policy_in") ) + else: + command = "no ip pim jp-policy {0} in".format(existing.get("jp_policy_in")) elif k == "jp_policy_out": if existing.get("jp_policy_out"): if existing.get("jp_type_out") == "prefix": - command = ( - "no ip pim jp-policy prefix-list {0} out".format( - existing.get("jp_policy_out") - ) + command = "no ip pim jp-policy prefix-list {0} out".format( + existing.get("jp_policy_out") ) else: command = "no ip pim jp-policy {0} out".format( @@ -586,27 +556,19 @@ def main(): if jp_policy_in: if not jp_type_in: - module.fail_json( - msg="jp_type_in required when using jp_policy_in." - ) + module.fail_json(msg="jp_type_in required when using jp_policy_in.") if jp_policy_out: if not jp_type_out: - module.fail_json( - msg="jp_type_out required when using jp_policy_out." - ) + module.fail_json(msg="jp_type_out required when using jp_policy_out.") if neighbor_policy: if not neighbor_type: - module.fail_json( - msg="neighbor_type required when using neighbor_policy." - ) + module.fail_json(msg="neighbor_type required when using neighbor_policy.") get_existing = get_pim_interface(module, interface) existing, jp_bidir, isauth = local_existing(get_existing) args = PARAM_TO_COMMAND_KEYMAP.keys() - proposed = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) normalize_proposed_values(proposed, module) delta = dict(set(proposed.items()).difference(existing.items())) diff --git a/plugins/modules/nxos_pim_rp_address.py b/plugins/modules/nxos_pim_rp_address.py index 9d48ac50e..576d95d1e 100644 --- a/plugins/modules/nxos_pim_rp_address.py +++ b/plugins/modules/nxos_pim_rp_address.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -83,17 +84,16 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) def get_existing(module, args, gl): @@ -146,9 +146,7 @@ def state_present(module, existing, proposed, candidate): def build_command(param_dict, command): for param in ["group_list", "prefix_list", "route_map"]: if param_dict.get(param): - command += " {0} {1}".format( - param.replace("_", "-"), param_dict.get(param) - ) + command += " {0} {1}".format(param.replace("_", "-"), param_dict.get(param)) if param_dict.get("bidir"): command += " bidir" return [command] @@ -191,9 +189,7 @@ def main(): prefix_list=dict(required=False, type="str"), route_map=dict(required=False, type="str"), bidir=dict(required=False, type="bool"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), ) argument_spec.update(nxos_argument_spec) @@ -214,9 +210,7 @@ def main(): args = ["rp_address", "group_list", "prefix_list", "route_map", "bidir"] - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) if module.params["group_list"]: existing = get_existing(module, args, True) diff --git a/plugins/modules/nxos_ping.py b/plugins/modules/nxos_ping.py index 0abc9c433..2e29dc3bf 100644 --- a/plugins/modules/nxos_ping.py +++ b/plugins/modules/nxos_ping.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -129,13 +130,12 @@ type: str sample: "0.00%" """ -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - run_commands, -) +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def get_summary(results_list, reference_point): @@ -205,9 +205,7 @@ def get_ping_results(command, module): splitted_ping = ping.split("\n") reference_point = get_statistics_summary_line(splitted_ping) summary, ping_pass = get_summary(splitted_ping, reference_point) - rtt = get_rtt( - splitted_ping, summary["packet_loss"], reference_point + 2 - ) + rtt = get_rtt(splitted_ping, summary["packet_loss"], reference_point + 2) return (summary, rtt, ping_pass) @@ -220,16 +218,12 @@ def main(): source=dict(required=False), size=dict(required=False, type="int"), df_bit=dict(required=False, default=False, type="bool"), - state=dict( - required=False, choices=["present", "absent"], default="present" - ), + state=dict(required=False, choices=["present", "absent"], default="present"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) destination = module.params["dest"] state = module.params["state"] diff --git a/plugins/modules/nxos_prefix_lists.py b/plugins/modules/nxos_prefix_lists.py index 707cceb12..cbd2415ca 100644 --- a/plugins/modules/nxos_prefix_lists.py +++ b/plugins/modules/nxos_prefix_lists.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -805,6 +806,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.prefix_lists.prefix_lists import ( Prefix_listsArgs, ) diff --git a/plugins/modules/nxos_reboot.py b/plugins/modules/nxos_reboot.py index 6a0111777..dafaff33c 100644 --- a/plugins/modules/nxos_reboot.py +++ b/plugins/modules/nxos_reboot.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -57,13 +58,12 @@ sample: true """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule def reboot(module): @@ -76,9 +76,7 @@ def main(): argument_spec = dict(confirm=dict(default=False, type="bool")) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = dict(changed=False, warnings=warnings) diff --git a/plugins/modules/nxos_rollback.py b/plugins/modules/nxos_rollback.py index ae77292b4..54f0f2372 100644 --- a/plugins/modules/nxos_rollback.py +++ b/plugins/modules/nxos_rollback.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -74,11 +75,12 @@ """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, run_commands, ) -from ansible.module_utils.basic import AnsibleModule def checkpoint(filename, module): @@ -100,9 +102,7 @@ def rollback(filename, module): def main(): - argument_spec = dict( - checkpoint_file=dict(required=False), rollback_to=dict(required=False) - ) + argument_spec = dict(checkpoint_file=dict(required=False), rollback_to=dict(required=False)) argument_spec.update(nxos_argument_spec) diff --git a/plugins/modules/nxos_route_maps.py b/plugins/modules/nxos_route_maps.py index 0cee81d7e..111cc4daf 100644 --- a/plugins/modules/nxos_route_maps.py +++ b/plugins/modules/nxos_route_maps.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1611,6 +1612,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.route_maps.route_maps import ( Route_mapsArgs, ) diff --git a/plugins/modules/nxos_rpm.py b/plugins/modules/nxos_rpm.py index 1d890fad5..eaecf42b8 100644 --- a/plugins/modules/nxos_rpm.py +++ b/plugins/modules/nxos_rpm.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -104,18 +105,17 @@ from copy import deepcopy -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) from ansible.module_utils.basic import AnsibleModule from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( remove_default_spec, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + load_config, + nxos_argument_spec, + run_commands, +) + def execute_show_command(command, module): iteration = 0 @@ -203,8 +203,7 @@ def activate_reload(module, pkg, flag): if "socket is closed" in msg[0].lower(): return cmd if ( - "another install operation is in progress" - in msg[0].lower() + "another install operation is in progress" in msg[0].lower() or "failed" in msg[0].lower() ): time.sleep(2) @@ -263,11 +262,7 @@ def install_remove_rpm(module, full_pkg, file_system, state): active_body = execute_show_command(show_active, module) if pkg not in inactive_body and pkg not in active_body: - commands.append( - add_operation( - module, show_inactive, file_system, full_pkg, pkg - ) - ) + commands.append(add_operation(module, show_inactive, file_system, full_pkg, pkg)) patch_type_body = execute_show_command(show_pkg_info, module) if patch_type_body and "Patch Type : reload" in patch_type_body: @@ -286,13 +281,9 @@ def install_remove_rpm(module, full_pkg, file_system, state): patch_body = execute_show_command(show_patches, module) if pkg in patch_body: # This is smu/patch rpm - commands.append( - commit_operation(module, show_commit, pkg, False) - ) + commands.append(commit_operation(module, show_commit, pkg, False)) else: - err = 'Operation "install activate {0} forced" Failed'.format( - pkg - ) + err = 'Operation "install activate {0} forced" Failed'.format(pkg) module.fail_json(msg=err) else: @@ -309,15 +300,11 @@ def install_remove_rpm(module, full_pkg, file_system, state): commands.append(activate_reload(module, pkg, False)) return commands else: - commands.append( - deactivate_operation(module, show_active, pkg, True) - ) + commands.append(deactivate_operation(module, show_active, pkg, True)) commit_body = execute_show_command(show_commit, module) if pkg in commit_body: # This is smu/patch rpm - commands.append( - commit_operation(module, show_commit, pkg, True) - ) + commands.append(commit_operation(module, show_commit, pkg, True)) commands.extend(remove_operation(module, show_inactive, pkg)) elif pkg in commit_body: @@ -331,9 +318,7 @@ def install_remove_rpm(module, full_pkg, file_system, state): commands.append(activate_reload(module, pkg, False)) return commands else: - commands.append( - deactivate_operation(module, show_inactive, pkg, False) - ) + commands.append(deactivate_operation(module, show_inactive, pkg, False)) commands.extend(remove_operation(module, show_inactive, pkg)) else: @@ -357,9 +342,7 @@ def main(): # remove default in aggregate spec, to handle common arguments remove_default_spec(aggregate_spec) - argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec) - ) + argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) argument_spec.update(element_spec) argument_spec.update(nxos_argument_spec) @@ -398,18 +381,12 @@ def main(): for obj in objects: if obj["state"] == "present": - remote_exists = remote_file_exists( - module, obj["pkg"], file_system=obj["file_system"] - ) + remote_exists = remote_file_exists(module, obj["pkg"], file_system=obj["file_system"]) if not remote_exists: - module.fail_json( - msg="The requested package doesn't exist on the device" - ) + module.fail_json(msg="The requested package doesn't exist on the device") - cmds = install_remove_rpm( - module, obj["pkg"], obj["file_system"], obj["state"] - ) + cmds = install_remove_rpm(module, obj["pkg"], obj["file_system"], obj["state"]) if cmds: results["changed"] = True diff --git a/plugins/modules/nxos_smu.py b/plugins/modules/nxos_smu.py index 5600e1c66..fba7ff585 100644 --- a/plugins/modules/nxos_smu.py +++ b/plugins/modules/nxos_smu.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -70,14 +71,13 @@ import time +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -132,9 +132,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} @@ -144,9 +142,7 @@ def main(): remote_exists = remote_file_exists(module, pkg, file_system=file_system) if not remote_exists: - module.fail_json( - msg="The requested package doesn't exist on the device" - ) + module.fail_json(msg="The requested package doesn't exist on the device") commands = get_commands(module, pkg, file_system) if commands: diff --git a/plugins/modules/nxos_snapshot.py b/plugins/modules/nxos_snapshot.py index 58cbbcd1e..a48df3bc3 100644 --- a/plugins/modules/nxos_snapshot.py +++ b/plugins/modules/nxos_snapshot.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -148,12 +149,11 @@ import re from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) @@ -289,9 +289,7 @@ def action_delete(module, existing_snapshots): exist = True if exist: - commands.append( - "snapshot delete {0}".format(module.params["snapshot_name"]) - ) + commands.append("snapshot delete {0}".format(module.params["snapshot_name"])) return commands @@ -372,11 +370,7 @@ def main(): comparison_results_file = module.params["comparison_results_file"] if not os.path.isdir(module.params["path"]): - module.fail_json( - msg="{0} is not a valid directory name.".format( - module.params["path"] - ) - ) + module.fail_json(msg="{0} is not a valid directory name.".format(module.params["path"])) existing_snapshots = invoke("get_existing", module) action_results = invoke("action_%s" % action, module, existing_snapshots) @@ -391,9 +385,7 @@ def main(): snapshot1 = module.params["snapshot1"] snapshot2 = module.params["snapshot2"] compare_option = module.params["compare_option"] - command = "show snapshot compare {0} {1}".format( - snapshot1, snapshot2 - ) + command = "show snapshot compare {0} {1}".format(snapshot1, snapshot2) if compare_option: command += " {0}".format(compare_option) content = execute_show_command(command, module)[0] @@ -410,14 +402,10 @@ def main(): and module.params["path"] and module.params["save_snapshot_locally"] ): - command = "show snapshot dump {0} | json".format( - module.params["snapshot_name"] - ) + command = "show snapshot dump {0} | json".format(module.params["snapshot_name"]) content = execute_show_command(command, module)[0] if content: - write_on_file( - str(content), module.params["snapshot_name"], module - ) + write_on_file(str(content), module.params["snapshot_name"], module) module.exit_json(**result) diff --git a/plugins/modules/nxos_snmp_community.py b/plugins/modules/nxos_snmp_community.py index 23571af14..4406ab735 100644 --- a/plugins/modules/nxos_snmp_community.py +++ b/plugins/modules/nxos_snmp_community.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -86,14 +87,14 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -216,9 +217,7 @@ def main(): configured_groups = get_snmp_groups(module) if group not in configured_groups: - module.fail_json( - msg="Group not on switch. Please add before moving forward" - ) + module.fail_json(msg="Group not on switch. Please add before moving forward") existing = get_snmp_community(module, community) args = dict(group=group, acl=acl) diff --git a/plugins/modules/nxos_snmp_contact.py b/plugins/modules/nxos_snmp_contact.py index f4050374e..5ab6b7ec1 100644 --- a/plugins/modules/nxos_snmp_contact.py +++ b/plugins/modules/nxos_snmp_contact.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -73,14 +74,13 @@ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -119,9 +119,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} diff --git a/plugins/modules/nxos_snmp_host.py b/plugins/modules/nxos_snmp_host.py index f7300db17..b1c2a0b1a 100644 --- a/plugins/modules/nxos_snmp_host.py +++ b/plugins/modules/nxos_snmp_host.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -123,14 +124,14 @@ import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -202,11 +203,7 @@ def get_snmp_host(host, udp, module): vrf_filt = each.get("TABLE_vrf_filters") if vrf_filt: - vrf_filter = ( - vrf_filt["ROW_vrf_filters"]["vrf_filter"] - .split(":")[1] - .split(",") - ) + vrf_filter = vrf_filt["ROW_vrf_filters"]["vrf_filter"].split(":")[1].split(",") filters = [vrf.strip() for vrf in vrf_filter] host_resource["vrf_filter"] = filters @@ -223,18 +220,14 @@ def get_snmp_host(host, udp, module): resource_table = [resource_table] for each in resource_table: - key = ( - str(each["address"]) + "_" + str(each["port"]).strip() - ) + key = str(each["address"]) + "_" + str(each["port"]).strip() src = each.get("src_intf") host_resource = apply_key_map(host_map_5k, each) if src: host_resource["src_intf"] = src if re.search(r"interface:", src): - host_resource["src_intf"] = src.split(":")[ - 1 - ].strip() + host_resource["src_intf"] = src.split(":")[1].strip() vrf = each.get("use_vrf_name") if vrf: @@ -242,9 +235,7 @@ def get_snmp_host(host, udp, module): vrf_filt = each.get("TABLE_filter_vrf") if vrf_filt: - vrf_filter = vrf_filt["ROW_filter_vrf"][ - "filter_vrf_name" - ].split(",") + vrf_filter = vrf_filt["ROW_filter_vrf"]["filter_vrf_name"].split(",") filters = [vrf.strip() for vrf in vrf_filter] host_resource["vrf_filter"] = filters @@ -407,9 +398,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} @@ -447,10 +436,7 @@ def main(): module.fail_json(msg="inform requires snmp v2c or v3") if (version == "v1" or version == "v2c") and v3: - module.fail_json( - msg='param: "v3" should not be used when ' - "using version v1 or v2c" - ) + module.fail_json(msg='param: "v3" should not be used when ' "using version v1 or v2c") if not any([vrf_filter, vrf, src_intf]): if not all([snmp_type, version, community, udp]): @@ -499,9 +485,7 @@ def main(): if proposed.get("vrf"): commands.append(remove_vrf(snmp_host, udp, proposed, existing)) if proposed.get("vrf_filter"): - commands.append( - remove_filter(snmp_host, udp, proposed, existing) - ) + commands.append(remove_filter(snmp_host, udp, proposed, existing)) elif state == "present": delta = dict(set(proposed.items()).difference(existing.items())) diff --git a/plugins/modules/nxos_snmp_location.py b/plugins/modules/nxos_snmp_location.py index 71c8f9770..bf7c7cac9 100644 --- a/plugins/modules/nxos_snmp_location.py +++ b/plugins/modules/nxos_snmp_location.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -78,14 +79,13 @@ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -124,9 +124,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} diff --git a/plugins/modules/nxos_snmp_server.py b/plugins/modules/nxos_snmp_server.py index 7c5165dad..1de2c84fe 100644 --- a/plugins/modules/nxos_snmp_server.py +++ b/plugins/modules/nxos_snmp_server.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1378,6 +1379,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.snmp_server.snmp_server import ( Snmp_serverArgs, ) diff --git a/plugins/modules/nxos_snmp_traps.py b/plugins/modules/nxos_snmp_traps.py index 0c9e263b5..54b04b13a 100644 --- a/plugins/modules/nxos_snmp_traps.py +++ b/plugins/modules/nxos_snmp_traps.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -109,17 +110,14 @@ """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, -) -from ansible.module_utils.basic import AnsibleModule def get_platform_id(module): @@ -180,9 +178,7 @@ def get_snmp_traps(group, module): ] if "all" in group and "N3K-C35" in get_platform_id(module): - module.warn( - "Platform does not support bfd traps; bfd ignored for 'group: all' request" - ) + module.warn("Platform does not support bfd traps; bfd ignored for 'group: all' request") feature_list.remove("bfd") for each in feature_list: @@ -230,17 +226,13 @@ def get_trap_commands(group, state, existing, module): if state == "disabled": for feature in existing: if existing[feature]: - trap_command = "no snmp-server enable traps {0}".format( - feature - ) + trap_command = "no snmp-server enable traps {0}".format(feature) commands.append(trap_command) elif state == "enabled": for feature in existing: if existing[feature] is False: - trap_command = "snmp-server enable traps {0}".format( - feature - ) + trap_command = "snmp-server enable traps {0}".format(feature) commands.append(trap_command) else: @@ -251,15 +243,11 @@ def get_trap_commands(group, state, existing, module): disabled = True if state == "disabled" and enabled: - commands.append( - ["no snmp-server enable traps {0}".format(group)] - ) + commands.append(["no snmp-server enable traps {0}".format(group)]) elif state == "enabled" and disabled: commands.append(["snmp-server enable traps {0}".format(group)]) else: - module.fail_json( - msg="{0} is not a currently " "enabled feature.".format(group) - ) + module.fail_json(msg="{0} is not a currently " "enabled feature.".format(group)) return commands @@ -306,9 +294,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} diff --git a/plugins/modules/nxos_snmp_user.py b/plugins/modules/nxos_snmp_user.py index 88b34cf12..35d70f0e1 100644 --- a/plugins/modules/nxos_snmp_user.py +++ b/plugins/modules/nxos_snmp_user.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -100,14 +101,13 @@ import re +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module, text=False): @@ -253,9 +253,7 @@ def get_non_structured_snmp_user(body_text): return resource resource["user"] = m.group("user") resource["auth"] = m.group("auth") - resource["encrypt"] = ( - "aes-128" if "aes" in str(m.group("priv")) else "none" - ) + resource["encrypt"] = "aes-128" if "aes" in str(m.group("priv")) else "none" resource["group"] = [m.group("group")] more_groups = re.findall(r"^\s+([\w\d-]+)\s*$", output, re.M) @@ -336,8 +334,7 @@ def main(): if privacy and encrypt: if not pwd and authentication: module.fail_json( - msg="pwd and authentication must be provided " - "when using privacy and encrypt" + msg="pwd and authentication must be provided " "when using privacy and encrypt" ) if group and group not in get_snmp_groups(module): diff --git a/plugins/modules/nxos_static_route.py b/plugins/modules/nxos_static_route.py index 4db8c8a23..15c714935 100644 --- a/plugins/modules/nxos_static_route.py +++ b/plugins/modules/nxos_static_route.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -149,16 +150,9 @@ sample: ["ip route 192.168.20.0/24 192.0.2.3 name testing 100"] """ import re + from copy import deepcopy -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) from ansible.module_utils.basic import AnsibleModule from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( CustomNetworkConfig, @@ -167,6 +161,13 @@ remove_default_spec, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_config, + load_config, + nxos_argument_spec, + run_commands, +) + def reconcile_candidate(module, candidate, prefix, want): state, vrf = want["state"], want["vrf"] @@ -178,9 +179,7 @@ def reconcile_candidate(module, candidate, prefix, want): flags = " | section '{0}' | include '^ ip route'".format(parents[0]) # Find existing routes in this vrf/default - netcfg = CustomNetworkConfig( - indent=2, contents=get_config(module, flags=[flags]) - ) + netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=[flags])) routes = str(netcfg).split("\n") # strip whitespace from route strings routes = [i.strip() for i in routes] @@ -223,9 +222,7 @@ def set_route_command(prefix, w, module): if get_configured_track(module, w["track"]): route_cmd += " track {0}".format(w["track"]) else: - module.fail_json( - msg="Track {0} not configured on device".format(w["track"]) - ) + module.fail_json(msg="Track {0} not configured on device".format(w["track"])) else: module.fail_json(msg="Invalid track number, valid range is 1-512.") if w["route_name"] and w["route_name"] != "default": @@ -267,13 +264,9 @@ def network_from_string(address, mask, module): for octect in octects: try: if int(octect) < 0 or int(octect) > 255: - module.fail_json( - msg="Address may contain invalid values.", address=address - ) + module.fail_json(msg="Address may contain invalid values.", address=address) except ValueError: - module.fail_json( - msg="Address may contain non-integer values.", address=address - ) + module.fail_json(msg="Address may contain non-integer values.", address=address) try: if int(mask) < 0 or int(mask) > 32: @@ -349,16 +342,12 @@ def main(): # remove default in aggregate spec, to handle common arguments remove_default_spec(aggregate_spec) - argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec) - ) + argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) argument_spec.update(element_spec) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {"changed": False, "commands": []} diff --git a/plugins/modules/nxos_static_routes.py b/plugins/modules/nxos_static_routes.py index 0bcf1c0f0..15b8e6903 100644 --- a/plugins/modules/nxos_static_routes.py +++ b/plugins/modules/nxos_static_routes.py @@ -27,6 +27,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -451,6 +452,7 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.static_routes.static_routes import ( Static_routesArgs, ) @@ -465,9 +467,7 @@ def main(): :returns: the result form module invocation """ - module = AnsibleModule( - argument_spec=Static_routesArgs.argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=Static_routesArgs.argument_spec, supports_check_mode=True) result = Static_routes(module).execute_module() module.exit_json(**result) diff --git a/plugins/modules/nxos_system.py b/plugins/modules/nxos_system.py index 4c5c77817..a369fdd9b 100644 --- a/plugins/modules/nxos_system.py +++ b/plugins/modules/nxos_system.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -118,13 +119,6 @@ """ import re -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( @@ -134,6 +128,13 @@ ComplexList, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_config, + load_config, + nxos_argument_spec, +) + + _CONFIGURED_VRFS = None @@ -375,9 +376,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_telemetry.py b/plugins/modules/nxos_telemetry.py index 7e1f65b7c..82134e7cc 100644 --- a/plugins/modules/nxos_telemetry.py +++ b/plugins/modules/nxos_telemetry.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -313,6 +314,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.telemetry.telemetry import ( TelemetryArgs, ) @@ -327,9 +329,7 @@ def main(): :returns: the result form module invocation """ - module = AnsibleModule( - argument_spec=TelemetryArgs.argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=TelemetryArgs.argument_spec, supports_check_mode=True) result = Telemetry(module).execute_module() module.exit_json(**result) diff --git a/plugins/modules/nxos_udld.py b/plugins/modules/nxos_udld.py index e47c7b6d1..72b7148c5 100644 --- a/plugins/modules/nxos_udld.py +++ b/plugins/modules/nxos_udld.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -108,14 +109,13 @@ sample: true """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule PARAM_TO_DEFAULT_KEYMAP = {"msg_time": "15"} @@ -148,17 +148,11 @@ def get_commands_config_udld_global(delta, reset, existing): commands = [] for param, value in delta.items(): if param == "aggressive": - command = ( - "udld aggressive" - if value == "enabled" - else "no udld aggressive" - ) + command = "udld aggressive" if value == "enabled" else "no udld aggressive" commands.append(command) elif param == "msg_time": if value == "default": - if existing.get("msg_time") != PARAM_TO_DEFAULT_KEYMAP.get( - "msg_time" - ): + if existing.get("msg_time") != PARAM_TO_DEFAULT_KEYMAP.get("msg_time"): commands.append("no udld message-time") else: commands.append("udld message-time " + value) @@ -205,9 +199,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -231,9 +223,7 @@ def main(): commands = [] if state == "present": if delta: - command = get_commands_config_udld_global( - dict(delta), reset, existing - ) + command = get_commands_config_udld_global(dict(delta), reset, existing) commands.append(command) elif state == "absent": diff --git a/plugins/modules/nxos_udld_interface.py b/plugins/modules/nxos_udld_interface.py index e9b37c2e4..6736e39ad 100644 --- a/plugins/modules/nxos_udld_interface.py +++ b/plugins/modules/nxos_udld_interface.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -118,14 +119,13 @@ """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def flatten_list(command_lists): @@ -144,9 +144,7 @@ def get_udld_interface(module, interface): mode = None mode_str = None try: - body = run_commands(module, [{"command": command, "output": "text"}])[ - 0 - ] + body = run_commands(module, [{"command": command, "output": "text"}])[0] if "aggressive" in body: mode = "aggressive" mode_str = "aggressive" @@ -230,18 +228,14 @@ def get_commands_remove_udld_interface(delta, interface, module, existing): def main(): argument_spec = dict( - mode=dict( - choices=["enabled", "disabled", "aggressive"], required=True - ), + mode=dict(choices=["enabled", "disabled", "aggressive"], required=True), interface=dict(type="str", required=True), state=dict(choices=["absent", "present"], default="present"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -260,9 +254,7 @@ def main(): cmds = [] if state == "present": if delta: - command = get_commands_config_udld_interface1( - delta, interface, module, existing - ) + command = get_commands_config_udld_interface1(delta, interface, module, existing) commands.append(command) cmds = flatten_list(commands) if module.check_mode: @@ -273,9 +265,7 @@ def main(): if delta["mode"] == "enabled" or delta["mode"] == "disabled": commands = [] - command = get_commands_config_udld_interface2( - delta, interface, module, existing - ) + command = get_commands_config_udld_interface2(delta, interface, module, existing) commands.append(command) cmds = flatten_list(commands) if module.check_mode: @@ -286,9 +276,7 @@ def main(): else: common = set(proposed.items()).intersection(existing.items()) if common: - command = get_commands_remove_udld_interface( - dict(common), interface, module, existing - ) + command = get_commands_remove_udld_interface(dict(common), interface, module, existing) cmds = flatten_list(commands) if module.check_mode: module.exit_json(changed=True, commands=cmds) diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index 5eab0b636..c3aa8453d 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -181,14 +182,6 @@ from copy import deepcopy from functools import partial -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - run_commands, - load_config, - get_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( @@ -196,6 +189,14 @@ to_list, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_config, + load_config, + nxos_argument_spec, + run_commands, +) + + BUILTIN_ROLES = [ "network-admin", "network-operator", @@ -307,9 +308,7 @@ def parse_roles(data): def map_config_to_obj(module): - out = run_commands( - module, [{"command": "show user-account", "output": "json"}] - ) + out = run_commands(module, [{"command": "show user-account", "output": "json"}]) data = out[0] objects = list() @@ -404,9 +403,7 @@ def main(): element_spec = dict( name=dict(), configured_password=dict(no_log=True), - update_password=dict( - default="always", choices=["on_create", "always"] - ), + update_password=dict(default="always", choices=["on_create", "always"]), roles=dict(type="list", aliases=["role"], elements="str"), sshkey=dict(no_log=False), state=dict(default="present", choices=["present", "absent"]), @@ -468,11 +465,7 @@ def main(): module.fail_json(msg=resp) else: result["warnings"].extend( - [ - x[9:] - for x in resp.splitlines() - if x.startswith("WARNING: ") - ] + [x[9:] for x in resp.splitlines() if x.startswith("WARNING: ")] ) result["changed"] = True diff --git a/plugins/modules/nxos_vlan.py b/plugins/modules/nxos_vlan.py index 055fb6b7e..f65104498 100644 --- a/plugins/modules/nxos_vlan.py +++ b/plugins/modules/nxos_vlan.py @@ -18,6 +18,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -250,18 +251,6 @@ from copy import deepcopy -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - normalize_interface, - nxos_argument_spec, -) from ansible.module_utils.basic import AnsibleModule from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( CustomNetworkConfig, @@ -270,6 +259,15 @@ remove_default_spec, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, + get_config, + load_config, + normalize_interface, + nxos_argument_spec, + run_commands, +) + def search_obj_in_list(vlan_id, lst): for o in lst: @@ -320,9 +318,7 @@ def map_obj_to_commands(updates, module): del w["state"] obj_in_have = search_obj_in_list(vlan_id, have) or {} - if not re.match("N[567]", os_platform) or ( - not obj_in_have.get("mode") and mode == "ce" - ): + if not re.match("N[567]", os_platform) or (not obj_in_have.get("mode") and mode == "ce"): mode = w["mode"] = None if state == "absent": @@ -352,9 +348,7 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(i)) commands.append("switchport") commands.append("switchport mode access") - commands.append( - "switchport access vlan {0}".format(vlan_id) - ) + commands.append("switchport access vlan {0}".format(vlan_id)) else: diff = get_diff(w, obj_in_have) @@ -396,23 +390,17 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(i)) commands.append("switchport") commands.append("switchport mode access") - commands.append( - "switchport access vlan {0}".format(vlan_id) - ) + commands.append("switchport access vlan {0}".format(vlan_id)) elif set(interfaces) != set(obj_in_have["interfaces"]): - missing_interfaces = list( - set(interfaces) - set(obj_in_have["interfaces"]) - ) + missing_interfaces = list(set(interfaces) - set(obj_in_have["interfaces"])) for i in missing_interfaces: commands.append("vlan {0}".format(vlan_id)) commands.append("exit") commands.append("interface {0}".format(i)) commands.append("switchport") commands.append("switchport mode access") - commands.append( - "switchport access vlan {0}".format(vlan_id) - ) + commands.append("switchport access vlan {0}".format(vlan_id)) superfluous_interfaces = list( set(obj_in_have["interfaces"]) - set(interfaces) @@ -423,9 +411,7 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(i)) commands.append("switchport") commands.append("switchport mode access") - commands.append( - "no switchport access vlan {0}".format(vlan_id) - ) + commands.append("no switchport access vlan {0}".format(vlan_id)) elif interfaces and interfaces[0] == "default": if obj_in_have["interfaces"]: @@ -435,16 +421,12 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(i)) commands.append("switchport") commands.append("switchport mode access") - commands.append( - "no switchport access vlan {0}".format(vlan_id) - ) + commands.append("no switchport access vlan {0}".format(vlan_id)) if purge: for h in have: if h["vlan_id"] == "1": - module.warn( - "Deletion of vlan 1 is not allowed; purge will ignore vlan 1" - ) + module.warn("Deletion of vlan 1 is not allowed; purge will ignore vlan 1") continue obj_in_want = search_obj_in_list(h["vlan_id"], want) if not obj_in_want: @@ -522,9 +504,7 @@ def map_params_to_obj(module): obj.append(d) else: interfaces = normalize(module.params["interfaces"]) - associated_interfaces = normalize( - module.params["associated_interfaces"] - ) + associated_interfaces = normalize(module.params["associated_interfaces"]) obj.append( { @@ -694,9 +674,7 @@ def map_config_to_obj(module): command = ["show vlan brief | json"] output = run_commands(module, command, check_rc="retry_json")[0] if output: - netcfg = CustomNetworkConfig( - indent=2, contents=get_config(module, flags=["all"]) - ) + netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=["all"])) if isinstance(output, dict): vlans = None @@ -759,15 +737,8 @@ def check_declarative_intent_params(want, module, result): for i in w["associated_interfaces"]: obj_in_have = search_obj_in_list(w["vlan_id"], have) - if ( - obj_in_have - and "interfaces" in obj_in_have - and i not in obj_in_have["interfaces"] - ): - module.fail_json( - msg="Interface %s not configured on vlan %s" - % (i, w["vlan_id"]) - ) + if obj_in_have and "interfaces" in obj_in_have and i not in obj_in_have["interfaces"]: + module.fail_json(msg="Interface %s not configured on vlan %s" % (i, w["vlan_id"])) def main(): @@ -778,14 +749,10 @@ def main(): name=dict(required=False), interfaces=dict(type="list", elements="str"), associated_interfaces=dict(type="list", elements="str"), - vlan_state=dict( - choices=["active", "suspend"], required=False, default="active" - ), + vlan_state=dict(choices=["active", "suspend"], required=False, default="active"), mapped_vni=dict(required=False), delay=dict(default=10, type="int"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), admin_state=dict(choices=["up", "down"], required=False, default="up"), mode=dict(default="ce", choices=["ce", "fabricpath"]), ) diff --git a/plugins/modules/nxos_vlans.py b/plugins/modules/nxos_vlans.py index 217a4ef10..cac276b64 100644 --- a/plugins/modules/nxos_vlans.py +++ b/plugins/modules/nxos_vlans.py @@ -28,6 +28,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -413,6 +414,7 @@ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.vlans.vlans import ( VlansArgs, ) @@ -427,9 +429,7 @@ def main(): :returns: the result form module invocation """ - module = AnsibleModule( - argument_spec=VlansArgs.argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=VlansArgs.argument_spec, supports_check_mode=True) result = Vlans(module).execute_module() module.exit_json(**result) diff --git a/plugins/modules/nxos_vpc.py b/plugins/modules/nxos_vpc.py index 5f8b4fc90..ba49aca7e 100644 --- a/plugins/modules/nxos_vpc.py +++ b/plugins/modules/nxos_vpc.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -154,15 +155,15 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule CONFIG_ARGS = { @@ -391,9 +392,7 @@ def main(): auto_recovery = module.params["auto_recovery"] auto_recovery_reload_delay = module.params["auto_recovery_reload_delay"] delay_restore = module.params["delay_restore"] - delay_restore_interface_vlan = module.params[ - "delay_restore_interface_vlan" - ] + delay_restore_interface_vlan = module.params["delay_restore_interface_vlan"] delay_restore_orphan_port = module.params["delay_restore_orphan_port"] state = module.params["state"] @@ -414,20 +413,15 @@ def main(): if not pkl_dest: if pkl_src: - module.fail_json( - msg="dest IP for peer-keepalive is required" - " when src IP is present" - ) + module.fail_json(msg="dest IP for peer-keepalive is required" " when src IP is present") elif pkl_vrf: if pkl_vrf != "management": module.fail_json( - msg="dest and src IP for peer-keepalive are required" - " when vrf is present" + msg="dest and src IP for peer-keepalive are required" " when vrf is present" ) else: module.fail_json( - msg="dest IP for peer-keepalive is required" - " when vrf is present" + msg="dest IP for peer-keepalive is required" " when vrf is present" ) if pkl_vrf: if pkl_vrf.lower() not in get_vrf_list(module): @@ -451,16 +445,13 @@ def main(): if delta: pkl_dependencies(module, delta, existing) - command = get_commands_to_config_vpc( - module, delta, domain, existing - ) + command = get_commands_to_config_vpc(module, delta, domain, existing) commands.append(command) elif state == "absent": if existing: if domain != existing["domain"]: module.fail_json( - msg="You are trying to remove a domain that " - "does not exist on the device" + msg="You are trying to remove a domain that " "does not exist on the device" ) else: commands.append("terminal dont-ask") diff --git a/plugins/modules/nxos_vpc_interface.py b/plugins/modules/nxos_vpc_interface.py index ab79e4ec0..b2589e61e 100644 --- a/plugins/modules/nxos_vpc_interface.py +++ b/plugins/modules/nxos_vpc_interface.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -77,15 +78,14 @@ sample: ["interface port-channel100", "vpc 10"] """ +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def flatten_list(command_lists): @@ -198,9 +198,7 @@ def get_portchannel_vpc_config(module, portchannel): return config -def get_commands_to_config_vpc_interface( - portchannel, delta, config_value, existing -): +def get_commands_to_config_vpc_interface(portchannel, delta, config_value, existing): commands = [] if not delta.get("peer-link") and existing.get("peer-link"): @@ -222,9 +220,7 @@ def get_commands_to_config_vpc_interface( def state_present(portchannel, delta, config_value, existing): commands = [] - command = get_commands_to_config_vpc_interface( - portchannel, delta, config_value, existing - ) + command = get_commands_to_config_vpc_interface(portchannel, delta, config_value, existing) commands.append(command) return commands @@ -273,9 +269,7 @@ def main(): active_peer_link = None if portchannel not in get_portchannel_list(module): - if not portchannel.isdigit() or int( - portchannel - ) not in get_portchannel_list(module): + if not portchannel.isdigit() or int(portchannel) not in get_portchannel_list(module): module.fail_json( msg="The portchannel you are trying to make a" " VPC or PL is not created yet. " @@ -317,8 +311,7 @@ def main(): if active_peer_link != portchannel: if peer_link: module.fail_json( - msg="A peer link already exists on" - " the device. Remove it first", + msg="A peer link already exists on" " the device. Remove it first", current_peer_link="Po{0}".format(active_peer_link), ) config_value = "peer-link" @@ -329,9 +322,7 @@ def main(): if state == "present": delta = dict(set(proposed.items()).difference(existing.items())) if delta: - commands = state_present( - portchannel, delta, config_value, existing - ) + commands = state_present(portchannel, delta, config_value, existing) elif state == "absent" and existing: commands = state_absent(portchannel, existing) diff --git a/plugins/modules/nxos_vrf.py b/plugins/modules/nxos_vrf.py index b928018f8..6f62024b8 100644 --- a/plugins/modules/nxos_vrf.py +++ b/plugins/modules/nxos_vrf.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -235,16 +236,15 @@ from copy import deepcopy from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, ) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, get_interface_type, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, + load_config, + nxos_argument_spec, + run_commands, ) @@ -340,12 +340,8 @@ def map_obj_to_commands(updates, module): else: # If vni is already configured on vrf, unconfigure it first. if vni: - if obj_in_have.get("vni") and vni != obj_in_have.get( - "vni" - ): - commands.append( - "no vni {0}".format(obj_in_have.get("vni")) - ) + if obj_in_have.get("vni") and vni != obj_in_have.get("vni"): + commands.append("no vni {0}".format(obj_in_have.get("vni"))) for item in args: candidate = w.get(item) @@ -356,9 +352,7 @@ def map_obj_to_commands(updates, module): elif candidate and candidate != obj_in_have.get(item): cmd = item + " " + str(candidate) commands.append(cmd) - if admin_state and admin_state != obj_in_have.get( - "admin_state" - ): + if admin_state and admin_state != obj_in_have.get("admin_state"): if admin_state == "up": commands.append("no shutdown") elif admin_state == "down": @@ -382,9 +376,7 @@ def map_obj_to_commands(updates, module): commands.append("vrf member {0}".format(name)) elif set(interfaces) != set(obj_in_have["interfaces"]): - missing_interfaces = list( - set(interfaces) - set(obj_in_have["interfaces"]) - ) + missing_interfaces = list(set(interfaces) - set(obj_in_have["interfaces"])) for i in missing_interfaces: commands.append("vrf context {0}".format(name)) commands.append("exit") @@ -442,9 +434,7 @@ def validate_vrf(name, module): if name == "default": module.fail_json(msg="cannot use default as name of a VRF") elif len(name) > 32: - module.fail_json( - msg="VRF name exceeded max length of 32", name=name - ) + module.fail_json(msg="VRF name exceeded max length of 32", name=name) else: return name @@ -471,9 +461,7 @@ def map_params_to_obj(module): "admin_state": module.params["admin_state"], "state": module.params["state"], "interfaces": module.params["interfaces"], - "associated_interfaces": module.params[ - "associated_interfaces" - ], + "associated_interfaces": module.params["associated_interfaces"], } ) return obj @@ -555,10 +543,7 @@ def check_declarative_intent_params(want, module, element_spec, result): if obj_in_have: interfaces = obj_in_have.get("interfaces") if interfaces is not None and i not in interfaces: - module.fail_json( - msg="Interface %s not configured on vrf %s" - % (i, w["name"]) - ) + module.fail_json(msg="Interface %s not configured on vrf %s" % (i, w["name"])) def vrf_error_check(module, commands, responses): @@ -567,13 +552,9 @@ def vrf_error_check(module, commands, responses): if re.search(pattern, str(responses)): # Allow delay/retry for VRF changes time.sleep(15) - responses = load_config( - module, commands, opts={"catch_clierror": True} - ) + responses = load_config(module, commands, opts={"catch_clierror": True}) if re.search(pattern, str(responses)): - module.fail_json( - msg="VRF config (and retry) failure: %s " % responses - ) + module.fail_json(msg="VRF config (and retry) failure: %s " % responses) module.warn("VRF config delayed by VRF deletion - passed on retry") @@ -588,9 +569,7 @@ def main(): interfaces=dict(type="list", elements="str"), associated_interfaces=dict(type="list", elements="str"), delay=dict(type="int", default=10), - state=dict( - type="str", default="present", choices=["present", "absent"] - ), + state=dict(type="str", default="present", choices=["present", "absent"]), ) aggregate_spec = deepcopy(element_spec) @@ -627,9 +606,7 @@ def main(): result["commands"] = commands if commands and not module.check_mode: - responses = load_config( - module, commands, opts={"catch_clierror": True} - ) + responses = load_config(module, commands, opts={"catch_clierror": True}) vrf_error_check(module, commands, responses) result["changed"] = True diff --git a/plugins/modules/nxos_vrf_af.py b/plugins/modules/nxos_vrf_af.py index 1f4fe9a1a..eb008c4b6 100644 --- a/plugins/modules/nxos_vrf_af.py +++ b/plugins/modules/nxos_vrf_af.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -160,20 +161,19 @@ type: list sample: ["vrf context ntc", "address-family ipv4 unicast"] """ -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - get_capabilities, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, -) +import re + from ansible.module_utils.basic import AnsibleModule from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( NetworkConfig, ) -import re +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, + get_config, + load_config, + nxos_argument_spec, +) def match_current_rt(rt, direction, current, rt_commands): @@ -198,9 +198,7 @@ def main(): elements="dict", options=dict( rt=dict(type="str", required=True), - direction=dict( - choices=["import", "export", "both"], default="both" - ), + direction=dict(choices=["import", "export", "both"], default="both"), state=dict(choices=["present", "absent"], default="present"), ), ), @@ -208,9 +206,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -251,32 +247,20 @@ def main(): if module.params["route_targets"] is not None: for rt in module.params["route_targets"]: if rt.get("direction") == "both" or not rt.get("direction"): - platform = get_capabilities(module)["device_info"][ - "network_os_platform" - ] + platform = get_capabilities(module)["device_info"]["network_os_platform"] if platform.startswith("N9K") and rt.get("rt") == "auto": - rt_commands = match_current_rt( - rt, "both", current, rt_commands - ) + rt_commands = match_current_rt(rt, "both", current, rt_commands) else: - rt_commands = match_current_rt( - rt, "import", current, rt_commands - ) - rt_commands = match_current_rt( - rt, "export", current, rt_commands - ) + rt_commands = match_current_rt(rt, "import", current, rt_commands) + rt_commands = match_current_rt(rt, "export", current, rt_commands) else: - rt_commands = match_current_rt( - rt, rt.get("direction"), current, rt_commands - ) + rt_commands = match_current_rt(rt, rt.get("direction"), current, rt_commands) if rt_commands: commands.extend(rt_commands) if commands and current: - commands.insert( - 0, "address-family %s unicast" % module.params["afi"] - ) + commands.insert(0, "address-family %s unicast" % module.params["afi"]) if commands: commands.insert(0, "vrf context %s" % module.params["vrf"]) diff --git a/plugins/modules/nxos_vrf_interface.py b/plugins/modules/nxos_vrf_interface.py index 4273b9211..90c284f1c 100644 --- a/plugins/modules/nxos_vrf_interface.py +++ b/plugins/modules/nxos_vrf_interface.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -83,19 +84,16 @@ """ import re -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, - nxos_argument_spec, - normalize_interface, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_interface_type, + load_config, + normalize_interface, + nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule def execute_show_command(command, module): @@ -184,16 +182,12 @@ def main(): argument_spec = dict( vrf=dict(required=True), interface=dict(type="str", required=True), - state=dict( - default="present", choices=["present", "absent"], required=False - ), + state=dict(default="present", choices=["present", "absent"], required=False), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} @@ -207,10 +201,7 @@ def main(): current_vrfs = get_vrf_list(module) if vrf not in current_vrfs: - warnings.append( - "The VRF is not present/active on the device. " - "Use nxos_vrf to fix this." - ) + warnings.append("The VRF is not present/active on the device. " "Use nxos_vrf to fix this.") intf_type = get_interface_type(interface) if intf_type != "ethernet" and network_api == "cliconf": diff --git a/plugins/modules/nxos_vrrp.py b/plugins/modules/nxos_vrrp.py index f24020918..6a7d44b6f 100644 --- a/plugins/modules/nxos_vrrp.py +++ b/plugins/modules/nxos_vrrp.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -123,18 +124,15 @@ "authentication text testing", "no shutdown"] """ -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, - nxos_argument_spec, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_interface_type, + load_config, + nxos_argument_spec, + run_commands, ) -from ansible.module_utils.basic import AnsibleModule PARAM_TO_DEFAULT_KEYMAP = { @@ -330,8 +328,7 @@ def validate_params(param, module): raise ValueError except ValueError: module.fail_json( - msg="Warning! 'priority' must be an integer " - "between 1 and 254", + msg="Warning! 'priority' must be an integer " "between 1 and 254", priority=value, ) @@ -351,15 +348,11 @@ def main(): default="shutdown", ), authentication=dict(required=False, type="str", no_log=True), - state=dict( - choices=["absent", "present"], required=False, default="present" - ), + state=dict(choices=["absent", "present"], required=False, default="present"), ) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() results = {"changed": False, "commands": [], "warnings": warnings} @@ -396,8 +389,7 @@ def main(): mode, name = get_interface_mode(interface, intf_type, module) if mode == "layer2": module.fail_json( - msg="That interface is a layer2 port.\nMake it " - "a layer 3 port first.", + msg="That interface is a layer2 port.\nMake it " "a layer 3 port first.", interface=interface, ) diff --git a/plugins/modules/nxos_vtp_domain.py b/plugins/modules/nxos_vtp_domain.py index 114fc2630..3e6d9a08c 100644 --- a/plugins/modules/nxos_vtp_domain.py +++ b/plugins/modules/nxos_vtp_domain.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -89,18 +90,16 @@ """ +import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, -) -from ansible.module_utils.basic import AnsibleModule -import re def execute_show_command(command, module, output="json"): @@ -174,9 +173,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vtp_password.py b/plugins/modules/nxos_vtp_password.py index 9d94d8d1e..0970fb08b 100644 --- a/plugins/modules/nxos_vtp_password.py +++ b/plugins/modules/nxos_vtp_password.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -102,18 +103,16 @@ sample: true """ +import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, -) -from ansible.module_utils.basic import AnsibleModule -import re def execute_show_command(command, module, output="json"): @@ -204,9 +203,7 @@ def main(): argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -244,10 +241,7 @@ def main(): ) else: if not existing.get("domain"): - module.fail_json( - msg="Cannot remove a vtp password " - "before vtp domain is set." - ) + module.fail_json(msg="Cannot remove a vtp password " "before vtp domain is set.") elif existing["vtp_password"] != ("\\"): commands.append(["no vtp password"]) @@ -255,9 +249,7 @@ def main(): elif state == "present": if delta: if not existing.get("domain"): - module.fail_json( - msg="Cannot set vtp password " "before vtp domain is set." - ) + module.fail_json(msg="Cannot set vtp password " "before vtp domain is set.") else: commands.append(["vtp password {0}".format(vtp_password)]) diff --git a/plugins/modules/nxos_vtp_version.py b/plugins/modules/nxos_vtp_version.py index 48d6ebc45..ef2b0d525 100644 --- a/plugins/modules/nxos_vtp_version.py +++ b/plugins/modules/nxos_vtp_version.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -84,18 +85,16 @@ type: bool sample: true """ +import re + +from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + get_capabilities, load_config, - run_commands, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, + run_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, -) -from ansible.module_utils.basic import AnsibleModule -import re def execute_show_command(command, module, output="json"): @@ -165,15 +164,11 @@ def get_vtp_password(module): def main(): - argument_spec = dict( - version=dict(type="str", choices=["1", "2"], required=True) - ) + argument_spec = dict(version=dict(type="str", choices=["1", "2"], required=True)) argument_spec.update(nxos_argument_spec) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vxlan_vtep.py b/plugins/modules/nxos_vxlan_vtep.py index fd9c996c5..7ae67c591 100644 --- a/plugins/modules/nxos_vxlan_vtep.py +++ b/plugins/modules/nxos_vxlan_vtep.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -128,20 +129,18 @@ import re +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( run_commands, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) + BOOL_PARAMS = [ "shutdown", @@ -171,9 +170,7 @@ def get_value(arg, config, module): if arg in BOOL_PARAMS: - REGEX = re.compile( - r"\s+{0}\s*$".format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M - ) + REGEX = re.compile(r"\s+{0}\s*$".format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M) NO_SHUT_REGEX = re.compile(r"\s+no shutdown\s*$", re.M) value = False if arg == "shutdown": @@ -195,9 +192,7 @@ def get_value(arg, config, module): r"(?:{0}\s)(?P.*)$".format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M, ) - NO_DESC_REGEX = re.compile( - r"\s+{0}\s*$".format("no description"), re.M - ) + NO_DESC_REGEX = re.compile(r"\s+{0}\s*$".format("no description"), re.M) SOURCE_INTF_REGEX = re.compile( r"(?:{0}\s)(?P\S+)$".format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M, @@ -212,11 +207,7 @@ def get_value(arg, config, module): for line in config.splitlines(): try: if PARAM_TO_COMMAND_KEYMAP[arg] in config: - value = ( - SOURCE_INTF_REGEX.search(config) - .group("value") - .strip() - ) + value = SOURCE_INTF_REGEX.search(config).group("value").strip() break except AttributeError: value = "" @@ -240,11 +231,7 @@ def get_value(arg, config, module): for line in config.splitlines(): try: if PARAM_TO_COMMAND_KEYMAP[arg] in config: - value = ( - SOURCE_INTF_REGEX.search(config) - .group("value") - .strip() - ) + value = SOURCE_INTF_REGEX.search(config).group("value").strip() break except AttributeError: value = "" @@ -256,13 +243,9 @@ def get_value(arg, config, module): def get_existing(module, args): existing = {} - netcfg = CustomNetworkConfig( - indent=2, contents=get_config(module, flags=["all"]) - ) + netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=["all"])) - interface_string = "interface {0}".format( - module.params["interface"].lower() - ) + interface_string = "interface {0}".format(module.params["interface"].lower()) parents = [interface_string] config = netcfg.get_section(parents) @@ -338,9 +321,7 @@ def gsa_tcam_check(module): This method checks the current TCAM allocation. Note that changing tcam_size requires a switch reboot to take effect. """ - cmds = [ - {"command": "show hardware access-list tcam region", "output": "json"} - ] + cmds = [{"command": "show hardware access-list tcam region", "output": "json"}] body = run_commands(module, cmds) if body: tcam_region = body[0]["TCAM_Region"]["TABLE_Sizes"]["ROW_Sizes"] @@ -348,8 +329,7 @@ def gsa_tcam_check(module): [ i for i in tcam_region - if i["type"].startswith("Ingress ARP-Ether ACL") - and i["tcam_size"] == "0" + if i["type"].startswith("Ingress ARP-Ether ACL") and i["tcam_size"] == "0" ] ): msg = ( @@ -396,9 +376,7 @@ def state_present(module, existing, proposed, candidate): candidate.add(commands, parents=parents) else: if not existing and module.params["interface"]: - commands = [ - "interface {0}".format(module.params["interface"].lower()) - ] + commands = ["interface {0}".format(module.params["interface"].lower())] candidate.add(commands, parents=[]) @@ -419,17 +397,13 @@ def main(): shutdown=dict(required=False, type="bool"), source_interface=dict(required=False, type="str"), source_interface_hold_down_time=dict(required=False, type="str"), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + state=dict(choices=["present", "absent"], default="present", required=False), multisite_border_gateway_interface=dict(required=False, type="str"), ) argument_spec.update(nxos_argument_spec) - mutually_exclusive = [ - ("global_ingress_replication_bgp", "global_mcast_group_L2") - ] + mutually_exclusive = [("global_ingress_replication_bgp", "global_mcast_group_L2")] module = AnsibleModule( argument_spec=argument_spec, @@ -445,9 +419,7 @@ def main(): args = PARAM_TO_COMMAND_KEYMAP.keys() existing = get_existing(module, args) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): if key != "interface": diff --git a/plugins/modules/nxos_vxlan_vtep_vni.py b/plugins/modules/nxos_vxlan_vtep_vni.py index 86bfc2d9b..cc0c7b0db 100644 --- a/plugins/modules/nxos_vxlan_vtep_vni.py +++ b/plugins/modules/nxos_vxlan_vtep_vni.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -113,17 +114,18 @@ """ import re + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + CustomNetworkConfig, +) + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( nxos_argument_spec, ) -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) + BOOL_PARAMS = ["assoc_vrf", "suppress_arp", "suppress_arp_disable"] PARAM_TO_DEFAULT_KEYMAP = { @@ -146,9 +148,7 @@ def get_value(arg, config, module): command = PARAM_TO_COMMAND_KEYMAP[arg] - command_val_re = re.compile( - r"(?:{0}\s)(?P.*)$".format(command), re.M - ) + command_val_re = re.compile(r"(?:{0}\s)(?P.*)$".format(command), re.M) if arg in BOOL_PARAMS: command_re = re.compile(r"\s+{0}\s*$".format(command), re.M) @@ -196,13 +196,8 @@ def get_existing(module, args): parents = ["interface {0}".format(interface_exist)] temp_config = netcfg.get_section(parents) - if ( - "member vni {0} associate-vrf".format(module.params["vni"]) - in temp_config - ): - parents.append( - "member vni {0} associate-vrf".format(module.params["vni"]) - ) + if "member vni {0} associate-vrf".format(module.params["vni"]) in temp_config: + parents.append("member vni {0} associate-vrf".format(module.params["vni"])) config = netcfg.get_section(parents) elif "member vni {0}".format(module.params["vni"]) in temp_config: parents.append("member vni {0}".format(module.params["vni"])) @@ -250,19 +245,12 @@ def state_present(module, existing, proposed, candidate): vni_command = "member vni {0}".format(module.params["vni"]) if vni_command not in commands: commands.append("member vni {0}".format(module.params["vni"])) - if value != PARAM_TO_DEFAULT_KEYMAP.get( - "multicast_group", "default" - ): + if value != PARAM_TO_DEFAULT_KEYMAP.get("multicast_group", "default"): commands.append("{0} {1}".format(key, value)) - elif ( - key == "ingress-replication protocol" - and value != existing_commands.get(key) - ): + elif key == "ingress-replication protocol" and value != existing_commands.get(key): evalue = existing_commands.get(key) - dvalue = PARAM_TO_DEFAULT_KEYMAP.get( - "ingress_replication", "default" - ) + dvalue = PARAM_TO_DEFAULT_KEYMAP.get("ingress_replication", "default") if value != dvalue: if evalue and evalue != dvalue: commands.append("no {0} {1}".format(key, evalue)) @@ -286,10 +274,7 @@ def state_present(module, existing, proposed, candidate): else: if key.replace(" ", "_").replace("-", "_") in BOOL_PARAMS: commands.append("no {0}".format(key.lower())) - elif ( - key == "multisite ingress-replication" - and value != existing_commands.get(key) - ): + elif key == "multisite ingress-replication" and value != existing_commands.get(key): vni_command = "member vni {0}".format(module.params["vni"]) if vni_command not in commands: commands.append("member vni {0}".format(module.params["vni"])) @@ -310,9 +295,7 @@ def state_present(module, existing, proposed, candidate): vni_command = "member vni {0}".format(module.params["vni"]) ingress_replications_command = "ingress-replication protocol static" ingress_replicationb_command = "ingress-replication protocol bgp" - ingress_replicationns_command = ( - "no ingress-replication protocol static" - ) + ingress_replicationns_command = "no ingress-replication protocol static" ingress_replicationnb_command = "no ingress-replication protocol bgp" interface_command = "interface {0}".format(module.params["interface"]) @@ -351,9 +334,7 @@ def state_present(module, existing, proposed, candidate): def state_absent(module, existing, proposed, candidate): if existing["assoc_vrf"]: - commands = [ - "no member vni {0} associate-vrf".format(module.params["vni"]) - ] + commands = ["no member vni {0} associate-vrf".format(module.params["vni"])] else: commands = ["no member vni {0}".format(module.params["vni"])] parents = ["interface {0}".format(module.params["interface"])] @@ -369,12 +350,8 @@ def main(): peer_list=dict(required=False, type="list", elements="str"), suppress_arp=dict(required=False, type="bool"), suppress_arp_disable=dict(required=False, type="bool"), - ingress_replication=dict( - required=False, type="str", choices=["bgp", "static", "default"] - ), - state=dict( - choices=["present", "absent"], default="present", required=False - ), + ingress_replication=dict(required=False, type="str", choices=["bgp", "static", "default"]), + state=dict(choices=["present", "absent"], default="present", required=False), multisite_ingress_replication=dict( required=False, type="str", @@ -406,8 +383,7 @@ def main(): and module.params["ingress_replication"] != "static" ): module.fail_json( - msg="ingress_replication=static is required " - "when using peer_list param" + msg="ingress_replication=static is required " "when using peer_list param" ) else: peer_list = module.params["peer_list"] @@ -437,9 +413,7 @@ def main(): msg="The proposed NVE interface does not exist. Use nxos_interface to create it first." ) elif interface_exist != module.params["interface"]: - module.fail_json( - msg="Only 1 NVE interface is allowed on the switch." - ) + module.fail_json(msg="Only 1 NVE interface is allowed on the switch.") elif state == "absent": if interface_exist != module.params["interface"]: module.exit_json(**result) @@ -451,9 +425,7 @@ def main(): existing_vni=existing["vni"], ) - proposed_args = dict( - (k, v) for k, v in module.params.items() if v is not None and k in args - ) + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): diff --git a/plugins/modules/storage/nxos_devicealias.py b/plugins/modules/storage/nxos_devicealias.py index cbece233b..c487e44b6 100644 --- a/plugins/modules/storage/nxos_devicealias.py +++ b/plugins/modules/storage/nxos_devicealias.py @@ -103,12 +103,15 @@ - no terminal dont-ask """ +import string + from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, run_commands, ) -import string + __metaclass__ = type @@ -176,15 +179,11 @@ def isNameInDaDatabase(self, name): return name in self.da_dict.keys() def isPwwnInDaDatabase(self, pwwn): - newpwwn = ":".join( - ["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")] - ) + newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) return newpwwn in self.da_dict.values() def isNamePwwnPresentInDatabase(self, name, pwwn): - newpwwn = ":".join( - ["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")] - ) + newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) if name in self.da_dict.keys(): if newpwwn == self.da_dict[name]: return True @@ -197,9 +196,7 @@ def getPwwnByName(self, name): return None def getNameByPwwn(self, pwwn): - newpwwn = ":".join( - ["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")] - ) + newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) for n, p in self.da_dict.items(): if p == newpwwn: return n @@ -266,9 +263,7 @@ def main(): rename=dict(type="list", elements="dict", options=element_spec_rename), ) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() messages = list() @@ -302,9 +297,7 @@ def main(): + str(name) + ". Note that name cannot be more than 64 alphanumeric chars, " + "it must start with a letter, and can only contain these characters: " - + ", ".join( - ["'{0}'".format(c) for c in VALID_DA_CHARS] - ) + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]) ) if not isPwwnValid(pwwn): module.fail_json( @@ -338,9 +331,7 @@ def main(): d = shDAStausObj.getDistribute() m = shDAStausObj.getMode() if shDAStausObj.isLocked(): - module.fail_json( - msg="device-alias has acquired lock on the switch. Hence cannot procced." - ) + module.fail_json(msg="device-alias has acquired lock on the switch. Hence cannot procced.") # Step 1: Process distribute commands = [] @@ -351,9 +342,7 @@ def main(): # but switch distribute is disabled(false), so set it to # true(enabled) commands.append("device-alias distribute") - messages.append( - "device-alias distribute changed from disabled to enabled" - ) + messages.append("device-alias distribute changed from disabled to enabled") else: messages.append( "device-alias distribute remains unchanged. current distribution mode is enabled" @@ -364,9 +353,7 @@ def main(): # but switch distribute is enabled(true), so set it to # false(disabled) commands.append("no device-alias distribute") - messages.append( - "device-alias distribute changed from enabled to disabled" - ) + messages.append("device-alias distribute changed from enabled to disabled") else: messages.append( "device-alias distribute remains unchanged. current distribution mode is disabled" @@ -390,39 +377,27 @@ def main(): if m == "enhanced": # but switch mode is enhanced, so set it to basic commands.append("no device-alias mode enhanced") - messages.append( - "device-alias mode changed from enhanced to basic" - ) + messages.append("device-alias mode changed from enhanced to basic") else: - messages.append( - "device-alias mode remains unchanged. current mode is basic" - ) + messages.append("device-alias mode remains unchanged. current mode is basic") else: # playbook has mode as enhanced if m == "basic": # but switch mode is basic, so set it to enhanced commands.append("device-alias mode enhanced") - messages.append( - "device-alias mode changed from basic to enhanced" - ) + messages.append("device-alias mode changed from basic to enhanced") else: - messages.append( - "device-alias mode remains unchanged. current mode is enhanced" - ) + messages.append("device-alias mode remains unchanged. current mode is enhanced") if commands: if distribute: commands.append("device-alias commit") - commands = ( - ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] else: if distribute is None and d == "enabled": commands.append("device-alias commit") - commands = ( - ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] cmds = flatten_list(commands) @@ -482,26 +457,18 @@ def main(): ) else: - commands.append( - "device-alias name " + name + " pwwn " + pwwn - ) + commands.append("device-alias name " + name + " pwwn " + pwwn) da_add_list.append(name) if len(da_add_list) != 0 or len(da_remove_list) != 0: commands = ["device-alias database"] + commands if distribute: commands.append("device-alias commit") - commands = ( - ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] else: if distribute is None and d == "enabled": commands.append("device-alias commit") - commands = ( - ["terminal dont-ask"] - + commands - + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] cmds = flatten_list(commands) if cmds: @@ -514,13 +481,11 @@ def main(): load_config(module, cmds) if len(da_remove_list) != 0: messages.append( - "the required device-alias were removed. " - + ",".join(da_remove_list) + "the required device-alias were removed. " + ",".join(da_remove_list) ) if len(da_add_list) != 0: messages.append( - "the required device-alias were added. " - + ",".join(da_add_list) + "the required device-alias were added. " + ",".join(da_add_list) ) # Step 5: Process rename @@ -539,9 +504,7 @@ def main(): + " with this one", ) if shDADatabaseObj.isNameInDaDatabase(oldname): - commands.append( - "device-alias rename " + oldname + " " + newname - ) + commands.append("device-alias rename " + oldname + " " + newname) else: module.fail_json( changed=False, @@ -554,17 +517,11 @@ def main(): commands = ["device-alias database"] + commands if distribute: commands.append("device-alias commit") - commands = ( - ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] else: if distribute is None and d == "enabled": commands.append("device-alias commit") - commands = ( - ["terminal dont-ask"] - + commands - + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] cmds = flatten_list(commands) if cmds: commands_to_execute = commands_to_execute + cmds diff --git a/plugins/modules/storage/nxos_vsan.py b/plugins/modules/storage/nxos_vsan.py index 2e7cc73d0..468503c53 100644 --- a/plugins/modules/storage/nxos_vsan.py +++ b/plugins/modules/storage/nxos_vsan.py @@ -85,12 +85,15 @@ - no terminal dont-ask """ +import re + from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, run_commands, ) -import re + __metaclass__ = type @@ -195,13 +198,9 @@ def main(): interface=dict(type="list", elements="str"), ) - argument_spec = dict( - vsan=dict(type="list", elements="dict", options=vsan_element_spec) - ) + argument_spec = dict(vsan=dict(type="list", elements="dict", options=vsan_element_spec)) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() messages = list() commands_executed = list() @@ -222,8 +221,7 @@ def main(): if int(vsanid) < 1 or int(vsanid) >= 4095: module.fail_json( - msg=vsanid - + " - This is an invalid vsan. Supported vsan range is 1-4094" + msg=vsanid + " - This is an invalid vsan. Supported vsan range is 1-4094" ) if vsanid in dictSwVsanObjs.keys(): @@ -240,10 +238,7 @@ def main(): if vsanremove: # Negative case: if vsanid == "4079" or vsanid == "4094": - messages.append( - str(vsanid) - + " is a reserved vsan, hence cannot be removed" - ) + messages.append(str(vsanid) + " is a reserved vsan, hence cannot be removed") continue if vsanid == sw_vsanid: commands.append("no vsan " + str(vsanid)) @@ -259,8 +254,7 @@ def main(): # Negative case: if vsanid == "4079" or vsanid == "4094": messages.append( - str(vsanid) - + " is a reserved vsan, and always present on the switch" + str(vsanid) + " is a reserved vsan, and always present on the switch" ) else: if vsanid == sw_vsanid: @@ -276,9 +270,7 @@ def main(): if vsanname is not None: # Negative case: if vsanid == "4079" or vsanid == "4094": - messages.append( - str(vsanid) + " is a reserved vsan, and cannot be renamed" - ) + messages.append(str(vsanid) + " is a reserved vsan, and cannot be renamed") else: if vsanname == sw_vsanname: messages.append( @@ -289,23 +281,13 @@ def main(): + " Hence there is nothing to configure" ) else: - commands.append( - "vsan " + str(vsanid) + " name " + vsanname - ) - messages.append( - "setting vsan name to " - + vsanname - + " for vsan " - + str(vsanid) - ) + commands.append("vsan " + str(vsanid) + " name " + vsanname) + messages.append("setting vsan name to " + vsanname + " for vsan " + str(vsanid)) if vsansuspend: # Negative case: if vsanid == "4079" or vsanid == "4094": - messages.append( - str(vsanid) - + " is a reserved vsan, and cannot be suspended" - ) + messages.append(str(vsanid) + " is a reserved vsan, and cannot be suspended") else: if sw_vsanstate == "suspended": messages.append( @@ -340,26 +322,13 @@ def main(): + " interface list" ) else: - commands.append( - "vsan " - + str(vsanid) - + " interface " - + each_interface_name - ) + commands.append("vsan " + str(vsanid) + " interface " + each_interface_name) messages.append( - "adding interface " - + each_interface_name - + " to vsan " - + str(vsanid) + "adding interface " + each_interface_name + " to vsan " + str(vsanid) ) if len(commands) != 0: - commands = ( - ["terminal dont-ask"] - + ["vsan database"] - + commands - + ["no terminal dont-ask"] - ) + commands = ["terminal dont-ask"] + ["vsan database"] + commands + ["no terminal dont-ask"] cmds = flatten_list(commands) commands_executed = cmds diff --git a/plugins/modules/storage/nxos_zone_zoneset.py b/plugins/modules/storage/nxos_zone_zoneset.py index 048e9658a..007d14b6c 100644 --- a/plugins/modules/storage/nxos_zone_zoneset.py +++ b/plugins/modules/storage/nxos_zone_zoneset.py @@ -213,9 +213,11 @@ """ -import re import json +import re + from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, run_commands, @@ -235,9 +237,7 @@ def __init__(self, module, vsan): self.parseCmdOutput() def execute_show_zoneset_active_cmd(self): - command = ( - "show zoneset active vsan " + str(self.vsan) + " | grep zoneset" - ) + command = "show zoneset active vsan " + str(self.vsan) + " | grep zoneset" output = execute_show_command(command, self.module)[0] return output @@ -460,9 +460,7 @@ def main(): zoneset_spec = dict( name=dict(type="str", required=True), - members=dict( - type="list", elements="dict", options=zoneset_member_spec - ), + members=dict(type="list", elements="dict", options=zoneset_member_spec), remove=dict(type="bool", default=False), action=dict(type="str", choices=["activate", "deactivate"]), ) @@ -477,14 +475,10 @@ def main(): ) argument_spec = dict( - zone_zoneset_details=dict( - type="list", elements="dict", options=zonedetails_spec - ) + zone_zoneset_details=dict(type="list", elements="dict", options=zonedetails_spec) ) - module = AnsibleModule( - argument_spec=argument_spec, supports_check_mode=True - ) + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() messages = list() @@ -514,9 +508,7 @@ def main(): if shZoneStatusObj.isVsanAbsent(): module.fail_json( - msg="Vsan " - + str(vsan) - + " is not present in the switch. Hence cannot procced." + msg="Vsan " + str(vsan) + " is not present in the switch. Hence cannot procced." ) if shZoneStatusObj.isLocked(): @@ -530,17 +522,13 @@ def main(): if op_default_zone is not None: if op_default_zone != sw_default_zone: if op_default_zone == "permit": - commands_executed.append( - "zone default-zone permit vsan " + str(vsan) - ) + commands_executed.append("zone default-zone permit vsan " + str(vsan)) messages.append( "default zone configuration changed from deny to permit for vsan " + str(vsan) ) else: - commands_executed.append( - "no zone default-zone permit vsan " + str(vsan) - ) + commands_executed.append("no zone default-zone permit vsan " + str(vsan)) messages.append( "default zone configuration changed from permit to deny for vsan " + str(vsan) @@ -557,17 +545,13 @@ def main(): if op_mode is not None: if op_mode != sw_mode: if op_mode == "enhanced": - commands_executed.append( - "zone mode enhanced vsan " + str(vsan) - ) + commands_executed.append("zone mode enhanced vsan " + str(vsan)) messages.append( "zone mode configuration changed from basic to enhanced for vsan " + str(vsan) ) else: - commands_executed.append( - "no zone mode enhanced vsan " + str(vsan) - ) + commands_executed.append("no zone mode enhanced vsan " + str(vsan)) messages.append( "zone mode configuration changed from enhanced to basic for vsan " + str(vsan) @@ -584,19 +568,11 @@ def main(): if op_smart_zoning is not None: if op_smart_zoning != sw_smart_zoning_bool: if op_smart_zoning: - commands_executed.append( - "zone smart-zoning enable vsan " + str(vsan) - ) - messages.append( - "smart-zoning enabled for vsan " + str(vsan) - ) + commands_executed.append("zone smart-zoning enable vsan " + str(vsan)) + messages.append("smart-zoning enabled for vsan " + str(vsan)) else: - commands_executed.append( - "no zone smart-zoning enable vsan " + str(vsan) - ) - messages.append( - "smart-zoning disabled for vsan " + str(vsan) - ) + commands_executed.append("no zone smart-zoning enable vsan " + str(vsan)) + messages.append("smart-zoning disabled for vsan " + str(vsan)) else: messages.append( "smart-zoning is already set to " @@ -616,15 +592,8 @@ def main(): removeflag = eachzone["remove"] if removeflag: if shZoneObj.isZonePresent(zname): - messages.append( - "zone '" - + zname - + "' is removed from vsan " - + str(vsan) - ) - commands_executed.append( - "no zone name " + zname + " vsan " + str(vsan) - ) + messages.append("zone '" + zname + "' is removed from vsan " + str(vsan)) + commands_executed.append("no zone name " + zname + " vsan " + str(vsan)) else: messages.append( "zone '" @@ -637,46 +606,25 @@ def main(): if zmembers is None: if shZoneObj.isZonePresent(zname): messages.append( - "zone '" - + zname - + "' is already present in vsan " - + str(vsan) + "zone '" + zname + "' is already present in vsan " + str(vsan) ) else: - commands_executed.append( - "zone name " + zname + " vsan " + str(vsan) - ) - messages.append( - "zone '" - + zname - + "' is created in vsan " - + str(vsan) - ) + commands_executed.append("zone name " + zname + " vsan " + str(vsan)) + messages.append("zone '" + zname + "' is created in vsan " + str(vsan)) else: cmdmemlist = [] for eachmem in zmembers: - memtype = getMemType( - supported_choices, eachmem.keys() - ) - cmd = ( - memtype.replace("_", "-") - + " " - + eachmem[memtype] - ) + memtype = getMemType(supported_choices, eachmem.keys()) + cmd = memtype.replace("_", "-") + " " + eachmem[memtype] if op_smart_zoning or sw_smart_zoning_bool: if eachmem["devtype"] is not None: cmd = cmd + " " + eachmem["devtype"] if eachmem["remove"]: if shZoneObj.isZonePresent(zname): - if shZoneObj.isZoneMemberPresent( - zname, cmd - ): + if shZoneObj.isZoneMemberPresent(zname, cmd): cmd = "no member " + cmd cmdmemlist.append(cmd) - if ( - op_smart_zoning - and eachmem["devtype"] is not None - ): + if op_smart_zoning and eachmem["devtype"] is not None: messages.append( "removing zone member '" + eachmem[memtype] @@ -697,10 +645,7 @@ def main(): + str(vsan) ) else: - if ( - op_smart_zoning - and eachmem["devtype"] is not None - ): + if op_smart_zoning and eachmem["devtype"] is not None: messages.append( "zone member '" + eachmem[memtype] @@ -733,10 +678,7 @@ def main(): else: if shZoneObj.isZoneMemberPresent(zname, cmd): - if ( - op_smart_zoning - and eachmem["devtype"] is not None - ): + if op_smart_zoning and eachmem["devtype"] is not None: messages.append( "zone member '" + eachmem[memtype] @@ -761,10 +703,7 @@ def main(): else: cmd = "member " + cmd cmdmemlist.append(cmd) - if ( - op_smart_zoning - and eachmem["devtype"] is not None - ): + if op_smart_zoning and eachmem["devtype"] is not None: messages.append( "adding zone member '" + eachmem[memtype] @@ -785,9 +724,7 @@ def main(): + str(vsan) ) if len(cmdmemlist) != 0: - commands_executed.append( - "zone name " + zname + " vsan " + str(vsan) - ) + commands_executed.append("zone name " + zname + " vsan " + str(vsan)) commands_executed = commands_executed + cmdmemlist # Process zoneset member options @@ -804,16 +741,10 @@ def main(): if removeflag: if shZonesetObj.isZonesetPresent(zsetname): messages.append( - "zoneset '" - + zsetname - + "' is removed from vsan " - + str(vsan) + "zoneset '" + zsetname + "' is removed from vsan " + str(vsan) ) commands_executed.append( - "no zoneset name " - + zsetname - + " vsan " - + str(vsan) + "no zoneset name " + zsetname + " vsan " + str(vsan) ) else: messages.append( @@ -830,9 +761,7 @@ def main(): zsetmem_name = eachzsmem["name"] zsetmem_removeflag = eachzsmem["remove"] if zsetmem_removeflag: - if shZonesetObj.isZonePresentInZoneset( - zsetname, zsetmem_name - ): + if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): cmd = "no member " + zsetmem_name cmdmemlist.append(cmd) messages.append( @@ -854,9 +783,7 @@ def main(): + " ,hence there is nothing to remove" ) else: - if shZonesetObj.isZonePresentInZoneset( - zsetname, zsetmem_name - ): + if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): messages.append( "zoneset member '" + zsetmem_name @@ -879,48 +806,30 @@ def main(): ) if len(cmdmemlist) != 0: commands_executed.append( - "zoneset name " - + zsetname - + " vsan " - + str(vsan) + "zoneset name " + zsetname + " vsan " + str(vsan) ) commands_executed = commands_executed + cmdmemlist else: if shZonesetObj.isZonesetPresent(zsetname): messages.append( - "zoneset '" - + zsetname - + "' is already present in vsan " - + str(vsan) + "zoneset '" + zsetname + "' is already present in vsan " + str(vsan) ) else: commands_executed.append( - "zoneset name " - + zsetname - + " vsan " - + str(vsan) + "zoneset name " + zsetname + " vsan " + str(vsan) ) messages.append( - "zoneset '" - + zsetname - + "' is created in vsan " - + str(vsan) + "zoneset '" + zsetname + "' is created in vsan " + str(vsan) ) # Process zoneset activate options if actionflag == "deactivate": if shZonesetActiveObj.isZonesetActive(zsetname): messages.append( - "deactivating zoneset '" - + zsetname - + "' in vsan " - + str(vsan) + "deactivating zoneset '" + zsetname + "' in vsan " + str(vsan) ) dactcmd.append( - "no zoneset activate name " - + zsetname - + " vsan " - + str(vsan) + "no zoneset activate name " + zsetname + " vsan " + str(vsan) ) else: messages.append( @@ -933,17 +842,9 @@ def main(): elif actionflag == "activate": if commands_executed: messages.append( - "activating zoneset '" - + zsetname - + "' in vsan " - + str(vsan) - ) - actcmd.append( - "zoneset activate name " - + zsetname - + " vsan " - + str(vsan) + "activating zoneset '" + zsetname + "' in vsan " + str(vsan) ) + actcmd.append("zoneset activate name " + zsetname + " vsan " + str(vsan)) else: messages.append( "no changes to existing zoneset '" @@ -962,11 +863,7 @@ def main(): commands_executed.append("zone commit vsan " + str(vsan)) if commands_executed: - commands_executed = ( - ["terminal dont-ask"] - + commands_executed - + ["no terminal dont-ask"] - ) + commands_executed = ["terminal dont-ask"] + commands_executed + ["no terminal dont-ask"] cmds = flatten_list(commands_executed) if cmds: diff --git a/plugins/netconf/nxos.py b/plugins/netconf/nxos.py index 9df55f49d..fcbee7952 100644 --- a/plugins/netconf/nxos.py +++ b/plugins/netconf/nxos.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -38,9 +39,7 @@ """ from ansible.plugins.netconf import NetconfBase -from ansible_collections.ansible.netcommon.plugins.plugin_utils.netconf_base import ( - NetconfBase, -) +from ansible_collections.ansible.netcommon.plugins.plugin_utils.netconf_base import NetconfBase class Netconf(NetconfBase): diff --git a/plugins/terminal/nxos.py b/plugins/terminal/nxos.py index dfcb7608e..94e816a2c 100644 --- a/plugins/terminal/nxos.py +++ b/plugins/terminal/nxos.py @@ -18,16 +18,15 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type -import re import json +import re from ansible.errors import AnsibleConnectionFailure from ansible.module_utils._text import to_bytes, to_text -from ansible_collections.ansible.netcommon.plugins.plugin_utils.terminal_base import ( - TerminalBase, -) +from ansible_collections.ansible.netcommon.plugins.plugin_utils.terminal_base import TerminalBase class TerminalModule(TerminalBase): @@ -58,9 +57,7 @@ class TerminalModule(TerminalBase): rb"[B|b]aud rate of console should be.* (\d*) to increase [a-z]* level", re.I, ), - re.compile( - rb"cannot apply non-existing acl policy to interface", re.I - ), + re.compile(rb"cannot apply non-existing acl policy to interface", re.I), re.compile(rb"Duplicate sequence number", re.I), re.compile( rb"Cannot apply ACL to an interface that is a port-channel member", @@ -90,21 +87,16 @@ def on_become(self, passwd=None): cmd = {"command": "enable"} if passwd: - cmd["prompt"] = to_text( - r"(?i)[\r\n]?Password: $", errors="surrogate_or_strict" - ) + cmd["prompt"] = to_text(r"(?i)[\r\n]?Password: $", errors="surrogate_or_strict") cmd["answer"] = passwd cmd["prompt_retry_check"] = True try: - self._exec_cli_command( - to_bytes(json.dumps(cmd), errors="surrogate_or_strict") - ) + self._exec_cli_command(to_bytes(json.dumps(cmd), errors="surrogate_or_strict")) prompt = self._get_prompt() if prompt is None or not prompt.strip().endswith(b"enable#"): raise AnsibleConnectionFailure( - "failed to elevate privilege to enable mode still at prompt [%s]" - % prompt + "failed to elevate privilege to enable mode still at prompt [%s]" % prompt ) except AnsibleConnectionFailure as e: prompt = self._get_prompt() diff --git a/pyproject.toml b/pyproject.toml index 4b00287ea..fa4225f3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.black] -line-length = 79 +line-length = 100 [tool.pytest.ini_options] addopts = ["-vvv", "-n", "2", "--log-level", "WARNING", "--color", "yes"] diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py index bfc8adfbe..e898a081e 100644 --- a/tests/unit/compat/builtins.py +++ b/tests/unit/compat/builtins.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type # diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py index b45d6b5c6..50583cd6f 100644 --- a/tests/unit/compat/mock.py +++ b/tests/unit/compat/mock.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -25,6 +26,7 @@ """ import sys + # Python 2.7 # Note: Could use the pypi mock library on python3.x as well as python2.x. It @@ -102,9 +104,7 @@ def _readline_side_effect(): if file_spec is None: import _io - file_spec = list( - set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))) - ) + file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) if mock is None: mock = MagicMock(name="open", spec=open) diff --git a/tests/unit/compat/unittest.py b/tests/unit/compat/unittest.py index df3379b82..df4266ec9 100644 --- a/tests/unit/compat/unittest.py +++ b/tests/unit/compat/unittest.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -26,6 +27,7 @@ import sys + # Allow wildcard import because we really do want to import all of # unittests's symbols into this compat shim # pylint: disable=wildcard-import,unused-wildcard-import diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index c21188ee3..2b5eb36a1 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -18,13 +18,14 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type import os from ansible.errors import AnsibleParserError -from ansible.parsing.dataloader import DataLoader from ansible.module_utils._text import to_bytes, to_text +from ansible.parsing.dataloader import DataLoader class DictDataLoader(DataLoader): diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py index 8db8e0418..d15430fde 100644 --- a/tests/unit/mock/path.py +++ b/tests/unit/mock/path.py @@ -1,10 +1,10 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock from ansible.utils.path import unfrackpath +from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock + -mock_unfrackpath_noop = MagicMock( - spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x -) +mock_unfrackpath_noop = MagicMock(spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x) diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py index 59fc1978a..e14ad0ece 100644 --- a/tests/unit/mock/procenv.py +++ b/tests/unit/mock/procenv.py @@ -19,16 +19,19 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type -import sys import json +import sys from contextlib import contextmanager from io import BytesIO, StringIO -from ansible_collections.cisco.nxos.tests.unit.compat import unittest -from ansible.module_utils.six import PY3 + from ansible.module_utils._text import to_bytes +from ansible.module_utils.six import PY3 + +from ansible_collections.cisco.nxos.tests.unit.compat import unittest @contextmanager diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py index b34ae1340..6006ba965 100644 --- a/tests/unit/mock/vault_helper.py +++ b/tests/unit/mock/vault_helper.py @@ -14,10 +14,10 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.module_utils._text import to_bytes - from ansible.parsing.vault import VaultSecret @@ -37,6 +37,4 @@ def __init__(self, text, encoding=None, errors=None, _bytes=None): @property def bytes(self): """The text encoded with encoding, unless we specifically set _bytes.""" - return self._bytes or to_bytes( - self.text, encoding=self.encoding, errors=self.errors - ) + return self._bytes or to_bytes(self.text, encoding=self.encoding, errors=self.errors) diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py index 5df30aaed..e3be12a42 100644 --- a/tests/unit/mock/yaml_helper.py +++ b/tests/unit/mock/yaml_helper.py @@ -1,12 +1,14 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import io + import yaml from ansible.module_utils.six import PY3 -from ansible.parsing.yaml.loader import AnsibleLoader from ansible.parsing.yaml.dumper import AnsibleDumper +from ansible.parsing.yaml.loader import AnsibleLoader class YamlTestUtils(object): @@ -44,9 +46,7 @@ def _dump_load_cycle(self, obj): obj_2 = loader.get_data() # dump the gen 2 objects directory to strings - string_from_object_dump_2 = self._dump_string( - obj_2, dumper=AnsibleDumper - ) + string_from_object_dump_2 = self._dump_string(obj_2, dumper=AnsibleDumper) # The gen 1 and gen 2 yaml strings self.assertEqual(string_from_object_dump, string_from_object_dump_2) @@ -58,9 +58,7 @@ def _dump_load_cycle(self, obj): loader_3 = self._loader(stream_3) obj_3 = loader_3.get_data() - string_from_object_dump_3 = self._dump_string( - obj_3, dumper=AnsibleDumper - ) + string_from_object_dump_3 = self._dump_string(obj_3, dumper=AnsibleDumper) self.assertEqual(obj, obj_3) # should be transitive, but... @@ -92,12 +90,8 @@ def _old_dump_load_cycle(self, obj): stream_obj_from_string = io.StringIO() if PY3: - yaml.dump( - obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper - ) - yaml.dump( - obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper - ) + yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper) + yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper) else: yaml.dump( obj_from_stream, @@ -119,12 +113,8 @@ def _old_dump_load_cycle(self, obj): stream_obj_from_string.seek(0) if PY3: - yaml_string_obj_from_stream = yaml.dump( - obj_from_stream, Dumper=AnsibleDumper - ) - yaml_string_obj_from_string = yaml.dump( - obj_from_string, Dumper=AnsibleDumper - ) + yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper) + yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper) else: yaml_string_obj_from_stream = yaml.dump( obj_from_stream, Dumper=AnsibleDumper, encoding=None @@ -134,11 +124,7 @@ def _old_dump_load_cycle(self, obj): ) assert yaml_string == yaml_string_obj_from_stream - assert ( - yaml_string - == yaml_string_obj_from_stream - == yaml_string_obj_from_string - ) + assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string assert ( yaml_string == yaml_string_obj_from_stream diff --git a/tests/unit/modules/conftest.py b/tests/unit/modules/conftest.py index e19a1e04c..41465c300 100644 --- a/tests/unit/modules/conftest.py +++ b/tests/unit/modules/conftest.py @@ -2,15 +2,16 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type import json import pytest -from ansible.module_utils.six import string_types from ansible.module_utils._text import to_bytes from ansible.module_utils.common._collections_compat import MutableMapping +from ansible.module_utils.six import string_types @pytest.fixture @@ -21,20 +22,11 @@ def patch_ansible_module(request, mocker): if "ANSIBLE_MODULE_ARGS" not in request.param: request.param = {"ANSIBLE_MODULE_ARGS": request.param} if "_ansible_remote_tmp" not in request.param["ANSIBLE_MODULE_ARGS"]: - request.param["ANSIBLE_MODULE_ARGS"][ - "_ansible_remote_tmp" - ] = "/tmp" - if ( - "_ansible_keep_remote_files" - not in request.param["ANSIBLE_MODULE_ARGS"] - ): - request.param["ANSIBLE_MODULE_ARGS"][ - "_ansible_keep_remote_files" - ] = False + request.param["ANSIBLE_MODULE_ARGS"]["_ansible_remote_tmp"] = "/tmp" + if "_ansible_keep_remote_files" not in request.param["ANSIBLE_MODULE_ARGS"]: + request.param["ANSIBLE_MODULE_ARGS"]["_ansible_keep_remote_files"] = False args = json.dumps(request.param) else: - raise Exception( - "Malformed data to the patch_ansible_module pytest fixture" - ) + raise Exception("Malformed data to the patch_ansible_module pytest fixture") mocker.patch("ansible.module_utils.basic._ANSIBLE_ARGS", to_bytes(args)) diff --git a/tests/unit/modules/network/nxos/nxos_module.py b/tests/unit/modules/network/nxos/nxos_module.py index 0c7b90c15..851cb9545 100644 --- a/tests/unit/modules/network/nxos/nxos_module.py +++ b/tests/unit/modules/network/nxos/nxos_module.py @@ -18,10 +18,11 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type -import os import json +import os from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( AnsibleExitJson, @@ -86,15 +87,11 @@ def execute_module_devices( retvals = {} for model in models: - retvals[model] = self.execute_module( - failed, changed, commands, sort, device=model - ) + retvals[model] = self.execute_module(failed, changed, commands, sort, device=model) return retvals - def execute_module( - self, failed=False, changed=False, commands=None, sort=True, device="" - ): + def execute_module(self, failed=False, changed=False, commands=None, sort=True, device=""): self.load_fixtures(commands, device=device) @@ -112,9 +109,7 @@ def execute_module( result["commands"], ) else: - self.assertEqual( - commands, result["commands"], result["commands"] - ) + self.assertEqual(commands, result["commands"], result["commands"]) return result diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py b/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py index 227221fa2..820d4055a 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py @@ -4,21 +4,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import pytest -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules.storage import ( - nxos_devicealias, -) +from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_devicealias from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_devicealias import ( - showDeviceAliasStatus, showDeviceAliasDatabase, + showDeviceAliasStatus, ) +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 @@ -33,9 +30,7 @@ def setUp(self): self.mock_run_commands = patch(module_path + "run_commands") self.run_commands = self.mock_run_commands.start() - self.mock_execute_show_cmd = patch( - module_path + "showDeviceAliasStatus.execute_show_cmd" - ) + self.mock_execute_show_cmd = patch(module_path + "showDeviceAliasStatus.execute_show_cmd") self.execute_show_cmd = self.mock_execute_show_cmd.start() self.mock_execute_show_cmd_1 = patch( @@ -60,9 +55,7 @@ def test_da_mode_1(self): # Playbook mode is basic # Switch has mode as enahnced set_module_args(dict(mode="basic"), True) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -78,9 +71,7 @@ def test_da_mode_2(self): # Playbook mode is enhanced # Switch has mode as enahnced set_module_args(dict(mode="enhanced"), True) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -88,9 +79,7 @@ def test_da_distribute_1(self): # Playbook mode is enhanced , distrbute = True # Switch has mode as enahnced, distrbute = True set_module_args(dict(distribute=True, mode="enhanced"), True) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -98,9 +87,7 @@ def test_da_distribute_2(self): # Playbook mode is enhanced , distrbute = False # Switch has mode as enhanced, distrbute = True set_module_args(dict(distribute=False, mode="enhanced"), True) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") result = self.execute_module(changed=True) self.assertEqual(result["commands"], ["no device-alias distribute"]) @@ -108,9 +95,7 @@ def test_da_distribute_3(self): # Playbook mode is basic , distrbute = False # Switch has mode as enahnced, distrbute = True set_module_args(dict(distribute=False, mode="basic"), True) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -131,12 +116,8 @@ def test_da_add_1(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -161,12 +142,8 @@ def test_da_add_2(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -181,12 +158,8 @@ def test_da_add_3(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False, failed=True) def test_da_add_4(self): @@ -200,12 +173,8 @@ def test_da_add_4(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False, failed=True) def test_da_remove_1(self): @@ -225,12 +194,8 @@ def test_da_remove_1(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -260,12 +225,8 @@ def test_da_remove_2(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -285,9 +246,7 @@ def test_da_lock(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatuslock.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatuslock.cfg") self.execute_module(failed=True) def test_da_paramete_not_supported(self): @@ -307,12 +266,8 @@ def test_da_paramete_not_supported(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] @@ -329,12 +284,8 @@ def test_da_name_parameter_missing(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] @@ -352,12 +303,8 @@ def test_da_rename_1(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -382,12 +329,8 @@ def test_da_rename_2(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False, failed=True) self.assertEqual(result["commands"], []) @@ -396,9 +339,7 @@ def test_da_mansi(self): self.execute_show_cmd.return_value = load_fixture( "nxos_devicealias", "shdastatus_mansi.cfg" ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -422,12 +363,8 @@ def test_da_add_bad(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False, failed=True) assert "it must start with a letter" in str(result["msg"]) @@ -443,12 +380,8 @@ def test_da_add_bad_1(self): ), True, ) - self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus.cfg" - ) - self.execute_show_cmd_1.return_value = load_fixture( - "nxos_devicealias", "shdadatabse.cfg" - ) + self.execute_show_cmd.return_value = load_fixture("nxos_devicealias", "shdastatus.cfg") + self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=False, failed=True) assert "and can only contain these characters" in str(result["msg"]) diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py b/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py index 691b05bc7..aa889df55 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py @@ -4,18 +4,15 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import pytest -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_vsan -from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_vsan import ( - GetVsanInfoFromSwitch, -) +from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_vsan import GetVsanInfoFromSwitch +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 @@ -25,9 +22,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.storage.nxos_vsan." self.mock_run_commands = patch(module_path + "run_commands") self.run_commands = self.mock_run_commands.start() @@ -40,9 +35,7 @@ def setUp(self): self.mock_execute_show_vsanmemcmd = patch( module_path + "GetVsanInfoFromSwitch.execute_show_vsan_mem_cmd" ) - self.execute_show_vsanmem_cmd = ( - self.mock_execute_show_vsanmemcmd.start() - ) + self.execute_show_vsanmem_cmd = self.mock_execute_show_vsanmemcmd.start() self.mock_load_config = patch(module_path + "load_config") self.load_config = self.mock_load_config.start() @@ -78,26 +71,16 @@ def test_vsan_add_remove_but_present_in_switch(self): ] } set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) def test_vsan_remove(self): - margs = { - "vsan": [{"id": 922, "remove": True}, {"id": 923, "remove": True}] - } + margs = {"vsan": [{"id": 922, "remove": True}, {"id": 923, "remove": True}]} set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -123,12 +106,8 @@ def test_vsan_add(self): ] } set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -164,12 +143,8 @@ def test_vsan_suspend(self): ] } set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -187,16 +162,10 @@ def test_vsan_suspend(self): ) def test_vsan_invalid_vsan(self): - margs = { - "vsan": [{"id": 4096, "name": "vsan-SAN-925", "suspend": True}] - } + margs = {"vsan": [{"id": 4096, "name": "vsan-SAN-925", "suspend": True}]} set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] @@ -204,16 +173,10 @@ def test_vsan_invalid_vsan(self): assert testdata["failed"] def test_vsan_change_reserved_vsan(self): - margs = { - "vsan": [{"id": 4094, "name": "vsan-SAN-925", "suspend": True}] - } + margs = {"vsan": [{"id": 4094, "name": "vsan-SAN-925", "suspend": True}]} set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=False) assert "reserved vsan" in str(result["messages"]) self.assertEqual(result["commands"], []) @@ -228,12 +191,8 @@ def test_vsan_add_int_existing_vsan(self): ] } set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -249,12 +208,8 @@ def test_vsan_add_int_existing_vsan(self): def test_vsan_remove_non_existing_vsan(self): margs = {"vsan": [{"id": 1111, "remove": True}]} set_module_args(margs, True) - self.execute_show_vsan_cmd.return_value = load_fixture( - "nxos_vsan", "shvsan.cfg" - ) - self.execute_show_vsanmem_cmd.return_value = load_fixture( - "nxos_vsan", "shvsanmem.cfg" - ) + self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") + self.execute_show_vsanmem_cmd.return_value = load_fixture("nxos_vsan", "shvsanmem.cfg") result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) assert "no vsan" in str(result["messages"]) diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py b/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py index c86f7259b..c62477445 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py @@ -5,24 +5,20 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import pytest -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, - AnsibleExitJson, -) -from ansible_collections.cisco.nxos.plugins.modules.storage import ( - nxos_zone_zoneset, -) +from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_zone_zoneset from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_zone_zoneset import ( - ShowZonesetActive, - ShowZoneset, ShowZone, + ShowZoneset, + ShowZonesetActive, ShowZoneStatus, ) +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch +from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleExitJson, AnsibleFailJson from ..nxos_module import TestNxosModule, load_fixture, set_module_args @@ -40,28 +36,20 @@ def setUp(self): self.mock_execute_show_cmd_zoneset_active = patch( module_path + "ShowZonesetActive.execute_show_zoneset_active_cmd" ) - self.execute_show_cmd_zoneset_active = ( - self.mock_execute_show_cmd_zoneset_active.start() - ) + self.execute_show_cmd_zoneset_active = self.mock_execute_show_cmd_zoneset_active.start() self.mock_execute_show_cmd_zoneset = patch( module_path + "ShowZoneset.execute_show_zoneset_cmd" ) - self.execute_show_cmd_zoneset = ( - self.mock_execute_show_cmd_zoneset.start() - ) + 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( module_path + "ShowZoneStatus.execute_show_zone_status_cmd" ) - self.execute_show_cmd_zone_status = ( - self.mock_execute_show_cmd_zone_status.start() - ) + self.execute_show_cmd_zone_status = self.mock_execute_show_cmd_zone_status.start() self.mock_load_config = patch(module_path + "load_config") self.load_config = self.mock_load_config.start() @@ -226,18 +214,12 @@ def test_zone_smart_zone_1(self): # 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"], @@ -250,34 +232,24 @@ def test_zone_add_rem(self): ) 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"]) self.assertEqual(result["commands"], []) def test_zone_add_rem_2(self): - a = dict( - zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneBNew")])] - ) + a = dict(zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneBNew")])]) 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"], @@ -290,16 +262,12 @@ def test_zone_add_rem_2(self): ) def test_zone_add_rem_3(self): - a = dict( - zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneB")])] - ) + a = dict(zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneB")])]) 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 'zoneB' is already present in vsan 923" assert m in str(result["messages"]) @@ -321,9 +289,7 @@ def test_zonemem_add_rem(self): 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"], @@ -342,17 +308,13 @@ def test_zonemem_add_rem_1(self): 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"], @@ -371,19 +333,13 @@ def test_zonemem_add_rem_2(self): 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"]) @@ -406,9 +362,7 @@ def test_zonemem_add_rem_3(self): 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"], @@ -426,18 +380,12 @@ def test_zonemem_add_rem_3(self): 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"], @@ -452,9 +400,7 @@ def test_zonemem_add_rem_4(self): # 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( @@ -474,11 +420,7 @@ def test_zoneset_add_rem(self): ) 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", "shzonestatus_0.cfg" @@ -497,11 +439,7 @@ def test_zoneset_add_rem_1(self): ) 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", "shzonestatus_0.cfg" @@ -516,11 +454,7 @@ def test_zoneset_add_rem_2(self): def test_zoneset_add_rem_3(self): a = dict( - zone_zoneset_details=[ - dict( - vsan=922, zoneset=[dict(name="zsetname21New", remove=True)] - ) - ] + zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21New", remove=True)])] ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( @@ -539,11 +473,7 @@ def test_zoneset_mem_add_rem(self): mem1 = {"name": "newZoneV100"} a = dict( - zone_zoneset_details=[ - dict( - vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])] - ) - ] + zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])])] ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( @@ -568,11 +498,7 @@ def test_zoneset_mem_add_rem_1(self): mem1 = {"name": "zone21A", "remove": True} a = dict( - zone_zoneset_details=[ - dict( - vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])] - ) - ] + zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])])] ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( @@ -597,11 +523,7 @@ def test_zoneset_mem_add_rem_2(self): mem1 = {"name": "zone21", "remove": True} a = dict( - zone_zoneset_details=[ - dict( - vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])] - ) - ] + zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])])] ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( @@ -618,11 +540,7 @@ def test_zoneset_mem_add_rem_2(self): # 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( @@ -702,17 +620,13 @@ def test_bug_zone_remove(self): 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" ) diff --git a/tests/unit/modules/network/nxos/test_nxos.py b/tests/unit/modules/network/nxos/test_nxos.py index fe465c339..e1b4400ac 100644 --- a/tests/unit/modules/network/nxos/test_nxos.py +++ b/tests/unit/modules/network/nxos/test_nxos.py @@ -18,19 +18,22 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type from os import path + try: from unittest.mock import MagicMock except ImportError: from mock import MagicMock -from ansible_collections.cisco.nxos.tests.unit.compat import unittest -from ansible_collections.cisco.nxos.plugins.cliconf import nxos from ansible.module_utils._text import to_bytes, to_text +from ansible_collections.cisco.nxos.plugins.cliconf import nxos +from ansible_collections.cisco.nxos.tests.unit.compat import unittest + class TestPluginCLIConfNXOS(unittest.TestCase): """Test class for NXOS CLI Conf Methods""" @@ -109,17 +112,13 @@ def test_get_device_info_mds(self): def test_get_command_with_output_nxos(self): """Test _get_command_with_output for nxos""" self._prepare() - cmd = self._cliconf._get_command_with_output( - command="show version", output="json" - ) + cmd = self._cliconf._get_command_with_output(command="show version", output="json") self.assertEqual(cmd, "show version | json") def test_get_command_with_output_mds(self): """Test _get_command_with_output for mds""" self._prepare(platform="mds") - cmd = self._cliconf._get_command_with_output( - command="show version", output="json" - ) + cmd = self._cliconf._get_command_with_output(command="show version", output="json") self.assertEqual(cmd, "show version | json native") diff --git a/tests/unit/modules/network/nxos/test_nxos_acl.py b/tests/unit/modules/network/nxos/test_nxos_acl.py index b548dcb7f..fce0c63aa 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl.py @@ -18,12 +18,14 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type import json -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_acl +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -60,9 +62,7 @@ def load_from_file(*args, **kwargs): command = obj["command"] except ValueError: command = item - filename = "%s.txt" % str(command).split(" | ", 1)[0].replace( - " ", "_" - ) + filename = "%s.txt" % str(command).split(" | ", 1)[0].replace(" ", "_") output.append(load_fixture("nxos_acl", filename)) return output @@ -87,9 +87,7 @@ def test_nxos_acl(self): ) def test_nxos_acl_remove(self): - set_module_args( - dict(name="copp-system-p-acl-bgp", seq=10, state="absent") - ) + set_module_args(dict(name="copp-system-p-acl-bgp", seq=10, state="absent")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -99,6 +97,4 @@ def test_nxos_acl_remove(self): def test_nxos_acl_delete_acl(self): set_module_args(dict(name="copp-system-p-acl-bgp", state="delete_acl")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["no ip access-list copp-system-p-acl-bgp"] - ) + self.assertEqual(result["commands"], ["no ip access-list copp-system-p-acl-bgp"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interface.py b/tests/unit/modules/network/nxos/test_nxos_acl_interface.py index 211e66696..75cb9dd1a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl_interface.py @@ -19,12 +19,14 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type __metacl_interfaceass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_acl_interface +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -60,9 +62,7 @@ def load_from_file(*args, **kwargs): command = item["command"] except ValueError: command = item - filename = "%s.txt" % str(command).split(" | ", 1)[0].replace( - " ", "_" - ) + filename = "%s.txt" % str(command).split(" | ", 1)[0].replace(" ", "_") output.append(load_fixture("nxos_acl_interface", filename)) return output @@ -70,9 +70,7 @@ def load_from_file(*args, **kwargs): self.load_config.return_value = None def test_nxos_acl_interface(self): - set_module_args( - dict(name="ANSIBLE", interface="ethernet1/41", direction="egress") - ) + set_module_args(dict(name="ANSIBLE", interface="ethernet1/41", direction="egress")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py index 99eaf6c1f..cf063f64c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py @@ -5,16 +5,13 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.cisco.nxos.plugins.modules import nxos_acl_interfaces -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - MagicMock, -) -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - set_module_args, -) +from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +from ansible_collections.cisco.nxos.tests.unit.modules.utils import set_module_args + from .nxos_module import TestNxosModule, load_fixture @@ -38,16 +35,12 @@ def setUp(self): 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.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.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.acl_interfaces.acl_interfaces.Acl_interfaces.edit_config" @@ -265,18 +258,14 @@ def test_nxos_acl_interfaces_overridden_idempotent(self): self.execute_module(changed=False, commands=[]) def test_nxos_acl_interfaces_deletedname(self): - set_module_args( - dict(config=[dict(name="Ethernet1/2")], state="deleted") - ) + set_module_args(dict(config=[dict(name="Ethernet1/2")], state="deleted")) commands = ["interface Ethernet1/2", "no ip access-group ACL1v4 out"] self.execute_module(changed=True, commands=commands) def test_nxos_acl_interfaces_deletedafi(self): set_module_args( dict( - config=[ - dict(name="Ethernet1/2", access_groups=[dict(afi="ipv4")]) - ], + config=[dict(name="Ethernet1/2", access_groups=[dict(afi="ipv4")])], state="deleted", ) ) @@ -342,9 +331,7 @@ def test_nxos_acl_interfaces_rendered(self): "ipv6 port traffic-filter ACL2v6 in", ] 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_acl_interfaces_parsed(self): set_module_args( @@ -368,9 +355,7 @@ def test_nxos_acl_interfaces_parsed(self): { "access_groups": [ { - "acls": [ - {"direction": "in", "name": "ACL2v6", "port": True} - ], + "acls": [{"direction": "in", "name": "ACL2v6", "port": True}], "afi": "ipv6", } ], @@ -395,9 +380,7 @@ def test_nxos_acl_interfaces_gathered(self): { "access_groups": [ { - "acls": [ - {"direction": "in", "name": "ACL2v6", "port": True} - ], + "acls": [{"direction": "in", "name": "ACL2v6", "port": True}], "afi": "ipv6", } ], diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index c9b26d722..d04bae051 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -5,18 +5,16 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type +from textwrap import dedent + from ansible_collections.cisco.nxos.plugins.modules import nxos_acls -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - MagicMock, -) -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - set_module_args, -) +from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +from ansible_collections.cisco.nxos.tests.unit.modules.utils import set_module_args + from .nxos_module import TestNxosModule -from textwrap import dedent class TestNxosAclsModule(TestNxosModule): @@ -39,16 +37,12 @@ def setUp(self): 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.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.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.acls.acls.Acls.edit_config" @@ -90,9 +84,7 @@ def test_nxos_acls_merged(self): fragments=True, sequence=20, protocol="tcp", - protocol_options=dict( - tcp=dict(ack=True) - ), + protocol_options=dict(tcp=dict(ack=True)), ), dict( destination=dict( @@ -110,15 +102,11 @@ def test_nxos_acls_merged(self): ), dict( grant="deny", - destination=dict( - prefix="2002:2:2:2::/64" - ), + destination=dict(prefix="2002:2:2:2::/64"), 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)), ), ], ) @@ -207,9 +195,7 @@ def test_nxos_acls_replaced(self): sequence=50, protocol="icmp", protocol_options=dict( - icmp=dict( - administratively_prohibited=True - ) + icmp=dict(administratively_prohibited=True) ), ) ], @@ -297,9 +283,7 @@ def test_nxos_acls_overridden(self): sequence=50, protocol="icmp", protocol_options=dict( - icmp=dict( - administratively_prohibited=True - ) + icmp=dict(administratively_prohibited=True) ), ), dict(remark="Overridden ACL"), @@ -438,9 +422,7 @@ def test_nxos_acls_rendered(self): "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( diff --git a/tests/unit/modules/network/nxos/test_nxos_banner.py b/tests/unit/modules/network/nxos/test_nxos_banner.py index a4784d58b..2d99b6ad5 100644 --- a/tests/unit/modules/network/nxos/test_nxos_banner.py +++ b/tests/unit/modules/network/nxos/test_nxos_banner.py @@ -17,10 +17,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_banner +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py index ad4cd1a10..a0f3835ce 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py @@ -19,21 +19,22 @@ from __future__ import absolute_import, division, print_function -__metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.plugins.modules import nxos_bfd_global -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - NxosCmdRef, -) -from .nxos_module import TestNxosModule, load_fixture, set_module_args +__metaclass__ = type # TBD: These imports / import checks are only needed as a workaround for # shippable, which fails this test due to import yaml & import ordereddict. import pytest + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + NxosCmdRef, nxosCmdRef_import_check, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_bfd_global +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + +from .nxos_module import TestNxosModule, load_fixture, set_module_args + msg = nxosCmdRef_import_check() @@ -209,9 +210,7 @@ def test_bfd_defaults_n7k(self): def test_bfd_existing_n9k(self): module_name = self.module.__name__.rsplit(".", 1)[1] - self.execute_show_command.return_value = load_fixture( - module_name, "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture(module_name, "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -247,9 +246,7 @@ def test_bfd_existing_n9k(self): def test_bfd_idempotence_n9k(self): module_name = self.module.__name__.rsplit(".", 1)[1] - self.execute_show_command.return_value = load_fixture( - module_name, "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture(module_name, "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -270,9 +267,7 @@ def test_bfd_idempotence_n9k(self): def test_bfd_existing_n7k(self): module_name = self.module.__name__.rsplit(".", 1)[1] - self.execute_show_command.return_value = load_fixture( - module_name, "N7K.cfg" - ) + self.execute_show_command.return_value = load_fixture(module_name, "N7K.cfg") self.get_platform_shortname.return_value = "N7K" set_module_args( dict( @@ -312,9 +307,7 @@ def test_bfd_existing_n7k(self): def test_bfd_idempotence_n7k(self): module_name = self.module.__name__.rsplit(".", 1)[1] - self.execute_show_command.return_value = load_fixture( - module_name, "N7K.cfg" - ) + self.execute_show_command.return_value = load_fixture(module_name, "N7K.cfg") self.get_platform_shortname.return_value = "N7K" set_module_args( dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py index 8e5dc2712..b7af5d120 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py @@ -19,19 +19,21 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_bfd_interfaces + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bfd_interfaces.bfd_interfaces import ( Bfd_interfaces, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_bfd_interfaces +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 + ignore_provider_arg = True @@ -50,16 +52,12 @@ def setUp(self): 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.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.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.bfd_interfaces.bfd_interfaces.Bfd_interfaces.edit_config" @@ -106,9 +104,7 @@ def test_1(self): interface Ethernet1/3 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="disable", echo="disable"), @@ -157,9 +153,7 @@ def test_2(self): no bfd echo """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="enable", echo="disable"), @@ -224,9 +218,7 @@ def test_3(self): no bfd echo """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/1")]) # Expected result commands for each 'state' merged = [] @@ -267,12 +259,8 @@ def test_4(self): no bfd """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } - playbook = dict( - config=[dict(name="Ethernet1/1.42", bfd="enable", echo="disable")] - ) + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} + playbook = dict(config=[dict(name="Ethernet1/1.42", bfd="enable", echo="disable")]) # Expected result commands for each 'state' merged = ["interface Ethernet1/1.42", "bfd", "no bfd echo"] deleted = [] @@ -312,9 +300,7 @@ def test_5(self): interface Ethernet1/2 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="disable", echo="disable"), diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp.py b/tests/unit/modules/network/nxos/test_nxos_bgp.py index 71edccf0c..291e51f5e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch 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 @@ -55,9 +57,7 @@ def load_fixtures(self, commands=None, device=""): 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"] - ) + 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")) @@ -74,9 +74,7 @@ def test_nxos_bgp_remove(self): 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"] - ) + 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")) @@ -96,9 +94,7 @@ def test_nxos_bgp_vrf(self): 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"] - ) + 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)) @@ -109,9 +105,7 @@ def test_nxos_bgp_global_param_outside_default(self): ) def test_nxos_bgp_default_value(self): - set_module_args( - dict(asn=65535, graceful_restart_timers_restart="default") - ) + 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"], @@ -141,9 +135,7 @@ def tearDown(self): 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.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): @@ -157,6 +149,4 @@ def test_nxos_bgp_wrong_asn(self): 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"] - ) + self.execute_module(changed=True, commands=["no router bgp 65535.65535"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py index 45ecf350f..1847c5d56 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py @@ -19,19 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent + +from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_address_family from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import ( - nxos_bgp_address_family, -) +from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson from .nxos_module import TestNxosModule, load_fixture, set_module_args + ignore_provider_arg = True @@ -56,9 +55,7 @@ def setUp(self): 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.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_address_family.bgp_address_family.Bgp_address_familyFacts.get_config" @@ -156,9 +153,7 @@ def test_nxos_bgp_additional_paths_replaced(self): dict( afi="ipv4", safi="multicast", - additional_paths=dict( - selection=dict(route_map="rmap1") - ), + additional_paths=dict(selection=dict(route_map="rmap1")), ), dict( vrf="site-1", @@ -237,9 +232,7 @@ def test_nxos_bgp_l2vpn_keys_replaced(self): dict( config=dict( as_number="65563", - address_family=[ - dict(afi="l2vpn", safi="evpn", advertise_pip=True) - ], + address_family=[dict(afi="l2vpn", safi="evpn", advertise_pip=True)], ), state="replaced", ), @@ -360,9 +353,7 @@ def test_nxos_bgp_aggregate_address_merged(self): afi="ipv4", safi="multicast", aggregate_address=[ - dict( - prefix="192.168.1.0/24", summary_only=True - ), + dict(prefix="192.168.1.0/24", summary_only=True), dict( prefix="192.168.2.0/24", advertise_map="rmap1", @@ -493,9 +484,7 @@ def test_nxos_bgp_dampen_igp_metric_merged(self): config=dict( as_number="65563", address_family=[ - dict( - afi="ipv4", safi="multicast", dampen_igp_metric=300 - ), + dict(afi="ipv4", safi="multicast", dampen_igp_metric=300), dict( vrf="site-1", afi="ipv4", @@ -843,9 +832,7 @@ def test_nxos_bgp_default_metric_merged(self): config=dict( as_number="65563", address_family=[ - dict( - afi="ipv4", safi="multicast", default_metric=7200 - ), + dict(afi="ipv4", safi="multicast", default_metric=7200), dict( vrf="site-1", afi="ipv4", @@ -927,17 +914,13 @@ def test_nxos_bgp_distance_merged(self): dict( afi="ipv4", safi="multicast", - distance=dict( - ebgp_routes=25, ibgp_routes=12, local_routes=4 - ), + distance=dict(ebgp_routes=25, ibgp_routes=12, local_routes=4), ), dict( vrf="site-1", afi="ipv4", safi="unicast", - distance=dict( - ebgp_routes=20, ibgp_routes=18, local_routes=3 - ), + distance=dict(ebgp_routes=20, ibgp_routes=18, local_routes=3), ), ], ), @@ -980,9 +963,7 @@ def test_nxos_bgp_distance_replaced(self): vrf="site-1", afi="ipv4", safi="unicast", - distance=dict( - ebgp_routes=20, ibgp_routes=18, local_routes=2 - ), + distance=dict(ebgp_routes=20, ibgp_routes=18, local_routes=2), ), ], ), @@ -1182,9 +1163,7 @@ def test_nxos_bgp_inject_map_replaced(self): dict( afi="ipv4", safi="multicast", - inject_map=[ - dict(route_map="rmap1", exist_map="rmap3") - ], + inject_map=[dict(route_map="rmap1", exist_map="rmap3")], ), dict( vrf="site-1", @@ -1233,9 +1212,7 @@ def test_nxos_bgp_maximum_paths_merged(self): dict( afi="ipv4", safi="multicast", - maximum_paths=dict( - parallel_paths=15, ibgp=dict(parallel_paths=64) - ), + maximum_paths=dict(parallel_paths=15, ibgp=dict(parallel_paths=64)), ), dict( vrf="site-1", @@ -1298,9 +1275,7 @@ def test_nxos_bgp_maximum_paths_replaced(self): dict( afi="ipv4", safi="multicast", - maximum_paths=dict( - parallel_paths=15, ibgp=dict(parallel_paths=64) - ), + maximum_paths=dict(parallel_paths=15, ibgp=dict(parallel_paths=64)), ), dict( vrf="site-1", @@ -1345,13 +1320,9 @@ def test_nxos_bgp_network_merged(self): afi="ipv4", safi="multicast", networks=[ - dict( - prefix="192.168.1.0/24", route_map="rmap2" - ), + dict(prefix="192.168.1.0/24", route_map="rmap2"), dict(prefix="192.168.2.0/24"), - dict( - prefix="192.168.3.0/24", route_map="rmap3" - ), + dict(prefix="192.168.3.0/24", route_map="rmap3"), ], ), dict( @@ -1407,19 +1378,13 @@ def test_nxos_bgp_network_replaced(self): dict( afi="ipv4", safi="multicast", - networks=[ - dict( - prefix="192.168.3.0/24", route_map="rmap4" - ) - ], + networks=[dict(prefix="192.168.3.0/24", route_map="rmap4")], ), dict( vrf="site-1", afi="ipv4", safi="unicast", - networks=[ - dict(prefix="11.0.0.0/8", route_map="rmap2") - ], + networks=[dict(prefix="11.0.0.0/8", route_map="rmap2")], ), ], ), @@ -1461,9 +1426,7 @@ def test_nxos_bgp_nexthop_merged(self): safi="multicast", nexthop=dict( route_map="rmap1", - trigger_delay=dict( - critical_delay=120, non_critical_delay=180 - ), + trigger_delay=dict(critical_delay=120, non_critical_delay=180), ), ), dict( @@ -1471,9 +1434,7 @@ def test_nxos_bgp_nexthop_merged(self): afi="ipv4", safi="unicast", nexthop=dict( - trigger_delay=dict( - critical_delay=110, non_critical_delay=170 - ) + trigger_delay=dict(critical_delay=110, non_critical_delay=170) ), ), ], @@ -1523,9 +1484,7 @@ def test_nxos_bgp_nexthop_replaced(self): afi="ipv4", safi="unicast", nexthop=dict( - trigger_delay=dict( - critical_delay=110, non_critical_delay=170 - ) + trigger_delay=dict(critical_delay=110, non_critical_delay=170) ), ), ], @@ -1939,9 +1898,7 @@ def test_nxos_bgp_timers_merged(self): afi="ipv4", safi="multicast", timers=dict( - bestpath_defer=dict( - defer_time=120, maximum_defer_time=380 - ) + bestpath_defer=dict(defer_time=120, maximum_defer_time=380) ), ), dict( @@ -1949,9 +1906,7 @@ def test_nxos_bgp_timers_merged(self): afi="ipv4", safi="unicast", timers=dict( - bestpath_defer=dict( - defer_time=110, maximum_defer_time=350 - ) + bestpath_defer=dict(defer_time=110, maximum_defer_time=350) ), ), ], @@ -1992,9 +1947,7 @@ def test_nxos_bgp_timers_replaced(self): afi="ipv4", safi="multicast", timers=dict( - bestpath_defer=dict( - defer_time=120, maximum_defer_time=380 - ) + bestpath_defer=dict(defer_time=120, maximum_defer_time=380) ), ), dict(vrf="site-1", afi="ipv4", safi="unicast"), @@ -2125,11 +2078,7 @@ def test_nxos_bgp_af_parsed(self): vrf="site-1", afi="ipv4", safi="unicast", - timers=dict( - bestpath_defer=dict( - defer_time=100, maximum_defer_time=350 - ) - ), + timers=dict(bestpath_defer=dict(defer_time=100, maximum_defer_time=350)), ), ], ) @@ -2164,11 +2113,7 @@ def test_nxos_bgp_af_gathered(self): vrf="site-1", afi="ipv4", safi="unicast", - timers=dict( - bestpath_defer=dict( - defer_time=100, maximum_defer_time=350 - ) - ), + timers=dict(bestpath_defer=dict(defer_time=100, maximum_defer_time=350)), ), ], ) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py index b4fc5de33..5cb2c2efd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch 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 @@ -61,9 +63,7 @@ def test_nxos_bgp_af(self): ) def test_nxos_bgp_af_vrf(self): - set_module_args( - dict(asn=65535, vrf="test", afi="ipv4", safi="unicast") - ) + set_module_args(dict(asn=65535, vrf="test", afi="ipv4", safi="unicast")) self.execute_module( changed=True, sort=False, @@ -75,9 +75,7 @@ def test_nxos_bgp_af_vrf(self): ) def test_nxos_bgp_af_vrf_exists(self): - set_module_args( - dict(asn=65535, vrf="test2", afi="ipv4", safi="unicast") - ) + 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): @@ -141,9 +139,7 @@ def test_nxos_bgp_af_dampening_mix(self): ) def test_nxos_bgp_af_client(self): - set_module_args( - dict(asn=65535, afi="ipv4", safi="unicast", client_to_client=False) - ) + set_module_args(dict(asn=65535, afi="ipv4", safi="unicast", client_to_client=False)) self.execute_module( changed=True, commands=[ @@ -154,11 +150,7 @@ def test_nxos_bgp_af_client(self): ) def test_nxos_bgp_af_retain_route_target(self): - set_module_args( - dict( - asn=65535, afi="l2vpn", safi="evpn", retain_route_target="abc" - ) - ) + set_module_args(dict(asn=65535, afi="l2vpn", safi="evpn", retain_route_target="abc")) self.execute_module( changed=True, commands=[ @@ -169,11 +161,7 @@ def test_nxos_bgp_af_retain_route_target(self): ) def test_nxos_bgp_af_retain_route_target_all(self): - set_module_args( - dict( - asn=65535, afi="l2vpn", safi="evpn", retain_route_target="all" - ) - ) + set_module_args(dict(asn=65535, afi="l2vpn", safi="evpn", retain_route_target="all")) self.execute_module( changed=True, commands=[ @@ -184,9 +172,5 @@ def test_nxos_bgp_af_retain_route_target_all(self): ) def test_nxos_bgp_af_retain_route_target_exists(self): - set_module_args( - dict( - asn=65535, afi="l2vpn", safi="evpn", retain_route_target="xyz" - ) - ) + set_module_args(dict(asn=65535, afi="l2vpn", safi="evpn", retain_route_target="xyz")) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index d7b343db1..247ddf013 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_global +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 + ignore_provider_arg = True @@ -43,9 +44,7 @@ def setUp(self): 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.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_global.bgp_global.Bgp_globalFacts.get_config" @@ -90,9 +89,7 @@ def test_nxos_bgp_global_merged(self): dict( neighbor_address="198.51.100.21", remote_as="65537", - password=dict( - encryption=7, key="12090404011C03162E" - ), + password=dict(encryption=7, key="12090404011C03162E"), ), ], vrfs=[ @@ -347,9 +344,7 @@ def test_nxos_bgp_global_merged_idempotent(self): dict( neighbor_address="198.51.100.21", remote_as="65537", - password=dict( - encryption=7, key="12090404011C03162E" - ), + password=dict(encryption=7, key="12090404011C03162E"), ), ], vrfs=[ @@ -666,9 +661,7 @@ def test_nxos_bgp_global_replaced_failed_2(self): dict( neighbor_address="198.51.100.21", remote_as="65537", - password=dict( - encryption=7, key="12090404011C03162E" - ), + password=dict(encryption=7, key="12090404011C03162E"), ), ], vrfs=[ @@ -737,9 +730,7 @@ def test_nxos_bgp_global_replaced_failed_3(self): dict( neighbor_address="198.51.100.21", remote_as="65537", - password=dict( - encryption=7, key="12090404011C03162E" - ), + password=dict(encryption=7, key="12090404011C03162E"), ), ], vrfs=[ diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py index ebaa38529..b04b6d6ff 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch 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 @@ -77,9 +79,7 @@ def test_nxos_bgp_neighbor_bfd_2(self): 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") - ) + set_module_args(dict(asn=65535, neighbor="192.0.2.3", description="some words")) self.execute_module( changed=True, commands=[ @@ -91,20 +91,14 @@ def test_nxos_bgp_neighbor(self): 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"] - ) + 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") - ) + 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") - ) + set_module_args(dict(asn=65535, neighbor="3.3.3.4", remove_private_as="replace-as")) self.execute_module( changed=True, commands=[ @@ -115,11 +109,7 @@ def test_nxos_bgp_neighbor_remove_private_as_changed(self): ) 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" - ) - ) + set_module_args(dict(asn=65535, neighbor="192.0.2.3", peer_type="fabric_border_leaf")) self.execute_module( changed=True, commands=[ @@ -130,9 +120,7 @@ def test_nxos_bgp_neighbor_peertype_border_leaf(self): ) def test_nxos_bgp_neighbor_peertype_external(self): - set_module_args( - dict(asn=65535, neighbor="192.0.2.3", peer_type="fabric_external") - ) + set_module_args(dict(asn=65535, neighbor="192.0.2.3", peer_type="fabric_external")) self.execute_module( changed=True, commands=[ @@ -143,13 +131,9 @@ def test_nxos_bgp_neighbor_peertype_external(self): ) 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") - ) + 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") - ) + set_module_args(dict(asn=65535, neighbor="6.6.6.6", peer_type="fabric_external")) self.execute_module(changed=False) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 172b0695b..cab007f0b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -19,19 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent + +from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_neighbor_address_family from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import ( - nxos_bgp_neighbor_address_family, -) +from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson from .nxos_module import TestNxosModule, load_fixture, set_module_args + ignore_provider_arg = True @@ -56,9 +55,7 @@ def setUp(self): 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.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_neighbor_address_family." @@ -95,9 +92,7 @@ def test_nxos_bgp_nbr_af_advertise_map_merged(self): dict( afi="ipv4", safi="multicast", - advertise_map=dict( - route_map="rmap1", exist_map="rmap2" - ), + advertise_map=dict(route_map="rmap1", exist_map="rmap2"), ) ], ) @@ -175,9 +170,7 @@ def test_nxos_bgp_nbr_af_advertise_map_replaced(self): dict( afi="ipv4", safi="multicast", - advertise_map=dict( - route_map="rmap1", exist_map="rmap3" - ), + advertise_map=dict(route_map="rmap1", exist_map="rmap3"), ) ], ) @@ -593,9 +586,7 @@ def test_nxos_bgp_nbr_af_as_override_replaced(self): neighbors=[ dict( neighbor_address="10.0.0.2", - address_family=[ - dict(afi="ipv4", safi="multicast") - ], + address_family=[dict(afi="ipv4", safi="multicast")], ) ], vrfs=[ @@ -661,9 +652,7 @@ def test_nxos_bgp_nbr_af_capability_merged(self): afi="ipv4", safi="multicast", capability=dict( - additional_paths=dict( - receive="enable", send="enable" - ) + additional_paths=dict(receive="enable", send="enable") ), ) ], @@ -754,9 +743,7 @@ def test_nxos_bgp_nbr_af_capability_replaced(self): dict( afi="ipv4", safi="multicast", - capability=dict( - additional_paths=dict(send="enable") - ), + capability=dict(additional_paths=dict(send="enable")), ) ], ) @@ -855,9 +842,7 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): dict( afi="ipv4", safi="multicast", - default_originate=dict( - route_map="rmap2" - ), + default_originate=dict(route_map="rmap2"), ), ], ) @@ -988,12 +973,8 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_merged(self): dict( afi="ipv4", safi="multicast", - filter_list=dict( - inbound="rmap3", outbound="rmap4" - ), - inherit=dict( - template="template-2", sequence=200 - ), + filter_list=dict(inbound="rmap3", outbound="rmap4"), + inherit=dict(template="template-2", sequence=200), ) ], ) @@ -1086,9 +1067,7 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_replaced(self): afi="ipv4", safi="multicast", filter_list=dict(inbound="rmap3"), - inherit=dict( - template="template-2", sequence=200 - ), + inherit=dict(template="template-2", sequence=200), ) ], ) @@ -1207,9 +1186,7 @@ def test_nxos_bgp_nbr_af_maximum_prefix_merged(self): dict( afi="ipv4", safi="multicast", - maximum_prefix=dict( - max_prefix_limit=28 - ), + maximum_prefix=dict(max_prefix_limit=28), ), dict( afi="ipv4", @@ -1315,9 +1292,7 @@ def test_nxos_bgp_nbr_af_maximum_prefix_replaced(self): dict( afi="ipv4", safi="multicast", - maximum_prefix=dict( - max_prefix_limit=28 - ), + maximum_prefix=dict(max_prefix_limit=28), ), dict( afi="ipv4", @@ -1409,16 +1384,12 @@ def test_nxos_bgp_nbr_af_next_hop_merged(self): dict( afi="ipv4", safi="multicast", - next_hop_self=dict( - all_routes=True - ), + next_hop_self=dict(all_routes=True), ), dict( afi="ipv6", safi="multicast", - next_hop_self=dict( - all_routes=True - ), + next_hop_self=dict(all_routes=True), ), ], ) @@ -1498,9 +1469,7 @@ def test_nxos_bgp_nbr_af_next_hop_replaced(self): dict( afi="ipv4", safi="multicast", - next_hop_self=dict( - all_routes=True - ), + next_hop_self=dict(all_routes=True), ), ], ) @@ -1551,9 +1520,7 @@ def test_nxos_bgp_nbr_af_prefix_list_merged(self): dict( afi="ipv4", safi="multicast", - prefix_list=dict( - inbound="rmap3", outbound="rmap4" - ), + prefix_list=dict(inbound="rmap3", outbound="rmap4"), ) ], ) @@ -1704,9 +1671,7 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_merged(self): dict( afi="ipv4", safi="multicast", - route_map=dict( - inbound="rmap3", outbound="rmap4" - ), + route_map=dict(inbound="rmap3", outbound="rmap4"), rewrite_evpn_rt_asn=True, ) ], @@ -2006,9 +1971,7 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_merged(self): dict( afi="ipv4", safi="multicast", - soft_reconfiguration_inbound=dict( - set=True - ), + soft_reconfiguration_inbound=dict(set=True), soo="73:43", ) ], @@ -2024,17 +1987,13 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_merged(self): dict( afi="ipv4", safi="unicast", - soft_reconfiguration_inbound=dict( - always=True - ), + soft_reconfiguration_inbound=dict(always=True), soo="65:28", ), dict( afi="ipv4", safi="multicast", - soft_reconfiguration_inbound=dict( - always=True - ), + soft_reconfiguration_inbound=dict(always=True), ), ], ) @@ -2089,9 +2048,7 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_replaced(self): dict( afi="ipv4", safi="multicast", - soft_reconfiguration_inbound=dict( - set=True - ), + soft_reconfiguration_inbound=dict(set=True), ) ], ) @@ -2106,9 +2063,7 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_replaced(self): dict( afi="ipv4", safi="unicast", - soft_reconfiguration_inbound=dict( - always=True - ), + soft_reconfiguration_inbound=dict(always=True), soo="65:28", ), dict(afi="ipv4", safi="multicast"), @@ -2244,9 +2199,7 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_replaced(self): neighbors=[ dict( neighbor_address="10.0.0.2", - address_family=[ - dict(afi="ipv4", safi="multicast") - ], + address_family=[dict(afi="ipv4", safi="multicast")], ) ], vrfs=[ @@ -2430,9 +2383,7 @@ def test_nxos_bgp_nbr_af_overridden(self): neighbors=[ dict( neighbor_address="192.168.1.1", - address_family=[ - dict(afi="ipv4", safi="multicast") - ], + address_family=[dict(afi="ipv4", safi="multicast")], ) ], ) @@ -2490,9 +2441,7 @@ def test_nxos_bgp_nbr_af_gathered(self): neighbors=[ dict( neighbor_address="192.168.1.1", - address_family=[ - dict(afi="ipv4", safi="multicast") - ], + address_family=[dict(afi="ipv4", safi="multicast")], ) ], ) @@ -2537,9 +2486,7 @@ def test_nxos_bgp_nbr_af_parsed(self): neighbors=[ dict( neighbor_address="192.168.1.1", - address_family=[ - dict(afi="ipv4", safi="multicast") - ], + address_family=[dict(afi="ipv4", safi="multicast")], ) ], ) @@ -2657,9 +2604,7 @@ def test_nxos_bgp_nbr_af_no_cmd(self): neighbors=[ dict( neighbor_address="10.0.0.2", - address_family=[ - dict(afi="ipv4", safi="multicast") - ], + address_family=[dict(afi="ipv4", safi="multicast")], ) ], ), diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py index daeea18ef..4e2ee989d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch 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 @@ -74,9 +76,7 @@ def test_nxos_bgp_neighbor_af(self): ) def test_nxos_bgp_neighbor_af_exists(self): - set_module_args( - dict(asn=65535, neighbor="3.3.3.5", afi="ipv4", safi="unicast") - ) + 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): diff --git a/tests/unit/modules/network/nxos/test_nxos_command.py b/tests/unit/modules/network/nxos/test_nxos_command.py index af27c64d3..8dd126109 100644 --- a/tests/unit/modules/network/nxos/test_nxos_command.py +++ b/tests/unit/modules/network/nxos/test_nxos_command.py @@ -19,12 +19,14 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import json -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_command +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -86,9 +88,7 @@ def test_nxos_command_wait_for_fails(self): def test_nxos_command_retries(self): wait_for = 'result[0] contains "test string"' - set_module_args( - dict(commands=["show version"], wait_for=wait_for, retries=2) - ) + set_module_args(dict(commands=["show version"], wait_for=wait_for, retries=2)) self.execute_module(failed=True) self.assertEqual(self.run_commands.call_count, 2) @@ -97,9 +97,7 @@ def test_nxos_command_match_any(self): 'result[0] contains "Cisco"', 'result[0] contains "test string"', ] - set_module_args( - dict(commands=["show version"], wait_for=wait_for, match="any") - ) + set_module_args(dict(commands=["show version"], wait_for=wait_for, match="any")) self.execute_module() def test_nxos_command_match_all(self): @@ -107,9 +105,7 @@ def test_nxos_command_match_all(self): 'result[0] contains "Cisco"', 'result[0] contains "image file"', ] - set_module_args( - dict(commands=["show version"], wait_for=wait_for, match="all") - ) + set_module_args(dict(commands=["show version"], wait_for=wait_for, match="all")) self.execute_module() def test_nxos_command_match_all_failure(self): @@ -118,7 +114,5 @@ def test_nxos_command_match_all_failure(self): 'result[0] contains "test string"', ] commands = ["show version", "show version"] - set_module_args( - dict(commands=commands, wait_for=wait_for, match="all") - ) + set_module_args(dict(commands=commands, wait_for=wait_for, match="all")) self.execute_module(failed=True) diff --git a/tests/unit/modules/network/nxos/test_nxos_config.py b/tests/unit/modules/network/nxos/test_nxos_config.py index ec51d19f5..a1ea87ce8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_config.py +++ b/tests/unit/modules/network/nxos/test_nxos_config.py @@ -19,14 +19,13 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - MagicMock, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_config from ansible_collections.cisco.nxos.plugins.cliconf.nxos import Cliconf +from ansible_collections.cisco.nxos.plugins.modules import nxos_config +from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -76,18 +75,14 @@ def tearDown(self): self.mock_get_connection.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "nxos_config", "config.cfg" - ) + self.get_config.return_value = load_fixture("nxos_config", "config.cfg") self.load_config.return_value = None def test_nxos_config_no_change(self): lines = ["hostname localhost"] args = dict(lines=lines) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff( - "\n".join(lines), self.running_config - ) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) ) set_module_args(args) result = self.execute_module() @@ -109,9 +104,7 @@ def test_nxos_config_src(self): "ip routing", ] - self.assertEqual( - sorted(config), sorted(result["commands"]), result["commands"] - ) + self.assertEqual(sorted(config), sorted(result["commands"]), result["commands"]) def test_nxos_config_replace_src(self): set_module_args(dict(replace_src="bootflash:config", replace="config")) @@ -121,43 +114,33 @@ def test_nxos_config_replace_src(self): ) ) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["config replace bootflash:config"] - ) + self.assertEqual(result["commands"], ["config replace bootflash:config"]) def test_nxos_config_lines(self): lines = ["hostname switch01", "ip domain-name eng.ansible.com"] args = dict(lines=lines) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff( - "\n".join(lines), self.running_config - ) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) ) set_module_args(args) result = self.execute_module(changed=True) config = ["hostname switch01"] - self.assertEqual( - sorted(config), sorted(result["commands"]), result["commands"] - ) + self.assertEqual(sorted(config), sorted(result["commands"]), result["commands"]) def test_nxos_config_before(self): lines = ["hostname switch01", "ip domain-name eng.ansible.com"] args = dict(lines=lines, before=["before command"]) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff( - "\n".join(lines), self.running_config - ) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) ) set_module_args(args) result = self.execute_module(changed=True) config = ["before command", "hostname switch01"] - self.assertEqual( - sorted(config), sorted(result["commands"]), result["commands"] - ) + self.assertEqual(sorted(config), sorted(result["commands"]), result["commands"]) self.assertEqual("before command", result["commands"][0]) def test_nxos_config_after(self): @@ -165,18 +148,14 @@ def test_nxos_config_after(self): args = dict(lines=lines, after=["after command"]) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff( - "\n".join(lines), self.running_config - ) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) ) set_module_args(args) result = self.execute_module(changed=True) config = ["after command", "hostname switch01"] - self.assertEqual( - sorted(config), sorted(result["commands"]), result["commands"] - ) + self.assertEqual(sorted(config), sorted(result["commands"]), result["commands"]) self.assertEqual("after command", result["commands"][-1]) def test_nxos_config_parents(self): @@ -279,17 +258,13 @@ def test_nxos_config_defaults_true(self): self.assertEqual(self.get_config.call_args[1], dict(flags=["all"])) def test_nxos_config_defaults_false_backup_true(self): - set_module_args( - dict(lines=["hostname localhost"], defaults=False, backup=True) - ) + set_module_args(dict(lines=["hostname localhost"], defaults=False, backup=True)) result = self.execute_module(changed=True) self.assertEqual(self.get_config.call_count, 1) self.assertEqual(self.get_config.call_args[1], dict(flags=[])) def test_nxos_config_defaults_true_backup_true(self): - set_module_args( - dict(lines=["hostname localhost"], defaults=True, backup=True) - ) + set_module_args(dict(lines=["hostname localhost"], defaults=True, backup=True)) result = self.execute_module(changed=True) self.assertEqual(self.get_config.call_count, 1) self.assertEqual(self.get_config.call_args[1], dict(flags=["all"])) diff --git a/tests/unit/modules/network/nxos/test_nxos_evpn_global.py b/tests/unit/modules/network/nxos/test_nxos_evpn_global.py index 2f926f6f0..ec2fe8642 100644 --- a/tests/unit/modules/network/nxos/test_nxos_evpn_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_evpn_global.py @@ -20,10 +20,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_evpn_global +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -59,15 +61,11 @@ def load_fixtures(self, commands=None, device=""): self.load_config.return_value = None def start_configured(self, *args, **kwargs): - self.get_config.return_value = load_fixture( - "nxos_evpn_global", "configured.cfg" - ) + self.get_config.return_value = load_fixture("nxos_evpn_global", "configured.cfg") return self.execute_module(*args, **kwargs) def start_unconfigured(self, *args, **kwargs): - self.get_config.return_value = load_fixture( - "nxos_evpn_global", "unconfigured.cfg" - ) + self.get_config.return_value = load_fixture("nxos_evpn_global", "unconfigured.cfg") return self.execute_module(*args, **kwargs) def test_nxos_evpn_global_enable(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py b/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py index 53e23d48c..bc09f4b90 100644 --- a/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py +++ b/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_evpn_vni +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -49,15 +51,11 @@ def tearDown(self): self.mock_get_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "", "nxos_evpn_vni_config.cfg" - ) + self.get_config.return_value = load_fixture("", "nxos_evpn_vni_config.cfg") self.load_config.return_value = None def test_nxos_evpn_vni_present(self): - set_module_args( - dict(vni="6000", route_target_import="5000:10", state="present") - ) + set_module_args(dict(vni="6000", route_target_import="5000:10", state="present")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], diff --git a/tests/unit/modules/network/nxos/test_nxos_feature.py b/tests/unit/modules/network/nxos/test_nxos_feature.py index cd80ece51..97476297d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_feature.py +++ b/tests/unit/modules/network/nxos/test_nxos_feature.py @@ -19,12 +19,14 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import json -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_feature +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -84,16 +86,12 @@ def load_from_file(*args, **kwargs): def test_nxos_feature_enable(self): set_module_args(dict(feature="nve", state="enabled")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["terminal dont-ask", "feature nv overlay"] - ) + self.assertEqual(result["commands"], ["terminal dont-ask", "feature nv overlay"]) def test_nxos_feature_disable(self): set_module_args(dict(feature="ospf", state="disabled")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["terminal dont-ask", "no feature ospf"] - ) + self.assertEqual(result["commands"], ["terminal dont-ask", "no feature ospf"]) class TestNxosFeatureModuleMDS(TestNxosModule): @@ -158,16 +156,12 @@ def load_from_file(*args, **kwargs): def test_nxos_feature_enable(self): set_module_args(dict(feature="fcrxbbcredit", state="enabled")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["terminal dont-ask", "feature fcrxbbcredit"] - ) + self.assertEqual(result["commands"], ["terminal dont-ask", "feature fcrxbbcredit"]) def test_nxos_feature_disable(self): set_module_args(dict(feature="port-track", state="disabled")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["terminal dont-ask", "no feature port-track"] - ) + self.assertEqual(result["commands"], ["terminal dont-ask", "no feature port-track"]) def test_nxos_feature_enable_already_enabled(self): set_module_args(dict(feature="analytics", state="enabled")) diff --git a/tests/unit/modules/network/nxos/test_nxos_hostname.py b/tests/unit/modules/network/nxos/test_nxos_hostname.py index e5810d7af..7dd0342bf 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hostname.py +++ b/tests/unit/modules/network/nxos/test_nxos_hostname.py @@ -18,16 +18,20 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + from typing import Sequence + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from ansible_collections.cisco.nxos.plugins.modules import nxos_hostname +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from .nxos_module import TestNxosModule, set_module_args + ignore_provider_arg = True @@ -41,9 +45,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname.HostnameFacts.get_config" @@ -155,9 +157,7 @@ def test_nxos_hostname_parsed(self): hostname NXOSv-9k """ ) - set_module_args( - dict(running_config=cfg, state="parsed"), ignore_provider_arg - ) + set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = {"hostname": "NXOSv-9k"} result = self.execute_module(changed=False) self.assertEqual(result["parsed"], parsed) diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp.py b/tests/unit/modules/network/nxos/test_nxos_hsrp.py index 3c125c857..f384d5e31 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_hsrp +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py index 2af403c68..748cd7306 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py @@ -19,19 +19,21 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_hsrp_interfaces + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.hsrp_interfaces.hsrp_interfaces import ( Hsrp_interfaces, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_hsrp_interfaces +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 + ignore_provider_arg = True @@ -50,16 +52,12 @@ def setUp(self): 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.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.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.hsrp_interfaces.hsrp_interfaces.Hsrp_interfaces.edit_config" @@ -104,9 +102,7 @@ def test_1(self): interface Ethernet1/3 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="enable"), @@ -147,9 +143,7 @@ def test_2(self): hsrp bfd """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="disable"), @@ -209,12 +203,8 @@ def test_3(self): hsrp bfd """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } - playbook = dict( - config=[dict(name="Ethernet1/1"), dict(name="Ethernet1/2")] - ) + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} + playbook = dict(config=[dict(name="Ethernet1/1"), dict(name="Ethernet1/2")]) # Expected result commands for each 'state' merged = [] deleted = [ @@ -264,9 +254,7 @@ def test_4(self): hsrp bfd """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/1.42", bfd="enable")]) # Expected result commands for each 'state' merged = ["interface Ethernet1/1.42", "hsrp bfd"] @@ -306,9 +294,7 @@ def test_5(self): interface Ethernet1/2 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="enable"), diff --git a/tests/unit/modules/network/nxos/test_nxos_interface.py b/tests/unit/modules/network/nxos/test_nxos_interface.py index d1b83a3c1..eab5e7394 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_interface.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_interface +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -57,12 +59,7 @@ def load_from_file(*args, **kwargs): for command in commands: if type(command) == dict: command = command["command"] - filename = ( - str(command) - .split(" | ", 1)[0] - .replace(" ", "_") - .replace("/", "_") - ) + filename = str(command).split(" | ", 1)[0].replace(" ", "_").replace("/", "_") print(filename) output.append(load_fixture(module_name, filename)) return output @@ -73,16 +70,12 @@ def load_from_file(*args, **kwargs): def test_nxos_interface_up(self): set_module_args(dict(interface="loopback0")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["interface loopback0", "no shutdown"] - ) + self.assertEqual(result["commands"], ["interface loopback0", "no shutdown"]) def test_nxos_interface_down(self): set_module_args(dict(interface="loopback0", admin_state="down")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["interface loopback0", "shutdown"] - ) + self.assertEqual(result["commands"], ["interface loopback0", "shutdown"]) def test_nxos_interface_delete(self): set_module_args(dict(interface="loopback0", state="absent")) @@ -95,9 +88,7 @@ def test_nxos_interface_type(self): self.assertEqual(result["commands"], ["no interface loopback0"]) def test_nxos_interface_mtu(self): - set_module_args( - dict(interface="Ethernet2/1", mode="layer2", mtu="1800") - ) + set_module_args(dict(interface="Ethernet2/1", mode="layer2", mtu="1800")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], diff --git a/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py b/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py index b1fa11572..2d3016e45 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py +++ b/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_interface_ospf +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -65,9 +67,7 @@ def test_nxos_interface_ospf(self): def test_bfd_1(self): # default -> enable - set_module_args( - dict(interface="ethernet1/33", ospf=1, area=1, bfd="enable") - ) + set_module_args(dict(interface="ethernet1/33", ospf=1, area=1, bfd="enable")) self.execute_module( changed=True, commands=[ @@ -78,9 +78,7 @@ def test_bfd_1(self): ) # default -> disable - set_module_args( - dict(interface="ethernet1/33", ospf=1, area=1, bfd="disable") - ) + set_module_args(dict(interface="ethernet1/33", ospf=1, area=1, bfd="disable")) self.execute_module( changed=True, commands=[ @@ -92,45 +90,29 @@ def test_bfd_1(self): def test_bfd_2(self): # default -> default - set_module_args( - dict(interface="ethernet1/33.101", ospf=1, area=1, bfd="default") - ) + set_module_args(dict(interface="ethernet1/33.101", ospf=1, area=1, bfd="default")) self.execute_module(changed=False) # enable -> default - set_module_args( - dict(interface="ethernet1/36", ospf=1, area=1, bfd="default") - ) - self.execute_module( - changed=True, commands=["interface Ethernet1/36", "no ip ospf bfd"] - ) + set_module_args(dict(interface="ethernet1/36", ospf=1, area=1, bfd="default")) + self.execute_module(changed=True, commands=["interface Ethernet1/36", "no ip ospf bfd"]) # disable -> default - set_module_args( - dict(interface="ethernet1/37", ospf=1, area=1, bfd="default") - ) - self.execute_module( - changed=True, commands=["interface Ethernet1/37", "no ip ospf bfd"] - ) + set_module_args(dict(interface="ethernet1/37", ospf=1, area=1, bfd="default")) + self.execute_module(changed=True, commands=["interface Ethernet1/37", "no ip ospf bfd"]) def test_bfd_3(self): # enable -> idempotence - set_module_args( - dict(interface="ethernet1/36", ospf=1, area=1, bfd="enable") - ) + set_module_args(dict(interface="ethernet1/36", ospf=1, area=1, bfd="enable")) self.execute_module(changed=False) # disable -> idempotence - set_module_args( - dict(interface="ethernet1/37", ospf=1, area=1, bfd="disable") - ) + set_module_args(dict(interface="ethernet1/37", ospf=1, area=1, bfd="disable")) self.execute_module(changed=False) def test_bfd_4(self): # None -> absent - set_module_args( - dict(interface="ethernet1/33.101", ospf=1, area=1, state="absent") - ) + set_module_args(dict(interface="ethernet1/33.101", ospf=1, area=1, state="absent")) self.execute_module( changed=True, commands=[ @@ -179,9 +161,7 @@ def test_bfd_4(self): def test_absent_1(self): # area only -> absent - set_module_args( - dict(interface="ethernet1/33.101", ospf=1, area=1, state="absent") - ) + set_module_args(dict(interface="ethernet1/33.101", ospf=1, area=1, state="absent")) self.execute_module( changed=True, commands=[ @@ -191,19 +171,13 @@ def test_absent_1(self): ) # None -> absent - set_module_args( - dict(interface="ethernet1/33", ospf=1, area=1, state="absent") - ) + set_module_args(dict(interface="ethernet1/33", ospf=1, area=1, state="absent")) self.execute_module(changed=False) def test_loopback_interface_failed(self): - set_module_args( - dict(interface="loopback0", ospf=1, area=0, passive_interface=True) - ) + set_module_args(dict(interface="loopback0", ospf=1, area=0, passive_interface=True)) self.execute_module(failed=True, changed=False) - set_module_args( - dict(interface="loopback0", ospf=1, area=0, network="broadcast") - ) + set_module_args(dict(interface="loopback0", ospf=1, area=0, network="broadcast")) self.execute_module(failed=True, changed=False) def test_nxos_interface_ospf_passive(self): @@ -258,9 +232,7 @@ def test_nxos_interface_ospf_passive(self): ], ) # True -> default (absent) - set_module_args( - dict(interface="ethernet1/34", ospf=1, area=1, state="absent") - ) + set_module_args(dict(interface="ethernet1/34", ospf=1, area=1, state="absent")) self.execute_module( changed=True, commands=[ @@ -283,9 +255,7 @@ def test_nxos_interface_ospf_passive(self): commands=["interface Ethernet1/35", "ip ospf passive-interface"], ) # False -> default (absent) - set_module_args( - dict(interface="ethernet1/35", ospf=1, area=1, state="absent") - ) + set_module_args(dict(interface="ethernet1/35", ospf=1, area=1, state="absent")) self.execute_module( changed=True, commands=[ diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 140b19ecb..9ebdc9f06 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -19,22 +19,24 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_interfaces + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces import ( Interfaces, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.interfaces.interfaces import ( InterfacesFacts, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_interfaces +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 + ignore_provider_arg = True @@ -53,16 +55,12 @@ def setUp(self): 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.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.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.interfaces.interfaces.Interfaces.edit_config" @@ -133,9 +131,7 @@ def test_1(self): description test-loopback """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict( @@ -293,9 +289,7 @@ def test_2(self): shutdown """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict( @@ -437,9 +431,7 @@ def test_3(self): shutdown """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict( @@ -502,9 +494,7 @@ def test_3(self): "no shutdown", "interface Ethernet1/4.101", ] - self.execute_module( - changed=True, commands=merged_legacy, device="legacy" - ) + self.execute_module(changed=True, commands=merged_legacy, device="legacy") deleted = [ "interface Ethernet1/2", @@ -615,9 +605,7 @@ def test_4(self): shutdown """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict( @@ -651,9 +639,7 @@ def test_5(self): no shutdown """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict() @@ -693,9 +679,7 @@ def test_6_gathered(self): interface loopback1 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict() @@ -736,9 +720,7 @@ def test_7_purged(self): description sub-intf """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_RUN_INTF: intf - } + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs playbook = dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interface.py b/tests/unit/modules/network/nxos/test_nxos_l3_interface.py index f30ad8ff1..0eb43dd3c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interface.py @@ -5,10 +5,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_l3_interface +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -36,9 +38,7 @@ def tearDown(self): def load_fixtures(self, commands=None, device=""): self.load_config.return_value = None - self.get_config.return_value = load_fixture( - "nxos_l3_interface", self.mode - ) + self.get_config.return_value = load_fixture("nxos_l3_interface", self.mode) def test_nxos_l3_interface_unknonw_ethernet(self): self.mode = "ethernet_noshut" @@ -192,23 +192,17 @@ def test_nxos_l3_interface_add_missing_with_aggregate(self): # Rem when missing def test_nxos_l3_interface_rem_missing_ipv4(self): self.mode = "ethernet_noshut" - set_module_args( - dict(name="Ethernet1/1", ipv4="192.168.0.1/24", state="absent") - ) + set_module_args(dict(name="Ethernet1/1", ipv4="192.168.0.1/24", state="absent")) result = self.execute_module() def test_nxos_l3_interface_rem_missing_ipv4_on_e11(self): self.mode = "ethernet_noshut" - set_module_args( - dict(name="et1/1", ipv4="192.168.0.1/24", state="absent") - ) + set_module_args(dict(name="et1/1", ipv4="192.168.0.1/24", state="absent")) result = self.execute_module() def test_nxos_l3_interface_rem_missing_ipv6(self): self.mode = "ethernet_noshut" - set_module_args( - dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent") - ) + set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent")) result = self.execute_module() def test_nxos_l3_interface_rem_missing_ipv4_and_ipv6(self): @@ -226,9 +220,7 @@ def test_nxos_l3_interface_rem_missing_ipv4_and_ipv6(self): # Rem when existing def test_nxos_l3_interface_rem_existing_ipv4(self): self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args( - dict(name="Ethernet1/1", ipv4="192.168.0.1/24", state="absent") - ) + set_module_args(dict(name="Ethernet1/1", ipv4="192.168.0.1/24", state="absent")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -237,9 +229,7 @@ def test_nxos_l3_interface_rem_existing_ipv4(self): def test_nxos_l3_interface_rem_existing_ipv4_on_e11(self): self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args( - dict(name="et1/1", ipv4="192.168.0.1/24", state="absent") - ) + set_module_args(dict(name="et1/1", ipv4="192.168.0.1/24", state="absent")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -248,9 +238,7 @@ def test_nxos_l3_interface_rem_existing_ipv4_on_e11(self): def test_nxos_l3_interface_rem_existing_ipv6(self): self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args( - dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent") - ) + set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -285,9 +273,7 @@ def test_nxos_l3_interface_rem_existing_ipv4_and_ipv6(self): # Rem when existing with multiple IPv6 def test_nxos_l3_interface_multiple_ipv6_rem_first(self): self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args( - dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent") - ) + set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -300,9 +286,7 @@ def test_nxos_l3_interface_multiple_ipv6_rem_first(self): def test_nxos_l3_interface_multiple_ipv6_rem_last(self): self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args( - dict(name="Ethernet1/1", ipv6="2001:db8:2::1/124", state="absent") - ) + set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8:2::1/124", state="absent")) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -388,8 +372,6 @@ def test_nxos_l3_interface_add_on_unknown_itf(self): # Rem unknown interface def test_nxos_l3_interface_rem_on_unknown_itf(self): self.mode = "ethernet_noshut" - set_module_args( - dict(name="Ethernet1/2", ipv4="192.168.0.1/24", state="absent") - ) + set_module_args(dict(name="Ethernet1/2", ipv4="192.168.0.1/24", state="absent")) result = self.execute_module() self.assertEqual(result["warnings"], ["Unknown interface Ethernet1/2"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py index bacc0d4c4..8dc0f91e1 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py @@ -19,22 +19,21 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - PropertyMock, -) -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_l3_interfaces + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.l3_interfaces.l3_interfaces import ( L3_interfaces, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_l3_interfaces +from ansible_collections.cisco.nxos.tests.unit.compat.mock import PropertyMock, patch +from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson + from .nxos_module import TestNxosModule, load_fixture, set_module_args + ignore_provider_arg = True @@ -53,16 +52,12 @@ def setUp(self): 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.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.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.l3_interfaces.l3_interfaces.L3_interfaces.edit_config" @@ -113,9 +108,7 @@ def test_2(self): ip address 10.1.3.1/24 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="mgmt0", ipv4=[{"address": "10.0.0.254/24"}]), @@ -185,9 +178,7 @@ def test_3(self): ipv6 address 10::5/128 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="mgmt0", ipv4=[{"address": "10.0.0.254/24"}]), @@ -292,9 +283,7 @@ def test_4(self): ip address 10.25.25.25/24 secondary """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="mgmt0", ipv4=[{"address": "10.0.0.254/24"}]), @@ -434,9 +423,7 @@ def test_5(self): ipv6 address 10::13/128 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict( @@ -521,9 +508,7 @@ def test_6(self): no ip redirects """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict( @@ -533,9 +518,7 @@ def test_6(self): ipv4=[{"address": "192.168.1.1/24"}], ), dict(name="Ethernet1/2"), - dict( - name="Ethernet1/3", redirects=True, unreachables=False - ), # defaults + dict(name="Ethernet1/3", redirects=True, unreachables=False), # defaults dict(name="Ethernet1/4", redirects=False, unreachables=True), ] ) @@ -607,9 +590,7 @@ def test_7(self): interface Ethernet1/2 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict( @@ -657,9 +638,7 @@ def test_7(self): interface Ethernet1/2 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook["state"] = "deleted" set_module_args(playbook, ignore_provider_arg) self.execute_module(changed=False) @@ -672,9 +651,7 @@ def test_8(self): ip address 10.1.1.1/24 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict() for i in ["merged", "replaced", "overridden"]: @@ -700,12 +677,8 @@ def test_9(self): ip address 10.25.25.25/24 secondary """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } - playbook = dict( - config=[dict(name="Ethernet1/3"), dict(name="Ethernet1/5")] - ) + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} + playbook = dict(config=[dict(name="Ethernet1/3"), dict(name="Ethernet1/5")]) # Expected result commands for each 'state' deleted = [ "interface Ethernet1/3", @@ -762,9 +735,7 @@ def test_10(self): evpn multisite dci-tracking """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="mgmt0", ipv4=[{"address": "10.0.0.254/24"}]), @@ -844,9 +815,7 @@ def test_11(self): evpn multisite fabric-tracking """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="mgmt0", ipv4=[{"address": "10.0.0.254/24"}]), @@ -989,16 +958,12 @@ def test_12(self): ip address 192.168.1.1/24 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict( name="Vlan99", - ipv4=[ - {"address": "192.168.1.1/24", "tag": 500} - ], # adding a tag + ipv4=[{"address": "192.168.1.1/24", "tag": 500}], # adding a tag ) ], state="replaced", @@ -1022,9 +987,7 @@ def test_12_gathered(self): interface loopback1 """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(state="gathered") gathered_facts = [ {"name": "nve1"}, diff --git a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py index b9f699488..256dd6640 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py @@ -19,16 +19,17 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - PropertyMock, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_lacp_interfaces +from ansible_collections.cisco.nxos.tests.unit.compat.mock import PropertyMock, patch + from .nxos_module import TestNxosModule, set_module_args + ignore_provider_arg = True @@ -47,16 +48,12 @@ def setUp(self): 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.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.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.l3_interfaces.l3_interfaces.L3_interfaces.edit_config" @@ -88,9 +85,7 @@ def test_lacp_mode_parse(self): no lacp graceful-convergence """ ) - self.get_resource_connection_facts.return_value = { - self.SHOW_CMD: existing - } + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py index 843a766c4..9d69e02e6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py @@ -5,16 +5,13 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.cisco.nxos.plugins.modules import nxos_lldp_interfaces -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - MagicMock, -) -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - set_module_args, -) +from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +from ansible_collections.cisco.nxos.tests.unit.modules.utils import set_module_args + from .nxos_module import TestNxosModule, load_fixture @@ -38,16 +35,12 @@ def setUp(self): 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.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.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.lldp_interfaces.lldp_interfaces.Lldp_interfaces.edit_config" @@ -158,9 +151,7 @@ def test_nxos_lldp_interfaces_replaced_idempotent(self): def test_nxos_lldp_interfaces_overridden(self): set_module_args( dict( - config=[ - dict(name="Ethernet1/4", receive=True, transmit=False) - ], + config=[dict(name="Ethernet1/4", receive=True, transmit=False)], state="overridden", ) ) @@ -194,9 +185,7 @@ def test_nxos_lldp_interfaces_overridden_idempotent(self): self.execute_module(changed=False, commands=[]) def test_nxos_lldp_interfaces_deleted_intf(self): - set_module_args( - dict(config=[dict(name="Ethernet1/2")], state="deleted") - ) + set_module_args(dict(config=[dict(name="Ethernet1/2")], state="deleted")) commands = [ "interface Ethernet1/2", "lldp receive", @@ -239,9 +228,7 @@ def test_nxos_lldp_interfaces_rendered(self): "lldp tlv-set vlan 12", ] 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_lldp_interfaces_parsed(self): set_module_args( diff --git a/tests/unit/modules/network/nxos/test_nxos_logging_global.py b/tests/unit/modules/network/nxos/test_nxos_logging_global.py index 1300a936b..357b87aeb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_logging_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_logging_global.py @@ -18,19 +18,21 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + from typing import Sequence + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_logging_global +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, set_module_args + ignore_provider_arg = True @@ -44,9 +46,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.logging_global.logging_global.Logging_globalFacts.get_config" @@ -240,9 +240,7 @@ def test_nxos_logging_global_linear_merged_3(self): origin_id=dict(hostname=True), ip=dict( access_list=dict( - cache=dict( - entries=16384, interval=200, threshold=80 - ), + cache=dict(entries=16384, interval=200, threshold=80), detailed=True, include=dict(sgt=True), ) @@ -287,9 +285,7 @@ def test_nxos_logging_global_linear_merged_3_idempotent(self): origin_id=dict(hostname=True), ip=dict( access_list=dict( - cache=dict( - entries=16384, interval=200, threshold=80 - ), + cache=dict(entries=16384, interval=200, threshold=80), detailed=True, include=dict(sgt=True), ) @@ -322,11 +318,7 @@ def test_nxos_logging_global_linear_replaced_3(self): dict( config=dict( origin_id=dict(ip="192.168.1.1"), - ip=dict( - access_list=dict( - cache=dict(entries=16384, interval=210) - ) - ), + ip=dict(access_list=dict(cache=dict(entries=16384, interval=210))), source_interface="Ethernet1/120", ), state="replaced", @@ -532,9 +524,7 @@ def test_nxos_logging_global_event_replaced(self): self.assertEqual(set(result["commands"]), set(commands)) def test_nxos_logging_global_gathered_empty(self): - set_module_args( - dict(running_config="", state="gathered"), ignore_provider_arg - ) + set_module_args(dict(running_config="", state="gathered"), ignore_provider_arg) result = self.execute_module(changed=False) self.assertEqual(result["gathered"], {}) @@ -562,9 +552,7 @@ def test_nxos_logging_global_gathered(self): "rate_limit": "disabled", "rfc_strict": True, "origin_id": {"string": "nodeA"}, - "facilities": [ - {"facility": "vlan_mgr", "severity": "notification"} - ], + "facilities": [{"facility": "vlan_mgr", "severity": "notification"}], } result = self.execute_module(changed=False) self.assertEqual(result["gathered"], gathered) @@ -583,9 +571,7 @@ def test_nxos_logging_global_parsed(self): logging origin-id string nodeA """ ) - set_module_args( - dict(running_config=cfg, state="parsed"), ignore_provider_arg - ) + set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = { "console": {"severity": "alert"}, "module": {"severity": "notification"}, @@ -614,9 +600,7 @@ def test_nxos_logging_global_hosts_merged(self): facility="auth", port=5891, use_vrf="default", - secure=dict( - trustpoint=dict(client_identity="test") - ), + secure=dict(trustpoint=dict(client_identity="test")), ), dict(host="192.168.1.2"), dict(host="192.168.1.3", severity="critical"), @@ -653,9 +637,7 @@ def test_nxos_logging_global_hosts_replaced(self): facility="auth", port=5891, use_vrf="default", - secure=dict( - trustpoint=dict(client_identity="test") - ), + secure=dict(trustpoint=dict(client_identity="test")), ), dict( host="192.168.1.3", @@ -741,9 +723,7 @@ def test_nxos_logging_global_event_replaced_2(self): ) set_module_args( dict( - config=dict( - event=dict(trunk_status=dict(enable=False, default=True)) - ), + config=dict(event=dict(trunk_status=dict(enable=False, default=True))), state="replaced", ), ignore_provider_arg, diff --git a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py index d1528db01..5ed7ba237 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_ntp_global +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, set_module_args + ignore_provider_arg = True @@ -43,9 +44,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config" @@ -329,9 +328,7 @@ def test_nxos_ntp_global_complex_2_merged(self): prefer=True, ), dict(peer="192.168.1.2", key_id=3, use_vrf="siteB"), - dict( - peer="192.168.1.3", maxpoll=10, use_vrf="default" - ), + dict(peer="192.168.1.3", maxpoll=10, use_vrf="default"), ], servers=[ dict( @@ -343,9 +340,7 @@ def test_nxos_ntp_global_complex_2_merged(self): prefer=True, ), dict(server="203.0.113.2", key_id=3, use_vrf="siteB"), - dict( - server="203.0.113.3", maxpoll=10, use_vrf="default" - ), + dict(server="203.0.113.3", maxpoll=10, use_vrf="default"), ], ), state="merged", @@ -567,9 +562,7 @@ def test_nxos_ntp_global_complex_3_replaced(self): self.assertEqual(set(result["commands"]), set(commands)) def test_nxos_ntp_global_gathered_empty(self): - set_module_args( - dict(running_config="", state="gathered"), ignore_provider_arg - ) + set_module_args(dict(running_config="", state="gathered"), ignore_provider_arg) result = self.execute_module(changed=False) self.assertEqual(result["gathered"], {}) @@ -603,9 +596,7 @@ def test_nxos_ntp_global_parsed(self): ntp source-interface 192.168.1.100 """ ) - set_module_args( - dict(running_config=cfg, state="parsed"), ignore_provider_arg - ) + set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = { "trusted_keys": [ {"key_id": 1001}, diff --git a/tests/unit/modules/network/nxos/test_nxos_nxapi.py b/tests/unit/modules/network/nxos/test_nxos_nxapi.py index 3e40becb9..2acffa3e6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_nxapi.py +++ b/tests/unit/modules/network/nxos/test_nxos_nxapi.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_nxapi +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -89,9 +91,7 @@ def test_nxos_nxapi_no_change(self): def test_nxos_nxapi_disable(self): set_module_args(dict(state="absent")) - self.execute_module_devices( - changed=True, commands=["no feature nxapi"] - ) + self.execute_module_devices(changed=True, commands=["no feature nxapi"]) def test_nxos_nxapi_no_http(self): set_module_args(dict(https=True, http=False, https_port=8443)) diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf.py b/tests/unit/modules/network/nxos/test_nxos_ospf.py index 5cc4102a7..69b50edaa 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_ospf +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py index b16d66c74..2611688ee 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_ospf_interfaces +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 + ignore_provider_arg = True @@ -51,9 +52,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_config" @@ -400,19 +399,13 @@ def test_nxos_ospf_interfaces_af_multiareas_merged(self): dict( name="Ethernet1/1", address_family=[ - dict( - afi="ipv4", multi_areas=["1.1.1.1", "1.1.1.3"] - ), - dict( - afi="ipv6", multi_areas=["3.3.3.3", "4.4.4.4"] - ), + dict(afi="ipv4", multi_areas=["1.1.1.1", "1.1.1.3"]), + dict(afi="ipv6", multi_areas=["3.3.3.3", "4.4.4.4"]), ], ), dict( name="Ethernet1/2", - address_family=[ - dict(afi="ipv6", multi_areas=["5.5.5.6"]) - ], + address_family=[dict(afi="ipv6", multi_areas=["5.5.5.6"])], ), ], state="merged", @@ -455,12 +448,8 @@ def test_nxos_ospf_interfaces_af_multiareas_replaced(self): dict( name="Ethernet1/1", address_family=[ - dict( - afi="ipv4", multi_areas=["1.1.1.1", "1.1.1.3"] - ), - dict( - afi="ipv6", multi_areas=["3.3.3.3", "4.4.4.4"] - ), + dict(afi="ipv4", multi_areas=["1.1.1.1", "1.1.1.3"]), + dict(afi="ipv6", multi_areas=["3.3.3.3", "4.4.4.4"]), ], ), dict(name="Ethernet1/2"), @@ -508,31 +497,21 @@ def test_nxos_ospf_interfaces_authentication_merged(self): address_family=[ dict( afi="ipv4", - authentication=dict( - key_chain="test-1", message_digest=True - ), + authentication=dict(key_chain="test-1", message_digest=True), ) ], ), dict( name="Ethernet1/2", - address_family=[ - dict( - afi="ipv4", authentication=dict(null_auth=True) - ) - ], + address_family=[dict(afi="ipv4", authentication=dict(null_auth=True))], ), dict( name="Ethernet1/3", - address_family=[ - dict(afi="ipv4", authentication=dict(enable=True)) - ], + address_family=[dict(afi="ipv4", authentication=dict(enable=True))], ), dict( name="Ethernet1/4", - address_family=[ - dict(afi="ipv4", authentication=dict(enable=False)) - ], + address_family=[dict(afi="ipv4", authentication=dict(enable=False))], ), ], state="merged", @@ -576,17 +555,11 @@ def test_nxos_ospf_interfaces_authentication_replaced(self): dict(name="Ethernet1/1"), dict( name="Ethernet1/2", - address_family=[ - dict( - afi="ipv4", authentication=dict(null_auth=True) - ) - ], + address_family=[dict(afi="ipv4", authentication=dict(null_auth=True))], ), dict( name="Ethernet1/3", - address_family=[ - dict(afi="ipv4", authentication=dict(enable=True)) - ], + address_family=[dict(afi="ipv4", authentication=dict(enable=True))], ), ], state="replaced", @@ -629,9 +602,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): address_family=[ dict( afi="ipv4", - authentication_key=dict( - encryption=3, key="77840f9d4d882176" - ), + authentication_key=dict(encryption=3, key="77840f9d4d882176"), ) ], ), @@ -640,9 +611,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): address_family=[ dict( afi="ipv4", - authentication_key=dict( - encryption=0, key="password" - ), + authentication_key=dict(encryption=0, key="password"), ) ], ), @@ -651,9 +620,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): address_family=[ dict( afi="ipv4", - authentication_key=dict( - encryption=7, key="712090404011C031628" - ), + authentication_key=dict(encryption=7, key="712090404011C031628"), ) ], ), @@ -699,9 +666,7 @@ def test_nxos_ospf_interfaces_authentication_key_replaced(self): address_family=[ dict( afi="ipv4", - authentication_key=dict( - encryption=0, key="password" - ), + authentication_key=dict(encryption=0, key="password"), ) ], ), @@ -756,9 +721,7 @@ def test_nxos_ospf_interfaces_message_digest_key_merged(self): address_family=[ dict( afi="ipv4", - message_digest_key=dict( - key_id=1, encryption=0, key="password" - ), + message_digest_key=dict(key_id=1, encryption=0, key="password"), ) ], ), @@ -817,9 +780,7 @@ def test_nxos_ospf_interfaces_message_digest_key_replaced(self): address_family=[ dict( afi="ipv4", - message_digest_key=dict( - key_id=1, encryption=0, key="password1" - ), + message_digest_key=dict(key_id=1, encryption=0, key="password1"), ) ], ), @@ -932,15 +893,11 @@ def test_nxos_ospf_interfaces_linear_args_1_replaced(self): config=[ dict( name="Ethernet1/1", - address_family=[ - dict(afi="ipv4", cost=200, hello_interval=9000) - ], + address_family=[dict(afi="ipv4", cost=200, hello_interval=9000)], ), dict( name="Ethernet1/2", - address_family=[ - dict(afi="ipv6", cost=180, dead_interval=3000) - ], + address_family=[dict(afi="ipv6", cost=180, dead_interval=3000)], ), ], state="replaced", @@ -1225,9 +1182,7 @@ def test_nxos_ospf_interfaces_linear_args_4_merged(self): dict( name="Ethernet1/1", address_family=[ - dict( - afi="ipv4", shutdown=False, transmit_delay=210 - ), + dict(afi="ipv4", shutdown=False, transmit_delay=210), dict(afi="ipv6", shutdown=True), ], ), @@ -1241,12 +1196,8 @@ def test_nxos_ospf_interfaces_linear_args_4_merged(self): dict( name="Ethernet1/3", address_family=[ - dict( - afi="ipv4", shutdown=True, transmit_delay=430 - ), - dict( - afi="ipv6", shutdown=True, transmit_delay=120 - ), + dict(afi="ipv4", shutdown=True, transmit_delay=430), + dict(afi="ipv6", shutdown=True, transmit_delay=120), ], ), ], @@ -1371,9 +1322,7 @@ def test_nxos_ospf_interfaces_parsed(self): "address_family": [ { "afi": "ipv6", - "processes": [ - {"process_id": "210", "multi_areas": ["3.3.3.3"]} - ], + "processes": [{"process_id": "210", "multi_areas": ["3.3.3.3"]}], } ], }, @@ -1433,9 +1382,7 @@ def test_nxos_ospf_interfaces_gathered(self): "address_family": [ { "afi": "ipv6", - "processes": [ - {"process_id": "210", "multi_areas": ["3.3.3.3"]} - ], + "processes": [{"process_id": "210", "multi_areas": ["3.3.3.3"]}], } ], }, @@ -1481,9 +1428,7 @@ def test_nxos_ospf_interfaces_overridden(self): dict( name="Ethernet1/1", address_family=[ - dict( - afi="ipv4", shutdown=False, transmit_delay=300 - ), + dict(afi="ipv4", shutdown=False, transmit_delay=300), dict(afi="ipv6", shutdown=True), ], ) @@ -1599,21 +1544,15 @@ def test_nxos_ospf_interfaces_passive_intf(self): ), dict( name="Ethernet1/2", - address_family=[ - dict(afi="ipv4", default_passive_interface=True) - ], + address_family=[dict(afi="ipv4", default_passive_interface=True)], ), dict( name="Ethernet1/3", - address_family=[ - dict(afi="ipv6", default_passive_interface=True) - ], + address_family=[dict(afi="ipv6", default_passive_interface=True)], ), dict( name="Ethernet1/4", - address_family=[ - dict(afi="ipv4", default_passive_interface=True) - ], + address_family=[dict(afi="ipv4", default_passive_interface=True)], ), ], state="merged", diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py b/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py index 754453301..5a2b7228f 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_ospf_vrf +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py index 829b4777f..b7f96d2a0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_ospfv2 +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 + ignore_provider_arg = True @@ -43,9 +44,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospfv2.ospfv2.Ospfv2Facts.get_config" @@ -85,12 +84,8 @@ def test_nxos_ospfv2_merged(self): dict( area_id="0.0.0.100", filter_list=[ - dict( - route_map="rmap_1", direction="in" - ), - dict( - route_map="rmap_2", direction="out" - ), + dict(route_map="rmap_1", direction="in"), + dict(route_map="rmap_2", direction="out"), ], ranges=[ dict(prefix="198.51.100.64/27"), @@ -168,12 +163,8 @@ def test_nxos_ospfv2_merged_idempotent(self): dict( area_id="0.0.0.100", filter_list=[ - dict( - route_map="rmap_1", direction="in" - ), - dict( - route_map="rmap_2", direction="out" - ), + dict(route_map="rmap_1", direction="in"), + dict(route_map="rmap_2", direction="out"), ], ranges=[ dict(prefix="198.51.100.64/27"), @@ -335,12 +326,8 @@ def test_nxos_ospfv2_replaced_idempotent(self): dict( area_id="0.0.0.100", filter_list=[ - dict( - route_map="rmap_1", direction="in" - ), - dict( - route_map="rmap_2", direction="out" - ), + dict(route_map="rmap_1", direction="in"), + dict(route_map="rmap_2", direction="out"), ], ranges=[ dict(prefix="198.51.100.64/27"), @@ -380,11 +367,7 @@ def test_nxos_ospfv2_overridden(self): ) set_module_args( dict( - config=dict( - processes=[ - dict(process_id="300", router_id="203.0.113.20") - ] - ), + config=dict(processes=[dict(process_id="300", router_id="203.0.113.20")]), state="overridden", ), ignore_provider_arg, @@ -440,12 +423,8 @@ def test_nxos_ospfv2_overridden_idempotent(self): dict( area_id="0.0.0.100", filter_list=[ - dict( - route_map="rmap_1", direction="in" - ), - dict( - route_map="rmap_2", direction="out" - ), + dict(route_map="rmap_1", direction="in"), + dict(route_map="rmap_2", direction="out"), ], ranges=[ dict(prefix="198.51.100.64/27"), @@ -487,9 +466,7 @@ def test_nxos_ospfv2_deleted(self): ) set_module_args( dict( - config=dict( - processes=[dict(process_id="100"), dict(process_id="300")] - ), + config=dict(processes=[dict(process_id="100"), dict(process_id="300")]), state="deleted", ), ignore_provider_arg, @@ -519,9 +496,7 @@ def test_nxos_ospfv2_deleted_idempotent(self): ) set_module_args( dict( - config=dict( - processes=[dict(process_id="400"), dict(process_id="500")] - ), + config=dict(processes=[dict(process_id="400"), dict(process_id="500")]), state="deleted", ), ignore_provider_arg, diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py index aa38f7c40..1365f1d2b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_ospfv3 +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 + ignore_provider_arg = True @@ -54,9 +55,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospfv3.ospfv3.Ospfv3Facts.get_config" @@ -234,9 +233,7 @@ def test_nxos_ospfv3_af_areas_ranges_merged(self): dict( area_id="1.1.1.2", ranges=[ - dict( - prefix="2001:db4::/32", cost=11 - ), + dict(prefix="2001:db4::/32", cost=11), dict( prefix="2001:db5::/32", not_advertise=True, @@ -291,9 +288,7 @@ def test_nxos_ospfv3_af_areas_ranges_replaced(self): dict( area_id="1.1.1.2", ranges=[ - dict( - prefix="2001:db4::/32", cost=11 - ), + dict(prefix="2001:db4::/32", cost=11), dict( prefix="2001:db5::/32", not_advertise=True, @@ -383,9 +378,7 @@ def test_nxos_ospfv3_af_areas_default_cost_replaced(self): address_family=dict( afi="ipv6", safi="unicast", - areas=[ - dict(area_id="1.1.1.2", default_cost=200) - ], + areas=[dict(area_id="1.1.1.2", default_cost=200)], ), ) ] @@ -422,9 +415,7 @@ def test_nxos_ospfv3_af_default_information_merged(self): afi="ipv6", safi="unicast", default_information=dict( - originate=dict( - always=True, route_map="test-2" - ) + originate=dict(always=True, route_map="test-2") ), ), ) @@ -460,9 +451,7 @@ def test_nxos_ospfv3_af_default_information_merged_2(self): address_family=dict( afi="ipv6", safi="unicast", - default_information=dict( - originate=dict(set=False) - ), + default_information=dict(originate=dict(set=False)), ), ) ] @@ -497,9 +486,7 @@ def test_nxos_ospfv3_af_default_information_replaced(self): address_family=dict( afi="ipv6", safi="unicast", - default_information=dict( - originate=dict(set=True) - ), + default_information=dict(originate=dict(set=True)), ), ) ] @@ -531,9 +518,7 @@ def test_nxos_ospfv3_af_distance_merged(self): processes=[ dict( process_id="100", - address_family=dict( - afi="ipv6", safi="unicast", distance=35 - ), + address_family=dict(afi="ipv6", safi="unicast", distance=35), ) ] ), @@ -597,9 +582,7 @@ def test_nxos_ospfv3_af_maximum_paths_merged(self): processes=[ dict( process_id="100", - address_family=dict( - afi="ipv6", safi="unicast", maximum_paths=27 - ), + address_family=dict(afi="ipv6", safi="unicast", maximum_paths=27), ) ] ), @@ -682,9 +665,7 @@ def test_nxos_ospfv3_af_redistribute_merged(self): id="65563", route_map="test-3", ), - dict( - protocol="static", route_map="test-4" - ), + dict(protocol="static", route_map="test-4"), ], ), ) @@ -734,9 +715,7 @@ def test_nxos_ospfv3_af_redistribute_replaced(self): id="65563", route_map="test-3", ), - dict( - protocol="static", route_map="test-4" - ), + dict(protocol="static", route_map="test-4"), ], ), ) @@ -1012,11 +991,7 @@ def test_nxos_ospfv3_areas_nssa_merged(self): no_summary=True, no_redistribution=True, route_map="test-1", - translate=dict( - type7=dict( - always=True, supress_fa=True - ) - ), + translate=dict(type7=dict(always=True, supress_fa=True)), ), ), ], @@ -1051,9 +1026,7 @@ def test_nxos_ospfv3_areas_nssa_merged_2(self): processes=[ dict( process_id="100", - areas=[ - dict(area_id="1.1.1.1", nssa=dict(set=False)) - ], + areas=[dict(area_id="1.1.1.1", nssa=dict(set=False))], ) ] ), @@ -1184,11 +1157,7 @@ def test_nxos_ospfv3_areas_stub_replaced(self): ) set_module_args( dict( - config=dict( - processes=[ - dict(process_id="100", areas=[dict(area_id="1.1.1.3")]) - ] - ), + config=dict(processes=[dict(process_id="100", areas=[dict(area_id="1.1.1.3")])]), state="replaced", ), ignore_provider_arg, @@ -1211,9 +1180,7 @@ def test_nxos_ospfv3_autocost_flush_route_isolate_merged(self): processes=[ dict( process_id="100", - auto_cost=dict( - reference_bandwidth=100, unit="Gbps" - ), + auto_cost=dict(reference_bandwidth=100, unit="Gbps"), flush_routes=True, isolate=True, ) @@ -1446,9 +1413,7 @@ def test_nxos_ospfv3_graceful_restart_merged(self): processes=[ dict( process_id="100", - graceful_restart=dict( - grace_period=50, helper_disable=True - ), + graceful_restart=dict(grace_period=50, helper_disable=True), ), dict( process_id="102", @@ -1533,11 +1498,7 @@ def test_nxos_ospfv3_max_metric_merged(self): dict( process_id="102", max_metric=dict( - router_lsa=dict( - inter_area_prefix_lsa=dict( - max_metric_value=1800 - ) - ) + router_lsa=dict(inter_area_prefix_lsa=dict(max_metric_value=1800)) ), ), dict( @@ -1782,9 +1743,7 @@ def test_nxos_ospfv3_vrf_merged(self): wait_period=1200, wait_for_bgp_asn=65563, ), - inter_area_prefix_lsa=dict( - set=True - ), + inter_area_prefix_lsa=dict(set=True), ) ), ) @@ -2163,9 +2122,7 @@ def test_nxos_ospfv3_parsed(self): {"vrf": "blue", "router_id": "10.0.0.2"}, { "vrf": "red", - "areas": [ - {"area_id": "1.1.1.1", "nssa": {"set": True}} - ], + "areas": [{"area_id": "1.1.1.1", "nssa": {"set": True}}], }, ], }, @@ -2216,9 +2173,7 @@ def test_nxos_ospfv3_gathered(self): {"vrf": "blue", "router_id": "10.0.0.2"}, { "vrf": "red", - "areas": [ - {"area_id": "1.1.1.1", "nssa": {"set": True}} - ], + "areas": [{"area_id": "1.1.1.1", "nssa": {"set": True}}], }, ], }, diff --git a/tests/unit/modules/network/nxos/test_nxos_overlay_global.py b/tests/unit/modules/network/nxos/test_nxos_overlay_global.py index 4ec526924..976407b7d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_overlay_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_overlay_global.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_overlay_global +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -48,9 +50,7 @@ def tearDown(self): self.mock_get_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "", "nxos_overlay_global_config.cfg" - ) + self.get_config.return_value = load_fixture("", "nxos_overlay_global_config.cfg") self.load_config.return_value = None def test_nxos_overlay_global_up(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_pim.py b/tests/unit/modules/network/nxos/test_nxos_pim.py index 66fe01628..4637b9030 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_pim +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -55,17 +57,13 @@ def test_nxos_pim_1(self): # Add/ Modify self.get_config.return_value = load_fixture("nxos_pim", "config.cfg") set_module_args(dict(ssm_range="233.0.0.0/8")) - self.execute_module( - changed=True, commands=["ip pim ssm range 233.0.0.0/8"] - ) + self.execute_module(changed=True, commands=["ip pim ssm range 233.0.0.0/8"]) def test_nxos_pim_2(self): # Remove existing values self.get_config.return_value = load_fixture("nxos_pim", "config.cfg") set_module_args(dict(bfd="disable", ssm_range="none")) - self.execute_module( - changed=True, commands=["no ip pim bfd", "ip pim ssm range none"] - ) + self.execute_module(changed=True, commands=["no ip pim bfd", "ip pim ssm range none"]) def test_nxos_pim_3(self): # bfd None (disable)-> enable @@ -91,9 +89,7 @@ def test_nxos_pim_5(self): # SSM 'default' self.get_config.return_value = load_fixture("nxos_pim", "config.cfg") set_module_args(dict(ssm_range="default")) - self.execute_module( - changed=True, commands=["no ip pim ssm range none"] - ) + self.execute_module(changed=True, commands=["no ip pim ssm range none"]) # SSM 'default' idempotence self.get_config.return_value = None diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py index a5ec2ad86..101d94ca3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_pim_interface +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -64,12 +66,7 @@ def load_from_file(*args, **kwargs): for command in commands: if type(command) == dict: command = command["command"] - filename = ( - str(command) - .split(" | ", 1)[0] - .replace(" ", "_") - .replace("/", "_") - ) + filename = str(command).split(" | ", 1)[0].replace(" ", "_").replace("/", "_") output.append(load_fixture(module_name, filename)) return output @@ -166,9 +163,7 @@ def test_bfd_1(self): # default (None) -> enable self.get_config.return_value = None set_module_args(dict(interface="eth2/1", bfd="enable")) - self.execute_module( - changed=True, commands=["interface eth2/1", "ip pim bfd-instance"] - ) + self.execute_module(changed=True, commands=["interface eth2/1", "ip pim bfd-instance"]) # default (None) -> disable set_module_args(dict(interface="eth2/1", bfd="disable")) diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py b/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py index ebff3a47b..9a32bdb32 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_pim_rp_address +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -49,16 +51,12 @@ def tearDown(self): self.mock_get_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "nxos_pim_rp_address", "config.cfg" - ) + self.get_config.return_value = load_fixture("nxos_pim_rp_address", "config.cfg") self.load_config.return_value = None def test_nxos_pim_rp_address(self): set_module_args(dict(rp_address="5.6.7.8")) - self.execute_module( - changed=True, commands=["ip pim rp-address 5.6.7.8"] - ) + self.execute_module(changed=True, commands=["ip pim rp-address 5.6.7.8"]) def test_nxos_pim_rp_address_no_change(self): set_module_args(dict(rp_address="1.2.3.4")) @@ -66,9 +64,7 @@ def test_nxos_pim_rp_address_no_change(self): def test_nxos_pim_rp_address_absent(self): set_module_args(dict(rp_address="1.2.3.4", state="absent")) - self.execute_module( - changed=True, commands=["no ip pim rp-address 1.2.3.4"] - ) + self.execute_module(changed=True, commands=["no ip pim rp-address 1.2.3.4"]) def test_nxos_pim_rp_address_absent_no_change(self): set_module_args(dict(rp_address="5.6.7.8", state="absent")) diff --git a/tests/unit/modules/network/nxos/test_nxos_ping.py b/tests/unit/modules/network/nxos/test_nxos_ping.py index 8df553c50..b07309e6b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ping.py +++ b/tests/unit/modules/network/nxos/test_nxos_ping.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_ping +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 + ignore_provider_arg = True @@ -66,9 +67,7 @@ def test_nxos_ping_expected_success(self): ] set_module_args(dict(dest="172.28.128.7", vrf="management")) result = self.execute_module() - self.assertEqual( - result["commands"], ["ping 172.28.128.7 count 5 vrf management"] - ) + self.assertEqual(result["commands"], ["ping 172.28.128.7 count 5 vrf management"]) self.assertEqual(result["packet_loss"], "0.00%") self.assertEqual(result["packets_rx"], 5) self.assertEqual(result["packets_tx"], 5) @@ -90,9 +89,7 @@ def test_nxos_ping_expected_failure(self): 5 packets transmitted, 0 packets received, 100.00% packet loss """ ] - set_module_args( - dict(dest="172.28.128.8", vrf="management", state="absent") - ) + set_module_args(dict(dest="172.28.128.8", vrf="management", state="absent")) self.execute_module(failed=False) def test_nxos_ping_expected_success_but_failed(self): @@ -128,9 +125,7 @@ def test_nxos_ping_expected_failure_but_succeeded(self): round-trip min/avg/max = 1.597/2.32/4.197 ms """ ] - set_module_args( - dict(dest="172.28.128.7", vrf="management", state="absent") - ) + set_module_args(dict(dest="172.28.128.7", vrf="management", state="absent")) result = self.execute_module(failed=True) self.assertEqual(result["msg"], "Ping succeeded unexpectedly") @@ -179,9 +174,7 @@ def test_nxos_ping_expected_success_df_bit(self): ] set_module_args(dict(dest="172.28.128.7", df_bit=True)) result = self.execute_module() - self.assertEqual( - result["commands"], ["ping 172.28.128.7 count 5 df-bit"] - ) + self.assertEqual(result["commands"], ["ping 172.28.128.7 count 5 df-bit"]) def test_nxos_ping_expected_success_size(self): self.run_commands.return_value = [ @@ -200,9 +193,7 @@ def test_nxos_ping_expected_success_size(self): ] set_module_args(dict(dest="172.28.128.7", size=65468)) result = self.execute_module() - self.assertEqual( - result["commands"], ["ping 172.28.128.7 count 5 packet-size 65468"] - ) + self.assertEqual(result["commands"], ["ping 172.28.128.7 count 5 packet-size 65468"]) def test_nxos_ping_expected_success_all(self): self.run_commands.return_value = [ @@ -271,6 +262,4 @@ def test_nxos_ping_failed_error(self): self.run_commands.return_value = [""""""] set_module_args(dict(dest="172.28.128.7", count=10, vrf="site-1")) result = self.execute_module(failed=True) - self.assertEqual( - result["msg"], "An unexpected error occurred. Check all params." - ) + self.assertEqual(result["msg"], "An unexpected error occurred. Check all params.") diff --git a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py index 0ade67b9d..e4cce5a9b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py +++ b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py @@ -18,19 +18,21 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + from typing import Sequence + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_prefix_lists +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, set_module_args + ignore_provider_arg = True @@ -55,9 +57,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config" @@ -561,21 +561,15 @@ def test_nxos_prefix_lists_parsed(self): ipv6 prefix-list plist3 description Test plist3 """ ) - set_module_args( - dict(running_config=cfg, state="parsed"), ignore_provider_arg - ) + set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = [ { "afi": "ipv4", - "prefix_lists": [ - {"name": "plist1", "description": "Test plist1"} - ], + "prefix_lists": [{"name": "plist1", "description": "Test plist1"}], }, { "afi": "ipv6", - "prefix_lists": [ - {"name": "plist3", "description": "Test plist3"} - ], + "prefix_lists": [{"name": "plist3", "description": "Test plist3"}], }, ] result = self.execute_module(changed=False) diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index df45051e1..71a81bec5 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -19,17 +19,18 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) + from ansible_collections.cisco.nxos.plugins.modules import nxos_route_maps +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 + ignore_provider_arg = True @@ -54,9 +55,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.route_maps.route_maps.Route_mapsFacts.get_config" @@ -91,9 +90,7 @@ def test_nxos_route_maps_linear_merged(self): sequence=40, description="rmap1-deny-40", set=dict( - as_path=dict( - prepend=dict(last_as=10), tag=True - ), + as_path=dict(prepend=dict(last_as=10), tag=True), comm_list="comm1", dampening=dict( half_life=10, @@ -116,15 +113,11 @@ def test_nxos_route_maps_linear_merged(self): set=dict( null_interface="null0", ip=dict( - address=dict( - prefix_list="prefixlist1" - ), + address=dict(prefix_list="prefixlist1"), precedence="critical", ), ipv6=dict( - address=dict( - prefix_list="prefixlist2" - ), + address=dict(prefix_list="prefixlist2"), precedence="immediate", ), label_index=20, @@ -235,9 +228,7 @@ def test_nxos_route_maps_linear_merged_idempotent(self): sequence=40, description="rmap1-deny-40", set=dict( - as_path=dict( - prepend=dict(last_as=10), tag=True - ), + as_path=dict(prepend=dict(last_as=10), tag=True), comm_list="comm1", dampening=dict( half_life=10, @@ -260,15 +251,11 @@ def test_nxos_route_maps_linear_merged_idempotent(self): set=dict( null_interface="null0", ip=dict( - address=dict( - prefix_list="prefixlist1" - ), + address=dict(prefix_list="prefixlist1"), precedence="critical", ), ipv6=dict( - address=dict( - prefix_list="prefixlist2" - ), + address=dict(prefix_list="prefixlist2"), precedence="immediate", ), label_index=20, @@ -366,9 +353,7 @@ def test_nxos_route_maps_linear_replaced(self): action="deny", set=dict( ip=dict( - address=dict( - prefix_list="prefixlist1" - ), + address=dict(prefix_list="prefixlist1"), precedence="critical", ) ), @@ -439,9 +424,7 @@ def test_nxos_route_maps_parsed(self): action="deny", sequence=40, description="rmap1-deny-40", - set=dict( - as_path=dict(prepend=dict(last_as=10), tag=True) - ), + set=dict(as_path=dict(prepend=dict(last_as=10), tag=True)), ), ], ), @@ -507,9 +490,7 @@ def test_nxos_route_maps_gathered(self): action="deny", sequence=40, description="rmap1-deny-40", - set=dict( - as_path=dict(prepend=dict(last_as=10), tag=True) - ), + set=dict(as_path=dict(prepend=dict(last_as=10), tag=True)), ), ], ), @@ -572,9 +553,7 @@ def test_nxos_route_maps_rendered(self): action="deny", set=dict( ip=dict( - address=dict( - prefix_list="prefixlist1" - ), + address=dict(prefix_list="prefixlist1"), precedence="critical", ) ), @@ -641,9 +620,7 @@ def test_nxos_route_maps_overridden(self): description="rmap1-deny-40", set=dict( ipv6=dict( - address=dict( - prefix_list="prefixlist2" - ), + address=dict(prefix_list="prefixlist2"), precedence="immediate", ) ), @@ -767,9 +744,7 @@ def test_nxos_route_maps_complex_merged(self): as_path_list=["acl1", "acl2"], ), as_path=["65565", "65578", "65590"], - community=dict( - community_list=["comm1", "comm2"] - ), + community=dict(community_list=["comm1", "comm2"]), evpn=dict(route_types=["1", "2-mac-ip"]), extcommunity=dict( extcommunity_list=[ @@ -791,12 +766,8 @@ def test_nxos_route_maps_complex_merged(self): ), source="192.168.1.0/24", ), - next_hop=dict( - prefix_lists=["pl1", "pl2"] - ), - route_source=dict( - prefix_lists=["pl3", "pl4"] - ), + next_hop=dict(prefix_lists=["pl1", "pl2"]), + route_source=dict(prefix_lists=["pl3", "pl4"]), ), mac_list=["mac1", "mac2"], metric=[100, 200], @@ -823,12 +794,8 @@ def test_nxos_route_maps_complex_merged(self): ), source="192.168.1.0/24", ), - next_hop=dict( - prefix_lists=["pl1", "pl2"] - ), - route_source=dict( - prefix_lists=["pl3", "pl4"] - ), + next_hop=dict(prefix_lists=["pl1", "pl2"]), + route_source=dict(prefix_lists=["pl3", "pl4"]), ) ), ), @@ -836,28 +803,20 @@ def test_nxos_route_maps_complex_merged(self): sequence=40, action="permit", set=dict( - as_path=dict( - prepend=dict( - as_number=["65546", "78878"] - ) - ), + as_path=dict(prepend=dict(as_number=["65546", "78878"])), distance=dict( igp_ebgp_routes=10, internal_routes=20, local_routes=90, ), - evpn=dict( - gateway_ip=dict(ip="192.168.1.1") - ), + evpn=dict(gateway_ip=dict(ip="192.168.1.1")), ), ), dict( sequence=52, action="permit", set=dict( - evpn=dict( - gateway_ip=dict(use_nexthop=True) - ), + evpn=dict(gateway_ip=dict(use_nexthop=True)), community=dict( internet=True, number=["655:10", "655:20"], diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index a877d2ab6..a743f49c2 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -19,14 +19,17 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from ansible_collections.cisco.nxos.plugins.modules import nxos_snmp_server +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from .nxos_module import TestNxosModule, set_module_args + ignore_provider_arg = True @@ -40,9 +43,7 @@ def setUp(self): 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.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config" @@ -68,25 +69,17 @@ def test_nxos_snmp_server_linear_merged(self): context=dict(name="public", vrf="siteA", instance="test"), counter=dict(cache=dict(timeout=1800)), drop=dict(unknown_engine_id=True, unknown_user=True), - engine_id=dict( - local="'00:00:00:63:00:01:00:10:20:15:10:03'" - ), + engine_id=dict(local="'00:00:00:63:00:01:00:10:20:15:10:03'"), communities=[ dict(name="private", group="network-admin"), dict(community="public", use_ipv4acl="myacl"), ], global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict( - community="public", context="public1" - ) - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), - source_interface=dict( - informs="Ethernet1/1", traps="Ethernet1/2" - ), + source_interface=dict(informs="Ethernet1/1", traps="Ethernet1/2"), system_shutdown=True, tcp_session=dict(auth=True), ), @@ -147,21 +140,13 @@ def test_nxos_snmp_server_linear_merged_idempotent(self): context=dict(name="public", vrf="siteA"), counter=dict(cache=dict(timeout=1800)), drop=dict(unknown_engine_id=True, unknown_user=True), - engine_id=dict( - local="00:00:00:63:00:01:00:10:20:15:10:03" - ), + engine_id=dict(local="00:00:00:63:00:01:00:10:20:15:10:03"), global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict( - community="public", context="public1" - ) - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), - source_interface=dict( - informs="Ethernet1/1", traps="Ethernet1/2" - ), + source_interface=dict(informs="Ethernet1/1", traps="Ethernet1/2"), system_shutdown=True, tcp_session=dict(auth=True), ), @@ -201,21 +186,13 @@ def test_nxos_snmp_server_linear_replaced(self): contact="testswitch@localhost", context=dict(name="public", vrf="siteA"), counter=dict(cache=dict(timeout=1860)), - engine_id=dict( - local="00:00:00:63:00:01:00:10:20:15:10:03" - ), + engine_id=dict(local="00:00:00:63:00:01:00:10:20:15:10:03"), global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict( - community="public", context="public1" - ) - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), - source_interface=dict( - informs="Ethernet1/3", traps="Ethernet1/2" - ), + source_interface=dict(informs="Ethernet1/3", traps="Ethernet1/2"), tcp_session=dict(auth=True), ), state="replaced", @@ -262,21 +239,13 @@ def test_nxos_snmp_server_linear_overridden(self): contact="testswitch@localhost", context=dict(name="public", vrf="siteA"), counter=dict(cache=dict(timeout=1860)), - engine_id=dict( - local="00:00:00:63:00:01:00:10:20:15:10:03" - ), + engine_id=dict(local="00:00:00:63:00:01:00:10:20:15:10:03"), global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict( - community="public", context="public1" - ) - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), - source_interface=dict( - informs="Ethernet1/3", traps="Ethernet1/2" - ), + source_interface=dict(informs="Ethernet1/3", traps="Ethernet1/2"), tcp_session=dict(auth=True), ), state="overridden", @@ -468,9 +437,7 @@ def test_nxos_snmp_server_hosts_merged(self): community="public", traps=True, ), - dict( - host="192.168.1.1", source_interface="Ethernet1/1" - ), + dict(host="192.168.1.1", source_interface="Ethernet1/1"), dict( host="192.168.2.1", version="1", @@ -535,9 +502,7 @@ def test_nxos_snmp_server_hosts_merged(self): community="public", traps=True, ), - dict( - host="192.168.1.1", source_interface="Ethernet1/1" - ), + dict(host="192.168.1.1", source_interface="Ethernet1/1"), dict( host="192.168.2.1", version="1", @@ -594,9 +559,7 @@ def test_nxos_snmp_server_hosts_replaced(self): community="public", traps=True, ), - dict( - host="192.168.1.1", source_interface="Ethernet1/1" - ), + dict(host="192.168.1.1", source_interface="Ethernet1/1"), dict( host="192.168.2.1", version="1", @@ -740,9 +703,7 @@ def test_nxos_snmp_server_users_merged(self): algorithm="md5", password="0x5632724fb8ac3699296af262", engine_id="2:2:2:2:2", - priv=dict( - privacy_password="0x5632724fb8ac3699296af262" - ), + priv=dict(privacy_password="0x5632724fb8ac3699296af262"), localizedv2_key=True, ), ), @@ -930,9 +891,7 @@ def test_nxos_snmp_server_parsed(self): engine_id=dict(local="00:00:00:63:00:01:00:10:20:15:10:03"), global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict(community="public", context="public1") - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), source_interface=dict(informs="Ethernet1/1", traps="Ethernet1/2"), @@ -947,9 +906,7 @@ def test_nxos_snmp_server_parsed(self): algorithm="md5", password="0x7d425fbf09417c44bca69e1d9e9ce889", localized_key=True, - priv=dict( - privacy_password="0x7d425fbf09417c44bca69e1d9e9ce889" - ), + priv=dict(privacy_password="0x7d425fbf09417c44bca69e1d9e9ce889"), ), ), dict( @@ -977,21 +934,13 @@ def test_nxos_snmp_server_rendered(self): context=dict(name="public", vrf="siteA"), counter=dict(cache=dict(timeout=1800)), drop=dict(unknown_engine_id=True, unknown_user=True), - engine_id=dict( - local="'00:00:00:63:00:01:00:10:20:15:10:03'" - ), + engine_id=dict(local="'00:00:00:63:00:01:00:10:20:15:10:03'"), global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict( - community="public", context="public1" - ) - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), - source_interface=dict( - informs="Ethernet1/1", traps="Ethernet1/2" - ), + source_interface=dict(informs="Ethernet1/1", traps="Ethernet1/2"), system_shutdown=True, tcp_session=dict(auth=True), ), @@ -1053,9 +1002,7 @@ def test_nxos_snmp_server_gathered(self): engine_id=dict(local="00:00:00:63:00:01:00:10:20:15:10:03"), global_enforce_priv=True, location="lab", - mib=dict( - community_map=dict(community="public", context="public1") - ), + mib=dict(community_map=dict(community="public", context="public1")), packetsize=484, protocol=dict(enable=True), source_interface=dict(informs="Ethernet1/1", traps="Ethernet1/2"), diff --git a/tests/unit/modules/network/nxos/test_nxos_static_route.py b/tests/unit/modules/network/nxos/test_nxos_static_route.py index 55cf040d0..fa835ccf6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_route.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_route.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_static_route +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -49,16 +51,12 @@ def tearDown(self): self.mock_get_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "", "nxos_static_route.cfg" - ) + self.get_config.return_value = load_fixture("", "nxos_static_route.cfg") self.load_config.return_value = None def test_nxos_static_route_present(self): set_module_args(dict(prefix="192.168.20.64/24", next_hop="192.0.2.3")) - self.execute_module( - changed=True, commands=["ip route 192.168.20.0/24 192.0.2.3"] - ) + self.execute_module(changed=True, commands=["ip route 192.168.20.0/24 192.0.2.3"]) def test_nxos_static_route_present_no_defaults(self): set_module_args( @@ -75,9 +73,7 @@ def test_nxos_static_route_present_no_defaults(self): ) def test_nxos_static_route_present_vrf(self): - set_module_args( - dict(prefix="192.168.20.64/24", next_hop="192.0.2.3", vrf="test") - ) + set_module_args(dict(prefix="192.168.20.64/24", next_hop="192.0.2.3", vrf="test")) self.execute_module( changed=True, sort=False, @@ -92,19 +88,11 @@ def test_nxos_static_route_no_change(self): self.execute_module(changed=False, commands=[]) def test_nxos_static_route_absent(self): - set_module_args( - dict(prefix="10.10.30.12/24", next_hop="1.2.4.8", state="absent") - ) - self.execute_module( - changed=True, commands=["no ip route 10.10.30.0/24 1.2.4.8"] - ) + set_module_args(dict(prefix="10.10.30.12/24", next_hop="1.2.4.8", state="absent")) + self.execute_module(changed=True, commands=["no ip route 10.10.30.0/24 1.2.4.8"]) def test_nxos_static_route_absent_no_change(self): - set_module_args( - dict( - prefix="192.168.20.6/24", next_hop="192.0.2.3", state="absent" - ) - ) + set_module_args(dict(prefix="192.168.20.6/24", next_hop="192.0.2.3", state="absent")) self.execute_module(changed=False, commands=[]) def test_nxos_static_route_absent_vrf(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_static_routes.py b/tests/unit/modules/network/nxos/test_nxos_static_routes.py index dd2cff02e..be1115202 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_routes.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_routes.py @@ -5,16 +5,13 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.cisco.nxos.plugins.modules import nxos_static_routes -from ansible_collections.cisco.nxos.tests.unit.compat.mock import ( - patch, - MagicMock, -) -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - set_module_args, -) +from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +from ansible_collections.cisco.nxos.tests.unit.modules.utils import set_module_args + from .nxos_module import TestNxosModule, load_fixture @@ -38,16 +35,12 @@ def setUp(self): 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.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.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" @@ -70,9 +63,7 @@ def tearDown(self): 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" - ] + 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" @@ -318,11 +309,7 @@ def test_nxos_static_routes_deleteddest(self): config=[ dict( vrf="test", - address_families=[ - dict( - afi="ipv4", routes=[dict(dest="192.0.2.96/28")] - ) - ], + address_families=[dict(afi="ipv4", routes=[dict(dest="192.0.2.96/28")])], ) ], state="deleted", @@ -401,9 +388,7 @@ def test_nxos_static_routes_rendered(self): "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(sorted(result["rendered"]), sorted(commands), result["rendered"]) def test_nxos_static_routes_parsed(self): set_module_args( diff --git a/tests/unit/modules/network/nxos/test_nxos_system.py b/tests/unit/modules/network/nxos/test_nxos_system.py index aa6bc1f38..41367cb1b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_system.py +++ b/tests/unit/modules/network/nxos/test_nxos_system.py @@ -20,10 +20,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_system +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -50,9 +52,7 @@ def tearDown(self): self.mock_load_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "nxos_system", "config.cfg", device=device - ) + self.get_config.return_value = load_fixture("nxos_system", "config.cfg", device=device) self.load_config.return_value = None def test_nxos_system_hostname_changed(self): @@ -91,9 +91,7 @@ def test_nxos_system_domain_name_vrf_only(self): ) ) commands = [] - self.execute_module( - changed=False, commands=commands, device="vrf_only" - ) + self.execute_module(changed=False, commands=commands, device="vrf_only") def test_nxos_system_domain_name_complex(self): domain_name = dict(name="example.net", vrf="management") diff --git a/tests/unit/modules/network/nxos/test_nxos_telemetry.py b/tests/unit/modules/network/nxos/test_nxos_telemetry.py index d197fc1c3..58374aaee 100644 --- a/tests/unit/modules/network/nxos/test_nxos_telemetry.py +++ b/tests/unit/modules/network/nxos/test_nxos_telemetry.py @@ -19,28 +19,28 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_telemetry -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - NxosCmdRef, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.telemetry.telemetry import ( - Telemetry, -) -from .nxos_module import TestNxosModule, load_fixture, set_module_args # TBD: These imports / import checks are only needed as a workaround for # shippable, which fails this test due to import yaml & import ordereddict. import pytest + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.telemetry.telemetry import ( + Telemetry, +) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + NxosCmdRef, nxosCmdRef_import_check, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_telemetry +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 + msg = nxosCmdRef_import_check() ignore_provider_arg = True @@ -62,16 +62,12 @@ def setUp(self): 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.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.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.telemetry.telemetry.Telemetry.edit_config" @@ -192,9 +188,7 @@ def test_tms_global_merged2_n9k(self): def test_tms_global_idempotent_n9k(self): # Assumes feature telemetry is enabled # TMS global config is present. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -216,9 +210,7 @@ def test_tms_global_change_cert_n9k(self): # Assumes feature telemetry is enabled # TMS global config is present # Change certificate - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -246,9 +238,7 @@ def test_tms_global_change_interface_n9k(self): # Assumes feature telemetry is enabled # TMS global config is present # Change interface - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -277,9 +267,7 @@ def test_tms_global_change_several_n9k(self): # Assumes feature telemetry is enabled # TMS global config is present # Change source_interface, vrf and cert - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -331,25 +319,20 @@ def test_tms_destgroup_input_validation_1(self): with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] - assert "Parameter under is required" in str( - testdata["msg"] - ) + assert "Parameter under is required" in str(testdata["msg"]) assert testdata["failed"] def test_tms_destgroup_input_validation_2(self): # Parameter 'destination' is not a dict. self.execute_show_command.return_value = None self.get_platform_shortname.return_value = "N9K" - args = build_args( - [{"id": "88", "destination": "192.168.1.1"}], "destination_groups" - ) + args = build_args([{"id": "88", "destination": "192.168.1.1"}], "destination_groups") set_module_args(args, ignore_provider_arg) with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] - assert ( - "Parameter under must be a dict" - in str(testdata["msg"]) + assert "Parameter under must be a dict" in str( + testdata["msg"] ) assert testdata["failed"] @@ -365,9 +348,7 @@ def test_tms_destgroup_input_validation_3(self): with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] - assert "Playbook entry contains unrecongnized parameters" in str( - testdata["msg"] - ) + assert "Playbook entry contains unrecongnized parameters" in str(testdata["msg"]) assert testdata["failed"] def test_tms_destgroup_merged_n9k(self): @@ -484,9 +465,7 @@ def test_tms_destgroup_idempotent_n9k(self): # Assumes feature telemetry is enabled # TMS destgroup config is not present. # Configure only identifier - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -509,9 +488,7 @@ def test_tms_destgroup_idempotent2_n9k(self): # Assumes feature telemetry is enabled # TMS destgroup config is not present. # Configure only identifier - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args([{"id": "2"}], "destination_groups") set_module_args(args, ignore_provider_arg) @@ -520,9 +497,7 @@ def test_tms_destgroup_idempotent2_n9k(self): def test_tms_destgroup_merged_aggregate_idempotent_n9k(self): # Assumes feature telemetry is enabled # TMS destgroup config is present. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -553,9 +528,7 @@ def test_tms_destgroup_merged_aggregate_idempotent_n9k(self): def test_tms_destgroup_change_n9k(self): # TMS destgroup config is not present. # Change protocol and encoding for dest group 2 - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -594,9 +567,7 @@ def test_tms_destgroup_add_n9k(self): # TMS destgroup config is not present. # Add destinations to destgroup 10 # Add new destgroup 55 and 56 - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -653,12 +624,8 @@ def test_tms_sensorgroup_merged_n9k(self): # TMS sensorgroup config is not present. self.execute_show_command.return_value = None self.get_platform_shortname.return_value = "N9K" - td55_name = ( - "sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]" - ) - td55_fc = ( - 'or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up"))' - ) + td55_name = "sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]" + td55_fc = 'or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up"))' args = build_args( [ { @@ -743,9 +710,7 @@ def test_tms_sensorgroup_input_validation_1(self): with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] - assert "Parameter under is required" in str( - testdata["msg"] - ) + assert "Parameter under is required" in str(testdata["msg"]) assert testdata["failed"] def test_tms_sensorgroup_input_validation_2(self): @@ -770,10 +735,7 @@ def test_tms_sensorgroup_input_validation_2(self): with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] - assert ( - "Parameter under requires key" - in str(testdata["msg"]) - ) + assert "Parameter under requires key" in str(testdata["msg"]) assert testdata["failed"] def test_tms_sensorgroup_resource_key_n9k(self): @@ -900,9 +862,7 @@ def test_tms_sensorgroup_merged_variable_args4_n9k(self): def test_tms_sensorgroup_merged_idempotent_n9k(self): # Assumes feature telemetry is enabled # TMS sensorgroup config is not present. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -925,9 +885,7 @@ def test_tms_sensorgroup_merged_idempotent_n9k(self): def test_tms_sensorgroup_quotes_merged_idempotent_n9k(self): # Assumes feature telemetry is enabled # TMS sensorgroup config is present with quotes in NX-API path. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K_SGs.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K_SGs.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -953,9 +911,7 @@ def test_tms_sensorgroup_quotes_merged_idempotent_n9k(self): def test_tms_sensorgroup_vxlan_idempotent_n9k(self): # TMS sensorgroup config present. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [{"id": "56", "data_source": "DME", "path": {"name": "vxlan"}}], @@ -966,9 +922,7 @@ def test_tms_sensorgroup_vxlan_idempotent_n9k(self): def test_tms_sensorgroup_idempotent_variable1_n9k(self): # TMS sensorgroup config is present with path key name. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -987,9 +941,7 @@ def test_tms_sensorgroup_idempotent_variable1_n9k(self): def test_tms_sensorgroup_idempotent_variable2_n9k(self): # TMS sensorgroup config is present with path key name and depth. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -1006,9 +958,7 @@ def test_tms_sensorgroup_idempotent_variable2_n9k(self): def test_tms_sensorgroup_idempotent_resource_key_n9k(self): # TMS sensorgroup config is present resource key only. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args([{"id": "55"}], "sensor_groups") set_module_args(args, ignore_provider_arg) @@ -1135,9 +1085,7 @@ def test_tms_subscription_merged_n9k(self): def test_tms_subscription_merged_idempotent_n9k(self): # TMS subscription config is not present. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -1161,9 +1109,7 @@ def test_tms_subscription_merged_idempotent_n9k(self): def test_tms_subscription_merged_change1_n9k(self): # TMS subscription config present. # Change sample interval for sensor group 2 - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -1194,9 +1140,7 @@ def test_tms_subscription_merged_change1_n9k(self): def test_tms_subscription_add_n9k(self): # TMS subscription config present. # Add new destination_group and sensor_group to subscription 5 - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" args = build_args( [ @@ -1383,9 +1327,7 @@ def test_telemetry_full_n9k(self): def test_telemetry_deleted_input_validation_n9k(self): # State is 'deleted' and 'config' key present. - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -1405,19 +1347,14 @@ def test_telemetry_deleted_input_validation_n9k(self): with pytest.raises(AnsibleFailJson) as errinfo: self.execute_module() testdata = errinfo.value.args[0] - assert ( - "Remove config key from playbook when state is " - in str(testdata["msg"]) - ) + assert "Remove config key from playbook when state is " in str(testdata["msg"]) assert testdata["failed"] def test_telemetry_deleted_n9k(self): # Assumes feature telemetry is enabled # TMS global config is present. # Make absent with all playbook keys provided - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args(dict(state="deleted"), ignore_provider_arg) self.execute_module(changed=True, commands=["no telemetry"]) @@ -1434,9 +1371,7 @@ def test_telemetry_deleted_idempotent_n9k(self): def test_tms_replaced1_n9k(self): # Assumes feature telemetry is enabled # Modify global config and remove everything else - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( dict( @@ -1479,9 +1414,7 @@ def test_tms_replaced2_n9k(self): # Modify destination-group 10, add 11 and 99, remove 2 # Modify sensor-group 55, 56 # remove all subscriptions - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( { @@ -1597,9 +1530,7 @@ def test_tms_replaced3_n9k(self): # remove all other destination-groups # Modify sensor-group 55 and delete all others # Modify subscription 7, add 10 and delete all others - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( { @@ -1690,9 +1621,7 @@ def test_tms_replaced_idempotent_n9k(self): # remove all other destination-groups # Modify sensor-group 55 and delete all others # Modify subscription 7, add 10 and delete all others - self.execute_show_command.return_value = load_fixture( - "nxos_telemetry", "N9K.cfg" - ) + self.execute_show_command.return_value = load_fixture("nxos_telemetry", "N9K.cfg") self.get_platform_shortname.return_value = "N9K" set_module_args( { diff --git a/tests/unit/modules/network/nxos/test_nxos_user.py b/tests/unit/modules/network/nxos/test_nxos_user.py index 62620129c..d85456270 100644 --- a/tests/unit/modules/network/nxos/test_nxos_user.py +++ b/tests/unit/modules/network/nxos/test_nxos_user.py @@ -19,12 +19,15 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_user +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, set_module_args + ignore_provider_arg = True @@ -71,9 +74,7 @@ def test_mds(self): { "usr_name": "admin", "expire_date": "this user account has no expiry date", - "TABLE_role": { - "ROW_role": {"role": "network-admin"} - }, + "TABLE_role": {"ROW_role": {"role": "network-admin"}}, }, { "usr_name": "ansible-test-1", @@ -92,9 +93,7 @@ def test_mds(self): "network_os_image": "bootflash:///m9100-s5ek9-mz.8.4.2b.bin", "network_os_platform": "DS-C9710", } - set_module_args( - dict(name="ansible-test-2", configured_password="ansible") - ) + set_module_args(dict(name="ansible-test-2", configured_password="ansible")) self.execute_module( changed=True, commands=[ diff --git a/tests/unit/modules/network/nxos/test_nxos_vlan.py b/tests/unit/modules/network/nxos/test_nxos_vlan.py index c1a0c8a09..a69ddd7d0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vlan.py +++ b/tests/unit/modules/network/nxos/test_nxos_vlan.py @@ -19,12 +19,14 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import json -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vlan +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -77,9 +79,7 @@ def load_from_file(*args, **kwargs): command = obj["command"] except ValueError: command = item - filename = "%s.txt" % str(command).split(" | ", 1)[0].replace( - " ", "_" - ) + filename = "%s.txt" % str(command).split(" | ", 1)[0].replace(" ", "_") output.append(load_fixture("nxos_vlan", filename)) return output diff --git a/tests/unit/modules/network/nxos/test_nxos_vlans.py b/tests/unit/modules/network/nxos/test_nxos_vlans.py index 17a8b2e1f..1b8fede1a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vlans.py +++ b/tests/unit/modules/network/nxos/test_nxos_vlans.py @@ -19,19 +19,21 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import ( - AnsibleFailJson, -) -from ansible_collections.cisco.nxos.plugins.modules import nxos_vlans + from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.vlans.vlans import ( Vlans, ) +from ansible_collections.cisco.nxos.plugins.modules import nxos_vlans +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 + ignore_provider_arg = True @@ -50,16 +52,12 @@ def setUp(self): 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.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.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.vlans.vlans.Vlans.edit_config" @@ -128,9 +126,7 @@ def test_1(self): config=[ dict(vlan_id=4), dict(vlan_id=5, mapped_vni=555, mode="ce"), - dict( - vlan_id=7, mapped_vni=777, name="test-vlan7", enabled=False - ), + dict(vlan_id=7, mapped_vni=777, name="test-vlan7", enabled=False), dict(vlan_id="8", state="active", name="test-changeme-not") # vlan 3 is not present in playbook. ] diff --git a/tests/unit/modules/network/nxos/test_nxos_vpc.py b/tests/unit/modules/network/nxos/test_nxos_vpc.py index 2aac9c000..225e0b25e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vpc.py +++ b/tests/unit/modules/network/nxos/test_nxos_vpc.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vpc +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -69,9 +71,7 @@ def vrf_load_from_file(*args, **kwargs): module, commands = args output = list() for command in commands: - filename = "vrf_test_" + str(command).split(" | ", 1)[ - 0 - ].replace(" ", "_") + filename = "vrf_test_" + str(command).split(" | ", 1)[0].replace(" ", "_") output.append(load_fixture("nxos_vpc", filename)) return output @@ -127,9 +127,7 @@ def test_nxos_vpc_vrf_1(self): def test_nxos_vpc_vrf_2(self): # vrf 'my_vrf'-> vrf 'test-vrf' # All pkl commands should be present - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") set_module_args( dict( domain=100, @@ -150,9 +148,7 @@ def test_nxos_vpc_vrf_2(self): def test_nxos_vpc_vrf_3(self): # vrf 'my_vrf' -> vrf 'obviously-different-vrf' # Existing pkl_src should be retained even though playbook does not specify it - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") set_module_args( dict( domain=100, @@ -172,12 +168,8 @@ def test_nxos_vpc_vrf_3(self): def test_nxos_vpc_vrf_4(self): # vrf 'my_vrf'-> vrf 'management' # 'management' is the default value for vrf, it will not nvgen - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) - set_module_args( - dict(domain=100, pkl_dest="192.168.1.1", pkl_vrf="management") - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") + set_module_args(dict(domain=100, pkl_dest="192.168.1.1", pkl_vrf="management")) self.execute_module( changed=True, device="_vrf_test", @@ -189,9 +181,7 @@ def test_nxos_vpc_vrf_4(self): def test_nxos_vpc_vrf_5(self): # vrf 'my_vrf' -> vrf 'my_vrf' (idempotence) - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") set_module_args( dict( domain=100, @@ -204,9 +194,7 @@ def test_nxos_vpc_vrf_5(self): def test_nxos_vpc_vrf_6(self): # vrf 'my_vrf' -> absent tests - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") set_module_args(dict(domain=100, state="absent")) self.execute_module( changed=True, @@ -217,19 +205,13 @@ def test_nxos_vpc_vrf_6(self): def test_nxos_vpc_vrf_7(self): # dest 192.168.1.1 source 10.1.1.1 vrf my_vrf -> (dest only) (idempotence) # pkl_src/pkl_vrf not in playbook but exists on device. - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") set_module_args(dict(domain=100, pkl_dest="192.168.1.1")) self.execute_module(changed=False, device="_vrf_test") def test_nxos_vpc_vrf_8(self): # dest 192.168.1.1 source 10.1.1.1 vrf my_vrf -> (optional vrf) (idempotence) # pkl_src not in playbook but exists on device. - self.get_config.return_value = load_fixture( - "nxos_vpc", "vrf_test_vpc_config" - ) - set_module_args( - dict(domain=100, pkl_dest="192.168.1.1", pkl_vrf="my_vrf") - ) + self.get_config.return_value = load_fixture("nxos_vpc", "vrf_test_vpc_config") + set_module_args(dict(domain=100, pkl_dest="192.168.1.1", pkl_vrf="my_vrf")) self.execute_module(changed=False, device="_vrf_test") diff --git a/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py b/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py index 233099795..35010df48 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vpc_interface +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -69,13 +71,9 @@ def load_from_file(*args, **kwargs): def test_nxos_vpc_interface_absent(self): set_module_args(dict(portchannel=10, vpc=100, state="absent")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["interface port-channel10", "no vpc"] - ) + self.assertEqual(result["commands"], ["interface port-channel10", "no vpc"]) def test_nxos_vpc_interface_present(self): set_module_args(dict(portchannel=20, vpc=200, state="present")) result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], ["interface port-channel20", "vpc 200"] - ) + self.assertEqual(result["commands"], ["interface port-channel20", "vpc 200"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_vrf.py b/tests/unit/modules/network/nxos/test_nxos_vrf.py index a2999cf83..35092a1e6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vrf.py +++ b/tests/unit/modules/network/nxos/test_nxos_vrf.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vrf +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -65,21 +67,15 @@ def load_from_file(*args, **kwargs): def test_nxos_vrf_present(self): set_module_args(dict(vrf="ntc", state="present", admin_state="up")) - self.execute_module( - changed=True, commands=["vrf context ntc", "no shutdown", "exit"] - ) + self.execute_module(changed=True, commands=["vrf context ntc", "no shutdown", "exit"]) def test_nxos_vrf_present_no_change(self): - set_module_args( - dict(vrf="management", state="present", admin_state="up") - ) + set_module_args(dict(vrf="management", state="present", admin_state="up")) self.execute_module(changed=False, commands=[]) def test_nxos_vrf_absent(self): set_module_args(dict(vrf="management", state="absent")) - self.execute_module( - changed=True, commands=["no vrf context management"] - ) + self.execute_module(changed=True, commands=["no vrf context management"]) def test_nxos_vrf_absent_no_change(self): set_module_args(dict(vrf="ntc", state="absent")) diff --git a/tests/unit/modules/network/nxos/test_nxos_vrf_af.py b/tests/unit/modules/network/nxos/test_nxos_vrf_af.py index f4ef571b5..86d7b5662 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vrf_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_vrf_af.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vrf_af +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -47,9 +49,7 @@ def setUp(self): "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.get_capabilities" ) self.get_capabilities = self.mock_get_capabilities.start() - self.get_capabilities.return_value = { - "device_info": {"network_os_platform": "N7K-C7018"} - } + self.get_capabilities.return_value = {"device_info": {"network_os_platform": "N7K-C7018"}} def tearDown(self): super(TestNxosVrfafModule, self).tearDown() @@ -58,9 +58,7 @@ def tearDown(self): self.mock_get_capabilities.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "nxos_vrf_af", "config.cfg" - ) + self.get_config.return_value = load_fixture("nxos_vrf_af", "config.cfg") self.load_config.return_value = None def test_nxos_vrf_af_present_current_non_existing(self): @@ -90,18 +88,14 @@ def test_nxos_vrf_af_absent_current_existing(self): ) def test_nxos_vrf_af_auto_evpn_route_target_present_current_existing(self): - set_module_args( - dict(vrf="vrf11", afi="ipv4", route_target_both_auto_evpn=True) - ) + set_module_args(dict(vrf="vrf11", afi="ipv4", route_target_both_auto_evpn=True)) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) def test_nxos_vrf_af_auto_evpn_route_target_present_current_non_existing( self, ): - set_module_args( - dict(vrf="vrf10", afi="ipv4", route_target_both_auto_evpn=True) - ) + set_module_args(dict(vrf="vrf10", afi="ipv4", route_target_both_auto_evpn=True)) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -113,9 +107,7 @@ def test_nxos_vrf_af_auto_evpn_route_target_present_current_non_existing( ) def test_nxos_vrf_af_auto_evpn_route_target_absent_current_existing(self): - set_module_args( - dict(vrf="vrf11", afi="ipv4", route_target_both_auto_evpn=False) - ) + set_module_args(dict(vrf="vrf11", afi="ipv4", route_target_both_auto_evpn=False)) result = self.execute_module(changed=True) self.assertEqual( result["commands"], @@ -129,9 +121,7 @@ def test_nxos_vrf_af_auto_evpn_route_target_absent_current_existing(self): def test_nxos_vrf_af_auto_evpn_route_target_absent_current_non_existing( self, ): - set_module_args( - dict(vrf="vrf1", afi="ipv4", route_target_both_auto_evpn=False) - ) + set_module_args(dict(vrf="vrf1", afi="ipv4", route_target_both_auto_evpn=False)) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -1099,16 +1089,12 @@ def test_nxos_vrf_af_auto_evpn_route_target_and_manual_route_targets_with_absent ) def test_nxos_vrf_af_both_auto_N9K(self): - self.get_capabilities.return_value = { - "device_info": {"network_os_platform": "N9K-C9300v"} - } + self.get_capabilities.return_value = {"device_info": {"network_os_platform": "N9K-C9300v"}} set_module_args( dict( vrf="v2000", afi="ipv4", - route_targets=[ - {"rt": "auto", "direction": "both", "state": "present"} - ], + route_targets=[{"rt": "auto", "direction": "both", "state": "present"}], ) ) result = self.execute_module(changed=True) diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py index e0011c15f..a4f4fe8af 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vxlan_vtep +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -49,15 +51,11 @@ def tearDown(self): self.mock_load_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "nxos_vxlan_vtep", "config.cfg" - ) + self.get_config.return_value = load_fixture("nxos_vxlan_vtep", "config.cfg") self.load_config.return_value = None def test_nxos_vxlan_vtep(self): - set_module_args( - dict(interface="nve1", description="simple description") - ) + set_module_args(dict(interface="nve1", description="simple description")) self.execute_module( changed=True, commands=[ diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py index a844d4b8f..eccb86dbc 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py @@ -19,10 +19,12 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.plugins.modules import nxos_vxlan_vtep_vni +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + from .nxos_module import TestNxosModule, load_fixture, set_module_args @@ -49,9 +51,7 @@ def tearDown(self): self.mock_load_config.stop() def load_fixtures(self, commands=None, device=""): - self.get_config.return_value = load_fixture( - "nxos_vxlan_vtep_vni", "config.cfg" - ) + self.get_config.return_value = load_fixture("nxos_vxlan_vtep_vni", "config.cfg") self.load_config.return_value = None def test_nxos_vxlan_vtep_vni_present_no_change(self): @@ -60,15 +60,11 @@ def test_nxos_vxlan_vtep_vni_present_no_change(self): def test_nxos_vxlan_vtep_vni(self): set_module_args(dict(interface="nve1", vni=5000)) - self.execute_module( - changed=True, commands=["interface nve1", "member vni 5000"] - ) + self.execute_module(changed=True, commands=["interface nve1", "member vni 5000"]) def test_nxos_vxlan_vtep_vni_absent(self): set_module_args(dict(interface="nve1", vni=6000, state="absent")) - self.execute_module( - changed=True, commands=["interface nve1", "no member vni 6000"] - ) + self.execute_module(changed=True, commands=["interface nve1", "no member vni 6000"]) def test_nxos_vxlan_vtep_vni_absent_no_change(self): set_module_args(dict(interface="nve2", vni=6000, state="absent")) diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py index dbfae7649..54f145f36 100644 --- a/tests/unit/modules/utils.py +++ b/tests/unit/modules/utils.py @@ -1,13 +1,15 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import json -from ansible_collections.cisco.nxos.tests.unit.compat import unittest -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible.module_utils import basic from ansible.module_utils._text import to_bytes +from ansible_collections.cisco.nxos.tests.unit.compat import unittest +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + def set_module_args(args): if "_ansible_remote_tmp" not in args: diff --git a/tox.ini b/tox.ini index a46d4a0c9..6ada631cb 100644 --- a/tox.ini +++ b/tox.ini @@ -10,12 +10,12 @@ deps = -r{toxinidir}/requirements.txt [testenv:black] install_command = pip install {opts} {packages} commands = - black -v -l79 {toxinidir} + black -v {toxinidir} [testenv:linters] install_command = pip install {opts} {packages} commands = - black -v -l79 --diff --check {toxinidir} + black -v --diff --check {toxinidir} flake8 {posargs} [testenv:venv] From 2ba91f694981606efe1dd2b2bc463fa9345fd2cc Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 2 Jun 2022 06:42:40 -0700 Subject: [PATCH 011/166] Add ansible-lint github action (#522) --- .github/workflows/test.yml | 2 ++ changelogs/fragments/522.yaml | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/522.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12a7ea846..7bd3729be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,8 @@ on: workflow_dispatch: jobs: + ansible-lint: + uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main changelog: uses: ansible-network/github_actions/.github/workflows/changelog.yml@main sanity: diff --git a/changelogs/fragments/522.yaml b/changelogs/fragments/522.yaml new file mode 100644 index 000000000..c511f13e5 --- /dev/null +++ b/changelogs/fragments/522.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Enable ansible-lint Github action for integration tests From 1deb2f4af9b9791105127d0dbe1ab529d7fcd3ed Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 2 Jun 2022 09:35:51 -0700 Subject: [PATCH 012/166] Require lint (#523) * Require lint * Changelog --- .github/workflows/test.yml | 2 ++ changelogs/fragments/523.yaml | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/523.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bd3729be..1fcf4c9a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,7 @@ jobs: all_green: if: ${{ always() }} needs: + - ansible-lint - changelog - sanity - unit-galaxy @@ -36,6 +37,7 @@ jobs: steps: - run: >- python -c "assert set([ + '${{ needs.ansible-lint.result }}', '${{ needs.changelog.result }}', '${{ needs.sanity.result }}', '${{ needs.unit-galaxy.result }}', diff --git a/changelogs/fragments/523.yaml b/changelogs/fragments/523.yaml new file mode 100644 index 000000000..0167ca5ce --- /dev/null +++ b/changelogs/fragments/523.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Require ansible-lint in all_green From 1d03f64fab0e14ed7af1a61859abab87209e2200 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 2 Jun 2022 14:13:53 -0700 Subject: [PATCH 013/166] Enable trailing comma in pre-commit (#521) * Enable trailing comma in pre-commit --- .pre-commit-config.yaml | 5 + changelogs/fragments/521.yaml | 3 + plugins/action/nxos.py | 18 +- plugins/cliconf/nxos.py | 21 +- plugins/httpapi/nxos.py | 7 +- .../network/nxos/argspec/acls/acls.py | 4 +- .../bgp_address_family/bgp_address_family.py | 4 +- .../nxos/argspec/bgp_global/bgp_global.py | 8 +- .../bgp_neighbor_address_family.py | 4 +- .../network/nxos/argspec/lacp/lacp.py | 2 +- .../argspec/logging_global/logging_global.py | 4 +- .../network/nxos/argspec/ospfv2/ospfv2.py | 24 +- .../network/nxos/argspec/ospfv3/ospfv3.py | 20 +- .../nxos/argspec/route_maps/route_maps.py | 12 +- .../nxos/argspec/snmp_server/snmp_server.py | 4 +- .../config/acl_interfaces/acl_interfaces.py | 10 +- .../network/nxos/config/acls/acls.py | 23 +- .../config/bfd_interfaces/bfd_interfaces.py | 8 +- .../bgp_address_family/bgp_address_family.py | 2 +- .../nxos/config/bgp_global/bgp_global.py | 8 +- .../config/hsrp_interfaces/hsrp_interfaces.py | 8 +- .../nxos/config/interfaces/interfaces.py | 15 +- .../config/l2_interfaces/l2_interfaces.py | 8 +- .../config/l3_interfaces/l3_interfaces.py | 11 +- .../network/nxos/config/lacp/lacp.py | 8 +- .../config/lacp_interfaces/lacp_interfaces.py | 10 +- .../config/lag_interfaces/lag_interfaces.py | 8 +- .../nxos/config/lldp_global/lldp_global.py | 10 +- .../config/lldp_interfaces/lldp_interfaces.py | 6 +- .../config/logging_global/logging_global.py | 2 +- .../nxos/config/prefix_lists/prefix_lists.py | 7 +- .../config/static_routes/static_routes.py | 50 +- .../nxos/config/telemetry/telemetry.py | 34 +- .../network/nxos/config/vlans/vlans.py | 8 +- .../network/nxos/facts/acls/acls.py | 4 +- .../nxos/facts/bgp_global/bgp_global.py | 2 +- .../network/nxos/facts/hostname/hostname.py | 2 +- .../nxos/facts/interfaces/interfaces.py | 4 +- .../nxos/facts/l2_interfaces/l2_interfaces.py | 3 +- .../network/nxos/facts/legacy/base.py | 14 +- .../facts/lldp_interfaces/lldp_interfaces.py | 3 +- .../facts/logging_global/logging_global.py | 6 +- .../nxos/facts/ntp_global/ntp_global.py | 5 +- .../facts/ospf_interfaces/ospf_interfaces.py | 9 +- .../network/nxos/facts/ospfv3/ospfv3.py | 2 +- .../nxos/facts/prefix_lists/prefix_lists.py | 2 +- .../nxos/facts/route_maps/route_maps.py | 2 +- .../nxos/facts/snmp_server/snmp_server.py | 8 +- .../network/nxos/facts/telemetry/telemetry.py | 2 +- plugins/module_utils/network/nxos/nxos.py | 18 +- .../nxos/rm_templates/bgp_address_family.py | 208 ++--- .../network/nxos/rm_templates/bgp_global.py | 730 +++++++++--------- .../bgp_neighbor_address_family.py | 446 +++++------ .../network/nxos/rm_templates/hostname.py | 3 +- .../nxos/rm_templates/logging_global.py | 114 +-- .../network/nxos/rm_templates/ntp_global.py | 91 ++- .../nxos/rm_templates/ospf_interfaces.py | 132 ++-- .../network/nxos/rm_templates/ospfv2.py | 256 +++--- .../network/nxos/rm_templates/ospfv3.py | 198 ++--- .../network/nxos/rm_templates/prefix_lists.py | 16 +- .../network/nxos/rm_templates/route_maps.py | 637 ++++++++------- .../network/nxos/rm_templates/snmp_server.py | 550 +++++++------ .../network/nxos/utils/telemetry/telemetry.py | 2 +- plugins/modules/nxos_aaa_server_host.py | 3 +- plugins/modules/nxos_acl_interface.py | 2 +- plugins/modules/nxos_banner.py | 2 +- plugins/modules/nxos_bgp.py | 3 +- plugins/modules/nxos_bgp_af.py | 15 +- plugins/modules/nxos_bgp_neighbor.py | 2 +- plugins/modules/nxos_bgp_neighbor_af.py | 16 +- plugins/modules/nxos_command.py | 2 +- plugins/modules/nxos_config.py | 4 +- plugins/modules/nxos_gir.py | 20 +- plugins/modules/nxos_hsrp.py | 6 +- plugins/modules/nxos_igmp_interface.py | 9 +- plugins/modules/nxos_interface.py | 18 +- plugins/modules/nxos_interface_ospf.py | 10 +- plugins/modules/nxos_l2_interface.py | 10 +- plugins/modules/nxos_l3_interface.py | 2 +- plugins/modules/nxos_linkagg.py | 10 +- plugins/modules/nxos_lldp.py | 2 +- plugins/modules/nxos_logging.py | 51 +- plugins/modules/nxos_ntp.py | 2 +- plugins/modules/nxos_ntp_auth.py | 4 +- plugins/modules/nxos_nxapi.py | 8 +- plugins/modules/nxos_pim.py | 2 +- plugins/modules/nxos_pim_interface.py | 15 +- plugins/modules/nxos_rollback.py | 2 +- plugins/modules/nxos_rpm.py | 2 +- plugins/modules/nxos_snapshot.py | 12 +- plugins/modules/nxos_snmp_host.py | 22 +- plugins/modules/nxos_snmp_user.py | 2 +- plugins/modules/nxos_static_route.py | 2 +- plugins/modules/nxos_user.py | 6 +- plugins/modules/nxos_vlan.py | 8 +- plugins/modules/nxos_vpc.py | 8 +- plugins/modules/nxos_vpc_interface.py | 4 +- plugins/modules/nxos_vrf.py | 4 +- plugins/modules/nxos_vrf_interface.py | 4 +- plugins/modules/nxos_vtp_password.py | 2 +- plugins/modules/nxos_vxlan_vtep.py | 4 +- plugins/modules/nxos_vxlan_vtep_vni.py | 8 +- plugins/modules/storage/nxos_devicealias.py | 26 +- plugins/modules/storage/nxos_vsan.py | 18 +- plugins/modules/storage/nxos_zone_zoneset.py | 77 +- plugins/terminal/nxos.py | 6 +- tests/unit/mock/yaml_helper.py | 8 +- .../nxos/storage/test_nxos_devicealias.py | 17 +- .../network/nxos/storage/test_nxos_vsan.py | 14 +- .../nxos/storage/test_nxos_zone_zoneset.py | 212 +++-- tests/unit/modules/network/nxos/test_nxos.py | 2 +- .../modules/network/nxos/test_nxos_acl.py | 6 +- .../network/nxos/test_nxos_acl_interface.py | 6 +- .../network/nxos/test_nxos_acl_interfaces.py | 82 +- .../modules/network/nxos/test_nxos_acls.py | 104 +-- .../modules/network/nxos/test_nxos_banner.py | 4 +- .../network/nxos/test_nxos_bfd_global.py | 26 +- .../network/nxos/test_nxos_bfd_interfaces.py | 24 +- .../modules/network/nxos/test_nxos_bgp.py | 8 +- .../nxos/test_nxos_bgp_address_family.py | 134 ++-- .../modules/network/nxos/test_nxos_bgp_af.py | 10 +- .../network/nxos/test_nxos_bgp_global.py | 68 +- .../network/nxos/test_nxos_bgp_neighbor.py | 4 +- .../test_nxos_bgp_neighbor_address_family.py | 332 ++++---- .../network/nxos/test_nxos_bgp_neighbor_af.py | 24 +- .../modules/network/nxos/test_nxos_command.py | 2 +- .../modules/network/nxos/test_nxos_config.py | 32 +- .../network/nxos/test_nxos_evpn_global.py | 6 +- .../network/nxos/test_nxos_evpn_vni.py | 4 +- .../modules/network/nxos/test_nxos_feature.py | 16 +- .../network/nxos/test_nxos_hostname.py | 20 +- .../modules/network/nxos/test_nxos_hsrp.py | 10 +- .../network/nxos/test_nxos_hsrp_interfaces.py | 24 +- .../network/nxos/test_nxos_interface.py | 4 +- .../network/nxos/test_nxos_interface_ospf.py | 16 +- .../network/nxos/test_nxos_interfaces.py | 52 +- .../network/nxos/test_nxos_l3_interface.py | 22 +- .../network/nxos/test_nxos_l3_interfaces.py | 52 +- .../network/nxos/test_nxos_lacp_interfaces.py | 14 +- .../network/nxos/test_nxos_lldp_interfaces.py | 32 +- .../network/nxos/test_nxos_logging_global.py | 64 +- .../network/nxos/test_nxos_ntp_global.py | 42 +- .../modules/network/nxos/test_nxos_nxapi.py | 11 +- .../modules/network/nxos/test_nxos_ospf.py | 4 +- .../network/nxos/test_nxos_ospf_interfaces.py | 124 +-- .../network/nxos/test_nxos_ospf_vrf.py | 8 +- .../modules/network/nxos/test_nxos_ospfv2.py | 48 +- .../modules/network/nxos/test_nxos_ospfv3.py | 322 ++++---- .../network/nxos/test_nxos_overlay_global.py | 4 +- .../modules/network/nxos/test_nxos_pim.py | 4 +- .../network/nxos/test_nxos_pim_interface.py | 22 +- .../network/nxos/test_nxos_pim_rp_address.py | 4 +- .../modules/network/nxos/test_nxos_ping.py | 28 +- .../network/nxos/test_nxos_prefix_lists.py | 56 +- .../network/nxos/test_nxos_route_maps.py | 70 +- .../network/nxos/test_nxos_snmp_server.py | 70 +- .../network/nxos/test_nxos_static_route.py | 8 +- .../network/nxos/test_nxos_static_routes.py | 150 ++-- .../modules/network/nxos/test_nxos_system.py | 8 +- .../network/nxos/test_nxos_telemetry.py | 66 +- .../modules/network/nxos/test_nxos_user.py | 14 +- .../modules/network/nxos/test_nxos_vlan.py | 24 +- .../modules/network/nxos/test_nxos_vlans.py | 18 +- .../modules/network/nxos/test_nxos_vpc.py | 16 +- .../network/nxos/test_nxos_vpc_interface.py | 6 +- .../modules/network/nxos/test_nxos_vrf.py | 4 +- .../modules/network/nxos/test_nxos_vrf_af.py | 102 +-- .../network/nxos/test_nxos_vxlan_vtep.py | 8 +- .../network/nxos/test_nxos_vxlan_vtep_vni.py | 10 +- tests/unit/modules/utils.py | 4 +- 170 files changed, 3680 insertions(+), 3310 deletions(-) create mode 100644 changelogs/fragments/521.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e5c026a3..d521ca13f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,11 @@ repos: args: [--branch, main] - id: trailing-whitespace + - repo: https://github.com/asottile/add-trailing-comma + rev: v2.2.3 + hooks: + - id: add-trailing-comma + - repo: https://github.com/pre-commit/mirrors-prettier rev: "v2.6.2" hooks: diff --git a/changelogs/fragments/521.yaml b/changelogs/fragments/521.yaml new file mode 100644 index 000000000..8a76a14f4 --- /dev/null +++ b/changelogs/fragments/521.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Enable trailing comma in pre-commit diff --git a/plugins/action/nxos.py b/plugins/action/nxos.py index 184f816ae..36bd2a155 100644 --- a/plugins/action/nxos.py +++ b/plugins/action/nxos.py @@ -101,10 +101,10 @@ def run(self, tmp=None, task_vars=None): msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT" msg += " must be set to 600 seconds or higher when using nxos_install_os module." msg += " Current persistent_command_timeout setting:" + str( - persistent_command_timeout + persistent_command_timeout, ) msg += " Current persistent_connect_timeout setting:" + str( - persistent_connect_timeout + persistent_connect_timeout, ) return {"failed": True, "msg": msg} @@ -113,7 +113,7 @@ def run(self, tmp=None, task_vars=None): if any(provider.values()): display.warning( "provider is unnecessary when using %s and will be ignored" - % self._play_context.connection + % self._play_context.connection, ) del self._task.args["provider"] @@ -161,7 +161,10 @@ def run(self, tmp=None, task_vars=None): pc.connection = "network_cli" pc.network_os = "nxos" connection = self._shared_loader_obj.connection_loader.get( - "persistent", pc, sys.stdin, task_uuid=self._task._uuid + "persistent", + pc, + sys.stdin, + task_uuid=self._task._uuid, ) display.vvv( @@ -189,13 +192,14 @@ def run(self, tmp=None, task_vars=None): else: self._task.args["provider"] = ActionModule.nxapi_implementation( - provider, self._play_context + provider, + self._play_context, ) warnings.append( [ "connection local support for this module is deprecated and will be removed in version 2.14," - " use connection either httpapi or ansible.netcommon.httpapi (whichever is applicable)" - ] + " use connection either httpapi or ansible.netcommon.httpapi (whichever is applicable)", + ], ) else: return { diff --git a/plugins/cliconf/nxos.py b/plugins/cliconf/nxos.py index 758cc41ab..d6a3fbffe 100644 --- a/plugins/cliconf/nxos.py +++ b/plugins/cliconf/nxos.py @@ -113,7 +113,9 @@ def get_device_info(self): device_info["network_os_image"] = match_isan_file_name.group(1) else: match_kick_file_name = re.search( - r"\s+kickstart image file is:\s*(\S+)", reply, re.M + r"\s+kickstart image file is:\s*(\S+)", + reply, + re.M, ) if match_kick_file_name: device_info["network_os_image"] = match_kick_file_name.group(1) @@ -154,13 +156,13 @@ def get_diff( if diff_match not in option_values["diff_match"]: raise ValueError( "'match' value %s in invalid, valid values are %s" - % (diff_match, ", ".join(option_values["diff_match"])) + % (diff_match, ", ".join(option_values["diff_match"])), ) if diff_replace not in option_values["diff_replace"]: raise ValueError( "'replace' value %s in invalid, valid values are %s" - % (diff_replace, ", ".join(option_values["diff_replace"])) + % (diff_replace, ", ".join(option_values["diff_replace"])), ) # prepare candidate configuration @@ -171,7 +173,10 @@ def get_diff( # running configuration running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) configdiffobjs = candidate_obj.difference( - running_obj, path=path, match=diff_match, replace=diff_replace + running_obj, + path=path, + match=diff_match, + replace=diff_replace, ) else: @@ -185,7 +190,7 @@ def get_config(self, source="running", format="text", flags=None): if format not in options_values["format"]: raise ValueError( "'format' value %s is invalid. Valid values are %s" - % (format, ",".join(options_values["format"])) + % (format, ",".join(options_values["format"])), ) lookup = {"running": "running-config", "startup": "startup-config"} @@ -281,7 +286,7 @@ def run_commands(self, commands=None, check_rc=True): out = to_text(out, errors="surrogate_or_strict").strip() except UnicodeError: raise ConnectionError( - message="Failed to decode output from %s: %s" % (cmd, to_text(out)) + message="Failed to decode output from %s: %s" % (cmd, to_text(out)), ) try: @@ -389,7 +394,7 @@ def set_cli_prompt_context(self): if out is None: raise AnsibleConnectionFailure( message="cli prompt is not identified from the last received" - " response window: %s" % self._connection._last_recv_window + " response window: %s" % self._connection._last_recv_window, ) # Match prompts ending in )# except those with (maint-mode)# config_prompt = re.compile(r"^.*\((?!maint-mode).*\)#$") @@ -404,7 +409,7 @@ def _get_command_with_output(self, command, output): if output not in options_values["output"]: raise ValueError( "'output' value %s is invalid. Valid values are %s" - % (output, ",".join(options_values["output"])) + % (output, ",".join(options_values["output"])), ) if output == "json" and not command.endswith("| json"): diff --git a/plugins/httpapi/nxos.py b/plugins/httpapi/nxos.py index 19b623d17..57421e835 100644 --- a/plugins/httpapi/nxos.py +++ b/plugins/httpapi/nxos.py @@ -95,14 +95,17 @@ def _run_queue(self, queue, output): headers = {"Content-Type": "application/json"} response, response_data = self.connection.send( - "/ins", request, headers=headers, method="POST" + "/ins", + request, + headers=headers, + method="POST", ) try: response_data = json.loads(to_text(response_data.getvalue())) except ValueError: raise ConnectionError( - "Response was not valid JSON, got {0}".format(to_text(response_data.getvalue())) + "Response was not valid JSON, got {0}".format(to_text(response_data.getvalue())), ) results = handle_response(response_data) diff --git a/plugins/module_utils/network/nxos/argspec/acls/acls.py b/plugins/module_utils/network/nxos/argspec/acls/acls.py index 1c1b2d49a..f0f17944a 100644 --- a/plugins/module_utils/network/nxos/argspec/acls/acls.py +++ b/plugins/module_utils/network/nxos/argspec/acls/acls.py @@ -66,7 +66,7 @@ class AclsArgs(object): # pylint: disable=R0903 "neq", "gt", "range", - ] + ], ], "options": { "eq": {"type": "str"}, @@ -160,7 +160,7 @@ class AclsArgs(object): # pylint: disable=R0903 "dvmrp", "host_query", "host_report", - ] + ], ], "options": { "dvmrp": {"type": "bool"}, diff --git a/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py index 10c9ddec6..f77843d79 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_address_family/bgp_address_family.py @@ -205,7 +205,7 @@ class Bgp_address_familyArgs(object): # pylint: disable=R0903 "retain_all": {"type": "bool"}, "route_map": {"type": "str"}, }, - } + }, }, }, "suppress_inactive": {"type": "bool"}, @@ -225,7 +225,7 @@ class Bgp_address_familyArgs(object): # pylint: disable=R0903 "defer_time": {"type": "int"}, "maximum_defer_time": {"type": "int"}, }, - } + }, }, }, "wait_igp_convergence": {"type": "bool"}, diff --git a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py index f476512f9..d47f7e429 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py @@ -176,7 +176,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "set": {"type": "bool"}, "route_map": {"type": "str"}, }, - } + }, }, }, "inherit": { @@ -257,7 +257,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "connection_mode": { "type": "dict", "options": {"passive": {"type": "bool"}}, - } + }, }, }, "ttl_security": { @@ -411,7 +411,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "set": {"type": "bool"}, "route_map": {"type": "str"}, }, - } + }, }, }, "inherit": { @@ -492,7 +492,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "connection_mode": { "type": "dict", "options": {"passive": {"type": "bool"}}, - } + }, }, }, "ttl_security": { diff --git a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 4dcffe7b9..4c97d2946 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -108,7 +108,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 ], }, }, - } + }, }, }, "default_originate": { @@ -275,7 +275,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 ], }, }, - } + }, }, }, "default_originate": { diff --git a/plugins/module_utils/network/nxos/argspec/lacp/lacp.py b/plugins/module_utils/network/nxos/argspec/lacp/lacp.py index f5965aaa9..3c2ac06a3 100644 --- a/plugins/module_utils/network/nxos/argspec/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/argspec/lacp/lacp.py @@ -52,7 +52,7 @@ class LacpArgs(object): "priority": {"type": "int"}, }, "type": "dict", - } + }, }, "type": "dict", }, diff --git a/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py b/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py index 340374458..58a9052f1 100644 --- a/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/argspec/logging_global/logging_global.py @@ -116,7 +116,7 @@ class Logging_globalArgs(object): # pylint: disable=R0903 "options": {"sgt": {"type": "bool"}}, }, }, - } + }, }, }, "facilities": { @@ -247,7 +247,7 @@ class Logging_globalArgs(object): # pylint: disable=R0903 "trustpoint": { "type": "dict", "options": {"client_identity": {"type": "str"}}, - } + }, }, }, "use_vrf": {"type": "str"}, diff --git a/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py b/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py index d03320b01..2e5e62f12 100644 --- a/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/nxos/argspec/ospfv2/ospfv2.py @@ -51,7 +51,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "nssa", "ranges", "stub", - ] + ], ], "elements": "dict", "options": { @@ -95,7 +95,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "supress_fa": {"type": "bool"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -148,7 +148,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "set": {"type": "bool"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -215,7 +215,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 }, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -233,7 +233,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "router_id": {"type": "str"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -325,7 +325,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "nssa", "ranges", "stub", - ] + ], ], "elements": "dict", "options": { @@ -369,7 +369,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 [ "always", "never", - ] + ], ], "options": { "always": {"type": "bool"}, @@ -377,7 +377,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "supress_fa": {"type": "bool"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -430,7 +430,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "set": {"type": "bool"}, "evpn": {"type": "bool"}, }, - } + }, }, }, "default_information": { @@ -442,7 +442,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "set": {"type": "bool"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -508,7 +508,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 }, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -602,7 +602,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 }, }, "type": "list", - } + }, }, "type": "dict", }, diff --git a/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py index ba9f19d2d..601bb618f 100644 --- a/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/argspec/ospfv3/ospfv3.py @@ -99,7 +99,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "always": {"type": "bool"}, "route_map": {"type": "str"}, }, - } + }, }, }, "distance": {"type": "int"}, @@ -164,9 +164,9 @@ class Ospfv3Args(object): # pylint: disable=R0903 "min_hold_time": {"type": "int"}, "max_wait_time": {"type": "int"}, }, - } + }, }, - } + }, }, }, }, @@ -194,7 +194,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "never": {"type": "bool"}, "supress_fa": {"type": "bool"}, }, - } + }, }, }, }, @@ -285,7 +285,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 }, }, }, - } + }, }, }, "name_lookup": {"type": "bool"}, @@ -311,7 +311,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "hold_interval": {"type": "int"}, "max_interval": {"type": "int"}, }, - } + }, }, }, }, @@ -346,7 +346,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "never": {"type": "bool"}, "supress_fa": {"type": "bool"}, }, - } + }, }, }, }, @@ -435,7 +435,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 }, }, }, - } + }, }, }, "name_lookup": {"type": "bool"}, @@ -460,7 +460,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 "hold_interval": {"type": "int"}, "max_interval": {"type": "int"}, }, - } + }, }, }, }, @@ -469,7 +469,7 @@ class Ospfv3Args(object): # pylint: disable=R0903 }, }, }, - } + }, }, }, "state": { diff --git a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py index 5b28c49c6..25e40d6bc 100644 --- a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py @@ -82,7 +82,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "route_types": { "type": "list", "elements": "str", - } + }, }, }, "extcommunity": { @@ -148,7 +148,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "prefix_lists": { "type": "list", "elements": "str", - } + }, }, }, "route_source": { @@ -157,7 +157,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "prefix_lists": { "type": "list", "elements": "str", - } + }, }, }, }, @@ -211,7 +211,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "prefix_lists": { "type": "list", "elements": "str", - } + }, }, }, "route_source": { @@ -220,7 +220,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "prefix_lists": { "type": "list", "elements": "str", - } + }, }, }, }, @@ -319,7 +319,7 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "ip": {"type": "str"}, "use_nexthop": {"type": "bool"}, }, - } + }, }, }, "extcomm_list": {"type": "str"}, diff --git a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py index 4570d0af3..a6b3d4201 100644 --- a/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/argspec/snmp_server/snmp_server.py @@ -71,7 +71,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "enable": {"type": "bool"}, "timeout": {"type": "int"}, }, - } + }, }, }, "drop": { @@ -318,7 +318,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "community": {"type": "str"}, "context": {"type": "str"}, }, - } + }, }, }, "packetsize": {"type": "int"}, diff --git a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py index 883b64bcc..6c0b3b939 100644 --- a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py @@ -52,7 +52,9 @@ def get_acl_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) acl_interfaces_facts = facts["ansible_network_resources"].get("acl_interfaces") if not acl_interfaces_facts: @@ -86,7 +88,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.set_config({}) # no need to fetch facts for parsed @@ -120,7 +122,7 @@ def set_config(self, existing_acl_interfaces_facts): for w in config: if get_interface_type(w["name"]) == "loopback": self._module.fail_json( - msg="This module works with ethernet, management or port-channe" + msg="This module works with ethernet, management or port-channe", ) w.update({"name": normalize_interface(w["name"])}) want.append(remove_empties(w)) @@ -139,7 +141,7 @@ def set_state(self, want, have): """ if self.state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) commands = [] diff --git a/plugins/module_utils/network/nxos/config/acls/acls.py b/plugins/module_utils/network/nxos/config/acls/acls.py index 0ab27d611..0d620a607 100644 --- a/plugins/module_utils/network/nxos/config/acls/acls.py +++ b/plugins/module_utils/network/nxos/config/acls/acls.py @@ -57,7 +57,9 @@ def get_acls_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) acls_facts = facts["ansible_network_resources"].get("acls") if not acls_facts: @@ -419,7 +421,9 @@ def _state_deleted(self, want, have): for acl in w["acls"]: if "aces" in acl.keys() and self.state != "deleted": have_name = search_obj_in_list( - acl["name"], have_afi["acls"], "name" + acl["name"], + have_afi["acls"], + "name", ) if have_name: ace_commands = [] @@ -431,7 +435,7 @@ def _state_deleted(self, want, have): for h_ace in have_name["aces"]: if h_ace["sequence"] == ace["sequence"]: ace_commands.append( - "no " + str(ace["sequence"]) + "no " + str(ace["sequence"]), ) flag = 1 else: @@ -442,7 +446,7 @@ def _state_deleted(self, want, have): del h_ace["sequence"] if ace == h_ace: ace_commands.append( - "no " + self.process_ace(ace) + "no " + self.process_ace(ace), ) flag = 1 if flag: @@ -554,10 +558,10 @@ def set_commands(self, want, have): { "name": name, "aces": ace_list, - } + }, ], - } - ] + }, + ], }, ) if "sequence" in w.keys() and w["sequence"] in common_seq: @@ -573,8 +577,9 @@ def set_commands(self, want, have): self._module.fail_json( msg="Cannot update existing ACE {0} of ACL {1} with state merged." " Please use state replaced or overridden.".format( - name, w["sequence"] - ) + name, + w["sequence"], + ), ) elif w_acl.get("aces"): # 'have' has ACL defined without any ACE diff --git a/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py b/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py index 33eb7da68..a9dc51fd9 100644 --- a/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py +++ b/plugins/module_utils/network/nxos/config/bfd_interfaces/bfd_interfaces.py @@ -51,7 +51,9 @@ def get_bfd_interfaces_facts(self, data=None): if self.state not in self.ACTION_STATES: self.gather_subset = ["!all", "!min"] facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) bfd_interfaces_facts = facts["ansible_network_resources"].get("bfd_interfaces", []) @@ -103,7 +105,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"], platform = self.get_bfd_interfaces_facts(data=running_config) @@ -158,7 +160,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) cmds = list() diff --git a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py index e4ecae678..4de52705b 100644 --- a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py @@ -247,7 +247,7 @@ def _remove_af(self, want_af, have_af, vrf=None, remove=False, purge=False): (remove and k in want_af), (not remove and k not in want_af), purge, - ) + ), ): self.addcmd(v, "address_family", True) if cur_ptr < len(self.commands) and vrf: diff --git a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py index c16ed3f8a..c174d790d 100644 --- a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py @@ -123,7 +123,7 @@ def generate_commands(self): self._module.fail_json( msg="BGP is already configured with ASN {0}. " "Please remove it with state purged before " - "configuring new ASN".format(h_asn) + "configuring new ASN".format(h_asn), ) if self.state in ["deleted", "replaced"]: @@ -247,7 +247,9 @@ def _compare_neighbors(self, want, have, vrf=None): if self._has_af(vrf=vrf, neighbor=name): self._module.fail_json( msg="Neighbor {0} has address-family configurations. " - "Please use the nxos_bgp_neighbor_af module to remove those first.".format(name) + "Please use the nxos_bgp_neighbor_af module to remove those first.".format( + name, + ), ) else: self.addcmd(entry, "neighbor_address", True) @@ -288,7 +290,7 @@ def _vrfs_compare(self, want, have): if self._has_af(vrf=name): self._module.fail_json( msg="VRF {0} has address-family configurations. " - "Please use the nxos_bgp_af module to remove those first.".format(name) + "Please use the nxos_bgp_af module to remove those first.".format(name), ) else: self.addcmd(entry, "vrf", True) diff --git a/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py b/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py index 749266f48..481578d04 100644 --- a/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py @@ -52,7 +52,9 @@ def get_hsrp_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) hsrp_interfaces_facts = facts["ansible_network_resources"].get("hsrp_interfaces", []) return hsrp_interfaces_facts @@ -96,7 +98,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_hsrp_interfaces_facts(data=running_config) @@ -142,7 +144,7 @@ def set_state(self, want, have): # check for 'config' keyword in play if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) cmds = list() diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index 3a23e9eb4..05aa0187c 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -62,7 +62,9 @@ def get_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ self.facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) interfaces_facts = self.facts["ansible_network_resources"].get("interfaces") @@ -103,7 +105,8 @@ def execute_module(self): if self.state in self.ACTION_STATES: self.intf_defs = self.render_interface_defaults( - self.get_system_defaults(), existing_interfaces_facts + self.get_system_defaults(), + existing_interfaces_facts, ) commands.extend(self.set_config(existing_interfaces_facts)) @@ -115,7 +118,7 @@ def execute_module(self): "L2_enabled": False, "L3_enabled": False, "mode": "layer3", - } + }, } commands.extend(self.set_config(existing_interfaces_facts)) @@ -137,7 +140,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_interfaces_facts(data=running_config) @@ -182,7 +185,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() @@ -468,7 +471,7 @@ def render_interface_defaults(self, config, intfs): "mode": None, "L2_enabled": None, "L3_enabled": L3_enabled, - } + }, } pat = "(no )*system default switchport$" m = re.search(pat, config, re.MULTILINE) diff --git a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py index 4f2668b3d..e8580f189 100644 --- a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py @@ -58,7 +58,9 @@ def get_l2_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) l2_interfaces_facts = facts["ansible_network_resources"].get("l2_interfaces") if not l2_interfaces_facts: @@ -101,7 +103,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_l2_interfaces_facts(data=running_config) @@ -160,7 +162,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() diff --git a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py index 77f6d256a..808d78361 100644 --- a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py @@ -61,7 +61,9 @@ def get_l3_interfaces_facts(self, data=None): self.gather_subset = ["!all", "!min"] facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) l3_interfaces_facts = facts["ansible_network_resources"].get("l3_interfaces") @@ -108,7 +110,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_l3_interfaces_facts(data=running_config) @@ -154,7 +156,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = [] @@ -398,7 +400,8 @@ def generate_delete_commands(self, obj): commands.append("no encapsulation dot1q") if "redirects" in obj: if not self.check_existing(name, "has_secondary") or re.match( - "N[35679]", self.platform + "N[35679]", + self.platform, ): # device auto-enables redirects when secondaries are removed; # auto-enable may fail on legacy platforms so always do explicit enable diff --git a/plugins/module_utils/network/nxos/config/lacp/lacp.py b/plugins/module_utils/network/nxos/config/lacp/lacp.py index 862cdb006..4d334badb 100644 --- a/plugins/module_utils/network/nxos/config/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/config/lacp/lacp.py @@ -48,7 +48,9 @@ def get_lacp_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lacp_facts = facts["ansible_network_resources"].get("lacp", {}) @@ -90,7 +92,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lacp_facts(data=running_config) @@ -130,7 +132,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() diff --git a/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py b/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py index 4c4e59721..eaad0763d 100644 --- a/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lacp_interfaces/lacp_interfaces.py @@ -54,7 +54,9 @@ def get_lacp_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lacp_interfaces_facts = facts["ansible_network_resources"].get("lacp_interfaces") if not lacp_interfaces_facts: @@ -97,7 +99,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lacp_interfaces_facts(data=running_config) @@ -129,7 +131,7 @@ def set_config(self, existing_lacp_interfaces_facts): "ethernet", ): self._module.fail_json( - msg="This module works with either portchannel or ethernet" + msg="This module works with either portchannel or ethernet", ) w.update({"name": normalize_interface(w["name"])}) want.append(remove_empties(w)) @@ -149,7 +151,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() diff --git a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py index 1edf64fa3..495244b41 100644 --- a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py @@ -50,7 +50,9 @@ def get_lag_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lag_interfaces_facts = facts["ansible_network_resources"].get("lag_interfaces") if not lag_interfaces_facts: @@ -99,7 +101,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lag_interfaces_facts(data=running_config) @@ -145,7 +147,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() diff --git a/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py b/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py index cfbe9af73..68d986212 100644 --- a/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py @@ -45,7 +45,9 @@ def get_lldp_global_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lldp_global_facts = facts["ansible_network_resources"].get("lldp_global") if not lldp_global_facts: @@ -88,7 +90,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lldp_global_facts(data=running_config) @@ -128,7 +130,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() @@ -187,7 +189,7 @@ def find_delete_params(self, have, want): else: if key == "tlv_select": delete_dict.update( - {key: self.delete_nested_dict(have["tlv_select"], want["tlv_select"])} + {key: self.delete_nested_dict(have["tlv_select"], want["tlv_select"])}, ) return delete_dict diff --git a/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py index 40ebba28f..528f74970 100644 --- a/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lldp_interfaces/lldp_interfaces.py @@ -52,7 +52,9 @@ def get_lldp_interfaces_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lldp_interfaces_facts = facts["ansible_network_resources"].get("lldp_interfaces") if not lldp_interfaces_facts: @@ -119,7 +121,7 @@ def set_config(self, existing_lldp_interfaces_facts): "ethernet", ): self._module.fail_json( - msg="This module works with either management or ethernet" + msg="This module works with either management or ethernet", ) w.update({"name": normalize_interface(w["name"])}) want.append(remove_empties(w)) diff --git a/plugins/module_utils/network/nxos/config/logging_global/logging_global.py b/plugins/module_utils/network/nxos/config/logging_global/logging_global.py index 91fe7ff29..6e493ad36 100644 --- a/plugins/module_utils/network/nxos/config/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/config/logging_global/logging_global.py @@ -115,7 +115,7 @@ def generate_commands(self): self.state in self._state_set, have_k is False, want_k is None, - ) + ), ): # if want is missing and have is negated # set want to True in order to revert to default state diff --git a/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py b/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py index fafa16591..2c6bb8142 100644 --- a/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/nxos/config/prefix_lists/prefix_lists.py @@ -111,7 +111,7 @@ def _compare(self, want, have): # remove remaining prefix lists for h in hplists.values(): self.commands.append( - "no {0} prefix-list {1}".format(h["afi"].replace("ipv4", "ip"), h["name"]) + "no {0} prefix-list {1}".format(h["afi"].replace("ipv4", "ip"), h["name"]), ) def _compare_seqs(self, want, have): @@ -123,8 +123,9 @@ def _compare_seqs(self, want, have): self._module.fail_json( msg="Cannot update existing sequence {0} of prefix list {1} with state merged." " Please use state replaced or overridden.".format( - hentry["sequence"], hentry["name"] - ) + hentry["sequence"], + hentry["name"], + ), ) else: self.addcmd(hentry, "entry", negate=True) diff --git a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py index 8df5cc42d..f6cfdaed4 100644 --- a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py @@ -54,7 +54,9 @@ def get_static_routes_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) static_routes_facts = facts["ansible_network_resources"].get("static_routes") if not static_routes_facts: @@ -188,7 +190,9 @@ def _state_replaced(self, want, have): for ro in h["routes"]: if ro["dest"] in want_dest_list: want_dest = search_obj_in_list( - ro["dest"], want_afi["routes"], "dest" + ro["dest"], + want_afi["routes"], + "dest", ) want_next_hops = [] if "next_hops" in want_dest.keys(): @@ -206,13 +210,13 @@ def _state_replaced(self, want, have): { "dest": ro["dest"], "next_hops": [next_hop], - } + }, ], - } + }, ], } delete_commands.extend( - self.del_commands([delete_dict]) + self.del_commands([delete_dict]), ) else: # want has no next_hops, so delete all next_hops under that dest @@ -226,9 +230,9 @@ def _state_replaced(self, want, have): { "dest": ro["dest"], "next_hops": ro["next_hops"], - } + }, ], - } + }, ], } delete_commands.extend(self.del_commands([delete_dict])) @@ -243,9 +247,9 @@ def _state_replaced(self, want, have): { "dest": ro["dest"], "next_hops": ro["next_hops"], - } + }, ], - } + }, ], } delete_commands.extend(self.del_commands([delete_dict])) @@ -261,7 +265,7 @@ def _state_replaced(self, want, have): { "afi": h["afi"], "routes": h["routes"], - } + }, ], } delete_commands.extend(self.del_commands([delete_dict])) @@ -275,9 +279,9 @@ def _state_replaced(self, want, have): { "address_families": list(obj_in_have["address_families"]), "vrf": obj_in_have["vrf"], - } - ] - ) + }, + ], + ), ) final_delete_commands = [] for d in delete_commands: @@ -367,9 +371,9 @@ def _state_deleted(self, want, have): { "dest": w2["dest"], "next_hops": hops, - } + }, ], - } + }, ], } commands.extend(self.del_commands([delete_dict])) @@ -381,7 +385,7 @@ def _state_deleted(self, want, have): { "afi": o2["afi"], "routes": o2["routes"], - } + }, ], } commands.extend(self.del_commands([delete_dict])) @@ -392,9 +396,9 @@ def _state_deleted(self, want, have): { "vrf": obj_in_have["vrf"], "address_families": [o2], - } - ] - ) + }, + ], + ), ) else: # only vrf given to delete @@ -499,7 +503,7 @@ def set_commands(self, want, have): for nh in ro["next_hops"]: if "interface" in nh.keys(): nh["interface"] = normalize_interface( - nh["interface"] + nh["interface"], ) if nh not in next_hop_list: # no match for next hop in have @@ -516,7 +520,11 @@ def set_commands(self, want, have): if "next_hops" in ro.keys(): for nh in ro["next_hops"]: commands = self.set_next_hop( - want, h2, nh, ro, commands + want, + h2, + nh, + ro, + commands, ) else: # no match for afi diff --git a/plugins/module_utils/network/nxos/config/telemetry/telemetry.py b/plugins/module_utils/network/nxos/config/telemetry/telemetry.py index 38749af58..da3f77439 100644 --- a/plugins/module_utils/network/nxos/config/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/config/telemetry/telemetry.py @@ -60,7 +60,9 @@ def get_telemetry_facts(self, data=None): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) telemetry_facts = facts["ansible_network_resources"].get("telemetry") if not telemetry_facts: @@ -187,7 +189,9 @@ def build_cmdref_objects(td): resource_key = td["cmd"].format(playvals["id"]) # Only build the NxosCmdRef object for the td['name'] module parameters. self._module.params["config"] = get_module_params_subsection( - ALL_MP, td["type"], playvals["id"] + ALL_MP, + td["type"], + playvals["id"], ) cmd_ref[td["type"]]["ref"].append(NxosCmdRef(self._module, td["obj"])) ref = cmd_ref[td["type"]]["ref"][-1] @@ -391,7 +395,7 @@ def _state_replaced(want, have): cmd = {} if item.get("data_source"): cmd["data_source"] = [ - setval["data_source"].format(item["data_source"]) + setval["data_source"].format(item["data_source"]), ] if item.get("path"): setval["path"] = get_setval_path(item.get("path")) @@ -408,12 +412,12 @@ def _state_replaced(want, have): if item.get("destination_group"): cmd["destination_group"] = [ setval["destination_group"].format( - item["destination_group"] - ) + item["destination_group"], + ), ] if item.get("sensor_group"): cmd["sensor_group"] = [ - setval["sensor_group"].format(**item["sensor_group"]) + setval["sensor_group"].format(**item["sensor_group"]), ] add[resource].extend(global_ctx) if property_ctx[0] not in add[resource]: @@ -443,7 +447,7 @@ def _state_replaced(want, have): cmd = {} if item.get("data_source"): cmd["data_source"] = [ - setval["data_source"].format(item["data_source"]) + setval["data_source"].format(item["data_source"]), ] if item.get("path"): setval["path"] = get_setval_path(item.get("path")) @@ -460,12 +464,12 @@ def _state_replaced(want, have): if item.get("destination_group"): cmd["destination_group"] = [ setval["destination_group"].format( - item["destination_group"] - ) + item["destination_group"], + ), ] if item.get("sensor_group"): cmd["sensor_group"] = [ - setval["sensor_group"].format(**item["sensor_group"]) + setval["sensor_group"].format(**item["sensor_group"]), ] add[resource].extend(global_ctx) if property_ctx[0] not in add[resource]: @@ -503,12 +507,12 @@ def _state_replaced(want, have): if item.get("data_source"): cmd["data_source"] = [ "no " - + setval["data_source"].format(item["data_source"]) + + setval["data_source"].format(item["data_source"]), ] if item.get("path"): setval["path"] = get_setval_path(item.get("path")) cmd["path"] = [ - "no " + setval["path"].format(**item["path"]) + "no " + setval["path"].format(**item["path"]), ] delete[resource].extend(global_ctx) if property_ctx[0] not in delete[resource]: @@ -523,13 +527,13 @@ def _state_replaced(want, have): cmd["destination_group"] = [ "no " + setval["destination_group"].format( - item["destination_group"] - ) + item["destination_group"], + ), ] if item.get("sensor_group"): cmd["sensor_group"] = [ "no " - + setval["sensor_group"].format(**item["sensor_group"]) + + setval["sensor_group"].format(**item["sensor_group"]), ] delete[resource].extend(global_ctx) if property_ctx[0] not in delete[resource]: diff --git a/plugins/module_utils/network/nxos/config/vlans/vlans.py b/plugins/module_utils/network/nxos/config/vlans/vlans.py index 4141cc320..515618ad8 100644 --- a/plugins/module_utils/network/nxos/config/vlans/vlans.py +++ b/plugins/module_utils/network/nxos/config/vlans/vlans.py @@ -58,7 +58,9 @@ def get_vlans_facts(self, data=None): :returns: The current configuration as a dictionary """ self.facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) vlans_facts = self.facts["ansible_network_resources"].get("vlans") if not vlans_facts: @@ -110,7 +112,7 @@ def execute_module(self): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_vlans_facts(data=running_config) @@ -150,7 +152,7 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) commands = list() diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index 217716691..8440fdb17 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -124,8 +124,8 @@ def get_endpoint(self, ace, pro): "range": { "start": limit.group(2), "end": limit.group(3), - } - } + }, + }, ) ace = re.sub(limit.group(2), "", ace, 1) ace = re.sub(limit.group(3), "", ace, 1) diff --git a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py index d0a8a8027..b0caec1af 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py @@ -83,7 +83,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("bgp_global", None) params = utils.remove_empties( - bgp_global_parser.validate_config(self.argument_spec, {"config": obj}, redact=True) + bgp_global_parser.validate_config(self.argument_spec, {"config": obj}, redact=True), ) facts["bgp_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/hostname/hostname.py b/plugins/module_utils/network/nxos/facts/hostname/hostname.py index 61666c7fa..f672c8272 100644 --- a/plugins/module_utils/network/nxos/facts/hostname/hostname.py +++ b/plugins/module_utils/network/nxos/facts/hostname/hostname.py @@ -64,7 +64,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("hostname", None) params = utils.remove_empties( - hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["hostname"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py b/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py index 9e4462048..4fa4008ac 100644 --- a/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py @@ -103,7 +103,9 @@ def render_config(self, spec, conf): config["enabled"] = utils.parse_conf_cmd_arg(conf, "shutdown", False, True) config["fabric_forwarding_anycast_gateway"] = utils.parse_conf_cmd_arg( - conf, "fabric forwarding mode anycast-gateway", True + conf, + "fabric forwarding mode anycast-gateway", + True, ) config["ip_forward"] = utils.parse_conf_cmd_arg(conf, "ip forward", True) diff --git a/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py index 2bd45f7b4..cf55552b8 100644 --- a/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/l2_interfaces/l2_interfaces.py @@ -96,7 +96,8 @@ def render_config(self, spec, conf): config["ip_forward"] = utils.parse_conf_arg(conf, "ip forward") config["access"]["vlan"] = utils.parse_conf_arg(conf, "switchport access vlan") config["trunk"]["allowed_vlans"] = utils.parse_conf_arg( - conf, "switchport trunk allowed vlan" + conf, + "switchport trunk allowed vlan", ) config["trunk"]["native_vlan"] = utils.parse_conf_arg(conf, "switchport trunk native vlan") diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index 87052dbcf..10767c974 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -44,7 +44,7 @@ def run(self, command, output="text"): return resp[0] except IndexError: self.warnings.append( - "command %s failed, facts for this command will not be populated" % command_string + "command %s failed, facts for this command will not be populated" % command_string, ) return None @@ -175,7 +175,7 @@ class Interfaces(FactsBase): ("eth_hw_addr", "macaddress"), ("eth_mtu", "mtu"), ("eth_hw_desc", "type"), - ] + ], ) INTERFACE_SVI_MAP = frozenset( @@ -185,7 +185,7 @@ class Interfaces(FactsBase): ("svi_mac", "macaddress"), ("svi_mtu", "mtu"), ("type", "type"), - ] + ], ) INTERFACE_IPV4_MAP = frozenset([("eth_ip_addr", "address"), ("eth_ip_mask", "masklen")]) @@ -531,7 +531,7 @@ class Legacy(FactsBase): ("host_name", "_hostname"), ("kickstart_ver_str", "_os"), ("chassis_id", "_platform"), - ] + ], ) MODULE_MAP = frozenset( @@ -540,7 +540,7 @@ class Legacy(FactsBase): ("modtype", "type"), ("ports", "ports"), ("status", "status"), - ] + ], ) FAN_MAP = frozenset( @@ -550,7 +550,7 @@ class Legacy(FactsBase): ("fanhwver", "hw_ver"), ("fandir", "direction"), ("fanstatus", "status"), - ] + ], ) POWERSUP_MAP = frozenset( @@ -565,7 +565,7 @@ class Legacy(FactsBase): ("input_type", "input_type"), ("watts", "watts"), ("amps", "amps"), - ] + ], ) def populate(self): diff --git a/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py index f63ee86bb..4cd8b2115 100644 --- a/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/lldp_interfaces/lldp_interfaces.py @@ -120,7 +120,8 @@ def render_config(self, spec, conf): config["transmit"] = False if "management-address" in conf: config["tlv_set"]["management_address"] = re.search( - r"management-address (\S*)", conf + r"management-address (\S*)", + conf, ).group(1) if "vlan" in conf: config["tlv_set"]["vlan"] = re.search(r"vlan (\S*)", conf).group(1) diff --git a/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py b/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py index 51b14fe9d..7222ce582 100644 --- a/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py @@ -81,7 +81,11 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("logging_global", None) params = utils.remove_empties( - logging_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + logging_global_parser.validate_config( + self.argument_spec, + {"config": objs}, + redact=True, + ), ) facts["logging_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py b/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py index b46955254..e1798958e 100644 --- a/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py @@ -65,7 +65,8 @@ def populate_facts(self, connection, ansible_facts, data=None): for x in ["peer", "query_only", "serve", "serve_only"]: if x in objs["access_group"]: objs["access_group"][x] = sorted( - objs["access_group"][x], key=lambda k: k["access_list"] + objs["access_group"][x], + key=lambda k: k["access_list"], ) pkey = { @@ -82,7 +83,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("ntp_global", None) params = utils.remove_empties( - ntp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + ntp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["ntp_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py index 83ac2186f..5cf66be5c 100644 --- a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py @@ -59,7 +59,8 @@ def populate_facts(self, connection, ansible_facts, data=None): # parse native config using the Ospf_interfaces template ospf_interfaces_parser = Ospf_interfacesTemplate( - lines=data.splitlines(), module=self._module + lines=data.splitlines(), + module=self._module, ) objs = list(ospf_interfaces_parser.parse().values()) if objs: @@ -82,8 +83,10 @@ def populate_facts(self, connection, ansible_facts, data=None): params = utils.remove_empties( ospf_interfaces_parser.validate_config( - self.argument_spec, {"config": objs}, redact=True - ) + self.argument_spec, + {"config": objs}, + redact=True, + ), ) facts["ospf_interfaces"] = params.get("config", []) diff --git a/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py index ead7a4008..2eb32cf44 100644 --- a/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py @@ -76,7 +76,7 @@ def populate_facts(self, connection, ansible_facts, data=None): if "address_family" in entry: if "areas" in entry["address_family"]: entry["address_family"]["areas"] = list( - entry["address_family"]["areas"].values() + entry["address_family"]["areas"].values(), ) ipv6["processes"].append(entry) diff --git a/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py b/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py index 0ce50d4e2..7bb186315 100644 --- a/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/nxos/facts/prefix_lists/prefix_lists.py @@ -71,7 +71,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("prefix_lists", None) params = utils.remove_empties( - prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["prefix_lists"] = params.get("config", []) ansible_facts["ansible_network_resources"].update(facts) diff --git a/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py b/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py index 637c441be..5d843c5b4 100644 --- a/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py @@ -68,7 +68,7 @@ def populate_facts(self, connection, ansible_facts, data=None): ansible_facts["ansible_network_resources"].pop("route_maps", None) params = utils.remove_empties( - route_maps_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + route_maps_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["route_maps"] = params.get("config", []) diff --git a/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py b/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py index 3c1405c22..c46e1a78a 100644 --- a/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/nxos/facts/snmp_server/snmp_server.py @@ -64,17 +64,19 @@ def populate_facts(self, connection, ansible_facts, data=None): if "users" in objs: if "auth" in objs["users"]: objs["users"]["auth"] = sorted( - objs["users"]["auth"], key=lambda k: to_text(k["user"]) + objs["users"]["auth"], + key=lambda k: to_text(k["user"]), ) if "use_acls" in objs["users"]: objs["users"]["use_acls"] = sorted( - objs["users"]["use_acls"], key=lambda k: to_text(k["user"]) + objs["users"]["use_acls"], + key=lambda k: to_text(k["user"]), ) ansible_facts["ansible_network_resources"].pop("snmp_server", None) params = utils.remove_empties( - snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["snmp_server"] = params.get("config", {}) diff --git a/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py b/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py index abac23968..bdb280310 100644 --- a/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/facts/telemetry/telemetry.py @@ -117,7 +117,7 @@ def populate_facts(self, connection, ansible_facts, data=None): if re.search(r"subscription", line): resource_key = line.strip() cmd_ref["TMS_SUBSCRIPTION"]["ref"].append( - NxosCmdRef(self._module, TMS_SUBSCRIPTION) + NxosCmdRef(self._module, TMS_SUBSCRIPTION), ) ref = cmd_ref["TMS_SUBSCRIPTION"]["ref"][-1] ref.set_context([resource_key]) diff --git a/plugins/module_utils/network/nxos/nxos.py b/plugins/module_utils/network/nxos/nxos.py index 9519dbed3..725686b73 100644 --- a/plugins/module_utils/network/nxos/nxos.py +++ b/plugins/module_utils/network/nxos/nxos.py @@ -110,7 +110,7 @@ options=nxos_provider_spec, removed_at_date="2022-06-01", removed_from_collection="cisco.nxos", - ) + ), } @@ -453,7 +453,7 @@ def _send(commands, output): item["output"] = "json" if all((output == "json", item["output"] == "text")) or all( - (output == "text", item["output"] == "json") + (output == "text", item["output"] == "json"), ): responses.extend(_send(queue, output)) queue = list() @@ -530,7 +530,10 @@ def get_diff( # running configuration running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) configdiffobjs = candidate_obj.difference( - running_obj, path=path, match=diff_match, replace=diff_replace + running_obj, + path=path, + match=diff_match, + replace=diff_replace, ) else: @@ -652,7 +655,10 @@ def get_diff( # running configuration running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) configdiffobjs = candidate_obj.difference( - running_obj, path=path, match=diff_match, replace=diff_replace + running_obj, + path=path, + match=diff_match, + replace=diff_replace, ) else: @@ -832,7 +838,7 @@ def feature_enable(self): output = self.execute_show_command(show_cmd, "text") if not output or "CLI command error" in output: msg = "** 'feature {0}' is not enabled. Module will auto-enable feature {0} ** ".format( - feature + feature, ) self._module.warn(msg) ref["_proposed"].append("feature {0}".format(feature)) @@ -1046,7 +1052,7 @@ def get_existing(self, cache_output=None): ref[k]["existing"][index] = item[0] else: raise ValueError( - "get_existing: unknown 'kind' value specified for key '{0}'".format(k) + "get_existing: unknown 'kind' value specified for key '{0}'".format(k), ) def get_playvals(self): diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py index b0eda815b..ef98c5968 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py @@ -77,13 +77,13 @@ def __init__(self, lines=None): "getval": re.compile( r""" ^router\sbgp\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "router bgp {{ as_number }}", "result": { "as_number": "{{ as_number }}", }, - "shared": True + "shared": True, }, { "name": "address_family", @@ -104,8 +104,8 @@ def __init__(self, lines=None): "vrf": "{{ vrf }}", "afi": "{{ afi }}", "safi": "{{ safi }}", - } - } + }, + }, }, "shared": True, }, @@ -124,9 +124,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "additional_paths": { "install_backup": "{{ not not backup }}", - } - } - } + }, + }, + }, }, }, { @@ -144,9 +144,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "additional_paths": { "receive": "{{ not not receive }}", - } - } - } + }, + }, + }, }, }, { @@ -166,10 +166,10 @@ def __init__(self, lines=None): "additional_paths": { "selection": { "route_map": "{{ route_map }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -187,9 +187,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "additional_paths": { "send": "{{ not not send }}", - } - } - } + }, + }, + }, }, }, { @@ -205,8 +205,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "advertise_l2vpn_evpn": "{{ not not advertise_l2vpn_evpn }}", - } - } + }, + }, }, }, { @@ -222,8 +222,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "advertise_pip": "{{ not not advertise_pip }}", - } - } + }, + }, }, }, { @@ -239,8 +239,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "advertise_system_mac": "{{ not not advertise_system_mac }}", - } - } + }, + }, }, }, { @@ -256,8 +256,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "allow_vni_in_ethertag": "{{ not not allow_vni_in_ethertag }}", - } - } + }, + }, }, }, { @@ -286,10 +286,10 @@ def __init__(self, lines=None): "advertise_map": "{{ advertise_map }}", "attribute_map": "{{ attribute_map }}", "suppress_map": "{{ suppress_map }}", - } - ] - } - } + }, + ], + }, + }, }, }, { @@ -307,9 +307,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "client_to_client": { "no_reflection": "{{ not not reflection }}", - } - } - } + }, + }, + }, }, }, { @@ -326,8 +326,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "dampen_igp_metric": "{{ dampen_igp_metric }}", - } - } + }, + }, }, }, { @@ -357,9 +357,9 @@ def __init__(self, lines=None): "start_suppress_route": "{{ start_suppress_route }}", "max_suppress_time": "{{ max_suppress_time }}", "route_map": "{{ route_map }}", - } - } - } + }, + }, + }, }, }, { @@ -377,9 +377,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "default_information": { "originate": "{{ not not originate }}", - } - } - } + }, + }, + }, }, }, { @@ -396,8 +396,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "default_metric": "{{ default_metric }}", - } - } + }, + }, }, }, { @@ -418,10 +418,10 @@ def __init__(self, lines=None): "distance": { "ebgp_routes": "{{ ebgp_routes }}", "ibgp_routes": "{{ ibgp_routes }}", - "local_routes": "{{ local_routes }}" - } - } - } + "local_routes": "{{ local_routes }}", + }, + }, + }, }, }, { @@ -437,8 +437,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "export_gateway_ip": "{{ not not export_gateway_ip }}", - } - } + }, + }, }, }, { @@ -461,10 +461,10 @@ def __init__(self, lines=None): "route_map": "{{ route_map }}", "exist_map": "{{ exist_map }}", "copy_attributes": "{{ not not copy_attributes }}", - } - ] - } - } + }, + ], + }, + }, }, }, { @@ -482,9 +482,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "maximum_paths": { "parallel_paths": "{{ parallel_paths }}", - } - } - } + }, + }, + }, }, }, { @@ -503,10 +503,10 @@ def __init__(self, lines=None): "maximum_paths": { "ibgp": { "parallel_paths": "{{ parallel_paths }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -525,10 +525,10 @@ def __init__(self, lines=None): "maximum_paths": { "eibgp": { "parallel_paths": "{{ parallel_paths }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -547,10 +547,10 @@ def __init__(self, lines=None): "maximum_paths": { "local": { "parallel_paths": "{{ parallel_paths }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -569,10 +569,10 @@ def __init__(self, lines=None): "maximum_paths": { "mixed": { "parallel_paths": "{{ parallel_paths }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -593,10 +593,10 @@ def __init__(self, lines=None): { "prefix": "{{ prefix }}", "route_map": "{{ route_map }}", - } - ] - } - } + }, + ], + }, + }, }, }, { @@ -614,9 +614,9 @@ def __init__(self, lines=None): '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "nexthop": { "route_map": "{{ route_map }}", - } - } - } + }, + }, + }, }, }, { @@ -638,10 +638,10 @@ def __init__(self, lines=None): "trigger_delay": { "critical_delay": "{{ critical_delay }}", "non_critical_delay": "{{ non_critical_delay }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -665,9 +665,9 @@ def __init__(self, lines=None): "id": "{{ id }}", "route_map": "{{ rmap }}", }, - ] - } - } + ], + }, + }, }, }, { @@ -686,10 +686,10 @@ def __init__(self, lines=None): "retain": { "route_target": { "retain_all": "{{ not not retain_all }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -708,10 +708,10 @@ def __init__(self, lines=None): "retain": { "route_target": { "route_map": "{{ route_map }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -727,8 +727,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "suppress_inactive": "{{ not not suppress_inactive }}", - } - } + }, + }, }, }, { @@ -748,9 +748,9 @@ def __init__(self, lines=None): "table_map": { "name": "{{ name }}", "filter": "{{ not not filter }}", - } - } - } + }, + }, + }, }, }, { @@ -771,10 +771,10 @@ def __init__(self, lines=None): "bestpath_defer": { "defer_time": "{{ defer_time }}", "maximum_defer_time": "{{ maximum_defer_time }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -790,8 +790,8 @@ def __init__(self, lines=None): "address_family": { '{{ nbr|d("nbr_") + afi + "_" + safi|d() + "_" + vrf|d() }}': { "wait_igp_convergence": "{{ not not wait_igp_convergence }}", - } - } + }, + }, }, }, ] diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py index cdd24c9a7..7a5454fb2 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py @@ -67,13 +67,13 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^router\sbgp\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "router bgp {{ as_number }}", "result": { "as_number": "{{ as_number }}", }, - "shared": True + "shared": True, }, { "name": "vrf", @@ -87,9 +87,9 @@ def __init__(self, lines=None, module=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "vrf": "{{ vrf }}" - } - } + "vrf": "{{ vrf }}", + }, + }, }, "shared": True, }, @@ -99,21 +99,21 @@ def __init__(self, lines=None, module=None): r""" \s+affinity-group \sactivate\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "affinity-group activate {{ affinity_group.group_id }}", "result": { "affinity_group": { "group_id": "{{ group_id }}", }, - } + }, }, { "name": "bestpath.always_compare_med", "getval": re.compile( r""" \s+bestpath\s(?Palways-compare-med) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath always-compare-med", "result": { @@ -121,17 +121,17 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "bestpath": { "always_compare_med": "{{ not not always_compare_med }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "bestpath.as_path.ignore", "getval": re.compile( r""" \s+bestpath\sas-path\s(?Pignore) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath as-path ignore", "result": { @@ -140,18 +140,18 @@ def __init__(self, lines=None, module=None): "bestpath": { "as_path": { "ignore": "{{ not not ignore }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "bestpath.as_path.multipath_relax", "getval": re.compile( r""" \s+bestpath\sas-path\s(?Pmultipath-relax) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath as-path multipath-relax", "result": { @@ -160,18 +160,18 @@ def __init__(self, lines=None, module=None): "bestpath": { "as_path": { "multipath_relax": "{{ not not multipath_relax }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "bestpath.compare_neighborid", "getval": re.compile( r""" \s+bestpath\s(?Pcompare-neighborid) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath compare-neighborid", "result": { @@ -179,18 +179,18 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "bestpath": { "compare_neighborid": "{{ not not compare_neighborid }}", - } - } - } + }, + }, + }, - } + }, }, { "name": "bestpath.compare_routerid", "getval": re.compile( r""" \s+bestpath\s(?Pcompare-routerid) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath compare-routerid", "result": { @@ -198,17 +198,17 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "bestpath": { "compare_routerid": "{{ not not compare_routerid }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "bestpath.cost_community_ignore", "getval": re.compile( r""" \s+bestpath\scost-community\s(?Pignore) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath cost-community ignore", "result": { @@ -216,17 +216,17 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "bestpath": { "cost_community_ignore": "{{ not not cost_community_ignore }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "bestpath.igp_metric_ignore", "getval": re.compile( r""" \s+bestpath\sigp-metric\s(?Pignore) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath igp-metric ignore", "result": { @@ -234,17 +234,17 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "bestpath": { "igp_metric_ignore": "{{ not not igp_metric_ignore }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "bestpath.med.confed", "getval": re.compile( r""" \s+bestpath\smed\s(?Pconfed) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath med confed", "result": { @@ -253,18 +253,18 @@ def __init__(self, lines=None, module=None): "bestpath": { "med": { "confed": "{{ not not confed }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "bestpath.med.missing_as_worst", "getval": re.compile( r""" \s+bestpath\smed\s(?Pmissing-as-worst) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath med missing-as-worst", "result": { @@ -273,18 +273,18 @@ def __init__(self, lines=None, module=None): "bestpath": { "med": { "missing_as_worst": "{{ not not missing_as_worst }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "bestpath.med.non_deterministic", "getval": re.compile( r""" \s+bestpath\smed\s(?Pnon-deterministic) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bestpath med non-deterministic", "result": { @@ -293,34 +293,34 @@ def __init__(self, lines=None, module=None): "bestpath": { "med": { "non_deterministic": "{{ not not non_deterministic }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "cluster_id", "getval": re.compile( r""" \s+cluster-id\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "cluster-id {{ cluster_id }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "cluster_id": "{{ cluster_id }}", - } - } - } + }, + }, + }, }, { "name": "confederation.identifier", "getval": re.compile( r""" \s+confederation\sidentifier\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "confederation identifier {{ confederation.identifier }}", "result": { @@ -329,8 +329,8 @@ def __init__(self, lines=None, module=None): "confederation": { "identifier": "{{ identifier }}", }, - } - } + }, + }, }, }, { @@ -338,7 +338,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+confederation\speers\s(?P.*) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": _tmplt_confederation_peers, "result": { @@ -347,23 +347,23 @@ def __init__(self, lines=None, module=None): "confederation": { "peers": "{{ peers }}", }, - } + }, }, - } + }, }, { "name": "disable_policy_batching", "getval": re.compile( r""" \s+(?Pdisable-policy-batching) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "disable-policy-batching", "result": { "disable_policy_batching": { "set": "{{ not not disable_policy_batching }}", }, - } + }, }, { "name": "disable_policy_batching.ipv4.prefix_list", @@ -371,16 +371,16 @@ def __init__(self, lines=None, module=None): r""" \s+disable-policy-batching\sipv4 \sprefix-list\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "disable-policy-batching ipv4 prefix-list {{ disable_policy_batching.ipv4.prefix_list }}", "result": { "disable_policy_batching": { "ipv4": { "prefix_list": "{{ ipv4_prefix_list }}", - } + }, }, - } + }, }, { "name": "disable_policy_batching.ipv6.prefix_list", @@ -388,97 +388,97 @@ def __init__(self, lines=None, module=None): r""" \s+disable-policy-batching\sipv6 \sprefix-list\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "disable-policy-batching ipv6 prefix-list {{ disable_policy_batching.ipv6.prefix_list }}", "result": { "disable_policy_batching": { "ipv6": { "prefix_list": "{{ ipv6_prefix_list }}", - } + }, }, - } + }, }, { "name": "disable_policy_batching.nexthop", "getval": re.compile( r""" \s+disable-policy-batching\s(?Pnexthop) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "disable-policy-batching nexthop", "result": { "disable_policy_batching": { "nexthop": "{{ not not nexthop }}", }, - } + }, }, { "name": "dynamic_med_interval", "getval": re.compile( r""" \s+dynamic-med-interval\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "dynamic-med-interval {{ dynamic_med_interval }}", "result": { "dynamic_med_interval": "{{ dynamic_med_interval }}", - } + }, }, { "name": "enforce_first_as", "getval": re.compile( r""" \s+no\s(?Penforce-first-as) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "enforce-first-as", "result": { "enforce_first_as": "{{ not enforce_first_as }}", - } + }, }, { "name": "enhanced_error", "getval": re.compile( r""" \s+no\s(?Penhanced-error) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "enhanced-error", "result": { "enhanced_error": "{{ not enhanced_error }}", - } + }, }, { "name": "fast_external_fallover", "getval": re.compile( r""" \s+no\s(?Pfast-external-fallover) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "fast-external-fallover", "result": { "fast_external_fallover": "{{ not fast_external_fallover }}", - } + }, }, { "name": "flush_routes", "getval": re.compile( r""" \s+(?Pflush-routes) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "flush-routes", "result": { "flush_routes": "{{ not not flush_routes }}", - } + }, }, { "name": "graceful_restart", "getval": re.compile( r""" \s+no\s(?Pgraceful-restart) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-restart", "result": { @@ -487,16 +487,16 @@ def __init__(self, lines=None, module=None): "graceful_restart": { "set": "{{ not graceful_restart }}", }, - } - } - } + }, + }, + }, }, { "name": "graceful_restart.restart_time", "getval": re.compile( r""" \s+graceful-restart\srestart-time\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-restart restart-time {{ graceful_restart.restart_time }}", "result": { @@ -505,16 +505,16 @@ def __init__(self, lines=None, module=None): "graceful_restart": { "restart_time": "{{ restart_time }}", }, - } - } - } + }, + }, + }, }, { "name": "graceful_restart.stalepath_time", "getval": re.compile( r""" \s+graceful-restart\sstalepath-time\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-restart stalepath-time {{ graceful_restart.stalepath_time }}", "result": { @@ -523,16 +523,16 @@ def __init__(self, lines=None, module=None): "graceful_restart": { "stalepath_time": "{{ stalepath_time }}", }, - } - } - } + }, + }, + }, }, { "name": "graceful_restart.helper", "getval": re.compile( r""" \s+(?Pgraceful-restart-helper) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-restart-helper", "result": { @@ -541,9 +541,9 @@ def __init__(self, lines=None, module=None): "graceful_restart": { "helper": "{{ not not helper }}", }, - } - } - } + }, + }, + }, }, { "name": "graceful_shutdown.activate", @@ -553,7 +553,7 @@ def __init__(self, lines=None, module=None): \s(?Pactivate) (\sroute-map \s(?P\S+))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-shutdown activate{{ ' route-map ' + graceful_shutdown.activate.route_map if graceful_shutdown.activate.route_map is defined }}", "result": { @@ -561,9 +561,9 @@ def __init__(self, lines=None, module=None): "activate": { "set": "{{ True if activate is defined and route_map is undefined else None }}", "route_map": "{{ route_map }}", - } + }, }, - } + }, }, { "name": "graceful_shutdown.aware", @@ -571,14 +571,14 @@ def __init__(self, lines=None, module=None): r""" \s+no\sgraceful-shutdown \s(?Paware) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-shutdown aware", "result": { "graceful_shutdown": { - "aware": "{{ not aware }}" + "aware": "{{ not aware }}", }, - } + }, }, { "name": "isolate", @@ -586,7 +586,7 @@ def __init__(self, lines=None, module=None): r""" \s+(?Pisolate) (\s(?Pinclude-local))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "isolate{{ ' include-local' if isolate.include_local|d(False) is True }}", "result": { @@ -594,39 +594,39 @@ def __init__(self, lines=None, module=None): "set": "{{ True if isolate is defined and include_local is not defined else None }}", "include_local": "{{ not not include_local }}", }, - } + }, }, { "name": "log_neighbor_changes", "getval": re.compile( r""" \s+(?Plog-neighbor-changes) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "log-neighbor-changes", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "log_neighbor_changes": "{{ not not log_neighbor_changes }}", - } - } - } + }, + }, + }, }, { "name": "maxas_limit", "getval": re.compile( r""" \s+maxas-limit\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "maxas-limit {{ maxas_limit }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "maxas_limit": "{{ maxas_limit }}", - } - } - } + }, + }, + }, }, # start neighbor parsers { @@ -634,7 +634,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "neighbor {{ neighbor_address }}", "result": { @@ -643,11 +643,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "neighbor_address": "{{ neighbor_address }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "bfd", @@ -657,7 +657,7 @@ def __init__(self, lines=None, module=None): \s(?Pbfd) (\s(?Psinglehop))? (\s(?Pmultihop))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": _tmplt_bfd, "result": { @@ -670,13 +670,13 @@ def __init__(self, lines=None, module=None): "singlehop": "{{ not not singlehop }}", "multihop": { "set": "{{ not not multihop }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "bfd.multihop.interval", @@ -687,7 +687,7 @@ def __init__(self, lines=None, module=None): \s(?P\d+) \smin_rx\s(?P\d+) \smultiplier\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bfd multihop interval" " {{ bfd.multihop.interval.tx_interval }}" @@ -704,14 +704,14 @@ def __init__(self, lines=None, module=None): "tx_interval": "{{ tx_interval }}", "min_rx_interval": "{{ min_rx_interval }}", "multiplier": "{{ multiplier }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "remote_as", @@ -719,7 +719,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \sremote-as\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "remote-as {{ remote_as }}", "result": { @@ -728,11 +728,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "remote_as": "{{ remote_as }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "neighbor_affinity_group.group_id", @@ -740,7 +740,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \saffinity-group\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "affinity-group {{ neighbor_affinity_group.group_id }}", "result": { @@ -750,12 +750,12 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "neighbor_affinity_group": { "group_id": "{{ group_id }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "bmp_activate_server", @@ -763,7 +763,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \sbmp-activate-server\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "bmp-activate-server {{ bmp_activate_server }}", "result": { @@ -772,11 +772,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "bmp_activate_server": "{{ bmp_activate_server }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "capability", @@ -784,7 +784,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \scapability\ssuppress\s(?P4-byte-as) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "capability suppress 4-byte-as", "result": { @@ -794,12 +794,12 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "capability": { "suppress_4_byte_as": "{{ not not suppress_4_byte_as }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "description", @@ -807,7 +807,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \sdescription\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "description {{ description }}", "result": { @@ -816,11 +816,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "description": "{{ description }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "disable_connected_check", @@ -828,7 +828,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \s(?Pdisable-connected-check) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "disable-connected-check", "result": { @@ -837,11 +837,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "disable_connected_check": "{{ not not disable_connected_check }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "dont_capability_negotiate", @@ -849,7 +849,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \s(?Pdont-capability-negotiate) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "dont-capability-negotiate", "result": { @@ -858,11 +858,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "dont_capability_negotiate": "{{ not not dont_capability_negotiate}}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "dscp", @@ -870,7 +870,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \sdscp\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "dscp {{ dscp }}", "result": { @@ -879,11 +879,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "dscp": "{{ dscp }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "dynamic_capability", @@ -891,7 +891,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \s(?Pdynamic-capability) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "dynamic-capability", "result": { @@ -900,11 +900,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "dynamic_capability": "{{ not not dynamic_capability }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "ebgp_multihop", @@ -912,7 +912,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \sebgp-multihop\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "ebgp-multihop {{ ebgp_multihop }}", "result": { @@ -921,11 +921,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "ebgp_multihop": "{{ ebgp_multihop }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "graceful_shutdown", @@ -935,7 +935,7 @@ def __init__(self, lines=None, module=None): \sgraceful-shutdown \s(?Pactivate) (\sroute-map\s(?P\S+))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "graceful-shutdown{{ (' route-map ' + graceful_shutdown.route_map) if graceful_shutdown.route_map is defined }}", "result": { @@ -948,12 +948,12 @@ def __init__(self, lines=None, module=None): "set": "{{ True if activate is defined and route_map is undefined else None }}", "route_map": "{{ route_map }}", }, - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "inherit.peer", @@ -962,7 +962,7 @@ def __init__(self, lines=None, module=None): \s+neighbor\s(?P\S+) \sinherit \speer\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "inherit peer {{ inherit.peer }}", "result": { @@ -972,12 +972,12 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "inherit": { "peer": "{{ peer }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "inherit.peer_session", @@ -986,7 +986,7 @@ def __init__(self, lines=None, module=None): \s+neighbor\s(?P\S+) \sinherit \speer-session\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "inherit peer-session {{ inherit.peer_session }}", "result": { @@ -996,12 +996,12 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "inherit": { "peer_session": "{{ peer_session }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "local_as", @@ -1009,7 +1009,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \slocal-as\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "local-as {{ local_as }}", "result": { @@ -1018,11 +1018,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "local_as": "{{ local_as }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "log_neighbor_changes", @@ -1031,7 +1031,7 @@ def __init__(self, lines=None, module=None): \s+neighbor\s(?P\S+) \s(?Plog-neighbor-changes) (\s(?Pdisable))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "log-neighbor-changes{{ ' disable' if log_neighbor_changes.disable is defined }}", "result": { @@ -1042,12 +1042,12 @@ def __init__(self, lines=None, module=None): "log_neighbor_changes": { "set": "{{ True if log_neighbor_changes is defined and disable is undefined }}", "disable": "{{ not not disable }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "low_memory", @@ -1055,7 +1055,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \slow-memory\s(?Pexempt) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "low-memory exempt", "result": { @@ -1065,12 +1065,12 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "low_memory": { "exempt": "{{ not not exempt }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "password", @@ -1079,7 +1079,7 @@ def __init__(self, lines=None, module=None): \s+neighbor\s(?P\S+) \spassword\s(?P\d+) \s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "password{{ (' ' + password.encryption|string) if password.encryption is defined }} {{ password.key }}", "result": { @@ -1090,12 +1090,12 @@ def __init__(self, lines=None, module=None): "password": { "encryption": "{{ encryption }}", "key": "{{ key }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "path_attribute", @@ -1106,7 +1106,7 @@ def __init__(self, lines=None, module=None): (?P\d+)? (range\s(?P\d+)\s(?P\d+))? \sin - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": _tmplt_path_attribute, "result": { @@ -1120,15 +1120,15 @@ def __init__(self, lines=None, module=None): "type": "{{ type if type is defined else None }}", "range": { "start": "{{ start if start is defined }}", - "end": "{{ end if end is defined }}" + "end": "{{ end if end is defined }}", }, }, - ] - } - } - } - } - } + ], + }, + }, + }, + }, + }, }, { "name": "peer_type", @@ -1136,7 +1136,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \speer-type\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "peer-type {{ peer_type }}", "result": { @@ -1145,11 +1145,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "peer_type": "{{ peer_type }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "remove_private_as", @@ -1159,7 +1159,7 @@ def __init__(self, lines=None, module=None): \s(?Premove-private-as) (\s(?Pall))? (\s(?Preplace-as))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "remove-private-as", "result": { @@ -1171,12 +1171,12 @@ def __init__(self, lines=None, module=None): "set": "{{ True if remove_private_as is defined and replace_as is undefined and all is undefined else None }}", "replace_as": "{{ not not replace_as }}", "all": "{{ not not all }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "shutdown", @@ -1184,7 +1184,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \s(?Pshutdown) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "shutdown", "result": { @@ -1193,11 +1193,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "shutdown": "{{ not not shutdown }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "timers", @@ -1205,7 +1205,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \stimers\s(?P\d+)\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "timers {{ timers.keepalive }} {{ timers.holdtime }}", "result": { @@ -1216,12 +1216,12 @@ def __init__(self, lines=None, module=None): "timers": { "keepalive": "{{ keepalive }}", "holdtime": "{{ holdtime }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "transport", @@ -1230,7 +1230,7 @@ def __init__(self, lines=None, module=None): \s+neighbor\s(?P\S+) \stransport\sconnection-mode \s(?Ppassive) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "transport connection-mode passive", "result": { @@ -1241,13 +1241,13 @@ def __init__(self, lines=None, module=None): "transport": { "connection_mode": { "passive": "{{ not not passive }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "ttl_security", @@ -1255,7 +1255,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \sttl-security\shops\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "ttl-security hops {{ ttl_security.hops }}", "result": { @@ -1265,12 +1265,12 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "ttl_security": { "hops": "{{ hops }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, { "name": "update_source", @@ -1278,7 +1278,7 @@ def __init__(self, lines=None, module=None): r""" \s+neighbor\s(?P\S+) \supdate-source\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "update-source {{ update_source }}", "result": { @@ -1287,11 +1287,11 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "update_source": "{{ update_source }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, # end neighbor parsers { @@ -1299,7 +1299,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor-down\s(?Pfib-accelerate) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "neighbor-down fib-accelerate", "result": { @@ -1307,10 +1307,10 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "neighbor_down": { "fib_accelerate": "{{ not not fib_accelerate }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "nexthop.suppress_default_resolution", @@ -1318,14 +1318,14 @@ def __init__(self, lines=None, module=None): r""" \s+nexthop \s(?Psuppress-default-resolution) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "nexthop suppress-default-resolution", "result": { "nexthop": { "suppress_default_resolution": "{{ not not suppress_default_resolution }}", }, - } + }, }, { "name": "reconnect_interval", @@ -1333,16 +1333,16 @@ def __init__(self, lines=None, module=None): r""" \s+reconnect-interval \s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "reconnect-interval {{ reconnect_interval }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "reconnect_interval": "{{ reconnect_interval }}", - } - } - } + }, + }, + }, }, { "name": "router_id", @@ -1350,40 +1350,40 @@ def __init__(self, lines=None, module=None): r""" \s+router-id \s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "router-id {{ router_id }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "router_id": "{{ router_id }}", - } - } - } + }, + }, + }, }, { "name": "shutdown", "getval": re.compile( r""" \s+(?Pshutdown) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "shutdown", "result": { "shutdown": "{{ not not shutdown }}", - } + }, }, { "name": "suppress_fib_pending", "getval": re.compile( r""" \s+no\s(?Psuppress-fib-pending) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "suppress-fib-pending", "result": { "suppress_fib_pending": "{{ not suppress_fib_pending }}", - } + }, }, { "name": "timers.bestpath_limit", @@ -1392,7 +1392,7 @@ def __init__(self, lines=None, module=None): \s+timers\sbestpath-limit \s(?P\d+) (\s(?Palways))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "timers bestpath-limit {{ timers.bestpath_limit.timeout }}{{ ' always' if timers.bestpath_limit.timeout is defined }}", "result": { @@ -1402,11 +1402,11 @@ def __init__(self, lines=None, module=None): "bestpath_limit": { "timeout": "{{ timeout }}", "always": "{{ not not always }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "timers.bgp", @@ -1415,7 +1415,7 @@ def __init__(self, lines=None, module=None): \s+timers\sbgp \s(?P\d+) (\s(?P\d+))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "timers bgp {{ timers.bgp.keepalive }} {{ timers.bgp.holdtime }}", "result": { @@ -1425,11 +1425,11 @@ def __init__(self, lines=None, module=None): "bgp": { "keepalive": "{{ keepalive }}", "holdtime": "{{ holdtime }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "timers.prefix_peer_timeout", @@ -1437,7 +1437,7 @@ def __init__(self, lines=None, module=None): r""" \s+timers \sprefix-peer-timeout\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "timers prefix-peer-timeout {{ timers.prefix_peer_timeout }}", "result": { @@ -1445,10 +1445,10 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "timers": { "prefix_peer_timeout": "{{ prefix_peer_timeout }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "timers.prefix_peer_wait", @@ -1456,7 +1456,7 @@ def __init__(self, lines=None, module=None): r""" \s+timers \sprefix-peer-wait\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "timers prefix-peer-wait {{ timers.prefix_peer_wait }}", "result": { @@ -1464,10 +1464,10 @@ def __init__(self, lines=None, module=None): '{{ "vrf_" + vrf|d() }}': { "timers": { "prefix_peer_wait": "{{ prefix_peer_wait }}", - } - } - } - } + }, + }, + }, + }, }, { "name": "fabric_soo", @@ -1475,12 +1475,12 @@ def __init__(self, lines=None, module=None): r""" \s+fabric-soo \s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "fabric-soo {{ fabric_soo }}", "result": { "fabric_soo": "{{ fabric_soo }}", - } + }, }, { "name": "rd", @@ -1488,15 +1488,15 @@ def __init__(self, lines=None, module=None): r""" \s+rd\s(?Pdual) (\sid\s(?P\d+))? - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "rd dual{{' id ' + rd.id if rd.id is defined }}", "result": { "rd": { "dual": "{{ not not dual }}", "id": "{{ id }}", - } - } + }, + }, }, # VRF only { @@ -1504,16 +1504,16 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+allocate-index\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "allocate-index {{ allocate_index }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "allocate_index": "{{ allocate_index }}", - } + }, }, - } + }, }, # VRF only { @@ -1521,16 +1521,16 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+local-as\s(?P\d+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "local-as {{ local_as }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { "local_as": "{{ local_as }}", - } - } - } + }, + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py index 38e6f0f3d..9a00cbbf9 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py @@ -45,13 +45,13 @@ def __init__(self, lines=None): "getval": re.compile( r""" ^router\sbgp\s(?P\S+) - $""", re.VERBOSE + $""", re.VERBOSE, ), "setval": "router bgp {{ as_number }}", "result": { "as_number": "{{ as_number }}", }, - "shared": True + "shared": True, }, { "name": "address_family", @@ -77,12 +77,12 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "afi": "{{ afi }}", "safi": "{{ safi }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, "shared": True, }, @@ -108,14 +108,14 @@ def __init__(self, lines=None): "advertise_map": { "route_map": "{{ route_map }}", "exist_map": "{{ exist_map }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "advertise_map.non_exist_map", @@ -139,14 +139,14 @@ def __init__(self, lines=None): "advertise_map": { "route_map": "{{ route_map }}", "non_exist_map": "{{ non_exist_map }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "advertisement_interval", @@ -167,13 +167,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "advertisement_interval": "{{ advertisement_interval }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "allowas_in", @@ -196,14 +196,14 @@ def __init__(self, lines=None): "allowas_in": { "set": "{{ True if allowas_in is defined and max_occurences is undefined }}", "max_occurences": "{{ max_occurences }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "as_override", @@ -223,13 +223,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "as_override": "{{ not not as_override }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "capability.additional_paths.receive", @@ -253,15 +253,15 @@ def __init__(self, lines=None): "capability": { "additional_paths": { "receive": "{{ 'disable' if disable is defined else 'enable' }}", - } - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "capability.additional_paths.send", @@ -286,14 +286,14 @@ def __init__(self, lines=None): "additional_paths": { "send": "{{ 'disable' if disable is defined else 'enable' }}", }, - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "default_originate", @@ -316,14 +316,14 @@ def __init__(self, lines=None): "default_originate": { "set": "{{ True if default_originate is defined and route_map is not defined }}", "route_map": "{{ route_map }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "disable_peer_as_check", @@ -343,13 +343,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "disable_peer_as_check": "{{ not not disable_peer_as_check }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "filter_list.inbound", @@ -371,14 +371,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "filter_list": { "inbound": "{{ in }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "filter_list.outbound", @@ -400,14 +400,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "filter_list": { "outbound": "{{ out }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "inherit", @@ -431,14 +431,14 @@ def __init__(self, lines=None): "inherit": { "template": "{{ template }}", "sequence": "{{ sequence }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "maximum_prefix", @@ -466,14 +466,14 @@ def __init__(self, lines=None): "generate_warning_threshold": "{{ generate_warning_threshold }}", "restart_interval": "{{ restart_interval }}", "warning_only": "{{ not not warning_only }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "next_hop_self", @@ -496,14 +496,14 @@ def __init__(self, lines=None): "next_hop_self": { "set": "{{ True if next_hop_self is defined and all_routes is not defined }}", "all_routes": "{{ not not all_routes }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "next_hop_third_party", @@ -523,13 +523,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "next_hop_third_party": "{{ not next_hop_third_party }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "prefix_list.inbound", @@ -551,14 +551,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "prefix_list": { "inbound": "{{ in }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "prefix_list.outbound", @@ -580,14 +580,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "prefix_list": { "outbound": "{{ out }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "rewrite_evpn_rt_asn", @@ -607,13 +607,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "rewrite_evpn_rt_asn": "{{ not not rewrite_evpn_rt_asn }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "route_map.inbound", @@ -635,14 +635,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "route_map": { "inbound": "{{ in }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "route_map.outbound", @@ -664,14 +664,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "route_map": { "outbound": "{{ out }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "route_reflector_client", @@ -691,13 +691,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "route_reflector_client": "{{ not not route_reflector_client }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "send_community.standard", @@ -718,14 +718,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "send_community": { "standard": "{{ True if send_community is defined }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "send_community.extended", @@ -747,14 +747,14 @@ def __init__(self, lines=None): '{{ afi + "_" + safi|d() }}': { "send_community": { "extended": "{{ True if extended is defined }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "soft_reconfiguration_inbound", @@ -777,14 +777,14 @@ def __init__(self, lines=None): "soft_reconfiguration_inbound": { "set": "{{ True if soft_reconfiguration_inbound is defined and always is undefined }}", "always": "{{ not not always }}", - } - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "soo", @@ -804,13 +804,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "soo": "{{ soo }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "suppress_inactive", @@ -830,13 +830,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "suppress_inactive": "{{ not not suppress_inactive }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "unsuppress_map", @@ -856,13 +856,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "unsuppress_map": "{{ unsuppress_map }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "weight", @@ -882,13 +882,13 @@ def __init__(self, lines=None): "address_family": { '{{ afi + "_" + safi|d() }}': { "weight": "{{ weight }}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/nxos/rm_templates/hostname.py b/plugins/module_utils/network/nxos/rm_templates/hostname.py index 558e0168c..bf922fb4c 100644 --- a/plugins/module_utils/network/nxos/rm_templates/hostname.py +++ b/plugins/module_utils/network/nxos/rm_templates/hostname.py @@ -33,7 +33,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^hostname\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "hostname {{ hostname }}", "result": { "hostname": "{{ hostname }}", diff --git a/plugins/module_utils/network/nxos/rm_templates/logging_global.py b/plugins/module_utils/network/nxos/rm_templates/logging_global.py index 0467ffe61..8287794e0 100644 --- a/plugins/module_utils/network/nxos/rm_templates/logging_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/logging_global.py @@ -55,7 +55,8 @@ def __init__(self, lines=None, module=None): ^(?Pno\s)? logging\sconsole (\s(?P\d))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'no ' if console.state|d('') == 'disabled' else '' }}" "logging console" "{{ (' ' + console.severity|string) if console.severity is defined else '' }}", @@ -72,14 +73,15 @@ def __init__(self, lines=None, module=None): r""" ^(?Pno\s)? logging\sevent\slink-status\senable - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging event link-status enable", "result": { "event": { "link_status": { "enable": "{{ False if negated is defined else True }}", - } - } + }, + }, }, }, { @@ -88,14 +90,15 @@ def __init__(self, lines=None, module=None): r""" ^(?Pno\s)? logging\sevent\slink-status\sdefault - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging event link-status default", "result": { "event": { "link_status": { "default": "{{ False if negated is defined else True }}", - } - } + }, + }, }, }, { @@ -104,14 +107,15 @@ def __init__(self, lines=None, module=None): r""" ^(?Pno\s)? logging\sevent\strunk-status\senable - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging event trunk-status enable", "result": { "event": { "trunk_status": { "enable": "{{ False if negated is defined else True }}", - } - } + }, + }, }, }, { @@ -120,14 +124,15 @@ def __init__(self, lines=None, module=None): r""" ^(?Pno\s)? logging\sevent\strunk-status\sdefault - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging event trunk-status default", "result": { "event": { "trunk_status": { "default": "{{ False if negated is defined else True }}", - } - } + }, + }, }, }, { @@ -136,7 +141,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\shistory \s(?P\d) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging history {{ history.severity }}", "result": { "history": { @@ -150,7 +156,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\shistory\ssize \s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging history size {{ history.size }}", "result": { "history": { @@ -164,7 +171,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\sip\saccess-list\scache \sentries\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging ip access-list cache entries {{ ip.access_list.cache.entries }}", "result": { "ip": { @@ -172,7 +180,7 @@ def __init__(self, lines=None, module=None): "cache": { "entries": "{{ entries }}", }, - } + }, }, }, }, @@ -182,7 +190,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\sip\saccess-list\scache \sinterval\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging ip access-list cache interval {{ ip.access_list.cache.interval }}", "result": { "ip": { @@ -190,7 +199,7 @@ def __init__(self, lines=None, module=None): "cache": { "interval": "{{ interval }}", }, - } + }, }, }, }, @@ -200,7 +209,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\sip\saccess-list\scache \sthreshold\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging ip access-list cache threshold {{ ip.access_list.cache.threshold }}", "result": { "ip": { @@ -208,7 +218,7 @@ def __init__(self, lines=None, module=None): "cache": { "threshold": "{{ threshold }}", }, - } + }, }, }, }, @@ -218,13 +228,14 @@ def __init__(self, lines=None, module=None): r""" ^logging\sip\saccess-list \s(?Pdetailed) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging ip access-list detailed", "result": { "ip": { "access_list": { "detailed": "{{ not not detailed }}", - } + }, }, }, }, @@ -234,15 +245,16 @@ def __init__(self, lines=None, module=None): r""" ^logging\sip\saccess-list\sinclude \s(?Psgt) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging ip access-list include sgt", "result": { "ip": { "access_list": { "include": { "sgt": "{{ not not sgt }}", - } - } + }, + }, }, }, }, @@ -256,7 +268,8 @@ def __init__(self, lines=None, module=None): \s(?P\S+) \s(?P\d+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging level {{ facility }} {{ severity }}", "result": { "facilities": [ @@ -264,7 +277,7 @@ def __init__(self, lines=None, module=None): "facility": "{{ facility }}", "severity": "{{ severity }}", }, - ] + ], }, }, { @@ -277,7 +290,8 @@ def __init__(self, lines=None, module=None): (\s(?P\d+))? (\ssize\s(?P\d+))? (\spersistent\sthreshold\s(?P\d+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'no ' if logfile.state|d('') == 'disabled' else '' }}" "logging logfile" "{{ ' ' + logfile.name if logfile.name|d('') else '' }}" @@ -301,7 +315,8 @@ def __init__(self, lines=None, module=None): ^(?Pno\s)? logging\smodule (\s(?P\d))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'no ' if module.state|d('') == 'disabled' else '' }}" "logging module" "{{ (' ' + module.severity|string) if module.severity is defined else '' }}", @@ -319,7 +334,8 @@ def __init__(self, lines=None, module=None): ^(?Pno\s)? logging\smonitor (\s(?P\d))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'no ' if monitor.state|d('') == 'disabled' else '' }}" "logging monitor" "{{ (' ' + monitor.severity|string) if monitor.severity is defined else '' }}", @@ -336,12 +352,13 @@ def __init__(self, lines=None, module=None): r""" ^logging\sorigin-id \s(?Phostname) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging origin-id hostname", "result": { "origin_id": { "hostname": "{{ not not hostname }}", - } + }, }, }, { @@ -350,12 +367,13 @@ def __init__(self, lines=None, module=None): r""" ^logging\sorigin-id \sip\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging origin-id ip {{ origin_id.ip }}", "result": { "origin_id": { "ip": "{{ ip }}", - } + }, }, }, { @@ -364,12 +382,13 @@ def __init__(self, lines=None, module=None): r""" ^logging\sorigin-id \sstring\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging origin-id string {{ origin_id.string }}", "result": { "origin_id": { "string": "{{ string }}", - } + }, }, }, { @@ -379,7 +398,8 @@ def __init__(self, lines=None, module=None): ^(?Pno\s)? logging \s(?Prate-limit) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'no ' if rate_limit|d('') == 'disabled' else '' }}" "logging rate-limit", "result": { @@ -392,7 +412,8 @@ def __init__(self, lines=None, module=None): r""" logging\srfc-strict \s(?P5424) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging rfc-strict 5424", "result": { "rfc_strict": "{{ not not rfc_strict }}", @@ -409,7 +430,8 @@ def __init__(self, lines=None, module=None): (\ssecure\strustpoint\sclient-identity\s(?P\S+))? (\suse-vrf\s(?P\S+))? (\sfacility\s(?P\S+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": _tmplt_hosts, "result": { "hosts": [ @@ -419,13 +441,13 @@ def __init__(self, lines=None, module=None): "secure": { "trustpoint": { "client_identity": "{{ client_identity }}", - } + }, }, "port": "{{ port }}", "facility": "{{ facility }}", "use_vrf": "{{ use_vrf }}", - } - ] + }, + ], }, }, { @@ -434,7 +456,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\ssource-interface \s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging source-interface {{ source_interface }}", "result": { "source_interface": "{{ source_interface }}", @@ -446,7 +469,8 @@ def __init__(self, lines=None, module=None): r""" ^logging\stimestamp \s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "logging timestamp {{ timestamp }}", "result": { "timestamp": "{{ timestamp }}", diff --git a/plugins/module_utils/network/nxos/rm_templates/ntp_global.py b/plugins/module_utils/network/nxos/rm_templates/ntp_global.py index f976e2fa7..8d5a354df 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ntp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/ntp_global.py @@ -33,12 +33,13 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\saccess-group\s(?Pmatch-all) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp access-group match-all", "result": { "access_group": { "match_all": "{{ True if match_all is defined else None }}", - } + }, }, }, { @@ -46,16 +47,17 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\saccess-group\speer\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp access-group peer {{ access_list }}", "result": { "access_group": { "peer": [ { "access_list": "{{ acl }}", - } + }, ], - } + }, }, }, { @@ -63,16 +65,17 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\saccess-group\squery-only\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp access-group query-only {{ access_list }}", "result": { "access_group": { "query_only": [ { "access_list": "{{ acl }}", - } + }, ], - } + }, }, }, { @@ -80,16 +83,17 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\saccess-group\sserve\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp access-group serve {{ access_list }}", "result": { "access_group": { "serve": [ { "access_list": "{{ acl }}", - } + }, ], - } + }, }, }, { @@ -97,16 +101,17 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\saccess-group\sserve-only\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp access-group serve-only {{ access_list }}", "result": { "access_group": { "serve_only": [ { "access_list": "{{ acl }}", - } + }, ], - } + }, }, }, { @@ -114,14 +119,15 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\sallow\scontrol\srate-limit\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp allow control rate-limit {{ allow.control.rate_limit }}", "result": { "allow": { "control": { "rate_limit": "{{ rate_limit }}", - } - } + }, + }, }, }, { @@ -129,12 +135,13 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\sallow\s(?Pprivate) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp allow private", "result": { "allow": { "private": "{{ not not private }}", - } + }, }, }, { @@ -142,7 +149,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\s(?Pauthenticate) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp authenticate", "result": { "authenticate": "{{ not not authenticate }}", @@ -153,7 +161,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\sauthentication-key\s(?P\d+)\smd5\s(?P\S+)\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp authentication-key {{ id }} md5 {{ key }} {{ encryption }}", "result": { "authentication_keys": [ @@ -162,7 +171,7 @@ def __init__(self, lines=None, module=None): "key": "{{ key }}", "encryption": "{{ encryption }}", }, - ] + ], }, }, { @@ -170,7 +179,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\s(?Plogging) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp logging", "result": { "logging": "{{ not not logging }}", @@ -181,12 +191,13 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\smaster\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp master {{ master.stratum }}", "result": { "master": { "stratum": "{{ stratum }}", - } + }, }, }, { @@ -194,7 +205,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\s(?Ppassive) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp passive", "result": { "passive": "{{ not not passive }}", @@ -211,7 +223,8 @@ def __init__(self, lines=None, module=None): (\skey\s(?P\d+))? (\sminpoll\s(?P\d+))? (\smaxpoll\s(?P\d+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp peer {{ peer }}" "{{ ' prefer' if prefer is defined else ''}}" "{{ (' use-vrf ' + vrf) if vrf is defined else '' }}" @@ -227,8 +240,8 @@ def __init__(self, lines=None, module=None): "key_id": "{{ key }}", "minpoll": "{{ minpoll }}", "maxpoll": "{{ maxpoll }}", - } - ] + }, + ], }, }, { @@ -242,7 +255,8 @@ def __init__(self, lines=None, module=None): (\skey\s(?P\d+))? (\sminpoll\s(?P\d+))? (\smaxpoll\s(?P\d+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp server {{ server }}" "{{ ' prefer' if prefer is defined else ''}}" "{{ (' use-vrf ' + vrf) if vrf is defined else '' }}" @@ -258,8 +272,8 @@ def __init__(self, lines=None, module=None): "key_id": "{{ key }}", "minpoll": "{{ minpoll }}", "maxpoll": "{{ maxpoll }}", - } - ] + }, + ], }, }, { @@ -267,7 +281,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\ssource\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp source {{ source }}", "result": { "source": "{{ source }}", @@ -278,7 +293,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\ssource-interface(\s)+(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp source-interface {{ source_interface }}", "result": { "source_interface": "{{ source_interface }}", @@ -289,14 +305,15 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^ntp\strusted-key\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "ntp trusted-key {{ key_id|string }}", "result": { "trusted_keys": [ { "key_id": "{{ key }}", - } - ] + }, + ], }, }, ] diff --git a/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py b/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py index 9b57d4c85..aa01db1d7 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py @@ -44,9 +44,11 @@ def __init__(self, lines=None, module=None): PARSERS = [ { "name": "interface", - "getval": re.compile(r''' + "getval": re.compile( + r''' ^interface - \s(?P\S+)$''', re.VERBOSE), + \s(?P\S+)$''', re.VERBOSE, + ), "setval": "interface {{ name }}", "result": { "{{ name }}": { @@ -82,12 +84,12 @@ def __init__(self, lines=None, module=None): "area_id": "{{ area_id }}", "secondaries": "{{ False if secondaries is defined else None }}", }, - } - } + }, + }, }, - } - } - } + }, + }, + }, }, { "name": "processes_multi_areas", @@ -113,12 +115,12 @@ def __init__(self, lines=None, module=None): "multi_areas": [ "{{ area }}", ], - } - } + }, + }, }, - } - } - } + }, + }, + }, }, { "name": "multi_areas", @@ -139,11 +141,11 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi == 'ip' else 'ipv6' }}", "multi_areas": [ "{{ area }}", - ] + ], }, - } - } - } + }, + }, + }, }, { "name": "authentication", @@ -165,11 +167,11 @@ def __init__(self, lines=None, module=None): "enable": "{{ True if authentication is defined and opt is undefined }}", "message_digest": "{{ True if opt == 'message-digest' else None }}", "null_auth": "{{ True if opt == 'null' else None }}", - } + }, }, - } - } - } + }, + }, + }, }, { "name": "authentication.key_chain", @@ -189,11 +191,11 @@ def __init__(self, lines=None, module=None): "afi": "{{ afi|replace('ip', 'ipv4') }}", "authentication": { "key_chain": "{{ key_chain }}", - } + }, }, - } - } - } + }, + }, + }, }, { "name": "authentication_key", @@ -216,11 +218,11 @@ def __init__(self, lines=None, module=None): "authentication_key": { "encryption": "{{ encryption }}", "key": "{{ key }}", - } + }, }, - } - } - } + }, + }, + }, }, { "name": "message_digest_key", @@ -247,11 +249,11 @@ def __init__(self, lines=None, module=None): "key_id": "{{ key_id }}", "encryption": "{{ encryption }}", "key": "{{ key }}", - } + }, }, - } - } - } + }, + }, + }, }, { "name": "cost", @@ -272,9 +274,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "cost": "{{ cost }}", }, - } - } - } + }, + }, + }, }, { "name": "dead_interval", @@ -295,9 +297,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "dead_interval": "{{ dead_interval }}", }, - } - } - } + }, + }, + }, }, { "name": "hello_interval", @@ -318,9 +320,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "hello_interval": "{{ hello_interval }}", }, - } - } - } + }, + }, + }, }, { "name": "instance", @@ -338,9 +340,9 @@ def __init__(self, lines=None, module=None): "afi": "ipv6", "instance": "{{ instance }}", }, - } - } - } + }, + }, + }, }, { "name": "mtu_ignore", @@ -361,9 +363,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "mtu_ignore": "{{ not not mtu_ignore }}", }, - } - } - } + }, + }, + }, }, { "name": "network", @@ -384,9 +386,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "network": "{{ network }}", }, - } - } - } + }, + }, + }, }, { "name": "passive_interface", @@ -408,9 +410,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "passive_interface": "{{ False if negated is defined else (not not passive_interface) }}", }, - } - } - } + }, + }, + }, }, { "name": "priority", @@ -431,9 +433,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "priority": "{{ priority }}", }, - } - } - } + }, + }, + }, }, { "name": "retransmit_interval", @@ -454,9 +456,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "retransmit_interval": "{{ retransmit_interval }}", }, - } - } - } + }, + }, + }, }, { "name": "shutdown", @@ -477,9 +479,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "shutdown": "{{ not not shutdown }}", }, - } - } - } + }, + }, + }, }, { "name": "transmit_delay", @@ -500,9 +502,9 @@ def __init__(self, lines=None, module=None): "afi": "{{ 'ipv4' if afi is defined else 'ipv6' }}", "transmit_delay": "{{ transmit_delay }}", }, - } - } - } + }, + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/nxos/rm_templates/ospfv2.py b/plugins/module_utils/network/nxos/rm_templates/ospfv2.py index 16b00694a..9d6600996 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospfv2.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospfv2.py @@ -217,9 +217,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "vrf": "{{ vrf }}" - } - } + "vrf": "{{ vrf }}", + }, + }, }, "shared": True, }, @@ -234,9 +234,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "bfd": "{{ not not bfd }}" - } - } + "bfd": "{{ not not bfd }}", + }, + }, }, }, { @@ -265,8 +265,8 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "down_bit_ignore": "{{ not not down_bit_ignore }}", - } - } + }, + }, }, }, { @@ -288,10 +288,10 @@ def __init__(self, lines=None): "vrf_lite": { "set": "{{ True if vrf_lite is defined and evpn is undefined else None }}", "evpn": "{{ not not evpn }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -313,9 +313,9 @@ def __init__(self, lines=None): "auto_cost": { "reference_bandwidth": "{{ acrb }}", "unit": "{{ unit }}", - } - } - } + }, + }, + }, }, }, { @@ -327,7 +327,7 @@ def __init__(self, lines=None): ), "setval": "flush-routes", "result": { - "flush_routes": "{{ not not flush_routes }}" + "flush_routes": "{{ not not flush_routes }}", }, }, { @@ -344,10 +344,10 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { - "set": "{{ not graceful_restart }}" - } - } - } + "set": "{{ not graceful_restart }}", + }, + }, + }, }, }, { @@ -365,9 +365,9 @@ def __init__(self, lines=None): '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { "helper_disable": "{{ not not helper_disable }}", - } - } - } + }, + }, + }, }, }, { @@ -386,9 +386,9 @@ def __init__(self, lines=None): '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { "grace_period": "{{ grace_period }}", - } - } - } + }, + }, + }, }, }, { @@ -416,9 +416,9 @@ def __init__(self, lines=None): "log_adjacency_changes": { "log": "{{ True if log is defined and detail is undefined else None }}", "detail": "{{ True if detail is defined else None }}", - } - } - } + }, + }, + }, }, }, { @@ -447,9 +447,9 @@ def __init__(self, lines=None): "ignore_count": "{{ ig_count }}", "reset_time": "{{ rst_time }}", "warning_only": "{{ not not warning_only }}", - } - } - } + }, + }, + }, }, }, { @@ -467,10 +467,10 @@ def __init__(self, lines=None): "areas": [ { "area_id": "{{ area_id }}", - } - ] - } - } + }, + ], + }, + }, }, }, { @@ -500,9 +500,9 @@ def __init__(self, lines=None): "result": { "mpls": { "traffic_eng": { - "multicast_intact": "{{ not not multicast_intact }}" - } - } + "multicast_intact": "{{ not not multicast_intact }}", + }, + }, }, }, { @@ -517,9 +517,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "name_lookup": "{{ not not name_lookup }}" - } - } + "name_lookup": "{{ not not name_lookup }}", + }, + }, }, }, { @@ -535,9 +535,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "passive_interface": {"default": "{{ not not default }}"} - } - } + "passive_interface": {"default": "{{ not not default }}"}, + }, + }, }, }, { @@ -551,9 +551,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "rfc1583compatibility": "{{ not not rfc }}" - } - } + "rfc1583compatibility": "{{ not not rfc }}", + }, + }, }, }, { @@ -568,9 +568,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "router_id": "{{ router_id }}" - } - } + "router_id": "{{ router_id }}", + }, + }, }, }, { @@ -584,9 +584,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "shutdown": "{{ not not shutdown }}" - } - } + "shutdown": "{{ not not shutdown }}", + }, + }, }, }, { @@ -609,10 +609,10 @@ def __init__(self, lines=None): "set": "{{ True if originate is defined and always is undefined and route_map is undefined else None }}", "always": "{{ not not always }}", "route_map": "{{ route_map }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -627,9 +627,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "default_metric": "{{ default_metric }}" - } - } + "default_metric": "{{ default_metric }}", + }, + }, }, }, { @@ -644,9 +644,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "distance": "{{ distance }}" - } - } + "distance": "{{ distance }}", + }, + }, }, }, { @@ -666,9 +666,9 @@ def __init__(self, lines=None): "table_map": { "name": "{{ rmap }}", "filter": "{{ not not filter }}", - } - } - } + }, + }, + }, }, }, { @@ -686,10 +686,10 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "timers": { - "lsa_arrival": "{{ lsa_arrival_val }}" - } - } - } + "lsa_arrival": "{{ lsa_arrival_val }}", + }, + }, + }, }, }, { @@ -707,10 +707,10 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "timers": { - "lsa_group_pacing": "{{ lsa_group_pacing }}" - } - } - } + "lsa_group_pacing": "{{ lsa_group_pacing }}", + }, + }, + }, }, }, { @@ -736,11 +736,11 @@ def __init__(self, lines=None): "start_interval": "{{ start }}", "hold_interval": "{{ hold }}", "max_interval": "{{ max }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -766,11 +766,11 @@ def __init__(self, lines=None): "initial_spf_delay": "{{ initial }}", "min_hold_time": "{{ min }}", "max_wait_time": "{{ max }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -791,10 +791,10 @@ def __init__(self, lines=None): "{{ area_id }}": { "area_id": "{{ area_id }}", "default_cost": "{{ default_cost|int }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -818,12 +818,12 @@ def __init__(self, lines=None): "area_id": "{{ area_id }}", "authentication": { "set": "{{ True if auth is defined and md is undefined }}", - "message_digest": "{{ True if md is defined else False }}" + "message_digest": "{{ True if md is defined else False }}", }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -849,10 +849,10 @@ def __init__(self, lines=None): "direction": "{{ dir }}", }, ], - } - } - } - } + }, + }, + }, + }, }, }, { @@ -876,9 +876,9 @@ def __init__(self, lines=None): "id": "{{ id }}", "route_map": "{{ rmap }}", }, - ] - } - } + ], + }, + }, }, }, { @@ -908,10 +908,10 @@ def __init__(self, lines=None): "no_redistribution": "{{ not not no_redis }}", "default_information_originate": "{{ not not def_info }}", }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -940,13 +940,13 @@ def __init__(self, lines=None): "always": '{{ True if choice == "always" else None }}', "never": '{{ True if choice == "never" else None }}', "supress_fa": "{{ not not supress_fa }}", - } - } + }, + }, }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -975,10 +975,10 @@ def __init__(self, lines=None): "not_advertise": "{{ not not not_adver }}", }, ], - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1002,9 +1002,9 @@ def __init__(self, lines=None): "not_advertise": "{{ not not not_adver }}", "tag": "{{ tag }}", }, - ] - } - } + ], + }, + }, }, }, { @@ -1030,10 +1030,10 @@ def __init__(self, lines=None): "set": "{{ True if stub is defined and no_summary is undefined else None }}", "no_summary": "{{ not not no_summary }}", }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1047,8 +1047,8 @@ def __init__(self, lines=None): "setval": ("maximum-paths {{ maximum_paths }}"), "result": { "vrfs": { - '{{ "vrf_" + vrf|d() }}': {"maximum_paths": "{{ maximum_paths }}"} - } + '{{ "vrf_" + vrf|d() }}': {"maximum_paths": "{{ maximum_paths }}"}, + }, }, }, { @@ -1091,10 +1091,10 @@ def __init__(self, lines=None): "set": "{{ True if summary_lsa is defined and sum_lsa_max_metric_value is undefined else None }}", "max_metric_value": "{{ sum_lsa_max_metric_value }}", }, - } - } - } - } + }, + }, + }, + }, }, }, ] diff --git a/plugins/module_utils/network/nxos/rm_templates/ospfv3.py b/plugins/module_utils/network/nxos/rm_templates/ospfv3.py index 9f66a00f3..6c9c78b8f 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospfv3.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospfv3.py @@ -181,9 +181,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "vrf": "{{ vrf }}" - } - } + "vrf": "{{ vrf }}", + }, + }, }, "shared": True, }, @@ -213,9 +213,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "router_id": "{{ router_id }}" - } - } + "router_id": "{{ router_id }}", + }, + }, }, }, { @@ -233,7 +233,7 @@ def __init__(self, lines=None): "address_family": { "afi": "{{ afi }}", "safi": "{{ safi }}", - } + }, }, 'shared': True, }, @@ -254,9 +254,9 @@ def __init__(self, lines=None): "{{ area_id }}": { "area_id": "{{ area_id }}", "default_cost": "{{ default_cost|int }}", - } - } - } + }, + }, + }, }, }, { @@ -281,9 +281,9 @@ def __init__(self, lines=None): "direction": "{{ dir }}", }, ], - } - } - } + }, + }, + }, }, }, { @@ -311,9 +311,9 @@ def __init__(self, lines=None): "not_advertise": "{{ not not not_adver }}", }, ], - } - } - } + }, + }, + }, }, }, { @@ -335,9 +335,9 @@ def __init__(self, lines=None): "set": "{{ True if originate is defined and always is undefined and route_map is undefined else None }}", "always": "{{ not not always }}", "route_map": "{{ route_map }}", - } - } - } + }, + }, + }, }, }, { @@ -351,8 +351,8 @@ def __init__(self, lines=None): "setval": "distance {{ distance }}", "result": { "address_family": { - "distance": "{{ distance }}" - } + "distance": "{{ distance }}", + }, }, }, { @@ -366,8 +366,8 @@ def __init__(self, lines=None): "setval": ("maximum-paths {{ maximum_paths }}"), "result": { "address_family": { - "maximum_paths": "{{ maximum_paths }}" - } + "maximum_paths": "{{ maximum_paths }}", + }, }, }, { @@ -390,8 +390,8 @@ def __init__(self, lines=None): "id": "{{ id }}", "route_map": "{{ rmap }}", }, - ] - } + ], + }, }, }, { @@ -414,8 +414,8 @@ def __init__(self, lines=None): "not_advertise": "{{ not not not_adver }}", "tag": "{{ tag }}", }, - ] - } + ], + }, }, }, { @@ -434,8 +434,8 @@ def __init__(self, lines=None): "table_map": { "name": "{{ rmap }}", "filter": "{{ not not filter }}", - } - } + }, + }, }, }, { @@ -460,10 +460,10 @@ def __init__(self, lines=None): "initial_spf_delay": "{{ initial }}", "min_hold_time": "{{ min }}", "max_wait_time": "{{ max }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -496,10 +496,10 @@ def __init__(self, lines=None): "default_information_originate": "{{ not not def_info }}", "route_map": "{{ rmap }}", }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -528,13 +528,13 @@ def __init__(self, lines=None): "always": '{{ True if choice == "always" else None }}', "never": '{{ True if choice == "never" else None }}', "supress_fa": "{{ not not supress_fa }}", - } - } + }, + }, }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -560,10 +560,10 @@ def __init__(self, lines=None): "set": "{{ True if stub is defined and no_summary is undefined else None }}", "no_summary": "{{ not not no_summary }}", }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -586,9 +586,9 @@ def __init__(self, lines=None): "area_id": "{{ area_id }}", "virtual_link": "{{ virtual_link }}", }, - } - } - } + }, + }, + }, }, }, { @@ -610,9 +610,9 @@ def __init__(self, lines=None): "auto_cost": { "reference_bandwidth": "{{ acrb }}", "unit": "{{ unit }}", - } - } - } + }, + }, + }, }, }, { @@ -624,7 +624,7 @@ def __init__(self, lines=None): ), "setval": "flush-routes", "result": { - "flush_routes": "{{ not not flush_routes }}" + "flush_routes": "{{ not not flush_routes }}", }, }, { @@ -641,10 +641,10 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { - "set": "{{ not graceful_restart }}" - } - } - } + "set": "{{ not graceful_restart }}", + }, + }, + }, }, }, { @@ -662,9 +662,9 @@ def __init__(self, lines=None): '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { "helper_disable": "{{ not not helper_disable }}", - } - } - } + }, + }, + }, }, }, { @@ -683,9 +683,9 @@ def __init__(self, lines=None): '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { "grace_period": "{{ grace_period }}", - } - } - } + }, + }, + }, }, }, { @@ -704,9 +704,9 @@ def __init__(self, lines=None): '{{ "vrf_" + vrf|d() }}': { "graceful_restart": { "planned_only": "{{ not planned_only }}", - } - } - } + }, + }, + }, }, }, { @@ -734,9 +734,9 @@ def __init__(self, lines=None): "log_adjacency_changes": { "log": "{{ True if log is defined and detail is undefined else None }}", "detail": "{{ True if detail is defined else None }}", - } - } - } + }, + }, + }, }, }, { @@ -766,9 +766,9 @@ def __init__(self, lines=None): "ignore_count": "{{ ig_count }}", "reset_time": "{{ rst_time }}", "warning_only": "{{ not not warning_only }}", - } - } - } + }, + }, + }, }, }, { @@ -812,10 +812,10 @@ def __init__(self, lines=None): "set": "{{ True if inter_area_prefix_lsa is defined and max_metric_summary_lsa is undefined else None }}", "max_metric_value": "{{ max_metric_summary_lsa }}", }, - } - } - } - } + }, + }, + }, + }, }, }, { @@ -830,9 +830,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "name_lookup": "{{ not not name_lookup }}" - } - } + "name_lookup": "{{ not not name_lookup }}", + }, + }, }, }, { @@ -848,9 +848,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "passive_interface": {"default": "{{ not not default }}"} - } - } + "passive_interface": {"default": "{{ not not default }}"}, + }, + }, }, }, { @@ -864,9 +864,9 @@ def __init__(self, lines=None): "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { - "shutdown": "{{ not not shutdown }}" - } - } + "shutdown": "{{ not not shutdown }}", + }, + }, }, }, { @@ -884,10 +884,10 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "timers": { - "lsa_arrival": "{{ lsa_arrival_val }}" - } - } - } + "lsa_arrival": "{{ lsa_arrival_val }}", + }, + }, + }, }, }, { @@ -905,10 +905,10 @@ def __init__(self, lines=None): "vrfs": { '{{ "vrf_" + vrf|d() }}': { "timers": { - "lsa_group_pacing": "{{ lsa_group_pacing }}" - } - } - } + "lsa_group_pacing": "{{ lsa_group_pacing }}", + }, + }, + }, }, }, { @@ -934,11 +934,11 @@ def __init__(self, lines=None): "start_interval": "{{ start }}", "hold_interval": "{{ hold }}", "max_interval": "{{ max }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, ] diff --git a/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py b/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py index 162d7dd62..0bb66eada 100644 --- a/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py +++ b/plugins/module_utils/network/nxos/rm_templates/prefix_lists.py @@ -43,7 +43,8 @@ def __init__(self, lines=None, module=None): (\sle\s(?P\d+))? (\smask\s(?P\S+))? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'ip' if afi == 'ipv4' else afi }} prefix-list {{ name }}" "{{ (' seq ' + sequence|string) if sequence|d('') else '' }}" " {{ action }}" @@ -67,10 +68,10 @@ def __init__(self, lines=None, module=None): "ge": "{{ ge }}", "le": "{{ le }}", "mask": "{{ mask }}", - } + }, ], - } - } + }, + }, }, }, }, @@ -82,7 +83,8 @@ def __init__(self, lines=None, module=None): \sprefix-list \s(?P\S+) \sdescription\s(?P.+)\s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "{{ 'ip' if afi == 'ipv4' else afi }} prefix-list {{ name }} description {{ description }}", "result": { "{{ 'ipv4' if afi == 'ip' else 'ipv6' }}": { @@ -91,8 +93,8 @@ def __init__(self, lines=None, module=None): "{{ name }}": { "name": "{{ name }}", "description": "{{ description }}", - } - } + }, + }, }, }, }, diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index 64a155d2a..dfbfc88e9 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -96,7 +96,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^route-map\s(?P\S+)\s(?P\S+)\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "route-map {{ route_map }}" "{{ ' ' + action if action is defined else '' }}" "{{ ' ' + sequence|string if sequence is defined else '' }}", @@ -107,9 +108,9 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "sequence": "{{ sequence }}", "action": "{{ action }}", - } - } - } + }, + }, + }, }, "shared": True, }, @@ -118,16 +119,17 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+continue\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "continue {{ continue_sequence }}", "result": { "{{ route_map }}": { "entries": { "{{ sequence }}": { "continue_sequence": "{{ continue_sequence }}", - } - } - } + }, + }, + }, }, }, { @@ -135,16 +137,17 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+description\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "description {{ description }}", "result": { "{{ route_map }}": { "entries": { "{{ sequence }}": { "description": "{{ description }}", - } - } - } + }, + }, + }, }, }, { @@ -154,7 +157,8 @@ def __init__(self, lines=None, module=None): \s+match\sas-number (?!\sas-path-list) \s(?P.+)\s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match as-number {{ match.as_number.asn|join(', ') }}", "result": { "{{ route_map }}": { @@ -164,11 +168,11 @@ def __init__(self, lines=None, module=None): "match": { "as_number": { "asn": "{{ asn.rstrip().split(', ') }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -177,7 +181,8 @@ def __init__(self, lines=None, module=None): r""" \s+match\sas-number \sas-path-list\s(?P.+)\s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match as-number as-path-list {{ match.as_number.as_path_list|join(' ') }}", "result": { "{{ route_map }}": { @@ -186,11 +191,11 @@ def __init__(self, lines=None, module=None): "match": { "as_number": { "as_path_list": "{{ as_path_list.split() }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -198,7 +203,8 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+match\sas-path\s(?P.+)\s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match as-path {{ match.as_path|join(' ') }}", "result": { "{{ route_map }}": { @@ -206,10 +212,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "as_path": "{{ as_path.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -220,7 +226,8 @@ def __init__(self, lines=None, module=None): \s(?P.+) (\s(?Pexact-match))? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match community {{ match.community.community_list|join(' ') }}{{ ' exact-match' if match.community.exact_match|d(False) else '' }}", "result": { "{{ route_map }}": { @@ -230,11 +237,11 @@ def __init__(self, lines=None, module=None): "community": { "community_list": "{{ community_list.split() }}", "exact_match": "{{ not not exact_match }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -244,7 +251,8 @@ def __init__(self, lines=None, module=None): \s+match\sevpn \sroute-type \s(?P.+)\s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match evpn route-type {{ match.evpn.route_types|join(' ') }}", "result": { "{{ route_map }}": { @@ -253,11 +261,11 @@ def __init__(self, lines=None, module=None): "match": { "evpn": { "route_types": "{{ route_types.split() }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -268,7 +276,8 @@ def __init__(self, lines=None, module=None): \s(?P.+) \s(?Pexact-match)? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match extcommunity {{ match.extcommunity.extcommunity_list|join(' ') }}" "{{ ' exact-match' if match.extcommunity.exact_match|d(False) else '' }}", "result": { @@ -279,11 +288,11 @@ def __init__(self, lines=None, module=None): "extcommunity": { "extcommunity_list": "{{ extcommunity_list.split() }}", "exact_match": "{{ not not exact_match }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -293,18 +302,19 @@ def __init__(self, lines=None, module=None): \s+match\sinterface \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match interface {{ match.interfaces|join(' ') }}", "result": { "{{ route_map }}": { "entries": { "{{ sequence }}": { "match": { - "interfaces": "{{ interfaces.split() }}" - } - } - } - } + "interfaces": "{{ interfaces.split() }}", + }, + }, + }, + }, }, }, { @@ -314,7 +324,8 @@ def __init__(self, lines=None, module=None): \s+match\sip\saddress \s(?P\S+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ip address {{ match.ip.address.access_list }}", "result": { "{{ route_map }}": { @@ -324,12 +335,12 @@ def __init__(self, lines=None, module=None): "ip": { "address": { "access_list": "{{ access_list }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -340,7 +351,8 @@ def __init__(self, lines=None, module=None): \sprefix-list \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ip address prefix-list {{ match.ip.address.prefix_lists|join(' ') }}", "result": { "{{ route_map }}": { @@ -350,12 +362,12 @@ def __init__(self, lines=None, module=None): "ip": { "address": { "prefix_lists": "{{ prefix_lists.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, # match ip multicast source 192.1.2.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 209.165.201.0/27 rp-type Bidir @@ -373,7 +385,8 @@ def __init__(self, lines=None, module=None): (\srp\s(?P\S+))? (\srp-type\s(?P\S+))? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": _tmplt_match_ip_multicast, "result": { "{{ route_map }}": { @@ -395,11 +408,11 @@ def __init__(self, lines=None, module=None): }, "source": "{{ source }}", }, - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -409,7 +422,8 @@ def __init__(self, lines=None, module=None): \s+match\sip\snext-hop \sprefix-list\s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ip next-hop prefix-list {{ match.ip.next_hop.prefix_lists|join(' ') }}", "result": { "{{ route_map }}": { @@ -419,12 +433,12 @@ def __init__(self, lines=None, module=None): "ip": { "next_hop": { "prefix_lists": "{{ prefix_lists.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -434,7 +448,8 @@ def __init__(self, lines=None, module=None): \s+match\sip\sroute-source \sprefix-list\s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ip route-source prefix-list {{ match.ip.route_source.prefix_lists|join(' ') }}", "result": { "{{ route_map }}": { @@ -444,12 +459,12 @@ def __init__(self, lines=None, module=None): "ip": { "route_source": { "prefix_lists": "{{ prefix_lists.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -459,7 +474,8 @@ def __init__(self, lines=None, module=None): \s+match\sipv6\saddress \s(?P\S+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ipv6 address {{ match.ipv6.address.access_list }}", "result": { "{{ route_map }}": { @@ -469,12 +485,12 @@ def __init__(self, lines=None, module=None): "ipv6": { "address": { "access_list": "{{ access_list }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -485,7 +501,8 @@ def __init__(self, lines=None, module=None): \sprefix-list \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ipv6 address prefix-list {{ match.ipv6.address.prefix_lists|join(' ') }}", "result": { "{{ route_map }}": { @@ -495,12 +512,12 @@ def __init__(self, lines=None, module=None): "ipv6": { "address": { "prefix_lists": "{{ prefix_lists.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -517,7 +534,8 @@ def __init__(self, lines=None, module=None): (\srp\s(?P\S+))? (\srp-type\s(?P\S+))? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": _tmplt_match_ipv6_multicast, "result": { "{{ route_map }}": { @@ -539,11 +557,11 @@ def __init__(self, lines=None, module=None): }, "source": "{{ source }}", }, - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -553,7 +571,8 @@ def __init__(self, lines=None, module=None): \s+match\sipv6\snext-hop \sprefix-list\s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ipv6 next-hop prefix-list {{ match.ipv6.next_hop.prefix_lists|join(' ') }}", "result": { "{{ route_map }}": { @@ -563,12 +582,12 @@ def __init__(self, lines=None, module=None): "ipv6": { "next_hop": { "prefix_lists": "{{ prefix_lists.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -578,7 +597,8 @@ def __init__(self, lines=None, module=None): \s+match\sipv6\sroute-source \sprefix-list\s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ipv6 route-source prefix-list {{ match.ipv6.route_source.prefix_lists|join(' ') }}", "result": { "{{ route_map }}": { @@ -588,12 +608,12 @@ def __init__(self, lines=None, module=None): "ipv6": { "route_source": { "prefix_lists": "{{ prefix_lists.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -603,7 +623,8 @@ def __init__(self, lines=None, module=None): \s+match\smac-list \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match mac-list {{ match.mac_list|join(' ') }}", "result": { "{{ route_map }}": { @@ -611,10 +632,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "mac_list": "{{ mac_list.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -624,7 +645,8 @@ def __init__(self, lines=None, module=None): \s+match\smetric \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match metric {{ match.metric|join(' ') }}", "result": { "{{ route_map }}": { @@ -632,10 +654,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "metric": "{{ metric.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -645,7 +667,8 @@ def __init__(self, lines=None, module=None): \s+match\sospf-area \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match ospf-area {{ match.ospf_area|join(' ') }}", "result": { "{{ route_map }}": { @@ -653,10 +676,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "ospf_area": "{{ ospf_area.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -666,7 +689,8 @@ def __init__(self, lines=None, module=None): \s+match\sroute-type \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match route-type {{ match.route_types|join(' ') }}", "result": { "{{ route_map }}": { @@ -674,10 +698,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "route_types": "{{ route_types.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -687,7 +711,8 @@ def __init__(self, lines=None, module=None): \s+match\ssource-protocol \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match source-protocol {{ match.source_protocol|join(' ') }}", "result": { "{{ route_map }}": { @@ -695,10 +720,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "source_protocol": "{{ source_protocol.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -708,7 +733,8 @@ def __init__(self, lines=None, module=None): \s+match\stag \s(?P.+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "match tag {{ match.tags|join(' ') }}", "result": { "{{ route_map }}": { @@ -716,10 +742,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "match": { "tags": "{{ tags.split() }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -729,7 +755,8 @@ def __init__(self, lines=None, module=None): \s+set\sas-path\sprepend \s(?P(?!last-as).+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set as-path prepend {{ set.as_path.prepend.as_number|join(' ') }}", "result": { "{{ route_map }}": { @@ -739,12 +766,12 @@ def __init__(self, lines=None, module=None): "as_path": { "prepend": { "as_number": "{{ as_number.split() }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -754,7 +781,8 @@ def __init__(self, lines=None, module=None): \s+set\sas-path\sprepend \slast-as\s(?P\d+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set as-path prepend last-as {{ set.as_path.prepend.last_as|string }}", "result": { "{{ route_map }}": { @@ -764,12 +792,12 @@ def __init__(self, lines=None, module=None): "as_path": { "prepend": { "last_as": "{{ last_as }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -779,7 +807,8 @@ def __init__(self, lines=None, module=None): \s+set\sas-path \s(?Ptag) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set as-path tag", "result": { "{{ route_map }}": { @@ -788,11 +817,11 @@ def __init__(self, lines=None, module=None): "set": { "as_path": { "tag": "{{ not not tag }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -802,7 +831,8 @@ def __init__(self, lines=None, module=None): \s+set\scomm-list \s(?P\S+) \s*delete - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set comm-list {{ set.comm_list }} delete", "result": { "{{ route_map }}": { @@ -810,10 +840,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "comm_list": "{{ comm_list }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -828,7 +858,8 @@ def __init__(self, lines=None, module=None): (\s(?Plocal-AS))? (\s(?Pgraceful-shutdown))? (\s(?Padditive))?\s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set community" "{{ ' internet' if set.community.internet|d(False) else '' }}" "{{ ' ' + set.community.number|join(' ') if set.community.number|d(False) else '' }}" @@ -850,11 +881,11 @@ def __init__(self, lines=None, module=None): "local_as": "{{ not not local_as }}", "graceful_shutdown": "{{ not not graceful_shutdown }}", "additive": "{{ not not additive }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -867,7 +898,8 @@ def __init__(self, lines=None, module=None): \s(?P\d+) \s(?P\d+) \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set dampening {{ set.dampening.half_life }}" " {{ set.dampening.start_reuse_route }}" " {{ set.dampening.start_suppress_route }}" @@ -882,11 +914,11 @@ def __init__(self, lines=None, module=None): "start_reuse_route": "{{ start_reuse_route }}", "start_suppress_route": "{{ start_suppress_route }}", "max_suppress_time": "{{ max_suppress_time }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -898,7 +930,8 @@ def __init__(self, lines=None, module=None): (\s(?P\d+))? (\s(?P\d+))? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set distance {{ set.distance.igp_ebgp_routes }}" "{{ ' ' + set.distance.internal_routes|string if set.distance.internal_routes|d(False) else '' }}" "{{ ' ' + set.distance.local_routes|string if set.distance.internal_routes|d(False) else '' }}", @@ -911,11 +944,11 @@ def __init__(self, lines=None, module=None): "igp_ebgp_routes": "{{ igp_ebgp_routes }}", "internal_routes": "{{ internal_routes }}", "local_routes": "{{ local_routes }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -927,7 +960,8 @@ def __init__(self, lines=None, module=None): (\s(?P(?!use-nexthop)\S+))? (\s(?Puse-nexthop))? \s* - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "set evpn gateway-ip" "{{ ' ' + set.evpn.gateway_ip.ip if set.evpn.gateway_ip.ip|d(False) else ''}}" "{{ ' use-nexthop' if set.evpn.gateway_ip.use_nexthop|d(False) else '' }}", @@ -940,12 +974,12 @@ def __init__(self, lines=None, module=None): "gateway_ip": { "ip": "{{ ip }}", "use_nexthop": "{{ not not use_nexthop }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -955,7 +989,8 @@ def __init__(self, lines=None, module=None): \s+set\sextcomm-list \s(?P\S+) \s*delete - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set extcomm-list {{ set.extcomm_list }} delete", "result": { "{{ route_map }}": { @@ -963,10 +998,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "extcomm_list": "{{ extcomm_list }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -975,7 +1010,8 @@ def __init__(self, lines=None, module=None): r""" \s+set \s(?Pforwarding-address) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set forwarding-address", "result": { "{{ route_map }}": { @@ -983,10 +1019,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "forwarding_address": "{{ not not forwarding_address }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -995,7 +1031,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sinterface \s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set interface {{ set.null_interface }}", "result": { "{{ route_map }}": { @@ -1003,10 +1040,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "null_interface": "{{ interface }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1015,7 +1052,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sip\saddress \sprefix-list\s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set ip address prefix-list {{ set.ip.address.prefix_list }}", "result": { "{{ route_map }}": { @@ -1025,12 +1063,12 @@ def __init__(self, lines=None, module=None): "ip": { "address": { "prefix_list": "{{ prefix_list }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -1039,7 +1077,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sip \sprecedence\s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set ip precedence {{ set.ip.precedence }}", "result": { "{{ route_map }}": { @@ -1048,11 +1087,11 @@ def __init__(self, lines=None, module=None): "set": { "ip": { "precedence": "{{ precedence }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -1061,7 +1100,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sipv6\saddress \sprefix-list\s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set ipv6 address prefix-list {{ set.ipv6.address.prefix_list }}", "result": { "{{ route_map }}": { @@ -1071,12 +1111,12 @@ def __init__(self, lines=None, module=None): "ipv6": { "address": { "prefix_list": "{{ prefix_list }}", - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, }, }, { @@ -1085,7 +1125,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sipv6 \sprecedence\s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set ipv6 precedence {{ set.ipv6.precedence }}", "result": { "{{ route_map }}": { @@ -1094,11 +1135,11 @@ def __init__(self, lines=None, module=None): "set": { "ipv6": { "precedence": "{{ precedence }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -1107,7 +1148,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\slabel-index \s(?P\d+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set label-index {{ set.label_index }}", "result": { "{{ route_map }}": { @@ -1115,10 +1157,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "label_index": "{{ label_index }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1127,7 +1169,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\slevel \s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set level {{ set.level }}", "result": { "{{ route_map }}": { @@ -1135,10 +1178,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "level": "{{ level }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1147,7 +1190,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\slocal-preference \s(?P\d+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set local-preference {{ set.local_preference }}", "result": { "{{ route_map }}": { @@ -1155,10 +1199,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "local_preference": "{{ local_preference }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1171,7 +1215,8 @@ def __init__(self, lines=None, module=None): (\s(?P\d+))? (\s(?P\d+))? (\s(?P\d+))? - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": _tmplt_set_metric, "result": { "{{ route_map }}": { @@ -1184,11 +1229,11 @@ def __init__(self, lines=None, module=None): "igrp_reliability_metric": "{{ igrp_reliability_metric }}", "igrp_effective_bandwidth_metric": "{{ igrp_effective_bandwidth_metric }}", "igrp_mtu": "{{ igrp_mtu }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, }, { @@ -1197,7 +1242,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\smetric-type \s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set metric-type {{ set.metric_type }}", "result": { "{{ route_map }}": { @@ -1205,10 +1251,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "metric_type": "{{ metric_type }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1217,7 +1263,8 @@ def __init__(self, lines=None, module=None): r""" \s+set \s(?Pnssa-only) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set nssa-only", "result": { "{{ route_map }}": { @@ -1225,10 +1272,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "nssa_only": "{{ not not nssa_only }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1237,7 +1284,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sorigin \s(?P\S+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set origin {{ set.origin }}", "result": { "{{ route_map }}": { @@ -1245,10 +1293,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "origin": "{{ origin }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1258,7 +1306,8 @@ def __init__(self, lines=None, module=None): \s+set\spath-selection \s(?P\S+) \sadvertise - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set path-selection {{ set.path_selection }} advertise", "result": { "{{ route_map }}": { @@ -1266,10 +1315,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "path_selection": "{{ path_selection }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1278,7 +1327,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\stag \s(?P\d+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set tag {{ set.tag }}", "result": { "{{ route_map }}": { @@ -1286,10 +1336,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "tag": "{{ tag }}", - } - } - } - } + }, + }, + }, + }, }, }, { @@ -1298,7 +1348,8 @@ def __init__(self, lines=None, module=None): r""" \s+set\sweight \s(?P\d+) - \s*$""", re.VERBOSE), + \s*$""", re.VERBOSE, + ), "setval": "set weight {{ set.weight }}", "result": { "{{ route_map }}": { @@ -1306,10 +1357,10 @@ def __init__(self, lines=None, module=None): "{{ sequence }}": { "set": { "weight": "{{ weight }}", - } - } - } - } + }, + }, + }, + }, }, }, ] diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index 1bf42ff0f..f131f5360 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -105,12 +105,13 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\saaa-user \scache-timeout\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server aaa-user cache-timeout {{ aaa_user.cache_timeout }}", "result": { "aaa_user": { "cache_timeout": "{{ cache_timeout }}", - } + }, }, }, { @@ -122,7 +123,8 @@ def __init__(self, lines=None, module=None): (\sgroup\s(?P\S+))? (\suse-ipv4acl\s(?P\S+))? (\suse-ipv6acl\s(?P\S+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": _template_communities, "result": { "communities": [ @@ -131,8 +133,8 @@ def __init__(self, lines=None, module=None): "group": "{{ group }}", "use_ipv4acl": "{{ use_ipv4acl }}", "use_ipv6acl": "{{ use_ipv6acl }}", - } - ] + }, + ], }, }, { @@ -141,7 +143,8 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \scontact\s(?P.+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server contact {{ contact }}", "result": { "contact": "{{ contact }}", @@ -156,7 +159,8 @@ def __init__(self, lines=None, module=None): (\sinstance\s(?P\S+))? (\svrf\s(?P\S+))? (\stopology\s(?P\S+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server context {{ context.name }}" "{{ ' instance ' + context.instance if context.instance is defined else '' }}" "{{ ' topology ' + context.topology if context.topology is defined else '' }}" @@ -167,7 +171,7 @@ def __init__(self, lines=None, module=None): "instance": "{{ instance }}", "vrf": "{{ vrf }}", "topology": "{{ topology }}", - } + }, }, }, @@ -178,14 +182,15 @@ def __init__(self, lines=None, module=None): ^snmp-server \scounter \scache\s(?Penable) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server counter cache enable", "result": { "counter": { "cache": { "enable": "{{ True if enable is defined else None }}", - } - } + }, + }, }, }, { @@ -195,14 +200,15 @@ def __init__(self, lines=None, module=None): ^snmp-server \scounter \scache\stimeout\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server counter cache timeout {{ counter.cache.timeout }}", "result": { "counter": { "cache": { "timeout": "{{ timeout }}", - } - } + }, + }, }, }, { @@ -211,12 +217,13 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\sdrop \s(?Punknown-engine-id) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server drop unknown-engine-id", "result": { "drop": { "unknown_engine_id": "{{ not not unknown_engine_id }}", - } + }, }, }, { @@ -225,12 +232,13 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\sdrop \s(?Punknown-user) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server drop unknown-user", "result": { "drop": { "unknown_user": "{{ not not unknown_user }}", - } + }, }, }, { @@ -239,15 +247,16 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\senable \straps\saaa\s(?Pserver-state-change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps aaa" "{{ ' server-state-change' if traps.aaa.server_state_change|d(False) else ''}}", "result": { "traps": { "aaa": { "server_state_change": "{{ not not server_state_change }}", - } - } + }, + }, }, }, { @@ -256,14 +265,15 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\senable \straps\s(?Pbgp) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps bgp", "result": { "traps": { "bgp": { "enable": "{{ not not enable }}", - } - } + }, + }, }, }, { @@ -273,14 +283,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sbridge\s(?Pnewroot) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps bridge newroot", "result": { "traps": { "bridge": { "newroot": "{{ not not newroot }}", - } - } + }, + }, }, }, { @@ -290,14 +301,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sbridge\s(?Ptopologychange) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps bridge topologychange", "result": { "traps": { "bridge": { "topologychange": "{{ not not topologychange }}", - } - } + }, + }, }, }, { @@ -307,14 +319,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \scallhome\s(?Pevent-notify) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps callhome event-notify", "result": { "traps": { "callhome": { "event_notify": "{{ not not event_notify }}", - } - } + }, + }, }, }, { @@ -324,14 +337,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \scallhome\s(?Psmtp-send-fail) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps callhome smtp-send-fail", "result": { "traps": { "callhome": { "smtp_send_fail": "{{ not not smtp_send_fail }}", - } - } + }, + }, }, }, { @@ -341,14 +355,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \scfs\s(?Pmerge-failure) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps cfs merge-failure", "result": { "traps": { "cfs": { "merge_failure": "{{ not not merge_failure }}", - } - } + }, + }, }, }, { @@ -358,14 +373,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \scfs\s(?Pstate-change-notif) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps cfs state-change-notif", "result": { "traps": { "cfs": { "state_change_notif": "{{ not not state_change_notif }}", - } - } + }, + }, }, }, { @@ -375,14 +391,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sconfig\s(?PccmCLIRunningConfigChanged) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps config ccmCLIRunningConfigChanged", "result": { "traps": { "config": { "ccmCLIRunningConfigChanged": "{{ not not ccmCLIRunningConfigChanged }}", - } - } + }, + }, }, }, { @@ -392,14 +409,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?PcefcMIBEnableStatusNotification) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity cefcMIBEnableStatusNotification", "result": { "traps": { "entity": { "cefcMIBEnableStatusNotification": "{{ not not cefcMIBEnableStatusNotification }}", - } - } + }, + }, }, }, { @@ -409,14 +427,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-fan-status-change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-fan-status-change", "result": { "traps": { "entity": { "entity_fan_status_change": "{{ not not entity_fan_status_change }}", - } - } + }, + }, }, }, { @@ -426,14 +445,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-mib-change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-mib-change", "result": { "traps": { "entity": { "entity_mib_change": "{{ not not entity_mib_change }}", - } - } + }, + }, }, }, { @@ -443,14 +463,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-module-inserted) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-module-inserted", "result": { "traps": { "entity": { "entity_module_inserted": "{{ not not entity_module_inserted }}", - } - } + }, + }, }, }, { @@ -460,14 +481,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-module-status-change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-module-status-change", "result": { "traps": { "entity": { "entity_module_status_change": "{{ not not entity_module_status_change }}", - } - } + }, + }, }, }, { @@ -477,14 +499,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-power-out-change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-power-out-change", "result": { "traps": { "entity": { "entity_power_out_change": "{{ not not entity_power_out_change }}", - } - } + }, + }, }, }, { @@ -494,14 +517,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity_power_status_change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-power-status-change", "result": { "traps": { "entity": { "entity_power_status_change": "{{ not not entity_power_status_change }}", - } - } + }, + }, }, }, { @@ -511,14 +535,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-sensor) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-sensor", "result": { "traps": { "entity": { "entity_sensor": "{{ not not entity_sensor }}", - } - } + }, + }, }, }, { @@ -528,14 +553,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sentity\s(?Pentity-unrecognised-module) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps entity entity-unrecognised-module", "result": { "traps": { "entity": { "entity_unrecognised_module": "{{ not not entity_unrecognised_module }}", - } - } + }, + }, }, }, { @@ -545,14 +571,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sfeature-control\s(?PfeatureOpStatusChange) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps feature-control featureOpStatusChange", "result": { "traps": { "feature_control": { "featureOpStatusChange": "{{ not not featureOpStatusChange }}", - } - } + }, + }, }, }, { @@ -562,14 +589,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sfeature-control\s(?PciscoFeatOpStatusChange) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps feature-control ciscoFeatOpStatusChange", "result": { "traps": { "feature_control": { "ciscoFeatOpStatusChange": "{{ not not ciscoFeatOpStatusChange }}", - } - } + }, + }, }, }, { @@ -579,14 +607,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sgeneric\s(?PcoldStart) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps generic coldStart", "result": { "traps": { "generic": { "coldStart": "{{ not not coldStart }}", - } - } + }, + }, }, }, { @@ -596,14 +625,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sgeneric\s(?PwarmStart) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps generic warmStart", "result": { "traps": { "generic": { "warmStart": "{{ not not warmStart }}", - } - } + }, + }, }, }, { @@ -613,14 +643,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slicense\s(?Pnotify_license_expiry) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps license notify-license-expiry", "result": { "traps": { "license": { "notify_license_expiry": "{{ not not notify_license_expiry }}", - } - } + }, + }, }, }, { @@ -630,14 +661,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slicense\s(?Pnotify-license-expiry-warning) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps license notify-license-expiry-warning", "result": { "traps": { "license": { "notify_license_expiry_warning": "{{ not not notify_license_expiry_warning }}", - } - } + }, + }, }, }, { @@ -647,14 +679,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slicense\s(?Pnotify-licensefile-missing) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps license notify-licensefile-missing", "result": { "traps": { "license": { "notify_licensefile_missing": "{{ not not notify_licensefile_missing }}", - } - } + }, + }, }, }, { @@ -664,14 +697,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slicense\s(?Pnotify-no-license-for-feature) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps license notify-no-license-for-feature", "result": { "traps": { "license": { "notify_no_license_for_feature": "{{ not not notify_no_license_for_feature }}", - } - } + }, + }, }, }, { @@ -681,14 +715,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?PcErrDisableInterfaceEventRev1) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link cErrDisableInterfaceEventRev1", "result": { "traps": { "link": { "cErrDisableInterfaceEventRev1": "{{ not not cErrDisableInterfaceEventRev1 }}", - } - } + }, + }, }, }, { @@ -698,14 +733,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?PcieLinkDown) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link cieLinkDown", "result": { "traps": { "link": { "cieLinkDown": "{{ not not cieLinkDown }}", - } - } + }, + }, }, }, { @@ -715,14 +751,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?PcieLinkUp) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link cieLinkUp", "result": { "traps": { "link": { "cieLinkUp": "{{ not not cieLinkUp }}", - } - } + }, + }, }, }, { @@ -732,14 +769,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?Pcisco-xcvr-mon-status-chg) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link cisco_xcvr_mon_status_chg", "result": { "traps": { "link": { "cisco_xcvr_mon_status_chg": "{{ not not cisco_xcvr_mon_status_chg }}", - } - } + }, + }, }, }, { @@ -749,14 +787,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?Pcmn-mac-move-notification) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link cmn-mac-move-notification", "result": { "traps": { "link": { "cmn_mac_move_notification": "{{ not not cmn_mac_move_notification }}", - } - } + }, + }, }, }, { @@ -766,14 +805,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?Pdelayed-link-state-change) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link delayed-link-state-change", "result": { "traps": { "link": { "delayed_link_state_change": "{{ not not delayed_link_state_change }}", - } - } + }, + }, }, }, { @@ -783,14 +823,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?Pextended-linkDown) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link extended-linkDown", "result": { "traps": { "link": { "extended_linkDown": "{{ not not extended_linkDown }}", - } - } + }, + }, }, }, { @@ -800,14 +841,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?Pextended-linkUp) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link extended-linkUp", "result": { "traps": { "link": { "extended_linkUp": "{{ not not extended_linkUp }}", - } - } + }, + }, }, }, { @@ -817,14 +859,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?PlinkDown) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link linkDown", "result": { "traps": { "link": { "linkDown": "{{ not not linkDown }}", - } - } + }, + }, }, }, { @@ -834,14 +877,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \slink\s(?PlinkUp) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps link linkUp", "result": { "traps": { "link": { "linkUp": "{{ not not linkUp }}", - } - } + }, + }, }, }, { @@ -851,14 +895,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \smmode\s(?PcseMaintModeChangeNotify) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps mmode cseMaintModeChangeNotify", "result": { "traps": { "mmode": { "cseMaintModeChangeNotify": "{{ not not cseMaintModeChangeNotify }}", - } - } + }, + }, }, }, { @@ -868,14 +913,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \smmode\s(?PcseNormalModeChangeNotify) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps mmode cseNormalModeChangeNotify", "result": { "traps": { "mmode": { "cseNormalModeChangeNotify": "{{ not not cseNormalModeChangeNotify }}", - } - } + }, + }, }, }, { @@ -884,14 +930,15 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\senable \straps\s(?Pospf) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps ospf", "result": { "traps": { "ospf": { "enable": "{{ not not enable }}", - } - } + }, + }, }, }, { @@ -900,14 +947,15 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\senable \straps\s(?Pospfv3) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps ospfv3", "result": { "traps": { "ospfv3": { "enable": "{{ not not enable }}", - } - } + }, + }, }, }, { @@ -917,14 +965,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \srf\s(?Predundancy-framework) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps rf redundancy-framework", "result": { "traps": { "rf": { "redundancy_framework": "{{ not not redundancy_framework }}", - } - } + }, + }, }, }, { @@ -934,14 +983,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \srmon\s(?PfallingAlarm) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps rmon fallingAlarm", "result": { "traps": { "rmon": { "fallingAlarm": "{{ not not fallingAlarm }}", - } - } + }, + }, }, }, { @@ -951,14 +1001,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \srmon\s(?PhcFallingAlarm) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps rmon hcFallingAlarm", "result": { "traps": { "rmon": { "hcFallingAlarm": "{{ not not hcFallingAlarm }}", - } - } + }, + }, }, }, { @@ -968,14 +1019,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \srmon\s(?PhcRisingAlarm) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps rmon hcRisingAlarm", "result": { "traps": { "rmon": { "hcRisingAlarm": "{{ not not hcRisingAlarm }}", - } - } + }, + }, }, }, { @@ -985,14 +1037,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \srmon\s(?PrisingAlarm) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps rmon risingAlarm", "result": { "traps": { "rmon": { "risingAlarm": "{{ not not risingAlarm }}", - } - } + }, + }, }, }, { @@ -1002,14 +1055,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \ssnmp\s(?Pauthentication) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps snmp authentication", "result": { "traps": { "snmp": { "authentication": "{{ not not authentication }}", - } - } + }, + }, }, }, { @@ -1019,14 +1073,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sstorm-control\s(?PcpscEventRev1) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps storm-control cpscEventRev1", "result": { "traps": { "storm_control": { "cpscEventRev1n": "{{ not not cpscEventRev1 }}", - } - } + }, + }, }, }, { @@ -1036,14 +1091,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sstorm-control\s(?Ptrap-rate) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps storm-control trap-rate", "result": { "traps": { "storm_control": { "trap_rate": "{{ not not trap_rate }}", - } - } + }, + }, }, }, { @@ -1053,14 +1109,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sstpx\s(?Pinconsistency) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps stpx inconsistency", "result": { "traps": { "stpx": { "inconsistency": "{{ not not inconsistency }}", - } - } + }, + }, }, }, { @@ -1070,14 +1127,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sstpx\s(?Proot-inconsistency) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps stpx root-inconsistency", "result": { "traps": { "stpx": { "root_inconsistency": "{{ not not root_inconsistency }}", - } - } + }, + }, }, }, { @@ -1087,14 +1145,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \sstpx\s(?Ploop-inconsistency) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps stpx loop-inconsistency", "result": { "traps": { "stpx": { "loop_inconsistency": "{{ not not loop_inconsistency }}", - } - } + }, + }, }, }, { @@ -1104,14 +1163,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \ssyslog\s(?Pmessage-generated) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps syslog message-generated", "result": { "traps": { "syslog": { "message_generated": "{{ not not message_generated }}", - } - } + }, + }, }, }, { @@ -1121,14 +1181,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \ssysmgr\s(?PcseFailSwCoreNotifyExtended) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps sysmgr cseFailSwCoreNotifyExtended", "result": { "traps": { "sysmgr": { "cseFailSwCoreNotifyExtended": "{{ not not cseFailSwCoreNotifyExtended }}", - } - } + }, + }, }, }, { @@ -1138,14 +1199,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \ssystem\s(?PClock-change-notification) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps system Clock-change-notification", "result": { "traps": { "system": { "clock_change_notification": "{{ not not clock_change_notification }}", - } - } + }, + }, }, }, { @@ -1155,14 +1217,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \supgrade\s(?PupgradeJobStatusNotify) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps upgrade upgradeJobStatusNotify", "result": { "traps": { "upgrade": { "upgradeJobStatusNotify": "{{ not not upgradeJobStatusNotify }}", - } - } + }, + }, }, }, { @@ -1172,14 +1235,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \supgrade\s(?PupgradeOpNotifyOnCompletion) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps upgrade upgradeOpNotifyOnCompletion", "result": { "traps": { "upgrade": { "upgradeOpNotifyOnCompletion": "{{ not not upgradeOpNotifyOnCompletion }}", - } - } + }, + }, }, }, { @@ -1189,14 +1253,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \svtp\s(?Pnotifs) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps vtp notifs", "result": { "traps": { "vtp": { "notifs": "{{ not not notifs }}", - } - } + }, + }, }, }, { @@ -1206,14 +1271,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \svtp\s(?Pvlancreate) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps vtp vlancreate", "result": { "traps": { "vtp": { "vlancreate": "{{ not not vlancreate }}", - } - } + }, + }, }, }, { @@ -1223,14 +1289,15 @@ def __init__(self, lines=None, module=None): ^snmp-server\senable \straps \svtp\s(?Pvlandelete) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server enable traps vtp vlandelete", "result": { "traps": { "vtp": { "vlandelete": "{{ not not vlandelete }}", - } - } + }, + }, }, }, @@ -1240,12 +1307,13 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\sengineID \slocal\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server engineID local {{ engine_id.local }}", "result": { "engine_id": { "local": "{{ local }}", - } + }, }, }, { @@ -1254,7 +1322,8 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \s(?PglobalEnforcePriv) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server globalEnforcePriv", "result": { "global_enforce_priv": "{{ not not global_enforce_priv }}", @@ -1270,7 +1339,8 @@ def __init__(self, lines=None, module=None): (\sversion\s(?P\S+))? (\s((auth\s(?P\S+))|(priv\s(?P\S+))|((?P\S+))))? (\sudp-port\s(?P\S+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": _template_hosts, "result": { "hosts": [ @@ -1286,8 +1356,8 @@ def __init__(self, lines=None, module=None): "udp_port": "{{ udp_port }}", "auth": "{{ auth }}", "priv": "{{ priv }}", - } - ] + }, + ], }, }, { @@ -1296,11 +1366,12 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \slocation\s(?P.+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server location {{ location }}", "result": { "location": "{{ location }}", - } + }, }, { "name": "mib.community_map", @@ -1310,7 +1381,8 @@ def __init__(self, lines=None, module=None): \smib \scommunity-map\s(?P\S+) \scontext\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server mib community-map {{ mib.community_map.community }} context {{ mib.community_map.context }}", "result": { "mib": { @@ -1318,9 +1390,9 @@ def __init__(self, lines=None, module=None): "community": "{{ community }}", "context": "{{ context }}", - } - } - } + }, + }, + }, }, { "name": "packetsize", @@ -1328,11 +1400,12 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \spacketsize\s(?P\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server packetsize {{ packetsize }}", "result": { "packetsize": "{{ packetsize }}", - } + }, }, { "name": "protocol.enable", @@ -1340,13 +1413,14 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \sprotocol\s(?Penable) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server protocol enable", "result": { "protocol": { "enable": "{{ not not enable }}", - } - } + }, + }, }, { "name": "source_interface.informs", @@ -1354,13 +1428,14 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \ssource-interface\sinforms\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server source-interface informs {{ source_interface.informs }}", "result": { "source_interface": { "informs": "{{ informs }}", - } - } + }, + }, }, { "name": "source_interface.traps", @@ -1368,13 +1443,14 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \ssource-interface\straps\s(?P\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server source-interface traps {{ source_interface.traps }}", "result": { "source_interface": { "traps": "{{ traps }}", - } - } + }, + }, }, { "name": "system_shutdown", @@ -1382,11 +1458,12 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server \s(?Psystem-shutdown) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server system-shutdown", "result": { "system_shutdown": "{{ not not system_shutdown }}", - } + }, }, { "name": "tcp_session", @@ -1395,15 +1472,16 @@ def __init__(self, lines=None, module=None): ^snmp-server \s(?Ptcp-session) (\s(?Pauth))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server tcp-session" "{{ ' auth' if tcp_session.auth|d(False) else '' }}", "result": { "tcp_session": { "enable": "{{ True if tcp_session is defined and auth is not defined else None }}", "auth": "{{ not not auth }}", - } - } + }, + }, }, { "name": "users.auth", @@ -1417,7 +1495,8 @@ def __init__(self, lines=None, module=None): (\s(?Plocalizedkey))? (\s(?PlocalizedV2key))? (\sengineID\s(?P\S+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": _tmplt_users_auth, "result": { "users": { @@ -1434,13 +1513,13 @@ def __init__(self, lines=None, module=None): "priv": { "privacy_password": "'{{ privacy_password }}'", "aes_128": "{{ not not aes_128 }}", - } - } + }, + }, - } - ] - } - } + }, + ], + }, + }, }, { "name": "users.use_acls", @@ -1450,7 +1529,8 @@ def __init__(self, lines=None, module=None): \suser\s(?P\S+) (\suse-ipv4acl\s(?P\S+))? (\suse-ipv6acl\s(?P\S+))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "snmp-server user {{ user }}" "{{ (' use-ipv4acl ' + ipv4) if ipv4 is defined else '' }}" "{{ (' use-ipv6acl ' + ipv6) if ipv6 is defined else '' }}", @@ -1461,10 +1541,10 @@ def __init__(self, lines=None, module=None): "user": "{{ user }}", "ipv4": "{{ ipv4 }}", "ipv6": "{{ ipv6 }}", - } - ] - } - } + }, + ], + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py b/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py index 96e0e2fa9..9e47e9bc0 100644 --- a/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py @@ -244,7 +244,7 @@ def massage_data(have_or_want): item["sensor_group"]["id"] = str(item["sensor_group"]["id"]) if item.get("sensor_group").get("sample_interval"): item["sensor_group"]["sample_interval"] = str( - item["sensor_group"]["sample_interval"] + item["sensor_group"]["sample_interval"], ) if item.get("destination_group") and item.get("sensor_group"): item_copy = deepcopy(item) diff --git a/plugins/modules/nxos_aaa_server_host.py b/plugins/modules/nxos_aaa_server_host.py index fd796a218..24eb5aeb3 100644 --- a/plugins/modules/nxos_aaa_server_host.py +++ b/plugins/modules/nxos_aaa_server_host.py @@ -344,7 +344,8 @@ def main(): intersect = dict(set(proposed.items()).intersection(existing.items())) if intersect.get("address") and intersect.get("server_type"): command = "no {0}-server host {1}".format( - intersect.get("server_type"), intersect.get("address") + intersect.get("server_type"), + intersect.get("address"), ) commands.append(command) diff --git a/plugins/modules/nxos_acl_interface.py b/plugins/modules/nxos_acl_interface.py index 0e97063e3..713b6e090 100644 --- a/plugins/modules/nxos_acl_interface.py +++ b/plugins/modules/nxos_acl_interface.py @@ -109,7 +109,7 @@ def check_for_acl_int_present(module, name, intf, direction): { "command": "show running-config aclmgr | section {0}".format(intf.title()), "output": "text", - } + }, ] body = run_commands(module, command) diff --git a/plugins/modules/nxos_banner.py b/plugins/modules/nxos_banner.py index 7f51b739e..2655fa1fa 100644 --- a/plugins/modules/nxos_banner.py +++ b/plugins/modules/nxos_banner.py @@ -143,7 +143,7 @@ def map_config_to_obj(module): if "Invalid command" in output: module.fail_json( msg="banner: %s may not be supported on this platform. Possible values are : exec | motd" - % module.params["banner"] + % module.params["banner"], ) if isinstance(output, dict): diff --git a/plugins/modules/nxos_bgp.py b/plugins/modules/nxos_bgp.py index 314026c3c..ba5612138 100644 --- a/plugins/modules/nxos_bgp.py +++ b/plugins/modules/nxos_bgp.py @@ -513,7 +513,8 @@ def state_present(module, existing, proposed, candidate): commands.append("{0} {1}".format(key, value)) elif key.startswith("timers bgp"): command = "timers bgp {0} {1}".format( - proposed["timer_bgp_keepalive"], proposed["timer_bgp_hold"] + proposed["timer_bgp_keepalive"], + proposed["timer_bgp_hold"], ) if command not in commands: commands.append(command) diff --git a/plugins/modules/nxos_bgp_af.py b/plugins/modules/nxos_bgp_af.py index 74c29a45e..94c247461 100644 --- a/plugins/modules/nxos_bgp_af.py +++ b/plugins/modules/nxos_bgp_af.py @@ -458,8 +458,8 @@ def get_existing(module, args, warnings): else: warnings.append( "The BGP process {0} didn't exist but the task just created it.".format( - module.params["asn"] - ) + module.params["asn"], + ), ) return existing @@ -529,7 +529,7 @@ def default_existing(existing_value, key, value): commands.append("no inject-map {0} exist-map {1}".format(maps[0], maps[1])) elif len(maps) == 3: commands.append( - "no inject-map {0} exist-map {1} " "copy-attributes".format(maps[0], maps[1]) + "no inject-map {0} exist-map {1} " "copy-attributes".format(maps[0], maps[1]), ) elif key == "redistribute": @@ -590,7 +590,8 @@ def get_inject_map_command(existing, key, value): command = "no inject-map {0} exist-map {1}".format(emaps[0], emaps[1]) elif len(emaps) == 3: command = "no inject-map {0} exist-map {1} " "copy-attributes".format( - emaps[0], emaps[1] + emaps[0], + emaps[1], ) if command: commands.append(command) @@ -667,7 +668,8 @@ def state_present(module, existing, proposed, candidate): for key, value in proposed_commands.items(): if key == "address-family": addr_family_command = "address-family {0} {1}".format( - module.params["afi"], module.params["safi"] + module.params["afi"], + module.params["safi"], ) if addr_family_command not in commands: commands.append(addr_family_command) @@ -729,7 +731,8 @@ def state_present(module, existing, proposed, candidate): parents.append("vrf {0}".format(module.params["vrf"])) addr_family_command = "address-family {0} {1}".format( - module.params["afi"], module.params["safi"] + module.params["afi"], + module.params["safi"], ) parents.append(addr_family_command) if addr_family_command in commands: diff --git a/plugins/modules/nxos_bgp_neighbor.py b/plugins/modules/nxos_bgp_neighbor.py index 46b657fde..87c196a91 100644 --- a/plugins/modules/nxos_bgp_neighbor.py +++ b/plugins/modules/nxos_bgp_neighbor.py @@ -410,7 +410,7 @@ def state_present(module, existing, proposed, candidate): commands.append(command) elif key == "timers": if proposed["timers_keepalive"] != PARAM_TO_DEFAULT_KEYMAP.get( - "timers_keepalive" + "timers_keepalive", ) or proposed["timers_holdtime"] != PARAM_TO_DEFAULT_KEYMAP.get("timers_holdtime"): command = "timers {0} {1}".format( proposed["timers_keepalive"], diff --git a/plugins/modules/nxos_bgp_neighbor_af.py b/plugins/modules/nxos_bgp_neighbor_af.py index faa377208..7d0912bbb 100644 --- a/plugins/modules/nxos_bgp_neighbor_af.py +++ b/plugins/modules/nxos_bgp_neighbor_af.py @@ -377,7 +377,9 @@ def get_value(arg, config, module): elif command.split()[0] in ["filter-list", "prefix-list", "route-map"]: has_cmd_direction_val = re.search( - r"{0}\s(?P.*)\s{1}$".format(*command.split()), config, re.M + r"{0}\s(?P.*)\s{1}$".format(*command.split()), + config, + re.M, ) if has_cmd_direction_val: value = has_cmd_direction_val.group("value") @@ -497,11 +499,13 @@ def get_default_command(key, value, existing_commands): else: if key == "advertise-map exist-map": command = "no advertise-map {0} exist-map {1}".format( - existing_value[0], existing_value[1] + existing_value[0], + existing_value[1], ) elif key == "advertise-map non-exist-map": command = "no advertise-map {0} non-exist-map {1}".format( - existing_value[0], existing_value[1] + existing_value[0], + existing_value[1], ) elif key == "filter-list in": command = "no filter-list {0} in".format(existing_value) @@ -577,7 +581,7 @@ def state_present(module, existing, proposed, candidate): commands.append("no {0}".format(key)) elif key == "address-family": commands.append( - "address-family {0} {1}".format(module.params["afi"], module.params["safi"]) + "address-family {0} {1}".format(module.params["afi"], module.params["safi"]), ) elif key.startswith("capability additional-paths"): command = key @@ -679,7 +683,9 @@ def main(): choices=["none", "both", "extended", "standard", "default"], ), soft_reconfiguration_in=dict( - required=False, type="str", choices=["enable", "always", "inherit"] + required=False, + type="str", + choices=["enable", "always", "inherit"], ), soo=dict(required=False, type="str"), suppress_inactive=dict(required=False, type="bool"), diff --git a/plugins/modules/nxos_command.py b/plugins/modules/nxos_command.py index def8e7c8f..bcdbb8535 100644 --- a/plugins/modules/nxos_command.py +++ b/plugins/modules/nxos_command.py @@ -158,7 +158,7 @@ def parse_commands(module, warnings): if not item["command"].startswith("show"): warnings.append( "Only show commands are supported when using check mode, not " - "executing %s" % item["command"] + "executing %s" % item["command"], ) commands.remove(item) diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index 13b372358..56274b2f9 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -387,7 +387,7 @@ def save_config(module, result): module.warn( "Skipping command `copy running-config startup-config` " "due to check_mode. Configuration not copied to " - "non-volatile storage" + "non-volatile storage", ) @@ -557,7 +557,7 @@ def main(): { "changed": True, "diff": {"before": str(before), "after": str(after)}, - } + }, ) if result.get("changed") and any((module.params["src"], module.params["lines"])): diff --git a/plugins/modules/nxos_gir.py b/plugins/modules/nxos_gir.py index 4c3c46cd6..6d0e0e82f 100644 --- a/plugins/modules/nxos_gir.py +++ b/plugins/modules/nxos_gir.py @@ -222,14 +222,14 @@ def get_commands(module, state, mode): if state == "present" and timeout != module.params["system_mode_maintenance_timeout"]: commands.append( "system mode maintenance timeout {0}".format( - module.params["system_mode_maintenance_timeout"] - ) + module.params["system_mode_maintenance_timeout"], + ), ) elif state == "absent" and timeout == module.params["system_mode_maintenance_timeout"]: commands.append( "no system mode maintenance timeout {0}".format( - module.params["system_mode_maintenance_timeout"] - ) + module.params["system_mode_maintenance_timeout"], + ), ) elif module.params["system_mode_maintenance_shutdown"] and mode == "normal": @@ -247,8 +247,8 @@ def get_commands(module, state, mode): commands.append( "system mode maintenance on-reload " "reset-reason {0}".format( - module.params["system_mode_maintenance_on_reload_reset_reason"] - ) + module.params["system_mode_maintenance_on_reload_reset_reason"], + ), ) elif ( state == "absent" @@ -258,8 +258,8 @@ def get_commands(module, state, mode): commands.append( "no system mode maintenance on-reload " "reset-reason {0}".format( - module.params["system_mode_maintenance_on_reload_reset_reason"] - ) + module.params["system_mode_maintenance_on_reload_reset_reason"], + ), ) if commands: @@ -302,7 +302,7 @@ def main(): "system_mode_maintenance_timeout", "system_mode_maintenance_shutdown", "system_mode_maintenance_on_reload_reset_reason", - ] + ], ], required_one_of=[ [ @@ -311,7 +311,7 @@ def main(): "system_mode_maintenance_timeout", "system_mode_maintenance_shutdown", "system_mode_maintenance_on_reload_reset_reason", - ] + ], ], supports_check_mode=True, ) diff --git a/plugins/modules/nxos_hsrp.py b/plugins/modules/nxos_hsrp.py index d48a0def4..3443e0259 100644 --- a/plugins/modules/nxos_hsrp.py +++ b/plugins/modules/nxos_hsrp.py @@ -328,7 +328,7 @@ def get_commands_config_hsrp(delta, interface, args, existing): commands.append(command) else: if existing and existing.get("auth_string") != PARAM_TO_DEFAULT_KEYMAP.get( - "auth_string" + "auth_string", ): commands.append("no authentication") @@ -443,7 +443,7 @@ def main(): if auth_type or auth_string: if not (auth_type and auth_string): module.fail_json( - msg="When using auth parameters, you need BOTH " "auth_type AND auth_string." + msg="When using auth parameters, you need BOTH " "auth_type AND auth_string.", ) args = dict( @@ -469,7 +469,7 @@ def main(): elif not proposed.get("auth_type", None) and existing: if (proposed["version"] == "1" and existing["auth_type"] == "md5") and state == "present": module.fail_json( - msg="Existing auth_type is md5. It's recommended " "to use HSRP v2 when using md5" + msg="Existing auth_type is md5. It's recommended " "to use HSRP v2 when using md5", ) commands = [] diff --git a/plugins/modules/nxos_igmp_interface.py b/plugins/modules/nxos_igmp_interface.py index 295209819..a39d8e2c8 100644 --- a/plugins/modules/nxos_igmp_interface.py +++ b/plugins/modules/nxos_igmp_interface.py @@ -469,7 +469,8 @@ def config_remove_oif(existing, existing_oif_prefix_source): for each in existing_oif_prefix_source: if each.get("prefix") and each.get("source"): command = "no ip igmp static-oif {0} source {1} ".format( - each.get("prefix"), each.get("source") + each.get("prefix"), + each.get("source"), ) elif each.get("prefix"): command = "no ip igmp static-oif {0}".format(each.get("prefix")) @@ -535,14 +536,14 @@ def main(): if oif_routemap and existing_oif_prefix_source: module.fail_json( msg="Delete static-oif configurations on this " - "interface if you want to use a routemap" + "interface if you want to use a routemap", ) if oif_ps and existing.get("oif_routemap"): module.fail_json( msg="Delete static-oif route-map configuration " "on this interface if you want to config " - "static entries" + "static entries", ) args = [ @@ -584,7 +585,7 @@ def main(): for each in CANNOT_ABSENT: if each in proposed: module.fail_json( - msg="only params: " "oif_ps, oif_routemap can be used when " "state=absent" + msg="only params: " "oif_ps, oif_routemap can be used when " "state=absent", ) # delta check for all params except oif_ps diff --git a/plugins/modules/nxos_interface.py b/plugins/modules/nxos_interface.py index 30c3f104e..f516b2015 100644 --- a/plugins/modules/nxos_interface.py +++ b/plugins/modules/nxos_interface.py @@ -638,7 +638,7 @@ def map_params_to_obj(module): "tx_rate": module.params["tx_rate"], "rx_rate": module.params["rx_rate"], "neighbors": module.params["neighbors"], - } + }, ) return obj @@ -678,7 +678,7 @@ def map_config_to_obj(want, module): if interface_table: if interface_table.get("eth_mode") == "fex-fabric": module.fail_json( - msg='nxos_interface does not support interfaces with mode "fex-fabric"' + msg='nxos_interface does not support interfaces with mode "fex-fabric"', ) intf_type = get_interface_type(w["name"]) @@ -786,7 +786,7 @@ def check_declarative_intent_params(module, want): { "command": "show interface {0}".format(w["name"]), "output": "text", - } + }, ] try: @@ -802,7 +802,9 @@ def check_declarative_intent_params(module, want): have_tx_rate = match.group(1) if have_tx_rate is None or not conditional( - want_tx_rate, have_tx_rate.strip(), cast=int + want_tx_rate, + have_tx_rate.strip(), + cast=int, ): failed_conditions.append("tx_rate " + want_tx_rate) @@ -814,7 +816,9 @@ def check_declarative_intent_params(module, want): have_rx_rate = match.group(1) if have_rx_rate is None or not conditional( - want_rx_rate, have_rx_rate.strip(), cast=int + want_rx_rate, + have_rx_rate.strip(), + cast=int, ): failed_conditions.append("rx_rate " + want_rx_rate) @@ -826,7 +830,7 @@ def check_declarative_intent_params(module, want): { "command": "show lldp neighbors interface {0} detail".format(w["name"]), "output": "text", - } + }, ] output = run_commands(module, cmd, check_rc=False) if output: @@ -885,7 +889,7 @@ def main(): elements="dict", options=aggregate_spec, mutually_exclusive=[["name", "interface_type"]], - ) + ), ) argument_spec.update(element_spec) diff --git a/plugins/modules/nxos_interface_ospf.py b/plugins/modules/nxos_interface_ospf.py index d90a9bc37..1783e7c6c 100644 --- a/plugins/modules/nxos_interface_ospf.py +++ b/plugins/modules/nxos_interface_ospf.py @@ -257,7 +257,7 @@ def get_existing(module, args): existing = {} netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) if module.params["interface"].startswith("loopback") or module.params["interface"].startswith( - "port-channel" + "port-channel", ): parents = ["interface {0}".format(module.params["interface"])] else: @@ -359,7 +359,7 @@ def state_present(module, existing, proposed, candidate): continue if key == "ip ospf passive-interface" and module.params.get("interface").upper().startswith( - "LO" + "LO", ): module.fail_json(msg="loopback interface does not support passive_interface") if ( @@ -385,7 +385,7 @@ def state_present(module, existing, proposed, candidate): elif value == "default": if existing_commands.get(key): commands.extend( - get_default_commands(existing, proposed, existing_commands, key, module) + get_default_commands(existing, proposed, existing_commands, key, module), ) else: if key == "ip router ospf" or key.startswith("ip ospf message-digest-key"): @@ -495,7 +495,7 @@ def main(): "message_digest_algorithm_type", "message_digest_encryption_type", "message_digest_password", - ] + ], ], supports_check_mode=True, ) @@ -524,7 +524,7 @@ def main(): and module.params["message_digest_key_id"] != "default" ): module.exit_json( - msg="Use message_digest_key_id=default to remove an existing authentication configuration" + msg="Use message_digest_key_id=default to remove an existing authentication configuration", ) state = module.params["state"] diff --git a/plugins/modules/nxos_l2_interface.py b/plugins/modules/nxos_l2_interface.py index b2f3ccb79..a51534e9a 100644 --- a/plugins/modules/nxos_l2_interface.py +++ b/plugins/modules/nxos_l2_interface.py @@ -352,7 +352,7 @@ def get_switchport_config_commands(name, existing, proposed, module): if not tv_check: if proposed.get("allowed"): command = "switchport trunk allowed vlan {0}".format( - proposed.get("trunk_allowed_vlans") + proposed.get("trunk_allowed_vlans"), ) commands.append(command) @@ -362,7 +362,7 @@ def get_switchport_config_commands(name, existing, proposed, module): vlans_to_add = set(proposed_vlans).difference(existing_vlans) if vlans_to_add: command = "switchport trunk allowed vlan add {0}".format( - proposed.get("trunk_vlans") + proposed.get("trunk_vlans"), ) commands.append(command) @@ -501,7 +501,7 @@ def map_params_to_obj(module): "trunk_vlans": module.params["trunk_vlans"], "trunk_allowed_vlans": module.params["trunk_allowed_vlans"], "state": module.params["state"], - } + }, ) return obj @@ -581,14 +581,14 @@ def main(): module.fail_json( msg="Ensure interface is configured to be a L2" "\nport first before using this module. You can use" - "\nthe nxos_interface module for this." + "\nthe nxos_interface module for this.", ) if interface_is_portchannel(name, module): module.fail_json( msg="Cannot change L2 config on physical " "\nport because it is in a portchannel. " - "\nYou should update the portchannel config." + "\nYou should update the portchannel config.", ) # existing will never be null for Eth intfs as there is always a default diff --git a/plugins/modules/nxos_l3_interface.py b/plugins/modules/nxos_l3_interface.py index dc329fbdb..cca9449cb 100644 --- a/plugins/modules/nxos_l3_interface.py +++ b/plugins/modules/nxos_l3_interface.py @@ -205,7 +205,7 @@ def map_params_to_obj(module): "ipv4": module.params["ipv4"], "ipv6": module.params["ipv6"], "state": module.params["state"], - } + }, ) return obj diff --git a/plugins/modules/nxos_linkagg.py b/plugins/modules/nxos_linkagg.py index d361e0110..d6a878df2 100644 --- a/plugins/modules/nxos_linkagg.py +++ b/plugins/modules/nxos_linkagg.py @@ -260,7 +260,7 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(m)) if force: commands.append( - "channel-group {0} force mode {1}".format(group, mode) + "channel-group {0} force mode {1}".format(group, mode), ) else: commands.append("channel-group {0} mode {1}".format(group, mode)) @@ -273,7 +273,7 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(m)) if force: commands.append( - "channel-group {0} force mode {1}".format(group, mode) + "channel-group {0} force mode {1}".format(group, mode), ) else: commands.append("channel-group {0} mode {1}".format(group, mode)) @@ -293,11 +293,11 @@ def map_obj_to_commands(updates, module): commands.append("interface {0}".format(i)) if force: commands.append( - "channel-group {0} force mode {1}".format(group, mode) + "channel-group {0} force mode {1}".format(group, mode), ) else: commands.append( - "channel-group {0} mode {1}".format(group, mode) + "channel-group {0} mode {1}".format(group, mode), ) if purge: @@ -337,7 +337,7 @@ def map_params_to_obj(module): "min_links": str(module.params["min_links"]), "members": members, "state": module.params["state"], - } + }, ) return obj diff --git a/plugins/modules/nxos_lldp.py b/plugins/modules/nxos_lldp.py index 5acc301bb..792004ebb 100644 --- a/plugins/modules/nxos_lldp.py +++ b/plugins/modules/nxos_lldp.py @@ -86,7 +86,7 @@ def main(): state=dict( default="present", choices=["present", "absent", "enabled", "disabled"], - ) + ), ) argument_spec.update(nxos_argument_spec) diff --git a/plugins/modules/nxos_logging.py b/plugins/modules/nxos_logging.py index aa405edb2..97b54f17a 100644 --- a/plugins/modules/nxos_logging.py +++ b/plugins/modules/nxos_logging.py @@ -270,7 +270,7 @@ def map_obj_to_commands(module, updates): and w["facility"] not in DEFAULT_LOGGING_LEVEL[int(w["facility_level"])] ): commands.append( - "no logging level {0} {1}".format(w["facility"], w["facility_level"]) + "no logging level {0} {1}".format(w["facility"], w["facility_level"]), ) if w["facility_link_status"] and w["facility"] in ("ethpm"): @@ -278,7 +278,7 @@ def map_obj_to_commands(module, updates): "no logging level {0} {1}".format( w["facility"], STATIC_CLI[w["facility_link_status"]], - ) + ), ) if w["name"] is not None: @@ -312,12 +312,14 @@ def map_obj_to_commands(module, updates): if w["file_size"]: commands.append( "logging logfile {0} {1} size {2}".format( - w["name"], w["dest_level"], w["file_size"] - ) + w["name"], + w["dest_level"], + w["file_size"], + ), ) else: commands.append( - "logging logfile {0} {1}".format(w["name"], w["dest_level"]) + "logging logfile {0} {1}".format(w["name"], w["dest_level"]), ) elif w["dest"] == "server": @@ -328,21 +330,23 @@ def map_obj_to_commands(module, updates): w["remote_server"], w["facility_level"], w["use_vrf"], - ) + ), ) else: commands.append( "logging server {0} {1}".format( - w["remote_server"], w["facility_level"] - ) + w["remote_server"], + w["facility_level"], + ), ) else: if w["use_vrf"]: commands.append( "logging server {0} use-vrf {1}".format( - w["remote_server"], w["use_vrf"] - ) + w["remote_server"], + w["use_vrf"], + ), ) else: commands.append("logging server {0}".format(w["remote_server"])) @@ -357,7 +361,7 @@ def map_obj_to_commands(module, updates): w["facility_level"], w["facility"], w["use_vrf"], - ) + ), ) else: commands.append( @@ -365,7 +369,7 @@ def map_obj_to_commands(module, updates): w["remote_server"], w["facility_level"], w["facility"], - ) + ), ) else: if w["use_vrf"]: @@ -374,13 +378,14 @@ def map_obj_to_commands(module, updates): w["remote_server"], w["facility"], w["use_vrf"], - ) + ), ) else: commands.append( "logging server {0} facility {1}".format( - w["remote_server"], w["facility"] - ) + w["remote_server"], + w["facility"], + ), ) else: if w["facility_link_status"]: @@ -388,17 +393,17 @@ def map_obj_to_commands(module, updates): "logging level {0} {1}".format( w["facility"], STATIC_CLI[w["facility_link_status"]], - ) + ), ) else: if not match_facility_default(module, w["facility"], w["facility_level"]): commands.append( - "logging level {0} {1}".format(w["facility"], w["facility_level"]) + "logging level {0} {1}".format(w["facility"], w["facility_level"]), ) if w["interface"]: commands.append( - "logging source-interface {0} {1}".format(*split_interface(w["interface"])) + "logging source-interface {0} {1}".format(*split_interface(w["interface"])), ) if w["event"] and w["event"] in STATIC_CLI: @@ -696,7 +701,7 @@ def map_config_to_obj(module): "file_size": file_size, "message": parse_message(line), "timestamp": parse_timestamp(line), - } + }, ) cmd = [ @@ -742,7 +747,7 @@ def map_config_to_obj(module): "file_size": None, "message": None, "timestamp": None, - } + }, ) return obj @@ -822,7 +827,7 @@ def map_params_to_obj(module): "message": module.params["interface_message"], "file_size": file_size, "timestamp": module.params["timestamp"], - } + }, ) return obj @@ -872,7 +877,7 @@ def main(): "link-down-error", "link-up-notif", "link-up-error", - ] + ], ), event=dict( choices=[ @@ -880,7 +885,7 @@ def main(): "link-default", "trunk-enable", "trunk-default", - ] + ], ), interface_message=dict(choices=["add-interface-description"]), file_size=dict(type="int"), diff --git a/plugins/modules/nxos_ntp.py b/plugins/modules/nxos_ntp.py index d94de666f..1ddc97374 100644 --- a/plugins/modules/nxos_ntp.py +++ b/plugins/modules/nxos_ntp.py @@ -302,7 +302,7 @@ def config_ntp(delta, existing): if peer_type: if existing.get("peer_type") and existing.get("address"): ntp_cmds.append( - "no ntp {0} {1}".format(existing.get("peer_type"), existing.get("address")) + "no ntp {0} {1}".format(existing.get("peer_type"), existing.get("address")), ) ntp_cmds.append(set_ntp_server_peer(peer_type, address, prefer, key_id, vrf_name)) if source: diff --git a/plugins/modules/nxos_ntp_auth.py b/plugins/modules/nxos_ntp_auth.py index b86050a1e..e89afc585 100644 --- a/plugins/modules/nxos_ntp_auth.py +++ b/plugins/modules/nxos_ntp_auth.py @@ -217,7 +217,7 @@ def set_ntp_auth_key(key_id, md5string, auth_type, trusted_key, authentication): if key_id and md5string: auth_type_num = auth_type_to_num(auth_type) ntp_auth_cmds.append( - "ntp authentication-key {0} md5 {1} {2}".format(key_id, md5string, auth_type_num) + "ntp authentication-key {0} md5 {1} {2}".format(key_id, md5string, auth_type_num), ) if trusted_key == "true": @@ -238,7 +238,7 @@ def remove_ntp_auth_key(key_id, md5string, auth_type, trusted_key, authenticatio if key_id: auth_type_num = auth_type_to_num(auth_type) auth_remove_cmds.append( - "no ntp authentication-key {0} md5 {1} {2}".format(key_id, md5string, auth_type_num) + "no ntp authentication-key {0} md5 {1} {2}".format(key_id, md5string, auth_type_num), ) if authentication: diff --git a/plugins/modules/nxos_nxapi.py b/plugins/modules/nxos_nxapi.py index 4fd15055e..f0355a419 100644 --- a/plugins/modules/nxos_nxapi.py +++ b/plugins/modules/nxos_nxapi.py @@ -177,7 +177,7 @@ def check_args(module, warnings, capabilities): os_platform = capabilities["device_info"]["network_os_platform"] if "7K" not in os_platform and module.params["sandbox"]: module.fail_json( - msg="sandbox or enable_sandbox is supported on NX-OS 7K series of switches" + msg="sandbox or enable_sandbox is supported on NX-OS 7K series of switches", ) state = module.params["state"] @@ -186,13 +186,13 @@ def check_args(module, warnings, capabilities): module.params["state"] = "present" warnings.append( "state=started is deprecated and will be removed in a " - "a future release. Please use state=present instead" + "a future release. Please use state=present instead", ) elif state == "stopped": module.params["state"] = "absent" warnings.append( "state=stopped is deprecated and will be removed in a " - "a future release. Please use state=absent instead" + "a future release. Please use state=absent instead", ) for key in ["http_port", "https_port"]: @@ -278,7 +278,7 @@ def needs_update(x): warnings.append( "os_version and/or os_platform keys from " "platform capabilities are not available. " - "Any NXAPI SSL optional arguments will be ignored" + "Any NXAPI SSL optional arguments will be ignored", ) send_commands.extend(commands.values()) diff --git a/plugins/modules/nxos_pim.py b/plugins/modules/nxos_pim.py index c7dee65fd..600700819 100644 --- a/plugins/modules/nxos_pim.py +++ b/plugins/modules/nxos_pim.py @@ -177,7 +177,7 @@ def main(): if len(item.split(".")) != 4: module.fail_json( msg="Valid ssm_range values are multicast addresses " - "or the keyword 'none' or the keyword 'default'." + "or the keyword 'none' or the keyword 'default'.", ) existing = get_existing(module, args) diff --git a/plugins/modules/nxos_pim_interface.py b/plugins/modules/nxos_pim_interface.py index e08737a75..e2c45fbb0 100644 --- a/plugins/modules/nxos_pim_interface.py +++ b/plugins/modules/nxos_pim_interface.py @@ -285,7 +285,8 @@ def get_pim_interface(module, interface): for each in all_lines: if "jp-policy" in each: policy_name = re.search( - r"ip pim jp-policy(?: prefix-list)? (\S+)(?: \S+)?", each + r"ip pim jp-policy(?: prefix-list)? (\S+)(?: \S+)?", + each, ).group(1) if "prefix-list" in each: ptype = "prefix" @@ -303,7 +304,8 @@ def get_pim_interface(module, interface): pim_interface["jp_bidir"] = True elif "neighbor-policy" in each: pim_interface["neighbor_policy"] = re.search( - r"ip pim neighbor-policy(?: prefix-list)? (\S+)", each + r"ip pim neighbor-policy(?: prefix-list)? (\S+)", + each, ).group(1) if "prefix-list" in each: pim_interface["neighbor_type"] = "prefix" @@ -321,7 +323,8 @@ def get_pim_interface(module, interface): pim_interface["border"] = True elif "hello-interval" in each: pim_interface["hello_interval"] = re.search( - r"ip pim hello-interval (\d+)", body + r"ip pim hello-interval (\d+)", + body, ).group(1) elif "dr-priority" in each: pim_interface["dr_prio"] = re.search(r"ip pim dr-priority (\d+)", body).group(1) @@ -453,7 +456,7 @@ def default_pim_interface_policies(existing, jp_bidir): if existing.get("jp_policy_in"): if existing.get("jp_type_in") == "prefix": command = "no ip pim jp-policy prefix-list {0} in".format( - existing.get("jp_policy_in") + existing.get("jp_policy_in"), ) else: command = "no ip pim jp-policy {0} in".format(existing.get("jp_policy_in")) @@ -461,11 +464,11 @@ def default_pim_interface_policies(existing, jp_bidir): if existing.get("jp_policy_out"): if existing.get("jp_type_out") == "prefix": command = "no ip pim jp-policy prefix-list {0} out".format( - existing.get("jp_policy_out") + existing.get("jp_policy_out"), ) else: command = "no ip pim jp-policy {0} out".format( - existing.get("jp_policy_out") + existing.get("jp_policy_out"), ) if command: commands.append(command) diff --git a/plugins/modules/nxos_rollback.py b/plugins/modules/nxos_rollback.py index 54f0f2372..f06bc2f6b 100644 --- a/plugins/modules/nxos_rollback.py +++ b/plugins/modules/nxos_rollback.py @@ -96,7 +96,7 @@ def rollback(filename, module): { "command": "rollback running-config file %s" % filename, "output": "text", - } + }, ] run_commands(module, commands) diff --git a/plugins/modules/nxos_rpm.py b/plugins/modules/nxos_rpm.py index eaecf42b8..eedb4395b 100644 --- a/plugins/modules/nxos_rpm.py +++ b/plugins/modules/nxos_rpm.py @@ -376,7 +376,7 @@ def main(): "pkg": module.params["pkg"], "file_system": module.params["file_system"], "state": module.params["state"], - } + }, ) for obj in objects: diff --git a/plugins/modules/nxos_snapshot.py b/plugins/modules/nxos_snapshot.py index a48df3bc3..c08304507 100644 --- a/plugins/modules/nxos_snapshot.py +++ b/plugins/modules/nxos_snapshot.py @@ -199,8 +199,9 @@ def action_create(module, existing_snapshots): if exist is False: commands.append( "snapshot create {0} {1}".format( - module.params["snapshot_name"], module.params["description"] - ) + module.params["snapshot_name"], + module.params["description"], + ), ) return commands @@ -253,7 +254,7 @@ def action_add(module, existing_snapshots): module.params["row_id"], module.params["element_key1"], module.params["element_key2"], - ) + ), ) else: commands.append( @@ -262,7 +263,7 @@ def action_add(module, existing_snapshots): module.params["show_command"], module.params["row_id"], module.params["element_key1"], - ) + ), ) return commands @@ -270,7 +271,8 @@ def action_add(module, existing_snapshots): def action_compare(module, existing_snapshots): command = "show snapshot compare {0} {1}".format( - module.params["snapshot1"], module.params["snapshot2"] + module.params["snapshot1"], + module.params["snapshot2"], ) if module.params["compare_option"]: diff --git a/plugins/modules/nxos_snmp_host.py b/plugins/modules/nxos_snmp_host.py index b1c2a0b1a..6a2f257a0 100644 --- a/plugins/modules/nxos_snmp_host.py +++ b/plugins/modules/nxos_snmp_host.py @@ -293,8 +293,10 @@ def remove_vrf(host, udp, proposed, existing): commands.append( "no snmp-server host {0} use-vrf \ {1} udp-port {2}".format( - host, proposed.get("vrf"), udp - ) + host, + proposed.get("vrf"), + udp, + ), ) return commands @@ -306,8 +308,10 @@ def remove_filter(host, udp, proposed, existing): commands.append( "no snmp-server host {0} filter-vrf \ {1} udp-port {2}".format( - host, proposed.get("vrf_filter"), udp - ) + host, + proposed.get("vrf_filter"), + udp, + ), ) return commands @@ -318,8 +322,10 @@ def remove_src(host, udp, proposed, existing): commands.append( "no snmp-server host {0} source-interface \ {1} udp-port {2}".format( - host, proposed.get("src_intf"), udp - ) + host, + proposed.get("src_intf"), + udp, + ), ) return commands @@ -444,13 +450,13 @@ def main(): msg="when not configuring options like " "vrf_filter, vrf, and src_intf," "the following params are required: " - "type, version, community" + "type, version, community", ) if version == "v3" and v3 is None: module.fail_json( msg="when using version=v3, the param v3 " - "(options: auth, noauth, priv) is also required" + "(options: auth, noauth, priv) is also required", ) # existing returns the list of vrfs configured for a given host diff --git a/plugins/modules/nxos_snmp_user.py b/plugins/modules/nxos_snmp_user.py index 35d70f0e1..0ce4c094c 100644 --- a/plugins/modules/nxos_snmp_user.py +++ b/plugins/modules/nxos_snmp_user.py @@ -334,7 +334,7 @@ def main(): if privacy and encrypt: if not pwd and authentication: module.fail_json( - msg="pwd and authentication must be provided " "when using privacy and encrypt" + msg="pwd and authentication must be provided " "when using privacy and encrypt", ) if group and group not in get_snmp_groups(module): diff --git a/plugins/modules/nxos_static_route.py b/plugins/modules/nxos_static_route.py index 15c714935..50e16b45b 100644 --- a/plugins/modules/nxos_static_route.py +++ b/plugins/modules/nxos_static_route.py @@ -317,7 +317,7 @@ def map_params_to_obj(module): "pref": module.params["pref"], "state": module.params["state"], "track": module.params["track"], - } + }, ) return obj diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index c3aa8453d..7e15c6969 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -321,7 +321,7 @@ def map_config_to_obj(module): "sshkey": item.get("sshkey_info"), "roles": parse_roles(item), "state": "present", - } + }, ) return objects @@ -370,7 +370,7 @@ def map_params_to_obj(module): "sshkey": get_value("sshkey"), "roles": get_value("roles"), "state": get_value("state"), - } + }, ) for key, value in iteritems(item): @@ -465,7 +465,7 @@ def main(): module.fail_json(msg=resp) else: result["warnings"].extend( - [x[9:] for x in resp.splitlines() if x.startswith("WARNING: ")] + [x[9:] for x in resp.splitlines() if x.startswith("WARNING: ")], ) result["changed"] = True diff --git a/plugins/modules/nxos_vlan.py b/plugins/modules/nxos_vlan.py index f65104498..a58f5f57d 100644 --- a/plugins/modules/nxos_vlan.py +++ b/plugins/modules/nxos_vlan.py @@ -403,7 +403,7 @@ def map_obj_to_commands(updates, module): commands.append("switchport access vlan {0}".format(vlan_id)) superfluous_interfaces = list( - set(obj_in_have["interfaces"]) - set(interfaces) + set(obj_in_have["interfaces"]) - set(interfaces), ) for i in superfluous_interfaces: commands.append("vlan {0}".format(vlan_id)) @@ -517,7 +517,7 @@ def map_params_to_obj(module): "admin_state": module.params["admin_state"], "mode": module.params["mode"], "associated_interfaces": associated_interfaces, - } + }, ) return obj @@ -641,7 +641,9 @@ def parse_vlan_non_structured(module, netcfg, vlans): interfaces = list() intfs_match = re.search( r"{0}\s*{1}\s*{2}\s*(.*)".format( - vlan_id, re.escape(name), vlan_state_match + vlan_id, + re.escape(name), + vlan_state_match, ), vlan, re.M, diff --git a/plugins/modules/nxos_vpc.py b/plugins/modules/nxos_vpc.py index ba49aca7e..092d92ab9 100644 --- a/plugins/modules/nxos_vpc.py +++ b/plugins/modules/nxos_vpc.py @@ -417,18 +417,18 @@ def main(): elif pkl_vrf: if pkl_vrf != "management": module.fail_json( - msg="dest and src IP for peer-keepalive are required" " when vrf is present" + msg="dest and src IP for peer-keepalive are required" " when vrf is present", ) else: module.fail_json( - msg="dest IP for peer-keepalive is required" " when vrf is present" + msg="dest IP for peer-keepalive is required" " when vrf is present", ) if pkl_vrf: if pkl_vrf.lower() not in get_vrf_list(module): module.fail_json( msg="The VRF you are trying to use for the peer " "keepalive link is not on device yet. Add it" - " first, please." + " first, please.", ) proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_vpc(module) @@ -451,7 +451,7 @@ def main(): if existing: if domain != existing["domain"]: module.fail_json( - msg="You are trying to remove a domain that " "does not exist on the device" + msg="You are trying to remove a domain that " "does not exist on the device", ) else: commands.append("terminal dont-ask") diff --git a/plugins/modules/nxos_vpc_interface.py b/plugins/modules/nxos_vpc_interface.py index b2589e61e..620b45d3d 100644 --- a/plugins/modules/nxos_vpc_interface.py +++ b/plugins/modules/nxos_vpc_interface.py @@ -273,7 +273,7 @@ def main(): module.fail_json( msg="The portchannel you are trying to make a" " VPC or PL is not created yet. " - "Create it first!" + "Create it first!", ) if vpc: mapping = get_existing_portchannel_to_vpc_mappings(module) @@ -301,7 +301,7 @@ def main(): module.fail_json( msg="That port channel is the current " "PEER LINK. Remove it if you want it" - " to be a VPC" + " to be a VPC", ) config_value = vpc diff --git a/plugins/modules/nxos_vrf.py b/plugins/modules/nxos_vrf.py index 6f62024b8..d7e4b83ab 100644 --- a/plugins/modules/nxos_vrf.py +++ b/plugins/modules/nxos_vrf.py @@ -389,7 +389,7 @@ def map_obj_to_commands(updates, module): commands.append("vrf member {0}".format(name)) superfluous_interfaces = list( - set(obj_in_have["interfaces"]) - set(interfaces) + set(obj_in_have["interfaces"]) - set(interfaces), ) for i in superfluous_interfaces: commands.append("vrf context {0}".format(name)) @@ -462,7 +462,7 @@ def map_params_to_obj(module): "state": module.params["state"], "interfaces": module.params["interfaces"], "associated_interfaces": module.params["associated_interfaces"], - } + }, ) return obj diff --git a/plugins/modules/nxos_vrf_interface.py b/plugins/modules/nxos_vrf_interface.py index 90c284f1c..ea6713808 100644 --- a/plugins/modules/nxos_vrf_interface.py +++ b/plugins/modules/nxos_vrf_interface.py @@ -209,7 +209,7 @@ def main(): module.fail_json( msg="interface does not exist on switch. Verify " "switch platform or create it first with " - "nxos_interface if it's a logical interface" + "nxos_interface if it's a logical interface", ) mode = get_interface_mode(interface, intf_type, module) @@ -217,7 +217,7 @@ def main(): module.fail_json( msg="Ensure interface is a Layer 3 port before " "configuring a VRF on an interface. You can " - "use nxos_interface" + "use nxos_interface", ) current_vrf = get_interface_info(interface, module) diff --git a/plugins/modules/nxos_vtp_password.py b/plugins/modules/nxos_vtp_password.py index 0970fb08b..0d0ee64d5 100644 --- a/plugins/modules/nxos_vtp_password.py +++ b/plugins/modules/nxos_vtp_password.py @@ -237,7 +237,7 @@ def main(): "current vtp password. It cannot be " "removed when state=absent. If you are " "trying to change the vtp password, use " - "state=present." + "state=present.", ) else: if not existing.get("domain"): diff --git a/plugins/modules/nxos_vxlan_vtep.py b/plugins/modules/nxos_vxlan_vtep.py index 7ae67c591..861672b4a 100644 --- a/plugins/modules/nxos_vxlan_vtep.py +++ b/plugins/modules/nxos_vxlan_vtep.py @@ -330,7 +330,7 @@ def gsa_tcam_check(module): i for i in tcam_region if i["type"].startswith("Ingress ARP-Ether ACL") and i["tcam_size"] == "0" - ] + ], ): msg = ( "'show hardware access-list tcam region' indicates 'ARP-Ether' tcam size is 0 (no allocated resources). " @@ -442,7 +442,7 @@ def main(): warnings.append( "The proposed NVE interface did not exist. " "It's recommended to use nxos_interface to create " - "all logical interfaces." + "all logical interfaces.", ) state_present(module, existing, proposed, candidate) elif state == "absent" and existing: diff --git a/plugins/modules/nxos_vxlan_vtep_vni.py b/plugins/modules/nxos_vxlan_vtep_vni.py index cc0c7b0db..862615e7f 100644 --- a/plugins/modules/nxos_vxlan_vtep_vni.py +++ b/plugins/modules/nxos_vxlan_vtep_vni.py @@ -383,7 +383,7 @@ def main(): and module.params["ingress_replication"] != "static" ): module.fail_json( - msg="ingress_replication=static is required " "when using peer_list param" + msg="ingress_replication=static is required " "when using peer_list param", ) else: peer_list = module.params["peer_list"] @@ -400,7 +400,7 @@ def main(): if module.params["ingress_replication"] == "static": module.fail_json( msg="ingress_replication=static is not allowed " - "when using multisite_ingress_replication" + "when using multisite_ingress_replication", ) state = module.params["state"] @@ -410,7 +410,7 @@ def main(): if state == "present": if not interface_exist: module.fail_json( - msg="The proposed NVE interface does not exist. Use nxos_interface to create it first." + msg="The proposed NVE interface does not exist. Use nxos_interface to create it first.", ) elif interface_exist != module.params["interface"]: module.fail_json(msg="Only 1 NVE interface is allowed on the switch.") @@ -420,7 +420,7 @@ def main(): elif existing and existing["vni"] != module.params["vni"]: module.fail_json( msg="ERROR: VNI delete failed: Could not find vni node for {0}".format( - module.params["vni"] + module.params["vni"], ), existing_vni=existing["vni"], ) diff --git a/plugins/modules/storage/nxos_devicealias.py b/plugins/modules/storage/nxos_devicealias.py index c487e44b6..71d4ebb67 100644 --- a/plugins/modules/storage/nxos_devicealias.py +++ b/plugins/modules/storage/nxos_devicealias.py @@ -289,7 +289,7 @@ def main(): module.fail_json( msg="This device alias name " + str(name) - + " which needs to be added, does not have pwwn specified. Please specify a valid pwwn" + + " which needs to be added, does not have pwwn specified. Please specify a valid pwwn", ) if not isNameValid(name): module.fail_json( @@ -297,13 +297,13 @@ def main(): + str(name) + ". Note that name cannot be more than 64 alphanumeric chars, " + "it must start with a letter, and can only contain these characters: " - + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]) + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), ) if not isPwwnValid(pwwn): module.fail_json( msg="This pwwn is invalid : " + str(pwwn) - + ". Please check that its a valid pwwn" + + ". Please check that its a valid pwwn", ) if rename is not None: for eachdict in rename: @@ -315,7 +315,7 @@ def main(): + str(oldname) + ". Note that name cannot be more than 64 alphanumeric chars, " + "it must start with a letter, and can only contain these characters: " - + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]) + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), ) if not isNameValid(newname): module.fail_json( @@ -323,7 +323,7 @@ def main(): + str(newname) + ". Note that name cannot be more than 64 alphanumeric chars, " + "it must start with a letter, and can only contain these characters: " - + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]) + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), ) # Step 0.1: Check DA status @@ -345,7 +345,7 @@ def main(): messages.append("device-alias distribute changed from disabled to enabled") else: messages.append( - "device-alias distribute remains unchanged. current distribution mode is enabled" + "device-alias distribute remains unchanged. current distribution mode is enabled", ) else: # playbook has distribute as False(disabled) @@ -356,7 +356,7 @@ def main(): messages.append("device-alias distribute changed from enabled to disabled") else: messages.append( - "device-alias distribute remains unchanged. current distribution mode is disabled" + "device-alias distribute remains unchanged. current distribution mode is disabled", ) cmds = flatten_list(commands) @@ -429,7 +429,7 @@ def main(): else: messages.append( name - + " - This device alias name is not in switch device-alias database, hence cannot be removed." + + " - This device alias name is not in switch device-alias database, hence cannot be removed.", ) else: if shDADatabaseObj.isNamePwwnPresentInDatabase(name, pwwn): @@ -437,7 +437,7 @@ def main(): name + " : " + pwwn - + " - This device alias name,pwwn is already in switch device-alias database, hence nothing to configure" + + " - This device alias name,pwwn is already in switch device-alias database, hence nothing to configure", ) else: if shDADatabaseObj.isNameInDaDatabase(name): @@ -445,7 +445,7 @@ def main(): msg=name + " - This device alias name is already present in switch device-alias database but assigned to another pwwn (" + shDADatabaseObj.getPwwnByName(name) - + ") hence cannot be added" + + ") hence cannot be added", ) elif shDADatabaseObj.isPwwnInDaDatabase(pwwn): @@ -453,7 +453,7 @@ def main(): msg=pwwn + " - This device alias pwwn is already present in switch device-alias database but assigned to another name (" + shDADatabaseObj.getNameByPwwn(pwwn) - + ") hence cannot be added" + + ") hence cannot be added", ) else: @@ -481,11 +481,11 @@ def main(): load_config(module, cmds) if len(da_remove_list) != 0: messages.append( - "the required device-alias were removed. " + ",".join(da_remove_list) + "the required device-alias were removed. " + ",".join(da_remove_list), ) if len(da_add_list) != 0: messages.append( - "the required device-alias were added. " + ",".join(da_add_list) + "the required device-alias were added. " + ",".join(da_add_list), ) # Step 5: Process rename diff --git a/plugins/modules/storage/nxos_vsan.py b/plugins/modules/storage/nxos_vsan.py index 468503c53..d95d95a96 100644 --- a/plugins/modules/storage/nxos_vsan.py +++ b/plugins/modules/storage/nxos_vsan.py @@ -221,7 +221,7 @@ def main(): if int(vsanid) < 1 or int(vsanid) >= 4095: module.fail_json( - msg=vsanid + " - This is an invalid vsan. Supported vsan range is 1-4094" + msg=vsanid + " - This is an invalid vsan. Supported vsan range is 1-4094", ) if vsanid in dictSwVsanObjs.keys(): @@ -247,21 +247,21 @@ def main(): messages.append( "There is no vsan " + str(vsanid) - + " present in the switch. Hence there is nothing to delete" + + " present in the switch. Hence there is nothing to delete", ) continue else: # Negative case: if vsanid == "4079" or vsanid == "4094": messages.append( - str(vsanid) + " is a reserved vsan, and always present on the switch" + str(vsanid) + " is a reserved vsan, and always present on the switch", ) else: if vsanid == sw_vsanid: messages.append( "There is already a vsan " + str(vsanid) - + " present in the switch. Hence there is nothing to configure" + + " present in the switch. Hence there is nothing to configure", ) else: commands.append("vsan " + str(vsanid)) @@ -278,7 +278,7 @@ def main(): + str(vsanid) + " present in the switch, which has the name " + vsanname - + " Hence there is nothing to configure" + + " Hence there is nothing to configure", ) else: commands.append("vsan " + str(vsanid) + " name " + vsanname) @@ -293,7 +293,7 @@ def main(): messages.append( "There is already a vsan " + str(vsanid) - + " present in the switch, which is in suspended state " + + " present in the switch, which is in suspended state ", ) else: commands.append("vsan " + str(vsanid) + " suspend") @@ -303,7 +303,7 @@ def main(): messages.append( "There is already a vsan " + str(vsanid) - + " present in the switch, which is in active state " + + " present in the switch, which is in active state ", ) else: commands.append("no vsan " + str(vsanid) + " suspend") @@ -319,12 +319,12 @@ def main(): each_interface_name + " is already present in the vsan " + str(vsanid) - + " interface list" + + " interface list", ) else: commands.append("vsan " + str(vsanid) + " interface " + each_interface_name) messages.append( - "adding interface " + each_interface_name + " to vsan " + str(vsanid) + "adding interface " + each_interface_name + " to vsan " + str(vsanid), ) if len(commands) != 0: diff --git a/plugins/modules/storage/nxos_zone_zoneset.py b/plugins/modules/storage/nxos_zone_zoneset.py index 007d14b6c..76101c3df 100644 --- a/plugins/modules/storage/nxos_zone_zoneset.py +++ b/plugins/modules/storage/nxos_zone_zoneset.py @@ -475,7 +475,7 @@ def main(): ) argument_spec = dict( - zone_zoneset_details=dict(type="list", elements="dict", options=zonedetails_spec) + zone_zoneset_details=dict(type="list", elements="dict", options=zonedetails_spec), ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) @@ -508,14 +508,14 @@ def main(): if shZoneStatusObj.isVsanAbsent(): module.fail_json( - msg="Vsan " + str(vsan) + " is not present in the switch. Hence cannot procced." + msg="Vsan " + str(vsan) + " is not present in the switch. Hence cannot procced.", ) if shZoneStatusObj.isLocked(): module.fail_json( msg="zone has acquired lock on the switch for vsan " + str(vsan) - + ". Hence cannot procced." + + ". Hence cannot procced.", ) # Process zone default zone options @@ -525,20 +525,20 @@ def main(): commands_executed.append("zone default-zone permit vsan " + str(vsan)) messages.append( "default zone configuration changed from deny to permit for vsan " - + str(vsan) + + str(vsan), ) else: commands_executed.append("no zone default-zone permit vsan " + str(vsan)) messages.append( "default zone configuration changed from permit to deny for vsan " - + str(vsan) + + str(vsan), ) else: messages.append( "default zone is already " + op_default_zone + " ,no change in default zone configuration for vsan " - + str(vsan) + + str(vsan), ) # Process zone mode options @@ -548,20 +548,20 @@ def main(): commands_executed.append("zone mode enhanced vsan " + str(vsan)) messages.append( "zone mode configuration changed from basic to enhanced for vsan " - + str(vsan) + + str(vsan), ) else: commands_executed.append("no zone mode enhanced vsan " + str(vsan)) messages.append( "zone mode configuration changed from enhanced to basic for vsan " - + str(vsan) + + str(vsan), ) else: messages.append( "zone mode is already " + op_mode + " ,no change in zone mode configuration for vsan " - + str(vsan) + + str(vsan), ) # Process zone smart-zone options @@ -578,7 +578,7 @@ def main(): "smart-zoning is already set to " + sw_smart_zoning + " , no change in smart-zoning configuration for vsan " - + str(vsan) + + str(vsan), ) # Process zone member options @@ -600,13 +600,13 @@ def main(): + zname + "' is not present in vsan " + str(vsan) - + " , so nothing to remove" + + " , so nothing to remove", ) else: if zmembers is None: if shZoneObj.isZonePresent(zname): messages.append( - "zone '" + zname + "' is already present in vsan " + str(vsan) + "zone '" + zname + "' is already present in vsan " + str(vsan), ) else: commands_executed.append("zone name " + zname + " vsan " + str(vsan)) @@ -633,7 +633,7 @@ def main(): + "' from zone '" + zname + "' in vsan " - + str(vsan) + + str(vsan), ) else: messages.append( @@ -642,7 +642,7 @@ def main(): + "' from zone '" + zname + "' in vsan " - + str(vsan) + + str(vsan), ) else: if op_smart_zoning and eachmem["devtype"] is not None: @@ -655,7 +655,7 @@ def main(): + zname + "' in vsan " + str(vsan) - + " hence nothing to remove" + + " hence nothing to remove", ) else: messages.append( @@ -665,7 +665,7 @@ def main(): + zname + "' in vsan " + str(vsan) - + " hence nothing to remove" + + " hence nothing to remove", ) else: messages.append( @@ -673,7 +673,7 @@ def main(): + zname + "' is not present in vsan " + str(vsan) - + " , hence cannot remove the members" + + " , hence cannot remove the members", ) else: @@ -688,7 +688,7 @@ def main(): + zname + "' in vsan " + str(vsan) - + " hence nothing to add" + + " hence nothing to add", ) else: messages.append( @@ -698,7 +698,7 @@ def main(): + zname + "' in vsan " + str(vsan) - + " hence nothing to add" + + " hence nothing to add", ) else: cmd = "member " + cmd @@ -712,7 +712,7 @@ def main(): + "' to zone '" + zname + "' in vsan " - + str(vsan) + + str(vsan), ) else: messages.append( @@ -721,7 +721,7 @@ def main(): + "' to zone '" + zname + "' in vsan " - + str(vsan) + + str(vsan), ) if len(cmdmemlist) != 0: commands_executed.append("zone name " + zname + " vsan " + str(vsan)) @@ -741,10 +741,10 @@ def main(): if removeflag: if shZonesetObj.isZonesetPresent(zsetname): messages.append( - "zoneset '" + zsetname + "' is removed from vsan " + str(vsan) + "zoneset '" + zsetname + "' is removed from vsan " + str(vsan), ) commands_executed.append( - "no zoneset name " + zsetname + " vsan " + str(vsan) + "no zoneset name " + zsetname + " vsan " + str(vsan), ) else: messages.append( @@ -752,7 +752,7 @@ def main(): + zsetname + "' is not present in vsan " + str(vsan) - + " ,hence there is nothing to remove" + + " ,hence there is nothing to remove", ) else: if zsetmembers is not None: @@ -770,7 +770,7 @@ def main(): + "' from zoneset '" + zsetname + "' in vsan " - + str(vsan) + + str(vsan), ) else: messages.append( @@ -780,7 +780,7 @@ def main(): + zsetname + "' in vsan " + str(vsan) - + " ,hence there is nothing to remove" + + " ,hence there is nothing to remove", ) else: if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): @@ -791,7 +791,7 @@ def main(): + zsetname + "' in vsan " + str(vsan) - + " ,hence there is nothing to add" + + " ,hence there is nothing to add", ) else: cmd = "member " + zsetmem_name @@ -802,34 +802,37 @@ def main(): + "' to zoneset '" + zsetname + "' in vsan " - + str(vsan) + + str(vsan), ) if len(cmdmemlist) != 0: commands_executed.append( - "zoneset name " + zsetname + " vsan " + str(vsan) + "zoneset name " + zsetname + " vsan " + str(vsan), ) commands_executed = commands_executed + cmdmemlist else: if shZonesetObj.isZonesetPresent(zsetname): messages.append( - "zoneset '" + zsetname + "' is already present in vsan " + str(vsan) + "zoneset '" + + zsetname + + "' is already present in vsan " + + str(vsan), ) else: commands_executed.append( - "zoneset name " + zsetname + " vsan " + str(vsan) + "zoneset name " + zsetname + " vsan " + str(vsan), ) messages.append( - "zoneset '" + zsetname + "' is created in vsan " + str(vsan) + "zoneset '" + zsetname + "' is created in vsan " + str(vsan), ) # Process zoneset activate options if actionflag == "deactivate": if shZonesetActiveObj.isZonesetActive(zsetname): messages.append( - "deactivating zoneset '" + zsetname + "' in vsan " + str(vsan) + "deactivating zoneset '" + zsetname + "' in vsan " + str(vsan), ) dactcmd.append( - "no zoneset activate name " + zsetname + " vsan " + str(vsan) + "no zoneset activate name " + zsetname + " vsan " + str(vsan), ) else: messages.append( @@ -837,12 +840,12 @@ def main(): + zsetname + "' in vsan " + str(vsan) - + " is not activated, hence cannot deactivate" + + " is not activated, hence cannot deactivate", ) elif actionflag == "activate": if commands_executed: messages.append( - "activating zoneset '" + zsetname + "' in vsan " + str(vsan) + "activating zoneset '" + zsetname + "' in vsan " + str(vsan), ) actcmd.append("zoneset activate name " + zsetname + " vsan " + str(vsan)) else: @@ -851,7 +854,7 @@ def main(): + zsetname + "' in vsan " + str(vsan) - + " hence activate action is ignored" + + " hence activate action is ignored", ) commands_executed = commands_executed + dactcmd + actcmd diff --git a/plugins/terminal/nxos.py b/plugins/terminal/nxos.py index 94e816a2c..b54664df2 100644 --- a/plugins/terminal/nxos.py +++ b/plugins/terminal/nxos.py @@ -33,7 +33,7 @@ class TerminalModule(TerminalBase): terminal_stdout_re = [ re.compile( - rb"[\r\n](?!\s*<)?(\x1b\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\s*)(\x1b\S+)*$" + rb"[\r\n](?!\s*<)?(\x1b\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\s*)(\x1b\S+)*$", ), re.compile(rb"[\r\n]?[a-zA-Z0-9]{1}[a-zA-Z0-9-_.]*\(.+\)#(?:\s*)$"), ] @@ -96,13 +96,13 @@ def on_become(self, passwd=None): prompt = self._get_prompt() if prompt is None or not prompt.strip().endswith(b"enable#"): raise AnsibleConnectionFailure( - "failed to elevate privilege to enable mode still at prompt [%s]" % prompt + "failed to elevate privilege to enable mode still at prompt [%s]" % prompt, ) except AnsibleConnectionFailure as e: prompt = self._get_prompt() raise AnsibleConnectionFailure( "unable to elevate privilege to enable mode, at prompt [%s] with error: %s" - % (prompt, e.message) + % (prompt, e.message), ) def on_unbecome(self): diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py index e3be12a42..2e857592a 100644 --- a/tests/unit/mock/yaml_helper.py +++ b/tests/unit/mock/yaml_helper.py @@ -117,10 +117,14 @@ def _old_dump_load_cycle(self, obj): yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper) else: yaml_string_obj_from_stream = yaml.dump( - obj_from_stream, Dumper=AnsibleDumper, encoding=None + obj_from_stream, + Dumper=AnsibleDumper, + encoding=None, ) yaml_string_obj_from_string = yaml.dump( - obj_from_string, Dumper=AnsibleDumper, encoding=None + obj_from_string, + Dumper=AnsibleDumper, + encoding=None, ) assert yaml_string == yaml_string_obj_from_stream diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py b/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py index 820d4055a..8ae5b9b56 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py @@ -34,7 +34,7 @@ def setUp(self): self.execute_show_cmd = self.mock_execute_show_cmd.start() self.mock_execute_show_cmd_1 = patch( - module_path + "showDeviceAliasDatabase.execute_show_cmd" + module_path + "showDeviceAliasDatabase.execute_show_cmd", ) self.execute_show_cmd_1 = self.mock_execute_show_cmd_1.start() @@ -189,7 +189,7 @@ def test_da_remove_1(self): name="tieHost-2", pwwn="10:00:00:00:89:a1:01:02", remove=True, - ) + ), ], ), True, @@ -220,7 +220,7 @@ def test_da_remove_2(self): name="somename", pwwn="10:00:00:00:89:a1:01:02", remove=True, - ) + ), ], ), True, @@ -241,7 +241,7 @@ def test_da_lock(self): name="somename", pwwn="10:00:00:00:89:a1:01:02", remove=True, - ) + ), ], ), True, @@ -261,7 +261,7 @@ def test_da_paramete_not_supported(self): name="somename", pwwn="10:00:00:00:89:a1:01:02", remove=True, - ) + ), ], ), True, @@ -299,7 +299,7 @@ def test_da_rename_1(self): rename=[ dict(old_name="test1_add", new_name="test234"), dict(old_name="tieHost-1", new_name="tieTarget-1"), - ] + ], ), True, ) @@ -325,7 +325,7 @@ def test_da_rename_2(self): rename=[ dict(old_name="test1", new_name="test234"), dict(old_name="tie", new_name="tieTarget-1"), - ] + ], ), True, ) @@ -337,7 +337,8 @@ def test_da_rename_2(self): def test_da_mansi(self): set_module_args({"distribute": True, "mode": "enhanced"}, True) self.execute_show_cmd.return_value = load_fixture( - "nxos_devicealias", "shdastatus_mansi.cfg" + "nxos_devicealias", + "shdastatus_mansi.cfg", ) self.execute_show_cmd_1.return_value = load_fixture("nxos_devicealias", "shdadatabse.cfg") result = self.execute_module(changed=True) diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py b/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py index aa889df55..55a892054 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py @@ -28,12 +28,12 @@ def setUp(self): self.run_commands = self.mock_run_commands.start() self.mock_execute_show_vsan_cmd = patch( - module_path + "GetVsanInfoFromSwitch.execute_show_vsan_cmd" + module_path + "GetVsanInfoFromSwitch.execute_show_vsan_cmd", ) self.execute_show_vsan_cmd = self.mock_execute_show_vsan_cmd.start() self.mock_execute_show_vsanmemcmd = patch( - module_path + "GetVsanInfoFromSwitch.execute_show_vsan_mem_cmd" + module_path + "GetVsanInfoFromSwitch.execute_show_vsan_mem_cmd", ) self.execute_show_vsanmem_cmd = self.mock_execute_show_vsanmemcmd.start() @@ -68,7 +68,7 @@ def test_vsan_add_remove_but_present_in_switch(self): "name": "vsan-SAN-B", }, {"id": 1923, "remove": True, "name": "vsan-SAN-Old"}, - ] + ], } set_module_args(margs, True) self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") @@ -103,7 +103,7 @@ def test_vsan_add(self): "id": 925, "name": "vsan-SAN-925", }, - ] + ], } set_module_args(margs, True) self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") @@ -140,7 +140,7 @@ def test_vsan_suspend(self): "name": "vsan-SAN-924", }, {"id": 925, "name": "vsan-SAN-925", "suspend": True}, - ] + ], } set_module_args(margs, True) self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") @@ -187,8 +187,8 @@ def test_vsan_add_int_existing_vsan(self): { "interface": ["fc1/1", "fc1/40", "port-channel 155"], "id": 922, - } - ] + }, + ], } set_module_args(margs, True) self.execute_show_vsan_cmd.return_value = load_fixture("nxos_vsan", "shvsan.cfg") diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py b/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py index c62477445..6f91183b8 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py @@ -34,12 +34,12 @@ def setUp(self): self.run_commands = self.mock_run_commands.start() self.mock_execute_show_cmd_zoneset_active = patch( - module_path + "ShowZonesetActive.execute_show_zoneset_active_cmd" + module_path + "ShowZonesetActive.execute_show_zoneset_active_cmd", ) self.execute_show_cmd_zoneset_active = self.mock_execute_show_cmd_zoneset_active.start() self.mock_execute_show_cmd_zoneset = patch( - module_path + "ShowZoneset.execute_show_zoneset_cmd" + module_path + "ShowZoneset.execute_show_zoneset_cmd", ) self.execute_show_cmd_zoneset = self.mock_execute_show_cmd_zoneset.start() @@ -47,7 +47,7 @@ def setUp(self): self.execute_show_cmd_zone = self.mock_execute_show_cmd_zone.start() self.mock_execute_show_cmd_zone_status = patch( - module_path + "ShowZoneStatus.execute_show_zone_status_cmd" + module_path + "ShowZoneStatus.execute_show_zone_status_cmd", ) self.execute_show_cmd_zone_status = self.mock_execute_show_cmd_zone_status.start() @@ -74,7 +74,8 @@ def test_zone_defzone_deny_to_permit(self): a = dict(zone_zoneset_details=[dict(vsan=922, default_zone="permit")]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -91,7 +92,8 @@ def test_zone_defzone_deny_to_permit_1(self): a = dict(zone_zoneset_details=[dict(vsan=922, default_zone="permit")]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_1.cfg" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -109,7 +111,8 @@ def test_zone_defzone_permit_to_deny_1(self): a = dict(zone_zoneset_details=[dict(vsan=923, default_zone="deny")]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_2.cfg" + "nxos_zone_zoneset", + "shzonestatus_2.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -127,7 +130,8 @@ def test_zone_defzone_permit_to_deny_2(self): a = dict(zone_zoneset_details=[dict(vsan=923, default_zone="deny")]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_3.cfg" + "nxos_zone_zoneset", + "shzonestatus_3.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -145,7 +149,8 @@ def test_zone_mode_basic_to_enh(self): a = dict(zone_zoneset_details=[dict(vsan=922, mode="enhanced")]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -164,7 +169,8 @@ def test_zone_mode_basic_to_enh_1(self): a = dict(zone_zoneset_details=[dict(vsan=922, mode="basic")]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_1.cfg" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -182,7 +188,8 @@ def test_zone_smart_zone(self): a = dict(zone_zoneset_details=[dict(vsan=922, smart_zoning=False)]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -199,7 +206,8 @@ def test_zone_smart_zone_1(self): a = dict(zone_zoneset_details=[dict(vsan=923, smart_zoning=True)]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_1.cfg" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -217,7 +225,8 @@ def test_zone_add_rem(self): 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" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=True) @@ -235,7 +244,8 @@ def test_zone_add_rem_1(self): 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" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=False, failed=False) @@ -247,7 +257,8 @@ def test_zone_add_rem_2(self): a = dict(zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneBNew")])]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_1.cfg" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=True) @@ -265,7 +276,8 @@ def test_zone_add_rem_3(self): a = dict(zone_zoneset_details=[dict(vsan=923, zone=[dict(name="zoneB")])]) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_1.cfg" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=False, failed=False) @@ -282,12 +294,13 @@ def test_zonemem_add_rem(self): dict( vsan=923, zone=[dict(name="zoneBNew", members=[mem1, mem2])], - ) - ] + ), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_1.cfg" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=True) @@ -308,11 +321,12 @@ def test_zonemem_add_rem_1(self): 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" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=True) @@ -333,11 +347,12 @@ def test_zonemem_add_rem_2(self): 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" + "nxos_zone_zoneset", + "shzonestatus_1.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_0.cfg") result = self.execute_module(changed=False, failed=False) @@ -355,12 +370,13 @@ def test_zonemem_add_rem_3(self): dict( vsan=922, zone=[dict(name="zoneBNew", members=[mem1, mem2, mem3])], - ) - ] + ), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_1.cfg") result = self.execute_module(changed=True) @@ -383,7 +399,8 @@ def test_zonemem_add_rem_4(self): 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" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zone.return_value = load_fixture("nxos_zone_zoneset", "shzone_1.cfg") result = self.execute_module(changed=True) @@ -400,14 +417,16 @@ def test_zonemem_add_rem_4(self): # 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( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -423,10 +442,12 @@ def test_zoneset_add_rem_1(self): 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", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -442,10 +463,12 @@ def test_zoneset_add_rem_2(self): 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", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=False, failed=False) m = "zoneset 'zsetname21' is already present in vsan 922" @@ -454,14 +477,18 @@ def test_zoneset_add_rem_2(self): def test_zoneset_add_rem_3(self): a = dict( - zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21New", remove=True)])] + zone_zoneset_details=[ + dict(vsan=922, zoneset=[dict(name="zsetname21New", remove=True)]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=False, failed=False) m = "zoneset 'zsetname21New' is not present in vsan 922 ,hence there is nothing to remove" @@ -473,14 +500,18 @@ def test_zoneset_mem_add_rem(self): mem1 = {"name": "newZoneV100"} a = dict( - zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])])] + zone_zoneset_details=[ + dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=True, failed=False) self.assertEqual( @@ -498,14 +529,18 @@ def test_zoneset_mem_add_rem_1(self): mem1 = {"name": "zone21A", "remove": True} a = dict( - zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])])] + zone_zoneset_details=[ + dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=True, failed=False) self.assertEqual( @@ -523,14 +558,18 @@ def test_zoneset_mem_add_rem_2(self): mem1 = {"name": "zone21", "remove": True} a = dict( - zone_zoneset_details=[dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])])] + zone_zoneset_details=[ + dict(vsan=922, zoneset=[dict(name="zsetname21", members=[mem1])]), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_0.cfg" + "nxos_zone_zoneset", + "shzoneset_0.cfg", ) result = self.execute_module(changed=False, failed=False) m = "zoneset member 'zone21' is not present in zoneset 'zsetname21' in vsan 922 ,hence there is nothing to remove" @@ -540,17 +579,20 @@ def test_zoneset_mem_add_rem_2(self): # 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( - "nxos_zone_zoneset", "shzonestatus_4.cfg" + "nxos_zone_zoneset", + "shzonestatus_4.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_2.cfg" + "nxos_zone_zoneset", + "shzoneset_2.cfg", ) self.execute_show_cmd_zoneset_active.return_value = load_fixture( - "nxos_zone_zoneset", "shzonesetactive_0.cfg" + "nxos_zone_zoneset", + "shzonesetactive_0.cfg", ) result = self.execute_module(changed=False, failed=False) self.assertEqual(result["commands"], []) @@ -561,18 +603,21 @@ def test_zoneset_activate_deactivate_1(self): dict( vsan=221, zoneset=[dict(name="zsv221", action="deactivate")], - ) - ] + ), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_4.cfg" + "nxos_zone_zoneset", + "shzonestatus_4.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_2.cfg" + "nxos_zone_zoneset", + "shzoneset_2.cfg", ) self.execute_show_cmd_zoneset_active.return_value = load_fixture( - "nxos_zone_zoneset", "shzonesetactive_0.cfg" + "nxos_zone_zoneset", + "shzonesetactive_0.cfg", ) result = self.execute_module(changed=True, failed=False) self.assertEqual( @@ -591,18 +636,21 @@ def test_zoneset_activate_deactivate_2(self): dict( vsan=221, zoneset=[dict(name="zsv221New", action="activate")], - ) - ] + ), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_4.cfg" + "nxos_zone_zoneset", + "shzonestatus_4.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_2.cfg" + "nxos_zone_zoneset", + "shzoneset_2.cfg", ) self.execute_show_cmd_zoneset_active.return_value = load_fixture( - "nxos_zone_zoneset", "shzonesetactive_0.cfg" + "nxos_zone_zoneset", + "shzonesetactive_0.cfg", ) result = self.execute_module(changed=True, failed=False) self.assertEqual( @@ -620,15 +668,17 @@ def test_bug_zone_remove(self): 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" + "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_zoneset_active.return_value = load_fixture( - "nxos_zone_zoneset", "shzonesetactive_0.cfg" + "nxos_zone_zoneset", + "shzonesetactive_0.cfg", ) result = self.execute_module(changed=True) self.assertEqual( @@ -649,18 +699,21 @@ def test_bug_from_active_zoneset_act(self): dict( vsan=221, zoneset=[dict(name="zsv221New", action="activate")], - ) - ] + ), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_4.cfg" + "nxos_zone_zoneset", + "shzonestatus_4.cfg", ) self.execute_show_cmd_zoneset.return_value = load_fixture( - "nxos_zone_zoneset", "shzoneset_2.cfg" + "nxos_zone_zoneset", + "shzoneset_2.cfg", ) self.execute_show_cmd_zoneset_active.return_value = load_fixture( - "nxos_zone_zoneset", "shzonesetactive_0.cfg" + "nxos_zone_zoneset", + "shzonesetactive_0.cfg", ) result = self.execute_module(changed=True, failed=False) self.assertEqual( @@ -683,15 +736,17 @@ def test_for_bug_339(self): vsan=100, smart_zoning=True, zone=[dict(name="SZ-WLD-IAAS1-HUABVA07", members=[mem1])], - ) - ] + ), + ], ) self.execute_show_cmd_zone.return_value = load_fixture( - "nxos_zone_zoneset", "shzone_bug339.cfg" + "nxos_zone_zoneset", + "shzone_bug339.cfg", ) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "shzonestatus_0.cfg" + "nxos_zone_zoneset", + "shzonestatus_0.cfg", ) set_module_args(a, True) result = self.execute_module(changed=False, failed=False) @@ -709,20 +764,23 @@ def test_bug_zone_remove_oliver(self): dict( name="z50_azusant_f0_unity8174_spa1", members=[mem1], - ) + ), ], - ) - ] + ), + ], ) set_module_args(a, True) self.execute_show_cmd_zone_status.return_value = load_fixture( - "nxos_zone_zoneset", "show_zone_status_vsan.out" + "nxos_zone_zoneset", + "show_zone_status_vsan.out", ) self.execute_show_cmd_zone.return_value = load_fixture( - "nxos_zone_zoneset", "show_zone_vsan.out" + "nxos_zone_zoneset", + "show_zone_vsan.out", ) self.execute_show_cmd_zoneset_active.return_value = load_fixture( - "nxos_zone_zoneset", "show_zoneset_active_vsan.out" + "nxos_zone_zoneset", + "show_zoneset_active_vsan.out", ) result = self.execute_module(changed=True) self.assertEqual( diff --git a/tests/unit/modules/network/nxos/test_nxos.py b/tests/unit/modules/network/nxos/test_nxos.py index e1b4400ac..fd5cdb36f 100644 --- a/tests/unit/modules/network/nxos/test_nxos.py +++ b/tests/unit/modules/network/nxos/test_nxos.py @@ -61,7 +61,7 @@ def _connection_side_effect(*args, **kwargs): value = kwargs.get("command") fixture_path = path.abspath( - b"%s/%s" % (b_FIXTURE_DIR, b"_".join(value.split(b" "))) + b"%s/%s" % (b_FIXTURE_DIR, b"_".join(value.split(b" "))), ) with open(fixture_path, "rb") as file_desc: return to_text(file_desc.read()) diff --git a/tests/unit/modules/network/nxos/test_nxos_acl.py b/tests/unit/modules/network/nxos/test_nxos_acl.py index fce0c63aa..34a7d6679 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl.py @@ -37,12 +37,12 @@ def setUp(self): super(TestNxosAclModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_acl.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_acl.load_config", ) self.load_config = self.mock_load_config.start() @@ -78,7 +78,7 @@ def test_nxos_acl(self): proto="tcp", src="192.0.2.1/24", dest="any", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interface.py b/tests/unit/modules/network/nxos/test_nxos_acl_interface.py index 75cb9dd1a..26011a376 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl_interface.py @@ -38,12 +38,12 @@ def setUp(self): super(TestNxosAclInterfaceModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl_interface.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_acl_interface.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl_interface.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_acl_interface.load_config", ) self.load_config = self.mock_load_config.start() @@ -84,7 +84,7 @@ def test_nxos_acl_interface_remove(self): interface="ethernet1/41", direction="egress", state="absent", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py index cf063f64c..016f89b27 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py @@ -23,32 +23,32 @@ def setUp(self): super(TestNxosAclInterfacesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "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" + "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" + "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" + "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.acl_interfaces.acl_interfaces.Acl_interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.acl_interfaces.acl_interfaces.Acl_interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() self.mock_execute_show_command = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acl_interfaces.acl_interfaces.Acl_interfacesFacts.get_device_data" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acl_interfaces.acl_interfaces.Acl_interfacesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -78,12 +78,12 @@ def test_nxos_acl_interfaces_merged(self): dict( afi="ipv4", acls=[dict(name="ACL1-v4", direction="in")], - ) + ), ], - ) + ), ], state="merged", - ) + ), ) commands = ["interface Ethernet1/3", "ip access-group ACL1-v4 in"] self.execute_module(changed=True, commands=commands) @@ -98,7 +98,7 @@ def test_nxos_acl_interfaces_merged_idempotent(self): dict( afi="ipv4", acls=[dict(name="ACL1v4", direction="out")], - ) + ), ], ), dict( @@ -111,14 +111,14 @@ def test_nxos_acl_interfaces_merged_idempotent(self): name="ACL2v6", direction="in", port=True, - ) + ), ], - ) + ), ], ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -136,9 +136,9 @@ def test_nxos_acl_interfaces_replaced(self): name="ACL1v6", direction="in", port=True, - ) + ), ], - ) + ), ], ), dict( @@ -151,14 +151,14 @@ def test_nxos_acl_interfaces_replaced(self): name="ACL2v4", direction="in", port=True, - ) + ), ], - ) + ), ], ), ], state="replaced", - ) + ), ) commands = [ "interface Ethernet1/2", @@ -179,12 +179,12 @@ def test_nxos_acl_interfaces_replaced_idempotent(self): dict( afi="ipv4", acls=[dict(name="ACL1v4", direction="out")], - ) + ), ], - ) + ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -205,12 +205,12 @@ def test_nxos_acl_interfaces_overridden(self): port=True, ), ], - ) + ), ], - ) + ), ], state="overridden", - ) + ), ) commands = [ "interface Ethernet1/2", @@ -233,7 +233,7 @@ def test_nxos_acl_interfaces_overridden_idempotent(self): dict( afi="ipv4", acls=[dict(name="ACL1v4", direction="out")], - ) + ), ], ), dict( @@ -246,14 +246,14 @@ def test_nxos_acl_interfaces_overridden_idempotent(self): name="ACL2v6", direction="in", port=True, - ) + ), ], - ) + ), ], ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -267,7 +267,7 @@ def test_nxos_acl_interfaces_deletedafi(self): dict( config=[dict(name="Ethernet1/2", access_groups=[dict(afi="ipv4")])], state="deleted", - ) + ), ) commands = ["interface Ethernet1/2", "no ip access-group ACL1v4 out"] self.execute_module(changed=True, commands=commands) @@ -282,12 +282,12 @@ def test_nxos_acl_interfaces_deletedacl(self): dict( afi="ipv4", acls=[dict(name="ACL1v4", direction="out")], - ) + ), ], - ) + ), ], state="deleted", - ) + ), ) commands = ["interface Ethernet1/2", "no ip access-group ACL1v4 out"] self.execute_module(changed=True, commands=commands) @@ -302,7 +302,7 @@ def test_nxos_acl_interfaces_rendered(self): dict( afi="ipv4", acls=[dict(name="ACL1v4", direction="out")], - ) + ), ], ), dict( @@ -315,14 +315,14 @@ def test_nxos_acl_interfaces_rendered(self): name="ACL2v6", direction="in", port=True, - ) + ), ], - ) + ), ], ), ], state="rendered", - ) + ), ) commands = [ "interface Ethernet1/2", @@ -339,7 +339,7 @@ def test_nxos_acl_interfaces_parsed(self): running_config="""interface Ethernet1/2\n ip access-group ACL1v4 out\n interface Ethernet1/4\n \ ipv6 port traffic-filter ACL2v6 in""", state="parsed", - ) + ), ) result = self.execute_module(changed=False) compare_list = [ @@ -348,7 +348,7 @@ def test_nxos_acl_interfaces_parsed(self): { "acls": [{"direction": "out", "name": "ACL1v4"}], "afi": "ipv4", - } + }, ], "name": "Ethernet1/2", }, @@ -357,7 +357,7 @@ def test_nxos_acl_interfaces_parsed(self): { "acls": [{"direction": "in", "name": "ACL2v6", "port": True}], "afi": "ipv6", - } + }, ], "name": "Ethernet1/4", }, @@ -373,7 +373,7 @@ def test_nxos_acl_interfaces_gathered(self): { "acls": [{"direction": "out", "name": "ACL1v4"}], "afi": "ipv4", - } + }, ], "name": "Ethernet1/2", }, @@ -382,7 +382,7 @@ def test_nxos_acl_interfaces_gathered(self): { "acls": [{"direction": "in", "name": "ACL2v6", "port": True}], "afi": "ipv6", - } + }, ], "name": "Ethernet1/4", }, diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index d04bae051..258c5a070 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -25,32 +25,32 @@ def setUp(self): super(TestNxosAclsModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "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" + "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" + "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" + "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.acls.acls.Acls.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.acls.acls.Acls.edit_config", ) self.edit_config = self.mock_edit_config.start() self.mock_execute_show_command = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acls.acls.AclsFacts.get_device_data" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.acls.acls.AclsFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -109,13 +109,13 @@ def test_nxos_acls_merged(self): protocol_options=dict(icmp=dict(echo_request=True)), ), ], - ) + ), ], ), dict(afi="ipv6", acls=[dict(name="ACL2v6")]), ], state="merged", - ) + ), ) commands = [ "ip access-list ACL2v4", @@ -151,7 +151,7 @@ def test_nxos_acls_merged_idempotent(self): protocol="udp", ), ], - ) + ), ], ), dict( @@ -166,14 +166,14 @@ def test_nxos_acls_merged_idempotent(self): source=dict(any=True), sequence=10, protocol="sctp", - ) + ), ], - ) + ), ], ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -195,16 +195,16 @@ def test_nxos_acls_replaced(self): sequence=50, protocol="icmp", protocol_options=dict( - icmp=dict(administratively_prohibited=True) + icmp=dict(administratively_prohibited=True), ), - ) + ), ], - ) + ), ], - ) + ), ], state="replaced", - ) + ), ) commands = [ "ip access-list ACL1v4", @@ -239,7 +239,7 @@ def test_nxos_acls_replaced_idempotent(self): protocol="udp", ), ], - ) + ), ], ), dict( @@ -254,14 +254,14 @@ def test_nxos_acls_replaced_idempotent(self): source=dict(any=True), sequence=10, protocol="sctp", - ) + ), ], - ) + ), ], ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -283,17 +283,17 @@ def test_nxos_acls_overridden(self): sequence=50, protocol="icmp", protocol_options=dict( - icmp=dict(administratively_prohibited=True) + icmp=dict(administratively_prohibited=True), ), ), dict(remark="Overridden ACL"), ], - ) + ), ], - ) + ), ], state="overridden", - ) + ), ) commands = [ "no ip access-list ACL1v4", @@ -329,7 +329,7 @@ def test_nxos_acls_overridden_idempotent(self): protocol="udp", ), ], - ) + ), ], ), dict( @@ -344,14 +344,14 @@ def test_nxos_acls_overridden_idempotent(self): source=dict(any=True), sequence=10, protocol="sctp", - ) + ), ], - ) + ), ], ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -390,7 +390,7 @@ def test_nxos_acls_rendered(self): protocol="udp", ), ], - ) + ), ], ), dict( @@ -405,14 +405,14 @@ def test_nxos_acls_rendered(self): source=dict(any=True), sequence=10, protocol="sctp", - ) + ), ], - ) + ), ], ), ], state="rendered", - ) + ), ) commands = [ "ip access-list ACL1v4", @@ -433,10 +433,10 @@ def test_nxos_acls_parsed(self): statistics per-entry 10 permit ip any any 20 deny udp any any dscp AF23 precedence critical - """ + """, ), state="parsed", - ) + ), ) result = self.execute_module(changed=False) compare_list = [ @@ -463,9 +463,9 @@ def test_nxos_acls_parsed(self): "precedence": "critical", }, ], - } + }, ], - } + }, ] self.assertEqual(result["parsed"], compare_list, result["parsed"]) @@ -483,10 +483,10 @@ def test_nxos_acls_gathered(self): "protocol": "sctp", "source": {"any": True}, "grant": "permit", - } + }, ], "name": "ACL1v6", - } + }, ], "afi": "ipv6", }, @@ -510,7 +510,7 @@ def test_nxos_acls_gathered(self): }, ], "name": "ACL1v4", - } + }, ], "afi": "ipv4", }, @@ -527,7 +527,7 @@ def test_nxos_acls_replaced_2(self): 40 remark TEST-COMMENT-2 50 permit ip 198.51.100.6/32 any 60 permit ip 198.51.100.7/32 any - """ + """, ) set_module_args( dict( @@ -567,12 +567,12 @@ def test_nxos_acls_replaced_2(self): protocol="ip", ), ], - ) + ), ], - ) + ), ], state="replaced", - ) + ), ) commands = [ @@ -596,7 +596,7 @@ def test_nxos_acls_merged_failure(self): """\ ip access-list 99 10 remark TEST-COMMENT-1 - """ + """, ) set_module_args( dict( @@ -613,14 +613,14 @@ def test_nxos_acls_merged_failure(self): source=dict(host="192.0.2.1"), sequence=10, protocol="ip", - ) + ), ], - ) + ), ], - ) + ), ], state="merged", - ) + ), ) result = self.execute_module(failed=True) @@ -638,7 +638,7 @@ def test_nxos_acls_parse_remark(self): 10 permit udp any any 20 deny tcp any any 30 remark for resetting to default run resequence ip access-list TEST_RESEQUENCE_ipv6 2 3 - """ + """, ) set_module_args(dict(state="gathered")) @@ -667,7 +667,7 @@ def test_nxos_acls_parse_remark(self): "remark": "for resetting to default run resequence ip access-list TEST_RESEQUENCE_ipv6 2 3", }, ], - } + }, ], "afi": "ipv6", }, @@ -698,7 +698,7 @@ def test_nxos_acls_parse_remark(self): "remark": "for resetting to default run resequence ip access-list TEST_RESEQUENCE 2 3", }, ], - } + }, ], "afi": "ipv4", }, diff --git a/tests/unit/modules/network/nxos/test_nxos_banner.py b/tests/unit/modules/network/nxos/test_nxos_banner.py index 2d99b6ad5..cb269f01c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_banner.py +++ b/tests/unit/modules/network/nxos/test_nxos_banner.py @@ -33,12 +33,12 @@ class TestNxosBannerModule(TestNxosModule): def setUp(self): super(TestNxosBannerModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_banner.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_banner.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_banner.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_banner.load_config", ) self.load_config = self.mock_load_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py index a0f3835ce..9b41f2806 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py @@ -48,17 +48,17 @@ def setUp(self): super(TestNxosBfdGlobalModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bfd_global.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_bfd_global.load_config", ) self.load_config = self.mock_load_config.start() self.mock_execute_show_command = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.execute_show_command" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.execute_show_command", ) self.execute_show_command = self.mock_execute_show_command.start() self.mock_get_platform_shortname = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.get_platform_shortname" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.get_platform_shortname", ) self.get_platform_shortname = self.mock_get_platform_shortname.start() @@ -88,7 +88,7 @@ def test_bfd_defaults_n9k(self): ipv6_echo_rx_interval=50, ipv6_interval={"tx": 50, "min_rx": 50, "multiplier": 3}, ipv6_slow_timer=2000, - ) + ), ) self.execute_module(changed=False) @@ -111,7 +111,7 @@ def test_bfd_non_defaults_n9k(self): ipv6_echo_rx_interval=51, ipv6_interval={"tx": 51, "min_rx": 51, "multiplier": 4}, ipv6_slow_timer=2001, - ) + ), ) self.execute_module( changed=True, @@ -147,7 +147,7 @@ def test_bfd_defaults_n3k(self): ipv6_echo_rx_interval=250, ipv6_interval={"tx": 250, "min_rx": 250, "multiplier": 3}, ipv6_slow_timer=2000, - ) + ), ) self.execute_module(changed=False) @@ -165,7 +165,7 @@ def test_bfd_defaults_n35(self): ipv4_echo_rx_interval=50, ipv4_interval={"tx": 50, "min_rx": 50, "multiplier": 3}, ipv4_slow_timer=2000, - ) + ), ) self.execute_module(changed=False) @@ -181,7 +181,7 @@ def test_bfd_defaults_n6k(self): fabricpath_interval={"tx": 50, "min_rx": 50, "multiplier": 3}, fabricpath_slow_timer=2000, fabricpath_vlan=1, - ) + ), ) self.execute_module(changed=False) @@ -204,7 +204,7 @@ def test_bfd_defaults_n7k(self): fabricpath_interval={"tx": 50, "min_rx": 50, "multiplier": 3}, fabricpath_slow_timer=2000, fabricpath_vlan=1, - ) + ), ) self.execute_module(changed=False) @@ -225,7 +225,7 @@ def test_bfd_existing_n9k(self): ipv6_echo_rx_interval=50, ipv6_interval={"tx": 51, "min_rx": 51, "multiplier": 3}, ipv6_slow_timer=2000, - ) + ), ) self.execute_module( changed=True, @@ -261,7 +261,7 @@ def test_bfd_idempotence_n9k(self): ipv6_echo_rx_interval=56, ipv6_interval={"tx": 56, "min_rx": 56, "multiplier": 6}, ipv6_slow_timer=2006, - ) + ), ) self.execute_module(changed=False) @@ -284,7 +284,7 @@ def test_bfd_existing_n7k(self): fabricpath_interval={"tx": 51, "min_rx": 51, "multiplier": 3}, fabricpath_slow_timer=2003, fabricpath_vlan=3, - ) + ), ) self.execute_module( changed=True, @@ -324,6 +324,6 @@ def test_bfd_idempotence_n7k(self): fabricpath_interval={"tx": 58, "min_rx": 58, "multiplier": 8}, fabricpath_slow_timer=2008, fabricpath_vlan=2, - ) + ), ) self.execute_module(changed=False) diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py index b7af5d120..0a1ad4091 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py @@ -45,22 +45,22 @@ def setUp(self): super(TestNxosBfdInterfacesModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.bfd_interfaces.bfd_interfaces.Bfd_interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bfd_interfaces.bfd_interfaces.Bfd_interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() @@ -102,14 +102,14 @@ def test_1(self): interface Ethernet1/1 interface Ethernet1/2 interface Ethernet1/3 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="disable", echo="disable"), dict(name="Ethernet1/2", bfd="disable"), - ] + ], ) # Expected result commands for each 'state' merged = [ @@ -151,7 +151,7 @@ def test_2(self): interface Ethernet1/3 no bfd no bfd echo - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -160,7 +160,7 @@ def test_2(self): dict(name="Ethernet1/2"), # Eth1/3 not present! Thus overridden should set Eth1/3 to defaults; # replaced should ignore Eth1/3. - ] + ], ) # Expected result commands for each 'state' merged = ["interface Ethernet1/1", "bfd", "no bfd echo"] @@ -216,7 +216,7 @@ def test_3(self): interface Ethernet1/3 no bfd no bfd echo - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/1")]) @@ -257,7 +257,7 @@ def test_4(self): feature bfd interface Ethernet1/1 no bfd - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/1.42", bfd="enable", echo="disable")]) @@ -298,14 +298,14 @@ def test_5(self): no bfd no bfd echo interface Ethernet1/2 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="disable", echo="disable"), dict(name="Ethernet1/2", bfd="enable", echo="enable"), - ] + ], ) # Expected result commands for each 'state' merged = [] diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp.py b/tests/unit/modules/network/nxos/test_nxos_bgp.py index 291e51f5e..a02266bdb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosBgpModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.load_config" + "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" + "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.get_config", ) self.get_config = self.mock_get_config.start() @@ -120,12 +120,12 @@ def setUp(self): super(TestNxosBgp32BitsAS, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.load_config" + "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" + "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp.get_config", ) self.get_config = self.mock_get_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py index 1847c5d56..b22d5aed6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py @@ -53,12 +53,12 @@ def setUp(self): super(TestNxosBGPAddressFamilyModule, 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" + "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_address_family.bgp_address_family.Bgp_address_familyFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_address_family.bgp_address_family.Bgp_address_familyFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -76,7 +76,7 @@ def test_nxos_bgp_additional_paths_merged(self): address-family ipv4 unicast additional-paths install backup additional-paths send - """ + """, ) set_module_args( dict( @@ -143,7 +143,7 @@ def test_nxos_bgp_additional_paths_replaced(self): vrf site-2 address-family ipv6 multicast additional-paths receive - """ + """, ) set_module_args( dict( @@ -188,7 +188,7 @@ def test_nxos_bgp_l2vpn_keys_merged(self): router bgp 65563 address-family l2vpn evpn advertise-pip - """ + """, ) set_module_args( dict( @@ -201,7 +201,7 @@ def test_nxos_bgp_l2vpn_keys_merged(self): advertise_pip=False, advertise_system_mac=True, allow_vni_in_ethertag=True, - ) + ), ], ), state="merged", @@ -226,7 +226,7 @@ def test_nxos_bgp_l2vpn_keys_replaced(self): address-family l2vpn evpn advertise-system-mac allow-vni-in-ethertag - """ + """, ) set_module_args( dict( @@ -256,7 +256,7 @@ def test_nxos_bgp_client_to_client_merged(self): vrf site-1 address-family ipv4 unicast no client-to-client reflection - """ + """, ) set_module_args( dict( @@ -302,7 +302,7 @@ def test_nxos_bgp_client_to_client_replaced(self): vrf site-1 address-family ipv4 unicast no client-to-client reflection - """ + """, ) set_module_args( dict( @@ -342,7 +342,7 @@ def test_nxos_bgp_aggregate_address_merged(self): vrf site-1 address-family ipv4 unicast aggregate-address 192.168.1.0/24 as-set - """ + """, ) set_module_args( dict( @@ -415,7 +415,7 @@ def test_nxos_bgp_aggregate_address_replaced(self): address-family ipv4 unicast aggregate-address 10.0.0.0/8 summary-only aggregate-address 11.0.0.0/8 advertise-map rmap1 as-set attribute-map rmap2 - """ + """, ) set_module_args( dict( @@ -431,7 +431,7 @@ def test_nxos_bgp_aggregate_address_replaced(self): advertise_map="rmap1", as_set=True, attribute_map="rmap2", - ) + ), ], ), dict( @@ -477,7 +477,7 @@ def test_nxos_bgp_dampen_igp_metric_merged(self): vrf site-1 address-family ipv4 unicast dampen-igp-metric 1200 - """ + """, ) set_module_args( dict( @@ -520,7 +520,7 @@ def test_nxos_bgp_dampen_igp_metric_replaced(self): dampen-igp-metric 1800 address-family ipv6 unicast dampen-igp-metric 1200 - """ + """, ) set_module_args( dict( @@ -558,7 +558,7 @@ def test_nxos_bgp_dampening_merged(self): vrf site-1 address-family ipv4 unicast dampening 3 22 23 23 - """ + """, ) set_module_args( dict( @@ -622,7 +622,7 @@ def test_nxos_bgp_dampening_replaced(self): vrf site-1 address-family ipv4 unicast dampening 3 22 23 23 - """ + """, ) set_module_args( dict( @@ -663,7 +663,7 @@ def test_nxos_bgp_dampening_route_map_merged(self): vrf site-1 address-family ipv4 unicast dampening route-map rmap1 - """ + """, ) set_module_args( dict( @@ -708,7 +708,7 @@ def test_nxos_bgp_dampening_route_map_replaced(self): vrf site-1 address-family ipv4 unicast dampening route-map rmap1 - """ + """, ) set_module_args( dict( @@ -744,7 +744,7 @@ def test_nxos_bgp_default_information_merged(self): vrf site-1 address-family ipv4 unicast default-information originate - """ + """, ) set_module_args( dict( @@ -789,7 +789,7 @@ def test_nxos_bgp_default_information_replaced(self): vrf site-1 address-family ipv4 unicast default-information originate - """ + """, ) set_module_args( dict( @@ -825,7 +825,7 @@ def test_nxos_bgp_default_metric_merged(self): vrf site-1 address-family ipv4 unicast default-metric 6400 - """ + """, ) set_module_args( dict( @@ -868,7 +868,7 @@ def test_nxos_bgp_default_metric_replaced(self): vrf site-1 address-family ipv4 unicast default-metric 6400 - """ + """, ) set_module_args( dict( @@ -904,7 +904,7 @@ def test_nxos_bgp_distance_merged(self): vrf site-1 address-family ipv4 unicast distance 20 18 2 - """ + """, ) set_module_args( dict( @@ -951,7 +951,7 @@ def test_nxos_bgp_distance_replaced(self): vrf site-1 address-family ipv4 unicast distance 20 18 2 - """ + """, ) set_module_args( dict( @@ -990,7 +990,7 @@ def test_nxos_bgp_export_gateway_ip_merged(self): vrf site-2 address-family ipv4 unicast export-gateway-ip - """ + """, ) set_module_args( dict( @@ -1048,7 +1048,7 @@ def test_nxos_bgp_export_gateway_ip_replaced(self): vrf site-2 address-family ipv4 unicast export-gateway-ip - """ + """, ) set_module_args( dict( @@ -1093,7 +1093,7 @@ def test_nxos_bgp_inject_map_merged(self): vrf site-1 address-family ipv4 unicast inject-map rmap1 exist-map rmap2 - """ + """, ) set_module_args( dict( @@ -1121,7 +1121,7 @@ def test_nxos_bgp_inject_map_merged(self): route_map="rmap3", exist_map="rmap4", copy_attributes=True, - ) + ), ], ), ], @@ -1153,7 +1153,7 @@ def test_nxos_bgp_inject_map_replaced(self): vrf site-1 address-family ipv4 unicast inject-map rmap3 exist-map rmap4 copy-attributes - """ + """, ) set_module_args( dict( @@ -1174,7 +1174,7 @@ def test_nxos_bgp_inject_map_replaced(self): route_map="rmap3", exist_map="rmap4", copy_attributes=True, - ) + ), ], ), ], @@ -1202,7 +1202,7 @@ def test_nxos_bgp_maximum_paths_merged(self): address-family ipv4 unicast maximum-paths 14 maximum-paths eibgp 64 - """ + """, ) set_module_args( dict( @@ -1265,7 +1265,7 @@ def test_nxos_bgp_maximum_paths_replaced(self): maximum-paths local 30 address-family ipv4 multicast maximum-paths mixed 40 - """ + """, ) set_module_args( dict( @@ -1309,7 +1309,7 @@ def test_nxos_bgp_network_merged(self): vrf site-1 address-family ipv4 unicast network 192.168.1.0/24 route-map rmap1 - """ + """, ) set_module_args( dict( @@ -1368,7 +1368,7 @@ def test_nxos_bgp_network_replaced(self): network 10.0.0.0/8 network 11.0.0.0/8 route-map rmap2 network 192.168.1.0/24 route-map rmap1 - """ + """, ) set_module_args( dict( @@ -1414,7 +1414,7 @@ def test_nxos_bgp_nexthop_merged(self): vrf site-1 address-family ipv4 unicast nexthop route-map rmap2 - """ + """, ) set_module_args( dict( @@ -1434,7 +1434,7 @@ def test_nxos_bgp_nexthop_merged(self): afi="ipv4", safi="unicast", nexthop=dict( - trigger_delay=dict(critical_delay=110, non_critical_delay=170) + trigger_delay=dict(critical_delay=110, non_critical_delay=170), ), ), ], @@ -1467,7 +1467,7 @@ def test_nxos_bgp_nexthop_replaced(self): address-family ipv4 unicast nexthop route-map rmap2 nexthop trigger-delay critical 110 non-critical 170 - """ + """, ) set_module_args( dict( @@ -1484,7 +1484,7 @@ def test_nxos_bgp_nexthop_replaced(self): afi="ipv4", safi="unicast", nexthop=dict( - trigger_delay=dict(critical_delay=110, non_critical_delay=170) + trigger_delay=dict(critical_delay=110, non_critical_delay=170), ), ), ], @@ -1512,7 +1512,7 @@ def test_nxos_bgp_redistribute_merged(self): vrf site-1 address-family ipv4 unicast redistribute eigrp 100 route-map test-17 - """ + """, ) set_module_args( dict( @@ -1589,7 +1589,7 @@ def test_nxos_bgp_redistribute_replaced(self): address-family ipv4 unicast redistribute eigrp 100 route-map test-18 redistribute ospf 101 route-map test-2 - """ + """, ) set_module_args( dict( @@ -1618,7 +1618,7 @@ def test_nxos_bgp_redistribute_replaced(self): protocol="ospf", id="101", route_map="test-2", - ) + ), ], ), ], @@ -1647,7 +1647,7 @@ def test_nxos_bgp_retain_merged(self): vrf site-1 address-family ipv4 unicast retain route-target all - """ + """, ) set_module_args( dict( @@ -1692,7 +1692,7 @@ def test_nxos_bgp_retain_replaced(self): vrf site-1 address-family ipv4 unicast retain route-target route-map rmap1 - """ + """, ) set_module_args( dict( @@ -1728,7 +1728,7 @@ def test_nxos_bgp_suppress_inactive_merged(self): vrf site-1 address-family ipv4 unicast suppress-inactive - """ + """, ) set_module_args( dict( @@ -1773,7 +1773,7 @@ def test_nxos_bgp_suppress_inactive_replaced(self): vrf site-1 address-family ipv4 unicast suppress-inactive - """ + """, ) set_module_args( dict( @@ -1809,7 +1809,7 @@ def test_nxos_bgp_table_map_merged(self): vrf site-1 address-family ipv4 unicast table-map rmap1 filter - """ + """, ) set_module_args( dict( @@ -1849,7 +1849,7 @@ def test_nxos_bgp_table_map_replaced(self): vrf site-1 address-family ipv4 unicast table-map rmap1 filter - """ + """, ) set_module_args( dict( @@ -1887,7 +1887,7 @@ def test_nxos_bgp_timers_merged(self): vrf site-1 address-family ipv4 unicast timers bestpath-defer 100 maximum 350 - """ + """, ) set_module_args( dict( @@ -1898,7 +1898,7 @@ def test_nxos_bgp_timers_merged(self): afi="ipv4", safi="multicast", timers=dict( - bestpath_defer=dict(defer_time=120, maximum_defer_time=380) + bestpath_defer=dict(defer_time=120, maximum_defer_time=380), ), ), dict( @@ -1906,7 +1906,7 @@ def test_nxos_bgp_timers_merged(self): afi="ipv4", safi="unicast", timers=dict( - bestpath_defer=dict(defer_time=110, maximum_defer_time=350) + bestpath_defer=dict(defer_time=110, maximum_defer_time=350), ), ), ], @@ -1936,7 +1936,7 @@ def test_nxos_bgp_timers_replaced(self): vrf site-1 address-family ipv4 unicast timers bestpath-defer 100 maximum 350 - """ + """, ) set_module_args( dict( @@ -1947,7 +1947,7 @@ def test_nxos_bgp_timers_replaced(self): afi="ipv4", safi="multicast", timers=dict( - bestpath_defer=dict(defer_time=120, maximum_defer_time=380) + bestpath_defer=dict(defer_time=120, maximum_defer_time=380), ), ), dict(vrf="site-1", afi="ipv4", safi="unicast"), @@ -1974,7 +1974,7 @@ def test_nxos_bgp_wait_igp_convergence_merged(self): vrf site-1 address-family ipv4 unicast wait-igp-convergence - """ + """, ) set_module_args( dict( @@ -2019,7 +2019,7 @@ def test_nxos_bgp_wait_igp_convergence_replaced(self): vrf site-1 address-family ipv4 unicast wait-igp-convergence - """ + """, ) set_module_args( dict( @@ -2064,7 +2064,7 @@ def test_nxos_bgp_af_parsed(self): vrf site-1 address-family ipv4 unicast timers bestpath-defer 100 maximum 350 - """ + """, ), state="parsed", ), @@ -2101,7 +2101,7 @@ def test_nxos_bgp_af_gathered(self): timers bestpath-defer 100 maximum 350 neighbor 192.168.3.0 address-family ipv6 multicast - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) @@ -2124,7 +2124,7 @@ def test_nxos_bgp_af_gathered_empty(self): # test gathered self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) @@ -2135,7 +2135,7 @@ def test_nxos_bgp_af_rendered(self): # test gathered self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( @@ -2164,7 +2164,7 @@ def test_nxos_bgp_af_rendered(self): protocol="ospf", id="101", route_map="test-2", - ) + ), ], ), ], @@ -2204,7 +2204,7 @@ def test_nxos_bgp_af_delete(self): address-family ipv6 multicast vrf site-2 address-family ipv6 unicast - """ + """, ) set_module_args( @@ -2242,7 +2242,7 @@ def test_nxos_bgp_af_idempotent(self): router bgp 65563 address-family ipv4 multicast wait-igp-convergence - """ + """, ) set_module_args( @@ -2254,7 +2254,7 @@ def test_nxos_bgp_af_idempotent(self): afi="ipv4", safi="multicast", wait_igp_convergence=True, - ) + ), ], ), state="merged", @@ -2282,7 +2282,7 @@ def test_nxos_bgp_af_overridden(self): address-family ipv6 multicast vrf site-2 address-family ipv6 unicast - """ + """, ) set_module_args( @@ -2294,7 +2294,7 @@ def test_nxos_bgp_af_overridden(self): afi="ipv4", safi="multicast", wait_igp_convergence=False, - ) + ), ], ), state="overridden", @@ -2336,7 +2336,7 @@ def test_nxos_bgp_af_delete(self): address-family ipv6 multicast vrf site-2 address-family ipv6 unicast - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) @@ -2364,7 +2364,7 @@ def test_nxos_bgp_vrf_af_advertise_l2vpn_evpn(self): vrf site-2 address-family ipv4 unicast advertise l2vpn evpn - """ + """, ) set_module_args( dict( @@ -2411,7 +2411,7 @@ def test_nxos_bgp_vrf_af_advertise_l2vpn_evpn_replaced(self): vrf site-2 address-family ipv4 unicast advertise l2vpn evpn - """ + """, ) set_module_args( dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py index 5cb2c2efd..d9773bd73 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosBgpAfModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_af.load_config" + "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" + "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_af.get_config", ) self.get_config = self.mock_get_config.start() @@ -85,7 +85,7 @@ def test_nxos_bgp_af_dampening_routemap(self): afi="ipv4", safi="unicast", dampening_routemap="route-map-a", - ) + ), ) self.execute_module( changed=True, @@ -106,7 +106,7 @@ def test_nxos_bgp_af_dampening_manual(self): dampening_suppress_time=2000, dampening_reuse_time=1900, dampening_max_suppress_time=10, - ) + ), ) self.execute_module( changed=True, @@ -128,7 +128,7 @@ def test_nxos_bgp_af_dampening_mix(self): dampening_suppress_time=2000, dampening_reuse_time=1900, dampening_max_suppress_time=10, - ) + ), ) result = self.execute_module(failed=True) self.assertEqual( diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index 247ddf013..e1c57815c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -42,17 +42,17 @@ def setUp(self): super(TestNxosBgpGlobalModule, 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" + "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_global.bgp_global.Bgp_globalFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_config", ) self.get_config = self.mock_get_config.start() self.mock_cfg_get_config = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_global.bgp_global.Bgp_global._get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_global.bgp_global.Bgp_global._get_config", ) self.cfg_get_config = self.mock_cfg_get_config.start() @@ -108,7 +108,7 @@ def test_nxos_bgp_global_merged(self): encryption=3, key="13D4D3549493D2877B1DC116EE27A6BE", ), - ) + ), ], ), dict( @@ -168,7 +168,7 @@ def test_nxos_bgp_global_bfd(self): tx_interval=300, min_rx_interval=258, multiplier=12, - ) + ), ), ), ), @@ -182,7 +182,7 @@ def test_nxos_bgp_global_bfd(self): min_rx_interval=260, multiplier=15, ), - ) + ), ), ), dict( @@ -237,7 +237,7 @@ def test_nxos_bgp_global_bfd(self): bfd multihop neighbor 198.51.100.24 bfd - """ + """, ) self.get_config.return_value = run_cfg self.cfg_get_config.return_value = run_cfg @@ -256,7 +256,7 @@ def test_nxos_bgp_global_bfd(self): tx_interval=300, min_rx_interval=258, multiplier=12, - ) + ), ), ), ), @@ -270,7 +270,7 @@ def test_nxos_bgp_global_bfd(self): min_rx_interval=260, multiplier=15, ), - ) + ), ), ), dict( @@ -322,7 +322,7 @@ def test_nxos_bgp_global_merged_idempotent(self): local-as 300 log-neighbor-changes neighbor-down fib-accelerate - """ + """, ) self.get_config.return_value = run_cfg @@ -362,7 +362,7 @@ def test_nxos_bgp_global_merged_idempotent(self): encryption=3, key="13D4D3549493D2877B1DC116EE27A6BE", ), - ) + ), ], ), dict( @@ -408,7 +408,7 @@ def test_nxos_bgp_global_replaced(self): 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 @@ -427,7 +427,7 @@ def test_nxos_bgp_global_replaced(self): remote_as="65537", description="NBR-1", low_memory=dict(exempt=True), - ) + ), ], vrfs=[ dict( @@ -444,9 +444,9 @@ def test_nxos_bgp_global_replaced(self): encryption=3, key="13D4D3549493D2877B1DC116EE27A6BE", ), - ) + ), ], - ) + ), ], ), state="replaced", @@ -487,7 +487,7 @@ def test_nxos_bgp_global_replaced_idempotent(self): remote-as 65538 description site-1-nbr-1 password 3 13D4D3549493D2877B1DC116EE27A6BE - """ + """, ) self.get_config.return_value = run_cfg self.cfg_get_config.return_value = run_cfg @@ -506,7 +506,7 @@ def test_nxos_bgp_global_replaced_idempotent(self): remote_as="65537", description="NBR-1", low_memory=dict(exempt=True), - ) + ), ], vrfs=[ dict( @@ -523,9 +523,9 @@ def test_nxos_bgp_global_replaced_idempotent(self): encryption=3, key="13D4D3549493D2877B1DC116EE27A6BE", ), - ) + ), ], - ) + ), ], ), state="replaced", @@ -563,7 +563,7 @@ def test_nxos_bgp_global_replaced_failed_1(self): 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 @@ -582,7 +582,7 @@ def test_nxos_bgp_global_replaced_failed_1(self): remote_as="65537", description="NBR-1", low_memory=dict(exempt=True), - ) + ), ], vrfs=[ dict( @@ -599,9 +599,9 @@ def test_nxos_bgp_global_replaced_failed_1(self): encryption=3, key="13D4D3549493D2877B1DC116EE27A6BE", ), - ) + ), ], - ) + ), ], ), state="replaced", @@ -638,7 +638,7 @@ def test_nxos_bgp_global_replaced_failed_2(self): 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 @@ -670,7 +670,7 @@ def test_nxos_bgp_global_replaced_failed_2(self): local_as="300", log_neighbor_changes=True, neighbor_down=dict(fib_accelerate=True), - ) + ), ], ), state="replaced", @@ -707,7 +707,7 @@ def test_nxos_bgp_global_replaced_failed_3(self): 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 @@ -780,7 +780,7 @@ def test_nxos_bgp_global_deleted(self): 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 @@ -803,7 +803,7 @@ def test_nxos_bgp_global_deleted(self): def test_nxos_bgp_global_deleted_idempotent_1(self): run_cfg = dedent( """\ - """ + """, ) self.get_config.return_value = run_cfg self.cfg_get_config.return_value = run_cfg @@ -840,7 +840,7 @@ def test_nxos_bgp_global_deleted_idempotent_2(self): 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 @@ -881,7 +881,7 @@ def test_nxos_bgp_global_deleted_failed(self): 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 @@ -916,7 +916,7 @@ def test_nxos_bgp_global_purged(self): 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 @@ -930,7 +930,7 @@ def test_nxos_bgp_global_purged(self): def test_nxos_bgp_global_purged_idempotent(self): run_cfg = dedent( """\ - """ + """, ) self.get_config.return_value = run_cfg self.cfg_get_config.return_value = run_cfg @@ -944,7 +944,7 @@ def test_nxos_bgp_global_purged(self): run_cfg = dedent( """\ router bgp 65001 - """ + """, ) self.get_config.return_value = run_cfg self.cfg_get_config.return_value = run_cfg @@ -958,7 +958,7 @@ def test_nxos_bgp_global_purged(self): neighbor_address="10.239.0.13", peer_type="fabric-external", remote_as="65002", - ) + ), ], ), state="merged", diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py index b04b6d6ff..b911d9f76 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosBgpNeighborModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor.load_config" + "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" + "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor.get_config", ) self.get_config = self.mock_get_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index cab007f0b..9dba98030 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -53,13 +53,13 @@ def setUp(self): super(TestNxosBGPNeighborAddressFamilyModule, 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" + "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_neighbor_address_family." - "bgp_neighbor_address_family.Bgp_neighbor_address_familyFacts.get_config" + "bgp_neighbor_address_family.Bgp_neighbor_address_familyFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -79,7 +79,7 @@ def test_nxos_bgp_nbr_af_advertise_map_merged(self): advertise-map rmap2 exist-map rmap3 address-family ipv4 multicast advertise-map rmap1 non-exist-map rmap5 - """ + """, ) set_module_args( dict( @@ -93,9 +93,9 @@ def test_nxos_bgp_nbr_af_advertise_map_merged(self): afi="ipv4", safi="multicast", advertise_map=dict(route_map="rmap1", exist_map="rmap2"), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -121,9 +121,9 @@ def test_nxos_bgp_nbr_af_advertise_map_merged(self): ), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -157,7 +157,7 @@ def test_nxos_bgp_nbr_af_advertise_map_replaced(self): advertise-map rmap2 exist-map rmap3 address-family ipv4 multicast advertise-map rmap1 non-exist-map rmap5 - """ + """, ) set_module_args( dict( @@ -171,9 +171,9 @@ def test_nxos_bgp_nbr_af_advertise_map_replaced(self): afi="ipv4", safi="multicast", advertise_map=dict(route_map="rmap1", exist_map="rmap3"), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -192,9 +192,9 @@ def test_nxos_bgp_nbr_af_advertise_map_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -223,7 +223,7 @@ def test_nxos_bgp_nbr_af_advertisement_interval_merged(self): neighbor 192.168.1.1 address-family ipv4 unicast advertisement-interval 300 - """ + """, ) set_module_args( dict( @@ -237,9 +237,9 @@ def test_nxos_bgp_nbr_af_advertisement_interval_merged(self): afi="ipv4", safi="multicast", advertisement_interval=350, - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -259,9 +259,9 @@ def test_nxos_bgp_nbr_af_advertisement_interval_merged(self): advertisement_interval=400, ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -297,7 +297,7 @@ def test_nxos_bgp_nbr_af_advertisement_interval_replaced(self): advertisement-interval 300 address-family ipv4 multicast advertisement-interval 400 - """ + """, ) set_module_args( dict( @@ -314,7 +314,7 @@ def test_nxos_bgp_nbr_af_advertisement_interval_replaced(self): advertisement_interval=350, ), ], - ) + ), ], vrfs=[ dict( @@ -330,9 +330,9 @@ def test_nxos_bgp_nbr_af_advertisement_interval_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -363,7 +363,7 @@ def test_nxos_bgp_nbr_af_allowas_in_merged(self): allowas-in 3 address-family ipv4 multicast allowas-in 3 - """ + """, ) set_module_args( dict( @@ -377,9 +377,9 @@ def test_nxos_bgp_nbr_af_allowas_in_merged(self): afi="ipv4", safi="multicast", allowas_in=dict(max_occurences=8), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -399,9 +399,9 @@ def test_nxos_bgp_nbr_af_allowas_in_merged(self): allowas_in=dict(max_occurences=3), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -435,7 +435,7 @@ def test_nxos_bgp_nbr_af_allowas_in_replaced(self): allowas-in 5 address-family ipv4 multicast allowas-in 3 - """ + """, ) set_module_args( dict( @@ -449,9 +449,9 @@ def test_nxos_bgp_nbr_af_allowas_in_replaced(self): afi="ipv4", safi="multicast", allowas_in=dict(max_occurences=9), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -467,9 +467,9 @@ def test_nxos_bgp_nbr_af_allowas_in_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -503,7 +503,7 @@ def test_nxos_bgp_nbr_af_as_override_merged(self): as-override address-family ipv4 multicast as-override - """ + """, ) set_module_args( dict( @@ -517,9 +517,9 @@ def test_nxos_bgp_nbr_af_as_override_merged(self): afi="ipv4", safi="multicast", as_override=True, - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -539,9 +539,9 @@ def test_nxos_bgp_nbr_af_as_override_merged(self): as_override=False, ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -577,7 +577,7 @@ def test_nxos_bgp_nbr_af_as_override_replaced(self): as-override address-family ipv4 multicast as-override - """ + """, ) set_module_args( dict( @@ -587,7 +587,7 @@ def test_nxos_bgp_nbr_af_as_override_replaced(self): dict( neighbor_address="10.0.0.2", address_family=[dict(afi="ipv4", safi="multicast")], - ) + ), ], vrfs=[ dict( @@ -603,9 +603,9 @@ def test_nxos_bgp_nbr_af_as_override_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -638,7 +638,7 @@ def test_nxos_bgp_nbr_af_capability_merged(self): address-family ipv4 multicast capability additional-paths receive disable capability additional-paths send - """ + """, ) set_module_args( dict( @@ -652,11 +652,11 @@ def test_nxos_bgp_nbr_af_capability_merged(self): afi="ipv4", safi="multicast", capability=dict( - additional_paths=dict(receive="enable", send="enable") + additional_paths=dict(receive="enable", send="enable"), ), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -672,7 +672,7 @@ def test_nxos_bgp_nbr_af_capability_merged(self): additional_paths=dict( receive="disable", send="enable", - ) + ), ), ), dict( @@ -682,13 +682,13 @@ def test_nxos_bgp_nbr_af_capability_merged(self): additional_paths=dict( receive="enable", send="disable", - ) + ), ), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -730,7 +730,7 @@ def test_nxos_bgp_nbr_af_capability_replaced(self): address-family ipv4 multicast capability additional-paths receive capability additional-paths send disable - """ + """, ) set_module_args( dict( @@ -744,9 +744,9 @@ def test_nxos_bgp_nbr_af_capability_replaced(self): afi="ipv4", safi="multicast", capability=dict(additional_paths=dict(send="enable")), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -762,14 +762,14 @@ def test_nxos_bgp_nbr_af_capability_replaced(self): additional_paths=dict( receive="disable", send="enable", - ) + ), ), ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -802,7 +802,7 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): disable-peer-as-check address-family ipv4 multicast default-originate route-map rmap1 - """ + """, ) set_module_args( dict( @@ -824,7 +824,7 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): default_originate=dict(route_map="rmap1"), ), ], - ) + ), ], vrfs=[ dict( @@ -845,9 +845,9 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): default_originate=dict(route_map="rmap2"), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -888,7 +888,7 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): disable-peer-as-check address-family ipv4 multicast default-originate route-map rmap1 - """ + """, ) set_module_args( dict( @@ -905,7 +905,7 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): default_originate=dict(route_map="rmap1"), ), ], - ) + ), ], vrfs=[ dict( @@ -922,9 +922,9 @@ def test_nxos_bgp_nbr_af_originate_peer_as_merged(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -960,7 +960,7 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_merged(self): address-family ipv4 multicast filter-list rmap1 out inherit peer-policy template-1 300 - """ + """, ) set_module_args( dict( @@ -975,9 +975,9 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_merged(self): safi="multicast", filter_list=dict(inbound="rmap3", outbound="rmap4"), inherit=dict(template="template-2", sequence=200), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1008,9 +1008,9 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_merged(self): ), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -1053,7 +1053,7 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_replaced(self): filter-list rmap1 out filter-list rmap2 in inherit peer-policy template-1 300 - """ + """, ) set_module_args( dict( @@ -1068,9 +1068,9 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_replaced(self): safi="multicast", filter_list=dict(inbound="rmap3"), inherit=dict(template="template-2", sequence=200), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1093,9 +1093,9 @@ def test_nxos_bgp_nbr_af_filter_list_inherit_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -1132,7 +1132,7 @@ def test_nxos_bgp_nbr_af_maximum_prefix_merged(self): maximum-prefix 12 85 warning-only address-family ipv6 unicast maximum-prefix 12 85 restart 1200 - """ + """, ) set_module_args( dict( @@ -1174,7 +1174,7 @@ def test_nxos_bgp_nbr_af_maximum_prefix_merged(self): ), ), ], - ) + ), ], vrfs=[ dict( @@ -1215,9 +1215,9 @@ def test_nxos_bgp_nbr_af_maximum_prefix_merged(self): ), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -1263,7 +1263,7 @@ def test_nxos_bgp_nbr_af_maximum_prefix_replaced(self): maximum-prefix 12 85 warning-only address-family ipv6 unicast maximum-prefix 12 85 restart 1200 - """ + """, ) set_module_args( dict( @@ -1280,7 +1280,7 @@ def test_nxos_bgp_nbr_af_maximum_prefix_replaced(self): maximum_prefix=dict(max_prefix_limit=28), ), ], - ) + ), ], vrfs=[ dict( @@ -1305,9 +1305,9 @@ def test_nxos_bgp_nbr_af_maximum_prefix_replaced(self): dict(afi="ipv6", safi="multicast"), dict(afi="ipv6", safi="unicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -1345,7 +1345,7 @@ def test_nxos_bgp_nbr_af_next_hop_merged(self): no next-hop-third-party address-family ipv4 multicast next-hop-self all - """ + """, ) set_module_args( dict( @@ -1366,7 +1366,7 @@ def test_nxos_bgp_nbr_af_next_hop_merged(self): next_hop_self=dict(all_routes=True), ), ], - ) + ), ], vrfs=[ dict( @@ -1392,9 +1392,9 @@ def test_nxos_bgp_nbr_af_next_hop_merged(self): next_hop_self=dict(all_routes=True), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -1435,7 +1435,7 @@ def test_nxos_bgp_nbr_af_next_hop_replaced(self): no next-hop-third-party address-family ipv4 multicast next-hop-self all - """ + """, ) set_module_args( dict( @@ -1452,7 +1452,7 @@ def test_nxos_bgp_nbr_af_next_hop_replaced(self): next_hop_self=dict(all_routes=True), ), ], - ) + ), ], vrfs=[ dict( @@ -1472,9 +1472,9 @@ def test_nxos_bgp_nbr_af_next_hop_replaced(self): next_hop_self=dict(all_routes=True), ), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -1507,7 +1507,7 @@ def test_nxos_bgp_nbr_af_prefix_list_merged(self): prefix-list rmap2 out address-family ipv4 multicast prefix-list rmap1 out - """ + """, ) set_module_args( dict( @@ -1521,9 +1521,9 @@ def test_nxos_bgp_nbr_af_prefix_list_merged(self): afi="ipv4", safi="multicast", prefix_list=dict(inbound="rmap3", outbound="rmap4"), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1546,9 +1546,9 @@ def test_nxos_bgp_nbr_af_prefix_list_merged(self): prefix_list=dict(inbound="rmap2"), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -1586,7 +1586,7 @@ def test_nxos_bgp_nbr_af_prefix_list_replaced(self): address-family ipv4 multicast prefix-list rmap1 out prefix-list rmap2 in - """ + """, ) set_module_args( dict( @@ -1600,9 +1600,9 @@ def test_nxos_bgp_nbr_af_prefix_list_replaced(self): afi="ipv4", safi="multicast", prefix_list=dict(inbound="rmap3"), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1621,9 +1621,9 @@ def test_nxos_bgp_nbr_af_prefix_list_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -1658,7 +1658,7 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_merged(self): address-family ipv4 multicast route-map rmap1 out rewrite-evpn-rt-asn - """ + """, ) set_module_args( dict( @@ -1673,9 +1673,9 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_merged(self): safi="multicast", route_map=dict(inbound="rmap3", outbound="rmap4"), rewrite_evpn_rt_asn=True, - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1700,9 +1700,9 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_merged(self): rewrite_evpn_rt_asn=True, ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -1745,7 +1745,7 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_replaced(self): route-map rmap1 out route-map rmap2 in rewrite-evpn-rt-asn - """ + """, ) set_module_args( dict( @@ -1760,9 +1760,9 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_replaced(self): safi="multicast", route_map=dict(inbound="rmap3"), rewrite_evpn_rt_asn=True, - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1782,9 +1782,9 @@ def test_nxos_bgp_nbr_af_rewrite_evpn_route_map_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -1816,7 +1816,7 @@ def test_nxos_bgp_route_reflector_client_send_community_merged(self): address-family ipv4 unicast route-reflector-client send-community - """ + """, ) set_module_args( dict( @@ -1831,9 +1831,9 @@ def test_nxos_bgp_route_reflector_client_send_community_merged(self): safi="multicast", route_reflector_client=True, send_community=dict(extended=True), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1854,9 +1854,9 @@ def test_nxos_bgp_route_reflector_client_send_community_merged(self): send_community=dict(set=True), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -1893,7 +1893,7 @@ def test_nxos_bgp_route_reflector_client_send_community_replaced(self): send-community address-family ipv4 multicast send-community - """ + """, ) set_module_args( dict( @@ -1907,9 +1907,9 @@ def test_nxos_bgp_route_reflector_client_send_community_replaced(self): afi="ipv4", safi="multicast", send_community=dict(extended=True), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1926,9 +1926,9 @@ def test_nxos_bgp_route_reflector_client_send_community_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -1958,7 +1958,7 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_merged(self): address-family ipv4 unicast soft-reconfiguration inbound always soo 65:28 - """ + """, ) set_module_args( dict( @@ -1973,9 +1973,9 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_merged(self): safi="multicast", soft_reconfiguration_inbound=dict(set=True), soo="73:43", - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -1996,9 +1996,9 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_merged(self): soft_reconfiguration_inbound=dict(always=True), ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -2035,7 +2035,7 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_replaced(self): soo 65:28 address-family ipv4 multicast soft-reconfiguration inbound always - """ + """, ) set_module_args( dict( @@ -2049,9 +2049,9 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_replaced(self): afi="ipv4", safi="multicast", soft_reconfiguration_inbound=dict(set=True), - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -2068,9 +2068,9 @@ def test_nxos_bgp_nbr_af_soft_reconfiguration_soo_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -2102,7 +2102,7 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_merged(self): unsuppress-map rmap1 address-family ipv4 multicast weight 10 - """ + """, ) set_module_args( dict( @@ -2118,9 +2118,9 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_merged(self): suppress_inactive=True, unsuppress_map="rmap2", weight=20, - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -2143,9 +2143,9 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_merged(self): unsuppress_map="rmap4", ), ], - ) + ), ], - ) + ), ], ), state="merged", @@ -2190,7 +2190,7 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_replaced(self): suppress-inactive unsuppress-map rmap4 weight 10 - """ + """, ) set_module_args( dict( @@ -2200,7 +2200,7 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_replaced(self): dict( neighbor_address="10.0.0.2", address_family=[dict(afi="ipv4", safi="multicast")], - ) + ), ], vrfs=[ dict( @@ -2218,9 +2218,9 @@ def test_nxos_bgp_nbr_af_suppress_inactive_unsuppress_replaced(self): ), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="replaced", @@ -2260,7 +2260,7 @@ def test_nxos_bgp_nbr_af_deleted(self): address-family ipv4 unicast address-family ipv4 multicast address-family ipv6 unicast - """ + """, ) set_module_args( dict( @@ -2273,7 +2273,7 @@ def test_nxos_bgp_nbr_af_deleted(self): dict(afi="ipv4", safi="multicast"), dict(afi="link-state"), ], - ) + ), ], vrfs=[ dict( @@ -2285,9 +2285,9 @@ def test_nxos_bgp_nbr_af_deleted(self): dict(afi="ipv4", safi="unicast"), dict(afi="ipv4", safi="multicast"), ], - ) + ), ], - ) + ), ], ), state="deleted", @@ -2323,7 +2323,7 @@ def test_nxos_bgp_nbr_af_deleted_all(self): address-family ipv4 unicast address-family ipv4 multicast address-family ipv6 unicast - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -2359,7 +2359,7 @@ def test_nxos_bgp_nbr_af_overridden(self): address-family ipv4 unicast address-family ipv4 multicast address-family ipv6 unicast - """ + """, ) set_module_args( dict( @@ -2375,7 +2375,7 @@ def test_nxos_bgp_nbr_af_overridden(self): route_reflector_client=True, ), ], - ) + ), ], vrfs=[ dict( @@ -2384,9 +2384,9 @@ def test_nxos_bgp_nbr_af_overridden(self): dict( neighbor_address="192.168.1.1", address_family=[dict(afi="ipv4", safi="multicast")], - ) + ), ], - ) + ), ], ), state="overridden", @@ -2421,7 +2421,7 @@ def test_nxos_bgp_nbr_af_gathered(self): vrf site-1 neighbor 192.168.1.1 address-family ipv4 multicast - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = dict( @@ -2433,7 +2433,7 @@ def test_nxos_bgp_nbr_af_gathered(self): dict(afi="ipv4", safi="unicast"), dict(afi="link-state"), ], - ) + ), ], vrfs=[ dict( @@ -2442,9 +2442,9 @@ def test_nxos_bgp_nbr_af_gathered(self): dict( neighbor_address="192.168.1.1", address_family=[dict(afi="ipv4", safi="multicast")], - ) + ), ], - ) + ), ], ) result = self.execute_module(changed=False) @@ -2463,7 +2463,7 @@ def test_nxos_bgp_nbr_af_parsed(self): vrf site-1 neighbor 192.168.1.1 address-family ipv4 multicast - """ + """, ), state="parsed", ), @@ -2478,7 +2478,7 @@ def test_nxos_bgp_nbr_af_parsed(self): dict(afi="ipv4", safi="unicast"), dict(afi="link-state"), ], - ) + ), ], vrfs=[ dict( @@ -2487,9 +2487,9 @@ def test_nxos_bgp_nbr_af_parsed(self): dict( neighbor_address="192.168.1.1", address_family=[dict(afi="ipv4", safi="multicast")], - ) + ), ], - ) + ), ], ) result = self.execute_module(changed=False) @@ -2511,9 +2511,9 @@ def test_nxos_bgp_nbr_af_rendered(self): suppress_inactive=True, unsuppress_map="rmap2", weight=20, - ) + ), ], - ) + ), ], vrfs=[ dict( @@ -2536,9 +2536,9 @@ def test_nxos_bgp_nbr_af_rendered(self): unsuppress_map="rmap4", ), ], - ) + ), ], - ) + ), ], ), state="rendered", @@ -2569,7 +2569,7 @@ def test_nxos_bgp_nbr_af_gathered_empty(self): # test gathered self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = dict() @@ -2581,7 +2581,7 @@ def test_nxos_bgp_nbr_af_gathered_only_asn(self): self.get_config.return_value = dedent( """\ router bgp 65563 - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = dict(as_number="65563") @@ -2595,7 +2595,7 @@ def test_nxos_bgp_nbr_af_no_cmd(self): router bgp 65536 neighbor 10.0.0.2 address-family ipv4 multicast - """ + """, ) set_module_args( dict( @@ -2605,7 +2605,7 @@ def test_nxos_bgp_nbr_af_no_cmd(self): dict( neighbor_address="10.0.0.2", address_family=[dict(afi="ipv4", safi="multicast")], - ) + ), ], ), state="merged", @@ -2626,7 +2626,7 @@ def test_nxos_bgp_af_send_community(self): address-family l2vpn evpn send-community send-community extended - """ + """, ) set_module_args( dict( @@ -2640,7 +2640,7 @@ def test_nxos_bgp_af_send_community(self): afi="l2vpn", safi="evpn", send_community=dict(both=True), - ) + ), ], ), dict( @@ -2650,7 +2650,7 @@ def test_nxos_bgp_af_send_community(self): afi="l2vpn", safi="evpn", send_community=dict(both=True), - ) + ), ], ), dict( @@ -2660,7 +2660,7 @@ def test_nxos_bgp_af_send_community(self): afi="l2vpn", safi="evpn", send_community=dict(set=True), - ) + ), ], ), ], diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py index 4e2ee989d..8e93f6499 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosBgpNeighborAfModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor_af.load_config" + "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" + "ansible_collections.cisco.nxos.plugins.modules.nxos_bgp_neighbor_af.get_config", ) self.get_config = self.mock_get_config.start() @@ -62,7 +62,7 @@ def test_nxos_bgp_neighbor_af(self): afi="ipv4", safi="unicast", route_reflector_client=True, - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -87,7 +87,7 @@ def test_nxos_bgp_neighbor_af_absent(self): afi="ipv4", safi="unicast", state="absent", - ) + ), ) self.execute_module( changed=True, @@ -107,7 +107,7 @@ def test_nxos_bgp_neighbor_af_advertise_map(self): afi="ipv4", safi="unicast", advertise_map_exist=["my_advertise_map", "my_exist_map"], - ) + ), ) self.execute_module( changed=True, @@ -131,7 +131,7 @@ def test_nxos_bgp_neighbor_af_advertise_map_non_exist(self): "my_advertise_map", "my_non_exist_map", ], - ) + ), ) self.execute_module( changed=True, @@ -152,7 +152,7 @@ def test_nxos_bgp_neighbor_af_max_prefix_limit_default(self): afi="ipv4", safi="unicast", max_prefix_limit="default", - ) + ), ) self.execute_module( changed=True, @@ -174,7 +174,7 @@ def test_nxos_bgp_neighbor_af_max_prefix(self): safi="unicast", max_prefix_threshold=20, max_prefix_limit=20, - ) + ), ) self.execute_module( changed=True, @@ -195,7 +195,7 @@ def test_nxos_bgp_neighbor_af_disable_peer_as_check(self): afi="ipv4", safi="unicast", disable_peer_as_check=True, - ) + ), ) self.execute_module( changed=True, @@ -215,7 +215,7 @@ def test_nxos_bgp_neighbor_af_rewrite_evpn(self): afi="l2vpn", safi="evpn", rewrite_evpn_rt_asn=True, - ) + ), ) self.execute_module( changed=True, @@ -235,7 +235,7 @@ def test_nxos_bgp_neighbor_af_rewrite_evpn_disable(self): afi="l2vpn", safi="evpn", rewrite_evpn_rt_asn=False, - ) + ), ) self.execute_module( changed=True, @@ -255,6 +255,6 @@ def test_nxos_bgp_neighbor_af_rewrite_evpn_exists(self): afi="l2vpn", safi="evpn", rewrite_evpn_rt_asn=True, - ) + ), ) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/network/nxos/test_nxos_command.py b/tests/unit/modules/network/nxos/test_nxos_command.py index 8dd126109..b6ce92f8a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_command.py +++ b/tests/unit/modules/network/nxos/test_nxos_command.py @@ -38,7 +38,7 @@ def setUp(self): super(TestNxosCommandModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_command.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_command.run_commands", ) self.run_commands = self.mock_run_commands.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_config.py b/tests/unit/modules/network/nxos/test_nxos_config.py index a1ea87ce8..800bea77b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_config.py +++ b/tests/unit/modules/network/nxos/test_nxos_config.py @@ -37,22 +37,22 @@ def setUp(self): super(TestNxosConfigModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_config.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_config.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_save_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_config.save_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_config.save_config", ) self.save_config = self.mock_save_config.start() self.mock_get_connection = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_config.get_connection" + "ansible_collections.cisco.nxos.plugins.modules.nxos_config.get_connection", ) self.get_connection = self.mock_get_connection.start() @@ -60,7 +60,7 @@ def setUp(self): self.conn.edit_config = MagicMock() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_config.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_config.run_commands", ) self.run_commands = self.mock_run_commands.start() @@ -82,7 +82,7 @@ def test_nxos_config_no_change(self): lines = ["hostname localhost"] args = dict(lines=lines) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config), ) set_module_args(args) result = self.execute_module() @@ -91,7 +91,7 @@ def test_nxos_config_src(self): src = load_fixture("nxos_config", "candidate.cfg") args = dict(src=src) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff(src, self.running_config) + return_value=self.cliconf_obj.get_diff(src, self.running_config), ) set_module_args(args) @@ -110,8 +110,10 @@ def test_nxos_config_replace_src(self): set_module_args(dict(replace_src="bootflash:config", replace="config")) self.conn.get_diff = MagicMock( return_value=self.cliconf_obj.get_diff( - self.running_config, self.running_config, diff_replace="config" - ) + self.running_config, + self.running_config, + diff_replace="config", + ), ) result = self.execute_module(changed=True) self.assertEqual(result["commands"], ["config replace bootflash:config"]) @@ -120,7 +122,7 @@ def test_nxos_config_lines(self): lines = ["hostname switch01", "ip domain-name eng.ansible.com"] args = dict(lines=lines) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config), ) set_module_args(args) @@ -133,7 +135,7 @@ def test_nxos_config_before(self): lines = ["hostname switch01", "ip domain-name eng.ansible.com"] args = dict(lines=lines, before=["before command"]) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config), ) set_module_args(args) @@ -148,7 +150,7 @@ def test_nxos_config_after(self): args = dict(lines=lines, after=["after command"]) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config) + return_value=self.cliconf_obj.get_diff("\n".join(lines), self.running_config), ) set_module_args(args) @@ -164,8 +166,10 @@ def test_nxos_config_parents(self): args = dict(lines=lines, parents=parents) self.conn.get_diff = MagicMock( return_value=self.cliconf_obj.get_diff( - "\n".join(parents + lines), self.running_config, path=parents - ) + "\n".join(parents + lines), + self.running_config, + path=parents, + ), ) set_module_args(args) diff --git a/tests/unit/modules/network/nxos/test_nxos_evpn_global.py b/tests/unit/modules/network/nxos/test_nxos_evpn_global.py index ec2fe8642..8b9fc698b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_evpn_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_evpn_global.py @@ -36,17 +36,17 @@ class TestNxosEvpnGlobalModule(TestNxosModule): def setUp(self): super(TestNxosEvpnGlobalModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_global.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_global.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_global.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_global.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_global.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_global.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = {"network_api": "cliconf"} diff --git a/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py b/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py index bc09f4b90..f191c7cf3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py +++ b/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosEvpnVniModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_vni.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_vni.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_vni.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_evpn_vni.get_config", ) self.get_config = self.mock_get_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_feature.py b/tests/unit/modules/network/nxos/test_nxos_feature.py index 97476297d..798f2d10e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_feature.py +++ b/tests/unit/modules/network/nxos/test_nxos_feature.py @@ -37,22 +37,22 @@ class TestNxosFeatureModule(TestNxosModule): def setUp(self): super(TestNxosFeatureModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_config", ) self.get_config = self.mock_get_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = {"network_api": "cliconf"} @@ -101,22 +101,22 @@ class TestNxosFeatureModuleMDS(TestNxosModule): def setUp(self): super(TestNxosFeatureModuleMDS, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_config", ) self.get_config = self.mock_get_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_feature.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = { diff --git a/tests/unit/modules/network/nxos/test_nxos_hostname.py b/tests/unit/modules/network/nxos/test_nxos_hostname.py index 7dd0342bf..3363e7f6a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hostname.py +++ b/tests/unit/modules/network/nxos/test_nxos_hostname.py @@ -43,12 +43,12 @@ def setUp(self): super(TestNxosHostnameModule, 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" + "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.hostname.hostname.HostnameFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname.HostnameFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -61,7 +61,7 @@ def test_nxos_hostname_merged(self): # test merged for linear attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict(config=dict(hostname="NXOSv-9k"), state="merged"), @@ -76,7 +76,7 @@ def test_nxos_hostname_linear_merged_idempotent(self): self.get_config.return_value = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args( dict(config=dict(hostname="NXOSv-9k"), state="merged"), @@ -90,7 +90,7 @@ def test_nxos_hostname_linear_merged_2(self): self.get_config.return_value = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args( dict(config=dict(hostname="NXOSv"), state="merged"), @@ -105,7 +105,7 @@ def test_nxos_hostname_linear_replaced(self): self.get_config.return_value = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args( dict(config=dict(hostname="NXOSv"), state="replaced"), @@ -120,7 +120,7 @@ def test_nxos_hostname_linear_overridden(self): self.get_config.return_value = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args( dict(config=dict(hostname="NXOSv"), state="overridden"), @@ -134,7 +134,7 @@ def test_nxos_hostname_deleted(self): self.get_config.return_value = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = ["no hostname NXOSv-9k"] @@ -155,7 +155,7 @@ def test_nxos_hostname_parsed(self): cfg = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = {"hostname": "NXOSv-9k"} @@ -167,7 +167,7 @@ def test_nxos_hostname_gathered(self): self.get_config.return_value = dedent( """\ hostname NXOSv-9k - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = {"hostname": "NXOSv-9k"} diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp.py b/tests/unit/modules/network/nxos/test_nxos_hsrp.py index f384d5e31..def01d998 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp.py @@ -35,17 +35,17 @@ class TestNxosHsrpModule(TestNxosModule): def setUp(self): super(TestNxosHsrpModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_hsrp.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_hsrp.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_hsrp.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_hsrp.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_hsrp.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_hsrp.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = {"network_api": "cliconf"} @@ -67,7 +67,7 @@ def test_nxos_hsrp(self): priority="150", interface="Ethernet1/2", preempt="enabled", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -81,6 +81,6 @@ def test_nxos_hsrp(self): "priority 150", "ip 192.0.2.2/8", "preempt", - ] + ], ), ) diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py index 748cd7306..299c225f8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py @@ -45,22 +45,22 @@ def setUp(self): super(TestNxosHsrpInterfacesModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.hsrp_interfaces.hsrp_interfaces.Hsrp_interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.hsrp_interfaces.hsrp_interfaces.Hsrp_interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() @@ -100,14 +100,14 @@ def test_1(self): interface Ethernet1/1 interface Ethernet1/2 interface Ethernet1/3 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="enable"), dict(name="Ethernet1/2", bfd="disable"), - ] + ], ) # Expected result commands for each 'state' merged = ["interface Ethernet1/1", "hsrp bfd"] @@ -141,7 +141,7 @@ def test_2(self): hsrp bfd interface Ethernet1/3 hsrp bfd - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -150,7 +150,7 @@ def test_2(self): dict(name="Ethernet1/2"), # Eth1/3 not present! Thus overridden should set Eth1/3 to defaults; # replaced should ignore Eth1/3. - ] + ], ) # Expected result commands for each 'state' merged = ["interface Ethernet1/1", "no hsrp bfd"] @@ -201,7 +201,7 @@ def test_3(self): hsrp bfd interface Ethernet1/3 hsrp bfd - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/1"), dict(name="Ethernet1/2")]) @@ -252,7 +252,7 @@ def test_4(self): hsrp bfd interface Ethernet1/2 hsrp bfd - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/1.42", bfd="enable")]) @@ -292,14 +292,14 @@ def test_5(self): interface Ethernet1/1 hsrp bfd interface Ethernet1/2 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( config=[ dict(name="Ethernet1/1", bfd="enable"), dict(name="Ethernet1/2", bfd="disable"), - ] + ], ) # Expected result commands for each 'state' merged = [] diff --git a/tests/unit/modules/network/nxos/test_nxos_interface.py b/tests/unit/modules/network/nxos/test_nxos_interface.py index eab5e7394..7b8854dd2 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_interface.py @@ -35,12 +35,12 @@ class TestNxosInterfaceModule(TestNxosModule): def setUp(self): super(TestNxosInterfaceModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_interface.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_interface.load_config", ) self.load_config = self.mock_load_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py b/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py index 2d3016e45..3ade69e7e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py +++ b/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosInterfaceOspfModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface_ospf.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_interface_ospf.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface_ospf.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_interface_ospf.load_config", ) self.load_config = self.mock_load_config.start() @@ -129,7 +129,7 @@ def test_bfd_4(self): area=1, bfd="enable", state="absent", - ) + ), ) self.execute_module( changed=True, @@ -148,7 +148,7 @@ def test_bfd_4(self): area=1, bfd="disable", state="absent", - ) + ), ) self.execute_module( changed=True, @@ -188,7 +188,7 @@ def test_nxos_interface_ospf_passive(self): ospf=1, area=1, passive_interface=True, - ) + ), ) self.execute_module( changed=True, @@ -205,7 +205,7 @@ def test_nxos_interface_ospf_passive(self): ospf=1, area=1, passive_interface=False, - ) + ), ) self.execute_module( changed=True, @@ -222,7 +222,7 @@ def test_nxos_interface_ospf_passive(self): ospf=1, area=1, passive_interface=False, - ) + ), ) self.execute_module( changed=True, @@ -248,7 +248,7 @@ def test_nxos_interface_ospf_passive(self): ospf=1, area=1, passive_interface=True, - ) + ), ) self.execute_module( changed=True, diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 9ebdc9f06..03434f7ce 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -48,32 +48,32 @@ def setUp(self): super(TestNxosInterfacesModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.interfaces.interfaces.Interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces.Interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() self.mock_get_system_defaults = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces.Interfaces.get_system_defaults" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces.Interfaces.get_system_defaults", ) self.get_system_defaults = self.mock_get_system_defaults.start() self.mock_get_platform = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces.Interfaces.get_platform" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces.Interfaces.get_platform", ) self.get_platform = self.mock_get_platform.start() @@ -107,7 +107,7 @@ def test_1(self): ! no system default switchport no system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -129,7 +129,7 @@ def test_1(self): no shutdown interface loopback0 description test-loopback - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -154,7 +154,7 @@ def test_1(self): dict(name="Ethernet1/4", mode="layer2"), dict(name="Ethernet1/5"), dict(name="loopback1", description="test-loopback"), - ] + ], ) merged = [ # Update existing device states with any differences in the playbook. @@ -266,7 +266,7 @@ def test_2(self): ! no system default switchport no system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -287,7 +287,7 @@ def test_2(self): interface port-channel2 interface port-channel3 shutdown - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -307,7 +307,7 @@ def test_2(self): dict(name="loopback4", enabled=True), dict(name="port-channel4", enabled=True), dict(name="Ethernet1/4.101"), - ] + ], ) # Testing with newer code version merged = [ @@ -408,7 +408,7 @@ def test_3(self): ! system default switchport system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -429,7 +429,7 @@ def test_3(self): interface port-channel2 interface port-channel3 shutdown - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -450,7 +450,7 @@ def test_3(self): dict(name="loopback4", enabled=True), dict(name="port-channel4", enabled=True), dict(name="Ethernet1/4.101"), - ] + ], ) merged = [ "interface Ethernet1/1", @@ -553,7 +553,7 @@ def test_3(self): dict(name="port-channel4", enabled=True), dict(name="Ethernet1/4.101", enabled=False), dict(name="Ethernet1/4.102", enabled=True), - ] + ], ) overridden = [ @@ -594,7 +594,7 @@ def test_4(self): ! no system default switchport no system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -603,7 +603,7 @@ def test_4(self): switchport speed 1000 shutdown - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -612,7 +612,7 @@ def test_4(self): config=[ dict(name="Ethernet1/1", mode="layer3"), dict(name="Ethernet1/2", mode="layer2", enabled=False), - ] + ], ) merged = [] playbook["state"] = "merged" @@ -628,7 +628,7 @@ def test_5(self): ! no system default switchport no system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -637,7 +637,7 @@ def test_5(self): interface Ethernet1/2 speed 1000 no shutdown - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -663,7 +663,7 @@ def test_6_gathered(self): ! no system default switchport no system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -677,7 +677,7 @@ def test_6_gathered(self): speed 1000 no shutdown interface loopback1 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -705,7 +705,7 @@ def test_7_purged(self): """\ no system default switchport no system default switchport shutdown - """ + """, ) intf = dedent( """\ @@ -718,7 +718,7 @@ def test_7_purged(self): interface Ethernet1/2 interface Ethernet1/2.100 description sub-intf - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} self.get_system_defaults.return_value = sysdefs @@ -728,7 +728,7 @@ def test_7_purged(self): dict(name="Vlan42"), dict(name="port-channel10"), dict(name="Ethernet1/2.100"), - ] + ], ) playbook["state"] = "purged" diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interface.py b/tests/unit/modules/network/nxos/test_nxos_l3_interface.py index 0eb43dd3c..30dcfe1cb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interface.py @@ -22,12 +22,12 @@ def setUp(self): super(TestNxosL3InterfaceModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_l3_interface.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_l3_interface.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_l3_interface.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_l3_interface.get_config", ) self.get_config = self.mock_get_config.start() @@ -80,7 +80,7 @@ def test_nxos_l3_interface_add_missing_ipv4_and_ipv6(self): name="Ethernet1/1", ipv4="192.168.0.1/24", ipv6="2001:db8::1/124", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -116,7 +116,7 @@ def test_nxos_l3_interface_add_existing_ipv4_and_ipv6(self): name="Ethernet1/1", ipv4="192.168.0.1/24", ipv6="2001:db8::1/124", - ) + ), ) result = self.execute_module() @@ -127,7 +127,7 @@ def test_nxos_l3_interface_new_ipv4_and_ipv6(self): name="Ethernet1/1", ipv4="192.168.0.2/24", ipv6="2001:db8::2/124", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -169,8 +169,8 @@ def test_nxos_l3_interface_add_missing_with_aggregate(self): ), dict(name="Ethernet1/1", ipv6="2001:db8:1::2/124"), dict(name="Ethernet1/1", ipv6="2001:db8:2::2/124"), - ] - ) + ], + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -213,7 +213,7 @@ def test_nxos_l3_interface_rem_missing_ipv4_and_ipv6(self): ipv4="192.168.0.1/24", ipv6="2001:db8::1/124", state="absent", - ) + ), ) result = self.execute_module() @@ -257,7 +257,7 @@ def test_nxos_l3_interface_rem_existing_ipv4_and_ipv6(self): ipv4="192.168.0.1/24", ipv6="2001:db8::1/124", state="absent", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -317,7 +317,7 @@ def test_nxos_l3_interface_rem_missing_with_aggregate(self): dict(name="Ethernet1/1", ipv6="2001:db8:1::2/124"), dict(name="Ethernet1/1", ipv6="2001:db8:2::2/124"), ], - ) + ), ) result = self.execute_module() @@ -336,7 +336,7 @@ def test_nxos_l3_interface_rem_existing_with_aggregate(self): dict(name="Ethernet1/1", ipv6="2001:db8:1::1/124"), dict(name="Ethernet1/1", ipv6="2001:db8:2::1/124"), ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py index 8dc0f91e1..a7c1e81cd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py @@ -45,22 +45,22 @@ def setUp(self): super(TestNxosL3InterfacesModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.l3_interfaces.l3_interfaces.L3_interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.l3_interfaces.l3_interfaces.L3_interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() @@ -106,7 +106,7 @@ def test_2(self): ip address 10.1.2.1/24 interface Ethernet1/3 ip address 10.1.3.1/24 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -116,7 +116,7 @@ def test_2(self): dict(name="Ethernet1/2"), # Eth1/3 not present! Thus overridden should set Eth1/3 to defaults; # replaced should ignore Eth1/3. - ] + ], ) # Expected result commands for each 'state' merged = ["interface Ethernet1/1", "ip address 192.168.1.1/24"] @@ -176,7 +176,7 @@ def test_3(self): encapsulation dot1q 45 ip address 10.5.5.5/24 ipv6 address 10::5/128 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -194,7 +194,7 @@ def test_3(self): ipv6=[{"address": "10::2/128"}], ), dict(name="Ethernet1/1.44"), - ] + ], ) # Expected result commands for each 'state' merged = [ @@ -281,7 +281,7 @@ def test_4(self): no ip redirects ip address 10.15.15.15/24 ip address 10.25.25.25/24 secondary - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -325,7 +325,7 @@ def test_4(self): ], ), dict(name="Ethernet1/5"), - ] + ], ) # Expected result commands for each 'state' merged = [ @@ -421,7 +421,7 @@ def test_5(self): ipv6 address 10::12/128 interface Ethernet1/3 ipv6 address 10::13/128 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -437,7 +437,7 @@ def test_5(self): ], ), # new addr+tag dict(name="Ethernet1/2"), - ] + ], ) # Expected result commands for each 'state' merged = [ @@ -506,7 +506,7 @@ def test_6(self): interface Ethernet1/4 interface Ethernet1/5 no ip redirects - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -520,7 +520,7 @@ def test_6(self): dict(name="Ethernet1/2"), dict(name="Ethernet1/3", redirects=True, unreachables=False), # defaults dict(name="Ethernet1/4", redirects=False, unreachables=True), - ] + ], ) merged = [ "interface Ethernet1/1", @@ -588,7 +588,7 @@ def test_7(self): no ip redirects ip unreachables interface Ethernet1/2 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -617,7 +617,7 @@ def test_7(self): ], ), dict(name="Ethernet1/2"), - ] + ], ) playbook["state"] = "merged" set_module_args(playbook, ignore_provider_arg) @@ -636,7 +636,7 @@ def test_7(self): """\ interface Ethernet1/1 interface Ethernet1/2 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook["state"] = "deleted" @@ -649,7 +649,7 @@ def test_8(self): """\ interface Ethernet1/1 ip address 10.1.1.1/24 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict() @@ -675,7 +675,7 @@ def test_9(self): no ip redirects ip address 10.15.15.15/24 ip address 10.25.25.25/24 secondary - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(config=[dict(name="Ethernet1/3"), dict(name="Ethernet1/5")]) @@ -733,7 +733,7 @@ def test_10(self): interface Ethernet1/3 ip address 10.1.3.1/24 evpn multisite dci-tracking - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -743,7 +743,7 @@ def test_10(self): dict(name="Ethernet1/2"), # Eth1/3 not present! Thus overridden should set Eth1/3 to defaults; # replaced should ignore Eth1/3. - ] + ], ) # Expected result commands for each 'state' merged = ["interface Ethernet1/1", "ip address 192.168.1.1/24"] @@ -813,7 +813,7 @@ def test_11(self): ip address 10.15.15.15/24 ip address 10.25.25.25/24 secondary evpn multisite fabric-tracking - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -858,7 +858,7 @@ def test_11(self): evpn_multisite_tracking="dci-tracking", ), dict(name="Ethernet1/5"), - ] + ], ) # Expected result commands for each 'state' merged = [ @@ -956,7 +956,7 @@ def test_12(self): interface Vlan99 no shutdown ip address 192.168.1.1/24 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -964,7 +964,7 @@ def test_12(self): dict( name="Vlan99", ipv4=[{"address": "192.168.1.1/24", "tag": 500}], # adding a tag - ) + ), ], state="replaced", ) @@ -985,7 +985,7 @@ def test_12_gathered(self): interface Ethernet1/2 ip address 192.168.2.1/24 interface loopback1 - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict(state="gathered") diff --git a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py index 256dd6640..ed7f41738 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py @@ -41,22 +41,22 @@ def setUp(self): super(TestNxosLacpInterfacesModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.l3_interfaces.l3_interfaces.L3_interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.l3_interfaces.l3_interfaces.L3_interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() @@ -83,7 +83,7 @@ def test_lacp_mode_parse(self): switchport trunk native vlan 5 switchport trunk allowed vlan 10 no lacp graceful-convergence - """ + """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} playbook = dict( @@ -93,8 +93,8 @@ def test_lacp_mode_parse(self): convergence={"graceful": False}, suspend_individual=True, mode="delay", - ) - ] + ), + ], ) # Expected result commands for each 'state' merged = [ diff --git a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py index 9d69e02e6..2632d21bf 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py @@ -23,32 +23,32 @@ def setUp(self): super(TestNxosLldpInterfacesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "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" + "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" + "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" + "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.lldp_interfaces.lldp_interfaces.Lldp_interfaces.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.lldp_interfaces.lldp_interfaces.Lldp_interfaces.edit_config", ) self.edit_config = self.mock_edit_config.start() self.mock_execute_show_command = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lldp_interfaces.lldp_interfaces.Lldp_interfacesFacts.get_device_data" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.lldp_interfaces.lldp_interfaces.Lldp_interfacesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -81,10 +81,10 @@ def test_nxos_lldp_interfaces_merged(self): name="Ethernet1/3", receive=False, tlv_set=dict(vlan=123), - ) + ), ], state="merged", - ) + ), ) commands = [ "interface Ethernet1/3", @@ -105,7 +105,7 @@ def test_nxos_lldp_interfaces_merged_idempotent(self): dict(name="Ethernet1/1", receive=True, transmit=False), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -118,10 +118,10 @@ def test_nxos_lldp_interfaces_replaced(self): receive=True, transmit=False, tlv_set=dict(management_address="192.0.2.123"), - ) + ), ], state="replaced", - ) + ), ) commands = [ "interface Ethernet1/2", @@ -144,7 +144,7 @@ def test_nxos_lldp_interfaces_replaced_idempotent(self): dict(name="Ethernet1/1", receive=True, transmit=False), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -153,7 +153,7 @@ def test_nxos_lldp_interfaces_overridden(self): dict( config=[dict(name="Ethernet1/4", receive=True, transmit=False)], state="overridden", - ) + ), ) commands = [ "interface Ethernet1/4", @@ -180,7 +180,7 @@ def test_nxos_lldp_interfaces_overridden_idempotent(self): dict(name="Ethernet1/1", receive=True, transmit=False), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -217,7 +217,7 @@ def test_nxos_lldp_interfaces_rendered(self): dict(name="Ethernet1/1", receive=True, transmit=False), ], state="rendered", - ) + ), ) commands = [ "interface Ethernet1/1", @@ -240,7 +240,7 @@ def test_nxos_lldp_interfaces_parsed(self): no lldp receive lldp tlv-set vlan 12""", state="parsed", - ) + ), ) result = self.execute_module(changed=False) compare_list = [ diff --git a/tests/unit/modules/network/nxos/test_nxos_logging_global.py b/tests/unit/modules/network/nxos/test_nxos_logging_global.py index 357b87aeb..48723fa93 100644 --- a/tests/unit/modules/network/nxos/test_nxos_logging_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_logging_global.py @@ -44,12 +44,12 @@ def setUp(self): super(TestNxosLoggingGlobalModule, 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" + "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.logging_global.logging_global.Logging_globalFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.logging_global.logging_global.Logging_globalFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -62,7 +62,7 @@ def test_nxos_logging_global_linear_merged(self): # test merged for linear attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -104,7 +104,7 @@ def test_nxos_logging_global_linear_merged_idempotent(self): no logging rate-limit logging rfc-strict 5424 logging origin-id string nodeA - """ + """, ) set_module_args( dict( @@ -134,7 +134,7 @@ def test_nxos_logging_global_linear_merged_2(self): logging history 6 logging history size 4096 no logging rate-limit - """ + """, ) set_module_args( dict( @@ -170,7 +170,7 @@ def test_nxos_logging_global_linear_replaced(self): no logging rate-limit logging rfc-strict 5424 logging origin-id string nodeA - """ + """, ) set_module_args( dict( @@ -205,7 +205,7 @@ def test_nxos_logging_global_linear_replaced(self): logging history size 4096 no logging rate-limit logging rfc-strict 5424 - """ + """, ) set_module_args( dict( @@ -232,7 +232,7 @@ def test_nxos_logging_global_linear_merged_3(self): # test merged for linear attributes - 3 self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -243,7 +243,7 @@ def test_nxos_logging_global_linear_merged_3(self): cache=dict(entries=16384, interval=200, threshold=80), detailed=True, include=dict(sgt=True), - ) + ), ), source_interface="Ethernet1/100", timestamp="milliseconds", @@ -277,7 +277,7 @@ def test_nxos_logging_global_linear_merged_3_idempotent(self): logging ip access-list include sgt logging source-interface Ethernet1/100 logging timestamp milliseconds - """ + """, ) set_module_args( dict( @@ -288,7 +288,7 @@ def test_nxos_logging_global_linear_merged_3_idempotent(self): cache=dict(entries=16384, interval=200, threshold=80), detailed=True, include=dict(sgt=True), - ) + ), ), source_interface="Ethernet1/100", timestamp="milliseconds", @@ -312,7 +312,7 @@ def test_nxos_logging_global_linear_replaced_3(self): logging ip access-list include sgt logging source-interface Ethernet1/100 logging timestamp milliseconds - """ + """, ) set_module_args( dict( @@ -342,7 +342,7 @@ def test_nxos_logging_global_complex_merged(self): # test merged for complex attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -383,7 +383,7 @@ def test_nxos_logging_global_complex_merged_idempotent(self): logging level ospfv3 2 logging level auth 1 logging level vlan_mgr 5 - """ + """, ) set_module_args( dict( @@ -416,7 +416,7 @@ def test_nxos_logging_global_complex_replaced(self): logging level cron 5 logging level ospfv3 2 logging level auth 1 - """ + """, ) set_module_args( dict( @@ -425,7 +425,7 @@ def test_nxos_logging_global_complex_replaced(self): dict(facility="auth", severity="alert"), dict(facility="ospfv3", severity="critical"), dict(facility="ospf", severity="notification"), - ] + ], ), state="replaced", ), @@ -445,7 +445,7 @@ def test_nxos_logging_global_event_merged(self): # test merged for `event` self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -453,7 +453,7 @@ def test_nxos_logging_global_event_merged(self): event=dict( link_status=dict(enable=False, default=False), trunk_status=dict(enable=False, default=True), - ) + ), ), state="merged", ), @@ -476,7 +476,7 @@ def test_nxos_logging_global_event_merged(self): no logging event link-status default no logging event trunk-status enable logging event trunk-status default - """ + """, ) set_module_args( dict( @@ -484,7 +484,7 @@ def test_nxos_logging_global_event_merged(self): event=dict( link_status=dict(enable=False, default=False), trunk_status=dict(enable=False, default=True), - ) + ), ), state="merged", ), @@ -501,7 +501,7 @@ def test_nxos_logging_global_event_replaced(self): no logging event link-status default no logging event trunk-status enable logging event trunk-status default - """ + """, ) set_module_args( dict( @@ -509,7 +509,7 @@ def test_nxos_logging_global_event_replaced(self): event=dict( link_status=dict(default=False), trunk_status=dict(enable=False), - ) + ), ), state="replaced", ), @@ -541,7 +541,7 @@ def test_nxos_logging_global_gathered(self): no logging rate-limit logging rfc-strict 5424 logging origin-id string nodeA - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = { @@ -569,7 +569,7 @@ def test_nxos_logging_global_parsed(self): no logging rate-limit logging rfc-strict 5424 logging origin-id string nodeA - """ + """, ) set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = { @@ -588,7 +588,7 @@ def test_nxos_logging_global_hosts_merged(self): # test merged for `hosts` self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -604,7 +604,7 @@ def test_nxos_logging_global_hosts_merged(self): ), dict(host="192.168.1.2"), dict(host="192.168.1.3", severity="critical"), - ] + ], ), state="merged", ), @@ -625,7 +625,7 @@ def test_nxos_logging_global_hosts_replaced(self): logging server 192.168.1.1 1 port 5891 secure trustpoint client-identity test facility auth use-vrf default logging server 192.168.1.2 logging server 192.168.1.3 2 - """ + """, ) set_module_args( dict( @@ -644,7 +644,7 @@ def test_nxos_logging_global_hosts_replaced(self): severity="debugging", use_vrf="management", ), - ] + ], ), state="replaced", ), @@ -666,7 +666,7 @@ def test_nxos_logging_global_linear_negated_merged(self): no logging console no logging module no logging monitor - """ + """, ) set_module_args( dict( @@ -695,7 +695,7 @@ def test_nxos_logging_global_deleted(self): no logging rate-limit logging rfc-strict 5424 logging origin-id string nodeA - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -719,7 +719,7 @@ def test_nxos_logging_global_event_replaced_2(self): no logging event link-status default no logging event trunk-status enable logging event trunk-status default - """ + """, ) set_module_args( dict( @@ -743,7 +743,7 @@ def test_nxos_logging_global_event_replaced_2(self): no logging event link-status default no logging event trunk-status enable logging event trunk-status default - """ + """, ) set_module_args( dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py index 5ed7ba237..99224383a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py @@ -42,12 +42,12 @@ def setUp(self): super(TestNxosNtpGlobalModule, 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" + "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.ntp_global.ntp_global.Ntp_globalFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -60,7 +60,7 @@ def test_nxos_ntp_global_linear_merged(self): # test merged for linear attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -118,7 +118,7 @@ def test_nxos_ntp_global_linear_merged_idempotent(self): ntp access-group serve-only ServeOnlyAcl2 ntp allow control rate-limit 400 ntp allow private - """ + """, ) set_module_args( dict( @@ -164,7 +164,7 @@ def test_nxos_ntp_global_linear_replaced_idempotent(self): ntp access-group serve-only ServeOnlyAcl2 ntp allow control rate-limit 400 ntp allow private - """ + """, ) set_module_args( dict( @@ -202,7 +202,7 @@ def test_nxos_ntp_global_complex_merged(self): # test merged for complex attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -247,7 +247,7 @@ def test_nxos_ntp_global_complex_merged_idempotent(self): ntp master 2 ntp passive ntp source 192.168.1.1 - """ + """, ) set_module_args( dict( @@ -282,7 +282,7 @@ def test_nxos_ntp_global_complex_merged_idempotent(self): ntp master 2 ntp passive ntp source 192.168.1.1 - """ + """, ) set_module_args( dict( @@ -313,7 +313,7 @@ def test_nxos_ntp_global_complex_2_merged(self): # test merged for complex attributes - 2 self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -368,7 +368,7 @@ def test_nxos_ntp_global_complex_2_merged_idempotent(self): ntp server 203.0.113.1 prefer use-vrf siteA key 2 minpoll 5 maxpoll 15 ntp server 203.0.113.2 use-vrf siteB key 3 ntp server 203.0.113.3 use-vrf default maxpoll 10 - """ + """, ) set_module_args( dict( @@ -415,7 +415,7 @@ def test_nxos_ntp_global_complex_2_replaced(self): ntp server 203.0.113.1 prefer use-vrf siteA key 2 minpoll 5 maxpoll 15 ntp server 203.0.113.2 use-vrf siteB key 3 ntp server 203.0.113.3 use-vrf default maxpoll 10 - """ + """, ) set_module_args( dict( @@ -439,7 +439,7 @@ def test_nxos_ntp_global_complex_2_replaced(self): maxpoll=15, vrf="siteA", prefer=True, - ) + ), ], ), state="replaced", @@ -460,7 +460,7 @@ def test_nxos_ntp_global_complex_3_merged(self): # test merged for complex attributes - 3 self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -493,7 +493,7 @@ def test_nxos_ntp_global_complex_3_merged_idempotent(self): ntp trusted-key 1002 ntp trusted-key 1003 ntp source-interface Ethernet1/1 - """ + """, ) set_module_args( dict( @@ -520,7 +520,7 @@ def test_nxos_ntp_global_source_interface_merged_idempotent(self): ntp trusted-key 1002 ntp trusted-key 1003 ntp source-interface Ethernet1/1 - """ + """, ) set_module_args( dict(config=dict(source_interface="Ethernet1/1"), state="merged"), @@ -537,7 +537,7 @@ def test_nxos_ntp_global_complex_3_replaced(self): ntp trusted-key 1002 ntp trusted-key 1003 ntp source-interface 192.168.1.100 - """ + """, ) set_module_args( dict( @@ -573,7 +573,7 @@ def test_nxos_ntp_global_gathered(self): ntp trusted-key 1002 ntp trusted-key 1003 ntp source-interface 192.168.1.100 - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = { @@ -594,7 +594,7 @@ def test_nxos_ntp_global_parsed(self): ntp trusted-key 1002 ntp trusted-key 1003 ntp source-interface 192.168.1.100 - """ + """, ) set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = { @@ -621,7 +621,7 @@ def test_nxos_ntp_global_linear_deleted(self): ntp access-group serve-only ServeOnlyAcl2 ntp allow control rate-limit 400 ntp allow private - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -642,7 +642,7 @@ def test_nxos_ntp_global_linear_deleted(self): def test_nxos_ntp_global_alias(self): self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -688,7 +688,7 @@ def test_nxos_ntp_global_alias_idempotent(self): ntp server 1.1.1.3 use-vrf v200 ntp peer 192.168.1.1 use-vrf default ntp peer 192.168.1.2 use-vrf v200 - """ + """, ) set_module_args( dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_nxapi.py b/tests/unit/modules/network/nxos/test_nxos_nxapi.py index 2acffa3e6..4690658e0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_nxapi.py +++ b/tests/unit/modules/network/nxos/test_nxos_nxapi.py @@ -36,17 +36,17 @@ def setUp(self): super(TestNxosNxapiModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_nxapi.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_nxapi.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_nxapi.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_nxapi.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_nxapi.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_nxapi.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = { @@ -85,7 +85,7 @@ def test_nxos_nxapi_no_change(self): http_port=80, https_port=443, sandbox=False, - ) + ), ) self.execute_module_devices(changed=False, commands=[]) @@ -96,5 +96,6 @@ def test_nxos_nxapi_disable(self): def test_nxos_nxapi_no_http(self): set_module_args(dict(https=True, http=False, https_port=8443)) self.execute_module_devices( - changed=True, commands=["no nxapi http", "nxapi https port 8443"] + changed=True, + commands=["no nxapi http", "nxapi https port 8443"], ) diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf.py b/tests/unit/modules/network/nxos/test_nxos_ospf.py index 69b50edaa..c1fce6527 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosOspfModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf.get_config", ) self.get_config = self.mock_get_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py index 2611688ee..a6795aa41 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py @@ -50,12 +50,12 @@ def setUp(self): super(TestNxosOspfInterfacesModule, 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" + "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.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -79,7 +79,7 @@ def test_nxos_ospf_interfaces_af_process_area_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -93,7 +93,7 @@ def test_nxos_ospf_interfaces_af_process_area_merged(self): dict( process_id="102", area=dict(area_id="1.1.1.2"), - ) + ), ], ), dict( @@ -102,7 +102,7 @@ def test_nxos_ospf_interfaces_af_process_area_merged(self): dict( process_id="200", area=dict(area_id="2.2.2.8"), - ) + ), ], ), ], @@ -116,9 +116,9 @@ def test_nxos_ospf_interfaces_af_process_area_merged(self): dict( process_id="101", area=dict(area_id="2.2.2.3"), - ) + ), ], - ) + ), ], ), dict( @@ -133,9 +133,9 @@ def test_nxos_ospf_interfaces_af_process_area_merged(self): area_id="2.2.2.3", secondaries="False", ), - ) + ), ], - ) + ), ], ), ], @@ -170,7 +170,7 @@ def test_nxos_ospf_interfaces_af_process_area_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -184,9 +184,9 @@ def test_nxos_ospf_interfaces_af_process_area_replaced(self): dict( process_id="200", area=dict(area_id="2.2.2.8"), - ) + ), ], - ) + ), ], ), dict( @@ -198,9 +198,9 @@ def test_nxos_ospf_interfaces_af_process_area_replaced(self): dict( process_id="102", area=dict(area_id="1.1.1.2"), - ) + ), ], - ) + ), ], ), ], @@ -237,7 +237,7 @@ def test_nxos_ospf_interfaces_af_process_multiareas_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -257,7 +257,7 @@ def test_nxos_ospf_interfaces_af_process_multiareas_merged(self): multi_areas=["3.3.3.3", "4.4.4.4"], ), ], - ) + ), ], ), dict( @@ -269,9 +269,9 @@ def test_nxos_ospf_interfaces_af_process_multiareas_merged(self): dict( process_id="109", multi_areas=["5.5.5.5", "5.5.5.6"], - ) + ), ], - ) + ), ], ), ], @@ -311,7 +311,7 @@ def test_nxos_ospf_interfaces_af_process_multiareas_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -335,7 +335,7 @@ def test_nxos_ospf_interfaces_af_process_multiareas_replaced(self): multi_areas=["3.3.3.3", "4.4.4.4"], ), ], - ) + ), ], ), dict( @@ -347,9 +347,9 @@ def test_nxos_ospf_interfaces_af_process_multiareas_replaced(self): dict( process_id="109", multi_areas=["5.5.5.6"], - ) + ), ], - ) + ), ], ), ], @@ -391,7 +391,7 @@ def test_nxos_ospf_interfaces_af_multiareas_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -440,7 +440,7 @@ def test_nxos_ospf_interfaces_af_multiareas_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -487,7 +487,7 @@ def test_nxos_ospf_interfaces_authentication_merged(self): interface Ethernet1/4 no switchport ip ospf authentication - """ + """, ) set_module_args( dict( @@ -498,7 +498,7 @@ def test_nxos_ospf_interfaces_authentication_merged(self): dict( afi="ipv4", authentication=dict(key_chain="test-1", message_digest=True), - ) + ), ], ), dict( @@ -547,7 +547,7 @@ def test_nxos_ospf_interfaces_authentication_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -592,7 +592,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -603,7 +603,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): dict( afi="ipv4", authentication_key=dict(encryption=3, key="77840f9d4d882176"), - ) + ), ], ), dict( @@ -612,7 +612,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): dict( afi="ipv4", authentication_key=dict(encryption=0, key="password"), - ) + ), ], ), dict( @@ -621,7 +621,7 @@ def test_nxos_ospf_interfaces_authentication_key_merged(self): dict( afi="ipv4", authentication_key=dict(encryption=7, key="712090404011C031628"), - ) + ), ], ), ], @@ -655,7 +655,7 @@ def test_nxos_ospf_interfaces_authentication_key_replaced(self): ip ospf authentication-key 7 712090404011C031628 interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -667,7 +667,7 @@ def test_nxos_ospf_interfaces_authentication_key_replaced(self): dict( afi="ipv4", authentication_key=dict(encryption=0, key="password"), - ) + ), ], ), ], @@ -698,7 +698,7 @@ def test_nxos_ospf_interfaces_message_digest_key_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -713,7 +713,7 @@ def test_nxos_ospf_interfaces_message_digest_key_merged(self): encryption=3, key="abc01d272be25d29", ), - ) + ), ], ), dict( @@ -722,7 +722,7 @@ def test_nxos_ospf_interfaces_message_digest_key_merged(self): dict( afi="ipv4", message_digest_key=dict(key_id=1, encryption=0, key="password"), - ) + ), ], ), dict( @@ -735,7 +735,7 @@ def test_nxos_ospf_interfaces_message_digest_key_merged(self): encryption=7, key="712090404011C031628", ), - ) + ), ], ), ], @@ -769,7 +769,7 @@ def test_nxos_ospf_interfaces_message_digest_key_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -781,7 +781,7 @@ def test_nxos_ospf_interfaces_message_digest_key_replaced(self): dict( afi="ipv4", message_digest_key=dict(key_id=1, encryption=0, key="password1"), - ) + ), ], ), ], @@ -818,7 +818,7 @@ def test_nxos_ospf_interfaces_linear_args_1_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -886,7 +886,7 @@ def test_nxos_ospf_interfaces_linear_args_1_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -937,7 +937,7 @@ def test_nxos_ospf_interfaces_linear_args_2_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -995,7 +995,7 @@ def test_nxos_ospf_interfaces_linear_args_2_replaced(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -1047,7 +1047,7 @@ def test_nxos_ospf_interfaces_linear_args_3_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -1070,7 +1070,7 @@ def test_nxos_ospf_interfaces_linear_args_3_merged(self): afi="ipv4", passive_interface=True, retransmit_interval=5000, - ) + ), ], ), dict( @@ -1125,7 +1125,7 @@ def test_nxos_ospf_interfaces_linear_args_3_replaced(self): ospfv3 retransmit-interval 5100 interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -1174,7 +1174,7 @@ def test_nxos_ospf_interfaces_linear_args_4_merged(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -1240,7 +1240,7 @@ def test_nxos_ospf_interfaces_linear_args_4_replaced(self): ip ospf transmit-delay 430 interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -1284,7 +1284,7 @@ def test_nxos_ospf_interfaces_parsed(self): no switchport interface Ethernet1/4 no switchport - """ + """, ), state="parsed", ), @@ -1303,7 +1303,7 @@ def test_nxos_ospf_interfaces_parsed(self): "area_id": "1.1.1.2", "secondaries": False, }, - } + }, ], }, { @@ -1312,7 +1312,7 @@ def test_nxos_ospf_interfaces_parsed(self): { "process_id": "200", "area": {"area_id": "2.2.2.8"}, - } + }, ], }, ], @@ -1323,7 +1323,7 @@ def test_nxos_ospf_interfaces_parsed(self): { "afi": "ipv6", "processes": [{"process_id": "210", "multi_areas": ["3.3.3.3"]}], - } + }, ], }, {"name": "Ethernet1/3"}, @@ -1347,7 +1347,7 @@ def test_nxos_ospf_interfaces_gathered(self): no switchport interface Ethernet1/4 no switchport - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = [ @@ -1363,7 +1363,7 @@ def test_nxos_ospf_interfaces_gathered(self): "area_id": "1.1.1.2", "secondaries": False, }, - } + }, ], }, { @@ -1372,7 +1372,7 @@ def test_nxos_ospf_interfaces_gathered(self): { "process_id": "200", "area": {"area_id": "2.2.2.8"}, - } + }, ], }, ], @@ -1383,7 +1383,7 @@ def test_nxos_ospf_interfaces_gathered(self): { "afi": "ipv6", "processes": [{"process_id": "210", "multi_areas": ["3.3.3.3"]}], - } + }, ], }, {"name": "Ethernet1/3"}, @@ -1396,7 +1396,7 @@ def test_nxos_ospf_interfaces_sanity(self): # test gathered self.get_config.return_value = dedent( """ - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = [] @@ -1420,7 +1420,7 @@ def test_nxos_ospf_interfaces_overridden(self): ip ospf message-digest-key 101 md5 3 109a86e9d947cc5d interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( @@ -1431,7 +1431,7 @@ def test_nxos_ospf_interfaces_overridden(self): dict(afi="ipv4", shutdown=False, transmit_delay=300), dict(afi="ipv6", shutdown=True), ], - ) + ), ], state="overridden", ), @@ -1469,7 +1469,7 @@ def test_nxos_ospf_interfaces_deleted(self): ip ospf message-digest-key 101 md5 3 109a86e9d947cc5d interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict(config=[dict(name="Ethernet1/1")], state="deleted"), @@ -1500,7 +1500,7 @@ def test_nxos_ospf_interfaces_deleted_all(self): ip ospf message-digest-key 101 md5 3 109a86e9d947cc5d interface Ethernet1/4 no switchport - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -1530,7 +1530,7 @@ def test_nxos_ospf_interfaces_passive_intf(self): no ospfv3 passive-interface interface Ethernet1/4 no switchport - """ + """, ) set_module_args( dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py b/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py index 5a2b7228f..49989cd32 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosOspfVrfModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf_vrf.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf_vrf.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf_vrf.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf_vrf.get_config", ) self.get_config = self.mock_get_config.start() @@ -66,7 +66,7 @@ def test_nxos_ospf_vrf_present(self): timer_throttle_lsa_max=3000, bfd="enable", state="present", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -78,7 +78,7 @@ def test_nxos_ospf_vrf_present(self): "timers throttle lsa 60 1100 3000", "timers throttle spf 50 1000 2000", "bfd", - ] + ], ), ) diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py index b7f96d2a0..30334f454 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py @@ -42,12 +42,12 @@ def setUp(self): super(TestNxosOspfv2Module, 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" + "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.ospfv2.ospfv2.Ospfv2Facts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospfv2.ospfv2.Ospfv2Facts.get_config", ) self.get_config = self.mock_get_config.start() @@ -98,7 +98,7 @@ def test_nxos_ospfv2_merged(self): ), ], ), - ] + ], ), state="merged", ), @@ -135,7 +135,7 @@ def test_nxos_ospfv2_merged_idempotent(self): area 0.0.0.100 range 198.51.100.64/27 area 0.0.0.100 range 198.51.100.96/27 area 0.0.0.101 authentication message-digest - """ + """, ) set_module_args( dict( @@ -177,7 +177,7 @@ def test_nxos_ospfv2_merged_idempotent(self): ), ], ), - ] + ], ), state="merged", ), @@ -200,7 +200,7 @@ def test_nxos_ospfv2_merged_update(self): area 0.0.0.100 range 198.51.100.64/27 area 0.0.0.100 range 198.51.100.96/27 area 0.0.0.101 authentication message-digest - """ + """, ) set_module_args( dict( @@ -214,16 +214,16 @@ def test_nxos_ospfv2_merged_update(self): protocol="eigrp", id="100", route_map="rmap_2", - ) + ), ], areas=[ dict( area_id="0.0.0.101", stub=dict(no_summary=True), - ) + ), ], - ) - ] + ), + ], ), state="merged", ), @@ -253,7 +253,7 @@ def test_nxos_ospfv2_replaced(self): area 0.0.0.100 range 198.51.100.64/27 area 0.0.0.100 range 198.51.100.96/27 area 0.0.0.101 authentication message-digest - """ + """, ) set_module_args( dict( @@ -266,10 +266,10 @@ def test_nxos_ospfv2_replaced(self): dict( area_id="0.0.0.101", stub=dict(no_summary=True), - ) + ), ], - ) - ] + ), + ], ), state="replaced", ), @@ -298,7 +298,7 @@ def test_nxos_ospfv2_replaced_idempotent(self): area 0.0.0.100 range 198.51.100.64/27 area 0.0.0.100 range 198.51.100.96/27 area 0.0.0.101 authentication message-digest - """ + """, ) set_module_args( dict( @@ -340,7 +340,7 @@ def test_nxos_ospfv2_replaced_idempotent(self): ), ], ), - ] + ], ), state="replaced", ), @@ -363,7 +363,7 @@ def test_nxos_ospfv2_overridden(self): area 0.0.0.100 range 198.51.100.64/27 area 0.0.0.100 range 198.51.100.96/27 area 0.0.0.101 authentication message-digest - """ + """, ) set_module_args( dict( @@ -395,7 +395,7 @@ def test_nxos_ospfv2_overridden_idempotent(self): area 0.0.0.100 range 198.51.100.64/27 area 0.0.0.100 range 198.51.100.96/27 area 0.0.0.101 authentication message-digest - """ + """, ) set_module_args( dict( @@ -437,7 +437,7 @@ def test_nxos_ospfv2_overridden_idempotent(self): ), ], ), - ] + ], ), state="overridden", ), @@ -462,7 +462,7 @@ def test_nxos_ospfv2_deleted(self): area 0.0.0.101 authentication message-digest router ospf 300 router-id 192.0.168.102 - """ + """, ) set_module_args( dict( @@ -492,7 +492,7 @@ def test_nxos_ospfv2_deleted_idempotent(self): area 0.0.0.101 authentication message-digest router ospf 300 router-id 192.0.168.102 - """ + """, ) set_module_args( dict( @@ -521,7 +521,7 @@ def test_nxos_ospfv2_deleted_all(self): area 0.0.0.101 authentication message-digest router ospf 300 router-id 192.0.168.102 - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) @@ -541,7 +541,7 @@ def test_nxos_ospfv2_process_id_word(self): router-id 203.0.113.20 router ospf TEST-1 router-id 198.51.100.1 - """ + """, ) set_module_args( dict( @@ -550,7 +550,7 @@ def test_nxos_ospfv2_process_id_word(self): dict(process_id="100", router_id="203.0.113.20"), dict(process_id="TEST-1", router_id="198.51.100.1"), dict(process_id="TEST-2", router_id="198.52.200.1"), - ] + ], ), state="merged", ), diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py index 1365f1d2b..bf7980997 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py @@ -53,12 +53,12 @@ def setUp(self): super(TestNxosOspfv3Module, 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" + "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.ospfv3.ospfv3.Ospfv3Facts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.ospfv3.ospfv3.Ospfv3Facts.get_config", ) self.get_config = self.mock_get_config.start() @@ -75,7 +75,7 @@ def test_nxos_ospfv3_af_areas_filter_list_merged(self): address-family ipv6 unicast area 1.1.1.1 default-cost 100 area 1.1.1.1 filter-list route-map test-11 in - """ + """, ) set_module_args( dict( @@ -115,8 +115,8 @@ def test_nxos_ospfv3_af_areas_filter_list_merged(self): ), ], ), - ) - ] + ), + ], ), state="merged", ), @@ -141,7 +141,7 @@ def test_nxos_ospfv3_af_areas_filter_list_replaced(self): address-family ipv6 unicast area 1.1.1.4 filter-list route-map test-11 out area 1.1.1.4 filter-list route-map test-12 in - """ + """, ) set_module_args( dict( @@ -181,8 +181,8 @@ def test_nxos_ospfv3_af_areas_filter_list_replaced(self): ), ], ), - ) - ] + ), + ], ), state="replaced", ), @@ -209,7 +209,7 @@ def test_nxos_ospfv3_af_areas_ranges_merged(self): address-family ipv6 unicast area 1.1.1.1 range 2001:db2::/32 area 1.1.1.1 range 2001:db3::/32 cost 10 - """ + """, ) set_module_args( dict( @@ -227,7 +227,7 @@ def test_nxos_ospfv3_af_areas_ranges_merged(self): dict( prefix="2001:db3::/32", cost="20", - ) + ), ], ), dict( @@ -247,8 +247,8 @@ def test_nxos_ospfv3_af_areas_ranges_merged(self): ), ], ), - ) - ] + ), + ], ), state="merged", ), @@ -273,7 +273,7 @@ def test_nxos_ospfv3_af_areas_ranges_replaced(self): address-family ipv6 unicast area 1.1.1.1 range 2001:db2::/32 area 1.1.1.1 range 2001:db3::/32 cost 10 - """ + """, ) set_module_args( dict( @@ -299,11 +299,11 @@ def test_nxos_ospfv3_af_areas_ranges_replaced(self): cost=18, ), ], - ) + ), ], ), - ) - ] + ), + ], ), state="replaced", ), @@ -328,7 +328,7 @@ def test_nxos_ospfv3_af_areas_default_cost_merged(self): router ospfv3 100 address-family ipv6 unicast area 1.1.1.1 default-cost 10 - """ + """, ) set_module_args( dict( @@ -344,8 +344,8 @@ def test_nxos_ospfv3_af_areas_default_cost_merged(self): dict(area_id="1.1.1.2", default_cost=200), ], ), - ) - ] + ), + ], ), state="merged", ), @@ -367,7 +367,7 @@ def test_nxos_ospfv3_af_areas_default_cost_replaced(self): router ospfv3 100 address-family ipv6 unicast area 1.1.1.1 default-cost 10 - """ + """, ) set_module_args( dict( @@ -380,8 +380,8 @@ def test_nxos_ospfv3_af_areas_default_cost_replaced(self): safi="unicast", areas=[dict(area_id="1.1.1.2", default_cost=200)], ), - ) - ] + ), + ], ), state="replaced", ), @@ -403,7 +403,7 @@ def test_nxos_ospfv3_af_default_information_merged(self): router ospfv3 100 address-family ipv6 unicast default-information originate - """ + """, ) set_module_args( dict( @@ -415,11 +415,11 @@ def test_nxos_ospfv3_af_default_information_merged(self): afi="ipv6", safi="unicast", default_information=dict( - originate=dict(always=True, route_map="test-2") + originate=dict(always=True, route_map="test-2"), ), ), - ) - ] + ), + ], ), state="merged", ), @@ -440,7 +440,7 @@ def test_nxos_ospfv3_af_default_information_merged_2(self): router ospfv3 100 address-family ipv6 unicast default-information originate always route-map test-2 - """ + """, ) set_module_args( dict( @@ -453,8 +453,8 @@ def test_nxos_ospfv3_af_default_information_merged_2(self): safi="unicast", default_information=dict(originate=dict(set=False)), ), - ) - ] + ), + ], ), state="merged", ), @@ -475,7 +475,7 @@ def test_nxos_ospfv3_af_default_information_replaced(self): router ospfv3 100 address-family ipv6 unicast default-information originate always test-2 - """ + """, ) set_module_args( dict( @@ -488,8 +488,8 @@ def test_nxos_ospfv3_af_default_information_replaced(self): safi="unicast", default_information=dict(originate=dict(set=True)), ), - ) - ] + ), + ], ), state="replaced", ), @@ -510,7 +510,7 @@ def test_nxos_ospfv3_af_distance_merged(self): router ospfv3 100 address-family ipv6 unicast distance 20 - """ + """, ) set_module_args( dict( @@ -519,8 +519,8 @@ def test_nxos_ospfv3_af_distance_merged(self): dict( process_id="100", address_family=dict(afi="ipv6", safi="unicast", distance=35), - ) - ] + ), + ], ), state="merged", ), @@ -543,7 +543,7 @@ def test_nxos_ospfv3_af_distance_replaced(self): router ospfv3 100 address-family ipv6 unicast distance 20 - """ + """, ) set_module_args( dict( @@ -552,8 +552,8 @@ def test_nxos_ospfv3_af_distance_replaced(self): dict( process_id="100", address_family=dict(afi="ipv6", safi="unicast"), - ) - ] + ), + ], ), state="replaced", ), @@ -574,7 +574,7 @@ def test_nxos_ospfv3_af_maximum_paths_merged(self): router ospfv3 100 address-family ipv6 unicast maximum-paths 18 - """ + """, ) set_module_args( dict( @@ -583,8 +583,8 @@ def test_nxos_ospfv3_af_maximum_paths_merged(self): dict( process_id="100", address_family=dict(afi="ipv6", safi="unicast", maximum_paths=27), - ) - ] + ), + ], ), state="replaced", ), @@ -607,7 +607,7 @@ def test_nxos_ospfv3_af_maximum_paths_replaced(self): router ospfv3 100 address-family ipv6 unicast maximum-paths 18 - """ + """, ) set_module_args( dict( @@ -616,8 +616,8 @@ def test_nxos_ospfv3_af_maximum_paths_replaced(self): dict( process_id="100", address_family=dict(afi="ipv6", safi="unicast"), - ) - ] + ), + ], ), state="replaced", ), @@ -638,7 +638,7 @@ def test_nxos_ospfv3_af_redistribute_merged(self): router ospfv3 100 address-family ipv6 unicast redistribute eigrp 100 route-map test-17 - """ + """, ) set_module_args( dict( @@ -668,8 +668,8 @@ def test_nxos_ospfv3_af_redistribute_merged(self): dict(protocol="static", route_map="test-4"), ], ), - ) - ] + ), + ], ), state="merged", ), @@ -693,7 +693,7 @@ def test_nxos_ospfv3_af_redistribute_replaced(self): router ospfv3 100 address-family ipv6 unicast redistribute eigrp 100 route-map test-1 - """ + """, ) set_module_args( dict( @@ -718,8 +718,8 @@ def test_nxos_ospfv3_af_redistribute_replaced(self): dict(protocol="static", route_map="test-4"), ], ), - ) - ] + ), + ], ), state="replaced", ), @@ -743,7 +743,7 @@ def test_nxos_ospfv3_af_summary_address_merged(self): router ospfv3 100 address-family ipv6 unicast summary-address 2001:db2::/32 - """ + """, ) set_module_args( dict( @@ -763,8 +763,8 @@ def test_nxos_ospfv3_af_summary_address_merged(self): dict(prefix="2001:db4::/32"), ], ), - ) - ] + ), + ], ), state="merged", ), @@ -787,7 +787,7 @@ def test_nxos_ospfv3_af_summary_address_replaced(self): router ospfv3 100 address-family ipv6 unicast summary-address 2001:db2::/32 tag 19 - """ + """, ) set_module_args( dict( @@ -802,11 +802,11 @@ def test_nxos_ospfv3_af_summary_address_replaced(self): dict( prefix="2001:db3::/32", not_advertise=True, - ) + ), ], ), - ) - ] + ), + ], ), state="replaced", ), @@ -828,7 +828,7 @@ def test_nxos_ospfv3_af_table_map_merged(self): router ospfv3 100 address-family ipv6 unicast summary-address 2001:db2::/32 tag 19 - """ + """, ) set_module_args( dict( @@ -841,8 +841,8 @@ def test_nxos_ospfv3_af_table_map_merged(self): safi="unicast", table_map=dict(name="test-1", filter=True), ), - ) - ] + ), + ], ), state="merged", ), @@ -863,7 +863,7 @@ def test_nxos_ospfv3_af_table_map_replaced(self): router ospfv3 100 address-family ipv6 unicast table-map test-1 filter - """ + """, ) set_module_args( dict( @@ -876,8 +876,8 @@ def test_nxos_ospfv3_af_table_map_replaced(self): safi="unicast", table_map=dict(name="test-2"), ), - ) - ] + ), + ], ), state="replaced", ), @@ -898,7 +898,7 @@ def test_nxos_ospfv3_af_timers_merged(self): router ospfv3 100 address-family ipv6 unicast timers throttle spf 1000 20 2800 - """ + """, ) set_module_args( dict( @@ -914,12 +914,12 @@ def test_nxos_ospfv3_af_timers_merged(self): spf=dict( initial_spf_delay=1100, max_wait_time=2805, - ) - ) + ), + ), ), ), - ) - ] + ), + ], ), state="merged", ), @@ -940,7 +940,7 @@ def test_nxos_ospfv3_af_timers_replaced(self): router ospfv3 100 address-family ipv6 unicast timers throttle spf 1000 20 2800 - """ + """, ) set_module_args( dict( @@ -949,8 +949,8 @@ def test_nxos_ospfv3_af_timers_replaced(self): dict( process_id="100", address_family=dict(afi="ipv6", safi="unicast"), - ) - ] + ), + ], ), state="replaced", ), @@ -970,7 +970,7 @@ def test_nxos_ospfv3_areas_nssa_merged(self): """\ router ospfv3 100 area 1.1.1.1 nssa no-redistribution default-information-originate - """ + """, ) set_module_args( dict( @@ -995,8 +995,8 @@ def test_nxos_ospfv3_areas_nssa_merged(self): ), ), ], - ) - ] + ), + ], ), state="merged", ), @@ -1018,7 +1018,7 @@ def test_nxos_ospfv3_areas_nssa_merged_2(self): """\ router ospfv3 100 area 1.1.1.1 nssa no-summary - """ + """, ) set_module_args( dict( @@ -1027,8 +1027,8 @@ def test_nxos_ospfv3_areas_nssa_merged_2(self): dict( process_id="100", areas=[dict(area_id="1.1.1.1", nssa=dict(set=False))], - ) - ] + ), + ], ), state="merged", ), @@ -1045,7 +1045,7 @@ def test_nxos_ospfv3_areas_nssa_replaced(self): router ospfv3 100 area 1.1.1.1 nssa no-summary no-redistribution default-information-originate area 1.1.1.3 nssa translate type7 always supress-fa - """ + """, ) set_module_args( dict( @@ -1062,10 +1062,10 @@ def test_nxos_ospfv3_areas_nssa_replaced(self): no_redistribution=True, route_map="test-1", ), - ) + ), ], - ) - ] + ), + ], ), state="replaced", ), @@ -1086,7 +1086,7 @@ def test_nxos_ospfv3_areas_stub_merged(self): """\ router ospfv3 100 area 1.1.1.3 stub - """ + """, ) set_module_args( dict( @@ -1098,10 +1098,10 @@ def test_nxos_ospfv3_areas_stub_merged(self): dict( area_id="1.1.1.3", stub=dict(no_summary=True), - ) + ), ], - ) - ] + ), + ], ), state="merged", ), @@ -1117,7 +1117,7 @@ def test_nxos_ospfv3_areas_stub_merged_2(self): """\ router ospfv3 100 area 1.1.1.3 stub - """ + """, ) set_module_args( dict( @@ -1132,8 +1132,8 @@ def test_nxos_ospfv3_areas_stub_merged_2(self): stub=dict(no_summary=True), ), ], - ) - ] + ), + ], ), state="merged", ), @@ -1153,7 +1153,7 @@ def test_nxos_ospfv3_areas_stub_replaced(self): """\ router ospfv3 100 area 1.1.1.3 stub no-summary - """ + """, ) set_module_args( dict( @@ -1172,7 +1172,7 @@ def test_nxos_ospfv3_autocost_flush_route_isolate_merged(self): """\ router ospfv3 100 auto-cost reference-bandwidth 300 Mbps - """ + """, ) set_module_args( dict( @@ -1183,8 +1183,8 @@ def test_nxos_ospfv3_autocost_flush_route_isolate_merged(self): auto_cost=dict(reference_bandwidth=100, unit="Gbps"), flush_routes=True, isolate=True, - ) - ] + ), + ], ), state="merged", ), @@ -1206,7 +1206,7 @@ def test_nxos_ospfv3_autocost_flush_route_isolate_replaced(self): router ospfv3 100 auto-cost reference-bandwidth 300 Mbps flush-routes - """ + """, ) set_module_args( dict( @@ -1232,7 +1232,7 @@ def test_nxos_ospfv3_log_adjacency_changes_name_lookup_passive_interface_merged( """\ router ospfv3 100 log-adjacency-changes - """ + """, ) set_module_args( dict( @@ -1248,7 +1248,7 @@ def test_nxos_ospfv3_log_adjacency_changes_name_lookup_passive_interface_merged( process_id="102", log_adjacency_changes=dict(log=True), ), - ] + ], ), state="merged", ), @@ -1274,7 +1274,7 @@ def test_nxos_ospfv3_log_adjacency_changes_name_lookup_passive_interface_replace router ospfv3 100 log-adjacency-changes detail name-lookup - """ + """, ) set_module_args( dict( @@ -1283,8 +1283,8 @@ def test_nxos_ospfv3_log_adjacency_changes_name_lookup_passive_interface_replace dict( process_id="100", passive_interface=dict(default=True), - ) - ] + ), + ], ), state="replaced", ), @@ -1308,7 +1308,7 @@ def test_nxos_ospfv3_max_lsa_router_id_merged(self): max-lsa 4200 85 ignore-count 10 reset-time 120 router ospfv3 102 max-lsa 4200 85 ignore-time 120 ignore-count 12 reset-time 300 - """ + """, ) set_module_args( dict( @@ -1342,7 +1342,7 @@ def test_nxos_ospfv3_max_lsa_router_id_merged(self): warning_only=True, ), ), - ] + ], ), state="merged", ), @@ -1369,7 +1369,7 @@ def test_nxos_ospfv3_max_lsa_router_id_replaced(self): max-lsa 4200 85 ignore-count 10 reset-time 120 router ospfv3 102 max-lsa 4200 85 ignore-time 120 ignore-count 12 reset-time 300 - """ + """, ) set_module_args( dict( @@ -1382,8 +1382,8 @@ def test_nxos_ospfv3_max_lsa_router_id_replaced(self): threshold=85, warning_only=True, ), - ) - ] + ), + ], ), state="replaced", ), @@ -1405,7 +1405,7 @@ def test_nxos_ospfv3_graceful_restart_merged(self): no graceful-restart router ospfv3 102 no graceful-restart planned-only - """ + """, ) set_module_args( dict( @@ -1419,7 +1419,7 @@ def test_nxos_ospfv3_graceful_restart_merged(self): process_id="102", graceful_restart=dict(planned_only=True), ), - ] + ], ), state="merged", ), @@ -1443,7 +1443,7 @@ def test_nxos_ospfv3_graceful_restart_replaced(self): graceful-restart grace-period 50 graceful-restart helper-disable router ospfv3 102 - """ + """, ) set_module_args( dict( @@ -1457,7 +1457,7 @@ def test_nxos_ospfv3_graceful_restart_replaced(self): process_id="102", graceful_restart=dict(helper_disable=True), ), - ] + ], ), state="replaced", ), @@ -1479,7 +1479,7 @@ def test_nxos_ospfv3_max_metric_merged(self): """\ router ospfv3 100 max-metric router-lsa external-lsa 1900 - """ + """, ) set_module_args( dict( @@ -1492,13 +1492,13 @@ def test_nxos_ospfv3_max_metric_merged(self): external_lsa=dict(max_metric_value=2000), stub_prefix_lsa=True, on_startup=dict(set=True), - ) + ), ), ), dict( process_id="102", max_metric=dict( - router_lsa=dict(inter_area_prefix_lsa=dict(max_metric_value=1800)) + router_lsa=dict(inter_area_prefix_lsa=dict(max_metric_value=1800)), ), ), dict( @@ -1510,10 +1510,10 @@ def test_nxos_ospfv3_max_metric_merged(self): wait_for_bgp_asn=65563, ), inter_area_prefix_lsa=dict(set=True), - ) + ), ), ), - ] + ], ), state="merged", ), @@ -1538,7 +1538,7 @@ def test_nxos_ospfv3_max_metric_merged_2(self): max-metric router-lsa inter-area-prefix-lsa 1800 router ospfv3 103 max-metric router-lsa on-startup 1200 wait-for bgp 65563 inter-area-prefix-lsa - """ + """, ) set_module_args( dict( @@ -1547,8 +1547,8 @@ def test_nxos_ospfv3_max_metric_merged_2(self): dict( process_id="100", max_metric=dict(router_lsa=dict(set=False)), - ) - ] + ), + ], ), state="merged", ), @@ -1567,7 +1567,7 @@ def test_nxos_ospfv3_max_metric_replaced(self): max-metric router-lsa inter-area-prefix-lsa 1800 router ospfv3 103 max-metric router-lsa on-startup 1200 wait-for bgp 65563 inter-area-prefix-lsa - """ + """, ) set_module_args( dict( @@ -1580,12 +1580,12 @@ def test_nxos_ospfv3_max_metric_replaced(self): external_lsa=dict(max_metric_value=2000), stub_prefix_lsa=True, on_startup=dict(set=True), - ) + ), ), ), dict(process_id="102"), dict(process_id="103"), - ] + ], ), state="replaced", ), @@ -1609,7 +1609,7 @@ def test_nxos_ospfv3_timers_shutdown_merged(self): router ospfv3 100 timers lsa-group-pacing 190 shutdown - """ + """, ) set_module_args( dict( @@ -1625,12 +1625,12 @@ def test_nxos_ospfv3_timers_shutdown_merged(self): start_interval=100, hold_interval=70, max_interval=1500, - ) + ), ), ), shutdown=False, - ) - ] + ), + ], ), state="merged", ), @@ -1654,7 +1654,7 @@ def test_nxos_ospfv3_timers_shutdown_replaced(self): timers lsa-arrival 800 timers lsa-group-pacing 210 timers throttle lsa 100 70 1500 - """ + """, ) set_module_args( dict( @@ -1664,8 +1664,8 @@ def test_nxos_ospfv3_timers_shutdown_replaced(self): process_id="100", timers=dict(lsa_arrival=1200), shutdown=True, - ) - ] + ), + ], ), state="replaced", ), @@ -1688,7 +1688,7 @@ def test_nxos_ospfv3_vrf_merged(self): router ospfv3 100 vrf blue area 1.1.1.1 nssa - """ + """, ) set_module_args( dict( @@ -1724,10 +1724,10 @@ def test_nxos_ospfv3_vrf_merged(self): type7=dict( always=True, supress_fa=True, - ) + ), ), ), - ) + ), ], ), ], @@ -1744,9 +1744,9 @@ def test_nxos_ospfv3_vrf_merged(self): wait_for_bgp_asn=65563, ), inter_area_prefix_lsa=dict(set=True), - ) + ), ), - ) + ), ], ), dict( @@ -1762,14 +1762,14 @@ def test_nxos_ospfv3_vrf_merged(self): start_interval=100, hold_interval=70, max_interval=1500, - ) + ), ), ), shutdown=True, - ) + ), ], ), - ] + ], ), state="merged", ), @@ -1816,7 +1816,7 @@ def test_nxos_ospfv3_vrf_replaced(self): timers lsa-group-pacing 210 timers throttle lsa 100 70 1500 shutdown - """ + """, ) set_module_args( dict( @@ -1836,15 +1836,15 @@ def test_nxos_ospfv3_vrf_replaced(self): type7=dict( always=True, supress_fa=True, - ) + ), ), ), - ) + ), ], - ) + ), ], - ) - ] + ), + ], ), state="replaced", ), @@ -1868,7 +1868,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_merged(self): router ospfv3 100 address-family ipv6 unicast table-map map1 filter - """ + """, ) set_module_args( dict( @@ -1884,7 +1884,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_merged(self): protocol="eigrp", id="100", route_map="rmap1", - ) + ), ], ), vrfs=[ @@ -1895,7 +1895,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_merged(self): dict( area_id="1.1.1.1", nssa=dict(set=True), - ) + ), ], ), ], @@ -1904,7 +1904,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_merged(self): process_id="103", vrfs=[dict(vrf="red", shutdown=True)], ), - ] + ], ), state="merged", ), @@ -1940,7 +1940,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_replaced(self): router ospfv3 103 vrf red shutdown - """ + """, ) set_module_args( dict( @@ -1956,11 +1956,11 @@ def test_nxos_ospfv3_top_spec_af_vrf_replaced(self): protocol="eigrp", id="100", route_map="rmap1", - ) + ), ], ), - ) - ] + ), + ], ), state="replaced", ), @@ -1991,7 +1991,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_overridden(self): router ospfv3 103 vrf red shutdown - """ + """, ) set_module_args( dict( @@ -2007,11 +2007,11 @@ def test_nxos_ospfv3_top_spec_af_vrf_overridden(self): protocol="eigrp", id="100", route_map="rmap2", - ) + ), ], ), - ) - ] + ), + ], ), state="overridden", ), @@ -2044,7 +2044,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_deleted(self): router ospfv3 103 vrf red shutdown - """ + """, ) set_module_args( dict( @@ -2072,7 +2072,7 @@ def test_nxos_ospfv3_top_spec_af_vrf_deleted_all(self): router ospfv3 103 vrf red shutdown - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = ["no router ospfv3 100", "no router ospfv3 103"] @@ -2096,7 +2096,7 @@ def test_nxos_ospfv3_parsed(self): router ospfv3 103 vrf red shutdown - """ + """, ), state="parsed", ), @@ -2113,7 +2113,7 @@ def test_nxos_ospfv3_parsed(self): "protocol": "eigrp", "id": "100", "route_map": "rmap1", - } + }, ], "afi": "ipv6", "safi": "unicast", @@ -2130,7 +2130,7 @@ def test_nxos_ospfv3_parsed(self): "process_id": "103", "vrfs": [{"vrf": "red", "shutdown": True}], }, - ] + ], } result = self.execute_module(changed=False) self.assertEqual(set(result["parsed"]), set(parsed)) @@ -2150,7 +2150,7 @@ def test_nxos_ospfv3_gathered(self): router ospfv3 103 vrf red shutdown - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = { @@ -2164,7 +2164,7 @@ def test_nxos_ospfv3_gathered(self): "protocol": "eigrp", "id": "100", "route_map": "rmap1", - } + }, ], "afi": "ipv6", "safi": "unicast", @@ -2181,7 +2181,7 @@ def test_nxos_ospfv3_gathered(self): "process_id": "103", "vrfs": [{"vrf": "red", "shutdown": True}], }, - ] + ], } result = self.execute_module(changed=False) self.assertEqual(set(result["gathered"]), set(gathered)) @@ -2193,7 +2193,7 @@ def test_nxos_ospfv3_process_id_word(self): router-id 203.0.113.20 router ospfv3 TEST-1 router-id 198.51.100.1 - """ + """, ) set_module_args( dict( @@ -2202,7 +2202,7 @@ def test_nxos_ospfv3_process_id_word(self): dict(process_id="100", router_id="203.0.113.20"), dict(process_id="TEST-1", router_id="198.51.100.1"), dict(process_id="TEST-2", router_id="198.52.200.1"), - ] + ], ), state="merged", ), diff --git a/tests/unit/modules/network/nxos/test_nxos_overlay_global.py b/tests/unit/modules/network/nxos/test_nxos_overlay_global.py index 976407b7d..59c190805 100644 --- a/tests/unit/modules/network/nxos/test_nxos_overlay_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_overlay_global.py @@ -35,12 +35,12 @@ class TestNxosOverlayGlobalModule(TestNxosModule): def setUp(self): super(TestNxosOverlayGlobalModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_overlay_global.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_overlay_global.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_overlay_global.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_overlay_global.get_config", ) self.get_config = self.mock_get_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_pim.py b/tests/unit/modules/network/nxos/test_nxos_pim.py index 4637b9030..dde259605 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosPimModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim.load_config", ) self.load_config = self.mock_load_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py index 101d94ca3..7b9a537d1 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py @@ -36,17 +36,17 @@ def setUp(self): super(TestNxosIPInterfaceModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.load_config", ) self.load_config = self.mock_load_config.start() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.run_commands", ) self.run_commands = self.mock_run_commands.start() @@ -82,7 +82,7 @@ def test_nxos_pim_interface_present(self): hello_interval=40, sparse=True, border=False, - ) + ), ) self.execute_module( changed=True, @@ -102,7 +102,7 @@ def test_nxos_pim_interface_jp(self): jp_policy_out="JPOUT", jp_type_in="routemap", jp_type_out="routemap", - ) + ), ) self.execute_module( changed=True, @@ -130,22 +130,22 @@ def setUp(self): super(TestNxosPimInterfaceBfdModule, self).setUp() self.mock_get_interface_mode = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.get_interface_mode" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.get_interface_mode", ) self.get_interface_mode = self.mock_get_interface_mode.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.load_config", ) self.load_config = self.mock_load_config.start() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_interface.run_commands", ) self.run_commands = self.mock_run_commands.start() @@ -270,7 +270,7 @@ def test_bfd_4(self): interface="Ethernet9/2", hello_interval=1, hello_interval_ms=True, - ) + ), ) self.execute_module( changed=True, @@ -283,7 +283,7 @@ def test_bfd_4(self): interface="Ethernet9/2", hello_interval=1000, hello_interval_ms=True, - ) + ), ) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py b/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py index 9a32bdb32..d068ee566 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosPimRpAddressModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_rp_address.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_rp_address.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_rp_address.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_pim_rp_address.get_config", ) self.get_config = self.mock_get_config.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_ping.py b/tests/unit/modules/network/nxos/test_nxos_ping.py index b07309e6b..0b7b5d6a9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ping.py +++ b/tests/unit/modules/network/nxos/test_nxos_ping.py @@ -42,7 +42,7 @@ class TestNxosPingModule(TestNxosModule): def setUp(self): super(TestNxosPingModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ping.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_ping.run_commands", ) self.run_commands = self.mock_run_commands.start() @@ -63,7 +63,7 @@ def test_nxos_ping_expected_success(self): --- 172.28.128.7 ping statistics --- 5 packets transmitted, 5 packets received, 0.00% packet loss round-trip min/avg/max = 1.597/2.32/4.197 ms - """ + """, ] set_module_args(dict(dest="172.28.128.7", vrf="management")) result = self.execute_module() @@ -87,7 +87,7 @@ def test_nxos_ping_expected_failure(self): --- 172.28.128.8 ping statistics --- 5 packets transmitted, 0 packets received, 100.00% packet loss - """ + """, ] set_module_args(dict(dest="172.28.128.8", vrf="management", state="absent")) self.execute_module(failed=False) @@ -104,7 +104,7 @@ def test_nxos_ping_expected_success_but_failed(self): --- 172.28.128.8 ping statistics --- 5 packets transmitted, 0 packets received, 100.00% packet loss - """ + """, ] set_module_args(dict(dest="172.28.128.8", vrf="management")) result = self.execute_module(failed=True) @@ -123,7 +123,7 @@ def test_nxos_ping_expected_failure_but_succeeded(self): --- 172.28.128.7 ping statistics --- 5 packets transmitted, 5 packets received, 0.00% packet loss round-trip min/avg/max = 1.597/2.32/4.197 ms - """ + """, ] set_module_args(dict(dest="172.28.128.7", vrf="management", state="absent")) result = self.execute_module(failed=True) @@ -142,7 +142,7 @@ def test_nxos_ping_expected_success_source(self): --- 172.28.128.7 ping statistics --- 5 packets transmitted, 5 packets received, 0.00% packet loss round-trip min/avg/max = 1.597/2.32/4.197 ms - """ + """, ] set_module_args(dict(dest="172.28.128.7", source="192.168.1.10")) result = self.execute_module() @@ -170,7 +170,7 @@ def test_nxos_ping_expected_success_df_bit(self): --- 172.28.128.7 ping statistics --- 5 packets transmitted, 5 packets received, 0.00% packet loss round-trip min/avg/max = 1.597/2.32/4.197 ms - """ + """, ] set_module_args(dict(dest="172.28.128.7", df_bit=True)) result = self.execute_module() @@ -189,7 +189,7 @@ def test_nxos_ping_expected_success_size(self): --- 172.28.128.7 ping statistics --- 5 packets transmitted, 5 packets received, 0.00% packet loss round-trip min/avg/max = 1.597/2.32/4.197 ms - """ + """, ] set_module_args(dict(dest="172.28.128.7", size=65468)) result = self.execute_module() @@ -208,7 +208,7 @@ def test_nxos_ping_expected_success_all(self): --- 172.28.128.7 ping statistics --- 5 packets transmitted, 5 packets received, 0.00% packet loss round-trip min/avg/max = 1.597/2.32/4.197 ms - """ + """, ] set_module_args( dict( @@ -218,13 +218,13 @@ def test_nxos_ping_expected_success_all(self): df_bit=True, source="192.168.1.1", vrf="management", - ) + ), ) result = self.execute_module() self.assertEqual( result["commands"], [ - "ping 172.28.128.7 count 10 source 192.168.1.1 vrf management packet-size 65468 df-bit" + "ping 172.28.128.7 count 10 source 192.168.1.1 vrf management packet-size 65468 df-bit", ], ) @@ -232,7 +232,7 @@ def test_nxos_ping_failed_cant_bind(self): self.run_commands.return_value = [ """ ping: can't bind to address 192.168.1.10 - """ + """, ] set_module_args( dict( @@ -242,7 +242,7 @@ def test_nxos_ping_failed_cant_bind(self): df_bit=True, source="192.168.1.1", vrf="management", - ) + ), ) result = self.execute_module(failed=True) self.assertEqual(result["msg"], "Can't bind to source address.") @@ -251,7 +251,7 @@ def test_nxos_ping_failed_bad_context(self): self.run_commands.return_value = [ """ ping: bad context site-1 - """ + """, ] set_module_args(dict(dest="172.28.128.7", count=10, vrf="site-1")) result = self.execute_module(failed=True) diff --git a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py index e4cce5a9b..a1d18615f 100644 --- a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py +++ b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py @@ -55,12 +55,12 @@ def setUp(self): super(TestNxosPrefixListsModule, 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" + "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.prefix_lists.prefix_lists.Prefix_listsFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -73,7 +73,7 @@ def test_nxos_prefix_lists_linear_merged(self): # test merged for linear attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -188,7 +188,7 @@ def test_nxos_prefix_lists_linear_merged_idempotent(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict( @@ -291,7 +291,7 @@ def test_nxos_prefix_lists_merged_update(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict( @@ -307,11 +307,11 @@ def test_nxos_prefix_lists_merged_update(self): sequence=10, action="permit", prefix="192.168.8.0/24", - ) + ), ], - ) + ), ], - ) + ), ], state="merged", ), @@ -338,7 +338,7 @@ def test_nxos_prefix_lists_replaced_update(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict( @@ -362,9 +362,9 @@ def test_nxos_prefix_lists_replaced_update(self): mask="255.255.255.0", ), ], - ) + ), ], - ) + ), ], state="replaced", ), @@ -391,7 +391,7 @@ def test_nxos_prefix_lists_replaced(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict( @@ -406,11 +406,11 @@ def test_nxos_prefix_lists_replaced(self): sequence=10, action="permit", prefix="192.168.8.0/24", - ) + ), ], - ) + ), ], - ) + ), ], state="replaced", ), @@ -439,7 +439,7 @@ def test_nxos_prefix_lists_overridden(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict( @@ -454,11 +454,11 @@ def test_nxos_prefix_lists_overridden(self): sequence=10, action="permit", prefix="192.168.8.0/24", - ) + ), ], - ) + ), ], - ) + ), ], state="overridden", ), @@ -490,7 +490,7 @@ def test_nxos_prefix_lists_deleted_afi(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict(config=[dict(afi="ipv4")], state="deleted"), @@ -514,7 +514,7 @@ def test_nxos_prefix_lists_deleted_prefix_list(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args( dict( @@ -541,7 +541,7 @@ def test_nxos_prefix_lists_deleted_all(self): ipv6 prefix-list plist3 seq 20 permit 2001:db8:2000::/36 ipv6 prefix-list plist4 seq 20 permit 2001:db8:3000::/36 ipv6 prefix-list plist4 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -559,7 +559,7 @@ def test_nxos_prefix_lists_parsed(self): """\ ip prefix-list plist1 description Test plist1 ipv6 prefix-list plist3 description Test plist3 - """ + """, ) set_module_args(dict(running_config=cfg, state="parsed"), ignore_provider_arg) parsed = [ @@ -583,7 +583,7 @@ def test_nxos_prefix_lists_gathered(self): ip prefix-list plist1 seq 20 deny 192.168.2.0/24 mask 255.255.255.0 ipv6 prefix-list plist3 description Test plist3 ipv6 prefix-list plist3 seq 50 deny 2001:db8:4000::/36 - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) gathered = [ @@ -599,9 +599,9 @@ def test_nxos_prefix_lists_gathered(self): "action": "deny", "prefix": "192.168.2.0/24", "mask": "255.255.255.0", - } + }, ], - } + }, ], }, { @@ -615,9 +615,9 @@ def test_nxos_prefix_lists_gathered(self): "sequence": 50, "action": "deny", "prefix": "2001:db8:4000::/36", - } + }, ], - } + }, ], }, ] diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index 71a81bec5..8008725e3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -53,12 +53,12 @@ def setUp(self): super(TestNxosRouteMapsModule, 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" + "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.route_maps.route_maps.Route_mapsFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.route_maps.route_maps.Route_mapsFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -71,7 +71,7 @@ def test_nxos_route_maps_linear_merged(self): # test merged for linear attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -137,7 +137,7 @@ def test_nxos_route_maps_linear_merged(self): tag=10, weight=40, ), - ) + ), ], ), ], @@ -209,7 +209,7 @@ def test_nxos_route_maps_linear_merged_idempotent(self): set path-selection all advertise set tag 10 set weight 40 - """ + """, ) set_module_args( dict( @@ -275,7 +275,7 @@ def test_nxos_route_maps_linear_merged_idempotent(self): tag=10, weight=40, ), - ) + ), ], ), ], @@ -319,7 +319,7 @@ def test_nxos_route_maps_linear_replaced(self): set path-selection all advertise set tag 10 set weight 40 - """ + """, ) set_module_args( dict( @@ -355,9 +355,9 @@ def test_nxos_route_maps_linear_replaced(self): ip=dict( address=dict(prefix_list="prefixlist1"), precedence="critical", - ) + ), ), - ) + ), ], ), ], @@ -403,7 +403,7 @@ def test_nxos_route_maps_parsed(self): set ip precedence critical set ipv6 address prefix-list prefixlist2 set ipv6 precedence immediate - """ + """, ), state="parsed", ), @@ -445,7 +445,7 @@ def test_nxos_route_maps_parsed(self): precedence="immediate", ), ), - ) + ), ], ), ] @@ -472,7 +472,7 @@ def test_nxos_route_maps_gathered(self): set ip precedence critical set ipv6 address prefix-list prefixlist2 set ipv6 precedence immediate - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) @@ -511,7 +511,7 @@ def test_nxos_route_maps_gathered(self): precedence="immediate", ), ), - ) + ), ], ), ] @@ -555,9 +555,9 @@ def test_nxos_route_maps_rendered(self): ip=dict( address=dict(prefix_list="prefixlist1"), precedence="critical", - ) + ), ), - ) + ), ], ), ], @@ -600,7 +600,7 @@ def test_nxos_route_maps_overridden(self): description rmap3-permit-21 route-map rmap3 permit 22 description rmap3-permit-21 - """ + """, ) set_module_args( dict( @@ -622,7 +622,7 @@ def test_nxos_route_maps_overridden(self): ipv6=dict( address=dict(prefix_list="prefixlist2"), precedence="immediate", - ) + ), ), ), ], @@ -635,7 +635,7 @@ def test_nxos_route_maps_overridden(self): action="permit", description="rmap2-permit-10", set=dict(null_interface="null0"), - ) + ), ], ), ], @@ -676,7 +676,7 @@ def test_nxos_route_maps_deleted_1(self): description rmap3-permit-21 route-map rmap3 permit 22 description rmap3-permit-21 - """ + """, ) set_module_args( dict(config=[dict(route_map="rmap1")], state="deleted"), @@ -709,7 +709,7 @@ def test_nxos_route_maps_deleted_2(self): description rmap3-permit-21 route-map rmap3 permit 22 description rmap3-permit-21 - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -727,7 +727,7 @@ def test_nxos_route_maps_complex_merged(self): # test merged for complex attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -750,7 +750,7 @@ def test_nxos_route_maps_complex_merged(self): extcommunity_list=[ "extcomm1", "extcomm2", - ] + ], ), interfaces=["Ethernet1/1", "Ethernet1/2"], ip=dict( @@ -796,7 +796,7 @@ def test_nxos_route_maps_complex_merged(self): ), next_hop=dict(prefix_lists=["pl1", "pl2"]), route_source=dict(prefix_lists=["pl3", "pl4"]), - ) + ), ), ), dict( @@ -829,7 +829,7 @@ def test_nxos_route_maps_complex_merged(self): ), ), ], - ) + ), ], state="merged", ), @@ -876,7 +876,7 @@ def test_nxos_route_maps_complex_merged_2(self): # test merged for complex attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -899,7 +899,7 @@ def test_nxos_route_maps_complex_merged_2(self): rp_type="Bidir", ), source="192.168.1.0/24", - ) + ), ), ipv6=dict( multicast=dict( @@ -912,7 +912,7 @@ def test_nxos_route_maps_complex_merged_2(self): rp_type="Bidir", ), source="2001:db8:2000::/36", - ) + ), ), ), set=dict( @@ -921,11 +921,11 @@ def test_nxos_route_maps_complex_merged_2(self): igrp_delay_metric=90, igrp_reliability_metric=80, igrp_effective_bandwidth_metric=100, - ) + ), ), - ) + ), ], - ) + ), ], state="merged", ), @@ -948,7 +948,7 @@ def test_nxos_route_maps_complex_replaced(self): match ip address prefix-list pl1 pl2 pl3 match ip multicast source 192.168.1.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 209.165.201.0/27 rp-type Bidir match ipv6 multicast source 2001:db8:2000::/36 group-range fd00:80:: to fd00:ff:ffff:ffff:: rp fd00:280::/25 rp-type Bidir - """ + """, ) set_module_args( dict( @@ -982,12 +982,12 @@ def test_nxos_route_maps_complex_replaced(self): rp_type="Bidir", ), source="2001:db8:2000::/36", - ) + ), ), ), - ) + ), ], - ) + ), ], state="replaced", ), @@ -1007,7 +1007,7 @@ def test_nxos_route_maps_gathered_empty(self): # test gathered for empty config self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index a743f49c2..230f7c7e3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -41,12 +41,12 @@ def setUp(self): super(TestNxosSnmpServerModule, 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" + "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.snmp_server.snmp_server.Snmp_serverFacts.get_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -59,7 +59,7 @@ def test_nxos_snmp_server_linear_merged(self): # test merged for linear attributes self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -130,7 +130,7 @@ def test_nxos_snmp_server_linear_merged_idempotent(self): snmp-server location lab snmp-server mib community-map public context public1 snmp-server source-interface traps Ethernet1/2 - """ + """, ) set_module_args( dict( @@ -177,7 +177,7 @@ def test_nxos_snmp_server_linear_replaced(self): snmp-server location lab snmp-server mib community-map public context public1 snmp-server source-interface traps Ethernet1/2 - """ + """, ) set_module_args( dict( @@ -230,7 +230,7 @@ def test_nxos_snmp_server_linear_overridden(self): snmp-server location lab snmp-server mib community-map public context public1 snmp-server source-interface traps Ethernet1/2 - """ + """, ) set_module_args( dict( @@ -269,7 +269,7 @@ def test_nxos_snmp_server_location_spaces(self): """\ snmp-server contact testswitch@localhost snmp-server location lab - """ + """, ) set_module_args( dict( @@ -292,7 +292,7 @@ def test_nxos_snmp_server_traps_merged(self): # test merged for traps self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -335,7 +335,7 @@ def test_nxos_snmp_server_traps_merged_idempotent(self): snmp-server enable traps bgp snmp-server enable traps ospf snmp-server enable traps ospfv3 - """ + """, ) set_module_args( dict( @@ -347,7 +347,7 @@ def test_nxos_snmp_server_traps_merged_idempotent(self): bgp=dict(enable=True), ospf=dict(enable=True), ospfv3=dict(enable=True), - ) + ), ), state="merged", ), @@ -366,7 +366,7 @@ def test_nxos_snmp_server_traps_replaced(self): snmp-server enable traps bridge topologychange snmp-server enable traps callhome event-notify snmp-server enable traps callhome smtp-send-fail - """ + """, ) set_module_args( dict( @@ -375,7 +375,7 @@ def test_nxos_snmp_server_traps_replaced(self): aaa=dict(server_state_change=True), bridge=dict(enable=True), cfs=dict(merge_failure=True), - ) + ), ), state="replaced", ), @@ -398,7 +398,7 @@ def test_nxos_snmp_server_traps_replaced(self): snmp-server enable traps bridge topologychange snmp-server enable traps callhome event-notify snmp-server enable traps callhome smtp-send-fail - """ + """, ) set_module_args( dict( @@ -407,7 +407,7 @@ def test_nxos_snmp_server_traps_replaced(self): aaa=dict(server_state_change=True), bridge=dict(enable=True), cfs=dict(merge_failure=True), - ) + ), ), state="replaced", ), @@ -425,7 +425,7 @@ def test_nxos_snmp_server_hosts_merged(self): # test merged for hosts self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -463,7 +463,7 @@ def test_nxos_snmp_server_hosts_merged(self): priv="private", informs=True, ), - ] + ], ), state="merged", ), @@ -490,7 +490,7 @@ def test_nxos_snmp_server_hosts_merged(self): snmp-server host 192.168.1.1 source-interface Ethernet1/1 snmp-server host 192.168.2.1 traps version 1 private snmp-server host 192.168.3.1 informs version 3 auth private udp-port 65550 - """ + """, ) set_module_args( dict( @@ -528,7 +528,7 @@ def test_nxos_snmp_server_hosts_merged(self): priv="private", informs=True, ), - ] + ], ), state="merged", ), @@ -547,7 +547,7 @@ def test_nxos_snmp_server_hosts_replaced(self): snmp-server host 192.168.1.1 source-interface Ethernet1/1 snmp-server host 192.168.2.1 traps version 1 private snmp-server host 192.168.3.1 informs version 3 auth private udp-port 65550 - """ + """, ) set_module_args( dict( @@ -574,7 +574,7 @@ def test_nxos_snmp_server_hosts_replaced(self): ), dict(host="192.168.2.1", filter_vrf="siteA"), dict(host="192.168.4.1", use_vrf="siteB"), - ] + ], ), state="replaced", ), @@ -593,7 +593,7 @@ def test_nxos_snmp_server_users_merged(self): # test merged for users self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -618,7 +618,7 @@ def test_nxos_snmp_server_users_merged(self): password="0x5632724fb8ac3699296af26281e1d0f1", engine_id="2:2:2:2:2", priv=dict( - privacy_password="0x5632724fb8ac3699296af26281e1d0f1" + privacy_password="0x5632724fb8ac3699296af26281e1d0f1", ), localizedv2_key=True, ), @@ -651,8 +651,8 @@ def test_nxos_snmp_server_users_merged(self): localized_key=True, ), ), - ] - ) + ], + ), ), state="merged", ), @@ -679,7 +679,7 @@ def test_nxos_snmp_server_users_merged(self): snmp-server user user3 network-admin auth md5 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3 snmp-server user user1 network-admin auth md5 0x5632724fb8ac3699296af262 localizedkey engineID 1:1:1:1:1 snmp-server user user4 network-admin auth sha-256 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 4:4:4:4:4 - """ + """, ) set_module_args( dict( @@ -735,8 +735,8 @@ def test_nxos_snmp_server_users_merged(self): localized_key=True, ), ), - ] - ) + ], + ), ), state="merged", ), @@ -752,7 +752,7 @@ def test_nxos_snmp_server_users_replaced(self): snmp-server user user2 network-admin auth md5 0x5632724fb8ac3699296af262 priv 0x5632724fb8ac3699296af262 localizedkey engineID 2:2:2:2:2 snmp-server user user3 network-admin auth md5 0x5632724fb8ac3699296af262 priv aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3 snmp-server user user1 network-admin auth md5 0x5632724fb8ac3699296af262 localizedkey engineID 1:1:1:1:1 - """ + """, ) set_module_args( dict( @@ -783,8 +783,8 @@ def test_nxos_snmp_server_users_replaced(self): localized_key=True, ), ), - ] - ) + ], + ), ), state="replaced", ), @@ -821,7 +821,7 @@ def test_nxos_snmp_server_deleted(self): snmp-server location lab snmp-server mib community-map public context public1 snmp-server source-interface traps Ethernet1/2 - """ + """, ) set_module_args(dict(state="deleted"), ignore_provider_arg) commands = [ @@ -871,7 +871,7 @@ def test_nxos_snmp_server_parsed(self): snmp-server source-interface traps Ethernet1/2 snmp-server user 1234 network-admin auth md5 0x7d425fbf09417c44bca69e1d9e9ce889 priv 0x7d425fbf09417c44bca69e1d9e9ce889 localizedkey snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey - """ + """, ), state="parsed", ), @@ -918,7 +918,7 @@ def test_nxos_snmp_server_parsed(self): localized_key=True, ), ), - ] + ], ), ) result = self.execute_module(changed=False) @@ -989,7 +989,7 @@ def test_nxos_snmp_server_gathered(self): snmp-server location lab snmp-server mib community-map public context public1 snmp-server source-interface traps Ethernet1/2 - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) @@ -1015,7 +1015,7 @@ def test_nxos_snmp_server_gathered(self): def test_nxos_snmp_server_gathered_empty(self): self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args(dict(state="gathered"), ignore_provider_arg) diff --git a/tests/unit/modules/network/nxos/test_nxos_static_route.py b/tests/unit/modules/network/nxos/test_nxos_static_route.py index fa835ccf6..181249322 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_route.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_route.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosStaticRouteModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_static_route.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_static_route.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_static_route.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_static_route.get_config", ) self.get_config = self.mock_get_config.start() @@ -65,7 +65,7 @@ def test_nxos_static_route_present_no_defaults(self): next_hop="192.0.2.3", route_name="testing", pref=100, - ) + ), ) self.execute_module( changed=True, @@ -102,7 +102,7 @@ def test_nxos_static_route_absent_vrf(self): next_hop="15.16.17.18", vrf="test", state="absent", - ) + ), ) self.execute_module( changed=True, diff --git a/tests/unit/modules/network/nxos/test_nxos_static_routes.py b/tests/unit/modules/network/nxos/test_nxos_static_routes.py index be1115202..37ffc1ae5 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_routes.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_routes.py @@ -23,32 +23,32 @@ 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" + "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" + "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" + "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" + "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" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.static_routes.static_routes.Static_routes.edit_config", ) self.edit_config = self.mock_edit_config.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_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -66,7 +66,7 @@ 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" + "\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", ] output = non_vrf_data + vrf_data @@ -90,16 +90,16 @@ def test_nxos_static_routes_merged(self): forward_router_address="192.0.2.40", interface="Ethernet1/2", admin_distance=5, - ) + ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="merged", - ) + ), ) commands = [ "configure terminal", @@ -122,16 +122,16 @@ def test_nxos_static_routes_merged_idempotent(self): dict( forward_router_address="192.0.2.24", route_name="initial_route", - ) + ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -151,16 +151,16 @@ def test_nxos_static_routes_replaced(self): forward_router_address="192.0.2.50", tag=12, route_name="replaced_route", - ) + ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="replaced", - ) + ), ) commands = [ "configure terminal", @@ -184,16 +184,16 @@ def test_nxos_static_routes_replaced_idempotent(self): dict( forward_router_address="192.0.2.24", route_name="initial_route", - ) + ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -213,16 +213,16 @@ def test_nxos_static_routes_overridden(self): forward_router_address="192.0.2.68", route_name="overridden_route", dest_vrf="end_vrf", - ) + ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="overridden", - ) + ), ) commands = [ "configure terminal", @@ -250,11 +250,11 @@ def test_nxos_static_routes_overridden_idempotent(self): dict( forward_router_address="192.0.2.122", dest_vrf="dest_vrf", - ) + ), ], - ) + ), ], - ) + ), ], ), dict( @@ -268,16 +268,16 @@ def test_nxos_static_routes_overridden_idempotent(self): dict( forward_router_address="192.0.2.24", route_name="initial_route", - ) + ), ], - ) + ), ], - ) - ] + ), + ], ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -295,7 +295,7 @@ def test_nxos_static_routes_deletedafi(self): dict( config=[dict(address_families=[dict(afi="ipv4")])], state="deleted", - ) + ), ) commands = [ "configure terminal", @@ -310,10 +310,10 @@ def test_nxos_static_routes_deleteddest(self): dict( vrf="test", address_families=[dict(afi="ipv4", routes=[dict(dest="192.0.2.96/28")])], - ) + ), ], state="deleted", - ) + ), ) commands = [ "vrf context test", @@ -338,16 +338,16 @@ def test_nxos_static_routes_deletedroute(self): forward_router_address="2001:db8::1001", route_name="ipv6_route", admin_distance=3, - ) + ), ], - ) + ), ], - ) + ), ], - ) + ), ], state="deleted", - ) + ), ) commands = [ "vrf context test", @@ -372,16 +372,16 @@ def test_nxos_static_routes_rendered(self): forward_router_address="2048:ae12::/64", interface="Eth1/4", admin_distance=5, - ) + ), ], - ) + ), ], - ) + ), ], - ) + ), ], state="rendered", - ) + ), ) commands = [ "vrf context testvrf", @@ -398,7 +398,7 @@ def test_nxos_static_routes_parsed(self): 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""", state="parsed", - ) + ), ) result = self.execute_module(changed=False) compare_list = [ @@ -413,9 +413,9 @@ def test_nxos_static_routes_parsed(self): { "dest_vrf": "dest_vrf", "forward_router_address": "192.0.2.122", - } + }, ], - } + }, ], "afi": "ipv4", }, @@ -428,9 +428,9 @@ def test_nxos_static_routes_parsed(self): "route_name": "ipv6_route", "forward_router_address": "2001:db8::1001", "admin_distance": 3, - } + }, ], - } + }, ], "afi": "ipv6", }, @@ -446,13 +446,13 @@ def test_nxos_static_routes_parsed(self): { "route_name": "initial_route", "forward_router_address": "192.0.2.24", - } + }, ], - } + }, ], "afi": "ipv4", - } - ] + }, + ], }, ] self.assertEqual(result["parsed"], compare_list, result["parsed"]) @@ -472,9 +472,9 @@ def test_nxos_static_routes_gathered(self): { "dest_vrf": "dest_vrf", "forward_router_address": "192.0.2.122", - } + }, ], - } + }, ], "afi": "ipv4", }, @@ -487,9 +487,9 @@ def test_nxos_static_routes_gathered(self): "route_name": "ipv6_route", "forward_router_address": "2001:db8::1001", "admin_distance": 3, - } + }, ], - } + }, ], "afi": "ipv6", }, @@ -505,13 +505,13 @@ def test_nxos_static_routes_gathered(self): { "route_name": "initial_route", "forward_router_address": "192.0.2.24", - } + }, ], - } + }, ], "afi": "ipv4", - } - ] + }, + ], }, ] self.assertEqual(result["gathered"], compare_list, result["gathered"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_system.py b/tests/unit/modules/network/nxos/test_nxos_system.py index 41367cb1b..f8744d109 100644 --- a/tests/unit/modules/network/nxos/test_nxos_system.py +++ b/tests/unit/modules/network/nxos/test_nxos_system.py @@ -37,12 +37,12 @@ def setUp(self): super(TestNxosSystemModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_system.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_system.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_system.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_system.load_config", ) self.load_config = self.mock_load_config.start() @@ -87,8 +87,8 @@ def test_nxos_system_domain_name_vrf_only(self): domain_name=[ {"name": "abc.com", "vrf": "test"}, {"name": "xyz.com", "vrf": "test2"}, - ] - ) + ], + ), ) commands = [] self.execute_module(changed=False, commands=commands, device="vrf_only") diff --git a/tests/unit/modules/network/nxos/test_nxos_telemetry.py b/tests/unit/modules/network/nxos/test_nxos_telemetry.py index 58374aaee..199af8e9b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_telemetry.py +++ b/tests/unit/modules/network/nxos/test_nxos_telemetry.py @@ -55,32 +55,32 @@ def setUp(self): super(TestNxosTelemetryModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.telemetry.telemetry.Telemetry.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.telemetry.telemetry.Telemetry.edit_config", ) self.edit_config = self.mock_edit_config.start() self.mock_execute_show_command = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.execute_show_command" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.execute_show_command", ) self.execute_show_command = self.mock_execute_show_command.start() self.mock_get_platform_shortname = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.get_platform_shortname" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos.NxosCmdRef.get_platform_shortname", ) self.get_platform_shortname = self.mock_get_platform_shortname.start() @@ -118,7 +118,7 @@ def test_tms_global_merged_n9k(self): compression="gzip", source_interface="Ethernet2/1", vrf="blue", - ) + ), ), ignore_provider_arg, ) @@ -200,7 +200,7 @@ def test_tms_global_idempotent_n9k(self): compression="gzip", source_interface="loopback55", vrf="management", - ) + ), ), ignore_provider_arg, ) @@ -222,7 +222,7 @@ def test_tms_global_change_cert_n9k(self): compression="gzip", source_interface="loopback55", vrf="management", - ) + ), ), ignore_provider_arg, ) @@ -250,7 +250,7 @@ def test_tms_global_change_interface_n9k(self): compression="gzip", source_interface="Ethernet8/1", vrf="management", - ) + ), ), ignore_provider_arg, ) @@ -279,7 +279,7 @@ def test_tms_global_change_several_n9k(self): compression="gzip", source_interface="Ethernet8/1", vrf="blue", - ) + ), ), ignore_provider_arg, ) @@ -310,8 +310,8 @@ def test_tms_destgroup_input_validation_1(self): "port": "5001", "protocol": "GRPC", "encoding": "GPB", - } - } + }, + }, ], "destination_groups", ) @@ -332,7 +332,7 @@ def test_tms_destgroup_input_validation_2(self): self.execute_module() testdata = errinfo.value.args[0] assert "Parameter under must be a dict" in str( - testdata["msg"] + testdata["msg"], ) assert testdata["failed"] @@ -427,7 +427,7 @@ def test_tms_destgroup_checkmode_n9k(self): "protocol": "GRPC", "encoding": "GPB", }, - } + }, ], "destination_groups", state="merged", @@ -477,7 +477,7 @@ def test_tms_destgroup_idempotent_n9k(self): "protocol": "grpc", "encoding": "gpb", }, - } + }, ], "destination_groups", ) @@ -702,7 +702,7 @@ def test_tms_sensorgroup_input_validation_1(self): "query_condition": "query_condition_xyz", "filter_condition": "filter_condition_xyz", }, - } + }, ], "sensor_groups", ) @@ -727,7 +727,7 @@ def test_tms_sensorgroup_input_validation_2(self): "query_condition": "query_condition_xyz", "filter_condition": "filter_condition_xyz", }, - } + }, ], "sensor_groups", ) @@ -781,7 +781,7 @@ def test_tms_sensorgroup_merged_variable_args2_n9k(self): "id": "77", "data_source": "DME", "path": {"name": "sys/bgp", "depth": 0}, - } + }, ], "sensor_groups", ) @@ -812,7 +812,7 @@ def test_tms_sensorgroup_merged_variable_args3_n9k(self): "depth": 0, "query_condition": "query_condition_xyz", }, - } + }, ], "sensor_groups", ) @@ -843,7 +843,7 @@ def test_tms_sensorgroup_merged_variable_args4_n9k(self): "depth": 0, "filter_condition": "filter_condition_xyz", }, - } + }, ], "sensor_groups", ) @@ -875,7 +875,7 @@ def test_tms_sensorgroup_merged_idempotent_n9k(self): "query_condition": "qc", "filter_condition": "fc", }, - } + }, ], "sensor_groups", ) @@ -930,9 +930,9 @@ def test_tms_sensorgroup_idempotent_variable1_n9k(self): "id": "2", "data_source": "DME", "path": { - "name": "sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]" + "name": "sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]", }, - } + }, ], "sensor_groups", ) @@ -949,7 +949,7 @@ def test_tms_sensorgroup_idempotent_variable2_n9k(self): "id": "2", "data_source": "DME", "path": {"name": "boo", "depth": 0}, - } + }, ], "sensor_groups", ) @@ -975,7 +975,7 @@ def test_tms_sensorgroup_present_path_environment_n9k(self): "id": "77", "data_source": "YANG", "path": {"name": "environment"}, - } + }, ], "sensor_groups", ) @@ -1002,7 +1002,7 @@ def test_tms_sensorgroup_present_path_interface_n9k(self): "id": "77", "data_source": "NATIVE", "path": {"name": "interface"}, - } + }, ], "sensor_groups", ) @@ -1029,7 +1029,7 @@ def test_tms_sensorgroup_present_path_interface_n9k(self): "id": "77", "data_source": "NX-API", "path": {"name": "resources"}, - } + }, ], "sensor_groups", ) @@ -1546,7 +1546,7 @@ def test_tms_replaced3_n9k(self): "protocol": "GRPC", "encoding": "GPB", }, - } + }, ], "sensor_groups": [ { @@ -1558,7 +1558,7 @@ def test_tms_replaced3_n9k(self): "query_condition": "query_condition_xyz", "filter_condition": "filter_condition_xyz", }, - } + }, ], "subscriptions": [ { @@ -1701,13 +1701,13 @@ def test_tms_replaced_idempotent_n9k(self): { "id": 2, "path": { - "name": "sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]" + "name": "sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]", }, }, { "id": 2, "path": { - "name": "sys/bgp/inst/dom-default/peer-[20.20.20.11]/ent-[20.20.20.11]" + "name": "sys/bgp/inst/dom-default/peer-[20.20.20.11]/ent-[20.20.20.11]", }, }, { @@ -1762,7 +1762,7 @@ def test_telemetry_gathered(self): destination-group 2 ip address 192.168.0.1 port 50001 protocol gRPC encoding GPB ip address 192.168.0.2 port 60001 protocol gRPC encoding GPB - """ + """, ) self.get_platform_shortname.return_value = "N9K" set_module_args(dict(state="gathered"), ignore_provider_arg) diff --git a/tests/unit/modules/network/nxos/test_nxos_user.py b/tests/unit/modules/network/nxos/test_nxos_user.py index d85456270..91942320f 100644 --- a/tests/unit/modules/network/nxos/test_nxos_user.py +++ b/tests/unit/modules/network/nxos/test_nxos_user.py @@ -39,22 +39,22 @@ def setUp(self): super(TestNxosUserModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_user.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_user.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_user.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_user.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_user.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_user.get_config", ) self.get_config = self.mock_get_config.start() self.mock_get_device_info = patch( - "ansible_collections.cisco.nxos.plugins.cliconf.nxos.Cliconf.get_device_info" + "ansible_collections.cisco.nxos.plugins.cliconf.nxos.Cliconf.get_device_info", ) self.get_device_info = self.mock_get_device_info.start() @@ -81,9 +81,9 @@ def test_mds(self): "expire_date": "this user account has no expiry date", "TABLE_role": {"ROW_role": [{"role": "priv-10"}]}, }, - ] - } - } + ], + }, + }, ] self.get_device_info.return_value = { "network_os": "nxos", diff --git a/tests/unit/modules/network/nxos/test_nxos_vlan.py b/tests/unit/modules/network/nxos/test_nxos_vlan.py index a69ddd7d0..403e265ce 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vlan.py +++ b/tests/unit/modules/network/nxos/test_nxos_vlan.py @@ -38,22 +38,22 @@ def setUp(self): super(TestNxosVlanModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.get_config", ) self.get_config = self.mock_get_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = { @@ -102,8 +102,8 @@ def test_nxos_vlan_agg_1(self): aggregate=[ {"name": "_5_", "vlan_id": 5}, {"name": "_6_", "vlan_id": 6}, - ] - ) + ], + ), ) self.execute_module( changed=True, @@ -123,8 +123,8 @@ def test_nxos_vlan_agg_2(self): aggregate=[ {"name": "_5_", "vlan_id": 5}, {"name": "_4_", "vlan_id": 4}, - ] - ) + ], + ), ) self.execute_module(changed=False) @@ -137,7 +137,7 @@ def test_nxos_vlan_agg_3(self): {"name": "_6_", "vlan_id": 6}, ], purge=True, - ) + ), ) self.execute_module( changed=True, @@ -158,8 +158,8 @@ def test_nxos_vlan_agg_4(self): aggregate=[ {"name": "_5_", "vlan_id": 5}, {"name": "_4_", "vlan_id": 4}, - ] - ) + ], + ), ) self.execute_module(changed=False) @@ -229,7 +229,7 @@ def test_nxos_vlan_no_change(self): name="default", vlan_state="active", admin_state="up", - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) diff --git a/tests/unit/modules/network/nxos/test_nxos_vlans.py b/tests/unit/modules/network/nxos/test_nxos_vlans.py index 1b8fede1a..2afceacdd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vlans.py +++ b/tests/unit/modules/network/nxos/test_nxos_vlans.py @@ -45,32 +45,32 @@ def setUp(self): super(TestNxosVlansModule, self).setUp() self.mock_FACT_LEGACY_SUBSETS = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts.FACT_LEGACY_SUBSETS", ) self.FACT_LEGACY_SUBSETS = self.mock_FACT_LEGACY_SUBSETS.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "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" + "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.vlans.vlans.Vlans.edit_config" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.vlans.vlans.Vlans.edit_config", ) self.edit_config = self.mock_edit_config.start() self.mock_get_device_data = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.vlans.vlans.VlansFacts.get_device_data" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.vlans.vlans.VlansFacts.get_device_data", ) self.get_device_data = self.mock_get_device_data.start() self.mock_get_platform = patch( - "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.vlans.vlans.Vlans.get_platform" + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.vlans.vlans.Vlans.get_platform", ) self.get_platform = self.mock_get_platform.start() @@ -127,9 +127,9 @@ def test_1(self): dict(vlan_id=4), dict(vlan_id=5, mapped_vni=555, mode="ce"), dict(vlan_id=7, mapped_vni=777, name="test-vlan7", enabled=False), - dict(vlan_id="8", state="active", name="test-changeme-not") + dict(vlan_id="8", state="active", name="test-changeme-not"), # vlan 3 is not present in playbook. - ] + ], ) merged = [ @@ -274,7 +274,7 @@ def test_5(self): state="suspend", enabled=False, ), - ] + ], ) playbook["state"] = "merged" diff --git a/tests/unit/modules/network/nxos/test_nxos_vpc.py b/tests/unit/modules/network/nxos/test_nxos_vpc.py index 225e0b25e..fec32d618 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vpc.py +++ b/tests/unit/modules/network/nxos/test_nxos_vpc.py @@ -36,17 +36,17 @@ def setUp(self): super(TestNxosVpcModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc.load_config", ) self.load_config = self.mock_load_config.start() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc.run_commands", ) self.run_commands = self.mock_run_commands.start() @@ -91,7 +91,7 @@ def test_nxos_vpc_present(self): pkl_src="10.1.100.20", peer_gw=True, auto_recovery=True, - ) + ), ) self.execute_module( changed=True, @@ -114,7 +114,7 @@ def test_nxos_vpc_vrf_1(self): pkl_dest="192.168.1.1", pkl_src="10.1.1.1", pkl_vrf="default", - ) + ), ) self.execute_module( changed=True, @@ -134,7 +134,7 @@ def test_nxos_vpc_vrf_2(self): pkl_dest="192.168.1.1", pkl_src="10.1.1.1", pkl_vrf="test-vrf", - ) + ), ) self.execute_module( changed=True, @@ -154,7 +154,7 @@ def test_nxos_vpc_vrf_3(self): domain=100, pkl_dest="192.168.1.1", pkl_vrf="obviously-different-vrf", - ) + ), ) self.execute_module( changed=True, @@ -188,7 +188,7 @@ def test_nxos_vpc_vrf_5(self): pkl_dest="192.168.1.1", pkl_src="10.1.1.1", pkl_vrf="my_vrf", - ) + ), ) self.execute_module(changed=False, device="_vrf_test") diff --git a/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py b/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py index 35010df48..6e5560b84 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py @@ -36,17 +36,17 @@ def setUp(self): super(TestNxosVpcModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc_interface.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc_interface.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc_interface.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc_interface.get_config", ) self.get_config = self.mock_get_config.start() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc_interface.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vpc_interface.run_commands", ) self.run_commands = self.mock_run_commands.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_vrf.py b/tests/unit/modules/network/nxos/test_nxos_vrf.py index 35092a1e6..602e57ca0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vrf.py +++ b/tests/unit/modules/network/nxos/test_nxos_vrf.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosVrfModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf.load_config", ) self.load_config = self.mock_load_config.start() self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf.run_commands" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf.run_commands", ) self.run_commands = self.mock_run_commands.start() diff --git a/tests/unit/modules/network/nxos/test_nxos_vrf_af.py b/tests/unit/modules/network/nxos/test_nxos_vrf_af.py index 86d7b5662..2df95473c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vrf_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_vrf_af.py @@ -36,17 +36,17 @@ def setUp(self): super(TestNxosVrfafModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.get_config", ) self.get_config = self.mock_get_config.start() self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.get_capabilities" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vrf_af.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = {"device_info": {"network_os_platform": "N7K-C7018"}} @@ -137,9 +137,9 @@ def test_nxos_vrf_af_route_target_import_present_current_non_existing( "rt": "65000:1000", "direction": "import", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -159,7 +159,7 @@ def test_nxos_vrf_af_route_target_default_direction_present_current_non_existing vrf="vrf1", afi="ipv4", route_targets=[{"rt": "65000:1000", "state": "present"}], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -182,9 +182,9 @@ def test_nxos_vrf_af_route_target_import_present_current_existing(self): "rt": "65000:1000", "direction": "import", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -197,7 +197,7 @@ def test_nxos_vrf_af_route_target_default_direction_present_current_existing( vrf="vrf21", afi="ipv4", route_targets=[{"rt": "65000:1000", "state": "present"}], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -226,7 +226,7 @@ def test_nxos_vrf_af_route_target_multi_import_present_current_non_existing( "state": "present", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -264,7 +264,7 @@ def test_nxos_vrf_af_route_target_multi_import_present_current_existing( "state": "present", }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -279,9 +279,9 @@ def test_nxos_vrf_af_route_target_import_absent_current_non_existing(self): "rt": "65000:1000", "direction": "import", "state": "absent", - } + }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -296,9 +296,9 @@ def test_nxos_vrf_af_route_target_import_absent_current_existing(self): "rt": "65000:1000", "direction": "import", "state": "absent", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -334,7 +334,7 @@ def test_nxos_vrf_af_route_target_multi_import_absent_current_non_existing( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -363,7 +363,7 @@ def test_nxos_vrf_af_route_target_multi_import_absent_current_existing( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -409,7 +409,7 @@ def test_nxos_vrf_af_route_target_multi_import_absent_current_mix(self): "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -434,9 +434,9 @@ def test_nxos_vrf_af_route_target_export_present_current_non_existing( "rt": "65000:1000", "direction": "export", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -458,9 +458,9 @@ def test_nxos_vrf_af_route_target_export_present_current_existing(self): "rt": "65000:1000", "direction": "export", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -489,7 +489,7 @@ def test_nxos_vrf_af_route_target_multi_export_present_current_non_existing( "state": "present", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -527,7 +527,7 @@ def test_nxos_vrf_af_route_target_multi_export_present_current_existing( "state": "present", }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -542,9 +542,9 @@ def test_nxos_vrf_af_route_target_export_absent_current_non_existing(self): "rt": "65000:1000", "direction": "export", "state": "absent", - } + }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -559,9 +559,9 @@ def test_nxos_vrf_af_route_target_export_absent_current_existing(self): "rt": "65000:1000", "direction": "export", "state": "absent", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -597,7 +597,7 @@ def test_nxos_vrf_af_route_target_multi_export_absent_current_non_existing( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -626,7 +626,7 @@ def test_nxos_vrf_af_route_target_multi_export_absent_current_existing( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -672,7 +672,7 @@ def test_nxos_vrf_af_route_target_multi_export_absent_current_mix(self): "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -695,9 +695,9 @@ def test_nxos_vrf_af_route_target_both_present_current_non_existing(self): "rt": "65000:1000", "direction": "both", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -720,9 +720,9 @@ def test_nxos_vrf_af_route_target_both_present_current_existing(self): "rt": "65000:1000", "direction": "both", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -751,7 +751,7 @@ def test_nxos_vrf_af_route_target_multi_both_present_current_non_existing( "state": "present", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -792,7 +792,7 @@ def test_nxos_vrf_af_route_target_multi_both_present_current_existing( "state": "present", }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -807,9 +807,9 @@ def test_nxos_vrf_af_route_target_both_absent_current_non_existing(self): "rt": "65000:1000", "direction": "both", "state": "absent", - } + }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -824,9 +824,9 @@ def test_nxos_vrf_af_route_target_both_absent_current_existing(self): "rt": "65000:1000", "direction": "both", "state": "absent", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -863,7 +863,7 @@ def test_nxos_vrf_af_route_target_multi_both_absent_current_non_existing( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -890,7 +890,7 @@ def test_nxos_vrf_af_route_target_multi_both_absent_current_existing(self): "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -939,7 +939,7 @@ def test_nxos_vrf_af_route_target_multi_both_absent_current_mix(self): "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -983,7 +983,7 @@ def test_nxos_vrf_af_route_target_multi_both_current_only_import_or_export( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -1023,7 +1023,7 @@ def test_nxos_vrf_af_route_target_multi_direction_current_only_import_or_export( "state": "absent", }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -1048,9 +1048,9 @@ def test_nxos_vrf_af_auto_evpn_route_target_and_manual_route_target(self): "rt": "65000:1000", "direction": "both", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -1078,9 +1078,9 @@ def test_nxos_vrf_af_auto_evpn_route_target_and_manual_route_targets_with_absent "rt": "65000:1000", "direction": "both", "state": "present", - } + }, ], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -1095,7 +1095,7 @@ def test_nxos_vrf_af_both_auto_N9K(self): vrf="v2000", afi="ipv4", route_targets=[{"rt": "auto", "direction": "both", "state": "present"}], - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py index a4f4fe8af..e0c419f5e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosVxlanVtepVniModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep.get_config", ) self.get_config = self.mock_get_config.start() @@ -82,7 +82,7 @@ def test_nxos_vxlan_vtep_multisite(self): dict( interface="nve1", multisite_border_gateway_interface="Loopback10", - ) + ), ) self.execute_module( changed=True, @@ -98,6 +98,6 @@ def test_nxos_vxlan_vtep_multisite_exists(self): dict( interface="nve1", multisite_border_gateway_interface="Loopback1", - ) + ), ) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py index eccb86dbc..2f626d9c3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py @@ -36,12 +36,12 @@ def setUp(self): super(TestNxosVxlanVtepVniModule, self).setUp() self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep_vni.load_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep_vni.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep_vni.get_config" + "ansible_collections.cisco.nxos.plugins.modules.nxos_vxlan_vtep_vni.get_config", ) self.get_config = self.mock_get_config.start() @@ -76,7 +76,7 @@ def test_nxos_vxlan_vtep_vni_multi_ingress_repl(self): interface="nve1", vni=5000, multisite_ingress_replication="enable", - ) + ), ) commands = [ "interface nve1", @@ -92,7 +92,7 @@ def test_nxos_vxlan_vtep_vni_multi_ingress_repl_opt(self): interface="nve1", vni=5000, multisite_ingress_replication="optimized", - ) + ), ) commands = [ "interface nve1", @@ -108,6 +108,6 @@ def test_nxos_vxlan_vtep_vni_multi_ingress_repl_opt_exists(self): interface="nve1", vni=6000, multisite_ingress_replication="optimized", - ) + ), ) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py index 54f145f36..cd3b7b05f 100644 --- a/tests/unit/modules/utils.py +++ b/tests/unit/modules/utils.py @@ -43,7 +43,9 @@ def fail_json(*args, **kwargs): class ModuleTestCase(unittest.TestCase): def setUp(self): self.mock_module = patch.multiple( - basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json + basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json, ) self.mock_module.start() self.mock_sleep = patch("time.sleep") From 675fdfda5cce9d774922fe11be92529b1e73c67b Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 2 Jun 2022 18:10:47 -0700 Subject: [PATCH 014/166] Switch to include_tasks (#520) * Switch to include_tasks * Changelog --- changelogs/fragments/520.yaml | 3 +++ .../targets/nxos_config/tasks/main.yaml | 4 ++-- .../targets/nxos_install_os/tasks/main.yaml | 4 ++-- .../upgrade/copy_kick_system_images.yaml | 2 +- .../tasks/upgrade/install_os.yaml | 10 ++++---- .../tasks/upgrade/main_os_install.yaml | 2 +- .../nxos_install_os/tests/common/upgrade.yaml | 8 +++---- .../common/upgrade_n3172_greensboro.yaml | 2 +- .../tests/common/upgrade_n3172_u61a.yaml | 2 +- .../tests/common/upgrade_n3172_u62a.yaml | 2 +- .../tests/common/upgrade_n3172_u63a.yaml | 2 +- .../tests/common/upgrade_n35_62a88.yaml | 2 +- .../tests/common/upgrade_n35_greensboro.yaml | 2 +- .../tests/common/upgrade_n5k_730_N11.yaml | 2 +- .../tests/common/upgrade_n5k_733_N11.yaml | 2 +- .../tests/common/upgrade_n7k_atherton.yaml | 2 +- .../tests/common/upgrade_n7k_helsinki.yaml | 2 +- .../tests/common/upgrade_n9k_greensboro.yaml | 2 +- .../common/upgrade_n9k_greensboro_force.yaml | 2 +- .../tests/common/upgrade_n9k_hamilton.yaml | 2 +- .../nxos_nxapi/tests/cli/configure.yaml | 24 +++++++++---------- .../tests/common/sanity.yaml | 4 ++-- .../targets/nxos_smoke/tasks/cli.yaml | 13 ++++++---- .../targets/nxos_smoke/tasks/nxapi.yaml | 4 +++- .../nxos_vxlan_vtep/tests/common/sanity.yaml | 4 ++-- .../tests/common/sanity.yaml | 4 ++-- 26 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 changelogs/fragments/520.yaml diff --git a/changelogs/fragments/520.yaml b/changelogs/fragments/520.yaml new file mode 100644 index 000000000..1c042cd90 --- /dev/null +++ b/changelogs/fragments/520.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Switch to include_task from bare include diff --git a/tests/integration/targets/nxos_config/tasks/main.yaml b/tests/integration/targets/nxos_config/tasks/main.yaml index 34b09ebba..955fcd112 100644 --- a/tests/integration/targets/nxos_config/tasks/main.yaml +++ b/tests/integration/targets/nxos_config/tasks/main.yaml @@ -11,11 +11,11 @@ tags: - nxapi - - ansible.builtin.include: cli_config.yaml + - ansible.builtin.include_tasks: cli_config.yaml tags: - cli_config - - ansible.builtin.include: redirection.yaml + - ansible.builtin.include_tasks: redirection.yaml when: ansible_version.full is version('2.10.0', '>=') always: - name: Change hostname back to {{ inventory_hostname_short }} diff --git a/tests/integration/targets/nxos_install_os/tasks/main.yaml b/tests/integration/targets/nxos_install_os/tasks/main.yaml index 5067603f0..20fd0eb71 100644 --- a/tests/integration/targets/nxos_install_os/tasks/main.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/main.yaml @@ -1,6 +1,6 @@ --- -- ansible.builtin.include: network_cli.yaml +- ansible.builtin.include_tasks: network_cli.yaml when: ansible_connection == 'ansible.netcommon.network_cli' -- ansible.builtin.include: httpapi.yaml +- ansible.builtin.include_tasks: httpapi.yaml when: ansible_connection == 'ansible.netcommon.httpapi' diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index 45b01d749..4b1da9cab 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -8,7 +8,7 @@ ignore_errors_httpapi: true when: ansible_connection == 'ansible.netcommon.httpapi' -- ansible.builtin.include: enable_scp_server.yaml +- ansible.builtin.include_tasks: enable_scp_server.yaml - name: Remove SSH known_hosts file before scp of image file ignore_errors: true # noqa ignore-errors diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml index 412d233e4..c38d89839 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml @@ -1,14 +1,16 @@ --- -- ansible.builtin.include: delete_files.yaml +- ansible.builtin.include_tasks: delete_files.yaml when: delete_files -- ansible.builtin.include: copy_kick_system_images.yaml ansible_connection=ansible.netcommon.network_cli connection={{ cli }} +- ansible.builtin.include_tasks: copy_kick_system_images.yaml + vars: + ansible_connection: ansible.netcommon.network_cli connection={{ cli }} when: copy_images -- ansible.builtin.include: install_with_kick.yaml +- ansible.builtin.include_tasks: install_with_kick.yaml when: ki is defined -- ansible.builtin.include: install_system.yaml +- ansible.builtin.include_tasks: install_system.yaml when: ki is undefined - name: Reset the connection diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml index b9da7285b..d5590278d 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml @@ -6,4 +6,4 @@ - name: End the play ansible.builtin.meta: end_play -- ansible.builtin.include: install_os.yaml +- ansible.builtin.include_tasks: install_os.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade.yaml index 0212cbaed..e4f02dd80 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade.yaml @@ -42,7 +42,7 @@ ki: n3000-uk9-kickstart.6.0.2.U6.1a.bin - name: Upgrade to u6.1a - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml - name: Set a fact for 'si' ansible.builtin.set_fact: @@ -53,7 +53,7 @@ ki: n3000-uk9-kickstart.6.0.2.U6.2a.bin - name: Upgrade to u6.2a - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml - name: Set a fact for 'si' ansible.builtin.set_fact: @@ -64,14 +64,14 @@ ki: n3000-s2-kickstart.8.0.1.bin - name: Upgrade to u6.3a - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml - name: Set a fact for 'si' ansible.builtin.set_fact: si: nxos.7.0.3.I7.2.bin - name: Upgrade to 7.0.3.i7.2 - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml - ansible.builtin.debug: msg: END connection={{ ansible_connection }} nxos_os_install upgrade diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml index e5d43344b..15c6748b5 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml @@ -38,4 +38,4 @@ si: nxos.7.0.3.I7.4.bin - name: Upgrade n3172 device to greensboro release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml index c3ea43dc3..b32be6e38 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml @@ -42,4 +42,4 @@ ki: n3000-uk9-kickstart.6.0.2.U6.1a.bin - name: Upgrade n3500 device to u61a release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml index 55fbf843c..3db45b719 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml @@ -42,4 +42,4 @@ ki: n3000-uk9-kickstart.6.0.2.U6.2a.bin - name: Upgrade n3500 device to u62a release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml index 0280b76f9..12c246fd6 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml @@ -42,4 +42,4 @@ ki: n3000-uk9-kickstart.6.0.2.U6.3a.bin - name: Upgrade n3500 device to u63a release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml index 670c6dee2..7ee9f0c6e 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml @@ -42,4 +42,4 @@ ki: n3500-uk9-kickstart.6.0.2.A8.8.bin - name: Upgrade n3500 device to a8_8 release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml index d5ff37113..4b997c8be 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml @@ -38,4 +38,4 @@ si: nxos.7.0.3.I7.4.bin - name: Upgrade n3500 device to greensboro release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml index 3bab0b296..b7405ec29 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml @@ -41,4 +41,4 @@ ki: n6000-uk9-kickstart.7.3.0.N1.1.bin - name: Upgrade N5K device to 7.3(0)n1(1) release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml index d79e33652..03e27f525 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml @@ -41,4 +41,4 @@ ki: n6000-uk9-kickstart.7.3.3.N1.1.bin - name: Upgrade N5K device to 7.3(3)n1(1) release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml index feea9c139..62507228b 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml @@ -41,4 +41,4 @@ ki: n7000-s2-kickstart.8.0.1.bin - name: Upgrade N7K device to atherton release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml index 134edce69..b8660ea1a 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml @@ -41,4 +41,4 @@ ki: n7000-s2-kickstart.7.3.0.D1.1.bin - name: Upgrade N7K device to helsinki release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml index bf9c1c93f..3da1fe5a2 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml @@ -47,4 +47,4 @@ si: nxos.7.0.3.I7.4.bin - name: Upgrade N9K device to greensboro release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml index 73369ad1f..3d8599c99 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro_force.yaml @@ -47,4 +47,4 @@ si: nxos.7.0.3.I7.4.bin - name: Upgrade N9K device to greensboro release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml index d1b3c66c4..304e26691 100644 --- a/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml +++ b/tests/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml @@ -45,4 +45,4 @@ si: nxos.9.2.1.bin - name: Upgrade N9K device to hamilton release image - ansible.builtin.include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml + ansible.builtin.include_tasks: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml diff --git a/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml b/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml index 990ab8e38..fb0f380fb 100644 --- a/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/cli/configure.yaml @@ -25,13 +25,13 @@ commands: - show nxapi | json - - ansible.builtin.include: tasks/platform/n7k/assert_changes_https.yaml + - ansible.builtin.include_tasks: tasks/platform/n7k/assert_changes_https.yaml when: platform is match('N7K') - - ansible.builtin.include: tasks/platform/n5k/assert_changes_https.yaml + - ansible.builtin.include_tasks: tasks/platform/n5k/assert_changes_https.yaml when: platform is search('N5K|N6K') - - ansible.builtin.include: tasks/platform/default/assert_changes_https.yaml + - ansible.builtin.include_tasks: tasks/platform/default/assert_changes_https.yaml when: platform is not search('N35|N5K|N6K|N7K') - name: Configure NX-API https again @@ -56,13 +56,13 @@ commands: - show nxapi | json - - ansible.builtin.include: tasks/platform/n7k/assert_changes_https_http.yaml + - ansible.builtin.include_tasks: tasks/platform/n7k/assert_changes_https_http.yaml when: platform is match('N7K') - - ansible.builtin.include: tasks/platform/n5k/assert_changes_https_http.yaml + - ansible.builtin.include_tasks: tasks/platform/n5k/assert_changes_https_http.yaml when: platform is match('N5K') - - ansible.builtin.include: tasks/platform/default/assert_changes_https_http.yaml + - ansible.builtin.include_tasks: tasks/platform/default/assert_changes_https_http.yaml when: platform is not search('N35|N5K|N6K|N7K') - name: Configure NX-API https & http again @@ -86,13 +86,13 @@ commands: - show nxapi | json - - ansible.builtin.include: tasks/platform/n7k/assert_changes_https_http_ports.yaml + - ansible.builtin.include_tasks: tasks/platform/n7k/assert_changes_https_http_ports.yaml when: platform is match('N7K') - - ansible.builtin.include: tasks/platform/n5k/assert_changes_https_http_ports.yaml + - ansible.builtin.include_tasks: tasks/platform/n5k/assert_changes_https_http_ports.yaml when: platform is match('N5K') - - ansible.builtin.include: tasks/platform/default/assert_changes_https_http_ports.yaml + - ansible.builtin.include_tasks: tasks/platform/default/assert_changes_https_http_ports.yaml when: platform is not search('N35|N5K|N6K|N7K') - name: Configure different NX-API https & http ports again @@ -114,13 +114,13 @@ commands: - show nxapi | json - - ansible.builtin.include: tasks/platform/n7k/assert_changes_http.yaml + - ansible.builtin.include_tasks: tasks/platform/n7k/assert_changes_http.yaml when: platform is match('N7K') - - ansible.builtin.include: tasks/platform/n5k/assert_changes_http.yaml + - ansible.builtin.include_tasks: tasks/platform/n5k/assert_changes_http.yaml when: platform is match('N5K') - - ansible.builtin.include: tasks/platform/default/assert_changes_http.yaml + - ansible.builtin.include_tasks: tasks/platform/default/assert_changes_http.yaml when: platform is not search('N35|N5K|N6K|N7K') - name: Configure NX-API http again diff --git a/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml b/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml index 2296290b5..6ad8399a0 100644 --- a/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_overlay_global/tests/common/sanity.yaml @@ -21,7 +21,7 @@ nv_overlay_evpn: true - name: Apply N7K specific setup configuration - ansible.builtin.include: tasks/platform/n7k/setup.yaml + ansible.builtin.include_tasks: tasks/platform/n7k/setup.yaml when: platform is match('N7K') - name: Configure additional N7K requiste features @@ -84,7 +84,7 @@ when: overlay_global_supported always: - name: Apply N7K specific cleanup configuration - ansible.builtin.include: tasks/platform/n7k/cleanup.yaml + ansible.builtin.include_tasks: tasks/platform/n7k/cleanup.yaml when: platform is match('N7K') - name: Disable NV overlay EVPN diff --git a/tests/integration/targets/nxos_smoke/tasks/cli.yaml b/tests/integration/targets/nxos_smoke/tasks/cli.yaml index ddee44927..1fa8d4e11 100644 --- a/tests/integration/targets/nxos_smoke/tasks/cli.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/cli.yaml @@ -39,12 +39,17 @@ # Temporarily disabling connection=local tests for CI issues # - name: run test cases (connection=local) -# include: "{{ test_case_to_run }} ansible_connection=local connection={{ cli }}" +# ansible.builtin.include_tasks: "{{ test_case_to_run }} +# vars: +# ansible_connection: local +# connection: "{{ cli }}" # with_items: "{{ test_items }}" # loop_control: # loop_var: test_case_to_run - name: Run test cases (connection=network_cli) - ansible.builtin.include: - "{{ role_path }}/tests/common/caching.yaml ansible_connection=ansible.netcommon.network_cli ansible_network_single_user_mode=True connection={{\ - \ 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/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml index 56f500768..f3a565f93 100644 --- a/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml @@ -32,7 +32,9 @@ connection: "{{ nxapi }}" # Temporarily disabling connection=local tests for CI issues # - name: run test cases (connection=local) -# include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}" +# ansible.builtin.include_tasks: "{{ test_case_to_run }} +# vars: +# ansible_connection: local connection={{ nxapi }} # with_items: "{{ test_items }}" # loop_control: # loop_var: test_case_to_run diff --git a/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml b/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml index 69e5e0f1d..11f53ed54 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml @@ -38,7 +38,7 @@ - block: - name: Apply N7K specific setup configuration - ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml + ansible.builtin.include_tasks: targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml when: platform is match('N7K') - name: Enable 'feature nv overlay' @@ -199,7 +199,7 @@ when: (platform is search("N7K|N9K")) always: - name: Apply N7K specific cleanup configuration - ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml + ansible.builtin.include_tasks: targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml when: platform is match('N7K') - name: Disable NV overlay EVPN diff --git a/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml index fa095fa5d..ac478b9a2 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vxlan_vtep_vni/tests/common/sanity.yaml @@ -4,7 +4,7 @@ - block: - name: Apply N7K specific setup configuration - ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml + ansible.builtin.include_tasks: targets/nxos_vxlan_vtep/tasks/platform/n7k/setup.yaml when: platform is match('N7K') - name: Enable 'feature nv overlay' @@ -230,7 +230,7 @@ when: (platform is search("N7K|N9K")) always: - name: Apply N7K specific cleanup configuration - ansible.builtin.include: targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml + ansible.builtin.include_tasks: targets/nxos_vxlan_vtep/tasks/platform/n7k/cleanup.yaml when: platform is match('N7K') - name: Remove vxlan_vtep From e3da876a2835610bc3a46fd9304fd651d3417ee2 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 7 Jun 2022 16:42:12 +0100 Subject: [PATCH 015/166] Fix two ansible-lint rules (#525) --- changelogs/changelog.yaml | 3 ++- galaxy.yml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index d4cd78675..5ba25a3a8 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -472,7 +472,8 @@ releases: major_changes: - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. - - Please refer to ansible.netcommon `changelog `_ + - Please refer to ansible.netcommon `changelog + `_ for more details. minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). diff --git a/galaxy.yml b/galaxy.yml index 76aec2b24..52b124b72 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -11,6 +11,6 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -# NOTE(pabelanger): We create an empty version key to keep ansible-galaxy +# NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: null +version: 0.0.0 From 08e9be9d149db9ec865e1aa73a88e12be06776b0 Mon Sep 17 00:00:00 2001 From: tin-ot <89586540+tin-ot@users.noreply.github.com> Date: Fri, 10 Jun 2022 10:40:18 +0200 Subject: [PATCH 016/166] [snmp_server] typo trap link (#527) Co-authored-by: Martin CARROUEE --- changelogs/fragments/snmp_server_526.yml | 3 +++ plugins/module_utils/network/nxos/rm_templates/snmp_server.py | 2 +- tests/unit/modules/network/nxos/test_nxos_snmp_server.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/snmp_server_526.yml diff --git a/changelogs/fragments/snmp_server_526.yml b/changelogs/fragments/snmp_server_526.yml new file mode 100644 index 000000000..9d58693ce --- /dev/null +++ b/changelogs/fragments/snmp_server_526.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`nxos_snmp_server` - Fix typo for traps link cisco-xcvr-mon-status-chg." diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index f131f5360..8615bb2c3 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -771,7 +771,7 @@ def __init__(self, lines=None, module=None): \slink\s(?Pcisco-xcvr-mon-status-chg) $""", re.VERBOSE, ), - "setval": "snmp-server enable traps link cisco_xcvr_mon_status_chg", + "setval": "snmp-server enable traps link cisco-xcvr-mon-status-chg", "result": { "traps": { "link": { diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 230f7c7e3..25e90e330 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -366,6 +366,7 @@ def test_nxos_snmp_server_traps_replaced(self): snmp-server enable traps bridge topologychange snmp-server enable traps callhome event-notify snmp-server enable traps callhome smtp-send-fail + snmp-server enable traps link cisco-xcvr-mon-status-chg """, ) set_module_args( @@ -375,6 +376,7 @@ def test_nxos_snmp_server_traps_replaced(self): aaa=dict(server_state_change=True), bridge=dict(enable=True), cfs=dict(merge_failure=True), + link=dict(cisco_xcvr_mon_status_chg=False), ), ), state="replaced", @@ -385,6 +387,7 @@ def test_nxos_snmp_server_traps_replaced(self): "no snmp-server enable traps callhome event-notify", "no snmp-server enable traps callhome smtp-send-fail", "snmp-server enable traps cfs merge-failure", + "no snmp-server enable traps link cisco-xcvr-mon-status-chg", ] result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) From 86107bdc3c82debbef44022d854c656ef179a8b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Jun 2022 18:11:46 +0530 Subject: [PATCH 017/166] [pre-commit.ci] pre-commit autoupdate (#528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.2.0 → v4.3.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.2.0...v4.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d521ca13f..e2fa2a397 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - id: check-merge-conflict - id: check-symlinks From df02bd3f27afa41cc62ca8a777c339656e732f7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:33:52 +0530 Subject: [PATCH 018/166] [pre-commit.ci] pre-commit autoupdate (#530) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v2.6.2 → v2.7.1](https://github.com/pre-commit/mirrors-prettier/compare/v2.6.2...v2.7.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e2fa2a397..db85876b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v2.6.2" + rev: "v2.7.1" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described From 8b325a7d6f2d5dc0e03cd9129f20dd49958f2097 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 27 Jun 2022 16:20:39 +0530 Subject: [PATCH 019/166] [file_copy] skip vrf for MDS targets (#531) * Skip vrf for MDS targets Signed-off-by: NilashishC * Address review comment Signed-off-by: NilashishC --- changelogs/fragments/filecopy_mds.yaml | 3 +++ docs/cisco.nxos.nxos_file_copy_module.rst | 3 ++- plugins/modules/nxos_file_copy.py | 24 +++++++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/filecopy_mds.yaml diff --git a/changelogs/fragments/filecopy_mds.yaml b/changelogs/fragments/filecopy_mds.yaml new file mode 100644 index 000000000..b130a6ca5 --- /dev/null +++ b/changelogs/fragments/filecopy_mds.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`nxos_file_copy` - Skip `vrf` when running against MDS switches (https://github.com/ansible-collections/cisco.nxos/issues/508)." diff --git a/docs/cisco.nxos.nxos_file_copy_module.rst b/docs/cisco.nxos.nxos_file_copy_module.rst index f5e4bebf1..c8632662d 100644 --- a/docs/cisco.nxos.nxos_file_copy_module.rst +++ b/docs/cisco.nxos.nxos_file_copy_module.rst @@ -526,7 +526,8 @@ Parameters Default:
"management"
-
The VRF used to pull the file. Useful when no vrf management is defined
+
The VRF used to pull the file. Useful when no vrf management is defined.
+
This option is not applicable for MDS switches.
diff --git a/plugins/modules/nxos_file_copy.py b/plugins/modules/nxos_file_copy.py index 13873a04c..05dfb9c69 100644 --- a/plugins/modules/nxos_file_copy.py +++ b/plugins/modules/nxos_file_copy.py @@ -157,7 +157,8 @@ type: str vrf: description: - - The VRF used to pull the file. Useful when no vrf management is defined + - The VRF used to pull the file. Useful when no vrf management is defined. + - This option is not applicable for MDS switches. default: management type: str """ @@ -236,10 +237,18 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_argument_spec -class FilePush: +class FileCopy: def __init__(self, module): self._module = module self._connection = get_resource_connection(self._module) + device_info = self._connection.get_device_info() + self._model = device_info.get("network_os_model", "") + self._platform = device_info.get("network_os_platform", "") + + +class FilePush(FileCopy): + def __init__(self, module): + super(FilePush, self).__init__(module) self.result = {} def md5sum_check(self, dst, file_system): @@ -348,10 +357,9 @@ def run(self): return self.result -class FilePull: +class FilePull(FileCopy): def __init__(self, module): - self._module = module - self._connection = get_resource_connection(self._module) + super(FilePull, self).__init__(module) self.result = {} def mkdir(self, directory): @@ -373,7 +381,11 @@ def copy_file_from_remote(self, local, local_file_directory, file_system): rfile = self._module.params["remote_file"] + " " if not rfile.startswith("/"): rfile = "/" + rfile - vrf = " vrf " + self._module.params["vrf"] + + if not self._platform.startswith("DS-") and "MDS" not in self._model: + vrf = " vrf " + self._module.params["vrf"] + else: + vrf = "" if self._module.params["file_pull_compact"]: compact = " compact " else: From 1213091c4006fd34149829ebc64da455c27c2ca2 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 28 Jun 2022 15:10:56 +0530 Subject: [PATCH 020/166] Update docs for MDS (#532) * Update docs for MDS Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC * More updates Signed-off-by: NilashishC * Update docs- --- changelogs/fragments/mds_docs.yaml | 3 + .../cisco.nxos.nxos_logging_global_module.rst | 8 +- docs/cisco.nxos.nxos_ntp_global_module.rst | 9 +- docs/cisco.nxos.nxos_snmp_server_module.rst | 35 ++++- plugins/modules/nxos_logging_global.py | 20 ++- plugins/modules/nxos_ntp_global.py | 24 +++- plugins/modules/nxos_snmp_server.py | 131 +++++++++++++----- 7 files changed, 183 insertions(+), 47 deletions(-) create mode 100644 changelogs/fragments/mds_docs.yaml diff --git a/changelogs/fragments/mds_docs.yaml b/changelogs/fragments/mds_docs.yaml new file mode 100644 index 000000000..268ec4d5e --- /dev/null +++ b/changelogs/fragments/mds_docs.yaml @@ -0,0 +1,3 @@ +--- +doc_changes: + - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global modules to reflect which options are unsupported on MDS switches. diff --git a/docs/cisco.nxos.nxos_logging_global_module.rst b/docs/cisco.nxos.nxos_logging_global_module.rst index 4e2a90216..ba49b2331 100644 --- a/docs/cisco.nxos.nxos_logging_global_module.rst +++ b/docs/cisco.nxos.nxos_logging_global_module.rst @@ -544,6 +544,7 @@ Parameters
Display per-VRF information.
+
This option is unsupported on MDS switches.
@@ -561,6 +562,7 @@ Parameters
IP configuration.
+
This option is unsupported on MDS switches.
@@ -770,6 +772,7 @@ Parameters
Set persistent logging utilization alert threshold in percentage.
+
This option is unsupported on MDS switches.
@@ -1082,6 +1085,7 @@ Parameters
Set RFC to which messages should compliant.
Syslogs will be compliant to RFC 5424.
+
This option is unsupported on MDS switches.
@@ -1098,6 +1102,7 @@ Parameters
Enable Source-Interface for Remote Syslog Server.
+
This option is unsupported on MDS switches.
@@ -1173,9 +1178,10 @@ Notes ----- .. note:: - - Tested against NX-OS 9.3.6. + - Tested against NX-OS 9.3.6 on Cisco Nexus Switches. - Limited Support for Cisco MDS - This module works with connection ``network_cli`` and ``httpapi``. + - Tested against Cisco MDS NX-OS 9.2(2) with connection ``network_cli``. diff --git a/docs/cisco.nxos.nxos_ntp_global_module.rst b/docs/cisco.nxos.nxos_ntp_global_module.rst index c6b54dea1..76d81c6a3 100644 --- a/docs/cisco.nxos.nxos_ntp_global_module.rst +++ b/docs/cisco.nxos.nxos_ntp_global_module.rst @@ -62,6 +62,7 @@ Parameters
NTP access-group.
+
This option is unsupported on MDS switches.
@@ -432,6 +433,7 @@ Parameters
Act as NTP master clock.
+
This option is unsupported on MDS switches.
@@ -470,6 +472,7 @@ Parameters
NTP passive command.
+
This option is unsupported on MDS switches.
@@ -595,6 +598,7 @@ Parameters
Display per-VRF information.
+
This option is unsupported on MDS switches.

aliases: use_vrf
@@ -722,6 +726,7 @@ Parameters
Display per-VRF information.
+
This option is not applicable for MDS switches.

aliases: use_vrf
@@ -740,6 +745,7 @@ Parameters
Source of NTP packets.
+
This option is unsupported on MDS switches.
@@ -845,8 +851,9 @@ Notes ----- .. note:: - - Tested against NX-OS 9.3.6. + - Tested against NX-OS 9.3.6 on Cisco Nexus Switches. - This module works with connection ``network_cli`` and ``httpapi``. + - Tested against Cisco MDS NX-OS 9.2(2) with connection ``network_cli``. diff --git a/docs/cisco.nxos.nxos_snmp_server_module.rst b/docs/cisco.nxos.nxos_snmp_server_module.rst index 74912ec4c..1324c39a1 100644 --- a/docs/cisco.nxos.nxos_snmp_server_module.rst +++ b/docs/cisco.nxos.nxos_snmp_server_module.rst @@ -191,6 +191,7 @@ Parameters
Specify IPv4 ACL, the ACL name specified must be IPv4 ACL.
+
This option is unsupported on MDS switches.
@@ -208,6 +209,7 @@ Parameters
Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL.
+
This option is unsupported on MDS switches.
@@ -309,6 +311,7 @@ Parameters
VRF associated with the SNMP context.
+
This option is unsupported on MDS switches.
@@ -326,6 +329,7 @@ Parameters
Configure port counter configuration.
+
This option is unsupported on MDS switches.
@@ -401,6 +405,7 @@ Parameters
Silently drop unknown v3 user packets.
+
This option is unsupported on MDS switches.
@@ -460,6 +465,7 @@ Parameters
Configure a local SNMPv3 engineID.
+
This option is unsupported on MDS switches.
@@ -567,6 +573,7 @@ Parameters
Filters notifications to the notification host receiver based on the configured VRF.
+
This option is unsupported on MDS switches.
@@ -694,6 +701,7 @@ Parameters
Configures SNMP to use the selected VRF to communicate with the host receiver.
+
This option is unsupported on MDS switches.
@@ -874,6 +882,7 @@ Parameters
Source interface to be used for sending out SNMP notifications.
+
This option is unsupported on MDS switches.
@@ -987,6 +996,7 @@ Parameters
Enable tcp-session.
+
This option is unsupported on MDS switches.
@@ -1123,6 +1133,7 @@ Parameters
Bridge traps.
+
This option is unsupported on MDS switches.
@@ -1229,6 +1240,7 @@ Parameters
Enable callhome traps.
+
This option is unsupported on MDS switches.
@@ -1313,6 +1325,7 @@ Parameters
Enable cfs traps.
+
This option is unsupported on MDS switches.
@@ -1419,6 +1432,7 @@ Parameters
Enable config traps.
+
This option is unsupported on MDS switches.
@@ -1741,6 +1755,7 @@ Parameters
Enable feature-control traps.
+
This option is unsupported on MDS switches.
@@ -1825,6 +1840,7 @@ Parameters
Enable generic traps.
+
This option is unsupported on MDS switches.
@@ -1887,6 +1903,7 @@ Parameters
Enable license traps.
+
This option is unsupported on MDS switches.
@@ -2015,6 +2032,7 @@ Parameters
Err-disable state notification.
+
This option is unsupported on MDS switches.
@@ -2103,6 +2121,7 @@ Parameters
Mac addr move trap.
+
This option is unsupported on MDS switches.
@@ -2147,6 +2166,7 @@ Parameters
Enable link traps.
+
This option is unsupported on MDS switches.
@@ -2253,6 +2273,7 @@ Parameters
MMode traps.
+
This option is unsupported on MDS switches.
@@ -2439,6 +2460,7 @@ Parameters
Enable rf traps.
+
This option is unsupported on MDS switches.
@@ -2501,6 +2523,7 @@ Parameters
Enable rmon traps.
+
This option is unsupported on MDS switches.
@@ -2651,6 +2674,7 @@ Parameters
Enable snmp traps.
+
This option is unsupported on MDS switches.
@@ -2691,6 +2715,7 @@ Parameters
Port-Storm-Control-Event.
+
This option is unsupported on MDS switches.
@@ -2713,6 +2738,7 @@ Parameters
Enable storm-control traps.
+
This option is unsupported on MDS switches.
@@ -2753,6 +2779,7 @@ Parameters
Stpx traps.
+
This option is unsupported on MDS switches.
@@ -2881,6 +2908,7 @@ Parameters
Enable syslog traps.
+
This option is unsupported on MDS switches.
@@ -2965,6 +2993,7 @@ Parameters
Enable sysmgr traps.
+
This option is unsupported on MDS switches.
@@ -3027,6 +3056,7 @@ Parameters
Enable system traps.
+
This option is unsupported on MDS switches.
@@ -3067,6 +3097,7 @@ Parameters
Enable upgrade traps.
+
This option is unsupported on MDS switches.
@@ -3129,6 +3160,7 @@ Parameters
VTP traps.
+
This option is unsupported on MDS switches.
@@ -3612,8 +3644,9 @@ Notes ----- .. note:: - - Tested against NX-OS 9.3.6. + - Tested against NX-OS 9.3.6 on Cisco Nexus Switches. - This module works with connection ``network_cli`` and ``httpapi``. + - Tested against Cisco MDS NX-OS 9.2(2) with connection ``network_cli``. diff --git a/plugins/modules/nxos_logging_global.py b/plugins/modules/nxos_logging_global.py index 7e0e0493d..1c060b01b 100644 --- a/plugins/modules/nxos_logging_global.py +++ b/plugins/modules/nxos_logging_global.py @@ -20,9 +20,10 @@ - This module manages logging configuration on devices running Cisco NX-OS. version_added: 2.5.0 notes: -- Tested against NX-OS 9.3.6. +- Tested against NX-OS 9.3.6 on Cisco Nexus Switches. - Limited Support for Cisco MDS - This module works with connection C(network_cli) and C(httpapi). +- Tested against Cisco MDS NX-OS 9.2(2) with connection C(network_cli). author: Nilashish Chakraborty (@NilashishC) options: running_config: @@ -85,7 +86,9 @@ description: Set history table size. type: int ip: - description: IP configuration. + description: + - IP configuration. + - This option is unsupported on MDS switches. type: dict suboptions: access_list: @@ -137,7 +140,9 @@ type: str severity: *sev persistent_threshold: - description: Set persistent logging utilization alert threshold in percentage. + description: + - Set persistent logging utilization alert threshold in percentage. + - This option is unsupported on MDS switches. type: int size: description: Enter the logfile size in bytes. @@ -187,6 +192,7 @@ description: - Set RFC to which messages should compliant. - Syslogs will be compliant to RFC 5424. + - This option is unsupported on MDS switches. type: bool hosts: description: Enable forwarding to Remote Syslog Servers. @@ -217,10 +223,14 @@ - Trustpoint to use for client certificate authentication. type: str use_vrf: - description: Display per-VRF information. + description: + - Display per-VRF information. + - This option is unsupported on MDS switches. type: str source_interface: - description: Enable Source-Interface for Remote Syslog Server. + description: + - Enable Source-Interface for Remote Syslog Server. + - This option is unsupported on MDS switches. type: str timestamp: description: Set logging timestamp granularity. diff --git a/plugins/modules/nxos_ntp_global.py b/plugins/modules/nxos_ntp_global.py index 50a0cbd21..e99fbef83 100644 --- a/plugins/modules/nxos_ntp_global.py +++ b/plugins/modules/nxos_ntp_global.py @@ -20,8 +20,9 @@ - This module manages ntp configuration on devices running Cisco NX-OS. version_added: 2.6.0 notes: -- Tested against NX-OS 9.3.6. +- Tested against NX-OS 9.3.6 on Cisco Nexus Switches. - This module works with connection C(network_cli) and C(httpapi). +- Tested against Cisco MDS NX-OS 9.2(2) with connection C(network_cli). author: Nilashish Chakraborty (@NilashishC) options: running_config: @@ -38,7 +39,9 @@ type: dict suboptions: access_group: - description: NTP access-group. + description: + - NTP access-group. + - This option is unsupported on MDS switches. type: dict suboptions: match_all: @@ -115,13 +118,16 @@ master: description: - Act as NTP master clock. + - This option is unsupported on MDS switches. type: dict suboptions: stratum: description: Stratum number. type: int passive: - description: NTP passive command. + description: + - NTP passive command. + - This option is unsupported on MDS switches. type: bool peers: description: NTP Peers. @@ -149,7 +155,9 @@ - Preferred Server. type: bool vrf: - description: Display per-VRF information. + description: + - Display per-VRF information. + - This option is unsupported on MDS switches. type: str aliases: ["use_vrf"] servers: @@ -178,11 +186,15 @@ - Preferred Server. type: bool vrf: - description: Display per-VRF information. + description: + - Display per-VRF information. + - This option is not applicable for MDS switches. type: str aliases: ["use_vrf"] source: - description: Source of NTP packets. + description: + - Source of NTP packets. + - This option is unsupported on MDS switches. type: str source_interface: description: Source interface sending NTP packets. diff --git a/plugins/modules/nxos_snmp_server.py b/plugins/modules/nxos_snmp_server.py index 1de2c84fe..7354dc1ee 100644 --- a/plugins/modules/nxos_snmp_server.py +++ b/plugins/modules/nxos_snmp_server.py @@ -20,8 +20,9 @@ - This module manages SNMP server configuration on devices running Cisco NX-OS. version_added: 2.8.0 notes: -- Tested against NX-OS 9.3.6. +- Tested against NX-OS 9.3.6 on Cisco Nexus Switches. - This module works with connection C(network_cli) and C(httpapi). +- Tested against Cisco MDS NX-OS 9.2(2) with connection C(network_cli). author: Nilashish Chakraborty (@NilashishC) options: running_config: @@ -63,10 +64,14 @@ description: Read-write access with this community string. type: bool use_ipv4acl: - description: Specify IPv4 ACL, the ACL name specified must be IPv4 ACL. + description: + - Specify IPv4 ACL, the ACL name specified must be IPv4 ACL. + - This option is unsupported on MDS switches. type: str use_ipv6acl: - description: Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL. + description: + - Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL. + - This option is unsupported on MDS switches. type: str contact: description: Modify sysContact. @@ -85,10 +90,14 @@ description: Topology associated with the SNMP context. type: str vrf: - description: VRF associated with the SNMP context. + description: + - VRF associated with the SNMP context. + - This option is unsupported on MDS switches. type: str counter: - description: Configure port counter configuration. + description: + - Configure port counter configuration. + - This option is unsupported on MDS switches. type: dict suboptions: cache: @@ -102,7 +111,9 @@ description: Timeout for which cached port stats exists(in secs). type: int drop: - description: Silently drop unknown v3 user packets. + description: + - Silently drop unknown v3 user packets. + - This option is unsupported on MDS switches. type: dict suboptions: unknown_engine_id: @@ -133,7 +144,9 @@ description: Enable SNMP BGP traps. type: bool bridge: - description: Bridge traps. + description: + - Bridge traps. + - This option is unsupported on MDS switches. type: dict suboptions: enable: @@ -150,7 +163,9 @@ type: dict suboptions: enable: - description: Enable callhome traps. + description: + - Enable callhome traps. + - This option is unsupported on MDS switches. type: bool event_notify: description: Callhome External Event Notification. @@ -163,7 +178,9 @@ type: dict suboptions: enable: - description: Enable cfs traps. + description: + - Enable cfs traps. + - This option is unsupported on MDS switches. type: bool merge_failure: description: Merge failure notification. @@ -176,7 +193,9 @@ type: dict suboptions: enable: - description: Enable config traps. + description: + - Enable config traps. + - This option is unsupported on MDS switches. type: bool ccmCLIRunningConfigChanged: description: Running config change trap. @@ -223,7 +242,9 @@ type: dict suboptions: enable: - description: Enable feature-control traps. + description: + - Enable feature-control traps. + - This option is unsupported on MDS switches. type: bool featureOpStatusChange: description: Feature operation status change notification. @@ -236,7 +257,9 @@ type: dict suboptions: enable: - description: Enable generic traps. + description: + - Enable generic traps. + - This option is unsupported on MDS switches. type: bool coldStart: description: Generic coldStart trap. @@ -249,7 +272,9 @@ type: dict suboptions: enable: - description: Enable license traps. + description: + - Enable license traps. + - This option is unsupported on MDS switches. type: bool notify_license_expiry: description: License Expiry Notification. @@ -268,10 +293,14 @@ type: dict suboptions: enable: - description: Enable link traps. + description: + - Enable link traps. + - This option is unsupported on MDS switches. type: bool cErrDisableInterfaceEventRev1: - description: Err-disable state notification. + description: + - Err-disable state notification. + - This option is unsupported on MDS switches. type: bool cieLinkDown: description: Cisco extended link state down notification. @@ -283,7 +312,9 @@ description: Cisco interface transceiver monitor status change notification. type: bool cmn_mac_move_notification: - description: Mac addr move trap. + description: + - Mac addr move trap. + - This option is unsupported on MDS switches. type: bool delayed_link_state_change: description: Delayed link state change. @@ -301,7 +332,9 @@ description: IETF Link state up notification. type: bool mmode: - description: MMode traps. + description: + - MMode traps. + - This option is unsupported on MDS switches. type: dict suboptions: enable: @@ -332,7 +365,9 @@ type: dict suboptions: enable: - description: Enable rf traps. + description: + - Enable rf traps. + - This option is unsupported on MDS switches. type: bool redundancy_framework: description: Redundancy_Framework (RF) Sup switchover MIB. @@ -342,7 +377,9 @@ type: dict suboptions: enable: - description: Enable rmon traps. + description: + - Enable rmon traps. + - This option is unsupported on MDS switches. type: bool fallingAlarm: description: Rmon falling alarm. @@ -361,7 +398,9 @@ type: dict suboptions: enable: - description: Enable snmp traps. + description: + - Enable snmp traps. + - This option is unsupported on MDS switches. type: bool authentication: description: SNMP authentication trap. @@ -371,16 +410,22 @@ type: dict suboptions: enable: - description: Enable storm-control traps. + description: + - Enable storm-control traps. + - This option is unsupported on MDS switches. type: bool cpscEventRev1: - description: Port-Storm-Control-Event. + description: + - Port-Storm-Control-Event. + - This option is unsupported on MDS switches. type: bool trap_rate: description: Number of traps per minute. type: bool stpx: - description: Stpx traps. + description: + - Stpx traps. + - This option is unsupported on MDS switches. type: dict suboptions: enable: @@ -400,7 +445,9 @@ type: dict suboptions: enable: - description: Enable syslog traps. + description: + - Enable syslog traps. + - This option is unsupported on MDS switches. type: bool message_generated: description: Message Generated Notification. @@ -410,7 +457,9 @@ type: dict suboptions: enable: - description: Enable sysmgr traps. + description: + - Enable sysmgr traps. + - This option is unsupported on MDS switches. type: bool cseFailSwCoreNotifyExtended: description: Software Core Notification. @@ -420,7 +469,9 @@ type: dict suboptions: enable: - description: Enable system traps. + description: + - Enable system traps. + - This option is unsupported on MDS switches. type: bool clock_change_notification: description: Clock-change-notification traps. @@ -430,7 +481,9 @@ type: dict suboptions: enable: - description: Enable upgrade traps. + description: + - Enable upgrade traps. + - This option is unsupported on MDS switches. type: bool upgradeJobStatusNotify: description: Upgrade Job Status Notification. @@ -439,7 +492,9 @@ description: Upgrade Global Status Notification. type: bool vtp: - description: VTP traps. + description: + - VTP traps. + - This option is unsupported on MDS switches. type: dict suboptions: enable: @@ -458,7 +513,9 @@ description: Enable vtpVlanDeleted notification. type: bool engine_id: - description: Configure a local SNMPv3 engineID. + description: + - Configure a local SNMPv3 engineID. + - This option is unsupported on MDS switches. type: dict suboptions: local: @@ -481,7 +538,9 @@ description: SNMP community string or SNMPv3 user name (Max Size 32). type: str filter_vrf: - description: Filters notifications to the notification host receiver based on the configured VRF. + description: + - Filters notifications to the notification host receiver based on the configured VRF. + - This option is unsupported on MDS switches. type: str informs: description: Send Inform messages to this host. @@ -493,7 +552,9 @@ description: Send Traps messages to this host. type: bool use_vrf: - description: Configures SNMP to use the selected VRF to communicate with the host receiver. + description: + - Configures SNMP to use the selected VRF to communicate with the host receiver. + - This option is unsupported on MDS switches. type: str version: description: SNMP version to use for notification messages. @@ -536,7 +597,9 @@ description: Enable/Disable snmp protocol operations. type: bool source_interface: - description: Source interface to be used for sending out SNMP notifications. + description: + - Source interface to be used for sending out SNMP notifications. + - This option is unsupported on MDS switches. type: dict suboptions: informs: @@ -553,7 +616,9 @@ type: dict suboptions: enable: - description: Enable tcp-session. + description: + - Enable tcp-session. + - This option is unsupported on MDS switches. type: bool auth: description: Enable one time authentication for snmp over tcp session. From 1216cbf40b6977b8aed5e1d391dbc83d3234ae9c Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 28 Jun 2022 18:03:12 +0530 Subject: [PATCH 021/166] Prepare for v3.1.0 (#533) * Prepare for v3.1.0 Signed-off-by: NilashishC * Update Signed-off-by: NilashishC * Update Signed-off-by: NilashishC * Fix ansible-lint issues Signed-off-by: NilashishC --- CHANGELOG.rst | 24 ++++++++- changelogs/changelog.yaml | 52 ++++++++++++++++++- changelogs/fragments/459.yaml | 3 -- changelogs/fragments/500.yaml | 3 -- changelogs/fragments/507.yaml | 3 -- changelogs/fragments/510.yaml | 3 -- changelogs/fragments/512.yaml | 3 -- changelogs/fragments/513.yaml | 3 -- changelogs/fragments/514.yaml | 3 -- changelogs/fragments/515.yaml | 3 -- changelogs/fragments/516.yaml | 3 -- changelogs/fragments/517.yaml | 3 -- changelogs/fragments/518.yaml | 3 -- changelogs/fragments/520.yaml | 3 -- changelogs/fragments/521.yaml | 3 -- changelogs/fragments/522.yaml | 3 -- changelogs/fragments/523.yaml | 3 -- changelogs/fragments/cleanup_1.yaml | 3 -- changelogs/fragments/file_copy.yaml | 3 -- changelogs/fragments/file_cp.yaml | 3 -- changelogs/fragments/filecopy_mds.yaml | 3 -- changelogs/fragments/include_prepare.yaml | 3 -- changelogs/fragments/include_test_case.yaml | 3 -- changelogs/fragments/mds_docs.yaml | 3 -- changelogs/fragments/ntp_global.yaml | 3 -- changelogs/fragments/nxos_interfaces.yaml | 3 -- changelogs/fragments/pre-commit.yaml | 3 -- changelogs/fragments/sanity.yaml | 3 -- changelogs/fragments/sanity_devel.yaml | 3 -- changelogs/fragments/set_fact_name.yaml | 3 -- changelogs/fragments/snmp_server.yaml | 3 -- changelogs/fragments/snmp_server_526.yml | 3 -- .../fragments/snmp_server_localized.yaml | 3 -- changelogs/fragments/unstyle_equal_debug.yaml | 3 -- 34 files changed, 73 insertions(+), 99 deletions(-) delete mode 100644 changelogs/fragments/459.yaml delete mode 100644 changelogs/fragments/500.yaml delete mode 100644 changelogs/fragments/507.yaml delete mode 100644 changelogs/fragments/510.yaml delete mode 100644 changelogs/fragments/512.yaml delete mode 100644 changelogs/fragments/513.yaml delete mode 100644 changelogs/fragments/514.yaml delete mode 100644 changelogs/fragments/515.yaml delete mode 100644 changelogs/fragments/516.yaml delete mode 100644 changelogs/fragments/517.yaml delete mode 100644 changelogs/fragments/518.yaml delete mode 100644 changelogs/fragments/520.yaml delete mode 100644 changelogs/fragments/521.yaml delete mode 100644 changelogs/fragments/522.yaml delete mode 100644 changelogs/fragments/523.yaml delete mode 100644 changelogs/fragments/cleanup_1.yaml delete mode 100644 changelogs/fragments/file_copy.yaml delete mode 100644 changelogs/fragments/file_cp.yaml delete mode 100644 changelogs/fragments/filecopy_mds.yaml delete mode 100644 changelogs/fragments/include_prepare.yaml delete mode 100644 changelogs/fragments/include_test_case.yaml delete mode 100644 changelogs/fragments/mds_docs.yaml delete mode 100644 changelogs/fragments/ntp_global.yaml delete mode 100644 changelogs/fragments/nxos_interfaces.yaml delete mode 100644 changelogs/fragments/pre-commit.yaml delete mode 100644 changelogs/fragments/sanity.yaml delete mode 100644 changelogs/fragments/sanity_devel.yaml delete mode 100644 changelogs/fragments/set_fact_name.yaml delete mode 100644 changelogs/fragments/snmp_server.yaml delete mode 100644 changelogs/fragments/snmp_server_526.yml delete mode 100644 changelogs/fragments/snmp_server_localized.yaml delete mode 100644 changelogs/fragments/unstyle_equal_debug.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f287a258b..c28cca909 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,28 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v3.1.0 +====== + +Minor Changes +------------- + +- `nxos_snmp_server` - Add support for localizedV2key (https://github.com/ansible-collections/cisco.nxos/issues/415). +- `nxos_snmp_server` - Add support for sha-256 based based user authentication. + +Bugfixes +-------- + +- `nxos_file_copy` - Skip `vrf` when running against MDS switches (https://github.com/ansible-collections/cisco.nxos/issues/508). +- `nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True (https://github.com/ansible-collections/cisco.nxos/issues/335). +- `nxos_ntp_global` - Ensure idempotence for aliased keys (https://github.com/ansible-collections/cisco.nxos/issues/484). +- `nxos_snmp_server` - Fix typo for traps link cisco-xcvr-mon-status-chg. + +Documentation Changes +--------------------- + +- Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global modules to reflect which options are unsupported on MDS switches. + v3.0.0 ====== @@ -298,8 +320,8 @@ v2.0.0 Major Changes ------------- -- Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. - Please refer to ansible.netcommon `changelog `_ for more details. +- Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. Minor Changes ------------- diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 5ba25a3a8..e40091983 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -470,11 +470,11 @@ releases: - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family resource module. major_changes: - - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` - and `ansible_network_import_modules`. - Please refer to ansible.netcommon `changelog `_ for more details. + - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` + and `ansible_network_import_modules`. minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). - Add hello_interval_ms option in nxos_pim_interface module to support sub-second @@ -799,3 +799,51 @@ releases: - snmp_server_PR444.yaml - stderr.yaml release_date: "2022-04-28" + 3.1.0: + changes: + bugfixes: + - "`nxos_file_copy` - Skip `vrf` when running against MDS switches (https://github.com/ansible-collections/cisco.nxos/issues/508)." + - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True + (https://github.com/ansible-collections/cisco.nxos/issues/335)." + - "`nxos_ntp_global` - Ensure idempotence for aliased keys (https://github.com/ansible-collections/cisco.nxos/issues/484)." + - "`nxos_snmp_server` - Fix typo for traps link cisco-xcvr-mon-status-chg." + doc_changes: + - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global + modules to reflect which options are unsupported on MDS switches. + minor_changes: + - "`nxos_snmp_server` - Add support for localizedV2key (https://github.com/ansible-collections/cisco.nxos/issues/415)." + - "`nxos_snmp_server` - Add support for sha-256 based based user authentication." + fragments: + - 459.yaml + - 500.yaml + - 507.yaml + - 510.yaml + - 512.yaml + - 513.yaml + - 514.yaml + - 515.yaml + - 516.yaml + - 517.yaml + - 518.yaml + - 520.yaml + - 521.yaml + - 522.yaml + - 523.yaml + - cleanup_1.yaml + - file_copy.yaml + - file_cp.yaml + - filecopy_mds.yaml + - include_prepare.yaml + - include_test_case.yaml + - mds_docs.yaml + - ntp_global.yaml + - nxos_interfaces.yaml + - pre-commit.yaml + - sanity.yaml + - sanity_devel.yaml + - set_fact_name.yaml + - snmp_server.yaml + - snmp_server_526.yml + - snmp_server_localized.yaml + - unstyle_equal_debug.yaml + release_date: "2022-06-28" diff --git a/changelogs/fragments/459.yaml b/changelogs/fragments/459.yaml deleted file mode 100644 index 2d667e470..000000000 --- a/changelogs/fragments/459.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Enable unit and sanity tests using Github actions diff --git a/changelogs/fragments/500.yaml b/changelogs/fragments/500.yaml deleted file mode 100644 index 90b5f9053..000000000 --- a/changelogs/fragments/500.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Undo `=` style formatting for set_fact tasks diff --git a/changelogs/fragments/507.yaml b/changelogs/fragments/507.yaml deleted file mode 100644 index e54054947..000000000 --- a/changelogs/fragments/507.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fixes line length, bools, and anchor/aliases diff --git a/changelogs/fragments/510.yaml b/changelogs/fragments/510.yaml deleted file mode 100644 index eb5a1d3e0..000000000 --- a/changelogs/fragments/510.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Switch to FQCN and ansible.builtin plugins diff --git a/changelogs/fragments/512.yaml b/changelogs/fragments/512.yaml deleted file mode 100644 index 9146f793f..000000000 --- a/changelogs/fragments/512.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Capitalize all task names diff --git a/changelogs/fragments/513.yaml b/changelogs/fragments/513.yaml deleted file mode 100644 index 77005db85..000000000 --- a/changelogs/fragments/513.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Add collections and .virl to .gitignore diff --git a/changelogs/fragments/514.yaml b/changelogs/fragments/514.yaml deleted file mode 100644 index 243b9b0b7..000000000 --- a/changelogs/fragments/514.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Uppercase acronyms, unabbreviated abbreviations, and quoted features diff --git a/changelogs/fragments/515.yaml b/changelogs/fragments/515.yaml deleted file mode 100644 index be7e07f60..000000000 --- a/changelogs/fragments/515.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Round trip with ruamel again, non task files diff --git a/changelogs/fragments/516.yaml b/changelogs/fragments/516.yaml deleted file mode 100644 index ed204becb..000000000 --- a/changelogs/fragments/516.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Enable concurrency check for PRs & GHA diff --git a/changelogs/fragments/517.yaml b/changelogs/fragments/517.yaml deleted file mode 100644 index bfe6c7e97..000000000 --- a/changelogs/fragments/517.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Add isort to pre-commit, increase black line length diff --git a/changelogs/fragments/518.yaml b/changelogs/fragments/518.yaml deleted file mode 100644 index e36d8543b..000000000 --- a/changelogs/fragments/518.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix errors reported by ansible-lint diff --git a/changelogs/fragments/520.yaml b/changelogs/fragments/520.yaml deleted file mode 100644 index 1c042cd90..000000000 --- a/changelogs/fragments/520.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Switch to include_task from bare include diff --git a/changelogs/fragments/521.yaml b/changelogs/fragments/521.yaml deleted file mode 100644 index 8a76a14f4..000000000 --- a/changelogs/fragments/521.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Enable trailing comma in pre-commit diff --git a/changelogs/fragments/522.yaml b/changelogs/fragments/522.yaml deleted file mode 100644 index c511f13e5..000000000 --- a/changelogs/fragments/522.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Enable ansible-lint Github action for integration tests diff --git a/changelogs/fragments/523.yaml b/changelogs/fragments/523.yaml deleted file mode 100644 index 0167ca5ce..000000000 --- a/changelogs/fragments/523.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Require ansible-lint in all_green diff --git a/changelogs/fragments/cleanup_1.yaml b/changelogs/fragments/cleanup_1.yaml deleted file mode 100644 index 9ee4e861c..000000000 --- a/changelogs/fragments/cleanup_1.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Begin switch from include to ansible.builtin.include_tasks diff --git a/changelogs/fragments/file_copy.yaml b/changelogs/fragments/file_copy.yaml deleted file mode 100644 index 852888d0e..000000000 --- a/changelogs/fragments/file_copy.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix file copy test validation message. diff --git a/changelogs/fragments/file_cp.yaml b/changelogs/fragments/file_cp.yaml deleted file mode 100644 index acc507ba7..000000000 --- a/changelogs/fragments/file_cp.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Make file_copy validation test assertions work across multiple ansible versions. diff --git a/changelogs/fragments/filecopy_mds.yaml b/changelogs/fragments/filecopy_mds.yaml deleted file mode 100644 index b130a6ca5..000000000 --- a/changelogs/fragments/filecopy_mds.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_file_copy` - Skip `vrf` when running against MDS switches (https://github.com/ansible-collections/cisco.nxos/issues/508)." diff --git a/changelogs/fragments/include_prepare.yaml b/changelogs/fragments/include_prepare.yaml deleted file mode 100644 index abd1c5e11..000000000 --- a/changelogs/fragments/include_prepare.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Replace conditional block with include_tasks for prepare. diff --git a/changelogs/fragments/include_test_case.yaml b/changelogs/fragments/include_test_case.yaml deleted file mode 100644 index f4cd7e416..000000000 --- a/changelogs/fragments/include_test_case.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Switch to FQCN for include of test case diff --git a/changelogs/fragments/mds_docs.yaml b/changelogs/fragments/mds_docs.yaml deleted file mode 100644 index 268ec4d5e..000000000 --- a/changelogs/fragments/mds_docs.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -doc_changes: - - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global modules to reflect which options are unsupported on MDS switches. diff --git a/changelogs/fragments/ntp_global.yaml b/changelogs/fragments/ntp_global.yaml deleted file mode 100644 index db68faf2c..000000000 --- a/changelogs/fragments/ntp_global.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_ntp_global` - Ensure idempotence for aliased keys (https://github.com/ansible-collections/cisco.nxos/issues/484)." diff --git a/changelogs/fragments/nxos_interfaces.yaml b/changelogs/fragments/nxos_interfaces.yaml deleted file mode 100644 index be7070695..000000000 --- a/changelogs/fragments/nxos_interfaces.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True (https://github.com/ansible-collections/cisco.nxos/issues/335)." diff --git a/changelogs/fragments/pre-commit.yaml b/changelogs/fragments/pre-commit.yaml deleted file mode 100644 index d03d12be2..000000000 --- a/changelogs/fragments/pre-commit.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Enable pre-commit with prettier diff --git a/changelogs/fragments/sanity.yaml b/changelogs/fragments/sanity.yaml deleted file mode 100644 index 32da1f4e4..000000000 --- a/changelogs/fragments/sanity.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - "Vendor in Version to fix sanity failures with >2.13 and Python 3.10." diff --git a/changelogs/fragments/sanity_devel.yaml b/changelogs/fragments/sanity_devel.yaml deleted file mode 100644 index fcef487c7..000000000 --- a/changelogs/fragments/sanity_devel.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Sanity fixes for latest devel. diff --git a/changelogs/fragments/set_fact_name.yaml b/changelogs/fragments/set_fact_name.yaml deleted file mode 100644 index 1a39f8e41..000000000 --- a/changelogs/fragments/set_fact_name.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Add name to `set_fact` where missing and update to FQCN diff --git a/changelogs/fragments/snmp_server.yaml b/changelogs/fragments/snmp_server.yaml deleted file mode 100644 index 7eaeeaec7..000000000 --- a/changelogs/fragments/snmp_server.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_snmp_server` - Add support for sha-256 based based user authentication." diff --git a/changelogs/fragments/snmp_server_526.yml b/changelogs/fragments/snmp_server_526.yml deleted file mode 100644 index 9d58693ce..000000000 --- a/changelogs/fragments/snmp_server_526.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_snmp_server` - Fix typo for traps link cisco-xcvr-mon-status-chg." diff --git a/changelogs/fragments/snmp_server_localized.yaml b/changelogs/fragments/snmp_server_localized.yaml deleted file mode 100644 index 0c2c841c8..000000000 --- a/changelogs/fragments/snmp_server_localized.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_snmp_server` - Add support for localizedV2key (https://github.com/ansible-collections/cisco.nxos/issues/415)." diff --git a/changelogs/fragments/unstyle_equal_debug.yaml b/changelogs/fragments/unstyle_equal_debug.yaml deleted file mode 100644 index eb0269bbb..000000000 --- a/changelogs/fragments/unstyle_equal_debug.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Remove = style formatting for debug statements From 358129ddd58951797eb809312bd43020a3afe878 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 13:03:45 +0530 Subject: [PATCH 022/166] [pre-commit.ci] pre-commit autoupdate (#535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.3.0 → 22.6.0](https://github.com/psf/black/compare/22.3.0...22.6.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db85876b2..8d6cb9f55 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: name: Sort import statements using isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black From 7142ebfce40718899e70d6a142a3f6bedbf56a17 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 3 Aug 2022 14:05:15 +0100 Subject: [PATCH 023/166] Fix var-spacing rule from ansible-lint (#544) Reference: https://ansible-lint.readthedocs.io/en/latest/default_rules/#var-spacing --- tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml | 2 +- tests/integration/targets/nxos_snmp_server/tasks/main.yaml | 4 +++- tests/integration/targets/nxos_telemetry/tasks/main.yaml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml index 85daeeff3..4ef02263b 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tasks/main.yaml @@ -1,7 +1,7 @@ --- - name: Set a fact for 'rsvd_intf' ansible.builtin.set_fact: - rsvd_intf: "{{ rsvd_intf|default('mgmt0') }}" + rsvd_intf: "{{ rsvd_intf | default('mgmt0') }}" - name: Run the CLI and NX-API tests block: diff --git a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index 9dc7823ff..29d07397d 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -6,6 +6,7 @@ - name: Grep admin user SNMP localized key ansible.builtin.set_fact: + # noqa var-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 @@ -14,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') }}" + admin_snmp_passwd_2: "{{ result['stdout'][0] | regex_search('snmp-server user admin auth (md5|sha|sha-256) (\\S+)', '\\2') }}" # noqa var-spacing - name: Find admin user SNMP localized key (second) ansible.builtin.set_fact: @@ -22,6 +23,7 @@ - name: Grep admin user SNMP engineid (second) ansible.builtin.set_fact: + # noqa var-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/tests/integration/targets/nxos_telemetry/tasks/main.yaml b/tests/integration/targets/nxos_telemetry/tasks/main.yaml index c1a0e9d3c..91ce8ac0c 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/main.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/main.yaml @@ -58,7 +58,7 @@ cisco.nxos.nxos_file_copy: local_file: "{{ role_path }}/tests/common/fixtures/{{ item }}" file_system: "bootflash:" - connect_ssh_port: "{{ ansible_ssh_port|d(22) }}" + connect_ssh_port: "{{ ansible_ssh_port | d(22) }}" loop: - server.crt - new_server.crt From e0956d1b441257e8f369d2027fa4ea39a7296968 Mon Sep 17 00:00:00 2001 From: takishida <38262981+takishida@users.noreply.github.com> Date: Thu, 4 Aug 2022 21:29:25 -0700 Subject: [PATCH 024/166] fix OSPF interface related modules failing with subinterfaces (#543) Co-authored-by: tkishida Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/ospf_subinterface_failure.yaml | 3 +++ .../network/nxos/facts/ospf_interfaces/ospf_interfaces.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ospf_subinterface_failure.yaml diff --git a/changelogs/fragments/ospf_subinterface_failure.yaml b/changelogs/fragments/ospf_subinterface_failure.yaml new file mode 100644 index 000000000..8923e08db --- /dev/null +++ b/changelogs/fragments/ospf_subinterface_failure.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Modules related to OSPF interfaces fail when the target NXOS device has subinterfaces diff --git a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py index 5cf66be5c..bfec2d51b 100644 --- a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py @@ -76,7 +76,9 @@ def populate_facts(self, connection, ansible_facts, data=None): objs = sorted( objs, - key=lambda i: [int(k) if k.isdigit() else k for k in i["name"].split("/")], + key=lambda i: [ + int(k) if k.isdigit() else k for k in i["name"].replace(".", "/").split("/") + ], ) ansible_facts["ansible_network_resources"].pop("ospf_interfaces", None) From 142c6f9aeb3be4774e17cc3ce1088f27dfeb3cec Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 6 Sep 2022 23:24:19 +0530 Subject: [PATCH 025/166] Fix sanity issues (#555) * Fix sanity issues Signed-off-by: NilashishC * Fix Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/sanity_fix.yaml | 3 +++ plugins/cliconf/nxos.py | 2 +- plugins/modules/nxos_bgp_neighbor.py | 2 +- plugins/modules/nxos_vrf_interface.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/sanity_fix.yaml diff --git a/changelogs/fragments/sanity_fix.yaml b/changelogs/fragments/sanity_fix.yaml new file mode 100644 index 000000000..786462df9 --- /dev/null +++ b/changelogs/fragments/sanity_fix.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix sanity issues. diff --git a/plugins/cliconf/nxos.py b/plugins/cliconf/nxos.py index d6a3fbffe..0dd8f2d2f 100644 --- a/plugins/cliconf/nxos.py +++ b/plugins/cliconf/nxos.py @@ -126,7 +126,7 @@ def get_device_info(self): device_info["network_os_image"] = match_isan_file_name.group(1) match_os_platform = re.search( - r'NAME: "Chassis",\s*DESCR:.*\n' r"PID:\s*(\S+)", + r'NAME: "Chassis",\s*DESCR:.*\nPID:\s*(\S+)', platform_reply, re.M, ) diff --git a/plugins/modules/nxos_bgp_neighbor.py b/plugins/modules/nxos_bgp_neighbor.py index 87c196a91..d87c2e405 100644 --- a/plugins/modules/nxos_bgp_neighbor.py +++ b/plugins/modules/nxos_bgp_neighbor.py @@ -348,7 +348,7 @@ def get_existing(module, args, warnings): existing["neighbor"] = module.params["neighbor"] existing["vrf"] = module.params["vrf"] else: - warnings.append("The BGP process didn't exist but the task" " just created it.") + warnings.append("The BGP process didn't exist but the task just created it.") return existing diff --git a/plugins/modules/nxos_vrf_interface.py b/plugins/modules/nxos_vrf_interface.py index ea6713808..0ce4fe217 100644 --- a/plugins/modules/nxos_vrf_interface.py +++ b/plugins/modules/nxos_vrf_interface.py @@ -201,7 +201,7 @@ def main(): current_vrfs = get_vrf_list(module) if vrf not in current_vrfs: - warnings.append("The VRF is not present/active on the device. " "Use nxos_vrf to fix this.") + warnings.append("The VRF is not present/active on the device. Use nxos_vrf to fix this.") intf_type = get_interface_type(interface) if intf_type != "ethernet" and network_api == "cliconf": From dd1f1205811f1497c3154f8427581cdbf5479046 Mon Sep 17 00:00:00 2001 From: Inseob Kim <62218023+insobi@users.noreply.github.com> Date: Wed, 7 Sep 2022 13:36:04 +0900 Subject: [PATCH 026/166] fixed typo in docs (#545) * fixed typo * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix typo Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- docs/cisco.nxos.nxos_telemetry_module.rst | 6 +++--- plugins/modules/nxos_telemetry.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/cisco.nxos.nxos_telemetry_module.rst b/docs/cisco.nxos.nxos_telemetry_module.rst index 742d0960b..46c41073f 100644 --- a/docs/cisco.nxos.nxos_telemetry_module.rst +++ b/docs/cisco.nxos.nxos_telemetry_module.rst @@ -615,13 +615,13 @@ Examples destination: ip: 192.168.0.2 port: 50001 - protocol: gPRC + protocol: gRPC encoding: GPB - id: 55 destination: ip: 192.168.0.55 port: 60001 - protocol: gPRC + protocol: gRPC encoding: GPB sensor_groups: - id: 1 @@ -667,7 +667,7 @@ Examples destination: ip: 192.168.0.2 port: 50001 - protocol: gPRC + protocol: gRPC encoding: GPB subscriptions: - id: 5 diff --git a/plugins/modules/nxos_telemetry.py b/plugins/modules/nxos_telemetry.py index 82134e7cc..e3fc10fbc 100644 --- a/plugins/modules/nxos_telemetry.py +++ b/plugins/modules/nxos_telemetry.py @@ -229,13 +229,13 @@ destination: ip: 192.168.0.2 port: 50001 - protocol: gPRC + protocol: gRPC encoding: GPB - id: 55 destination: ip: 192.168.0.55 port: 60001 - protocol: gPRC + protocol: gRPC encoding: GPB sensor_groups: - id: 1 @@ -281,7 +281,7 @@ destination: ip: 192.168.0.2 port: 50001 - protocol: gPRC + protocol: gRPC encoding: GPB subscriptions: - id: 5 From 4482b4b93b911faf30aa83592c70987271ea6d08 Mon Sep 17 00:00:00 2001 From: Kate Case Date: Wed, 7 Sep 2022 05:30:29 -0400 Subject: [PATCH 027/166] Drop pinned paramiko version (#551) * Drop pinned paramiko version * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/paramiko.yaml | 3 +++ requirements.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/paramiko.yaml diff --git a/changelogs/fragments/paramiko.yaml b/changelogs/fragments/paramiko.yaml new file mode 100644 index 000000000..63a96887d --- /dev/null +++ b/changelogs/fragments/paramiko.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove pinned paramiko version diff --git a/requirements.txt b/requirements.txt index 00c176353..ee91c107c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -paramiko==2.8.1 +paramiko scp From 5c1dfa1396db9f3442702b8b2205f2bf36c82150 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 7 Sep 2022 18:27:05 +0530 Subject: [PATCH 028/166] Prepare for release v3.1.1 (#556) * Prepare for release v3.1.1 Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC * Fix Signed-off-by: NilashishC * Fix Signed-off-by: NilashishC * Fix lint Signed-off-by: NilashishC Signed-off-by: NilashishC --- CHANGELOG.rst | 8 ++++++++ changelogs/changelog.yaml | 13 +++++++++++-- changelogs/fragments/ospf_subinterface_failure.yaml | 3 --- changelogs/fragments/paramiko.yaml | 3 --- changelogs/fragments/sanity_fix.yaml | 3 --- .../targets/prepare_nxos_tests/tasks/prepare.yml | 10 +++++----- 6 files changed, 24 insertions(+), 16 deletions(-) delete mode 100644 changelogs/fragments/ospf_subinterface_failure.yaml delete mode 100644 changelogs/fragments/paramiko.yaml delete mode 100644 changelogs/fragments/sanity_fix.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c28cca909..8e574729c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,14 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v3.1.1 +====== + +Bugfixes +-------- + +- Fix issue with modules related to OSPF interfaces failing when the target NXOS device has subinterfaces. + v3.1.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index e40091983..0ab7519d1 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -470,8 +470,8 @@ releases: - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family resource module. major_changes: - - Please refer to ansible.netcommon `changelog - `_ + - Please refer to ansible.netcommon + `changelog `_ for more details. - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. @@ -847,3 +847,12 @@ releases: - snmp_server_localized.yaml - unstyle_equal_debug.yaml release_date: "2022-06-28" + 3.1.1: + changes: + bugfixes: + - Fix issue with modules related to OSPF interfaces failing when the target NXOS device has subinterfaces. + fragments: + - ospf_subinterface_failure.yaml + - paramiko.yaml + - sanity_fix.yaml + release_date: "2022-09-07" diff --git a/changelogs/fragments/ospf_subinterface_failure.yaml b/changelogs/fragments/ospf_subinterface_failure.yaml deleted file mode 100644 index 8923e08db..000000000 --- a/changelogs/fragments/ospf_subinterface_failure.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - Modules related to OSPF interfaces fail when the target NXOS device has subinterfaces diff --git a/changelogs/fragments/paramiko.yaml b/changelogs/fragments/paramiko.yaml deleted file mode 100644 index 63a96887d..000000000 --- a/changelogs/fragments/paramiko.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Remove pinned paramiko version diff --git a/changelogs/fragments/sanity_fix.yaml b/changelogs/fragments/sanity_fix.yaml deleted file mode 100644 index 786462df9..000000000 --- a/changelogs/fragments/sanity_fix.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix sanity issues. diff --git a/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml b/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml index 073e0d7bf..52d385973 100644 --- a/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml +++ b/tests/integration/targets/prepare_nxos_tests/tasks/prepare.yml @@ -75,12 +75,12 @@ - name: Set a fact for 'platform' ansible.builtin.set_fact: platform: N3K-F - when: ( platform is match("N3K")) and ( fretta is search("true")) + when: (platform is match("N3K")) and (fretta is search("true")) - name: Set a fact for 'platform' ansible.builtin.set_fact: platform: N9K-F - when: ( platform is match("N9K")) and ( fretta is search("true")) + when: (platform is match("N9K")) and (fretta is search("true")) - name: Set a fact for 'titanium' ansible.builtin.set_fact: @@ -94,17 +94,17 @@ - name: Set a fact for 'platform' ansible.builtin.set_fact: platform: N35 - when: ( chassis_type is search("C35")) + when: (chassis_type is search("C35")) - name: Set a fact for 'platform' ansible.builtin.set_fact: platform: N35NG - when: ( chassis_type is search("C35")) and image_version is search("7.0\(3\)I7") + when: (chassis_type is search("C35")) and image_version is search("7.0\(3\)I7") - name: Set a fact for 'platform' ansible.builtin.set_fact: platform: N3L - when: ( chassis_type is search("C3048")) + when: (chassis_type is search("C3048")) - name: Set a fact for 'imagetag' ansible.builtin.set_fact: From e47d0d991c97899227478c976efbaddd64eb7283 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 15 Sep 2022 21:02:45 +0530 Subject: [PATCH 029/166] [facts] Parse module info correctly when TABLE_modinfo is a list (#560) * [facts] Parse module info correctly when TABLE_modinfo is a list Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/nxos_facts.yaml | 3 +++ .../network/nxos/facts/legacy/base.py | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/nxos_facts.yaml diff --git a/changelogs/fragments/nxos_facts.yaml b/changelogs/fragments/nxos_facts.yaml new file mode 100644 index 000000000..24abd1f38 --- /dev/null +++ b/changelogs/fragments/nxos_facts.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index 10767c974..62912b8b0 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -636,10 +636,17 @@ def parse_structured_vlans(self, data): return objects def parse_structured_module(self, data): - data = data["TABLE_modinfo"]["ROW_modinfo"] - if isinstance(data, dict): - data = [data] - objects = list(self.transform_iterable(data, self.MODULE_MAP)) + modinfo = data["TABLE_modinfo"] + if isinstance(modinfo, dict): + modinfo = [modinfo] + + objects = [] + for entry in modinfo: + entry = entry["ROW_modinfo"] + if isinstance(entry, dict): + entry = [entry] + entry_objects = list(self.transform_iterable(entry, self.MODULE_MAP)) + objects.extend(entry_objects) return objects def parse_structured_fan_info(self, data): From cbe607a474fb222c214d293dbf3b0f334276107d Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 19 Sep 2022 22:16:15 +0530 Subject: [PATCH 030/166] Prepare for v3.1.2 (#561) * Prepare for v3.1.2 Signed-off-by: NilashishC * Fix lint Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC Signed-off-by: NilashishC --- CHANGELOG.rst | 11 +++++++++-- changelogs/changelog.yaml | 21 +++++++++++++++------ changelogs/fragments/nxos_facts.yaml | 3 --- 3 files changed, 24 insertions(+), 11 deletions(-) delete mode 100644 changelogs/fragments/nxos_facts.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8e574729c..82f2b4dae 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,14 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v3.1.2 +====== + +Bugfixes +-------- + +- `nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559). + v3.1.1 ====== @@ -98,8 +106,7 @@ v2.8.2 ====== Release Summary ---------------- - +---------------- - The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains an additional bug fix for the `nxos_ntp_global` module. diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 0ab7519d1..68af2c11a 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -470,11 +470,11 @@ releases: - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family resource module. major_changes: + - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` + and `ansible_network_import_modules`. - Please refer to ansible.netcommon `changelog `_ for more details. - - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` - and `ansible_network_import_modules`. minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). - Add hello_interval_ms option in nxos_pim_interface module to support sub-second @@ -716,9 +716,9 @@ releases: release_date: "2021-12-10" 2.8.2: changes: - release_summary: - - The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which - also contains an additional bug fix. + release_summary: > + The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. + Please download and use v2.8.2 which also contains an additional bug fix. bugfixes: - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." @@ -850,9 +850,18 @@ releases: 3.1.1: changes: bugfixes: - - Fix issue with modules related to OSPF interfaces failing when the target NXOS device has subinterfaces. + - Fix issue with modules related to OSPF interfaces failing when the target + NXOS device has subinterfaces. fragments: - ospf_subinterface_failure.yaml - paramiko.yaml - sanity_fix.yaml release_date: "2022-09-07" + 3.1.2: + changes: + bugfixes: + - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo + entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." + fragments: + - nxos_facts.yaml + release_date: "2022-09-19" diff --git a/changelogs/fragments/nxos_facts.yaml b/changelogs/fragments/nxos_facts.yaml deleted file mode 100644 index 24abd1f38..000000000 --- a/changelogs/fragments/nxos_facts.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." From 45d685265a7637fd24ff519aa61d9661c494aaab Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 27 Sep 2022 17:25:27 +0530 Subject: [PATCH 031/166] Add ignore-2.15.txt (#566) * Add ignore-2.15.txt Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/ignore_2.15.yaml | 3 +++ tests/sanity/ignore-2.15.txt | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/ignore_2.15.yaml create mode 100644 tests/sanity/ignore-2.15.txt diff --git a/changelogs/fragments/ignore_2.15.yaml b/changelogs/fragments/ignore_2.15.yaml new file mode 100644 index 000000000..b50e372d4 --- /dev/null +++ b/changelogs/fragments/ignore_2.15.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Add ignore-2.15.txt diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt new file mode 100644 index 000000000..c2ac0a10b --- /dev/null +++ b/tests/sanity/ignore-2.15.txt @@ -0,0 +1,3 @@ +plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` +plugins/cliconf/nxos.py pylint:arguments-renamed +tests/unit/mock/loader.py pylint:arguments-renamed From 77571e0c5ad681f542948c972b9e825c6d0f8651 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 27 Sep 2022 19:46:51 +0100 Subject: [PATCH 032/166] Fix name[template] violation (#565) See: https://ansible-lint.readthedocs.io/rules/name/ Co-authored-by: Nilashish Chakraborty --- .../tasks/upgrade/copy_kick_system_images.yaml | 6 +++--- .../nxos_install_os/tasks/upgrade/install_system.yaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index 4b1da9cab..204ebd0f9 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -15,7 +15,7 @@ cisco.nxos.nxos_command: commands: run bash rm /var/home/admin/.ssh/known_hosts -- name: Copy {{ si }} to bootflash # noqa var-spacing +- name: Copy file to bootflash {{ si }} register: result cisco.nxos.nxos_file_copy: file_pull: true @@ -30,13 +30,13 @@ msg: "{{ item.key }} {{ item.value }}" with_dict: "{{ result }}" -- name: Copy {{ ki }} to bootflash # noqa var-spacing +- name: Copy file to bootflash {{ ki }} when: ki is defined register: result cisco.nxos.nxos_file_copy: file_pull: true file_pull_timeout: 1200 - remote_file: "{{image_dir}}{{ ki }}" + remote_file: "{{ image_dir }}{{ ki }}" remote_scp_server: "{{ remote_scp_server }}" remote_scp_server_user: "{{ remote_scp_user }}" remote_scp_server_password: "{{ remote_scp_password }}" diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml index a45453fa0..fcc403878 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml @@ -17,7 +17,7 @@ - no boot system match: line -- name: Set OS image {{ si }} boot pointers +- name: "Set OS image boot pointers: {{ si }}" when: force cisco.nxos.nxos_config: lines: @@ -25,7 +25,7 @@ - copy run start match: line -- name: Boot image {{ si }} using reload +- name: "Boot image using reload: {{ si }}" ignore_errors: true # noqa ignore-errors when: force cisco.nxos.nxos_config: From 79e5e1f58344237e41c54be091da6315804e9851 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 28 Sep 2022 14:29:15 +0100 Subject: [PATCH 033/166] Enable dependabot (#562) --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..b6559bdca --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 3 + labels: + - "skip-changelog" From 8ab11ac44f6a9794daecb2aea66329655f4d55a3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Sep 2022 17:54:41 -0400 Subject: [PATCH 034/166] [pre-commit.ci] pre-commit autoupdate (#550) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v2.2.3 → v2.3.0](https://github.com/asottile/add-trailing-comma/compare/v2.2.3...v2.3.0) - [github.com/pre-commit/mirrors-prettier: v2.7.1 → v3.0.0-alpha.0](https://github.com/pre-commit/mirrors-prettier/compare/v2.7.1...v3.0.0-alpha.0) - [github.com/psf/black: 22.6.0 → 22.8.0](https://github.com/psf/black/compare/22.6.0...22.8.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8d6cb9f55..5cb93ba4f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,12 +12,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v2.2.3 + rev: v2.3.0 hooks: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v2.7.1" + rev: "v3.0.0-alpha.0" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described @@ -48,7 +48,7 @@ repos: name: Sort import statements using isort - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.8.0 hooks: - id: black From b15e2e598b9e42563251090d336cd16ef5557b65 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 29 Sep 2022 07:06:51 +0100 Subject: [PATCH 035/166] Linting fixes (#568) Co-authored-by: Nilashish Chakraborty --- .../tasks/upgrade/copy_kick_system_images.yaml | 2 +- .../nxos_install_os/tasks/upgrade/install_with_kick.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index 204ebd0f9..cc0abf470 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -20,7 +20,7 @@ cisco.nxos.nxos_file_copy: file_pull: true file_pull_timeout: 1200 - remote_file: "{{image_dir}}{{ si }}" + remote_file: "{{ image_dir }}{{ si }}" remote_scp_server: "{{ remote_scp_server }}" remote_scp_server_user: "{{ remote_scp_user }}" remote_scp_server_password: "{{ remote_scp_password }}" diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml index 7116671d7..aa0d11cf6 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml @@ -8,7 +8,7 @@ kickstart_image_file: "{{ ki }}" issu: "{{ issu }}" -- name: Set OS image {{ si }} boot pointers +- name: Set boot pointers for OS image {{ si }} when: force cisco.nxos.nxos_config: lines: @@ -19,7 +19,7 @@ - copy run start match: line -- name: Boot image {{ si }} using reload +- name: Boot image using reload ({{ si }}) ignore_errors: true # noqa ignore-errors when: force cisco.nxos.nxos_command: From f0d36c5935ad02270f181390db95a38f8789f23c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 11:16:39 +0530 Subject: [PATCH 036/166] [pre-commit.ci] pre-commit autoupdate (#572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.0 → v3.0.0-alpha.1](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.0...v3.0.0-alpha.1) - [github.com/psf/black: 22.8.0 → 22.10.0](https://github.com/psf/black/compare/22.8.0...22.10.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5cb93ba4f..95ab26318 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.0" + rev: "v3.0.0-alpha.1" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described @@ -48,7 +48,7 @@ repos: name: Sort import statements using isort - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black From aac22a9cb81b59a772a5f02f211e8b3cfbb54c3b Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 11 Oct 2022 14:18:39 +0530 Subject: [PATCH 037/166] [l3_interfaces] support enabling/disabling ipv6 redirects (#570) * [l3_interfaces] support enabling-disabling ipv6 redirects Signed-off-by: NilashishC * Revert test change Signed-off-by: NilashishC * Fix lint issues Signed-off-by: NilashishC * Delete length=15 files Signed-off-by: NilashishC Co-authored-by: Kate Case --- changelogs/fragments/l3_interfaces.yaml | 3 +++ docs/cisco.nxos.nxos_l3_interfaces_module.rst | 22 ++++++++++++++- .../argspec/l3_interfaces/l3_interfaces.py | 1 + .../config/l3_interfaces/l3_interfaces.py | 16 ++++++++++- .../nxos/facts/l3_interfaces/l3_interfaces.py | 1 + plugins/modules/nxos_l3_interfaces.py | 6 ++++- .../targets/nxos_config/tasks/main.yaml | 6 +++-- .../targets/nxos_install_os/tasks/main.yaml | 6 +++-- .../upgrade/copy_kick_system_images.yaml | 3 ++- .../tasks/upgrade/install_os.yaml | 12 ++++++--- .../tasks/upgrade/install_with_kick.yaml | 2 +- .../tasks/upgrade/main_os_install.yaml | 3 ++- .../targets/nxos_smoke/tasks/main.yaml | 2 +- .../network/nxos/test_nxos_l3_interfaces.py | 27 ++++++++++++++++++- 14 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 changelogs/fragments/l3_interfaces.yaml diff --git a/changelogs/fragments/l3_interfaces.yaml b/changelogs/fragments/l3_interfaces.yaml new file mode 100644 index 000000000..bd42cded6 --- /dev/null +++ b/changelogs/fragments/l3_interfaces.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_l3_interfaces` - Add support for toggling ipv6 redirects (https://github.com/ansible-collections/cisco.nxos/issues/569)." diff --git a/docs/cisco.nxos.nxos_l3_interfaces_module.rst b/docs/cisco.nxos.nxos_l3_interfaces_module.rst index 236cf7bc1..0f46e95d2 100644 --- a/docs/cisco.nxos.nxos_l3_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_l3_interfaces_module.rst @@ -211,6 +211,26 @@ Parameters + + + +
+ ipv6_redirects + +
+ boolean +
+ + +
    Choices: +
  • no
  • +
  • yes
  • +
+ + +
Enables/disables ipv6 redirects.
+ + @@ -245,7 +265,7 @@ Parameters -
Enables/disables ip redirects
+
Enables/disables ipv4 redirects.
diff --git a/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py index 038e16d96..7a5163e0f 100644 --- a/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/l3_interfaces/l3_interfaces.py @@ -58,6 +58,7 @@ class L3_interfacesArgs(object): # pylint: disable=R0903 }, "name": {"required": True, "type": "str"}, "redirects": {"type": "bool"}, + "ipv6_redirects": {"type": "bool"}, "unreachables": {"type": "bool"}, "evpn_multisite_tracking": { "type": "str", diff --git a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py index 808d78361..0bb5f4bac 100644 --- a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py @@ -406,6 +406,14 @@ def generate_delete_commands(self, obj): # device auto-enables redirects when secondaries are removed; # auto-enable may fail on legacy platforms so always do explicit enable commands.append("ip redirects") + if "ipv6_redirects" in obj: + if not self.check_existing(name, "has_secondary") or re.match( + "N[35679]", + self.platform, + ): + # device auto-enables redirects when secondaries are removed; + # auto-enable may fail on legacy platforms so always do explicit enable + commands.append("ipv6 redirects") if "unreachables" in obj: commands.append("no ip unreachables") if "ipv4" in obj: @@ -473,6 +481,12 @@ def add_commands(self, diff, name=""): no_cmd = "no " if diff["redirects"] is False else "" commands.append(no_cmd + "ip redirects") self.cmd_order_fixup(commands, name) + if "ipv6_redirects" in diff: + # Note: device will auto-disable redirects when secondaries are present + if diff["ipv6_redirects"] != self.check_existing(name, "ipv6_redirects"): + no_cmd = "no " if diff["ipv6_redirects"] is False else "" + commands.append(no_cmd + "ipv6 redirects") + self.cmd_order_fixup(commands, name) if "unreachables" in diff: if diff["unreachables"] != self.check_existing(name, "unreachables"): no_cmd = "no " if diff["unreachables"] is False else "" @@ -525,7 +539,7 @@ def cmd_order_fixup(self, cmds, name): if name and not [item for item in cmds if item.startswith("interface")]: cmds.insert(0, "interface " + name) - redirects = [item for item in cmds if re.match("(no )*ip redirects", item)] + redirects = [item for item in cmds if re.match("(no )*ip(v6)* redirects", item)] if redirects: # redirects should occur after ipv4 commands, just move to end of list redirects = redirects.pop() diff --git a/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py index 71c1e1620..ad36e17ca 100644 --- a/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/l3_interfaces/l3_interfaces.py @@ -92,6 +92,7 @@ def render_config(self, spec, conf): config["name"] = intf config["dot1q"] = utils.parse_conf_arg(conf, "encapsulation dot1[qQ]") config["redirects"] = utils.parse_conf_cmd_arg(conf, "no ip redirects", False, True) + config["ipv6_redirects"] = utils.parse_conf_cmd_arg(conf, "no ipv6 redirects", False, True) config["unreachables"] = utils.parse_conf_cmd_arg(conf, "ip unreachables", True, False) config["evpn_multisite_tracking"] = utils.parse_conf_arg(conf, "evpn multisite") ipv4_match = re.compile(r"\n ip address (.*)") diff --git a/plugins/modules/nxos_l3_interfaces.py b/plugins/modules/nxos_l3_interfaces.py index 860a8faac..7b5cb7a63 100644 --- a/plugins/modules/nxos_l3_interfaces.py +++ b/plugins/modules/nxos_l3_interfaces.py @@ -99,7 +99,11 @@ type: int redirects: description: - - Enables/disables ip redirects + - Enables/disables ipv4 redirects. + type: bool + ipv6_redirects: + description: + - Enables/disables ipv6 redirects. type: bool unreachables: description: diff --git a/tests/integration/targets/nxos_config/tasks/main.yaml b/tests/integration/targets/nxos_config/tasks/main.yaml index 955fcd112..641205bf8 100644 --- a/tests/integration/targets/nxos_config/tasks/main.yaml +++ b/tests/integration/targets/nxos_config/tasks/main.yaml @@ -11,11 +11,13 @@ tags: - nxapi - - ansible.builtin.include_tasks: cli_config.yaml + - name: Run cli_config tests + ansible.builtin.include_tasks: cli_config.yaml tags: - cli_config - - ansible.builtin.include_tasks: redirection.yaml + - name: Run redirection tests + ansible.builtin.include_tasks: redirection.yaml when: ansible_version.full is version('2.10.0', '>=') always: - name: Change hostname back to {{ inventory_hostname_short }} diff --git a/tests/integration/targets/nxos_install_os/tasks/main.yaml b/tests/integration/targets/nxos_install_os/tasks/main.yaml index 20fd0eb71..30b50a39a 100644 --- a/tests/integration/targets/nxos_install_os/tasks/main.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/main.yaml @@ -1,6 +1,8 @@ --- -- ansible.builtin.include_tasks: network_cli.yaml +- name: Run network_cli tests + ansible.builtin.include_tasks: network_cli.yaml when: ansible_connection == 'ansible.netcommon.network_cli' -- ansible.builtin.include_tasks: httpapi.yaml +- name: Run httpapi tests + ansible.builtin.include_tasks: httpapi.yaml when: ansible_connection == 'ansible.netcommon.httpapi' diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index cc0abf470..0ee795a8f 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -8,7 +8,8 @@ ignore_errors_httpapi: true when: ansible_connection == 'ansible.netcommon.httpapi' -- ansible.builtin.include_tasks: enable_scp_server.yaml +- name: Enable SCP server + ansible.builtin.include_tasks: enable_scp_server.yaml - name: Remove SSH known_hosts file before scp of image file ignore_errors: true # noqa ignore-errors diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml index c38d89839..e348d1e22 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml @@ -1,16 +1,20 @@ --- -- ansible.builtin.include_tasks: delete_files.yaml +- name: Run delete files tasks + ansible.builtin.include_tasks: delete_files.yaml when: delete_files -- ansible.builtin.include_tasks: copy_kick_system_images.yaml +- name: Copy Kick System images + ansible.builtin.include_tasks: copy_kick_system_images.yaml vars: ansible_connection: ansible.netcommon.network_cli connection={{ cli }} when: copy_images -- ansible.builtin.include_tasks: install_with_kick.yaml +- name: Run install with kick tests + ansible.builtin.include_tasks: install_with_kick.yaml when: ki is defined -- ansible.builtin.include_tasks: install_system.yaml +- name: Run install system + ansible.builtin.include_tasks: install_system.yaml when: ki is undefined - name: Reset the connection diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml index aa0d11cf6..3a5af1240 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml @@ -19,7 +19,7 @@ - copy run start match: line -- name: Boot image using reload ({{ si }}) +- name: "Boot image using reload {{ si }}" ignore_errors: true # noqa ignore-errors when: force cisco.nxos.nxos_command: diff --git a/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml b/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml index d5590278d..acbf45a56 100644 --- a/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml +++ b/tests/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml @@ -6,4 +6,5 @@ - name: End the play ansible.builtin.meta: end_play -- ansible.builtin.include_tasks: install_os.yaml +- name: Run Install OS + ansible.builtin.include_tasks: install_os.yaml diff --git a/tests/integration/targets/nxos_smoke/tasks/main.yaml b/tests/integration/targets/nxos_smoke/tasks/main.yaml index 2d03cb9fa..144efbb59 100644 --- a/tests/integration/targets/nxos_smoke/tasks/main.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/main.yaml @@ -15,7 +15,7 @@ always: - name: "Change hostname back to {{ inventory_hostname_short }}" - nxos_config: + cisco.nxos.nxos_config: lines: - "hostname {{ inventory_hostname_short }}" match: none diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py index a7c1e81cd..cb41e0ab2 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py @@ -106,6 +106,9 @@ def test_2(self): ip address 10.1.2.1/24 interface Ethernet1/3 ip address 10.1.3.1/24 + interface port-channel336 + interface port-channel337 + no ipv6 redirects """, ) self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} @@ -114,12 +117,22 @@ def test_2(self): dict(name="mgmt0", ipv4=[{"address": "10.0.0.254/24"}]), dict(name="Ethernet1/1", ipv4=[{"address": "192.168.1.1/24"}]), dict(name="Ethernet1/2"), + dict(name="port-channel355", ipv6_redirects=False), + dict(name="port-channel336", ipv6_redirects=False, ipv6=[{"address": "10::5/128"}]), # Eth1/3 not present! Thus overridden should set Eth1/3 to defaults; # replaced should ignore Eth1/3. ], ) # Expected result commands for each 'state' - merged = ["interface Ethernet1/1", "ip address 192.168.1.1/24"] + merged = [ + "interface Ethernet1/1", + "ip address 192.168.1.1/24", + "interface port-channel355", + "no ipv6 redirects", + "interface port-channel336", + "ipv6 address 10::5/128", + "no ipv6 redirects", + ] deleted = [ "interface mgmt0", "no ip address", @@ -133,6 +146,11 @@ def test_2(self): "ip address 192.168.1.1/24", "interface Ethernet1/2", "no ip address", + "interface port-channel355", + "no ipv6 redirects", + "interface port-channel336", + "ipv6 address 10::5/128", + "no ipv6 redirects", ] overridden = [ "interface Ethernet1/1", @@ -141,6 +159,13 @@ def test_2(self): "no ip address", "interface Ethernet1/3", "no ip address", + "interface port-channel355", + "no ipv6 redirects", + "interface port-channel336", + "ipv6 address 10::5/128", + "no ipv6 redirects", + "interface port-channel337", + "ipv6 redirects", ] playbook["state"] = "merged" From 73b571f3a936ab4d7024d6110ac307aed8e293e8 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 11 Oct 2022 17:48:15 +0530 Subject: [PATCH 038/166] Fix incorrect use of password lookup in tests (#573) Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/passwd_lookup.yaml | 3 +++ tests/integration/targets/nxos_file_copy/tasks/main.yaml | 2 +- tests/integration/targets/nxos_telemetry/tasks/main.yaml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/passwd_lookup.yaml diff --git a/changelogs/fragments/passwd_lookup.yaml b/changelogs/fragments/passwd_lookup.yaml new file mode 100644 index 000000000..99bebdb7b --- /dev/null +++ b/changelogs/fragments/passwd_lookup.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix incorrect use of password lookup in tests. diff --git a/tests/integration/targets/nxos_file_copy/tasks/main.yaml b/tests/integration/targets/nxos_file_copy/tasks/main.yaml index 510f642fa..33ba6cb95 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/main.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/main.yaml @@ -10,7 +10,7 @@ - name: Generate and store random password for temp user ansible.builtin.set_fact: - temp_passwd: "{{ lookup('password', 'length=15 chars=ascii_letters') }}" + temp_passwd: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}" delegate_to: localhost no_log: true diff --git a/tests/integration/targets/nxos_telemetry/tasks/main.yaml b/tests/integration/targets/nxos_telemetry/tasks/main.yaml index 91ce8ac0c..cb0d40859 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/main.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/main.yaml @@ -24,7 +24,7 @@ - name: Generate and store random password for temp user ansible.builtin.set_fact: - temp_passwd: "{{ lookup('password', 'length=15 chars=ascii_letters') }}" + temp_passwd: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}" delegate_to: localhost no_log: true From 6855c9318b95d65f551ce91bb4226138f53aaa97 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 12 Oct 2022 15:52:32 +0530 Subject: [PATCH 039/166] [telemetry] assorted fixes for destination and sensor groups (#574) * [telemetry] assorted fixes for destination and sensor groups Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix tests Signed-off-by: NilashishC * Add tests Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelogs/fragments/telemetry.yaml | 4 + docs/cisco.nxos.nxos_telemetry_module.rst | 16 +-- .../nxos/argspec/telemetry/telemetry.py | 10 +- .../nxos/cmdref/telemetry/telemetry.py | 2 +- plugins/module_utils/network/nxos/nxos.py | 16 ++- .../network/nxos/utils/telemetry/telemetry.py | 6 +- plugins/modules/nxos_telemetry.py | 16 +-- .../network/nxos/test_nxos_telemetry.py | 117 ++++++++++++++++++ 8 files changed, 159 insertions(+), 28 deletions(-) create mode 100644 changelogs/fragments/telemetry.yaml diff --git a/changelogs/fragments/telemetry.yaml b/changelogs/fragments/telemetry.yaml new file mode 100644 index 000000000..bdd481443 --- /dev/null +++ b/changelogs/fragments/telemetry.yaml @@ -0,0 +1,4 @@ +--- +bugfixes: + - "`nxos_telemetry` - Allow destination-group & sensor-group id to be strings." + - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional properties." diff --git a/docs/cisco.nxos.nxos_telemetry_module.rst b/docs/cisco.nxos.nxos_telemetry_module.rst index 46c41073f..00dcb28b2 100644 --- a/docs/cisco.nxos.nxos_telemetry_module.rst +++ b/docs/cisco.nxos.nxos_telemetry_module.rst @@ -245,14 +245,14 @@ Parameters id
- integer + string
Destination group identifier.
-
Value must be a int representing the destination group identifier.
+
Value must be an integer or string representing the destination group identifier.
@@ -303,14 +303,14 @@ Parameters id
- integer + string
Sensor group identifier.
-
Value must be a int representing the sensor group identifier.
+
Value must be a integer or a string representing the sensor group identifier.
@@ -449,7 +449,7 @@ Parameters destination_group
- integer + string
@@ -466,14 +466,14 @@ Parameters id
- integer + string
Subscription identifier.
-
Value must be a int representing the subscription identifier.
+
Value must be an integer or string representing the subscription identifier.
@@ -503,7 +503,7 @@ Parameters id
- integer + string
diff --git a/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py b/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py index 8ea952cb0..7da72979b 100644 --- a/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/argspec/telemetry/telemetry.py @@ -64,7 +64,7 @@ class TelemetryArgs(object): # pylint: disable=R0903 }, "type": "dict", }, - "id": {"type": "int"}, + "id": {"type": "str"}, }, "type": "list", "elements": "raw", @@ -75,7 +75,7 @@ class TelemetryArgs(object): # pylint: disable=R0903 "choices": ["NX-API", "DME", "YANG"], "type": "str", }, - "id": {"type": "int"}, + "id": {"type": "str"}, "path": { "options": { "depth": {"type": "str"}, @@ -91,11 +91,11 @@ class TelemetryArgs(object): # pylint: disable=R0903 }, "subscriptions": { "options": { - "destination_group": {"type": "int"}, - "id": {"type": "int"}, + "destination_group": {"type": "str"}, + "id": {"type": "str"}, "sensor_group": { "options": { - "id": {"type": "int"}, + "id": {"type": "str"}, "sample_interval": {"type": "int"}, }, "type": "dict", diff --git a/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py b/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py index 7f00fd5a4..f5844538f 100644 --- a/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/cmdref/telemetry/telemetry.py @@ -131,7 +131,7 @@ destination_group: _exclude: ['N3K', 'N5K', 'N6k', 'N7k'] multiple: true - kind: int + kind: str getval: dst-grp (\\S+)$ setval: 'dst-grp {0}' default: ~ diff --git a/plugins/module_utils/network/nxos/nxos.py b/plugins/module_utils/network/nxos/nxos.py index 725686b73..a605c4242 100644 --- a/plugins/module_utils/network/nxos/nxos.py +++ b/plugins/module_utils/network/nxos/nxos.py @@ -1108,9 +1108,19 @@ def build_cmd_set(self, playval, existing, k): # match up with the getval regex named group keys; e.g. # getval: my-cmd (?P\d+) bar (?P\d+) # setval: my-cmd {foo} bar {baz} - cmd = ref[k]["setval"].format(**playval) + if ref[k]["setval"].startswith("path"): + tmplt = "path {name}" + if "depth" in playval: + tmplt += " depth {depth}" + if "query_condition" in playval: + tmplt += " query-condition {query_condition}" + if "filter_condition" in playval: + tmplt += " filter-condition {filter_condition}" + cmd = tmplt.format(**playval) + else: + cmd = ref[k]["setval"].format(**playval) elif "str" == kind: - if "deleted" in playval: + if "deleted" in str(playval): if existing: cmd = "no " + ref[k]["setval"].format(existing) else: @@ -1146,7 +1156,7 @@ def compare(playval, existing): if ref["_state"] in self.present_states: if existing is None: return False - elif playval == existing: + elif str(playval) == str(existing): return True elif isinstance(existing, dict) and playval in existing.values(): return True diff --git a/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py b/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py index 9e47e9bc0..aa540aded 100644 --- a/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py +++ b/plugins/module_utils/network/nxos/utils/telemetry/telemetry.py @@ -97,9 +97,9 @@ def get_instance_data(key, cr_key, cr, existing_key): instance = cr._ref[cr_key]["existing"][existing_key] patterns = { - "destination_groups": r"destination-group (\d+)", - "sensor_groups": r"sensor-group (\d+)", - "subscriptions": r"subscription (\d+)", + "destination_groups": r"destination-group (\S+)", + "sensor_groups": r"sensor-group (\S+)", + "subscriptions": r"subscription (\S+)", } if key in patterns.keys(): m = re.search(patterns[key], cr._ref["_resource_key"]) diff --git a/plugins/modules/nxos_telemetry.py b/plugins/modules/nxos_telemetry.py index e3fc10fbc..7498ff880 100644 --- a/plugins/modules/nxos_telemetry.py +++ b/plugins/modules/nxos_telemetry.py @@ -83,10 +83,10 @@ elements: raw suboptions: id: - type: int + type: str description: - Destination group identifier. - - Value must be a int representing the destination group identifier. + - Value must be an integer or string representing the destination group identifier. destination: type: dict description: @@ -124,10 +124,10 @@ elements: raw suboptions: id: - type: int + type: str description: - Sensor group identifier. - - Value must be a int representing the sensor group identifier. + - Value must be a integer or a string representing the sensor group identifier. data_source: type: str description: @@ -168,12 +168,12 @@ elements: raw suboptions: id: - type: int + type: str description: - Subscription identifier. - - Value must be a int representing the subscription identifier. + - Value must be an integer or string representing the subscription identifier. destination_group: - type: int + type: str description: - Associated destination group. sensor_group: @@ -183,7 +183,7 @@ - Value must be a dict defining values for keys (id, sample_interval). suboptions: id: - type: int + type: str description: - Associated sensor group id. sample_interval: diff --git a/tests/unit/modules/network/nxos/test_nxos_telemetry.py b/tests/unit/modules/network/nxos/test_nxos_telemetry.py index 199af8e9b..9418ad90d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_telemetry.py +++ b/tests/unit/modules/network/nxos/test_nxos_telemetry.py @@ -1800,6 +1800,123 @@ def test_telemetry_gathered(self): result = self.execute_module(changed=False) self.assertEqual(result["gathered"], gathered) + def test_tms_names(self): + # TMS input with strings + self.execute_show_command.return_value = "" + self.get_platform_shortname.return_value = "N9K" + set_module_args( + dict( + config=dict( + destination_groups=[ + dict( + id="collector", + destination=dict( + ip="192.168.1.100", + port=50051, + protocol="gRPC", + encoding="GPB", + ), + ), + ], + sensor_groups=[ + dict( + id="dme_bgp", + data_source="DME", + path=dict( + name="sys/bd", + depth="unbounded", + ), + ), + ], + subscriptions=[ + dict( + id="collector_sub", + destination_group="collector", + sensor_group=dict( + id="dme_bgp", + sample_interval=1000, + ), + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + self.execute_module( + changed=True, + commands=[ + "feature telemetry", + "telemetry", + "destination-group collector", + "ip address 192.168.1.100 port 50051 protocol grpc encoding gpb", + "sensor-group dme_bgp", + "data-source DME", + "path sys/bd depth unbounded", + "subscription collector_sub", + "dst-grp collector", + "snsr-grp dme_bgp sample-interval 1000", + ], + ) + + def test_tms_names_idempotent(self): + # TMS input with strings + self.execute_show_command.return_value = dedent( + """\ + feature telemetry + telemetry + destination-group collector + ip address 192.168.1.100 port 50051 protocol grpc encoding gpb + sensor-group dme_bgp + data-source DME + path sys/bd depth unbounded + subscription collector_sub + dst-grp collector + snsr-grp dme_bgp sample-interval 1000 + """, + ) + self.get_platform_shortname.return_value = "N9K" + set_module_args( + dict( + config=dict( + destination_groups=[ + dict( + id="collector", + destination=dict( + ip="192.168.1.100", + port=50051, + protocol="gRPC", + encoding="GPB", + ), + ), + ], + sensor_groups=[ + dict( + id="dme_bgp", + data_source="DME", + path=dict( + name="sys/bd", + depth="unbounded", + ), + ), + ], + subscriptions=[ + dict( + id="collector_sub", + destination_group="collector", + sensor_group=dict( + id="dme_bgp", + sample_interval=1000, + ), + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + self.execute_module(changed=False, commands=[]) + def build_args(data, type, state=None, check_mode=None): if state is None: From 900b156405fab47865d9b83179174cb7365c4daa Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 12 Oct 2022 18:14:10 +0530 Subject: [PATCH 040/166] Prepare v3.2.0 (#575) * Prepare v3.2.0 Signed-off-by: NilashishC * Lint fix Signed-off-by: NilashishC * Fix linter Signed-off-by: NilashishC Signed-off-by: NilashishC --- CHANGELOG.rst | 23 +++++++++++++++---- changelogs/changelog.yaml | 30 ++++++++++++++++++++----- changelogs/fragments/ignore_2.15.yaml | 3 --- changelogs/fragments/l3_interfaces.yaml | 3 --- changelogs/fragments/passwd_lookup.yaml | 3 --- changelogs/fragments/telemetry.yaml | 4 ---- 6 files changed, 43 insertions(+), 23 deletions(-) delete mode 100644 changelogs/fragments/ignore_2.15.yaml delete mode 100644 changelogs/fragments/l3_interfaces.yaml delete mode 100644 changelogs/fragments/passwd_lookup.yaml delete mode 100644 changelogs/fragments/telemetry.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 82f2b4dae..ff72437e9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,20 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v3.2.0 +====== + +Minor Changes +------------- + +- `nxos_l3_interfaces` - Add support for toggling ipv6 redirects (https://github.com/ansible-collections/cisco.nxos/issues/569). + +Bugfixes +-------- + +- `nxos_telemetry` - Allow destination-group & sensor-group id to be strings. +- `nxos_telemetry` - Allow sensor-group paths to be generated without additional properties. + v3.1.2 ====== @@ -106,9 +120,10 @@ v2.8.2 ====== Release Summary ----------------- -- The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which - also contains an additional bug fix for the `nxos_ntp_global` module. +--------------- + +The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains an additional bug fix. + Bugfixes -------- @@ -335,8 +350,8 @@ v2.0.0 Major Changes ------------- -- Please refer to ansible.netcommon `changelog `_ for more details. - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. +- Please refer to ansible.netcommon `changelog `_ for more details. Minor Changes ------------- diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 68af2c11a..84c4e67ce 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -472,9 +472,10 @@ releases: major_changes: - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. - - Please refer to ansible.netcommon - `changelog `_ - for more details. + - "Please refer to + ansible.netcommon + `changelog ` + for more details." minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). - Add hello_interval_ms option in nxos_pim_interface module to support sub-second @@ -716,12 +717,15 @@ releases: release_date: "2021-12-10" 2.8.2: changes: - release_summary: > - The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. - Please download and use v2.8.2 which also contains an additional bug fix. bugfixes: - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." + release_summary: + "The v2.8.1 of the cisco.nxos collection is not available on + Ansible Automation Hub. Please download and use v2.8.2 which also contains + an additional bug fix. + + " fragments: - ignore.yaml - nxos_ntp.yaml @@ -865,3 +869,17 @@ releases: fragments: - nxos_facts.yaml release_date: "2022-09-19" + 3.2.0: + changes: + bugfixes: + - "`nxos_telemetry` - Allow destination-group & sensor-group id to be strings." + - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional + properties." + minor_changes: + - "`nxos_l3_interfaces` - Add support for toggling ipv6 redirects (https://github.com/ansible-collections/cisco.nxos/issues/569)." + fragments: + - ignore_2.15.yaml + - l3_interfaces.yaml + - passwd_lookup.yaml + - telemetry.yaml + release_date: "2022-10-12" diff --git a/changelogs/fragments/ignore_2.15.yaml b/changelogs/fragments/ignore_2.15.yaml deleted file mode 100644 index b50e372d4..000000000 --- a/changelogs/fragments/ignore_2.15.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Add ignore-2.15.txt diff --git a/changelogs/fragments/l3_interfaces.yaml b/changelogs/fragments/l3_interfaces.yaml deleted file mode 100644 index bd42cded6..000000000 --- a/changelogs/fragments/l3_interfaces.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_l3_interfaces` - Add support for toggling ipv6 redirects (https://github.com/ansible-collections/cisco.nxos/issues/569)." diff --git a/changelogs/fragments/passwd_lookup.yaml b/changelogs/fragments/passwd_lookup.yaml deleted file mode 100644 index 99bebdb7b..000000000 --- a/changelogs/fragments/passwd_lookup.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix incorrect use of password lookup in tests. diff --git a/changelogs/fragments/telemetry.yaml b/changelogs/fragments/telemetry.yaml deleted file mode 100644 index bdd481443..000000000 --- a/changelogs/fragments/telemetry.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -bugfixes: - - "`nxos_telemetry` - Allow destination-group & sensor-group id to be strings." - - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional properties." From c85ed8be9ac8f3d8130f0c5f2a82c12353db2e70 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 12 Oct 2022 22:30:15 +0530 Subject: [PATCH 041/166] Remove deprecated plugins that have reached their EOL (#571) * Remove all eligible deprecated modules Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC * Fix lint Signed-off-by: NilashishC * Remove redundant ignores Signed-off-by: NilashishC * Add back required ignore Signed-off-by: NilashishC * Remove invalid tests and references Signed-off-by: NilashishC * Fix linter Signed-off-by: NilashishC * Remove obsolete tests Signed-off-by: NilashishC * Update changelogs/fragments/remove_deprecated.yaml Signed-off-by: NilashishC Co-authored-by: Sagar Paul --- README.md | 13 - changelogs/fragments/remove_deprecated.yaml | 17 + docs/cisco.nxos.nxos_acl_interface_module.rst | 438 ------- docs/cisco.nxos.nxos_acl_module.rst | 836 ------------- docs/cisco.nxos.nxos_interface_module.rst | 1043 ----------------- .../cisco.nxos.nxos_interface_ospf_module.rst | 623 ---------- docs/cisco.nxos.nxos_l2_interface_module.rst | 640 ---------- docs/cisco.nxos.nxos_l3_interface_module.rst | 516 -------- docs/cisco.nxos.nxos_linkagg_module.rst | 638 ---------- docs/cisco.nxos.nxos_lldp_module.rst | 373 ------ docs/cisco.nxos.nxos_ospf_module.rst | 382 ------ docs/cisco.nxos.nxos_ospf_vrf_module.rst | 602 ---------- docs/cisco.nxos.nxos_smu_module.rst | 381 ------ docs/cisco.nxos.nxos_static_route_module.rst | 631 ---------- docs/cisco.nxos.nxos_vlan_module.rst | 804 ------------- docs/cisco.nxos.nxos_vxlan_vtep_module.rst | 2 +- meta/runtime.yml | 169 --- plugins/modules/nxos_acl.py | 669 ----------- plugins/modules/nxos_acl_interface.py | 221 ---- plugins/modules/nxos_interface.py | 944 --------------- plugins/modules/nxos_interface_ospf.py | 577 --------- plugins/modules/nxos_l2_interface.py | 664 ----------- plugins/modules/nxos_l3_interface.py | 288 ----- plugins/modules/nxos_linkagg.py | 508 -------- plugins/modules/nxos_lldp.py | 127 -- plugins/modules/nxos_ospf.py | 170 --- plugins/modules/nxos_ospf_vrf.py | 469 -------- plugins/modules/nxos_smu.py | 160 --- plugins/modules/nxos_static_route.py | 373 ------ plugins/modules/nxos_vlan.py | 817 ------------- plugins/modules/nxos_vrf_interface.py | 4 +- plugins/modules/nxos_vxlan_vtep.py | 4 +- .../targets/nxos_acl/defaults/main.yaml | 2 - .../targets/nxos_acl/meta/main.yml | 3 - .../targets/nxos_acl/tasks/cli.yaml | 32 - .../targets/nxos_acl/tasks/main.yaml | 10 - .../targets/nxos_acl/tasks/nxapi.yaml | 32 - .../targets/nxos_acl/tests/common/sanity.yaml | 234 ---- .../nxos_acl_interface/defaults/main.yaml | 2 - .../targets/nxos_acl_interface/meta/main.yml | 3 - .../targets/nxos_acl_interface/tasks/cli.yaml | 32 - .../nxos_acl_interface/tasks/main.yaml | 10 - .../nxos_acl_interface/tasks/nxapi.yaml | 32 - .../tests/common/sanity.yaml | 122 -- .../targets/nxos_interface/defaults/main.yaml | 2 - .../targets/nxos_interface/meta/main.yml | 3 - .../targets/nxos_interface/tasks/cli.yaml | 32 - .../targets/nxos_interface/tasks/main.yaml | 10 - .../targets/nxos_interface/tasks/nxapi.yaml | 32 - .../nxos_interface/tests/common/intent.yaml | 74 -- .../nxos_interface/tests/common/sanity.yaml | 134 --- .../tests/common/set_state_absent.yaml | 31 - .../tests/common/set_state_present.yaml | 34 - .../nxos_interface/tests/common/sub_int.yaml | 77 -- .../nxos_interface_ospf/defaults/main.yaml | 2 - .../targets/nxos_interface_ospf/meta/main.yml | 3 - .../nxos_interface_ospf/tasks/cli.yaml | 32 - .../nxos_interface_ospf/tasks/main.yaml | 12 - .../nxos_interface_ospf/tasks/nxapi.yaml | 32 - .../tests/common/sanity.yaml | 295 ----- .../nxos_l2_interface/defaults/main.yaml | 2 - .../targets/nxos_l2_interface/meta/main.yml | 3 - .../targets/nxos_l2_interface/tasks/cli.yaml | 32 - .../targets/nxos_l2_interface/tasks/main.yaml | 10 - .../nxos_l2_interface/tasks/nxapi.yaml | 32 - .../nxos_l2_interface/tests/common/agg.yaml | 119 -- .../tests/common/sanity.yaml | 156 --- .../nxos_l3_interface/defaults/main.yaml | 2 - .../targets/nxos_l3_interface/meta/main.yml | 3 - .../targets/nxos_l3_interface/tasks/cli.yaml | 32 - .../targets/nxos_l3_interface/tasks/main.yaml | 10 - .../nxos_l3_interface/tasks/nxapi.yaml | 32 - .../nxos_l3_interface/tests/cli/sanity.yaml | 132 --- .../nxos_l3_interface/tests/nxapi/sanity.yaml | 127 -- .../targets/nxos_linkagg/defaults/main.yaml | 3 - .../targets/nxos_linkagg/meta/main.yml | 3 - .../targets/nxos_linkagg/tasks/cli.yaml | 32 - .../targets/nxos_linkagg/tasks/main.yaml | 10 - .../targets/nxos_linkagg/tasks/nxapi.yaml | 32 - .../nxos_linkagg/tests/common/sanity.yaml | 204 ---- .../targets/nxos_lldp/defaults/main.yaml | 2 - .../targets/nxos_lldp/meta/main.yml | 3 - .../targets/nxos_lldp/tasks/cli.yaml | 32 - .../targets/nxos_lldp/tasks/main.yaml | 10 - .../targets/nxos_lldp/tasks/nxapi.yaml | 32 - .../targets/nxos_lldp/tests/cli/sanity.yaml | 49 - .../targets/nxos_lldp/tests/nxapi/sanity.yaml | 49 - .../targets/nxos_ospf/defaults/main.yaml | 2 - .../targets/nxos_ospf/meta/main.yml | 3 - .../targets/nxos_ospf/tasks/cli.yaml | 32 - .../targets/nxos_ospf/tasks/main.yaml | 12 - .../targets/nxos_ospf/tasks/nxapi.yaml | 32 - .../nxos_ospf/tests/common/sanity.yaml | 51 - .../targets/nxos_ospf_vrf/defaults/main.yaml | 2 - .../targets/nxos_ospf_vrf/meta/main.yml | 3 - .../targets/nxos_ospf_vrf/tasks/cli.yaml | 32 - .../targets/nxos_ospf_vrf/tasks/main.yaml | 12 - .../targets/nxos_ospf_vrf/tasks/nxapi.yaml | 32 - .../nxos_ospf_vrf/tests/common/sanity.yaml | 141 --- .../tests/common/sanity.yaml | 13 +- .../tests/common/common_config.yaml | 55 - .../nxos_smoke/tests/common/common_utils.yaml | 44 - .../nxos_static_route/defaults/main.yaml | 5 - .../targets/nxos_static_route/meta/main.yml | 3 - .../targets/nxos_static_route/tasks/cli.yaml | 32 - .../targets/nxos_static_route/tasks/main.yaml | 12 - .../nxos_static_route/tasks/nxapi.yaml | 32 - .../tests/common/sanity.yaml | 213 ---- .../targets/nxos_vlan/defaults/main.yaml | 2 - .../targets/nxos_vlan/meta/main.yml | 3 - .../targets/nxos_vlan/tasks/cli.yaml | 32 - .../targets/nxos_vlan/tasks/main.yaml | 10 - .../targets/nxos_vlan/tasks/nxapi.yaml | 32 - .../targets/nxos_vlan/tests/common/agg.yaml | 122 -- .../nxos_vlan/tests/common/interface.yaml | 129 -- .../nxos_vlan/tests/common/sanity.yaml | 230 ---- tests/sanity/ignore-2.9.txt | 28 +- .../modules/network/nxos/test_nxos_acl.py | 100 -- .../network/nxos/test_nxos_acl_interface.py | 96 -- .../network/nxos/test_nxos_interface.py | 107 -- .../network/nxos/test_nxos_interface_ospf.py | 266 ----- .../network/nxos/test_nxos_l3_interface.py | 377 ------ .../modules/network/nxos/test_nxos_ospf.py | 64 - .../network/nxos/test_nxos_ospf_vrf.py | 118 -- .../network/nxos/test_nxos_static_route.py | 114 -- .../modules/network/nxos/test_nxos_vlan.py | 235 ---- 126 files changed, 30 insertions(+), 19373 deletions(-) create mode 100644 changelogs/fragments/remove_deprecated.yaml delete mode 100644 docs/cisco.nxos.nxos_acl_interface_module.rst delete mode 100644 docs/cisco.nxos.nxos_acl_module.rst delete mode 100644 docs/cisco.nxos.nxos_interface_module.rst delete mode 100644 docs/cisco.nxos.nxos_interface_ospf_module.rst delete mode 100644 docs/cisco.nxos.nxos_l2_interface_module.rst delete mode 100644 docs/cisco.nxos.nxos_l3_interface_module.rst delete mode 100644 docs/cisco.nxos.nxos_linkagg_module.rst delete mode 100644 docs/cisco.nxos.nxos_lldp_module.rst delete mode 100644 docs/cisco.nxos.nxos_ospf_module.rst delete mode 100644 docs/cisco.nxos.nxos_ospf_vrf_module.rst delete mode 100644 docs/cisco.nxos.nxos_smu_module.rst delete mode 100644 docs/cisco.nxos.nxos_static_route_module.rst delete mode 100644 docs/cisco.nxos.nxos_vlan_module.rst delete mode 100644 plugins/modules/nxos_acl.py delete mode 100644 plugins/modules/nxos_acl_interface.py delete mode 100644 plugins/modules/nxos_interface.py delete mode 100644 plugins/modules/nxos_interface_ospf.py delete mode 100644 plugins/modules/nxos_l2_interface.py delete mode 100644 plugins/modules/nxos_l3_interface.py delete mode 100644 plugins/modules/nxos_linkagg.py delete mode 100644 plugins/modules/nxos_lldp.py delete mode 100644 plugins/modules/nxos_ospf.py delete mode 100644 plugins/modules/nxos_ospf_vrf.py delete mode 100644 plugins/modules/nxos_smu.py delete mode 100644 plugins/modules/nxos_static_route.py delete mode 100644 plugins/modules/nxos_vlan.py delete mode 100644 tests/integration/targets/nxos_acl/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_acl/meta/main.yml delete mode 100644 tests/integration/targets/nxos_acl/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_acl/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_acl/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_acl/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_acl_interface/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_acl_interface/meta/main.yml delete mode 100644 tests/integration/targets/nxos_acl_interface/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_acl_interface/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_interface/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_interface/meta/main.yml delete mode 100644 tests/integration/targets/nxos_interface/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_interface/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_interface/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_interface/tests/common/intent.yaml delete mode 100644 tests/integration/targets/nxos_interface/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_interface/tests/common/set_state_absent.yaml delete mode 100644 tests/integration/targets/nxos_interface/tests/common/set_state_present.yaml delete mode 100644 tests/integration/targets/nxos_interface/tests/common/sub_int.yaml delete mode 100644 tests/integration/targets/nxos_interface_ospf/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_interface_ospf/meta/main.yml delete mode 100644 tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_interface_ospf/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_l2_interface/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_l2_interface/meta/main.yml delete mode 100644 tests/integration/targets/nxos_l2_interface/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_l2_interface/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_l2_interface/tests/common/agg.yaml delete mode 100644 tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_l3_interface/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_l3_interface/meta/main.yml delete mode 100644 tests/integration/targets/nxos_l3_interface/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_l3_interface/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml delete mode 100644 tests/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml delete mode 100644 tests/integration/targets/nxos_linkagg/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_linkagg/meta/main.yml delete mode 100644 tests/integration/targets/nxos_linkagg/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_linkagg/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_lldp/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_lldp/meta/main.yml delete mode 100644 tests/integration/targets/nxos_lldp/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_lldp/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_lldp/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_lldp/tests/cli/sanity.yaml delete mode 100644 tests/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml delete mode 100644 tests/integration/targets/nxos_ospf/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_ospf/meta/main.yml delete mode 100644 tests/integration/targets/nxos_ospf/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_ospf/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_ospf/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_ospf/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_ospf_vrf/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_ospf_vrf/meta/main.yml delete mode 100644 tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_static_route/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_static_route/meta/main.yml delete mode 100644 tests/integration/targets/nxos_static_route/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_static_route/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_static_route/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_static_route/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_vlan/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_vlan/meta/main.yml delete mode 100644 tests/integration/targets/nxos_vlan/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_vlan/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_vlan/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_vlan/tests/common/agg.yaml delete mode 100644 tests/integration/targets/nxos_vlan/tests/common/interface.yaml delete mode 100644 tests/integration/targets/nxos_vlan/tests/common/sanity.yaml delete mode 100644 tests/unit/modules/network/nxos/test_nxos_acl.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_acl_interface.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_interface.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_interface_ospf.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_l3_interface.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_ospf.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_static_route.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_vlan.py diff --git a/README.md b/README.md index bcb5c6407..d5d93b820 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,6 @@ Name | Description --- | --- [cisco.nxos.nxos_aaa_server](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_aaa_server_module.rst)|Manages AAA server global configuration. [cisco.nxos.nxos_aaa_server_host](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_aaa_server_host_module.rst)|Manages AAA server host-specific configuration. -[cisco.nxos.nxos_acl](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_acl_module.rst)|(deprecated, removed after 2022-06-01) Manages access list entries for ACLs. -[cisco.nxos.nxos_acl_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_acl_interface_module.rst)|(deprecated, removed after 2022-06-01) Manages applying ACLs to interfaces. [cisco.nxos.nxos_acl_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_acl_interfaces_module.rst)|ACL interfaces resource module [cisco.nxos.nxos_acls](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_acls_module.rst)|ACLs resource module [cisco.nxos.nxos_banner](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_banner_module.rst)|Manage multiline banners on Cisco NXOS devices @@ -78,18 +76,12 @@ Name | Description [cisco.nxos.nxos_igmp_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_igmp_interface_module.rst)|Manages IGMP interface configuration. [cisco.nxos.nxos_igmp_snooping](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_igmp_snooping_module.rst)|Manages IGMP snooping global configuration. [cisco.nxos.nxos_install_os](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_install_os_module.rst)|Set boot options like boot, kickstart image and issu. -[cisco.nxos.nxos_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_interface_module.rst)|(deprecated, removed after 2022-06-01) Manages physical attributes of interfaces. -[cisco.nxos.nxos_interface_ospf](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_interface_ospf_module.rst)|(deprecated, removed after 2022-10-26) Manages configuration of an OSPF interface instance. [cisco.nxos.nxos_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_interfaces_module.rst)|Interfaces resource module -[cisco.nxos.nxos_l2_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_l2_interface_module.rst)|(deprecated, removed after 2022-06-01) Manage Layer-2 interface on Cisco NXOS devices. [cisco.nxos.nxos_l2_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_l2_interfaces_module.rst)|L2 interfaces resource module -[cisco.nxos.nxos_l3_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_l3_interface_module.rst)|(deprecated, removed after 2022-06-01) Manage L3 interfaces on Cisco NXOS network devices [cisco.nxos.nxos_l3_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_l3_interfaces_module.rst)|L3 interfaces resource module [cisco.nxos.nxos_lacp](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_lacp_module.rst)|LACP resource module [cisco.nxos.nxos_lacp_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_lacp_interfaces_module.rst)|LACP interfaces resource module [cisco.nxos.nxos_lag_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_lag_interfaces_module.rst)|LAG interfaces resource module -[cisco.nxos.nxos_linkagg](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_linkagg_module.rst)|(deprecated, removed after 2022-06-01) Manage link aggregation groups on Cisco NXOS devices. -[cisco.nxos.nxos_lldp](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_lldp_module.rst)|(deprecated, removed after 2022-06-01) Manage LLDP configuration on Cisco NXOS network devices. [cisco.nxos.nxos_lldp_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_lldp_global_module.rst)|LLDP resource module [cisco.nxos.nxos_lldp_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_lldp_interfaces_module.rst)|LLDP interfaces resource module [cisco.nxos.nxos_logging](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_logging_module.rst)|Manage logging on network devices @@ -99,9 +91,7 @@ Name | Description [cisco.nxos.nxos_ntp_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ntp_global_module.rst)|NTP Global resource module. [cisco.nxos.nxos_ntp_options](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ntp_options_module.rst)|Manages NTP options. [cisco.nxos.nxos_nxapi](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_nxapi_module.rst)|Manage NXAPI configuration on an NXOS device. -[cisco.nxos.nxos_ospf](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ospf_module.rst)|(deprecated, removed after 2022-06-01) Manages configuration of an ospf instance. [cisco.nxos.nxos_ospf_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ospf_interfaces_module.rst)|OSPF Interfaces Resource Module. -[cisco.nxos.nxos_ospf_vrf](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ospf_vrf_module.rst)|(deprecated, removed after 2022-10-01)Manages a VRF for an OSPF router. [cisco.nxos.nxos_ospfv2](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ospfv2_module.rst)|OSPFv2 resource module [cisco.nxos.nxos_ospfv3](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_ospfv3_module.rst)|OSPFv3 resource module [cisco.nxos.nxos_overlay_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_overlay_global_module.rst)|Configures anycast gateway MAC of the switch. @@ -114,7 +104,6 @@ Name | Description [cisco.nxos.nxos_rollback](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_rollback_module.rst)|Set a checkpoint or rollback to a checkpoint. [cisco.nxos.nxos_route_maps](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_route_maps_module.rst)|Route Maps resource module. [cisco.nxos.nxos_rpm](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_rpm_module.rst)|Install patch or feature rpms on Cisco NX-OS devices. -[cisco.nxos.nxos_smu](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_smu_module.rst)|(deprecated, removed after 2022-10-01) Perform SMUs on Cisco NX-OS devices. [cisco.nxos.nxos_snapshot](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_snapshot_module.rst)|Manage snapshots of the running states of selected features. [cisco.nxos.nxos_snmp_community](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_snmp_community_module.rst)|(deprecated, removed after 2024-01-01) Manages SNMP community configs. [cisco.nxos.nxos_snmp_contact](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_snmp_contact_module.rst)|(deprecated, removed after 2024-01-01) Manages SNMP contact info. @@ -123,14 +112,12 @@ Name | Description [cisco.nxos.nxos_snmp_server](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_snmp_server_module.rst)|SNMP Server resource module. [cisco.nxos.nxos_snmp_traps](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_snmp_traps_module.rst)|(deprecated, removed after 2024-01-01) Manages SNMP traps. [cisco.nxos.nxos_snmp_user](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_snmp_user_module.rst)|(deprecated, removed after 2024-01-01) Manages SNMP users for monitoring. -[cisco.nxos.nxos_static_route](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_static_route_module.rst)|(deprecated, removed after 2022-06-01) Manages static route configuration [cisco.nxos.nxos_static_routes](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_static_routes_module.rst)|Static routes resource module [cisco.nxos.nxos_system](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_system_module.rst)|Manage the system attributes on Cisco NXOS devices [cisco.nxos.nxos_telemetry](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_telemetry_module.rst)|TELEMETRY resource module [cisco.nxos.nxos_udld](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_udld_module.rst)|Manages UDLD global configuration params. [cisco.nxos.nxos_udld_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_udld_interface_module.rst)|Manages UDLD interface configuration params. [cisco.nxos.nxos_user](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_user_module.rst)|Manage the collection of local users on Nexus devices -[cisco.nxos.nxos_vlan](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_vlan_module.rst)|(deprecated, removed after 2022-06-01) Manages VLAN resources and attributes. [cisco.nxos.nxos_vlans](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_vlans_module.rst)|VLANs resource module [cisco.nxos.nxos_vpc](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_vpc_module.rst)|Manages global VPC configuration [cisco.nxos.nxos_vpc_interface](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_vpc_interface_module.rst)|Manages interface VPC configuration diff --git a/changelogs/fragments/remove_deprecated.yaml b/changelogs/fragments/remove_deprecated.yaml new file mode 100644 index 000000000..36d9e5668 --- /dev/null +++ b/changelogs/fragments/remove_deprecated.yaml @@ -0,0 +1,17 @@ +--- +removed_features: + - "This release removes all deprecated plugins that have reached their end-of-life." + - "This includes the following modules:" + - "nxos_acl" + - "nxos_acl_interface" + - "nxos_interface" + - "nxos_interface_ospf" + - "nxos_l2_interface" + - "nxos_l3_interface" + - "nxos_linkagg" + - "nxos_lldp" + - "nxos_ospf" + - "nxos_ospf_vrf" + - "nxos_smu" + - "nxos_static_route" + - "nxos_vlan" diff --git a/docs/cisco.nxos.nxos_acl_interface_module.rst b/docs/cisco.nxos.nxos_acl_interface_module.rst deleted file mode 100644 index 1266f6cab..000000000 --- a/docs/cisco.nxos.nxos_acl_interface_module.rst +++ /dev/null @@ -1,438 +0,0 @@ -.. _cisco.nxos.nxos_acl_interface_module: - - -***************************** -cisco.nxos.nxos_acl_interface -***************************** - -**(deprecated, removed after 2022-06-01) Manages applying ACLs to interfaces.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_acl_interfaces - - - -Synopsis --------- -- Manages applying ACLs to interfaces. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- direction - -
- string - / required -
-
-
    Choices: -
  • ingress
  • -
  • egress
  • -
-
-
Direction ACL to be applied in on the interface.
-
-
- interface - -
- string - / required -
-
- -
Full name of interface, e.g. Ethernet1/1.
-
-
- name - -
- string - / required -
-
- -
Case sensitive name of the access list (ACL).
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Specify desired state of the resource.
-
-
- - -Notes ------ - -.. note:: - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: apply egress acl to ethernet1/41 - cisco.nxos.nxos_acl_interface: - name: ANSIBLE - interface: ethernet1/41 - direction: egress - state: present - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - - - - - - -
KeyReturnedDescription
-
- acl_applied_to - -
- list -
-
always -
list of interfaces the ACL is applied to
-
-
Sample:
-
[{'acl_type': 'Router ACL', 'direction': 'egress', 'interface': 'Ethernet1/41', 'name': 'ANSIBLE'}]
-
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['interface ethernet1/41', 'ip access-group ANSIBLE out']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Jason Edelman (@jedelman8) -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_acl_module.rst b/docs/cisco.nxos.nxos_acl_module.rst deleted file mode 100644 index 974509303..000000000 --- a/docs/cisco.nxos.nxos_acl_module.rst +++ /dev/null @@ -1,836 +0,0 @@ -.. _cisco.nxos.nxos_acl_module: - - -******************* -cisco.nxos.nxos_acl -******************* - -**(deprecated, removed after 2022-06-01) Manages access list entries for ACLs.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_acls - - - -Synopsis --------- -- Manages access list entries for ACLs. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- ack - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match on the ACK bit.
-
-
- action - -
- string -
-
-
    Choices: -
  • permit
  • -
  • deny
  • -
  • remark
  • -
-
-
Action of the ACE.
-
-
- dest - -
- string -
-
- -
Destination ip and mask using IP/MASK notation and supports the keyword 'any'.
-
-
- dest_port1 - -
- string -
-
- -
Port/protocol and also first (lower) port when using range operand.
-
-
- dest_port2 - -
- string -
-
- -
Second (end) port when using range operand.
-
-
- dest_port_op - -
- string -
-
-
    Choices: -
  • any
  • -
  • eq
  • -
  • gt
  • -
  • lt
  • -
  • neq
  • -
  • range
  • -
-
-
Destination port operands such as eq, neq, gt, lt, range.
-
-
- dscp - -
- string -
-
-
    Choices: -
  • af11
  • -
  • af12
  • -
  • af13
  • -
  • af21
  • -
  • af22
  • -
  • af23
  • -
  • af31
  • -
  • af32
  • -
  • af33
  • -
  • af41
  • -
  • af42
  • -
  • af43
  • -
  • cs1
  • -
  • cs2
  • -
  • cs3
  • -
  • cs4
  • -
  • cs5
  • -
  • cs6
  • -
  • cs7
  • -
  • default
  • -
  • ef
  • -
-
-
Match packets with given dscp value.
-
-
- established - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match established connections.
-
-
- fin - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match on the FIN bit.
-
-
- fragments - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Check non-initial fragments.
-
-
- log - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Log matches against this entry.
-
-
- name - -
- string - / required -
-
- -
Case sensitive name of the access list (ACL).
-
-
- precedence - -
- string -
-
-
    Choices: -
  • critical
  • -
  • flash
  • -
  • flash-override
  • -
  • immediate
  • -
  • internet
  • -
  • network
  • -
  • priority
  • -
  • routine
  • -
-
-
Match packets with given precedence.
-
-
- proto - -
- string -
-
- -
Port number or protocol (as supported by the switch).
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- psh - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match on the PSH bit.
-
-
- remark - -
- string -
-
- -
If action is set to remark, this is the description.
-
-
- rst - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match on the RST bit.
-
-
- seq - -
- string -
-
- -
Sequence number of the entry (ACE).
-
-
- src - -
- string -
-
- -
Source ip and mask using IP/MASK notation and supports keyword 'any'.
-
-
- src_port1 - -
- string -
-
- -
Port/protocol and also first (lower) port when using range operand.
-
-
- src_port2 - -
- string -
-
- -
Second (end) port when using range operand.
-
-
- src_port_op - -
- string -
-
-
    Choices: -
  • any
  • -
  • eq
  • -
  • gt
  • -
  • lt
  • -
  • neq
  • -
  • range
  • -
-
-
Source port operands such as eq, neq, gt, lt, range.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
  • delete_acl
  • -
-
-
Specify desired state of the resource.
-
-
- syn - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match on the SYN bit.
-
-
- time_range - -
- string -
-
- -
Name of time-range to apply.
-
-
- urg - -
- string -
-
-
    Choices: -
  • enable
  • -
-
-
Match on the URG bit.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - ``state=absent`` removes the ACE if it exists. - - ``state=delete_acl`` deletes the ACL if it exists. - - For idempotency, use port numbers for the src/dest port params like *src_port1* and names for the well defined protocols for the *proto* param. - - Although this module is idempotent in that if the ace as presented in the task is identical to the one on the switch, no changes will be made. If there is any difference, what is in Ansible will be pushed (configured options will be overridden). This is to improve security, but at the same time remember an ACE is removed, then re-added, so if there is a change, the new ACE will be exactly what parameters you are sending to the module. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - # configure ACL ANSIBLE - - cisco.nxos.nxos_acl: - name: ANSIBLE - seq: 10 - action: permit - proto: tcp - src: 192.0.2.1/24 - dest: any - state: present - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['ip access-list ANSIBLE', '10 permit tcp 192.0.2.1/24 any']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Jason Edelman (@jedelman8) -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_interface_module.rst b/docs/cisco.nxos.nxos_interface_module.rst deleted file mode 100644 index 644581a92..000000000 --- a/docs/cisco.nxos.nxos_interface_module.rst +++ /dev/null @@ -1,1043 +0,0 @@ -.. _cisco.nxos.nxos_interface_module: - - -************************* -cisco.nxos.nxos_interface -************************* - -**(deprecated, removed after 2022-06-01) Manages physical attributes of interfaces.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_interfaces - - - -Synopsis --------- -- Manages physical attributes of interfaces of NX-OS switches. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- admin_state - -
- string -
-
-
    Choices: -
  • up ←
  • -
  • down
  • -
-
-
Administrative state of the interface.
-
-
- aggregate - -
- list - / elements=dictionary -
-
- -
List of Interfaces definitions.
-
-
- admin_state - -
- string -
-
-
    Choices: -
  • up
  • -
  • down
  • -
-
-
Administrative state of the interface.
-
-
- delay - -
- integer -
-
- -
Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state arguments.
-
-
- description - -
- string -
-
- -
Interface description.
-
-
- duplex - -
- string -
-
-
    Choices: -
  • full
  • -
  • half
  • -
  • auto
  • -
-
-
Interface link status. Applicable for ethernet interface only.
-
-
- fabric_forwarding_anycast_gateway - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Associate SVI with anycast gateway under VLAN configuration mode. Applicable for SVI interface only.
-
-
- interface_type - -
- string -
-
-
    Choices: -
  • loopback
  • -
  • portchannel
  • -
  • svi
  • -
  • nve
  • -
-
-
Interface type to be unconfigured from the device.
-
-
- ip_forward - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
-
-
Enable/Disable ip forward feature on SVIs.
-
-
- mode - -
- string -
-
-
    Choices: -
  • layer2
  • -
  • layer3
  • -
-
-
Manage Layer 2 or Layer 3 state of the interface. This option is supported for ethernet and portchannel interface. Applicable for ethernet and portchannel interface only.
-
-
- mtu - -
- string -
-
- -
MTU for a specific interface. Must be an even number between 576 and 9216. Applicable for ethernet interface only.
-
-
- name - -
- string - / required -
-
- -
Full name of interface, i.e. Ethernet1/1, port-channel10.
-
-
- neighbors - -
- list - / elements=dictionary -
-
- -
Check the operational state of given interface name for LLDP neighbor.
-
The following suboptions are available. This is state check parameter only.
-
-
- host - -
- string -
-
- -
LLDP neighbor host for given interface name.
-
-
- port - -
- string -
-
- -
LLDP neighbor port to which given interface name is connected.
-
-
- rx_rate - -
- string -
-
- -
Receiver rate in bits per second (bps).
-
This is state check parameter only.
- -
-
- speed - -
- string -
-
- -
Interface link speed. Applicable for ethernet interface only.
-
-
- state - -
- string -
-
-
    Choices: -
  • present
  • -
  • absent
  • -
  • default
  • -
-
-
Specify desired state of the resource.
-
-
- tx_rate - -
- string -
-
- -
Transmit rate in bits per second (bps).
-
This is state check parameter only.
- -
-
- delay - -
- integer -
-
- Default:
10
-
-
Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state arguments.
-
-
- description - -
- string -
-
- -
Interface description.
-
-
- duplex - -
- string -
-
-
    Choices: -
  • full
  • -
  • half
  • -
  • auto
  • -
-
-
Interface link status. Applicable for ethernet interface only.
-
-
- fabric_forwarding_anycast_gateway - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Associate SVI with anycast gateway under VLAN configuration mode. Applicable for SVI interface only.
-
-
- interface_type - -
- string -
-
-
    Choices: -
  • loopback
  • -
  • portchannel
  • -
  • svi
  • -
  • nve
  • -
-
-
Interface type to be unconfigured from the device.
-
-
- ip_forward - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
-
-
Enable/Disable ip forward feature on SVIs.
-
-
- mode - -
- string -
-
-
    Choices: -
  • layer2
  • -
  • layer3
  • -
-
-
Manage Layer 2 or Layer 3 state of the interface. This option is supported for ethernet and portchannel interface. Applicable for ethernet and portchannel interface only.
-
-
- mtu - -
- string -
-
- -
MTU for a specific interface. Must be an even number between 576 and 9216. Applicable for ethernet interface only.
-
-
- name - -
- string -
-
- -
Full name of interface, i.e. Ethernet1/1, port-channel10.
-

aliases: interface
-
-
- neighbors - -
- list - / elements=dictionary -
-
- -
Check the operational state of given interface name for LLDP neighbor.
-
The following suboptions are available. This is state check parameter only.
-
-
- host - -
- string -
-
- -
LLDP neighbor host for given interface name.
-
-
- port - -
- string -
-
- -
LLDP neighbor port to which given interface name is connected.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- rx_rate - -
- string -
-
- -
Receiver rate in bits per second (bps).
-
This is state check parameter only.
- -
-
- speed - -
- string -
-
- -
Interface link speed. Applicable for ethernet interface only.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
  • default
  • -
-
-
Specify desired state of the resource.
-
-
- tx_rate - -
- string -
-
- -
Transmit rate in bits per second (bps).
-
This is state check parameter only.
- -
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - This module is also used to create logical interfaces such as svis and loopbacks. - - Be cautious of platform specific idiosyncrasies. For example, when you default a loopback interface, the admin state toggles on certain versions of NX-OS. - - The :ref:`cisco.nxos.nxos_overlay_global ` ``anycast_gateway_mac`` attribute must be set before setting the ``fabric_forwarding_anycast_gateway`` property. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: Ensure an interface is a Layer 3 port and that it has the proper description - cisco.nxos.nxos_interface: - name: Ethernet1/1 - description: Configured by Ansible - mode: layer3 - - - name: Admin down an interface - cisco.nxos.nxos_interface: - name: Ethernet2/1 - admin_state: down - - - name: Remove all loopback interfaces - cisco.nxos.nxos_interface: - name: loopback - state: absent - - - name: Remove all logical interfaces - cisco.nxos.nxos_interface: - interface_type: '{{ item }} ' - state: absent - loop: - - loopback - - portchannel - - svi - - nve - - - name: Admin up all loopback interfaces - cisco.nxos.nxos_interface: - name: loopback 0-1023 - admin_state: up - - - name: Admin down all loopback interfaces - cisco.nxos.nxos_interface: - name: loopback 0-1023 - admin_state: down - - - name: Check neighbors intent arguments - cisco.nxos.nxos_interface: - name: Ethernet2/3 - neighbors: - - port: Ethernet2/3 - host: abc.mycompany.com - - - name: Add interface using aggregate - cisco.nxos.nxos_interface: - aggregate: - - {name: Ethernet0/1, mtu: 256, description: test-interface-1} - - {name: Ethernet0/2, mtu: 516, description: test-interface-2} - duplex: full - speed: 100 - state: present - - - name: Delete interface using aggregate - cisco.nxos.nxos_interface: - aggregate: - - name: Loopback9 - - name: Loopback10 - state: absent - - - name: Check intent arguments - cisco.nxos.nxos_interface: - name: Ethernet0/2 - state: up - tx_rate: ge(0) - rx_rate: le(0) - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
command list sent to the device
-
-
Sample:
-
['interface Ethernet2/3', 'mtu 1500', 'speed 10']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Jason Edelman (@jedelman8) -- Trishna Guha (@trishnaguha) diff --git a/docs/cisco.nxos.nxos_interface_ospf_module.rst b/docs/cisco.nxos.nxos_interface_ospf_module.rst deleted file mode 100644 index 02e9f4143..000000000 --- a/docs/cisco.nxos.nxos_interface_ospf_module.rst +++ /dev/null @@ -1,623 +0,0 @@ -.. _cisco.nxos.nxos_interface_ospf_module: - - -****************************** -cisco.nxos.nxos_interface_ospf -****************************** - -**(deprecated, removed after 2022-10-26) Manages configuration of an OSPF interface instance.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-10-26 -:Why: Updated modules released with more functionality -:Alternative: nxos_ospf_interfaces - - - -Synopsis --------- -- Manages configuration of an OSPF interface instance. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- area - -
- string - / required -
-
- -
Ospf area associated with this cisco_interface_ospf instance. Valid values are a string, formatted as an IP address (i.e. "0.0.0.0") or as an integer.
-
-
- bfd - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
  • default
  • -
-
-
Enables bfd at interface level. This overrides the bfd variable set at the ospf router level.
-
Valid values are 'enable', 'disable' or 'default'.
-
Dependency: ''feature bfd''
-
-
- cost - -
- string -
-
- -
The cost associated with this cisco_interface_ospf instance.
-
-
- dead_interval - -
- string -
-
- -
Time interval an ospf neighbor waits for a hello packet before tearing down adjacencies. Valid values are an integer or the keyword 'default'.
-
-
- hello_interval - -
- string -
-
- -
Time between sending successive hello packets. Valid values are an integer or the keyword 'default'.
-
-
- interface - -
- string - / required -
-
- -
Name of this cisco_interface resource. Valid value is a string.
-
-
- message_digest - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enables or disables the usage of message digest authentication.
-
-
- message_digest_algorithm_type - -
- string -
-
-
    Choices: -
  • md5
  • -
  • default
  • -
-
-
Algorithm used for authentication among neighboring routers within an area. Valid values are 'md5' and 'default'.
-
-
- message_digest_encryption_type - -
- string -
-
-
    Choices: -
  • cisco_type_7
  • -
  • 3des
  • -
  • default
  • -
-
-
Specifies the scheme used for encrypting message_digest_password. Valid values are '3des' or 'cisco_type_7' encryption or 'default'.
-
-
- message_digest_key_id - -
- string -
-
- -
Md5 authentication key-id associated with the ospf instance. If this is present, message_digest_encryption_type, message_digest_algorithm_type and message_digest_password are mandatory. Valid value is an integer and 'default'.
-
-
- message_digest_password - -
- string -
-
- -
Specifies the message_digest password. Valid value is a string.
-
-
- network - -
- string -
-
-
    Choices: -
  • point-to-point
  • -
  • broadcast
  • -
-
-
Specifies interface ospf network type. Valid values are 'point-to-point' or 'broadcast'.
-
-
- ospf - -
- string - / required -
-
- -
Name of the ospf instance.
-
-
- passive_interface - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable or disable passive-interface state on this interface. true - (enable) Prevent OSPF from establishing an adjacency or sending routing updates on this interface. false - (disable) Override global 'passive-interface default' for this interface.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Determines whether the config should be present or not on the device.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - Default, where supported, restores params default value. - - To remove an existing authentication configuration you should use ``message_digest_key_id=default`` plus all other options matching their existing values. - - Loopback interfaces only support ospf network type 'point-to-point'. - - ``state=absent`` removes the whole OSPF interface configuration. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - cisco.nxos.nxos_interface_ospf: - interface: ethernet1/32 - ospf: 1 - area: 1 - bfd: disable - cost: default - - - cisco.nxos.nxos_interface_ospf: - interface: loopback0 - ospf: prod - area: 0.0.0.0 - bfd: enable - network: point-to-point - state: present - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['interface Ethernet1/32', 'ip router ospf 1 area 0.0.0.1', 'ip ospf bfd disable']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-10-26. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_l2_interface_module.rst b/docs/cisco.nxos.nxos_l2_interface_module.rst deleted file mode 100644 index 947757fee..000000000 --- a/docs/cisco.nxos.nxos_l2_interface_module.rst +++ /dev/null @@ -1,640 +0,0 @@ -.. _cisco.nxos.nxos_l2_interface_module: - - -**************************** -cisco.nxos.nxos_l2_interface -**************************** - -**(deprecated, removed after 2022-06-01) Manage Layer-2 interface on Cisco NXOS devices.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_l2_interfaces - - - -Synopsis --------- -- This module provides declarative management of Layer-2 interface on Cisco NXOS devices. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- access_vlan - -
- string -
-
- -
Configure given VLAN in access port. If mode=access, used as the access VLAN ID.
-
-
- aggregate - -
- list - / elements=dictionary -
-
- -
List of Layer-2 interface definitions.
-
-
- access_vlan - -
- string -
-
- -
Configure given VLAN in access port. If mode=access, used as the access VLAN ID.
-
-
- mode - -
- string -
-
-
    Choices: -
  • access
  • -
  • trunk
  • -
-
-
Mode in which interface needs to be configured.
-
-
- name - -
- string -
-
- -
Full name of the interface excluding any logical unit number, i.e. Ethernet1/1.
-

aliases: interface
-
-
- native_vlan - -
- string -
-
- -
Native VLAN to be configured in trunk port. If mode=trunk, used as the trunk native VLAN ID.
-
-
- state - -
- string -
-
-
    Choices: -
  • present
  • -
  • absent
  • -
  • unconfigured
  • -
-
-
Manage the state of the Layer-2 Interface configuration.
-
-
- trunk_allowed_vlans - -
- string -
-
- -
List of allowed VLANs in a given trunk port. If mode=trunk, these are the only VLANs that will be configured on the trunk, i.e. "2-10,15".
-
-
- trunk_vlans - -
- string -
-
- -
List of VLANs to be configured in trunk port. If mode=trunk, used as the VLAN range to ADD or REMOVE from the trunk.
-

aliases: trunk_add_vlans
-
-
- mode - -
- string -
-
-
    Choices: -
  • access
  • -
  • trunk
  • -
-
-
Mode in which interface needs to be configured.
-
-
- name - -
- string -
-
- -
Full name of the interface excluding any logical unit number, i.e. Ethernet1/1.
-

aliases: interface
-
-
- native_vlan - -
- string -
-
- -
Native VLAN to be configured in trunk port. If mode=trunk, used as the trunk native VLAN ID.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
  • unconfigured
  • -
-
-
Manage the state of the Layer-2 Interface configuration.
-
-
- trunk_allowed_vlans - -
- string -
-
- -
List of allowed VLANs in a given trunk port. If mode=trunk, these are the only VLANs that will be configured on the trunk, i.e. "2-10,15".
-
-
- trunk_vlans - -
- string -
-
- -
List of VLANs to be configured in trunk port. If mode=trunk, used as the VLAN range to ADD or REMOVE from the trunk.
-

aliases: trunk_add_vlans
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.0(3)I5(1). - - Unsupported for Cisco MDS - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: Ensure Eth1/5 is in its default l2 interface state - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - state: unconfigured - - - name: Ensure Eth1/5 is configured for access vlan 20 - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: access - access_vlan: 20 - - - name: Ensure Eth1/5 only has vlans 5-10 as trunk vlans - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: trunk - native_vlan: 10 - trunk_vlans: 5-10 - - - name: Ensure eth1/5 is a trunk port and ensure 2-50 are being tagged (doesn't mean - others aren't also being tagged) - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: trunk - native_vlan: 10 - trunk_vlans: 2-50 - - - name: Ensure these VLANs are not being tagged on the trunk - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: trunk - trunk_vlans: 51-4094 - state: absent - - - name: Aggregate Configure interfaces for access_vlan with aggregate - cisco.nxos.nxos_l2_interface: - aggregate: - - {name: Ethernet1/2, access_vlan: 6} - - {name: Ethernet1/7, access_vlan: 15} - mode: access - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always, except for the platforms that use Netconf transport to manage the device. -
The list of configuration mode commands to send to the device
-
-
Sample:
-
['interface eth1/5', 'switchport access vlan 20']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Trishna Guha (@trishnaguha) diff --git a/docs/cisco.nxos.nxos_l3_interface_module.rst b/docs/cisco.nxos.nxos_l3_interface_module.rst deleted file mode 100644 index 32addf270..000000000 --- a/docs/cisco.nxos.nxos_l3_interface_module.rst +++ /dev/null @@ -1,516 +0,0 @@ -.. _cisco.nxos.nxos_l3_interface_module: - - -**************************** -cisco.nxos.nxos_l3_interface -**************************** - -**(deprecated, removed after 2022-06-01) Manage L3 interfaces on Cisco NXOS network devices** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_l3_interfaces - - - -Synopsis --------- -- This module provides declarative management of L3 interfaces on Cisco NXOS network devices. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- aggregate - -
- list - / elements=dictionary -
-
- -
List of L3 interfaces definitions.
-
-
- ipv4 - -
- string -
-
- -
IPv4 of the L3 interface.
-
-
- ipv6 - -
- string -
-
- -
IPv6 of the L3 interface.
-
-
- name - -
- string -
-
- -
Name of the L3 interface.
-
-
- state - -
- string -
-
-
    Choices: -
  • present
  • -
  • absent
  • -
-
-
State of the L3 interface configuration.
-
-
- ipv4 - -
- string -
-
- -
IPv4 of the L3 interface.
-
-
- ipv6 - -
- string -
-
- -
IPv6 of the L3 interface.
-
-
- name - -
- string -
-
- -
Name of the L3 interface.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
State of the L3 interface configuration.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.0(3)I5(1). - - Unsupported for Cisco MDS - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: Set interface IPv4 address - cisco.nxos.nxos_l3_interface: - name: Ethernet2/3 - ipv4: 192.168.0.1/24 - - - name: Remove interface IPv4 address - cisco.nxos.nxos_l3_interface: - name: Ethernet2/3 - state: absent - - - name: Set IP addresses on aggregate - cisco.nxos.nxos_l3_interface: - aggregate: - - {name: "Ethernet2/1", ipv4: "192.168.2.10/24"} - - {name: "Ethernet2/5", ipv4: "192.168.3.10/24", ipv6: "fd5d:12c9:2201:1::1/64"} - - - name: Remove IP addresses on aggregate - cisco.nxos.nxos_l3_interface: - aggregate: - - {name: "Ethernet2/1", ipv4: "192.168.2.10/24"} - - {name: "Ethernet2/5", ipv4: "192.168.3.10/24", ipv6: "fd5d:12c9:2201:1::1/64"} - state: absent - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always, except for the platforms that use Netconf transport to manage the device. -
The list of configuration mode commands to send to the device
-
-
Sample:
-
['interface ethernet2/3', 'no switchport', 'ip address 192.168.22.1/24', 'ipv6 address "fd5d:12c9:2201:1::1/64"', 'no ip address 192.168.22.1/24']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Trishna Guha (@trishnaguha) diff --git a/docs/cisco.nxos.nxos_linkagg_module.rst b/docs/cisco.nxos.nxos_linkagg_module.rst deleted file mode 100644 index 95c9d7645..000000000 --- a/docs/cisco.nxos.nxos_linkagg_module.rst +++ /dev/null @@ -1,638 +0,0 @@ -.. _cisco.nxos.nxos_linkagg_module: - - -*********************** -cisco.nxos.nxos_linkagg -*********************** - -**(deprecated, removed after 2022-06-01) Manage link aggregation groups on Cisco NXOS devices.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality. -:Alternative: nxos_lag_interfaces - - - -Synopsis --------- -- This module provides declarative management of link aggregation groups on Cisco NXOS devices. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- aggregate - -
- list - / elements=dictionary -
-
- -
List of link aggregation definitions.
-
-
- force - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
When true it forces link aggregation group members to match what is declared in the members param. This can be used to remove members.
-
-
- group - -
- string - / required -
-
- -
Channel-group number for the port-channel Link aggregation group.
-
-
- members - -
- list - / elements=string -
-
- -
List of interfaces that will be managed in the link aggregation group.
-
-
- min_links - -
- integer -
-
- -
Minimum number of ports required up before bringing up the link aggregation group.
-
-
- mode - -
- string -
-
-
    Choices: -
  • active
  • -
  • on
  • -
  • passive
  • -
-
-
Mode for the link aggregation group.
-
-
- state - -
- string -
-
-
    Choices: -
  • present
  • -
  • absent
  • -
-
-
State of the link aggregation group.
-
-
- force - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
When true it forces link aggregation group members to match what is declared in the members param. This can be used to remove members.
-
-
- group - -
- string -
-
- -
Channel-group number for the port-channel Link aggregation group.
-
-
- members - -
- list - / elements=string -
-
- -
List of interfaces that will be managed in the link aggregation group.
-
-
- min_links - -
- integer -
-
- -
Minimum number of ports required up before bringing up the link aggregation group.
-
-
- mode - -
- string -
-
-
    Choices: -
  • active
  • -
  • on ←
  • -
  • passive
  • -
-
-
Mode for the link aggregation group.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- purge - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Purge links not defined in the aggregate parameter.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
State of the link aggregation group.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.0(3)I5(1). - - Unsupported for Cisco MDS - - ``state=absent`` removes the portchannel config and interface if it already exists. If members to be removed are not explicitly passed, all existing members (if any), are removed. - - Members must be a list. - - LACP needs to be enabled first if active/passive modes are used. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: create link aggregation group - cisco.nxos.nxos_linkagg: - group: 99 - state: present - - - name: delete link aggregation group - cisco.nxos.nxos_linkagg: - group: 99 - state: absent - - - name: set link aggregation group to members - cisco.nxos.nxos_linkagg: - group: 10 - min_links: 3 - mode: active - members: - - Ethernet1/2 - - Ethernet1/4 - - - name: remove link aggregation group from Ethernet1/2 - cisco.nxos.nxos_linkagg: - group: 10 - min_links: 3 - mode: active - members: - - Ethernet1/4 - - - name: Create aggregate of linkagg definitions - cisco.nxos.nxos_linkagg: - aggregate: - - {group: 3} - - {group: 100, min_links: 3} - - - name: Remove aggregate of linkagg definitions - cisco.nxos.nxos_linkagg: - aggregate: - - {group: 3} - - {group: 100, min_links: 3} - state: absent - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always, except for the platforms that use Netconf transport to manage the device. -
The list of configuration mode commands to send to the device
-
-
Sample:
-
['interface port-channel 30', 'lacp min-links 5', 'interface Ethernet2/1', 'channel-group 30 mode active', 'no interface port-channel 30']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Trishna Guha (@trishnaguha) diff --git a/docs/cisco.nxos.nxos_lldp_module.rst b/docs/cisco.nxos.nxos_lldp_module.rst deleted file mode 100644 index 67434174d..000000000 --- a/docs/cisco.nxos.nxos_lldp_module.rst +++ /dev/null @@ -1,373 +0,0 @@ -.. _cisco.nxos.nxos_lldp_module: - - -******************** -cisco.nxos.nxos_lldp -******************** - -**(deprecated, removed after 2022-06-01) Manage LLDP configuration on Cisco NXOS network devices.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_lldp_global - - - -Synopsis --------- -- This module provides declarative management of LLDP service on Cisco NXOS network devices. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
  • enabled
  • -
  • disabled
  • -
-
-
State of the LLDP configuration. If value is present lldp will be enabled else if it is absent it will be disabled.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.0(3)I5(1). - - Unsupported for Cisco MDS - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: Enable LLDP service - cisco.nxos.nxos_lldp: - state: present - - - name: Disable LLDP service - cisco.nxos.nxos_lldp: - state: absent - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always, except for the platforms that use Netconf transport to manage the device. -
The list of configuration mode commands to send to the device
-
-
Sample:
-
['feature lldp']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Ganesh Nalawade (@ganeshrn) diff --git a/docs/cisco.nxos.nxos_ospf_module.rst b/docs/cisco.nxos.nxos_ospf_module.rst deleted file mode 100644 index 2c4566a17..000000000 --- a/docs/cisco.nxos.nxos_ospf_module.rst +++ /dev/null @@ -1,382 +0,0 @@ -.. _cisco.nxos.nxos_ospf_module: - - -******************** -cisco.nxos.nxos_ospf -******************** - -**(deprecated, removed after 2022-06-01) Manages configuration of an ospf instance.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality. -:Alternative: nxos_ospfv2 and nxos_ospfv3 - - - -Synopsis --------- -- Manages configuration of an ospf instance. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- ospf - -
- string - / required -
-
- -
Name of the ospf instance.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Determines whether the config should be present or not on the device.
-
-
- - -Notes ------ - -.. note:: - - Unsupported for Cisco MDS - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - cisco.nxos.nxos_ospf: - ospf: 1 - state: present - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['router ospf 1']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_ospf_vrf_module.rst b/docs/cisco.nxos.nxos_ospf_vrf_module.rst deleted file mode 100644 index 00c969595..000000000 --- a/docs/cisco.nxos.nxos_ospf_vrf_module.rst +++ /dev/null @@ -1,602 +0,0 @@ -.. _cisco.nxos.nxos_ospf_vrf_module: - - -************************ -cisco.nxos.nxos_ospf_vrf -************************ - -**(deprecated, removed after 2022-10-01)Manages a VRF for an OSPF router.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-10-01 -:Why: Updated modules released with more functionality. -:Alternative: nxos_ospfv2 and nxos_ospfv3 - - - -Synopsis --------- -- Manages a VRF for an OSPF router. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- auto_cost - -
- string -
-
- -
Specifies the reference bandwidth used to assign OSPF cost. Valid values are an integer, in Mbps, or the keyword 'default'.
-
-
- bfd - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
-
-
Enables BFD on all OSPF interfaces.
-
Dependency: ''feature bfd''
-
-
- default_metric - -
- string -
-
- -
Specify the default Metric value. Valid values are an integer or the keyword 'default'.
-
-
- log_adjacency - -
- string -
-
-
    Choices: -
  • log
  • -
  • detail
  • -
  • default
  • -
-
-
Controls the level of log messages generated whenever a neighbor changes state. Valid values are 'log', 'detail', and 'default'.
-
-
- ospf - -
- string - / required -
-
- -
Name of the OSPF instance.
-
-
- passive_interface - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Setting to yes will suppress routing update on interface.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- router_id - -
- string -
-
- -
Router Identifier (ID) of the OSPF router VRF instance.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
State of ospf vrf configuration.
-
-
- timer_throttle_lsa_hold - -
- string -
-
- -
Specify the hold interval for rate-limiting Link-State Advertisement (LSA) generation. Valid values are an integer, in milliseconds, or the keyword 'default'.
-
-
- timer_throttle_lsa_max - -
- string -
-
- -
Specify the max interval for rate-limiting Link-State Advertisement (LSA) generation. Valid values are an integer, in milliseconds, or the keyword 'default'.
-
-
- timer_throttle_lsa_start - -
- string -
-
- -
Specify the start interval for rate-limiting Link-State Advertisement (LSA) generation. Valid values are an integer, in milliseconds, or the keyword 'default'.
-
-
- timer_throttle_spf_hold - -
- string -
-
- -
Specify minimum hold time between Shortest Path First (SPF) calculations. Valid values are an integer, in milliseconds, or the keyword 'default'.
-
-
- timer_throttle_spf_max - -
- string -
-
- -
Specify the maximum wait time between Shortest Path First (SPF) calculations. Valid values are an integer, in milliseconds, or the keyword 'default'.
-
-
- timer_throttle_spf_start - -
- string -
-
- -
Specify initial Shortest Path First (SPF) schedule delay. Valid values are an integer, in milliseconds, or the keyword 'default'.
-
-
- vrf - -
- string -
-
- Default:
"default"
-
-
Name of the resource instance. Valid value is a string. The name 'default' is a valid VRF representing the global OSPF.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - Value *default* restores params default value, if any. Otherwise it removes the existing param configuration. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - cisco.nxos.nxos_ospf_vrf: - ospf: 1 - timer_throttle_spf_start: 50 - timer_throttle_spf_hold: 1000 - timer_throttle_spf_max: 2000 - timer_throttle_lsa_start: 60 - timer_throttle_lsa_hold: 1100 - timer_throttle_lsa_max: 3000 - vrf: test - bfd: enable - state: present - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['router ospf 1', 'vrf test', 'bfd', 'timers throttle lsa 60 1100 3000']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-10-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_smu_module.rst b/docs/cisco.nxos.nxos_smu_module.rst deleted file mode 100644 index 76afa1a8e..000000000 --- a/docs/cisco.nxos.nxos_smu_module.rst +++ /dev/null @@ -1,381 +0,0 @@ -.. _cisco.nxos.nxos_smu_module: - - -******************* -cisco.nxos.nxos_smu -******************* - -**(deprecated, removed after 2022-10-01) Perform SMUs on Cisco NX-OS devices.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-10-01 -:Why: Updated modules released with more functionality. -:Alternative: nxos_rpm - - - -Synopsis --------- -- Perform software maintenance upgrades (SMUs) on Cisco NX-OS devices. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- file_system - -
- string -
-
- Default:
"bootflash:"
-
-
The remote file system of the device. If omitted, devices that support a file_system parameter will use their default values.
-
-
- pkg - -
- string - / required -
-
- -
Name of the remote package.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - The module can only activate and commit a package, not remove or deactivate it. - - Use ``transport=nxapi`` to avoid connection timeout - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - cisco.nxos.nxos_smu: - pkg: nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['install add bootflash:nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm', 'install activate bootflash:nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm force', 'install commit bootflash:nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-10-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_static_route_module.rst b/docs/cisco.nxos.nxos_static_route_module.rst deleted file mode 100644 index bf522ad05..000000000 --- a/docs/cisco.nxos.nxos_static_route_module.rst +++ /dev/null @@ -1,631 +0,0 @@ -.. _cisco.nxos.nxos_static_route_module: - - -**************************** -cisco.nxos.nxos_static_route -**************************** - -**(deprecated, removed after 2022-06-01) Manages static route configuration** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_static_routes - - - -Synopsis --------- -- Manages static route configuration - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- aggregate - -
- list - / elements=dictionary -
-
- -
List of static route definitions
-
-
- next_hop - -
- string - / required -
-
- -
Next hop address or interface of static route. If interface, it must be the fully-qualified interface name.
-
-
- pref - -
- string -
-
- -
Preference or administrative difference of route (range 1-255) or keyword 'default'.
-

aliases: admin_distance
-
-
- prefix - -
- string - / required -
-
- -
Destination prefix of static route.
-
-
- route_name - -
- string -
-
- -
Name of the route or keyword 'default'. Used with the name parameter on the CLI.
-
-
- state - -
- string -
-
-
    Choices: -
  • present
  • -
  • absent
  • -
-
-
Manage the state of the resource.
-
-
- tag - -
- string -
-
- -
Route tag value (numeric) or keyword 'default'.
-
-
- track - -
- integer -
-
- -
Track value (range 1 - 512). Track must already be configured on the device before adding the route.
-
-
- vrf - -
- string -
-
- -
VRF for static route.
-
-
- next_hop - -
- string -
-
- -
Next hop address or interface of static route. If interface, it must be the fully-qualified interface name.
-
-
- pref - -
- string -
-
- -
Preference or administrative difference of route (range 1-255) or keyword 'default'.
-

aliases: admin_distance
-
-
- prefix - -
- string -
-
- -
Destination prefix of static route.
-

aliases: address
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- route_name - -
- string -
-
- -
Name of the route or keyword 'default'. Used with the name parameter on the CLI.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Manage the state of the resource.
-
-
- tag - -
- string -
-
- -
Route tag value (numeric) or keyword 'default'.
-
-
- track - -
- integer -
-
- -
Track value (range 1 - 512). Track must already be configured on the device before adding the route.
-
-
- vrf - -
- string -
-
- Default:
"default"
-
-
VRF for static route.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - If no vrf is supplied, vrf is set to default. - - If ``state=absent``, the route will be removed, regardless of the non-required parameters. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - cisco.nxos.nxos_static_route: - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: testing - pref: 100 - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['ip route 192.168.20.0/24 192.0.2.3 name testing 100']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_vlan_module.rst b/docs/cisco.nxos.nxos_vlan_module.rst deleted file mode 100644 index 0be685165..000000000 --- a/docs/cisco.nxos.nxos_vlan_module.rst +++ /dev/null @@ -1,804 +0,0 @@ -.. _cisco.nxos.nxos_vlan_module: - - -******************** -cisco.nxos.nxos_vlan -******************** - -**(deprecated, removed after 2022-06-01) Manages VLAN resources and attributes.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2022-06-01 -:Why: Updated modules released with more functionality -:Alternative: nxos_vlans - - - -Synopsis --------- -- Manages VLAN configurations on NX-OS switches. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- admin_state - -
- string -
-
-
    Choices: -
  • up ←
  • -
  • down
  • -
-
-
Manage the VLAN administrative state of the VLAN equivalent to shut/no shut in VLAN config mode.
-
-
- aggregate - -
- list - / elements=dictionary -
-
- -
List of VLANs definitions.
-
-
- admin_state - -
- string -
-
-
    Choices: -
  • up
  • -
  • down
  • -
-
-
Manage the VLAN administrative state of the VLAN equivalent to shut/no shut in VLAN config mode.
-
-
- associated_interfaces - -
- list - / elements=string -
-
- -
This is a intent option and checks the operational state of the for given vlan name for associated interfaces. If the value in the associated_interfaces does not match with the operational state of vlan interfaces on device it will result in failure.
-
-
- delay - -
- integer -
-
- -
Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state arguments.
-
-
- interfaces - -
- list - / elements=string -
-
- -
List of interfaces that should be associated to the VLAN or keyword 'default'.
-
-
- mapped_vni - -
- string -
-
- -
The Virtual Network Identifier (VNI) ID that is mapped to the VLAN. Valid values are integer and keyword 'default'. Range 4096-16773119.
-
-
- mode - -
- string -
-
-
    Choices: -
  • ce
  • -
  • fabricpath
  • -
-
-
Set VLAN mode to classical ethernet or fabricpath. This is a valid option for Nexus 5000 and 7000 series.
-
-
- name - -
- string -
-
- -
Name of VLAN or keyword 'default'.
-
-
- state - -
- string -
-
-
    Choices: -
  • present
  • -
  • absent
  • -
-
-
Manage the state of the resource.
-
-
- vlan_id - -
- integer - / required -
-
- -
Single VLAN ID.
-
-
- vlan_range - -
- string -
-
- -
Range of VLANs such as 2-10 or 2,5,10-15, etc.
-
-
- vlan_state - -
- string -
-
-
    Choices: -
  • active
  • -
  • suspend
  • -
-
-
Manage the vlan operational state of the VLAN
-
-
- associated_interfaces - -
- list - / elements=string -
-
- -
This is a intent option and checks the operational state of the for given vlan name for associated interfaces. If the value in the associated_interfaces does not match with the operational state of vlan interfaces on device it will result in failure.
-
-
- delay - -
- integer -
-
- Default:
10
-
-
Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state arguments.
-
-
- interfaces - -
- list - / elements=string -
-
- -
List of interfaces that should be associated to the VLAN or keyword 'default'.
-
-
- mapped_vni - -
- string -
-
- -
The Virtual Network Identifier (VNI) ID that is mapped to the VLAN. Valid values are integer and keyword 'default'. Range 4096-16773119.
-
-
- mode - -
- string -
-
-
    Choices: -
  • ce ←
  • -
  • fabricpath
  • -
-
-
Set VLAN mode to classical ethernet or fabricpath. This is a valid option for Nexus 5000 and 7000 series.
-
-
- name - -
- string -
-
- -
Name of VLAN or keyword 'default'.
-
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
-
- purge - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Purge VLANs not defined in the aggregate parameter. This parameter can be used without aggregate as well.
-
Removal of Vlan 1 is not allowed and will be ignored by purge.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Manage the state of the resource.
-
-
- vlan_id - -
- integer -
-
- -
Single VLAN ID.
-
-
- vlan_range - -
- string -
-
- -
Range of VLANs such as 2-10 or 2,5,10-15, etc.
-
-
- vlan_state - -
- string -
-
-
    Choices: -
  • active ←
  • -
  • suspend
  • -
-
-
Manage the vlan operational state of the VLAN
-
-
- - -Notes ------ - -.. note:: - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: Ensure a range of VLANs are not present on the switch - cisco.nxos.nxos_vlan: - vlan_range: 2-10,20,50,55-60,100-150 - state: absent - - - name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state - cisco.nxos.nxos_vlan: - vlan_id: 50 - admin_state: down - name: WEB - - - name: Ensure VLAN is NOT on the device - cisco.nxos.nxos_vlan: - vlan_id: 50 - state: absent - - - name: Add interfaces to VLAN and check intent (config + intent) - cisco.nxos.nxos_vlan: - vlan_id: 100 - interfaces: - - Ethernet2/1 - - Ethernet2/5 - associated_interfaces: - - Ethernet2/1 - - Ethernet2/5 - - - name: Check interfaces assigned to VLAN - cisco.nxos.nxos_vlan: - vlan_id: 100 - associated_interfaces: - - Ethernet2/1 - - Ethernet2/5 - - - name: Create aggregate of vlans - cisco.nxos.nxos_vlan: - aggregate: - - {vlan_id: 4000, mode: ce} - - {vlan_id: 4001, name: vlan-4001} - - - name: purge vlans - removes all other vlans except the ones mentioned in aggregate) - cisco.nxos.nxos_vlan: - aggregate: - - vlan_id: 1 - - vlan_id: 4001 - purge: yes - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
Set of command strings to send to the remote device
-
-
Sample:
-
['vlan 20', 'vlan 55', 'vn-segment 5000']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2022-06-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Jason Edelman (@jedelman8) diff --git a/docs/cisco.nxos.nxos_vxlan_vtep_module.rst b/docs/cisco.nxos.nxos_vxlan_vtep_module.rst index ee68c43a8..f367016b1 100644 --- a/docs/cisco.nxos.nxos_vxlan_vtep_module.rst +++ b/docs/cisco.nxos.nxos_vxlan_vtep_module.rst @@ -479,7 +479,7 @@ Notes .. note:: - Tested against NXOSv 7.3.(0)D1(1) on VIRL - Unsupported for Cisco MDS - - The module is used to manage NVE properties, not to create NVE interfaces. Use :ref:`cisco.nxos.nxos_interface ` if you wish to do so. + - The module is used to manage NVE properties, not to create NVE interfaces. Use :ref:`cisco.nxos.nxos_interfaces ` if you wish to do so. - ``state=absent`` removes the interface. - Default, where supported, restores params default value. - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` diff --git a/meta/runtime.yml b/meta/runtime.yml index 87a44f8fc..1f30b0e9c 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -10,14 +10,6 @@ plugin_routing: redirect: cisco.nxos.nxos aaa_server_host: redirect: cisco.nxos.nxos - nxos_acl: - redirect: cisco.nxos.nxos - acl: - redirect: cisco.nxos.nxos - nxos_acl_interface: - redirect: cisco.nxos.nxos - acl_interface: - redirect: cisco.nxos.nxos nxos_acl_interfaces: redirect: cisco.nxos.nxos acl_interfaces: @@ -118,30 +110,14 @@ plugin_routing: redirect: cisco.nxos.nxos install_os: redirect: cisco.nxos.nxos - nxos_interface: - redirect: cisco.nxos.nxos - interface: - redirect: cisco.nxos.nxos - nxos_interface_ospf: - redirect: cisco.nxos.nxos - interface_ospf: - redirect: cisco.nxos.nxos nxos_interfaces: redirect: cisco.nxos.nxos interfaces: redirect: cisco.nxos.nxos - nxos_l2_interface: - redirect: cisco.nxos.nxos - l2_interface: - redirect: cisco.nxos.nxos nxos_l2_interfaces: redirect: cisco.nxos.nxos l2_interfaces: redirect: cisco.nxos.nxos - nxos_l3_interface: - redirect: cisco.nxos.nxos - l3_interface: - redirect: cisco.nxos.nxos nxos_l3_interfaces: redirect: cisco.nxos.nxos l3_interfaces: @@ -158,14 +134,6 @@ plugin_routing: redirect: cisco.nxos.nxos lag_interfaces: redirect: cisco.nxos.nxos - nxos_linkagg: - redirect: cisco.nxos.nxos - linkagg: - redirect: cisco.nxos.nxos - nxos_lldp: - redirect: cisco.nxos.nxos - lldp: - redirect: cisco.nxos.nxos nxos_lldp_global: redirect: cisco.nxos.nxos lldp_global: @@ -206,14 +174,6 @@ plugin_routing: redirect: cisco.nxos.nxos ospf_interfaces: redirect: cisco.nxos.nxos - nxos_ospf: - redirect: cisco.nxos.nxos - ospf: - redirect: cisco.nxos.nxos - nxos_ospf_vrf: - redirect: cisco.nxos.nxos - ospf_vrf: - redirect: cisco.nxos.nxos nxos_bgp_global: redirect: cisco.nxos.nxos bgp_global: @@ -270,10 +230,6 @@ plugin_routing: redirect: cisco.nxos.nxos rpm: redirect: cisco.nxos.nxos - nxos_smu: - redirect: cisco.nxos.nxos - smu: - redirect: cisco.nxos.nxos nxos_snapshot: redirect: cisco.nxos.nxos snapshot: @@ -308,10 +264,6 @@ plugin_routing: redirect: cisco.nxos.nxos nxos_static_route: redirect: cisco.nxos.nxos - static_route: - redirect: cisco.nxos.nxos - nxos_static_routes: - redirect: cisco.nxos.nxos static_routes: redirect: cisco.nxos.nxos nxos_system: @@ -334,10 +286,6 @@ plugin_routing: redirect: cisco.nxos.nxos user: redirect: cisco.nxos.nxos - nxos_vlan: - redirect: cisco.nxos.nxos - vlan: - redirect: cisco.nxos.nxos nxos_vlans: redirect: cisco.nxos.nxos vlans: @@ -399,24 +347,6 @@ plugin_routing: redirect: cisco.nxos.nxos_aaa_server aaa_server_host: redirect: cisco.nxos.nxos_aaa_server_host - acl: - redirect: cisco.nxos.nxos_acl - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_acl: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - acl_interface: - redirect: cisco.nxos.nxos_acl_interface - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_acl_interface: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details acl_interfaces: redirect: cisco.nxos.nxos_acl_interfaces acls: @@ -497,46 +427,10 @@ plugin_routing: redirect: cisco.nxos.nxos_igmp_snooping install_os: redirect: cisco.nxos.nxos_install_os - interface: - redirect: cisco.nxos.nxos_interface - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_interface: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - interface_ospf: - redirect: cisco.nxos.nxos_interface_ospf - deprecation: - removal_date: "2022-10-26" - warning_text: See the plugin documentation for more details - nxos_interface_ospf: - deprecation: - removal_date: "2022-10-26" - warning_text: See the plugin documentation for more details interfaces: redirect: cisco.nxos.nxos_interfaces - l2_interface: - redirect: cisco.nxos.nxos_l2_interface - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_l2_interface: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details l2_interfaces: redirect: cisco.nxos.nxos_l2_interfaces - l3_interface: - redirect: cisco.nxos.nxos_l3_interface - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_l3_interface: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details l3_interfaces: redirect: cisco.nxos.nxos_l3_interfaces lacp: @@ -545,24 +439,6 @@ plugin_routing: redirect: cisco.nxos.nxos_lacp_interfaces lag_interfaces: redirect: cisco.nxos.nxos_lag_interfaces - linkagg: - redirect: cisco.nxos.nxos_linkagg - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_linkagg: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - lldp: - redirect: cisco.nxos.nxos_lldp - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_lldp: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details lldp_global: redirect: cisco.nxos.nxos_lldp_global lldp_interfaces: @@ -611,24 +487,6 @@ plugin_routing: redirect: cisco.nxos.nxos_nxapi ospf_interfaces: redirect: cisco.nxos.nxos_ospf_interfaces - ospf: - redirect: cisco.nxos.nxos_ospf - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_ospf: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - ospf_vrf: - redirect: cisco.nxos.nxos_ospf_vrf - deprecation: - removal_date: "2022-10-01" - warning_text: See the plugin documentation for more details - nxos_ospf_vrf: - deprecation: - removal_date: "2022-10-01" - warning_text: See the plugin documentation for more details bgp_global: redirect: cisco.nxos.nxos_bgp_global bgp_address_family: @@ -657,15 +515,6 @@ plugin_routing: redirect: cisco.nxos.nxos_route_maps rpm: redirect: cisco.nxos.nxos_rpm - smu: - redirect: cisco.nxos.nxos_smu - deprecation: - removal_date: "2022-10-01" - warning_text: See the plugin documentation for more details - nxos_smu: - deprecation: - removal_date: "2022-10-01" - warning_text: See the plugin documentation for more details snapshot: redirect: cisco.nxos.nxos_snapshot snmp_community: @@ -724,15 +573,6 @@ plugin_routing: deprecation: removal_date: "2024-01-01" warning_text: See the plugin documentation for more details - static_route: - redirect: cisco.nxos.nxos_static_route - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_static_route: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details static_routes: redirect: cisco.nxos.nxos_static_routes system: @@ -745,15 +585,6 @@ plugin_routing: redirect: cisco.nxos.nxos_udld_interface user: redirect: cisco.nxos.nxos_user - vlan: - redirect: cisco.nxos.nxos_vlan - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details - nxos_vlan: - deprecation: - removal_date: "2022-06-01" - warning_text: See the plugin documentation for more details vlans: redirect: cisco.nxos.nxos_vlans vpc: diff --git a/plugins/modules/nxos_acl.py b/plugins/modules/nxos_acl.py deleted file mode 100644 index c5a60b21f..000000000 --- a/plugins/modules/nxos_acl.py +++ /dev/null @@ -1,669 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_acl -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manages access - list entries for ACLs. -description: -- Manages access list entries for ACLs. -version_added: 1.0.0 -author: -- Jason Edelman (@jedelman8) -- Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_acls - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- C(state=absent) removes the ACE if it exists. -- C(state=delete_acl) deletes the ACL if it exists. -- For idempotency, use port numbers for the src/dest port params like I(src_port1) - and names for the well defined protocols for the I(proto) param. -- Although this module is idempotent in that if the ace as presented in the task is - identical to the one on the switch, no changes will be made. If there is any difference, - what is in Ansible will be pushed (configured options will be overridden). This - is to improve security, but at the same time remember an ACE is removed, then re-added, - so if there is a change, the new ACE will be exactly what parameters you are sending - to the module. -options: - seq: - description: - - Sequence number of the entry (ACE). - type: str - name: - description: - - Case sensitive name of the access list (ACL). - required: true - type: str - action: - description: - - Action of the ACE. - choices: - - permit - - deny - - remark - type: str - remark: - description: - - If action is set to remark, this is the description. - type: str - proto: - description: - - Port number or protocol (as supported by the switch). - type: str - src: - description: - - Source ip and mask using IP/MASK notation and supports keyword 'any'. - type: str - src_port_op: - description: - - Source port operands such as eq, neq, gt, lt, range. - choices: - - any - - eq - - gt - - lt - - neq - - range - type: str - src_port1: - description: - - Port/protocol and also first (lower) port when using range operand. - type: str - src_port2: - description: - - Second (end) port when using range operand. - type: str - dest: - description: - - Destination ip and mask using IP/MASK notation and supports the keyword 'any'. - type: str - dest_port_op: - description: - - Destination port operands such as eq, neq, gt, lt, range. - choices: - - any - - eq - - gt - - lt - - neq - - range - type: str - dest_port1: - description: - - Port/protocol and also first (lower) port when using range operand. - type: str - dest_port2: - description: - - Second (end) port when using range operand. - type: str - log: - description: - - Log matches against this entry. - choices: - - enable - type: str - urg: - description: - - Match on the URG bit. - choices: - - enable - type: str - ack: - description: - - Match on the ACK bit. - choices: - - enable - type: str - psh: - description: - - Match on the PSH bit. - choices: - - enable - type: str - rst: - description: - - Match on the RST bit. - choices: - - enable - type: str - syn: - description: - - Match on the SYN bit. - choices: - - enable - type: str - fin: - description: - - Match on the FIN bit. - choices: - - enable - type: str - established: - description: - - Match established connections. - choices: - - enable - type: str - fragments: - description: - - Check non-initial fragments. - choices: - - enable - type: str - time_range: - description: - - Name of time-range to apply. - type: str - precedence: - description: - - Match packets with given precedence. - choices: - - critical - - flash - - flash-override - - immediate - - internet - - network - - priority - - routine - type: str - dscp: - description: - - Match packets with given dscp value. - choices: - - af11 - - af12 - - af13 - - af21 - - af22 - - af23 - - af31 - - af32 - - af33 - - af41 - - af42 - - af43 - - cs1 - - cs2 - - cs3 - - cs4 - - cs5 - - cs6 - - cs7 - - default - - ef - type: str - state: - description: - - Specify desired state of the resource. - default: present - choices: - - present - - absent - - delete_acl - type: str - - -""" - -EXAMPLES = """ -# configure ACL ANSIBLE -- cisco.nxos.nxos_acl: - name: ANSIBLE - seq: 10 - action: permit - proto: tcp - src: 192.0.2.1/24 - dest: any - state: present -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["ip access-list ANSIBLE", "10 permit tcp 192.0.2.1/24 any"] -""" -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - nxos_argument_spec, - run_commands, -) - - -def execute_show_command(command, module, check_rc=True): - command += " | json" - cmds = [command] - body = run_commands(module, cmds, check_rc=check_rc) - return body - - -def get_acl(module, acl_name, seq_number): - command = "show ip access-list" - new_acl = [] - saveme = {} - acl_body = {} - - body = execute_show_command(command, module, check_rc=False) - if "Structured output unsupported" in repr(body): - # Some older versions raise 501 and return a string when no ACLs exist - return {}, [] - - if body and body[0]: - all_acl_body = body[0]["TABLE_ip_ipv6_mac"]["ROW_ip_ipv6_mac"] - else: - # no access-lists configured on the device - return {}, [] - - if isinstance(all_acl_body, dict): - # Only 1 ACL configured. - if all_acl_body.get("acl_name") == acl_name: - acl_body = all_acl_body - else: - for acl in all_acl_body: - if acl.get("acl_name") == acl_name: - acl_body = acl - break - - try: - acl_entries = acl_body["TABLE_seqno"]["ROW_seqno"] - acl_name = acl_body.get("acl_name") - except KeyError: # could be raised if no ACEs are configured for an ACL - return {}, [{"acl": "no_entries"}] - - if isinstance(acl_entries, dict): - acl_entries = [acl_entries] - - for each in acl_entries: - temp = {} - options = {} - remark = each.get("remark") - - temp["name"] = acl_name - temp["seq"] = str(each.get("seqno")) - - if remark: - temp["remark"] = remark - temp["action"] = "remark" - else: - temp["action"] = each.get("permitdeny") - temp["proto"] = str(each.get("proto", each.get("proto_str", each.get("ip")))) - temp["src"] = each.get("src_any", each.get("src_ip_prefix")) - temp["src_port_op"] = each.get("src_port_op") - temp["src_port1"] = each.get("src_port1_num") - temp["src_port2"] = each.get("src_port2_num") - temp["dest"] = each.get("dest_any", each.get("dest_ip_prefix")) - temp["dest_port_op"] = each.get("dest_port_op") - temp["dest_port1"] = each.get("dest_port1_num") - temp["dest_port2"] = each.get("dest_port2_num") - - options["log"] = each.get("log") - options["urg"] = each.get("urg") - options["ack"] = each.get("ack") - options["psh"] = each.get("psh") - options["rst"] = each.get("rst") - options["syn"] = each.get("syn") - options["fin"] = each.get("fin") - options["established"] = each.get("established") - options["dscp"] = each.get("dscp_str") - options["precedence"] = each.get("precedence_str") - options["fragments"] = each.get("fragments") - options["time_range"] = each.get("timerange") - - keep = {} - for key, value in temp.items(): - if value: - keep[key] = value - - options_no_null = {} - for key, value in options.items(): - if value is not None: - options_no_null[key] = value - keep["options"] = options_no_null - - if keep.get("seq") == seq_number: - saveme = dict(keep) - - new_acl.append(keep) - - return saveme, new_acl - - -def _acl_operand(operand, srcp1, sprcp2): - sub_entry = " " + operand - - if operand == "range": - sub_entry += " " + srcp1 + " " + sprcp2 - else: - sub_entry += " " + srcp1 - - return sub_entry - - -def config_core_acl(proposed): - seq = proposed.get("seq") - action = proposed.get("action") - remark = proposed.get("remark") - proto = proposed.get("proto") - src = proposed.get("src") - src_port_op = proposed.get("src_port_op") - src_port1 = proposed.get("src_port1") - src_port2 = proposed.get("src_port2") - - dest = proposed.get("dest") - dest_port_op = proposed.get("dest_port_op") - dest_port1 = proposed.get("dest_port1") - dest_port2 = proposed.get("dest_port2") - - ace_start_entries = [action, proto, src] - if not remark: - ace = seq + " " + " ".join(ace_start_entries) - if src_port_op: - ace += _acl_operand(src_port_op, src_port1, src_port2) - ace += " " + dest - if dest_port_op: - ace += _acl_operand(dest_port_op, dest_port1, dest_port2) - else: - ace = seq + " remark " + remark - - return ace - - -def config_acl_options(options): - ENABLE_ONLY = [ - "psh", - "urg", - "log", - "ack", - "syn", - "established", - "rst", - "fin", - "fragments", - "log", - ] - - OTHER = ["dscp", "precedence", "time-range"] - # packet-length is the only option not currently supported - - if options.get("time_range"): - options["time-range"] = options.get("time_range") - options.pop("time_range") - - command = "" - for option, value in options.items(): - if option in ENABLE_ONLY: - if value == "enable": - command += " " + option - elif option in OTHER: - command += " " + option + " " + value - if command: - command = command.strip() - return command - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def main(): - argument_spec = dict( - seq=dict(required=False, type="str"), - name=dict(required=True, type="str"), - action=dict(required=False, choices=["remark", "permit", "deny"]), - remark=dict(required=False, type="str"), - proto=dict(required=False, type="str"), - src=dict(required=False, type="str"), - src_port_op=dict(required=False, choices=["any", "eq", "gt", "lt", "neq", "range"]), - src_port1=dict(required=False, type="str"), - src_port2=dict(required=False, type="str"), - dest=dict(required=False, type="str"), - dest_port_op=dict(required=False, choices=["any", "eq", "gt", "lt", "neq", "range"]), - dest_port1=dict(required=False, type="str"), - dest_port2=dict(required=False, type="str"), - log=dict(required=False, choices=["enable"]), - urg=dict(required=False, choices=["enable"]), - ack=dict(required=False, choices=["enable"]), - psh=dict(required=False, choices=["enable"]), - rst=dict(required=False, choices=["enable"]), - syn=dict(required=False, choices=["enable"]), - fragments=dict(required=False, choices=["enable"]), - fin=dict(required=False, choices=["enable"]), - established=dict(required=False, choices=["enable"]), - time_range=dict(required=False), - precedence=dict( - required=False, - choices=[ - "critical", - "flash", - "flash-override", - "immediate", - "internet", - "network", - "priority", - "routine", - ], - ), - dscp=dict( - required=False, - choices=[ - "af11", - "af12", - "af13", - "af21", - "af22", - "af23", - "af31", - "af32", - "af33", - "af41", - "af42", - "af43", - "cs1", - "cs2", - "cs3", - "cs4", - "cs5", - "cs6", - "cs7", - "default", - "ef", - ], - ), - state=dict(choices=["absent", "present", "delete_acl"], default="present"), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - - results = dict(changed=False, warnings=warnings) - - state = module.params["state"] - action = module.params["action"] - remark = module.params["remark"] - dscp = module.params["dscp"] - precedence = module.params["precedence"] - seq = module.params["seq"] - name = module.params["name"] - seq = module.params["seq"] - - if action == "remark" and not remark: - module.fail_json(msg="when state is action, remark param is also required") - - REQUIRED = ["seq", "name", "action", "proto", "src", "dest"] - ABSENT = ["name", "seq"] - if state == "present": - if action and remark and seq: - pass - else: - for each in REQUIRED: - if module.params[each] is None: - module.fail_json( - msg="req'd params when state is present:", - params=REQUIRED, - ) - elif state == "absent": - for each in ABSENT: - if module.params[each] is None: - module.fail_json(msg="require params when state is absent", params=ABSENT) - elif state == "delete_acl": - if module.params["name"] is None: - module.fail_json(msg="param name req'd when state is delete_acl") - - if dscp and precedence: - module.fail_json(msg="only one of the params dscp/precedence " "are allowed") - - OPTIONS_NAMES = [ - "log", - "urg", - "ack", - "psh", - "rst", - "syn", - "fin", - "established", - "dscp", - "precedence", - "fragments", - "time_range", - ] - - CORE = [ - "seq", - "name", - "action", - "proto", - "src", - "src_port_op", - "src_port1", - "src_port2", - "dest", - "dest_port_op", - "dest_port1", - "dest_port2", - "remark", - ] - - proposed_core = dict( - (param, value) - for (param, value) in module.params.items() - if param in CORE and value is not None - ) - - proposed_options = dict( - (param, value) - for (param, value) in module.params.items() - if param in OPTIONS_NAMES and value is not None - ) - proposed = {} - proposed.update(proposed_core) - proposed.update(proposed_options) - - existing_options = {} - - # getting existing existing_core=dict, acl=list, seq=list - existing_core, acl = get_acl(module, name, seq) - if existing_core: - existing_options = existing_core.get("options") - existing_core.pop("options") - - commands = [] - delta_core = {} - delta_options = {} - - if not existing_core.get("remark"): - dcore = dict(set(proposed_core.items()).difference(existing_core.items())) - if not dcore: - # check the diff in the other way just in case - dcore = dict(set(existing_core.items()).difference(proposed_core.items())) - delta_core = dcore - if delta_core: - delta_options = proposed_options - else: - doptions = dict(set(proposed_options.items()).difference(existing_options.items())) - # check the diff in the other way just in case - if not doptions: - doptions = dict(set(existing_options.items()).difference(proposed_options.items())) - delta_options = doptions - else: - delta_core = dict(set(proposed_core.items()).difference(existing_core.items())) - - if state == "present": - if delta_core or delta_options: - if existing_core: # if the ace exists already - commands.append(["no {0}".format(seq)]) - if delta_options: - myacl_str = config_core_acl(proposed_core) - myacl_str += " " + config_acl_options(proposed_options) - else: - myacl_str = config_core_acl(proposed_core) - command = [myacl_str] - commands.append(command) - elif state == "absent": - if existing_core: - commands.append(["no {0}".format(seq)]) - elif state == "delete_acl": - if acl and acl[0].get("acl") != "no_entries": - commands.append(["no ip access-list {0}".format(name)]) - - cmds = [] - if commands: - preface = [] - if state in ["present", "absent"]: - preface = ["ip access-list {0}".format(name)] - commands.insert(0, preface) - - cmds = flatten_list(commands) - if module.check_mode: - module.exit_json(changed=True, commands=cmds) - else: - load_config(module, cmds) - results["changed"] = True - if "configure" in cmds: - cmds.pop(0) - - results["commands"] = cmds - - module.exit_json(**results) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_acl_interface.py b/plugins/modules/nxos_acl_interface.py deleted file mode 100644 index 713b6e090..000000000 --- a/plugins/modules/nxos_acl_interface.py +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_acl_interface -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manages applying - ACLs to interfaces. -description: -- Manages applying ACLs to interfaces. -version_added: 1.0.0 -deprecated: - alternative: nxos_acl_interfaces - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -author: -- Jason Edelman (@jedelman8) -- Gabriele Gerbino (@GGabriele) -options: - name: - description: - - Case sensitive name of the access list (ACL). - required: true - type: str - interface: - description: - - Full name of interface, e.g. I(Ethernet1/1). - required: true - type: str - direction: - description: - - Direction ACL to be applied in on the interface. - required: true - choices: - - ingress - - egress - type: str - state: - description: - - Specify desired state of the resource. - required: false - default: present - choices: - - present - - absent - type: str - - -""" - -EXAMPLES = """ -- name: apply egress acl to ethernet1/41 - cisco.nxos.nxos_acl_interface: - name: ANSIBLE - interface: ethernet1/41 - direction: egress - state: present -""" - -RETURN = """ -acl_applied_to: - description: list of interfaces the ACL is applied to - returned: always - type: list - sample: [{"acl_type": "Router ACL", "direction": "egress", - "interface": "Ethernet1/41", "name": "ANSIBLE"}] -commands: - description: commands sent to the device - returned: always - type: list - sample: ["interface ethernet1/41", "ip access-group ANSIBLE out"] -""" -import re - -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - nxos_argument_spec, - run_commands, -) - - -def check_for_acl_int_present(module, name, intf, direction): - # Need to Capitalize the interface name as the nxos - # output has capitalization - command = [ - { - "command": "show running-config aclmgr | section {0}".format(intf.title()), - "output": "text", - }, - ] - body = run_commands(module, command) - - if direction == "ingress": - mdir = "in" - elif direction == "egress": - mdir = "out" - - match = re.search("ip access-group {0} {1}".format(name, mdir), str(body[0])) - return bool(match) - - -def apply_acl(proposed): - commands = [] - - commands.append("interface " + proposed.get("interface")) - direction = proposed.get("direction") - if direction == "egress": - cmd = "ip access-group {0} {1}".format(proposed.get("name"), "out") - elif direction == "ingress": - cmd = "ip access-group {0} {1}".format(proposed.get("name"), "in") - commands.append(cmd) - - return commands - - -def remove_acl(proposed): - commands = [] - - commands.append("interface " + proposed.get("interface")) - direction = proposed.get("direction") - if direction == "egress": - cmd = "no ip access-group {0} {1}".format(proposed.get("name"), "out") - elif direction == "ingress": - cmd = "no ip access-group {0} {1}".format(proposed.get("name"), "in") - commands.append(cmd) - - return commands - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def main(): - argument_spec = dict( - name=dict(required=True, type="str"), - interface=dict(required=True), - direction=dict(required=True, choices=["egress", "ingress"]), - state=dict(choices=["absent", "present"], default="present"), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - - results = dict(changed=False, warnings=warnings) - - state = module.params["state"] - name = module.params["name"] - interface = module.params["interface"].lower() - direction = module.params["direction"].lower() - - proposed = dict(name=name, interface=interface, direction=direction) - - existing = check_for_acl_int_present(module, name, interface, direction) - - cmds = [] - commands = [] - if state == "present": - if not existing: - command = apply_acl(proposed) - if command: - commands.append(command) - - elif state == "absent": - if existing: - command = remove_acl(proposed) - if command: - commands.append(command) - - if commands: - cmds = flatten_list(commands) - if cmds: - if module.check_mode: - module.exit_json(changed=True, commands=cmds) - else: - load_config(module, cmds) - results["changed"] = True - if "configure" in cmds: - cmds.pop(0) - else: - cmds = [] - - results["commands"] = cmds - - module.exit_json(**results) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_interface.py b/plugins/modules/nxos_interface.py deleted file mode 100644 index f516b2015..000000000 --- a/plugins/modules/nxos_interface.py +++ /dev/null @@ -1,944 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_interface -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manages physical - attributes of interfaces. -description: -- Manages physical attributes of interfaces of NX-OS switches. -version_added: 1.0.0 -deprecated: - alternative: nxos_interfaces - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -author: -- Jason Edelman (@jedelman8) -- Trishna Guha (@trishnaguha) -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- This module is also used to create logical interfaces such as svis and loopbacks. -- Be cautious of platform specific idiosyncrasies. For example, when you default a - loopback interface, the admin state toggles on certain versions of NX-OS. -- The M(cisco.nxos.nxos_overlay_global) C(anycast_gateway_mac) attribute must be set before setting - the C(fabric_forwarding_anycast_gateway) property. -options: - name: - description: - - Full name of interface, i.e. Ethernet1/1, port-channel10. - aliases: - - interface - type: str - interface_type: - description: - - Interface type to be unconfigured from the device. - choices: - - loopback - - portchannel - - svi - - nve - type: str - speed: - description: - - Interface link speed. Applicable for ethernet interface only. - type: str - admin_state: - description: - - Administrative state of the interface. - default: up - choices: - - up - - down - type: str - description: - description: - - Interface description. - type: str - mode: - description: - - Manage Layer 2 or Layer 3 state of the interface. This option is supported for - ethernet and portchannel interface. Applicable for ethernet and portchannel - interface only. - choices: - - layer2 - - layer3 - type: str - mtu: - description: - - MTU for a specific interface. Must be an even number between 576 and 9216. Applicable - for ethernet interface only. - type: str - ip_forward: - description: - - Enable/Disable ip forward feature on SVIs. - choices: - - enable - - disable - type: str - fabric_forwarding_anycast_gateway: - description: - - Associate SVI with anycast gateway under VLAN configuration mode. Applicable - for SVI interface only. - type: bool - duplex: - description: - - Interface link status. Applicable for ethernet interface only. - choices: - - full - - half - - auto - type: str - tx_rate: - description: - - Transmit rate in bits per second (bps). - - This is state check parameter only. - - Supports conditionals, see - U(https://docs.ansible.com/ansible/latest/network/user_guide/network_working_with_command_output.html#conditionals-in-networking-modules) - type: str - rx_rate: - description: - - Receiver rate in bits per second (bps). - - This is state check parameter only. - - Supports conditionals, see - U(https://docs.ansible.com/ansible/latest/network/user_guide/network_working_with_command_output.html#conditionals-in-networking-modules) - type: str - neighbors: - description: - - Check the operational state of given interface C(name) for LLDP neighbor. - - The following suboptions are available. This is state check parameter only. - type: list - elements: dict - suboptions: - host: - description: - - LLDP neighbor host for given interface C(name). - type: str - port: - description: - - LLDP neighbor port to which given interface C(name) is connected. - type: str - aggregate: - description: List of Interfaces definitions. - type: list - elements: dict - suboptions: - name: - description: - - Full name of interface, i.e. Ethernet1/1, port-channel10. - required: true - type: str - interface_type: - description: - - Interface type to be unconfigured from the device. - choices: - - loopback - - portchannel - - svi - - nve - type: str - speed: - description: - - Interface link speed. Applicable for ethernet interface only. - type: str - admin_state: - description: - - Administrative state of the interface. - choices: - - up - - down - type: str - description: - description: - - Interface description. - type: str - mode: - description: - - Manage Layer 2 or Layer 3 state of the interface. This option is supported for - ethernet and portchannel interface. Applicable for ethernet and portchannel - interface only. - choices: - - layer2 - - layer3 - type: str - mtu: - description: - - MTU for a specific interface. Must be an even number between 576 and 9216. Applicable - for ethernet interface only. - type: str - ip_forward: - description: - - Enable/Disable ip forward feature on SVIs. - choices: - - enable - - disable - type: str - fabric_forwarding_anycast_gateway: - description: - - Associate SVI with anycast gateway under VLAN configuration mode. Applicable - for SVI interface only. - type: bool - duplex: - description: - - Interface link status. Applicable for ethernet interface only. - choices: - - full - - half - - auto - type: str - tx_rate: - description: - - Transmit rate in bits per second (bps). - - This is state check parameter only. - - Supports conditionals, see - U(https://docs.ansible.com/ansible/latest/network/user_guide/network_working_with_command_output.html#conditionals-in-networking-modules) - type: str - rx_rate: - description: - - Receiver rate in bits per second (bps). - - This is state check parameter only. - - Supports conditionals, see - U(https://docs.ansible.com/ansible/latest/network/user_guide/network_working_with_command_output.html#conditionals-in-networking-modules) - type: str - neighbors: - description: - - Check the operational state of given interface C(name) for LLDP neighbor. - - The following suboptions are available. This is state check parameter only. - type: list - elements: dict - suboptions: - host: - description: - - LLDP neighbor host for given interface C(name). - type: str - port: - description: - - LLDP neighbor port to which given interface C(name) is connected. - type: str - state: - description: - - Specify desired state of the resource. - choices: - - present - - absent - - default - type: str - delay: - description: - - Time in seconds to wait before checking for the operational state on remote - device. This wait is applicable for operational state arguments. - type: int - state: - description: - - Specify desired state of the resource. - default: present - choices: - - present - - absent - - default - type: str - delay: - description: - - Time in seconds to wait before checking for the operational state on remote - device. This wait is applicable for operational state arguments. - default: 10 - type: int - - -""" - -EXAMPLES = """ -- name: Ensure an interface is a Layer 3 port and that it has the proper description - cisco.nxos.nxos_interface: - name: Ethernet1/1 - description: Configured by Ansible - mode: layer3 - -- name: Admin down an interface - cisco.nxos.nxos_interface: - name: Ethernet2/1 - admin_state: down - -- name: Remove all loopback interfaces - cisco.nxos.nxos_interface: - name: loopback - state: absent - -- name: Remove all logical interfaces - cisco.nxos.nxos_interface: - interface_type: '{{ item }} ' - state: absent - loop: - - loopback - - portchannel - - svi - - nve - -- name: Admin up all loopback interfaces - cisco.nxos.nxos_interface: - name: loopback 0-1023 - admin_state: up - -- name: Admin down all loopback interfaces - cisco.nxos.nxos_interface: - name: loopback 0-1023 - admin_state: down - -- name: Check neighbors intent arguments - cisco.nxos.nxos_interface: - name: Ethernet2/3 - neighbors: - - port: Ethernet2/3 - host: abc.mycompany.com - -- name: Add interface using aggregate - cisco.nxos.nxos_interface: - aggregate: - - {name: Ethernet0/1, mtu: 256, description: test-interface-1} - - {name: Ethernet0/2, mtu: 516, description: test-interface-2} - duplex: full - speed: 100 - state: present - -- name: Delete interface using aggregate - cisco.nxos.nxos_interface: - aggregate: - - name: Loopback9 - - name: Loopback10 - state: absent - -- name: Check intent arguments - cisco.nxos.nxos_interface: - name: Ethernet0/2 - state: up - tx_rate: ge(0) - rx_rate: le(0) -""" - -RETURN = """ -commands: - description: command list sent to the device - returned: always - type: list - sample: - - interface Ethernet2/3 - - mtu 1500 - - speed 10 -""" - -import re -import time - -from copy import deepcopy - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - conditional, - remove_default_spec, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_interface_type, - load_config, - normalize_interface, - nxos_argument_spec, - run_commands, -) - - -def execute_show_command(command, module): - if "show run" not in command: - output = "json" - else: - output = "text" - cmds = [{"command": command, "output": output}] - body = run_commands(module, cmds, check_rc=False) - if body and "Invalid" in body[0]: - return [] - else: - return body - - -def search_obj_in_list(name, lst): - for o in lst: - if o["name"] == name: - return o - - return None - - -def get_interfaces_dict(module): - """Gets all active interfaces on a given switch""" - try: - body = execute_show_command("show interface", module)[0] - except IndexError: - return {} - - interfaces = { - "ethernet": [], - "svi": [], - "loopback": [], - "management": [], - "portchannel": [], - "nve": [], - "unknown": [], - } - - if body: - interface_list = body["TABLE_interface"]["ROW_interface"] - for index in interface_list: - intf = index["interface"] - intf_type = get_interface_type(intf) - interfaces[intf_type].append(intf) - - return interfaces - - -def get_vlan_interface_attributes(name, intf_type, module): - """Returns dictionary that has two k/v pairs: - admin_state & description if not an svi, returns None - """ - command = "show run interface {0} all".format(name) - try: - body = execute_show_command(command, module)[0] - except (IndexError, TypeError): - return None - if body: - command_list = body.split("\n") - desc = None - admin_state = "down" - for each in command_list: - if "description" in each: - desc = each.lstrip().split("description")[1].lstrip() - elif "no shutdown" in each: - admin_state = "up" - return dict(description=desc, admin_state=admin_state) - else: - return None - - -def get_interface_type_removed_cmds(interfaces): - commands = [] - - for interface in interfaces: - if interface != "Vlan1": - commands.append("no interface {0}".format(interface)) - - return commands - - -def get_admin_state(admin_state): - command = "" - if admin_state == "up": - command = "no shutdown" - elif admin_state == "down": - command = "shutdown" - return command - - -def is_default_interface(name, module): - """Checks to see if interface exists and if it is a default config""" - command = "show run interface {0}".format(name) - - try: - body = execute_show_command(command, module)[0] - except (IndexError, TypeError): - body = "" - - if body: - raw_list = body.split("\n") - found = False - for line in raw_list: - if line.startswith("interface"): - found = True - if found and line and not line.startswith("interface"): - return False - return True - - else: - return "DNE" - - -def add_command_to_interface(interface, cmd, commands): - if interface not in commands: - commands.append(interface) - commands.append(cmd) - - -def map_obj_to_commands(updates, module): - commands = list() - commands2 = list() - want, have = updates - - args = ("speed", "description", "duplex", "mtu") - for w in want: - name = w["name"] - mode = w["mode"] - ip_forward = w["ip_forward"] - fabric_forwarding_anycast_gateway = w["fabric_forwarding_anycast_gateway"] - admin_state = w["admin_state"] - state = w["state"] - interface_type = w["interface_type"] - del w["state"] - if name: - w["interface_type"] = None - - if interface_type: - obj_in_have = {} - if state in ("present", "default"): - module.fail_json(msg="The interface_type param can be used only with state absent.") - else: - obj_in_have = search_obj_in_list(name, have) - is_default = is_default_interface(name, module) - - if name: - interface = "interface " + name - - if state == "absent": - if obj_in_have: - commands.append("no interface {0}".format(name)) - elif interface_type and not obj_in_have: - intfs = get_interfaces_dict(module)[interface_type] - cmds = get_interface_type_removed_cmds(intfs) - commands.extend(cmds) - - elif state == "present": - if obj_in_have: - # Don't run switchport command for loopback and svi interfaces - if get_interface_type(name) in ("ethernet", "portchannel"): - if mode == "layer2" and mode != obj_in_have.get("mode"): - add_command_to_interface(interface, "switchport", commands) - elif mode == "layer3" and mode != obj_in_have.get("mode"): - add_command_to_interface(interface, "no switchport", commands) - - if admin_state == "up" and admin_state != obj_in_have.get("admin_state"): - add_command_to_interface(interface, "no shutdown", commands) - elif admin_state == "down" and admin_state != obj_in_have.get("admin_state"): - add_command_to_interface(interface, "shutdown", commands) - - if ip_forward == "enable" and ip_forward != obj_in_have.get("ip_forward"): - add_command_to_interface(interface, "ip forward", commands) - elif ip_forward == "disable" and ip_forward != obj_in_have.get("ip forward"): - add_command_to_interface(interface, "no ip forward", commands) - - if ( - fabric_forwarding_anycast_gateway is True - and obj_in_have.get("fabric_forwarding_anycast_gateway") is False - ): - add_command_to_interface( - interface, - "fabric forwarding mode anycast-gateway", - commands, - ) - - elif ( - fabric_forwarding_anycast_gateway is False - and obj_in_have.get("fabric_forwarding_anycast_gateway") is True - ): - add_command_to_interface( - interface, - "no fabric forwarding mode anycast-gateway", - commands, - ) - - for item in args: - candidate = w.get(item) - if candidate and candidate != obj_in_have.get(item): - cmd = item + " " + str(candidate) - add_command_to_interface(interface, cmd, commands) - - if name and get_interface_type(name) == "ethernet": - if mode != obj_in_have.get("mode"): - admin_state = w.get("admin_state") or obj_in_have.get("admin_state") - if admin_state: - c1 = "interface {0}".format(normalize_interface(w["name"])) - c2 = get_admin_state(admin_state) - commands2.append(c1) - commands2.append(c2) - - else: - commands.append(interface) - # Don't run switchport command for loopback and svi interfaces - if get_interface_type(name) in ("ethernet", "portchannel"): - if mode == "layer2": - commands.append("switchport") - elif mode == "layer3": - commands.append("no switchport") - - if admin_state == "up": - commands.append("no shutdown") - elif admin_state == "down": - commands.append("shutdown") - - if ip_forward == "enable": - commands.append("ip forward") - elif ip_forward == "disable": - commands.append("no ip forward") - - if fabric_forwarding_anycast_gateway is True: - commands.append("fabric forwarding mode anycast-gateway") - - elif fabric_forwarding_anycast_gateway is False: - commands.append("no fabric forwarding mode anycast-gateway") - - for item in args: - candidate = w.get(item) - if candidate: - commands.append(item + " " + str(candidate)) - - elif state == "default": - if is_default is False: - commands.append("default interface {0}".format(name)) - elif is_default == "DNE": - module.exit_json(msg="interface you are trying to default does not exist") - - return commands, commands2 - - -def map_params_to_obj(module): - obj = [] - aggregate = module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = module.params[key] - - d = item.copy() - name = d["name"] - d["name"] = normalize_interface(name) - obj.append(d) - - else: - obj.append( - { - "name": normalize_interface(module.params["name"]), - "description": module.params["description"], - "speed": module.params["speed"], - "mode": module.params["mode"], - "mtu": module.params["mtu"], - "duplex": module.params["duplex"], - "ip_forward": module.params["ip_forward"], - "fabric_forwarding_anycast_gateway": module.params[ - "fabric_forwarding_anycast_gateway" - ], - "admin_state": module.params["admin_state"], - "state": module.params["state"], - "interface_type": module.params["interface_type"], - "tx_rate": module.params["tx_rate"], - "rx_rate": module.params["rx_rate"], - "neighbors": module.params["neighbors"], - }, - ) - - return obj - - -def map_config_to_obj(want, module): - objs = list() - - for w in want: - obj = dict( - name=None, - description=None, - admin_state=None, - speed=None, - mtu=None, - mode=None, - duplex=None, - interface_type=None, - ip_forward=None, - fabric_forwarding_anycast_gateway=None, - ) - - if not w["name"]: - return obj - - command = "show interface {0}".format(w["name"]) - try: - body = execute_show_command(command, module)[0] - except IndexError: - return list() - if body: - try: - interface_table = body["TABLE_interface"]["ROW_interface"] - except (KeyError, TypeError): - return list() - - if interface_table: - if interface_table.get("eth_mode") == "fex-fabric": - module.fail_json( - msg='nxos_interface does not support interfaces with mode "fex-fabric"', - ) - - intf_type = get_interface_type(w["name"]) - - if intf_type in ["portchannel", "ethernet"]: - mode = interface_table.get("eth_mode") - if mode in ("access", "trunk", "dot1q-tunnel"): - obj["mode"] = "layer2" - elif mode in ("routed", "layer3"): - obj["mode"] = "layer3" - else: - obj["mode"] = "layer3" - - if intf_type == "ethernet": - obj["name"] = normalize_interface(interface_table.get("interface")) - obj["admin_state"] = interface_table.get("admin_state") - obj["description"] = interface_table.get("desc") - obj["mtu"] = interface_table.get("eth_mtu") - obj["duplex"] = interface_table.get("eth_duplex") - - command = "show run interface {0}".format(obj["name"]) - body = execute_show_command(command, module)[0] - - speed_match = re.search(r"speed (\d+)", body) - if speed_match is None: - obj["speed"] = "auto" - else: - obj["speed"] = speed_match.group(1) - - duplex_match = re.search(r"duplex (\S+)", body) - if duplex_match is None: - obj["duplex"] = "auto" - else: - obj["duplex"] = duplex_match.group(1) - - if "ip forward" in body: - obj["ip_forward"] = "enable" - else: - obj["ip_forward"] = "disable" - - elif intf_type == "svi": - obj["name"] = normalize_interface(interface_table.get("interface")) - attributes = get_vlan_interface_attributes(obj["name"], intf_type, module) - obj["admin_state"] = str(attributes.get("admin_state", "nxapibug")) - obj["description"] = str(attributes.get("description", "nxapi_bug")) - obj["mtu"] = interface_table.get("svi_mtu") - - command = "show run interface {0}".format(obj["name"]) - body = execute_show_command(command, module)[0] - if "ip forward" in body: - obj["ip_forward"] = "enable" - else: - obj["ip_forward"] = "disable" - if "fabric forwarding mode anycast-gateway" in body: - obj["fabric_forwarding_anycast_gateway"] = True - else: - obj["fabric_forwarding_anycast_gateway"] = False - - elif intf_type in ("loopback", "management", "nve"): - obj["name"] = normalize_interface(interface_table.get("interface")) - obj["admin_state"] = interface_table.get("admin_state") - if obj["admin_state"] is None and intf_type == "loopback": - # Some platforms don't have the 'admin_state' key. - # For loopback interfaces it's safe to use the - # 'state' key instead. - obj["admin_state"] = interface_table.get("state") - obj["description"] = interface_table.get("desc") - - elif intf_type == "portchannel": - obj["name"] = normalize_interface(interface_table.get("interface")) - obj["admin_state"] = interface_table.get("admin_state") - obj["description"] = interface_table.get("desc") - obj["mtu"] = interface_table.get("eth_mtu") - - if obj["admin_state"] is None: - # Some nxos platforms do not have the 'admin_state' key. - # Use the 'state_rsn_desc' key instead to determine the - # admin state of the interface. - state_description = interface_table.get("state_rsn_desc") - if state_description == "Administratively down": - obj["admin_state"] = "down" - elif state_description is not None: - obj["admin_state"] = "up" - - objs.append(obj) - - return objs - - -def check_declarative_intent_params(module, want): - failed_conditions = [] - have_neighbors = None - for w in want: - if w["interface_type"]: - continue - want_tx_rate = w.get("tx_rate") - want_rx_rate = w.get("rx_rate") - want_neighbors = w.get("neighbors") - if not (want_tx_rate or want_rx_rate or want_neighbors): - continue - - time.sleep(module.params["delay"]) - - cmd = [ - { - "command": "show interface {0}".format(w["name"]), - "output": "text", - }, - ] - - try: - out = run_commands(module, cmd, check_rc=False)[0] - except (AttributeError, IndexError, TypeError): - out = "" - - if want_tx_rate: - match = re.search(r"output rate (\d+)", out, re.M) - have_tx_rate = None - - if match: - have_tx_rate = match.group(1) - - if have_tx_rate is None or not conditional( - want_tx_rate, - have_tx_rate.strip(), - cast=int, - ): - failed_conditions.append("tx_rate " + want_tx_rate) - - if want_rx_rate: - match = re.search(r"input rate (\d+)", out, re.M) - have_rx_rate = None - - if match: - have_rx_rate = match.group(1) - - if have_rx_rate is None or not conditional( - want_rx_rate, - have_rx_rate.strip(), - cast=int, - ): - failed_conditions.append("rx_rate " + want_rx_rate) - - if want_neighbors: - have_host = [] - have_port = [] - if have_neighbors is None: - cmd = [ - { - "command": "show lldp neighbors interface {0} detail".format(w["name"]), - "output": "text", - }, - ] - output = run_commands(module, cmd, check_rc=False) - if output: - have_neighbors = output[0] - else: - have_neighbors = "" - if have_neighbors and "Total entries displayed: 0" not in have_neighbors: - for line in have_neighbors.strip().split("\n"): - if line.startswith("Port Description"): - have_port.append(line.split(": ")[1]) - if line.startswith("System Name"): - have_host.append(line.split(": ")[1]) - - for item in want_neighbors: - host = item.get("host") - port = item.get("port") - if host and host not in have_host: - failed_conditions.append("host " + host) - if port and port not in have_port: - failed_conditions.append("port " + port) - - return failed_conditions - - -def main(): - """main entry point for module execution""" - neighbors_spec = dict(host=dict(), port=dict()) - - element_spec = dict( - name=dict(aliases=["interface"]), - admin_state=dict(default="up", choices=["up", "down"]), - description=dict(), - speed=dict(), - mode=dict(choices=["layer2", "layer3"]), - mtu=dict(), - duplex=dict(choices=["full", "half", "auto"]), - interface_type=dict(choices=["loopback", "portchannel", "svi", "nve"]), - ip_forward=dict(choices=["enable", "disable"]), - fabric_forwarding_anycast_gateway=dict(type="bool"), - tx_rate=dict(), - rx_rate=dict(), - neighbors=dict(type="list", elements="dict", options=neighbors_spec), - delay=dict(default=10, type="int"), - state=dict(choices=["absent", "present", "default"], default="present"), - ) - - aggregate_spec = deepcopy(element_spec) - aggregate_spec["name"] = dict(required=True) - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - argument_spec = dict( - aggregate=dict( - type="list", - elements="dict", - options=aggregate_spec, - mutually_exclusive=[["name", "interface_type"]], - ), - ) - - argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - - required_one_of = [["name", "aggregate", "interface_type"]] - mutually_exclusive = [["name", "aggregate"], ["name", "interface_type"]] - - module = AnsibleModule( - argument_spec=argument_spec, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - supports_check_mode=True, - ) - warnings = list() - - result = {"changed": False} - if warnings: - result["warnings"] = warnings - - want = map_params_to_obj(module) - have = map_config_to_obj(want, module) - - commands = [] - commands1, commands2 = map_obj_to_commands((want, have), module) - commands.extend(commands1) - - if commands: - if not module.check_mode: - load_config(module, commands) - result["changed"] = True - # if the mode changes from L2 to L3, the admin state - # seems to change after the API call, so adding a second API - # call to ensure it's in the desired state. - if commands2: - load_config(module, commands2) - commands.extend(commands2) - commands = [cmd for cmd in commands if cmd != "configure"] - result["commands"] = commands - - if result["changed"]: - failed_conditions = check_declarative_intent_params(module, want) - - if failed_conditions: - msg = "One or more conditional statements have not been satisfied" - module.fail_json(msg=msg, failed_conditions=failed_conditions) - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_interface_ospf.py b/plugins/modules/nxos_interface_ospf.py deleted file mode 100644 index 1783e7c6c..000000000 --- a/plugins/modules/nxos_interface_ospf.py +++ /dev/null @@ -1,577 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_interface_ospf -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-10-26) Manages configuration of an OSPF interface instance. -description: -- Manages configuration of an OSPF interface instance. -version_added: 1.0.0 -deprecated: - alternative: nxos_ospf_interfaces - why: Updated modules released with more functionality - removed_at_date: '2022-10-26' -author: Gabriele Gerbino (@GGabriele) -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- Default, where supported, restores params default value. -- To remove an existing authentication configuration you should use C(message_digest_key_id=default) - plus all other options matching their existing values. -- Loopback interfaces only support ospf network type 'point-to-point'. -- C(state=absent) removes the whole OSPF interface configuration. -options: - interface: - description: - - Name of this cisco_interface resource. Valid value is a string. - required: true - type: str - ospf: - description: - - Name of the ospf instance. - required: true - type: str - area: - description: - - Ospf area associated with this cisco_interface_ospf instance. Valid values are - a string, formatted as an IP address (i.e. "0.0.0.0") or as an integer. - required: true - type: str - bfd: - description: - - Enables bfd at interface level. This overrides the bfd variable set at the ospf - router level. - - Valid values are 'enable', 'disable' or 'default'. - - "Dependency: ''feature bfd''" - type: str - choices: - - enable - - disable - - default - cost: - description: - - The cost associated with this cisco_interface_ospf instance. - type: str - hello_interval: - description: - - Time between sending successive hello packets. Valid values are an integer or - the keyword 'default'. - type: str - dead_interval: - description: - - Time interval an ospf neighbor waits for a hello packet before tearing down - adjacencies. Valid values are an integer or the keyword 'default'. - type: str - passive_interface: - description: - - Enable or disable passive-interface state on this interface. true - (enable) - Prevent OSPF from establishing an adjacency or sending routing updates on this - interface. false - (disable) Override global 'passive-interface default' for - this interface. - type: bool - network: - description: - - Specifies interface ospf network type. Valid values are 'point-to-point' or - 'broadcast'. - choices: - - point-to-point - - broadcast - type: str - message_digest: - description: - - Enables or disables the usage of message digest authentication. - type: bool - message_digest_key_id: - description: - - Md5 authentication key-id associated with the ospf instance. If this is present, - message_digest_encryption_type, message_digest_algorithm_type and message_digest_password - are mandatory. Valid value is an integer and 'default'. - type: str - message_digest_algorithm_type: - description: - - Algorithm used for authentication among neighboring routers within an area. - Valid values are 'md5' and 'default'. - choices: - - md5 - - default - type: str - message_digest_encryption_type: - description: - - Specifies the scheme used for encrypting message_digest_password. Valid values - are '3des' or 'cisco_type_7' encryption or 'default'. - choices: - - cisco_type_7 - - 3des - - default - type: str - message_digest_password: - description: - - Specifies the message_digest password. Valid value is a string. - type: str - state: - description: - - Determines whether the config should be present or not on the device. - default: present - choices: - - present - - absent - type: str -""" -EXAMPLES = """ -- cisco.nxos.nxos_interface_ospf: - interface: ethernet1/32 - ospf: 1 - area: 1 - bfd: disable - cost: default - -- cisco.nxos.nxos_interface_ospf: - interface: loopback0 - ospf: prod - area: 0.0.0.0 - bfd: enable - network: point-to-point - state: present -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["interface Ethernet1/32", "ip router ospf 1 area 0.0.0.1", "ip ospf bfd disable"] -""" - - -import re -import socket -import struct - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - nxos_argument_spec, -) - - -BOOL_PARAMS = ["passive_interface", "message_digest"] -PARAM_TO_COMMAND_KEYMAP = { - "interface": "", - "cost": "ip ospf cost", - "ospf": "ip router ospf", - "area": "ip router ospf", - "bfd": "ip ospf bfd", - "hello_interval": "ip ospf hello-interval", - "dead_interval": "ip ospf dead-interval", - "passive_interface": "ip ospf passive-interface", - "message_digest": "ip ospf authentication message-digest", - "message_digest_key_id": "ip ospf message-digest-key", - "message_digest_algorithm_type": "ip ospf message-digest-key", - "message_digest_encryption_type": "ip ospf message-digest-key", - "message_digest_password": "ip ospf message-digest-key", - "network": "ip ospf network", -} - - -def get_value(arg, config, module): - command = PARAM_TO_COMMAND_KEYMAP[arg] - has_command = re.search(r"\s+{0}\s*$".format(command), config, re.M) - has_command_val = re.search(r"(?:{0}\s)(?P.*)$".format(command), config, re.M) - - if command == "ip router ospf": - value = "" - if has_command_val: - value_list = has_command_val.group("value").split() - if arg == "ospf": - value = value_list[0] - elif arg == "area": - value = value_list[2] - value = normalize_area(value, module) - elif command == "ip ospf message-digest-key": - value = "" - if has_command_val: - value_list = has_command_val.group("value").split() - if arg == "message_digest_key_id": - value = value_list[0] - elif arg == "message_digest_algorithm_type": - value = value_list[1] - elif arg == "message_digest_encryption_type": - value = value_list[2] - if value == "3": - value = "3des" - elif value == "7": - value = "cisco_type_7" - elif arg == "message_digest_password": - value = value_list[3] - elif arg == "passive_interface": - has_no_command = re.search(r"\s+no\s+{0}\s*$".format(command), config, re.M) - if has_no_command: - value = False - elif has_command: - value = True - else: - value = None - elif arg == "bfd": - m = re.search(r"\s*ip ospf bfd(?P disable)?", config) - if m: - value = "disable" if m.group("disable") else "enable" - else: - value = "default" - elif arg in BOOL_PARAMS: - value = bool(has_command) - else: - value = "" - if has_command_val: - value = has_command_val.group("value") - return value - - -def get_existing(module, args): - existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - if module.params["interface"].startswith("loopback") or module.params["interface"].startswith( - "port-channel", - ): - parents = ["interface {0}".format(module.params["interface"])] - else: - parents = ["interface {0}".format(module.params["interface"].capitalize())] - config = netcfg.get_section(parents) - if "ospf" in config: - for arg in args: - if arg not in ["interface"]: - existing[arg] = get_value(arg, config, module) - existing["interface"] = module.params["interface"] - return existing - - -def apply_key_map(key_map, table): - new_dict = {} - for key, value in table.items(): - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = value - return new_dict - - -def get_default_commands(existing, proposed, existing_commands, key, module): - commands = list() - existing_value = existing_commands.get(key) - if key.startswith("ip ospf message-digest-key"): - check = False - for param in [ - "message_digest_encryption_type", - "message_digest_algorithm_type", - "message_digest_password", - ]: - if existing[param] == proposed[param]: - check = True - if check: - if existing["message_digest_encryption_type"] == "3des": - encryption_type = "3" - elif existing["message_digest_encryption_type"] == "cisco_type_7": - encryption_type = "7" - command = "no {0} {1} {2} {3} {4}".format( - key, - existing["message_digest_key_id"], - existing["message_digest_algorithm_type"], - encryption_type, - existing["message_digest_password"], - ) - commands.append(command) - elif "ip ospf bfd" in key: - commands.append("no {0}".format(key)) - elif "passive-interface" in key: - commands.append("default ip ospf passive-interface") - else: - commands.append("no {0} {1}".format(key, existing_value)) - return commands - - -def get_custom_command(existing_cmd, proposed, key, module): - commands = list() - - if key == "ip router ospf": - command = "{0} {1} area {2}".format(key, proposed["ospf"], proposed["area"]) - if command not in existing_cmd: - commands.append(command) - - if key == "ip ospf network": - command = "{0} {1}".format(key, proposed["network"]) - - if command not in existing_cmd: - commands.append(command) - - elif key.startswith("ip ospf message-digest-key"): - if proposed["message_digest_key_id"] != "default" and "options" not in key: - if proposed["message_digest_encryption_type"] == "3des": - encryption_type = "3" - elif proposed["message_digest_encryption_type"] == "cisco_type_7": - encryption_type = "7" - command = "{0} {1} {2} {3} {4}".format( - key, - proposed["message_digest_key_id"], - proposed["message_digest_algorithm_type"], - encryption_type, - proposed["message_digest_password"], - ) - commands.append(command) - return commands - - -def state_present(module, existing, proposed, candidate): - commands = list() - proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - - for key, value in proposed_commands.items(): - if existing_commands.get(key): - if key == "ip router ospf": - if proposed["area"] == existing["area"]: - continue - if existing_commands[key] == value: - continue - - if key == "ip ospf passive-interface" and module.params.get("interface").upper().startswith( - "LO", - ): - module.fail_json(msg="loopback interface does not support passive_interface") - if ( - key == "ip ospf network" - and value == "broadcast" - and module.params.get("interface").upper().startswith("LO") - ): - module.fail_json(msg="loopback interface does not support ospf network type broadcast") - - if key == "ip ospf bfd": - cmd = key - if "disable" in value: - cmd += " disable" - elif "default" in value and existing.get("bfd") is not None: - cmd = "no " + cmd - commands.append(cmd) - continue - - if value is True: - commands.append(key) - elif value is False: - commands.append("no {0}".format(key)) - elif value == "default": - if existing_commands.get(key): - commands.extend( - get_default_commands(existing, proposed, existing_commands, key, module), - ) - else: - if key == "ip router ospf" or key.startswith("ip ospf message-digest-key"): - commands.extend(get_custom_command(commands, proposed, key, module)) - else: - command = "{0} {1}".format(key, value.lower()) - commands.append(command) - - if commands: - parents = ["interface {0}".format(module.params["interface"].capitalize())] - candidate.add(commands, parents=parents) - - -def state_absent(module, existing, proposed, candidate): - commands = [] - parents = ["interface {0}".format(module.params["interface"].capitalize())] - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - - for key, value in existing_commands.items(): - if "ip ospf bfd" in key: - if "default" not in value: - # cli is present when enabled or disabled; this removes either case - commands.append("no ip ospf bfd") - continue - if "ip ospf passive-interface" in key and value is not None: - # cli is present for both enabled or disabled; 'no' will not remove - commands.append("default ip ospf passive-interface") - continue - - if value: - if key.startswith("ip ospf message-digest-key"): - if "options" not in key: - if existing["message_digest_encryption_type"] == "3des": - encryption_type = "3" - elif existing["message_digest_encryption_type"] == "cisco_type_7": - encryption_type = "7" - command = "no {0} {1} {2} {3} {4}".format( - key, - existing["message_digest_key_id"], - existing["message_digest_algorithm_type"], - encryption_type, - existing["message_digest_password"], - ) - commands.append(command) - elif key in [ - "ip ospf authentication message-digest", - "ip ospf network", - ]: - if value: - commands.append("no {0}".format(key)) - elif key == "ip router ospf": - command = "no {0} {1} area {2}".format(key, proposed["ospf"], proposed["area"]) - if command not in commands: - commands.append(command) - else: - existing_value = existing_commands.get(key) - commands.append("no {0} {1}".format(key, existing_value)) - - candidate.add(commands, parents=parents) - - -def normalize_area(area, module): - try: - area = int(area) - area = socket.inet_ntoa(struct.pack("!L", area)) - except ValueError: - splitted_area = area.split(".") - if len(splitted_area) != 4: - module.fail_json(msg="Incorrect Area ID format", area=area) - return area - - -def main(): - argument_spec = dict( - interface=dict(required=True, type="str"), - ospf=dict(required=True, type="str"), - area=dict(required=True, type="str"), - bfd=dict( - choices=["enable", "disable", "default"], - required=False, - type="str", - ), - cost=dict(required=False, type="str"), - hello_interval=dict(required=False, type="str"), - dead_interval=dict(required=False, type="str"), - passive_interface=dict(required=False, type="bool"), - network=dict(required=False, type="str", choices=["broadcast", "point-to-point"]), - message_digest=dict(required=False, type="bool"), - message_digest_key_id=dict(required=False, type="str"), - message_digest_algorithm_type=dict(required=False, type="str", choices=["md5", "default"]), - message_digest_encryption_type=dict( - required=False, - type="str", - choices=["cisco_type_7", "3des", "default"], - ), - message_digest_password=dict(required=False, type="str", no_log=True), - state=dict(choices=["present", "absent"], default="present", required=False), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule( - argument_spec=argument_spec, - required_together=[ - [ - "message_digest_key_id", - "message_digest_algorithm_type", - "message_digest_encryption_type", - "message_digest_password", - ], - ], - supports_check_mode=True, - ) - - # Normalize interface input data. - # - # * For port-channel and loopback interfaces expection is all lower case names. - # * All other interfaces the expectation is an uppercase leading character - # followed by lower case characters. - # - if re.match(r"(port-channel|loopback)", module.params["interface"], re.I): - module.params["interface"] = module.params["interface"].lower() - else: - module.params["interface"] = module.params["interface"].capitalize() - - warnings = list() - result = {"changed": False, "commands": [], "warnings": warnings} - - for param in [ - "message_digest_encryption_type", - "message_digest_algorithm_type", - "message_digest_password", - ]: - if ( - module.params[param] == "default" - and module.params["message_digest_key_id"] != "default" - ): - module.exit_json( - msg="Use message_digest_key_id=default to remove an existing authentication configuration", - ) - - state = module.params["state"] - args = PARAM_TO_COMMAND_KEYMAP.keys() - - existing = get_existing(module, args) - proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) - - proposed = {} - for key, value in proposed_args.items(): - if key != "interface": - if str(value).lower() == "true": - value = True - elif str(value).lower() == "false": - value = False - elif str(value).lower() == "default": - value = "default" - elif key == "bfd": - value = str(value).lower() - if existing.get(key) or (not existing.get(key) and value): - proposed[key] = value - elif "passive_interface" in key and existing.get(key) is None and value is False: - proposed[key] = value - - proposed["area"] = normalize_area(proposed["area"], module) - if "hello_interval" in proposed and proposed["hello_interval"] == "10": - proposed["hello_interval"] = "default" - - candidate = CustomNetworkConfig(indent=3) - if state == "present": - state_present(module, existing, proposed, candidate) - elif ( - state == "absent" - and existing.get("ospf") == proposed["ospf"] - and existing.get("area") == proposed["area"] - ): - state_absent(module, existing, proposed, candidate) - - if candidate: - candidate = candidate.items_text() - if not module.check_mode: - load_config(module, candidate) - result["changed"] = True - result["commands"] = candidate - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_l2_interface.py b/plugins/modules/nxos_l2_interface.py deleted file mode 100644 index a51534e9a..000000000 --- a/plugins/modules/nxos_l2_interface.py +++ /dev/null @@ -1,664 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2017, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_l2_interface -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manage Layer-2 - interface on Cisco NXOS devices. -description: -- This module provides declarative management of Layer-2 interface on Cisco NXOS devices. -version_added: 1.0.0 -deprecated: - alternative: nxos_l2_interfaces - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -author: -- Trishna Guha (@trishnaguha) -notes: -- Tested against NXOSv 7.0(3)I5(1). -- Unsupported for Cisco MDS -options: - name: - description: - - Full name of the interface excluding any logical unit number, i.e. Ethernet1/1. - aliases: - - interface - type: str - mode: - description: - - Mode in which interface needs to be configured. - choices: - - access - - trunk - type: str - access_vlan: - description: - - Configure given VLAN in access port. If C(mode=access), used as the access VLAN - ID. - type: str - native_vlan: - description: - - Native VLAN to be configured in trunk port. If C(mode=trunk), used as the trunk - native VLAN ID. - type: str - trunk_vlans: - description: - - List of VLANs to be configured in trunk port. If C(mode=trunk), used as the - VLAN range to ADD or REMOVE from the trunk. - aliases: - - trunk_add_vlans - type: str - trunk_allowed_vlans: - description: - - List of allowed VLANs in a given trunk port. If C(mode=trunk), these are the - only VLANs that will be configured on the trunk, i.e. "2-10,15". - type: str - aggregate: - description: - - List of Layer-2 interface definitions. - type: list - elements: dict - suboptions: - name: - description: - - Full name of the interface excluding any logical unit number, i.e. Ethernet1/1. - aliases: - - interface - type: str - mode: - description: - - Mode in which interface needs to be configured. - choices: - - access - - trunk - type: str - access_vlan: - description: - - Configure given VLAN in access port. If C(mode=access), used as the access VLAN - ID. - type: str - native_vlan: - description: - - Native VLAN to be configured in trunk port. If C(mode=trunk), used as the trunk - native VLAN ID. - type: str - trunk_vlans: - description: - - List of VLANs to be configured in trunk port. If C(mode=trunk), used as the - VLAN range to ADD or REMOVE from the trunk. - aliases: - - trunk_add_vlans - type: str - trunk_allowed_vlans: - description: - - List of allowed VLANs in a given trunk port. If C(mode=trunk), these are the - only VLANs that will be configured on the trunk, i.e. "2-10,15". - type: str - state: - description: - - Manage the state of the Layer-2 Interface configuration. - choices: - - present - - absent - - unconfigured - type: str - - state: - description: - - Manage the state of the Layer-2 Interface configuration. - default: present - choices: - - present - - absent - - unconfigured - type: str - - -""" - -EXAMPLES = """ -- name: Ensure Eth1/5 is in its default l2 interface state - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - state: unconfigured - -- name: Ensure Eth1/5 is configured for access vlan 20 - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: access - access_vlan: 20 - -- name: Ensure Eth1/5 only has vlans 5-10 as trunk vlans - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: trunk - native_vlan: 10 - trunk_vlans: 5-10 - -- name: Ensure eth1/5 is a trunk port and ensure 2-50 are being tagged (doesn't mean - others aren't also being tagged) - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: trunk - native_vlan: 10 - trunk_vlans: 2-50 - -- name: Ensure these VLANs are not being tagged on the trunk - cisco.nxos.nxos_l2_interface: - name: Ethernet1/5 - mode: trunk - trunk_vlans: 51-4094 - state: absent - -- name: Aggregate Configure interfaces for access_vlan with aggregate - cisco.nxos.nxos_l2_interface: - aggregate: - - {name: Ethernet1/2, access_vlan: 6} - - {name: Ethernet1/7, access_vlan: 15} - mode: access -""" - -RETURN = """ -commands: - description: The list of configuration mode commands to send to the device - returned: always, except for the platforms that use Netconf transport to manage the device. - type: list - sample: - - interface eth1/5 - - switchport access vlan 20 -""" - -from copy import deepcopy - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_interface_type, - load_config, - nxos_argument_spec, - run_commands, -) - - -def get_interface_mode(name, module): - """Gets current mode of interface: layer2 or layer3 - Args: - device (Device): This is the device object of an NX-API enabled device - using the Device class within device.py - interface (string): full name of interface, i.e. Ethernet1/1, - loopback10, port-channel20, vlan20 - Returns: - str: 'layer2' or 'layer3' - """ - command = "show interface {0} | json".format(name) - intf_type = get_interface_type(name) - mode = "unknown" - interface_table = {} - - try: - body = run_commands(module, [command])[0] - interface_table = body["TABLE_interface"]["ROW_interface"] - except (KeyError, AttributeError, IndexError): - return mode - - if interface_table: - # HACK FOR NOW - if intf_type in ["ethernet", "portchannel"]: - mode = str(interface_table.get("eth_mode", "layer3")) - if mode in ["access", "trunk"]: - mode = "layer2" - if mode == "routed": - mode = "layer3" - elif intf_type == "loopback" or intf_type == "svi": - mode = "layer3" - return mode - - -def interface_is_portchannel(name, module): - """Checks to see if an interface is part of portchannel bundle - Args: - interface (str): full name of interface, i.e. Ethernet1/1 - Returns: - True/False based on if interface is a member of a portchannel bundle - """ - intf_type = get_interface_type(name) - - if intf_type == "ethernet": - command = "show interface {0} | json".format(name) - try: - body = run_commands(module, [command])[0] - interface_table = body["TABLE_interface"]["ROW_interface"] - except (KeyError, AttributeError, IndexError): - interface_table = None - - if interface_table: - state = interface_table.get("eth_bundle") - if state: - return True - else: - return False - - return False - - -def get_switchport(port, module): - """Gets current config of L2 switchport - Args: - device (Device): This is the device object of an NX-API enabled device - using the Device class within device.py - port (str): full name of interface, i.e. Ethernet1/1 - Returns: - dictionary with k/v pairs for L2 vlan config - """ - - command = "show interface {0} switchport | json".format(port) - - try: - body = run_commands(module, [command])[0] - sp_table = body["TABLE_interface"]["ROW_interface"] - except (KeyError, AttributeError, IndexError): - sp_table = None - - if sp_table: - key_map = { - "interface": "name", - "oper_mode": "mode", - "switchport": "switchport", - "access_vlan": "access_vlan", - "access_vlan_name": "access_vlan_name", - "native_vlan": "native_vlan", - "native_vlan_name": "native_vlan_name", - "trunk_vlans": "trunk_vlans", - } - sp = apply_key_map(key_map, sp_table) - return sp - - else: - return {} - - -def remove_switchport_config_commands(name, existing, proposed, module): - mode = proposed.get("mode") - commands = [] - command = None - - if mode == "access": - av_check = existing.get("access_vlan") == proposed.get("access_vlan") - if av_check: - command = "no switchport access vlan {0}".format(existing.get("access_vlan")) - commands.append(command) - - elif mode == "trunk": - existing_vlans = existing.get("trunk_vlans_list") - proposed_vlans = proposed.get("trunk_vlans_list") - vlans_to_remove = set(proposed_vlans).intersection(existing_vlans) - - if vlans_to_remove: - proposed_allowed_vlans = proposed.get("trunk_allowed_vlans") - remove_trunk_allowed_vlans = proposed.get("trunk_vlans", proposed_allowed_vlans) - command = "switchport trunk allowed vlan remove {0}".format(remove_trunk_allowed_vlans) - commands.append(command) - - native_check = existing.get("native_vlan") == proposed.get("native_vlan") - if native_check and proposed.get("native_vlan"): - command = "no switchport trunk native vlan {0}".format(existing.get("native_vlan")) - commands.append(command) - - if commands: - commands.insert(0, "interface " + name) - return commands - - -def get_switchport_config_commands(name, existing, proposed, module): - """Gets commands required to config a given switchport interface""" - - proposed_mode = proposed.get("mode") - existing_mode = existing.get("mode") - commands = [] - command = None - - if proposed_mode != existing_mode: - if proposed_mode == "trunk": - command = "switchport mode trunk" - elif proposed_mode == "access": - command = "switchport mode access" - - if command: - commands.append(command) - - if proposed_mode == "access": - av_check = str(existing.get("access_vlan")) == str(proposed.get("access_vlan")) - if not av_check: - command = "switchport access vlan {0}".format(proposed.get("access_vlan")) - commands.append(command) - - elif proposed_mode == "trunk": - tv_check = existing.get("trunk_vlans_list") == proposed.get("trunk_vlans_list") - - if not tv_check: - if proposed.get("allowed"): - command = "switchport trunk allowed vlan {0}".format( - proposed.get("trunk_allowed_vlans"), - ) - commands.append(command) - - else: - existing_vlans = existing.get("trunk_vlans_list") - proposed_vlans = proposed.get("trunk_vlans_list") - vlans_to_add = set(proposed_vlans).difference(existing_vlans) - if vlans_to_add: - command = "switchport trunk allowed vlan add {0}".format( - proposed.get("trunk_vlans"), - ) - commands.append(command) - - native_check = str(existing.get("native_vlan")) == str(proposed.get("native_vlan")) - if not native_check and proposed.get("native_vlan"): - command = "switchport trunk native vlan {0}".format(proposed.get("native_vlan")) - commands.append(command) - - if commands: - commands.insert(0, "interface " + name) - return commands - - -def is_switchport_default(existing): - """Determines if switchport has a default config based on mode - Args: - existing (dict): existing switchport configuration from Ansible mod - Returns: - boolean: True if switchport has OOB Layer 2 config, i.e. - vlan 1 and trunk all and mode is access - """ - - c1 = str(existing["access_vlan"]) == "1" - c2 = str(existing["native_vlan"]) == "1" - c3 = existing["trunk_vlans"] == "1-4094" - c4 = existing["mode"] == "access" - - default = c1 and c2 and c3 and c4 - - return default - - -def default_switchport_config(name): - commands = [] - commands.append("interface " + name) - commands.append("switchport mode access") - commands.append("switch access vlan 1") - commands.append("switchport trunk native vlan 1") - commands.append("switchport trunk allowed vlan all") - return commands - - -def vlan_range_to_list(vlans): - result = [] - if vlans: - for part in vlans.split(","): - if part == "none": - break - if "-" in part: - a, b = part.split("-") - a, b = int(a), int(b) - result.extend(range(a, b + 1)) - else: - a = int(part) - result.append(a) - return numerical_sort(result) - return result - - -def get_list_of_vlans(module): - - command = "show vlan | json" - vlan_list = [] - - try: - body = run_commands(module, [command])[0] - vlan_table = body["TABLE_vlanbrief"]["ROW_vlanbrief"] - except (KeyError, AttributeError, IndexError): - return [] - - if isinstance(vlan_table, list): - for vlan in vlan_table: - vlan_list.append(str(vlan["vlanshowbr-vlanid-utf"])) - else: - vlan_list.append("1") - - return vlan_list - - -def numerical_sort(string_int_list): - """Sorts list of strings/integers that are digits in numerical order.""" - - as_int_list = [] - as_str_list = [] - for vlan in string_int_list: - as_int_list.append(int(vlan)) - as_int_list.sort() - for vlan in as_int_list: - as_str_list.append(str(vlan)) - return as_str_list - - -def apply_key_map(key_map, table): - new_dict = {} - for key, value in table.items(): - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = str(value) - return new_dict - - -def apply_value_map(value_map, resource): - for key, value in value_map.items(): - resource[key] = value[resource.get(key)] - return resource - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def map_params_to_obj(module): - obj = [] - aggregate = module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = module.params[key] - - d = item.copy() - obj.append(d) - else: - obj.append( - { - "name": module.params["name"], - "mode": module.params["mode"], - "access_vlan": module.params["access_vlan"], - "native_vlan": module.params["native_vlan"], - "trunk_vlans": module.params["trunk_vlans"], - "trunk_allowed_vlans": module.params["trunk_allowed_vlans"], - "state": module.params["state"], - }, - ) - - return obj - - -def main(): - """main entry point for module execution""" - element_spec = dict( - name=dict(type="str", aliases=["interface"]), - mode=dict(choices=["access", "trunk"]), - access_vlan=dict(type="str"), - native_vlan=dict(type="str"), - trunk_vlans=dict(type="str", aliases=["trunk_add_vlans"]), - trunk_allowed_vlans=dict(type="str"), - state=dict(choices=["absent", "present", "unconfigured"], default="present"), - ) - - aggregate_spec = deepcopy(element_spec) - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) - - argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule( - argument_spec=argument_spec, - mutually_exclusive=[ - ["access_vlan", "trunk_vlans"], - ["access_vlan", "native_vlan"], - ["access_vlan", "trunk_allowed_vlans"], - ], - supports_check_mode=True, - ) - - warnings = list() - commands = [] - result = {"changed": False} - if warnings: - result["warnings"] = warnings - - want = map_params_to_obj(module) - for w in want: - name = w["name"] - mode = w["mode"] - access_vlan = w["access_vlan"] - state = w["state"] - trunk_vlans = w["trunk_vlans"] - native_vlan = w["native_vlan"] - trunk_allowed_vlans = w["trunk_allowed_vlans"] - - args = dict( - name=name, - mode=mode, - access_vlan=access_vlan, - native_vlan=native_vlan, - trunk_vlans=trunk_vlans, - trunk_allowed_vlans=trunk_allowed_vlans, - ) - - proposed = dict((k, v) for k, v in args.items() if v is not None) - - name = name.lower() - - if mode == "access" and state == "present" and not access_vlan: - module.fail_json(msg="access_vlan param is required when mode=access && state=present") - - if mode == "trunk" and access_vlan: - module.fail_json(msg="access_vlan param not supported when using mode=trunk") - - current_mode = get_interface_mode(name, module) - - # Current mode will return layer3, layer2, or unknown - if current_mode == "unknown" or current_mode == "layer3": - module.fail_json( - msg="Ensure interface is configured to be a L2" - "\nport first before using this module. You can use" - "\nthe nxos_interface module for this.", - ) - - if interface_is_portchannel(name, module): - module.fail_json( - msg="Cannot change L2 config on physical " - "\nport because it is in a portchannel. " - "\nYou should update the portchannel config.", - ) - - # existing will never be null for Eth intfs as there is always a default - existing = get_switchport(name, module) - - # Safeguard check - # If there isn't an existing, something is wrong per previous comment - if not existing: - module.fail_json(msg="Make sure you are using the FULL interface name") - - if trunk_vlans or trunk_allowed_vlans: - if trunk_vlans: - trunk_vlans_list = vlan_range_to_list(trunk_vlans) - elif trunk_allowed_vlans: - trunk_vlans_list = vlan_range_to_list(trunk_allowed_vlans) - proposed["allowed"] = True - - existing_trunks_list = vlan_range_to_list((existing["trunk_vlans"])) - - existing["trunk_vlans_list"] = existing_trunks_list - proposed["trunk_vlans_list"] = trunk_vlans_list - - current_vlans = get_list_of_vlans(module) - - if state == "present": - if access_vlan and access_vlan not in current_vlans: - module.fail_json( - msg="You are trying to configure a VLAN" - " on an interface that\ndoes not exist on the " - " switch yet!", - vlan=access_vlan, - ) - elif native_vlan and native_vlan not in current_vlans: - module.fail_json( - msg="You are trying to configure a VLAN" - " on an interface that\ndoes not exist on the " - " switch yet!", - vlan=native_vlan, - ) - else: - command = get_switchport_config_commands(name, existing, proposed, module) - commands.append(command) - elif state == "unconfigured": - is_default = is_switchport_default(existing) - if not is_default: - command = default_switchport_config(name) - commands.append(command) - elif state == "absent": - command = remove_switchport_config_commands(name, existing, proposed, module) - commands.append(command) - - if trunk_vlans or trunk_allowed_vlans: - existing.pop("trunk_vlans_list") - proposed.pop("trunk_vlans_list") - - cmds = flatten_list(commands) - if cmds: - if module.check_mode: - module.exit_json(changed=True, commands=cmds) - else: - result["changed"] = True - load_config(module, cmds) - if "configure" in cmds: - cmds.pop(0) - - result["commands"] = cmds - result["warnings"] = warnings - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_l3_interface.py b/plugins/modules/nxos_l3_interface.py deleted file mode 100644 index cca9449cb..000000000 --- a/plugins/modules/nxos_l3_interface.py +++ /dev/null @@ -1,288 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2017, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_l3_interface -author: Trishna Guha (@trishnaguha) -short_description: (deprecated, removed after 2022-06-01) Manage L3 interfaces - on Cisco NXOS network devices -description: -- This module provides declarative management of L3 interfaces on Cisco NXOS network - devices. -version_added: 1.0.0 -deprecated: - alternative: nxos_l3_interfaces - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -notes: -- Tested against NXOSv 7.0(3)I5(1). -- Unsupported for Cisco MDS -options: - name: - description: - - Name of the L3 interface. - type: str - ipv4: - description: - - IPv4 of the L3 interface. - type: str - ipv6: - description: - - IPv6 of the L3 interface. - type: str - aggregate: - description: List of L3 interfaces definitions. - type: list - elements: dict - suboptions: - name: - description: - - Name of the L3 interface. - type: str - ipv4: - description: - - IPv4 of the L3 interface. - type: str - ipv6: - description: - - IPv6 of the L3 interface. - type: str - state: - description: - - State of the L3 interface configuration. - choices: - - present - - absent - type: str - state: - description: - - State of the L3 interface configuration. - default: present - choices: - - present - - absent - type: str -extends_documentation_fragment: -- cisco.nxos.nxos -""" - -EXAMPLES = """ -- name: Set interface IPv4 address - cisco.nxos.nxos_l3_interface: - name: Ethernet2/3 - ipv4: 192.168.0.1/24 - -- name: Remove interface IPv4 address - cisco.nxos.nxos_l3_interface: - name: Ethernet2/3 - state: absent - -- name: Set IP addresses on aggregate - cisco.nxos.nxos_l3_interface: - aggregate: - - {name: "Ethernet2/1", ipv4: "192.168.2.10/24"} - - {name: "Ethernet2/5", ipv4: "192.168.3.10/24", ipv6: "fd5d:12c9:2201:1::1/64"} - -- name: Remove IP addresses on aggregate - cisco.nxos.nxos_l3_interface: - aggregate: - - {name: "Ethernet2/1", ipv4: "192.168.2.10/24"} - - {name: "Ethernet2/5", ipv4: "192.168.3.10/24", ipv6: "fd5d:12c9:2201:1::1/64"} - state: absent -""" - -RETURN = """ -commands: - description: The list of configuration mode commands to send to the device - returned: always, except for the platforms that use Netconf transport to manage the device. - type: list - sample: - - interface ethernet2/3 - - no switchport - - ip address 192.168.22.1/24 - - ipv6 address "fd5d:12c9:2201:1::1/64" - - no ip address 192.168.22.1/24 -""" - -import re - -from copy import deepcopy - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - normalize_interface, - nxos_argument_spec, -) - - -def search_obj_in_list(name, lst): - for o in lst: - if o["name"] == name: - return o - - -def map_obj_to_commands(updates, module, warnings): - commands = list() - want, have = updates - - for w in want: - name = w["name"] - ipv4 = w["ipv4"] - ipv6 = w["ipv6"] - state = w["state"] - del w["state"] - - obj_in_have = search_obj_in_list(name, have) - - if not obj_in_have: - warnings.append("Unknown interface {0}".format(name)) - elif state == "absent": - command = [] - if obj_in_have["name"] == name: - if ipv4 and ipv4 == obj_in_have["ipv4"]: - command.append("no ip address {0}".format(ipv4)) - if ipv6 and ipv6 in obj_in_have["ipv6"]: - command.append("no ipv6 address {0}".format(ipv6)) - if command: - command.append("exit") - command.insert(0, "interface {0}".format(name)) - commands.extend(command) - - elif state == "present": - command = [] - if obj_in_have["name"] == name: - if ipv4 and ipv4 != obj_in_have["ipv4"]: - command.append("ip address {0}".format(ipv4)) - if ipv6 and ipv6 not in obj_in_have["ipv6"]: - command.append("ipv6 address {0}".format(ipv6)) - if command: - command.append("exit") - command.insert(0, "interface {0}".format(name)) - elif not ipv4 and not ipv6: - command.append("interface {0}".format(name)) - commands.extend(command) - - return commands - - -def map_params_to_obj(module): - obj = [] - - aggregate = module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = module.params[key] - - d = item.copy() - name = d["name"] - d["name"] = normalize_interface(name) - obj.append(d) - - else: - obj.append( - { - "name": normalize_interface(module.params["name"]), - "ipv4": module.params["ipv4"], - "ipv6": module.params["ipv6"], - "state": module.params["state"], - }, - ) - - return obj - - -def map_config_to_obj(want, module): - objs = list() - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - - for w in want: - parents = ["interface {0}".format(w["name"])] - config = netcfg.get_section(parents) - obj = dict(name=None, ipv4=None, ipv6=[]) - - if config: - match_name = re.findall(r"interface (\S+)", config, re.M) - if match_name: - obj["name"] = normalize_interface(match_name[0]) - - match_ipv4 = re.findall(r"ip address (\S+)", config, re.M) - if match_ipv4: - obj["ipv4"] = match_ipv4[0] - - match_ipv6 = re.findall(r"ipv6 address (\S+)", config, re.M) - if match_ipv6: - obj["ipv6"] = match_ipv6 - - objs.append(obj) - return objs - - -def main(): - """main entry point for module execution""" - element_spec = dict( - name=dict(), - ipv4=dict(), - ipv6=dict(), - state=dict(default="present", choices=["present", "absent"]), - ) - - aggregate_spec = deepcopy(element_spec) - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) - - argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - - required_one_of = [["name", "aggregate"]] - mutually_exclusive = [["name", "aggregate"]] - module = AnsibleModule( - argument_spec=argument_spec, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - supports_check_mode=True, - ) - - warnings = list() - result = {"changed": False} - - want = map_params_to_obj(module) - have = map_config_to_obj(want, module) - - commands = map_obj_to_commands((want, have), module, warnings) - result["commands"] = commands - - if warnings: - result["warnings"] = warnings - if commands: - if not module.check_mode: - load_config(module, commands) - result["changed"] = True - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_linkagg.py b/plugins/modules/nxos_linkagg.py deleted file mode 100644 index d6a878df2..000000000 --- a/plugins/modules/nxos_linkagg.py +++ /dev/null @@ -1,508 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2017, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_linkagg -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manage link - aggregation groups on Cisco NXOS devices. -description: -- This module provides declarative management of link aggregation groups on Cisco - NXOS devices. -version_added: 1.0.0 -deprecated: - alternative: nxos_lag_interfaces - why: Updated modules released with more functionality. - removed_at_date: '2022-06-01' -author: -- Trishna Guha (@trishnaguha) -notes: -- Tested against NXOSv 7.0(3)I5(1). -- Unsupported for Cisco MDS -- C(state=absent) removes the portchannel config and interface if it already exists. - If members to be removed are not explicitly passed, all existing members (if any), - are removed. -- Members must be a list. -- LACP needs to be enabled first if active/passive modes are used. -options: - group: - description: - - Channel-group number for the port-channel Link aggregation group. - type: str - mode: - description: - - Mode for the link aggregation group. - choices: - - 'active' - - 'on' - - 'passive' - default: 'on' - type: str - min_links: - description: - - Minimum number of ports required up before bringing up the link aggregation - group. - type: int - members: - description: - - List of interfaces that will be managed in the link aggregation group. - type: list - elements: str - force: - description: - - When true it forces link aggregation group members to match what is declared - in the members param. This can be used to remove members. - type: bool - default: no - aggregate: - description: List of link aggregation definitions. - type: list - elements: dict - suboptions: - group: - description: - - Channel-group number for the port-channel Link aggregation group. - type: str - required: True - mode: - description: - - Mode for the link aggregation group. - choices: - - 'active' - - 'on' - - 'passive' - type: str - min_links: - description: - - Minimum number of ports required up before bringing up the link aggregation - group. - type: int - members: - description: - - List of interfaces that will be managed in the link aggregation group. - type: list - elements: str - force: - description: - - When true it forces link aggregation group members to match what is declared - in the members param. This can be used to remove members. - type: bool - state: - description: - - State of the link aggregation group. - choices: - - present - - absent - type: str - state: - description: - - State of the link aggregation group. - default: present - choices: - - present - - absent - type: str - purge: - description: - - Purge links not defined in the I(aggregate) parameter. - type: bool - default: no -""" - -EXAMPLES = """ -- name: create link aggregation group - cisco.nxos.nxos_linkagg: - group: 99 - state: present - -- name: delete link aggregation group - cisco.nxos.nxos_linkagg: - group: 99 - state: absent - -- name: set link aggregation group to members - cisco.nxos.nxos_linkagg: - group: 10 - min_links: 3 - mode: active - members: - - Ethernet1/2 - - Ethernet1/4 - -- name: remove link aggregation group from Ethernet1/2 - cisco.nxos.nxos_linkagg: - group: 10 - min_links: 3 - mode: active - members: - - Ethernet1/4 - -- name: Create aggregate of linkagg definitions - cisco.nxos.nxos_linkagg: - aggregate: - - {group: 3} - - {group: 100, min_links: 3} - -- name: Remove aggregate of linkagg definitions - cisco.nxos.nxos_linkagg: - aggregate: - - {group: 3} - - {group: 100, min_links: 3} - state: absent -""" - -RETURN = """ -commands: - description: The list of configuration mode commands to send to the device - returned: always, except for the platforms that use Netconf transport to manage the device. - type: list - sample: - - interface port-channel 30 - - lacp min-links 5 - - interface Ethernet2/1 - - channel-group 30 mode active - - no interface port-channel 30 -""" - -import re - -from copy import deepcopy - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - normalize_interface, - nxos_argument_spec, - run_commands, -) - - -def search_obj_in_list(group, lst): - for o in lst: - if o["group"] == group: - return o - - -def get_diff(w, obj): - c = deepcopy(w) - o = deepcopy(obj) - - if o["group"] == c["group"] and o.get("members") == c.get("members"): - if "members" in o: - del o["members"] - if "members" in c: - del c["members"] - diff_dict = dict(set(c.items()) - set(o.items())) - return diff_dict - - -def map_obj_to_commands(updates, module): - commands = list() - want, have = updates - purge = module.params["purge"] - force = module.params["force"] - - for w in want: - group = w["group"] - mode = w["mode"] - min_links = w["min_links"] - members = w.get("members") or [] - state = w["state"] - del w["state"] - - obj_in_have = search_obj_in_list(group, have) - - if state == "absent": - if obj_in_have: - members_to_remove = list(set(obj_in_have["members"]) - set(members)) - if members_to_remove: - for m in members_to_remove: - commands.append("interface {0}".format(m)) - commands.append("no channel-group {0}".format(obj_in_have["group"])) - commands.append("exit") - commands.append("no interface port-channel {0}".format(group)) - - elif state == "present": - if not obj_in_have: - commands.append("interface port-channel {0}".format(group)) - if min_links != "None": - commands.append("lacp min-links {0}".format(min_links)) - commands.append("exit") - if members: - for m in members: - commands.append("interface {0}".format(m)) - if force: - commands.append("channel-group {0} force mode {1}".format(group, mode)) - else: - commands.append("channel-group {0} mode {1}".format(group, mode)) - - else: - if members: - if not obj_in_have["members"]: - for m in members: - commands.append("interface port-channel {0}".format(group)) - commands.append("exit") - commands.append("interface {0}".format(m)) - if force: - commands.append( - "channel-group {0} force mode {1}".format(group, mode), - ) - else: - commands.append("channel-group {0} mode {1}".format(group, mode)) - - elif set(members) != set(obj_in_have["members"]): - missing_members = list(set(members) - set(obj_in_have["members"])) - for m in missing_members: - commands.append("interface port-channel {0}".format(group)) - commands.append("exit") - commands.append("interface {0}".format(m)) - if force: - commands.append( - "channel-group {0} force mode {1}".format(group, mode), - ) - else: - commands.append("channel-group {0} mode {1}".format(group, mode)) - - superfluous_members = list(set(obj_in_have["members"]) - set(members)) - for m in superfluous_members: - commands.append("interface port-channel {0}".format(group)) - commands.append("exit") - commands.append("interface {0}".format(m)) - commands.append("no channel-group {0}".format(group)) - - else: - diff = get_diff(w, obj_in_have) - if diff and "mode" in diff: - mode = diff["mode"] - for i in members: - commands.append("interface {0}".format(i)) - if force: - commands.append( - "channel-group {0} force mode {1}".format(group, mode), - ) - else: - commands.append( - "channel-group {0} mode {1}".format(group, mode), - ) - - if purge: - for h in have: - obj_in_want = search_obj_in_list(h["group"], want) - if not obj_in_want: - commands.append("no interface port-channel {0}".format(h["group"])) - - return commands - - -def map_params_to_obj(module): - obj = [] - aggregate = module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = module.params[key] - - d = item.copy() - d["group"] = str(d["group"]) - d["min_links"] = str(d["min_links"]) - if d["members"]: - d["members"] = [normalize_interface(i) for i in d["members"]] - - obj.append(d) - else: - members = None - if module.params["members"]: - members = [normalize_interface(i) for i in module.params["members"]] - - obj.append( - { - "group": str(module.params["group"]), - "mode": module.params["mode"], - "min_links": str(module.params["min_links"]), - "members": members, - "state": module.params["state"], - }, - ) - - return obj - - -def parse_min_links(module, group): - min_links = None - - flags = ["| section interface.port-channel{0}".format(group)] - config = get_config(module, flags=flags) - match = re.search(r"lacp min-links (\S+)", config, re.M) - if match: - min_links = match.group(1) - - return min_links - - -def parse_mode(module, m): - mode = None - - flags = ["| section interface.{0}".format(m)] - config = get_config(module, flags=flags) - match = re.search(r"channel-group [0-9]+ (force )?mode (\S+)", config, re.M) - if match: - mode = match.group(2) - - return mode - - -def get_members(channel): - members = [] - if "TABLE_member" in channel.keys(): - interfaces = channel["TABLE_member"]["ROW_member"] - else: - return list() - - if isinstance(interfaces, dict): - members.append(normalize_interface(interfaces.get("port"))) - elif isinstance(interfaces, list): - for i in interfaces: - members.append(normalize_interface(i.get("port"))) - - return members - - -def parse_members(output, group): - channels = output["TABLE_channel"]["ROW_channel"] - - if isinstance(channels, list): - for channel in channels: - if channel["group"] == group: - members = get_members(channel) - elif isinstance(channels, dict): - if channels["group"] == group: - members = get_members(channels) - else: - return list() - - return members - - -def parse_channel_options(module, output, channel): - obj = {} - - group = channel["group"] - obj["group"] = str(group) - obj["min_links"] = parse_min_links(module, group) - members = parse_members(output, group) - obj["members"] = members - for m in members: - obj["mode"] = parse_mode(module, m) - - return obj - - -def map_config_to_obj(module): - objs = list() - output = run_commands(module, ["show port-channel summary | json"])[0] - if not output: - return list() - - try: - channels = output["TABLE_channel"]["ROW_channel"] - except (TypeError, KeyError): - return objs - - if channels: - if isinstance(channels, list): - for channel in channels: - obj = parse_channel_options(module, output, channel) - objs.append(obj) - - elif isinstance(channels, dict): - obj = parse_channel_options(module, output, channels) - objs.append(obj) - - return objs - - -def main(): - """main entry point for module execution""" - element_spec = dict( - group=dict(type="str"), - mode=dict( - required=False, - choices=["on", "active", "passive"], - default="on", - type="str", - ), - min_links=dict(required=False, default=None, type="int"), - members=dict(required=False, default=None, type="list", elements="str"), - force=dict(required=False, default=False, type="bool"), - state=dict(required=False, choices=["absent", "present"], default="present"), - ) - - aggregate_spec = deepcopy(element_spec) - aggregate_spec["group"] = dict(required=True) - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec), - purge=dict(default=False, type="bool"), - ) - - argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - - required_one_of = [["group", "aggregate"]] - mutually_exclusive = [["group", "aggregate"]] - module = AnsibleModule( - argument_spec=argument_spec, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - supports_check_mode=True, - ) - - warnings = list() - result = {"changed": False} - if warnings: - result["warnings"] = warnings - - want = map_params_to_obj(module) - have = map_config_to_obj(module) - - commands = map_obj_to_commands((want, have), module) - result["commands"] = commands - - if commands: - if not module.check_mode: - resp = load_config(module, commands, True) - if resp: - for item in resp: - if item: - if isinstance(item, dict): - err_str = item["clierror"] - else: - err_str = item - if "cannot add" in err_str.lower(): - module.fail_json(msg=err_str) - result["changed"] = True - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_lldp.py b/plugins/modules/nxos_lldp.py deleted file mode 100644 index 792004ebb..000000000 --- a/plugins/modules/nxos_lldp.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2017, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_lldp -author: Ganesh Nalawade (@ganeshrn) -short_description: (deprecated, removed after 2022-06-01) Manage LLDP - configuration on Cisco NXOS network devices. -description: -- This module provides declarative management of LLDP service on Cisco NXOS network - devices. -version_added: 1.0.0 -deprecated: - alternative: nxos_lldp_global - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -notes: -- Tested against NXOSv 7.0(3)I5(1). -- Unsupported for Cisco MDS -options: - state: - description: - - State of the LLDP configuration. If value is I(present) lldp will be enabled - else if it is I(absent) it will be disabled. - default: present - choices: - - present - - absent - - enabled - - disabled - type: str -extends_documentation_fragment: -- cisco.nxos.nxos - - -""" - -EXAMPLES = """ -- name: Enable LLDP service - cisco.nxos.nxos_lldp: - state: present - -- name: Disable LLDP service - cisco.nxos.nxos_lldp: - state: absent -""" - -RETURN = """ -commands: - description: The list of configuration mode commands to send to the device - returned: always, except for the platforms that use Netconf transport to manage the device. - type: list - sample: - - feature lldp -""" -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - nxos_argument_spec, -) - - -def has_lldp(module): - output = get_config(module, ["| section lldp"]) - is_lldp_enable = False - if output and "feature lldp" in output: - is_lldp_enable = True - - return is_lldp_enable - - -def main(): - """main entry point for module execution""" - argument_spec = dict( - state=dict( - default="present", - choices=["present", "absent", "enabled", "disabled"], - ), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - - result = {"changed": False} - - if warnings: - result["warnings"] = warnings - - HAS_LLDP = has_lldp(module) - - commands = [] - - if module.params["state"] == "absent" and HAS_LLDP: - commands.append("no feature lldp") - elif module.params["state"] == "present" and not HAS_LLDP: - commands.append("feature lldp") - - result["commands"] = commands - - if commands: - # On N35 A8 images, some features return a yes/no prompt - # on enablement or disablement. Bypass using terminal dont-ask - commands.insert(0, "terminal dont-ask") - if not module.check_mode: - load_config(module, commands) - - result["changed"] = True - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_ospf.py b/plugins/modules/nxos_ospf.py deleted file mode 100644 index 83f608e8c..000000000 --- a/plugins/modules/nxos_ospf.py +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_ospf -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manages configuration - of an ospf instance. -description: -- Manages configuration of an ospf instance. -notes: -- Unsupported for Cisco MDS -version_added: 1.0.0 -author: Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_ospfv2 and nxos_ospfv3 - why: Updated modules released with more functionality. - removed_at_date: '2022-06-01' -options: - ospf: - description: - - Name of the ospf instance. - required: true - type: str - state: - description: - - Determines whether the config should be present or not on the device. - required: false - default: present - choices: - - present - - absent - type: str - -""" - -EXAMPLES = """ -- cisco.nxos.nxos_ospf: - ospf: 1 - state: present -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["router ospf 1"] -""" - -import re - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - nxos_argument_spec, -) - - -PARAM_TO_COMMAND_KEYMAP = {"ospf": "router ospf"} - - -def get_value(config, module): - splitted_config = config.splitlines() - value_list = [] - REGEX = r"^router ospf\s(?P\S+).*" - for line in splitted_config: - value = "" - if "router ospf" in line: - try: - match_ospf = re.match(REGEX, line, re.DOTALL) - ospf_group = match_ospf.groupdict() - value = ospf_group["ospf"] - except AttributeError: - value = "" - if value: - value_list.append(value) - - return value_list - - -def get_existing(module): - existing = {} - config = str(get_config(module)) - - value = get_value(config, module) - if value: - existing["ospf"] = value - return existing - - -def state_present(module, proposed, candidate): - commands = ["router ospf {0}".format(proposed["ospf"])] - candidate.add(commands, parents=[]) - - -def state_absent(module, proposed, candidate): - commands = ["no router ospf {0}".format(proposed["ospf"])] - candidate.add(commands, parents=[]) - - -def main(): - argument_spec = dict( - ospf=dict(required=True, type="str"), - state=dict(choices=["present", "absent"], default="present", required=False), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - result = dict(changed=False, warnings=warnings) - - state = module.params["state"] - ospf = str(module.params["ospf"]) - - existing = get_existing(module) - proposed = dict(ospf=ospf) - - if not existing: - existing_list = [] - else: - existing_list = existing["ospf"] - - candidate = CustomNetworkConfig(indent=3) - if state == "present" and ospf not in existing_list: - state_present(module, proposed, candidate) - if state == "absent" and ospf in existing_list: - state_absent(module, proposed, candidate) - - if candidate: - candidate = candidate.items_text() - load_config(module, candidate) - result["changed"] = True - result["commands"] = candidate - - else: - result["commands"] = [] - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_ospf_vrf.py b/plugins/modules/nxos_ospf_vrf.py deleted file mode 100644 index cecd9adf3..000000000 --- a/plugins/modules/nxos_ospf_vrf.py +++ /dev/null @@ -1,469 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_ospf_vrf -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-10-01)Manages a VRF for an OSPF router. -description: -- Manages a VRF for an OSPF router. -version_added: 1.0.0 -author: Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_ospfv2 and nxos_ospfv3 - why: Updated modules released with more functionality. - removed_at_date: '2022-10-01' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- Value I(default) restores params default value, if any. Otherwise it removes the - existing param configuration. -options: - vrf: - description: - - Name of the resource instance. Valid value is a string. The name 'default' is - a valid VRF representing the global OSPF. - default: default - type: str - ospf: - description: - - Name of the OSPF instance. - required: true - type: str - router_id: - description: - - Router Identifier (ID) of the OSPF router VRF instance. - type: str - default_metric: - description: - - Specify the default Metric value. Valid values are an integer or the keyword - 'default'. - type: str - log_adjacency: - description: - - Controls the level of log messages generated whenever a neighbor changes state. - Valid values are 'log', 'detail', and 'default'. - choices: - - log - - detail - - default - type: str - timer_throttle_lsa_start: - description: - - Specify the start interval for rate-limiting Link-State Advertisement (LSA) - generation. Valid values are an integer, in milliseconds, or the keyword 'default'. - type: str - timer_throttle_lsa_hold: - description: - - Specify the hold interval for rate-limiting Link-State Advertisement (LSA) generation. - Valid values are an integer, in milliseconds, or the keyword 'default'. - type: str - timer_throttle_lsa_max: - description: - - Specify the max interval for rate-limiting Link-State Advertisement (LSA) generation. - Valid values are an integer, in milliseconds, or the keyword 'default'. - type: str - timer_throttle_spf_start: - description: - - Specify initial Shortest Path First (SPF) schedule delay. Valid values are an - integer, in milliseconds, or the keyword 'default'. - type: str - timer_throttle_spf_hold: - description: - - Specify minimum hold time between Shortest Path First (SPF) calculations. Valid - values are an integer, in milliseconds, or the keyword 'default'. - type: str - timer_throttle_spf_max: - description: - - Specify the maximum wait time between Shortest Path First (SPF) calculations. - Valid values are an integer, in milliseconds, or the keyword 'default'. - type: str - auto_cost: - description: - - Specifies the reference bandwidth used to assign OSPF cost. Valid values are - an integer, in Mbps, or the keyword 'default'. - type: str - bfd: - description: - - Enables BFD on all OSPF interfaces. - - "Dependency: ''feature bfd''" - type: str - choices: - - enable - - disable - passive_interface: - description: - - Setting to C(yes) will suppress routing update on interface. - type: bool - state: - description: - - State of ospf vrf configuration. - default: present - choices: - - present - - absent - type: str -""" - -EXAMPLES = """ -- cisco.nxos.nxos_ospf_vrf: - ospf: 1 - timer_throttle_spf_start: 50 - timer_throttle_spf_hold: 1000 - timer_throttle_spf_max: 2000 - timer_throttle_lsa_start: 60 - timer_throttle_lsa_hold: 1100 - timer_throttle_lsa_max: 3000 - vrf: test - bfd: enable - state: present -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: - - router ospf 1 - - vrf test - - bfd - - timers throttle lsa 60 1100 3000 -""" - -import re - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - nxos_argument_spec, -) - - -BOOL_PARAMS = ["passive_interface"] -PARAM_TO_COMMAND_KEYMAP = { - "vrf": "vrf", - "router_id": "router-id", - "default_metric": "default-metric", - "log_adjacency": "log-adjacency-changes", - "timer_throttle_lsa_start": "timers throttle lsa", - "timer_throttle_lsa_max": "timers throttle lsa", - "timer_throttle_lsa_hold": "timers throttle lsa", - "timer_throttle_spf_max": "timers throttle spf", - "timer_throttle_spf_start": "timers throttle spf", - "timer_throttle_spf_hold": "timers throttle spf", - "auto_cost": "auto-cost reference-bandwidth", - "bfd": "bfd", - "passive_interface": "passive-interface default", -} -PARAM_TO_DEFAULT_KEYMAP = { - "timer_throttle_lsa_start": "0", - "timer_throttle_lsa_max": "5000", - "timer_throttle_lsa_hold": "5000", - "timer_throttle_spf_start": "200", - "timer_throttle_spf_max": "5000", - "timer_throttle_spf_hold": "1000", - "auto_cost": "40000", - "bfd": "disable", - "default_metric": "", - "passive_interface": False, - "router_id": "", - "log_adjacency": "", -} - - -def get_existing(module, args): - existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - parents = ["router ospf {0}".format(module.params["ospf"])] - - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - config = netcfg.get_section(parents) - for arg in args: - if arg not in ["ospf", "vrf"]: - existing[arg] = PARAM_TO_DEFAULT_KEYMAP.get(arg) - - if config: - if module.params["vrf"] == "default": - splitted_config = config.splitlines() - vrf_index = False - for index in range(0, len(splitted_config) - 1): - if "vrf" in splitted_config[index].strip(): - vrf_index = index - break - if vrf_index: - config = "\n".join(splitted_config[0:vrf_index]) - - splitted_config = config.splitlines() - for line in splitted_config: - if "passive" in line: - existing["passive_interface"] = True - elif "router-id" in line: - existing["router_id"] = re.search(r"router-id (\S+)", line).group(1) - elif "metric" in line: - existing["default_metric"] = re.search(r"default-metric (\S+)", line).group(1) - elif "adjacency" in line: - log = re.search(r"log-adjacency-changes(?: (\S+))?", line).group(1) - if log: - existing["log_adjacency"] = log - else: - existing["log_adjacency"] = "log" - elif "auto" in line: - cost = re.search(r"auto-cost reference-bandwidth (\d+) (\S+)", line).group(1) - if "Gbps" in line: - cost = int(cost) * 1000 - existing["auto_cost"] = str(cost) - elif "bfd" in line: - existing["bfd"] = "enable" - elif "timers throttle lsa" in line: - tmp = re.search(r"timers throttle lsa (\S+) (\S+) (\S+)", line) - existing["timer_throttle_lsa_start"] = tmp.group(1) - existing["timer_throttle_lsa_hold"] = tmp.group(2) - existing["timer_throttle_lsa_max"] = tmp.group(3) - elif "timers throttle spf" in line: - tmp = re.search(r"timers throttle spf (\S+) (\S+) (\S+)", line) - existing["timer_throttle_spf_start"] = tmp.group(1) - existing["timer_throttle_spf_hold"] = tmp.group(2) - existing["timer_throttle_spf_max"] = tmp.group(3) - existing["vrf"] = module.params["vrf"] - existing["ospf"] = module.params["ospf"] - - return existing - - -def apply_key_map(key_map, table): - new_dict = {} - for key in table: - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = table.get(key) - return new_dict - - -def get_timer_prd(key, proposed): - if proposed.get(key): - return proposed.get(key) - else: - return PARAM_TO_DEFAULT_KEYMAP.get(key) - - -def state_present(module, existing, proposed, candidate): - commands = list() - proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - - for key, value in proposed_commands.items(): - if key == "vrf": - continue - if value is True: - commands.append(key) - - elif value is False: - if key == "passive-interface default": - if existing_commands.get(key): - commands.append("no {0}".format(key)) - else: - commands.append("no {0}".format(key)) - - elif value == "default" or value == "": - if key == "log-adjacency-changes": - commands.append("no {0}".format(key)) - elif existing_commands.get(key): - existing_value = existing_commands.get(key) - commands.append("no {0} {1}".format(key, existing_value)) - else: - if key == "timers throttle lsa": - command = "{0} {1} {2} {3}".format( - key, - get_timer_prd("timer_throttle_lsa_start", proposed), - get_timer_prd("timer_throttle_lsa_hold", proposed), - get_timer_prd("timer_throttle_lsa_max", proposed), - ) - elif key == "timers throttle spf": - command = "{0} {1} {2} {3}".format( - key, - get_timer_prd("timer_throttle_spf_start", proposed), - get_timer_prd("timer_throttle_spf_hold", proposed), - get_timer_prd("timer_throttle_spf_max", proposed), - ) - elif key == "log-adjacency-changes": - if value == "log": - command = key - elif value == "detail": - command = "{0} {1}".format(key, value) - elif key == "auto-cost reference-bandwidth": - if len(value) < 5: - command = "{0} {1} Mbps".format(key, value) - else: - value = str(int(value) // 1000) - command = "{0} {1} Gbps".format(key, value) - elif key == "bfd": - command = "no bfd" if value == "disable" else "bfd" - else: - command = "{0} {1}".format(key, value.lower()) - - if command not in commands: - commands.append(command) - - if commands: - parents = ["router ospf {0}".format(module.params["ospf"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - candidate.add(commands, parents=parents) - - -def state_absent(module, existing, proposed, candidate): - commands = [] - parents = ["router ospf {0}".format(module.params["ospf"])] - if module.params["vrf"] == "default": - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in existing_commands.items(): - if value and key != "vrf": - command = None - if key == "passive-interface default": - command = "no {0}".format(key) - elif key == "timers throttle lsa": - if ( - existing["timer_throttle_lsa_start"] - != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_lsa_start") - or existing["timer_throttle_lsa_hold"] - != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_lsa_hold") - or existing["timer_throttle_lsa_max"] - != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_lsa_max") - ): - command = "no {0} {1} {2} {3}".format( - key, - existing["timer_throttle_lsa_start"], - existing["timer_throttle_lsa_hold"], - existing["timer_throttle_lsa_max"], - ) - elif key == "timers throttle spf": - if ( - existing["timer_throttle_spf_start"] - != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_spf_start") - or existing["timer_throttle_spf_hold"] - != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_spf_hold") - or existing["timer_throttle_spf_max"] - != PARAM_TO_DEFAULT_KEYMAP.get("timer_throttle_spf_max") - ): - command = "no {0} {1} {2} {3}".format( - key, - existing["timer_throttle_spf_start"], - existing["timer_throttle_spf_hold"], - existing["timer_throttle_spf_max"], - ) - elif key == "log-adjacency-changes": - command = "no {0}".format(key) - elif key == "auto-cost reference-bandwidth": - if value != PARAM_TO_DEFAULT_KEYMAP.get("auto_cost"): - command = "no {0}".format(key) - else: - command = None - elif key == "bfd": - if value == "enable": - command = "no bfd" - else: - existing_value = existing_commands.get(key) - command = "no {0} {1}".format(key, existing_value) - - if command: - if command not in commands: - commands.append(command) - else: - if existing.get("vrf") and existing.get("vrf") == module.params["vrf"]: - commands = ["no vrf {0}".format(module.params["vrf"])] - - if commands: - candidate.add(commands, parents=parents) - - -def main(): - argument_spec = dict( - vrf=dict(required=False, type="str", default="default"), - ospf=dict(required=True, type="str"), - router_id=dict(required=False, type="str"), - default_metric=dict(required=False, type="str"), - log_adjacency=dict(required=False, type="str", choices=["log", "detail", "default"]), - timer_throttle_lsa_start=dict(required=False, type="str"), - timer_throttle_lsa_hold=dict(required=False, type="str"), - timer_throttle_lsa_max=dict(required=False, type="str"), - timer_throttle_spf_start=dict(required=False, type="str"), - timer_throttle_spf_hold=dict(required=False, type="str"), - timer_throttle_spf_max=dict(required=False, type="str"), - auto_cost=dict(required=False, type="str"), - bfd=dict(required=False, type="str", choices=["enable", "disable"]), - passive_interface=dict(required=False, type="bool"), - state=dict(choices=["present", "absent"], default="present", required=False), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - result = dict(changed=False, commands=[], warnings=warnings) - - state = module.params["state"] - args = PARAM_TO_COMMAND_KEYMAP.keys() - existing = get_existing(module, args) - proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) - - proposed = {} - for key, value in proposed_args.items(): - if key != "interface": - if str(value).lower() == "true": - value = True - elif str(value).lower() == "false": - value = False - elif str(value).lower() == "default": - value = PARAM_TO_DEFAULT_KEYMAP.get(key) - if value is None: - value = "default" - if existing.get(key) != value: - proposed[key] = value - - candidate = CustomNetworkConfig(indent=3) - if state == "present": - state_present(module, existing, proposed, candidate) - if state == "absent" and existing: - state_absent(module, existing, proposed, candidate) - - if candidate: - candidate = candidate.items_text() - result["commands"] = candidate - if not module.check_mode: - load_config(module, candidate) - result["changed"] = True - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_smu.py b/plugins/modules/nxos_smu.py deleted file mode 100644 index fba7ff585..000000000 --- a/plugins/modules/nxos_smu.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_smu -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-10-01) Perform SMUs on Cisco NX-OS devices. -description: -- Perform software maintenance upgrades (SMUs) on Cisco NX-OS devices. -version_added: 1.0.0 -author: Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_rpm - why: Updated modules released with more functionality. - removed_at_date: '2022-10-01' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- The module can only activate and commit a package, not remove or deactivate it. -- Use C(transport=nxapi) to avoid connection timeout -options: - pkg: - description: - - Name of the remote package. - required: true - type: str - file_system: - description: - - The remote file system of the device. If omitted, devices that support a file_system - parameter will use their default values. - default: 'bootflash:' - type: str -""" - -EXAMPLES = """ -- cisco.nxos.nxos_smu: - pkg: nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["install add bootflash:nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm", - "install activate bootflash:nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm force", - "install commit bootflash:nxos.CSCuz65185-n9k_EOR-1.0.0-7.0.3.I2.2d.lib32_n9000.rpm"] -""" - - -import time - -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - nxos_argument_spec, - run_commands, -) - - -def execute_show_command(command, module): - cmds = [{"command": command, "output": "text"}] - - return run_commands(module, cmds) - - -def remote_file_exists(module, dst, file_system="bootflash:"): - command = "dir {0}/{1}".format(file_system, dst) - body = execute_show_command(command, module) - if "No such file" in body[0]: - return False - return True - - -def apply_patch(module, commands): - for command in commands: - load_config(module, [command]) - time.sleep(5) - - -def get_commands(module, pkg, file_system): - commands = [] - splitted_pkg = pkg.split(".") - fixed_pkg = ".".join(splitted_pkg[0:-1]) - - command = "show install inactive" - inactive_body = execute_show_command(command, module) - - command = "show install active" - active_body = execute_show_command(command, module) - - if fixed_pkg not in inactive_body[0] and fixed_pkg not in active_body[0]: - commands.append("install add {0}{1}".format(file_system, pkg)) - - if fixed_pkg not in active_body[0]: - commands.append("install activate {0} force".format(pkg)) - command = "show install committed" - install_body = execute_show_command(command, module) - if fixed_pkg not in install_body[0]: - commands.append("install commit {0}".format(pkg)) - - return commands - - -def main(): - argument_spec = dict( - pkg=dict(required=True), - file_system=dict(required=False, default="bootflash:"), - ) - - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - results = {"changed": False, "commands": [], "warnings": warnings} - - pkg = module.params["pkg"] - file_system = module.params["file_system"] - remote_exists = remote_file_exists(module, pkg, file_system=file_system) - - if not remote_exists: - module.fail_json(msg="The requested package doesn't exist on the device") - - commands = get_commands(module, pkg, file_system) - if commands: - results["changed"] = True - if not module.check_mode: - apply_patch(module, commands) - if "configure" in commands: - commands.pop(0) - results["commands"] = commands - - module.exit_json(**results) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_static_route.py b/plugins/modules/nxos_static_route.py deleted file mode 100644 index 50e16b45b..000000000 --- a/plugins/modules/nxos_static_route.py +++ /dev/null @@ -1,373 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_static_route -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manages static - route configuration -description: -- Manages static route configuration -version_added: 1.0.0 -deprecated: - alternative: nxos_static_routes - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -author: Gabriele Gerbino (@GGabriele) -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- If no vrf is supplied, vrf is set to default. -- If C(state=absent), the route will be removed, regardless of the non-required parameters. -options: - prefix: - description: - - Destination prefix of static route. - aliases: - - address - type: str - next_hop: - description: - - Next hop address or interface of static route. If interface, it must be the - fully-qualified interface name. - type: str - vrf: - description: - - VRF for static route. - default: default - type: str - tag: - description: - - Route tag value (numeric) or keyword 'default'. - type: str - route_name: - description: - - Name of the route or keyword 'default'. Used with the name parameter on the - CLI. - type: str - pref: - description: - - Preference or administrative difference of route (range 1-255) or keyword 'default'. - aliases: - - admin_distance - type: str - aggregate: - description: List of static route definitions - type: list - elements: dict - suboptions: - prefix: - description: - - Destination prefix of static route. - required: True - type: str - next_hop: - description: - - Next hop address or interface of static route. If interface, it must be the - fully-qualified interface name. - required: true - type: str - vrf: - description: - - VRF for static route. - type: str - tag: - description: - - Route tag value (numeric) or keyword 'default'. - type: str - route_name: - description: - - Name of the route or keyword 'default'. Used with the name parameter on the - CLI. - type: str - pref: - description: - - Preference or administrative difference of route (range 1-255) or keyword 'default'. - aliases: - - admin_distance - type: str - track: - description: - - Track value (range 1 - 512). Track must already be configured on the device - before adding the route. - type: int - state: - description: - - Manage the state of the resource. - choices: - - present - - absent - type: str - track: - description: - - Track value (range 1 - 512). Track must already be configured on the device - before adding the route. - type: int - state: - description: - - Manage the state of the resource. - choices: - - present - - absent - default: present - type: str -""" - -EXAMPLES = """ -- cisco.nxos.nxos_static_route: - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: testing - pref: 100 -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["ip route 192.168.20.0/24 192.0.2.3 name testing 100"] -""" -import re - -from copy import deepcopy - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, - nxos_argument_spec, - run_commands, -) - - -def reconcile_candidate(module, candidate, prefix, want): - state, vrf = want["state"], want["vrf"] - if vrf == "default": - parents = [] - flags = " | include '^ip route'" - else: - parents = ["vrf context {0}".format(vrf)] - flags = " | section '{0}' | include '^ ip route'".format(parents[0]) - - # Find existing routes in this vrf/default - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=[flags])) - routes = str(netcfg).split("\n") - # strip whitespace from route strings - routes = [i.strip() for i in routes] - - prefix_and_nh = "ip route {0} {1}".format(prefix, want["next_hop"]) - existing = [i for i in routes if i.startswith(prefix_and_nh)] - proposed = set_route_command(prefix, want, module) - - commands = [] - if state == "absent" and existing: - commands = ["no " + existing[0]] - elif state == "present" and proposed not in routes: - if existing: - commands = ["no " + existing[0]] - commands.append(proposed) - - if commands: - candidate.add(commands, parents=parents) - - -def get_configured_track(module, ctrack): - check_track = "{0}".format(ctrack) - track_exists = False - command = "show track" - try: - body = run_commands(module, {"command": command, "output": "text"}) - match = re.findall(r"Track\s+(\d+)", body[0]) - except IndexError: - return None - if check_track in match: - track_exists = True - return track_exists - - -def set_route_command(prefix, w, module): - route_cmd = "ip route {0} {1}".format(prefix, w["next_hop"]) - - if w["track"]: - if w["track"] in range(1, 512): - if get_configured_track(module, w["track"]): - route_cmd += " track {0}".format(w["track"]) - else: - module.fail_json(msg="Track {0} not configured on device".format(w["track"])) - else: - module.fail_json(msg="Invalid track number, valid range is 1-512.") - if w["route_name"] and w["route_name"] != "default": - route_cmd += " name {0}".format(w["route_name"]) - if w["tag"]: - if w["tag"] != "default" and w["tag"] != "0": - route_cmd += " tag {0}".format(w["tag"]) - if w["pref"] and w["pref"] != "default": - route_cmd += " {0}".format(w["pref"]) - - return route_cmd - - -def get_dotted_mask(mask): - bits = 0 - for i in range(32 - mask, 32): - bits |= 1 << i - mask = "%d.%d.%d.%d" % ( - (bits & 0xFF000000) >> 24, - (bits & 0xFF0000) >> 16, - (bits & 0xFF00) >> 8, - (bits & 0xFF), - ) - return mask - - -def get_network_start(address, netmask): - address = address.split(".") - netmask = netmask.split(".") - return [str(int(address[x]) & int(netmask[x])) for x in range(0, 4)] - - -def network_from_string(address, mask, module): - octects = address.split(".") - - if len(octects) > 4: - module.fail_json(msg="Incorrect address format.", address=address) - - for octect in octects: - try: - if int(octect) < 0 or int(octect) > 255: - module.fail_json(msg="Address may contain invalid values.", address=address) - except ValueError: - module.fail_json(msg="Address may contain non-integer values.", address=address) - - try: - if int(mask) < 0 or int(mask) > 32: - module.fail_json(msg="Incorrect mask value.", mask=mask) - except ValueError: - module.fail_json(msg="Mask may contain non-integer values.", mask=mask) - - netmask = get_dotted_mask(int(mask)) - return ".".join(get_network_start(address, netmask)) - - -def normalize_prefix(module, prefix): - splitted_prefix = prefix.split("/") - - address = splitted_prefix[0] - if len(splitted_prefix) > 2: - module.fail_json(msg="Incorrect address format.", address=address) - elif len(splitted_prefix) == 2: - mask = splitted_prefix[1] - network = network_from_string(address, mask, module) - - normalized_prefix = str(network) + "/" + str(mask) - else: - normalized_prefix = prefix + "/" + str(32) - - return normalized_prefix - - -def map_params_to_obj(module): - obj = [] - aggregate = module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = module.params[key] - - d = item.copy() - obj.append(d) - else: - obj.append( - { - "prefix": module.params["prefix"], - "next_hop": module.params["next_hop"], - "vrf": module.params["vrf"], - "tag": module.params["tag"], - "route_name": module.params["route_name"], - "pref": module.params["pref"], - "state": module.params["state"], - "track": module.params["track"], - }, - ) - - return obj - - -def main(): - element_spec = dict( - prefix=dict(type="str", aliases=["address"]), - next_hop=dict(type="str"), - vrf=dict(type="str", default="default"), - tag=dict(type="str"), - route_name=dict(type="str"), - pref=dict(type="str", aliases=["admin_distance"]), - state=dict(choices=["absent", "present"], default="present"), - track=dict(type="int"), - ) - - aggregate_spec = deepcopy(element_spec) - aggregate_spec["prefix"] = dict(required=True) - aggregate_spec["next_hop"] = dict(required=True) - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) - - argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - result = {"changed": False, "commands": []} - if warnings: - result["warnings"] = warnings - - want = map_params_to_obj(module) - for w in want: - prefix = normalize_prefix(module, w["prefix"]) - candidate = CustomNetworkConfig(indent=3) - reconcile_candidate(module, candidate, prefix, w) - - if not module.check_mode and candidate: - candidate = candidate.items_text() - load_config(module, candidate) - result["commands"].extend(candidate) - result["changed"] = True - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_vlan.py b/plugins/modules/nxos_vlan.py deleted file mode 100644 index a58f5f57d..000000000 --- a/plugins/modules/nxos_vlan.py +++ /dev/null @@ -1,817 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_vlan -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2022-06-01) Manages VLAN - resources and attributes. -description: -- Manages VLAN configurations on NX-OS switches. -version_added: 1.0.0 -deprecated: - alternative: nxos_vlans - why: Updated modules released with more functionality - removed_at_date: '2022-06-01' -author: Jason Edelman (@jedelman8) -options: - vlan_id: - description: - - Single VLAN ID. - type: int - vlan_range: - description: - - Range of VLANs such as 2-10 or 2,5,10-15, etc. - type: str - name: - description: - - Name of VLAN or keyword 'default'. - type: str - interfaces: - description: - - List of interfaces that should be associated to the VLAN or keyword 'default'. - type: list - elements: str - associated_interfaces: - description: - - This is a intent option and checks the operational state of the for given vlan - C(name) for associated interfaces. If the value in the C(associated_interfaces) - does not match with the operational state of vlan interfaces on device it will - result in failure. - type: list - elements: str - vlan_state: - description: - - Manage the vlan operational state of the VLAN - default: active - choices: - - active - - suspend - type: str - admin_state: - description: - - Manage the VLAN administrative state of the VLAN equivalent to shut/no shut - in VLAN config mode. - default: up - choices: - - up - - down - type: str - mapped_vni: - description: - - The Virtual Network Identifier (VNI) ID that is mapped to the VLAN. Valid values - are integer and keyword 'default'. Range 4096-16773119. - type: str - aggregate: - description: List of VLANs definitions. - type: list - elements: dict - suboptions: - vlan_id: - description: - - Single VLAN ID. - required: True - type: int - vlan_range: - description: - - Range of VLANs such as 2-10 or 2,5,10-15, etc. - type: str - name: - description: - - Name of VLAN or keyword 'default'. - type: str - interfaces: - description: - - List of interfaces that should be associated to the VLAN or keyword 'default'. - type: list - elements: str - associated_interfaces: - description: - - This is a intent option and checks the operational state of the for given vlan - C(name) for associated interfaces. If the value in the C(associated_interfaces) - does not match with the operational state of vlan interfaces on device it will - result in failure. - type: list - elements: str - vlan_state: - description: - - Manage the vlan operational state of the VLAN - choices: - - active - - suspend - type: str - admin_state: - description: - - Manage the VLAN administrative state of the VLAN equivalent to shut/no shut - in VLAN config mode. - choices: - - up - - down - type: str - mapped_vni: - description: - - The Virtual Network Identifier (VNI) ID that is mapped to the VLAN. Valid values - are integer and keyword 'default'. Range 4096-16773119. - type: str - mode: - description: - - Set VLAN mode to classical ethernet or fabricpath. This is a valid option for - Nexus 5000 and 7000 series. - choices: - - ce - - fabricpath - type: str - delay: - description: - - Time in seconds to wait before checking for the operational state on remote - device. This wait is applicable for operational state arguments. - type: int - state: - description: - - Manage the state of the resource. - choices: - - present - - absent - type: str - state: - description: - - Manage the state of the resource. - default: present - choices: - - present - - absent - type: str - mode: - description: - - Set VLAN mode to classical ethernet or fabricpath. This is a valid option for - Nexus 5000 and 7000 series. - choices: - - ce - - fabricpath - default: ce - type: str - purge: - description: - - Purge VLANs not defined in the I(aggregate) parameter. This parameter can be - used without aggregate as well. - - Removal of Vlan 1 is not allowed and will be ignored by purge. - type: bool - default: no - delay: - description: - - Time in seconds to wait before checking for the operational state on remote - device. This wait is applicable for operational state arguments. - default: 10 - type: int - - -""" - -EXAMPLES = """ -- name: Ensure a range of VLANs are not present on the switch - cisco.nxos.nxos_vlan: - vlan_range: 2-10,20,50,55-60,100-150 - state: absent - -- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state - cisco.nxos.nxos_vlan: - vlan_id: 50 - admin_state: down - name: WEB - -- name: Ensure VLAN is NOT on the device - cisco.nxos.nxos_vlan: - vlan_id: 50 - state: absent - -- name: Add interfaces to VLAN and check intent (config + intent) - cisco.nxos.nxos_vlan: - vlan_id: 100 - interfaces: - - Ethernet2/1 - - Ethernet2/5 - associated_interfaces: - - Ethernet2/1 - - Ethernet2/5 - -- name: Check interfaces assigned to VLAN - cisco.nxos.nxos_vlan: - vlan_id: 100 - associated_interfaces: - - Ethernet2/1 - - Ethernet2/5 - -- name: Create aggregate of vlans - cisco.nxos.nxos_vlan: - aggregate: - - {vlan_id: 4000, mode: ce} - - {vlan_id: 4001, name: vlan-4001} - -- name: purge vlans - removes all other vlans except the ones mentioned in aggregate) - cisco.nxos.nxos_vlan: - aggregate: - - vlan_id: 1 - - vlan_id: 4001 - purge: yes - -""" - -RETURN = """ -commands: - description: Set of command strings to send to the remote device - returned: always - type: list - sample: ["vlan 20", "vlan 55", "vn-segment 5000"] -""" - -import re -import time - -from copy import deepcopy - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_capabilities, - get_config, - load_config, - normalize_interface, - nxos_argument_spec, - run_commands, -) - - -def search_obj_in_list(vlan_id, lst): - for o in lst: - if o["vlan_id"] == vlan_id: - return o - - -def get_diff(w, obj): - c = deepcopy(w) - entries = ("interfaces", "associated_interfaces", "delay", "vlan_range") - for key in entries: - if key in c: - del c[key] - - o = deepcopy(obj) - del o["interfaces"] - if o["vlan_id"] == w["vlan_id"]: - diff_dict = dict(set(c.items()) - set(o.items())) - return diff_dict - - -def is_default_name(obj, vlan_id): - cname = obj["name"] - if "VLAN" in cname: - vid = int(cname[4:]) - if vid == int(vlan_id): - return True - - return False - - -def map_obj_to_commands(updates, module): - commands = list() - purge = module.params["purge"] - want, have = updates - info = get_capabilities(module).get("device_info") - os_platform = info.get("network_os_platform") - - for w in want: - vlan_id = w["vlan_id"] - name = w["name"] - interfaces = w.get("interfaces") or [] - mapped_vni = w["mapped_vni"] - mode = w["mode"] - vlan_state = w["vlan_state"] - admin_state = w["admin_state"] - state = w["state"] - del w["state"] - - obj_in_have = search_obj_in_list(vlan_id, have) or {} - if not re.match("N[567]", os_platform) or (not obj_in_have.get("mode") and mode == "ce"): - mode = w["mode"] = None - - if state == "absent": - if obj_in_have: - commands.append("no vlan {0}".format(vlan_id)) - - elif state == "present": - if not obj_in_have: - commands.append("vlan {0}".format(vlan_id)) - - if name and name != "default": - commands.append("name {0}".format(name)) - if mode: - commands.append("mode {0}".format(mode)) - if vlan_state: - commands.append("state {0}".format(vlan_state)) - if mapped_vni != "None" and mapped_vni != "default": - commands.append("vn-segment {0}".format(mapped_vni)) - if admin_state == "up": - commands.append("no shutdown") - if admin_state == "down": - commands.append("shutdown") - commands.append("exit") - - if interfaces and interfaces[0] != "default": - for i in interfaces: - commands.append("interface {0}".format(i)) - commands.append("switchport") - commands.append("switchport mode access") - commands.append("switchport access vlan {0}".format(vlan_id)) - - else: - diff = get_diff(w, obj_in_have) - if diff: - commands.append("vlan {0}".format(vlan_id)) - for key, value in diff.items(): - if key == "name": - if name != "default": - if name is not None: - commands.append("name {0}".format(value)) - else: - if not is_default_name(obj_in_have, vlan_id): - commands.append("no name") - if key == "vlan_state" and value: - commands.append("state {0}".format(value)) - if key == "mapped_vni": - if value == "default": - if obj_in_have["mapped_vni"] != "None": - commands.append("no vn-segment") - elif value != "None": - commands.append("vn-segment {0}".format(value)) - if key == "admin_state": - if value == "up": - commands.append("no shutdown") - elif value == "down": - commands.append("shutdown") - if key == "mode" and value: - commands.append("mode {0}".format(value)) - if len(commands) > 1: - commands.append("exit") - else: - del commands[:] - - if interfaces and interfaces[0] != "default": - if not obj_in_have["interfaces"]: - for i in interfaces: - commands.append("vlan {0}".format(vlan_id)) - commands.append("exit") - commands.append("interface {0}".format(i)) - commands.append("switchport") - commands.append("switchport mode access") - commands.append("switchport access vlan {0}".format(vlan_id)) - - elif set(interfaces) != set(obj_in_have["interfaces"]): - missing_interfaces = list(set(interfaces) - set(obj_in_have["interfaces"])) - for i in missing_interfaces: - commands.append("vlan {0}".format(vlan_id)) - commands.append("exit") - commands.append("interface {0}".format(i)) - commands.append("switchport") - commands.append("switchport mode access") - commands.append("switchport access vlan {0}".format(vlan_id)) - - superfluous_interfaces = list( - set(obj_in_have["interfaces"]) - set(interfaces), - ) - for i in superfluous_interfaces: - commands.append("vlan {0}".format(vlan_id)) - commands.append("exit") - commands.append("interface {0}".format(i)) - commands.append("switchport") - commands.append("switchport mode access") - commands.append("no switchport access vlan {0}".format(vlan_id)) - - elif interfaces and interfaces[0] == "default": - if obj_in_have["interfaces"]: - for i in obj_in_have["interfaces"]: - commands.append("vlan {0}".format(vlan_id)) - commands.append("exit") - commands.append("interface {0}".format(i)) - commands.append("switchport") - commands.append("switchport mode access") - commands.append("no switchport access vlan {0}".format(vlan_id)) - - if purge: - for h in have: - if h["vlan_id"] == "1": - module.warn("Deletion of vlan 1 is not allowed; purge will ignore vlan 1") - continue - obj_in_want = search_obj_in_list(h["vlan_id"], want) - if not obj_in_want: - commands.append("no vlan {0}".format(h["vlan_id"])) - - return commands - - -def want_vlan_list(module): - result = [] - vlan_range = module.params["vlan_range"] - for part in vlan_range.split(","): - if part == "none": - break - if "-" in part: - start, end = part.split("-") - start, end = int(start), int(end) - result.extend([str(i) for i in range(start, end + 1)]) - else: - result.append(part) - return result - - -def have_vlan_list(have): - result = [] - if have: - for h in have: - result.append(str(h.get("vlan_id"))) - return result - - -def vlan_range_commands(module, have): - commands = list() - proposed_vlans_list = want_vlan_list(module) - existing_vlans_list = have_vlan_list(have) - - if module.params["state"] == "absent": - vlans = set(proposed_vlans_list).intersection(existing_vlans_list) - for vlan in vlans: - commands.append("no vlan {0}".format(vlan)) - - elif module.params["state"] == "present": - vlans = set(proposed_vlans_list).difference(existing_vlans_list) - for vlan in vlans: - commands.append("vlan {0}".format(vlan)) - - return commands - - -def normalize(interfaces): - normalized = None - if interfaces: - normalized = [normalize_interface(i) for i in interfaces] - return normalized - - -def map_params_to_obj(module): - obj = [] - if module.params["vlan_range"]: - return [] - - aggregate = module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = module.params[key] - - d = item.copy() - d["vlan_id"] = str(d["vlan_id"]) - d["mapped_vni"] = str(d["mapped_vni"]) - d["interfaces"] = normalize(d["interfaces"]) - d["associated_interfaces"] = normalize(d["associated_interfaces"]) - - obj.append(d) - else: - interfaces = normalize(module.params["interfaces"]) - associated_interfaces = normalize(module.params["associated_interfaces"]) - - obj.append( - { - "vlan_id": str(module.params["vlan_id"]), - "name": module.params["name"], - "interfaces": interfaces, - "vlan_state": module.params["vlan_state"], - "mapped_vni": str(module.params["mapped_vni"]), - "state": module.params["state"], - "admin_state": module.params["admin_state"], - "mode": module.params["mode"], - "associated_interfaces": associated_interfaces, - }, - ) - - return obj - - -def parse_admin_state(vlan): - shutstate = vlan.get("vlanshowbr-shutstate") - if shutstate == "noshutdown": - return "up" - elif shutstate == "shutdown": - return "down" - - -def parse_mode(config): - mode = None - - if config: - match = re.search(r"mode (\S+)", config) - if match: - mode = match.group(1) - return mode - - -def parse_vni(config): - vni = None - - if config: - match = re.search(r"vn-segment (\S+)", config) - if match: - vni = match.group(1) - return str(vni) - - -def get_vlan_int(interfaces): - vlan_int = [] - for i in interfaces.split(","): - if "eth" in i.lower() and "-" in i: - int_range = i.split("-") - stop = int((int_range)[1]) - start = int(int_range[0].split("/")[1]) - eth = int_range[0].split("/")[0] - for r in range(start, stop + 1): - vlan_int.append(eth + "/" + str(r)) - else: - vlan_int.append(i) - return vlan_int - - -def parse_interfaces(module, vlan): - vlan_int = [] - interfaces = vlan.get("vlanshowplist-ifidx") - if interfaces: - if isinstance(interfaces, list): - interfaces_list = [i.strip() for i in interfaces] - interfaces_str = ",".join(interfaces_list) - vlan_int = get_vlan_int(interfaces_str) - else: - vlan_int = get_vlan_int(interfaces) - return vlan_int - - -def parse_vlan_config(netcfg, vlan_id): - parents = ["vlan {0}".format(vlan_id)] - config = netcfg.get_section(parents) - return config - - -def parse_vlan_options(module, netcfg, output, vlan): - obj = {} - vlan_id = vlan["vlanshowbr-vlanid-utf"] - config = parse_vlan_config(netcfg, vlan_id) - - obj["vlan_id"] = str(vlan_id) - obj["name"] = vlan.get("vlanshowbr-vlanname") - obj["vlan_state"] = vlan.get("vlanshowbr-vlanstate") - obj["admin_state"] = parse_admin_state(vlan) - obj["mode"] = parse_mode(config) - obj["mapped_vni"] = parse_vni(config) - obj["interfaces"] = parse_interfaces(module, vlan) - return obj - - -def parse_vlan_non_structured(module, netcfg, vlans): - objs = list() - - for vlan in vlans: - vlan_match = re.search(r"(\d+)", vlan, re.M) - if vlan_match: - obj = {} - vlan_id = vlan_match.group(1) - obj["vlan_id"] = str(vlan_id) - - name_match = re.search(r"{0}\s*(\S+)".format(vlan_id), vlan, re.M) - if name_match: - name = name_match.group(1) - obj["name"] = name - state_match = re.search( - r"{0}\s*{1}\s*(\S+)".format(vlan_id, re.escape(name)), - vlan, - re.M, - ) - if state_match: - vlan_state_match = state_match.group(1) - if vlan_state_match == "suspended": - vlan_state = "suspend" - admin_state = "up" - elif vlan_state_match == "sus/lshut": - vlan_state = "suspend" - admin_state = "down" - if vlan_state_match == "active": - vlan_state = "active" - admin_state = "up" - if vlan_state_match == "act/lshut": - vlan_state = "active" - admin_state = "down" - - obj["vlan_state"] = vlan_state - obj["admin_state"] = admin_state - - vlan = ",".join(vlan.splitlines()) - interfaces = list() - intfs_match = re.search( - r"{0}\s*{1}\s*{2}\s*(.*)".format( - vlan_id, - re.escape(name), - vlan_state_match, - ), - vlan, - re.M, - ) - if intfs_match: - intfs = intfs_match.group(1) - intfs = intfs.split() - for i in intfs: - intf = normalize_interface(i.strip(",")) - interfaces.append(intf) - - if interfaces: - obj["interfaces"] = interfaces - else: - obj["interfaces"] = None - - config = parse_vlan_config(netcfg, vlan_id) - obj["mode"] = parse_mode(config) - obj["mapped_vni"] = parse_vni(config) - - objs.append(obj) - - return objs - - -def map_config_to_obj(module): - objs = list() - output = None - - command = ["show vlan brief | json"] - output = run_commands(module, command, check_rc="retry_json")[0] - if output: - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=["all"])) - - if isinstance(output, dict): - vlans = None - try: - vlans = output["TABLE_vlanbriefxbrief"]["ROW_vlanbriefxbrief"] - except KeyError: - return objs - - if vlans: - if isinstance(vlans, list): - for vlan in vlans: - obj = parse_vlan_options(module, netcfg, output, vlan) - objs.append(obj) - elif isinstance(vlans, dict): - obj = parse_vlan_options(module, netcfg, output, vlans) - objs.append(obj) - else: - vlans = list() - splitted_line = re.split(r"\n(\d+)|\n{2}", output.strip()) - - for line in splitted_line: - if not line: - continue - if len(line) > 0: - line = line.strip() - if line[0].isdigit(): - match = re.search(r"^(\d+)$", line, re.M) - if match: - v = match.group(1) - pos1 = splitted_line.index(v) - pos2 = pos1 + 1 - # fmt: off - vlaninfo = "".join(splitted_line[pos1: pos2 + 1]) - # fmt: on - vlans.append(vlaninfo) - - if vlans: - objs = parse_vlan_non_structured(module, netcfg, vlans) - else: - return objs - - return objs - - -def check_declarative_intent_params(want, module, result): - - have = None - is_delay = False - - for w in want: - if w.get("associated_interfaces") is None: - continue - - if result["changed"] and not is_delay: - time.sleep(module.params["delay"]) - is_delay = True - - if have is None: - have = map_config_to_obj(module) - - for i in w["associated_interfaces"]: - obj_in_have = search_obj_in_list(w["vlan_id"], have) - if obj_in_have and "interfaces" in obj_in_have and i not in obj_in_have["interfaces"]: - module.fail_json(msg="Interface %s not configured on vlan %s" % (i, w["vlan_id"])) - - -def main(): - """main entry point for module execution""" - element_spec = dict( - vlan_id=dict(required=False, type="int"), - vlan_range=dict(required=False), - name=dict(required=False), - interfaces=dict(type="list", elements="str"), - associated_interfaces=dict(type="list", elements="str"), - vlan_state=dict(choices=["active", "suspend"], required=False, default="active"), - mapped_vni=dict(required=False), - delay=dict(default=10, type="int"), - state=dict(choices=["present", "absent"], default="present", required=False), - admin_state=dict(choices=["up", "down"], required=False, default="up"), - mode=dict(default="ce", choices=["ce", "fabricpath"]), - ) - - aggregate_spec = deepcopy(element_spec) - aggregate_spec["vlan_id"] = dict(required=True, type="int") - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec), - purge=dict(default=False, type="bool"), - ) - - argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - - required_one_of = [["vlan_id", "aggregate", "vlan_range"]] - mutually_exclusive = [ - ["vlan_id", "aggregate"], - ["vlan_range", "name"], - ["vlan_id", "vlan_range"], - ] - - module = AnsibleModule( - argument_spec=argument_spec, - required_one_of=required_one_of, - mutually_exclusive=mutually_exclusive, - supports_check_mode=True, - ) - - warnings = list() - result = {"changed": False} - if warnings: - result["warnings"] = warnings - - have = map_config_to_obj(module) - want = map_params_to_obj(module) - - if module.params["vlan_range"]: - commands = vlan_range_commands(module, have) - result["commands"] = commands - else: - commands = map_obj_to_commands((want, have), module) - result["commands"] = commands - - if commands: - if not module.check_mode: - load_config(module, commands) - result["changed"] = True - - if want: - check_declarative_intent_params(want, module, result) - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_vrf_interface.py b/plugins/modules/nxos_vrf_interface.py index 0ce4fe217..697d92d16 100644 --- a/plugins/modules/nxos_vrf_interface.py +++ b/plugins/modules/nxos_vrf_interface.py @@ -209,7 +209,7 @@ def main(): module.fail_json( msg="interface does not exist on switch. Verify " "switch platform or create it first with " - "nxos_interface if it's a logical interface", + "nxos_interfaces if it's a logical interface", ) mode = get_interface_mode(interface, intf_type, module) @@ -217,7 +217,7 @@ def main(): module.fail_json( msg="Ensure interface is a Layer 3 port before " "configuring a VRF on an interface. You can " - "use nxos_interface", + "use nxos_interfaces", ) current_vrf = get_interface_info(interface, module) diff --git a/plugins/modules/nxos_vxlan_vtep.py b/plugins/modules/nxos_vxlan_vtep.py index 861672b4a..da43cc82b 100644 --- a/plugins/modules/nxos_vxlan_vtep.py +++ b/plugins/modules/nxos_vxlan_vtep.py @@ -34,7 +34,7 @@ notes: - Tested against NXOSv 7.3.(0)D1(1) on VIRL - Unsupported for Cisco MDS -- The module is used to manage NVE properties, not to create NVE interfaces. Use M(cisco.nxos.nxos_interface) +- The module is used to manage NVE properties, not to create NVE interfaces. Use M(cisco.nxos.nxos_interfaces) if you wish to do so. - C(state=absent) removes the interface. - Default, where supported, restores params default value. @@ -441,7 +441,7 @@ def main(): if not existing: warnings.append( "The proposed NVE interface did not exist. " - "It's recommended to use nxos_interface to create " + "It's recommended to use nxos_interfaces to create " "all logical interfaces.", ) state_present(module, existing, proposed, candidate) diff --git a/tests/integration/targets/nxos_acl/defaults/main.yaml b/tests/integration/targets/nxos_acl/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_acl/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_acl/meta/main.yml b/tests/integration/targets/nxos_acl/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_acl/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_acl/tasks/cli.yaml b/tests/integration/targets/nxos_acl/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_acl/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/tests/integration/targets/nxos_acl/tasks/main.yaml b/tests/integration/targets/nxos_acl/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_acl/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/tests/integration/targets/nxos_acl/tasks/nxapi.yaml b/tests/integration/targets/nxos_acl/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_acl/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/tests/integration/targets/nxos_acl/tests/common/sanity.yaml b/tests/integration/targets/nxos_acl/tests/common/sanity.yaml deleted file mode 100644 index 59670ca1d..000000000 --- a/tests/integration/targets/nxos_acl/tests/common/sanity.yaml +++ /dev/null @@ -1,234 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_acl sanity test - -- name: Set a fact for 'time_range' - ansible.builtin.set_fact: - time_range: ans-range - when: platform is not search('N35|N5K|N6K') - -- name: "Setup: cleanup possibly existing acl." - ignore_errors: true - cisco.nxos.nxos_acl: &id012 - name: TEST_ACL - seq: 10 - state: delete_acl - -- name: Configure ace10 - register: result - cisco.nxos.nxos_acl: &id001 - name: TEST_ACL - seq: 10 - action: permit - proto: tcp - src: 192.0.2.1/24 - src_port_op: range - src_port1: 1900 - src_port2: 1910 - ack: enable - dscp: af43 - dest: any - dest_port_op: neq - dest_port1: 1899 - urg: enable - psh: enable - established: enable - log: enable - fin: enable - rst: enable - syn: enable - time_range: "{{time_range|default(omit)}}" - state: present - -- ansible.builtin.assert: &id002 - that: - - result.changed == true - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id001 - -- ansible.builtin.assert: &id004 - that: - - result.changed == false - -- name: Change ace10 - register: result - cisco.nxos.nxos_acl: &id003 - name: TEST_ACL - seq: 10 - action: deny - proto: tcp - src: 192.0.2.1/24 - src_port_op: range - src_port1: 1900 - src_port2: 1910 - ack: enable - dscp: af43 - dest: any - dest_port_op: neq - dest_port1: 1899 - urg: enable - psh: enable - established: enable - log: enable - fin: enable - rst: enable - syn: enable - time_range: "{{time_range|default(omit)}}" - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id003 - -- ansible.builtin.assert: *id004 - -- name: Ace remark - register: result - cisco.nxos.nxos_acl: &id005 - name: TEST_ACL - seq: 20 - action: remark - remark: test_remark - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id005 - -- ansible.builtin.assert: *id004 - -- name: Change remark - register: result - cisco.nxos.nxos_acl: &id006 - name: TEST_ACL - seq: 20 - action: remark - remark: changed_remark - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id006 - -- ansible.builtin.assert: *id004 - -- name: Ace 30 - register: result - cisco.nxos.nxos_acl: &id007 - name: TEST_ACL - seq: 30 - action: deny - proto: 24 - src: any - dest: any - fragments: enable - precedence: network - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id007 - -- ansible.builtin.assert: *id004 - -- name: Change ACE 30 options - register: result - cisco.nxos.nxos_acl: &id008 - name: TEST_ACL - seq: 30 - action: deny - proto: 24 - src: any - dest: any - precedence: network - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id008 - -- ansible.builtin.assert: *id004 - -- name: Ace 40 - register: result - cisco.nxos.nxos_acl: &id009 - name: TEST_ACL - seq: 40 - action: permit - proto: udp - src: any - src_port_op: neq - src_port1: 1200 - dest: any - precedence: network - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id009 - -- ansible.builtin.assert: *id004 - -- name: Change ACE 40 - register: result - cisco.nxos.nxos_acl: &id010 - name: TEST_ACL - seq: 40 - action: permit - proto: udp - src: any - dest: any - precedence: network - state: present - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id010 - -- ansible.builtin.assert: *id004 - -- name: Remove ACE 30 - register: result - cisco.nxos.nxos_acl: &id011 - name: TEST_ACL - seq: 30 - state: absent - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id011 - -- ansible.builtin.assert: *id004 - -- name: Remove ACL - register: result - cisco.nxos.nxos_acl: *id012 - -- ansible.builtin.assert: *id002 - -- name: Check idempotence - register: result - cisco.nxos.nxos_acl: *id012 - -- ansible.builtin.assert: *id004 - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_acl sanity test diff --git a/tests/integration/targets/nxos_acl_interface/defaults/main.yaml b/tests/integration/targets/nxos_acl_interface/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_acl_interface/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_acl_interface/meta/main.yml b/tests/integration/targets/nxos_acl_interface/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_acl_interface/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_acl_interface/tasks/cli.yaml b/tests/integration/targets/nxos_acl_interface/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_acl_interface/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/tests/integration/targets/nxos_acl_interface/tasks/main.yaml b/tests/integration/targets/nxos_acl_interface/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_acl_interface/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/tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_acl_interface/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_acl_interface/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/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml deleted file mode 100644 index 3b7804ce2..000000000 --- a/tests/integration/targets/nxos_acl_interface/tests/common/sanity.yaml +++ /dev/null @@ -1,122 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_acl_interface sanity test - -- name: Set a fact for 'intname' - ansible.builtin.set_fact: - intname: "{{ nxos_int1 }}" - -- name: Interface selected for this test - ansible.builtin.debug: - msg: "{{ intname }}" - -- name: "Setup: put interface into a default state" - ignore_errors: true - cisco.nxos.nxos_config: &id007 - lines: - - default interface {{ intname }} - -- name: "Setup: put interface into no switch port mode" - ignore_errors: true - cisco.nxos.nxos_config: - commands: - - no switchport - parents: - - interface {{ intname }} - match: none - -- name: "Setup: cleanup possibly existing ACL" - ignore_errors: true - cisco.nxos.nxos_acl: &id008 - name: ANSIBLE_ACL - seq: 10 - state: delete_acl - -- name: Configure supporting ACL - cisco.nxos.nxos_acl: - name: ANSIBLE_ACL - seq: 10 - action: permit - proto: tcp - src: 192.0.2.1/24 - dest: any - -- block: - - name: Configure ACL interface egress - register: result - cisco.nxos.nxos_acl_interface: &id001 - name: ANSIBLE_ACL - interface: "{{ intname }}" - direction: egress - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence egress - register: result - cisco.nxos.nxos_acl_interface: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure ACL interface ingress - register: result - cisco.nxos.nxos_acl_interface: &id003 - name: ANSIBLE_ACL - interface: "{{ intname }}" - direction: ingress - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence ingress - register: result - cisco.nxos.nxos_acl_interface: *id003 - - - ansible.builtin.assert: *id004 - - - name: Cleanup ACL interface egress - register: result - cisco.nxos.nxos_acl_interface: &id005 - name: ANSIBLE_ACL - interface: "{{ intname }}" - direction: egress - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence egress cleanup - register: result - cisco.nxos.nxos_acl_interface: *id005 - - - ansible.builtin.assert: *id004 - - - name: Cleanup ACL interface ingress - register: result - cisco.nxos.nxos_acl_interface: &id006 - name: ANSIBLE_ACL - interface: "{{ intname }}" - direction: ingress - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence ingress cleanup - register: result - cisco.nxos.nxos_acl_interface: *id006 - - - ansible.builtin.assert: *id004 - rescue: - - name: Put test interface into default state. - ignore_errors: true - cisco.nxos.nxos_config: *id007 - always: - - name: Remove possible configured ACL - ignore_errors: true - cisco.nxos.nxos_acl: *id008 - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_acl_interface sanity test diff --git a/tests/integration/targets/nxos_interface/defaults/main.yaml b/tests/integration/targets/nxos_interface/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_interface/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_interface/meta/main.yml b/tests/integration/targets/nxos_interface/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_interface/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_interface/tasks/cli.yaml b/tests/integration/targets/nxos_interface/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_interface/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/tests/integration/targets/nxos_interface/tasks/main.yaml b/tests/integration/targets/nxos_interface/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_interface/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/tests/integration/targets/nxos_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_interface/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_interface/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/tests/integration/targets/nxos_interface/tests/common/intent.yaml b/tests/integration/targets/nxos_interface/tests/common/intent.yaml deleted file mode 100644 index 3ca038082..000000000 --- a/tests/integration/targets/nxos_interface/tests/common/intent.yaml +++ /dev/null @@ -1,74 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_interface intent test - -- name: Set a fact for 'testint1' - ansible.builtin.set_fact: - testint1: "{{ nxos_int1 }}" - -- name: Set a fact for 'testint2' - ansible.builtin.set_fact: - testint2: "{{ nxos_int2 }}" - -- name: "Setup: put interfaces into a default state" - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - default interface {{ testint1 }} - - default interface {{ testint2 }} - -- name: Check intent arguments - register: result - cisco.nxos.nxos_interface: - name: "{{ testint2 }}" - admin_state: up - tx_rate: ge(0) - rx_rate: ge(0) - -- ansible.builtin.assert: - that: - - result.failed == false - -- name: Clear interface {{ testint2 }} counters before next task - ignore_errors: true - cisco.nxos.nxos_command: - commands: clear counters interface {{ testint2 }} - -- name: Check intent arguments (failed condition) - ignore_errors: true - register: result - cisco.nxos.nxos_interface: - name: "{{ testint2 }}" - admin_state: down - tx_rate: gt(10000) - rx_rate: lt(0) - -- ansible.builtin.assert: - that: - - result.failed == true - - "'tx_rate gt(10000)' in result.failed_conditions" - - "'rx_rate lt(0)' in result.failed_conditions" - -- name: Aggregate definition of interface - register: result - cisco.nxos.nxos_interface: - aggregate: - - name: "{{ testint1 }}" - description: Test aggregation on first interface - - - name: "{{ testint2 }}" - mode: layer3 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: "Teardown: put interfaces into a default state" - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - default interface {{ testint1 }} - - default interface {{ testint2 }} - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_interface intent test diff --git a/tests/integration/targets/nxos_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_interface/tests/common/sanity.yaml deleted file mode 100644 index 5ae20dae4..000000000 --- a/tests/integration/targets/nxos_interface/tests/common/sanity.yaml +++ /dev/null @@ -1,134 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_interface sanity test - -- name: Set a fact for 'testint' - ansible.builtin.set_fact: - testint: "{{ nxos_int1 }}" - -- name: "Setup: enable 'feature interface-vlan'" - ignore_errors: true - cisco.nxos.nxos_feature: - feature: interface-vlan - state: enabled - -- name: "Setup: put interface {{ testint }} into a default state" - ignore_errors: true - cisco.nxos.nxos_config: &id008 - lines: - - default interface {{ testint }} - -- name: "Setup: remove possibly existing VLAN interfaces" - ignore_errors: true - cisco.nxos.nxos_config: &id009 - lines: - - no interface vlan 2 - - no interface vlan 710 - - no interface vlan 711 - - no interface vlan 712 - -- block: - - name: Configure layer3 params - register: result - cisco.nxos.nxos_interface: &id001 - interface: "{{ testint }}" - mode: layer3 - description: Configured by Ansible - Layer3 - admin_state: up - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure layer2 params - register: result - cisco.nxos.nxos_interface: &id003 - interface: "{{ testint }}" - mode: layer2 - description: Configured by Ansible - Layer2 - admin_state: down - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface: *id003 - - - ansible.builtin.assert: *id004 - - - name: Create VLAN interfaces - with_items: &id005 - - os_svi_int: vlan2 - os_svi_desc: SVI_VLAN2 - - - os_svi_int: vlan710 - os_svi_desc: SVI_VLAN710 - - - os_svi_int: vlan711 - os_svi_desc: SVI_VLAN711 - - - os_svi_int: vlan712 - os_svi_desc: SVI_VLAN712 - register: result - cisco.nxos.nxos_interface: &id006 - interface: "{{ item.os_svi_int }}" - description: "{{ item.os_svi_desc }}" - - - ansible.builtin.assert: *id002 - - - name: Configure required SVI - register: result - cisco.nxos.nxos_l3_interface: &id007 - aggregate: - - name: vlan2 - ipv4: 192.168.2.1/24 - - - name: vlan710 - ipv4: 192.168.3.1/24 - - - name: vlan711 - ipv4: 192.168.4.1/24 - - - name: vlan712 - ipv4: 192.168.5.1/24 - - - ansible.builtin.assert: *id002 - - - name: Create VLAN interfaces idempotence check - with_items: *id005 - register: result - cisco.nxos.nxos_interface: *id006 - - - ansible.builtin.assert: *id004 - - - name: Configure required SVI idempotence check - register: result - cisco.nxos.nxos_l3_interface: *id007 - - - ansible.builtin.assert: *id004 - always: - - name: Set interface back to default - ignore_errors: true - cisco.nxos.nxos_config: *id008 - - - name: Remove VLAN interfaces - cisco.nxos.nxos_config: *id009 - - - name: "Setup: disable 'feature interface-vlan'" - ignore_errors: true - cisco.nxos.nxos_feature: - feature: interface-vlan - state: disabled - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_interface sanity test diff --git a/tests/integration/targets/nxos_interface/tests/common/set_state_absent.yaml b/tests/integration/targets/nxos_interface/tests/common/set_state_absent.yaml deleted file mode 100644 index 0140d86f9..000000000 --- a/tests/integration/targets/nxos_interface/tests/common/set_state_absent.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/set_state_absent.yaml - -- name: Setup - cisco.nxos.nxos_config: - lines: - - interface Loopback1 - -- name: Set state=absent - register: result - cisco.nxos.nxos_interface: - interface: Loopback1 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Verify state=absent - register: result - cisco.nxos.nxos_interface: - interface: Loopback1 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }}/set_state_absent.yaml diff --git a/tests/integration/targets/nxos_interface/tests/common/set_state_present.yaml b/tests/integration/targets/nxos_interface/tests/common/set_state_present.yaml deleted file mode 100644 index 5165b2f50..000000000 --- a/tests/integration/targets/nxos_interface/tests/common/set_state_present.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/set_state_present.yaml - -- name: Setup - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - no interface Loopback1 - -- name: Set state=present - register: result - cisco.nxos.nxos_interface: - interface: Loopback1 - state: present - description: Configured by Ansible - Layer3 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Verify state=present - register: result - cisco.nxos.nxos_interface: - interface: Loopback1 - state: present - description: Configured by Ansible - Layer3 - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }}/set_state_present.yaml diff --git a/tests/integration/targets/nxos_interface/tests/common/sub_int.yaml b/tests/integration/targets/nxos_interface/tests/common/sub_int.yaml deleted file mode 100644 index 358e19651..000000000 --- a/tests/integration/targets/nxos_interface/tests/common/sub_int.yaml +++ /dev/null @@ -1,77 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_interface sub-interface test - -- name: Set a fact for 'testint' - ansible.builtin.set_fact: - testint: "{{ nxos_int1 }}" - -- name: Setup - delete sub-interface - ignore_errors: true - cisco.nxos.nxos_interface: &id003 - name: "{{ testint }}.20" - state: absent - -- name: Setup - ensure the interface is layer3 - cisco.nxos.nxos_interface: - name: "{{ testint }}" - mode: layer3 - -- name: Create sub-interface - register: result - cisco.nxos.nxos_interface: &id001 - name: "{{ testint }}.20" - description: sub-interface Configured by Ansible - admin_state: up - mtu: 800 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Create sub-interface (idempotence) - register: result - cisco.nxos.nxos_interface: *id001 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Make admin_state down - register: result - cisco.nxos.nxos_interface: &id002 - name: "{{ testint }}.20" - description: sub-interface Configured by Ansible - admin_state: down - mtu: 800 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Create sub-interface (idempotence) - register: result - cisco.nxos.nxos_interface: *id002 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove sub-interface - register: result - cisco.nxos.nxos_interface: *id003 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Remove sub-interface (idempotence) - register: result - cisco.nxos.nxos_interface: *id003 - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_interface sub-interface test diff --git a/tests/integration/targets/nxos_interface_ospf/defaults/main.yaml b/tests/integration/targets/nxos_interface_ospf/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_interface_ospf/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_interface_ospf/meta/main.yml b/tests/integration/targets/nxos_interface_ospf/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_interface_ospf/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_interface_ospf/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/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml deleted file mode 100644 index c9e70304e..000000000 --- a/tests/integration/targets/nxos_interface_ospf/tasks/main.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Run the CLI and NX-API tests - block: - - name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - always: - - name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml b/tests/integration/targets/nxos_interface_ospf/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_interface_ospf/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/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml b/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml deleted file mode 100644 index cb33c0b8a..000000000 --- a/tests/integration/targets/nxos_interface_ospf/tests/common/sanity.yaml +++ /dev/null @@ -1,295 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_interface_ospf sanity test - -- name: Set a fact for 'testint' - ansible.builtin.set_fact: - testint: "{{ nxos_int1 }}" - -- name: Setup - disable features - loop: - - ospf - - bfd - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- name: Setup - enable features - loop: - - ospf - - bfd - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: enabled - -- name: Put interface into default state - ignore_errors: true - cisco.nxos.nxos_config: &id013 - lines: - - default interface {{ testint }} - -- name: Remove switchport configuration - ignore_errors: true - cisco.nxos.nxos_config: - commands: - - no switchport - parents: - - interface {{ testint }} - -- name: Remove possibly existing port-channel and loopback ints - ignore_errors: true - cisco.nxos.nxos_config: &id014 - commands: - - no interface port-channel10 - - no interface port-channel11 - - no interface loopback55 - - no interface loopback77 - -- block: - - name: Configure OSPF interface - register: result - cisco.nxos.nxos_interface_ospf: &id001 - interface: "{{ nxos_int1|upper }}" - ospf: 1 - area: 12345678 - bfd: enable - cost: 55 - passive_interface: true - hello_interval: 15 - dead_interval: 75 - network: point-to-point - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface_ospf: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Modify properties - register: result - cisco.nxos.nxos_interface_ospf: &id003 - interface: "{{ testint }}" - ospf: 1 - area: 12345678 - cost: 66 - passive_interface: false - hello_interval: 17 - dead_interval: 70 - network: broadcast - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface_ospf: *id003 - - - ansible.builtin.assert: *id004 - - - name: Default properties - register: result - cisco.nxos.nxos_interface_ospf: &id005 - interface: "{{ testint }}" - ospf: 1 - area: 12345678 - bfd: default - cost: default - hello_interval: 10 - dead_interval: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface_ospf: *id005 - - - ansible.builtin.assert: *id004 - - - name: Message_digest properties - register: result - cisco.nxos.nxos_interface_ospf: &id006 - interface: "{{ testint }}" - ospf: 1 - area: 12345678 - message_digest: true - message_digest_key_id: 10 - message_digest_algorithm_type: md5 - message_digest_encryption_type: 3des - message_digest_password: b69f7bc54725b1bfd1ea93afa7b09400 - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface_ospf: *id006 - - - ansible.builtin.assert: *id004 - - - name: Message_digest defaults - register: result - cisco.nxos.nxos_interface_ospf: &id007 - interface: "{{ testint }}" - ospf: 1 - area: 12345678 - message_digest: false - message_digest_key_id: default - message_digest_algorithm_type: default - message_digest_encryption_type: default - message_digest_password: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface_ospf: *id007 - - - ansible.builtin.assert: *id004 - - - name: Create port-channel and loopback interfaces - cisco.nxos.nxos_config: - commands: - - interface port-channel10 - - interface port-channel11 - - interface loopback55 - - interface loopback77 - match: none - - - name: Ensure port-channels are layer3 - with_items: - - port-channel10 - - port-channel11 - cisco.nxos.nxos_config: - commands: - - no switchport - parents: - - interface {{ item }} - - - name: Configure OSPF interface port-channel10 - register: result - cisco.nxos.nxos_interface_ospf: &id008 - interface: Port-channel10 - ospf: 1 - area: 429496729 - cost: 55 - passive_interface: true - hello_interval: 15 - dead_interval: 75 - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence for port-channel10 - register: result - cisco.nxos.nxos_interface_ospf: *id008 - - - ansible.builtin.assert: *id004 - - - name: Configure OSPF interface port-channel11 using lower case name - register: result - cisco.nxos.nxos_interface_ospf: &id009 - interface: port-channel11 - ospf: 1 - area: 42949672 - cost: 55 - passive_interface: true - hello_interval: 15 - dead_interval: 75 - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence for port-channel11 - register: result - cisco.nxos.nxos_interface_ospf: *id009 - - - ansible.builtin.assert: *id004 - - - name: Configure OSPF interface loopback55 - register: result - cisco.nxos.nxos_interface_ospf: &id010 - interface: LOOPBACK55 - ospf: 1 - area: 192.0.2.4 - cost: 55 - hello_interval: 15 - dead_interval: 75 - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence for loopback55 - register: result - cisco.nxos.nxos_interface_ospf: *id010 - - - ansible.builtin.assert: *id004 - - - name: Configure OSPF interface loopback77 using lower case name - register: result - cisco.nxos.nxos_interface_ospf: &id011 - interface: loopback77 - ospf: 1 - area: 429496 - cost: 77 - hello_interval: 45 - dead_interval: 75 - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence for loopback77 - register: result - cisco.nxos.nxos_interface_ospf: *id011 - - - ansible.builtin.assert: *id004 - - - name: Remove OSPF interface configuration - register: result - cisco.nxos.nxos_interface_ospf: &id012 - interface: "{{ testint }}" - ospf: 1 - area: 12345678 - bfd: disable - cost: 55 - passive_interface: true - hello_interval: 15 - dead_interval: 75 - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_interface_ospf: *id012 - - - ansible.builtin.assert: *id004 - always: - - name: Disable features - loop: - - ospf - - bfd - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - - - name: Interface cleanup - ignore_errors: true - cisco.nxos.nxos_config: *id013 - - - name: Remove port-channel and loopback ints - ignore_errors: true - cisco.nxos.nxos_config: *id014 - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_interface_ospf sanity test diff --git a/tests/integration/targets/nxos_l2_interface/defaults/main.yaml b/tests/integration/targets/nxos_l2_interface/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_l2_interface/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_l2_interface/meta/main.yml b/tests/integration/targets/nxos_l2_interface/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_l2_interface/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_l2_interface/tasks/cli.yaml b/tests/integration/targets/nxos_l2_interface/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_l2_interface/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/tests/integration/targets/nxos_l2_interface/tasks/main.yaml b/tests/integration/targets/nxos_l2_interface/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_l2_interface/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/tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_l2_interface/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_l2_interface/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/tests/integration/targets/nxos_l2_interface/tests/common/agg.yaml b/tests/integration/targets/nxos_l2_interface/tests/common/agg.yaml deleted file mode 100644 index 3f3e6e9c3..000000000 --- a/tests/integration/targets/nxos_l2_interface/tests/common/agg.yaml +++ /dev/null @@ -1,119 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_l2_interface aggregate test - -- name: Set a fact for 'intname1' - ansible.builtin.set_fact: - intname1: "{{ nxos_int1 }}" - -- name: Set a fact for 'intname2' - ansible.builtin.set_fact: - intname2: "{{ nxos_int2 }}" - -- name: Setup vlans - cisco.nxos.nxos_vlan: - vlan_range: 6,15 - -- name: Setup - ensure interfaces are layer2 - cisco.nxos.nxos_interface: - aggregate: - - name: "{{ intname1 }}" - - - name: "{{ intname2 }}" - mode: layer2 - -- name: Setup - remove interface aggregate before testing - cisco.nxos.nxos_l2_interface: - aggregate: - - name: "{{ intname1 }}" - mode: access - access_vlan: 6 - - - name: "{{ intname2 }}" - mode: access - access_vlan: 15 - state: absent - -- name: Sleep for 2 seconds on fretta platform - ansible.builtin.wait_for: timeout=2 - when: platform is match("N9K-F") - -- block: - - name: Configure interface for access_vlan aggregate - register: result - cisco.nxos.nxos_l2_interface: &id001 - aggregate: - - name: "{{ intname1 }}" - mode: access - access_vlan: 6 - - - name: "{{ intname2 }}" - mode: access - access_vlan: 15 - - - ansible.builtin.assert: - that: - - result.changed == true - - - name: Sleep for 2 seconds on fretta platform - ansible.builtin.wait_for: timeout=2 - when: platform is match("N9K-F") - - - name: Configure interface for access_vlan aggregate(idempotence) - register: result - cisco.nxos.nxos_l2_interface: *id001 - - - ansible.builtin.assert: - that: - - result.changed == false - - - name: Remove interface aggregate - register: result - cisco.nxos.nxos_l2_interface: &id002 - aggregate: - - name: "{{ intname1 }}" - mode: access - access_vlan: 6 - - - name: "{{ intname2 }}" - mode: access - access_vlan: 15 - state: absent - - - ansible.builtin.assert: - that: - - result.changed == true - - - name: Sleep for 2 seconds on fretta platform - ansible.builtin.wait_for: timeout=2 - when: platform is match("N9K-F") - - - name: Remove interface aggregate(idempotence) - register: result - cisco.nxos.nxos_l2_interface: *id002 - - - ansible.builtin.assert: - that: - - result.changed == false - always: - - name: Remove vlans - ignore_errors: true - cisco.nxos.nxos_vlan: - vlan_range: 6,15 - state: absent - - - name: Remove interface aggregate after testing - ignore_errors: true - cisco.nxos.nxos_l2_interface: - aggregate: - - name: "{{ intname1 }}" - mode: access - access_vlan: 6 - - - name: "{{ intname2 }}" - mode: access - access_vlan: 15 - state: absent - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_l2_interface aggregate test diff --git a/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml deleted file mode 100644 index 1e06eb5f5..000000000 --- a/tests/integration/targets/nxos_l2_interface/tests/common/sanity.yaml +++ /dev/null @@ -1,156 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_l2_interface sanity test - -- name: Set a fact for 'intname' - ansible.builtin.set_fact: - intname: "{{ nxos_int1 }}" - -- name: Interface selected for this test - ansible.builtin.debug: - msg: "{{ intname }}" - -- name: Setup interface - ignore_errors: true - cisco.nxos.nxos_config: &id009 - lines: - - default interface {{ intname }} - -- name: Setup - ensure interface is layer2 - cisco.nxos.nxos_interface: - interface: "{{ intname }}" - mode: layer2 - -- name: Setup vlans - cisco.nxos.nxos_vlan: - vlan_range: 5-10,20 - -- block: - - name: Ensure interface is in its default switchport state - cisco.nxos.nxos_l2_interface: &id008 - name: "{{ intname }}" - state: unconfigured - - - name: Ensure interface is configured for access VLAN 20 - register: result - cisco.nxos.nxos_l2_interface: &id001 - name: "{{ intname }}" - mode: access - access_vlan: 20 - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Sleep for 2 seconds on fretta platform - ansible.builtin.wait_for: timeout=2 - when: platform is match("N9K-F") - - - name: Access VLAN idempotence - register: result - cisco.nxos.nxos_l2_interface: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Ensure interface only has vlans 5-10 as trunk vlans - register: result - cisco.nxos.nxos_l2_interface: &id003 - name: "{{ intname }}" - mode: trunk - native_vlan: 10 - trunk_allowed_vlans: 5-10 - - - ansible.builtin.assert: *id002 - - - name: Trunk VLAN idempotence - register: result - cisco.nxos.nxos_l2_interface: *id003 - - - ansible.builtin.assert: *id004 - - - name: Ensure interface is a trunk port and ensure 2-50 are being tagged (doesn't mean others aren't also being tagged) - register: result - cisco.nxos.nxos_l2_interface: &id005 - name: "{{ intname }}" - mode: trunk - native_vlan: 10 - trunk_vlans: 2-50 - - - ansible.builtin.assert: *id002 - - - name: Tag VLAN idempotence - register: result - cisco.nxos.nxos_l2_interface: *id005 - - - ansible.builtin.assert: *id004 - - - name: Remove full trunk VLAN range 2-50 - register: result - cisco.nxos.nxos_l2_interface: &id006 - name: "{{ intname }}" - mode: trunk - trunk_vlans: 2-50 - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence remove full trunk VLAN range 2-50 - register: result - cisco.nxos.nxos_l2_interface: *id006 - - - ansible.builtin.assert: *id004 - - - name: Reconfigure interface trunk port and ensure 2-50 are being tagged - register: result - cisco.nxos.nxos_l2_interface: *id005 - - - ansible.builtin.assert: *id002 - - - name: Check idempotence reconfigure interface trunk port and ensure 2-50 are being tagged - register: result - cisco.nxos.nxos_l2_interface: *id005 - - - ansible.builtin.assert: *id004 - - - name: Remove partial trunk VLAN range 30-4094 are removed - register: result - cisco.nxos.nxos_l2_interface: &id007 - name: "{{ intname }}" - mode: trunk - trunk_vlans: 30-4094 - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence remove partial trunk VLAN range 30-4094 are removed - register: result - cisco.nxos.nxos_l2_interface: *id007 - - - ansible.builtin.assert: *id004 - - - name: Put interface default state - register: result - cisco.nxos.nxos_l2_interface: *id008 - - - ansible.builtin.assert: *id002 - - - name: Default state idempotence - register: result - cisco.nxos.nxos_l2_interface: *id008 - - - ansible.builtin.assert: *id004 - always: - - name: Remove vlans - ignore_errors: true - cisco.nxos.nxos_vlan: - vlan_range: 5-10,20 - state: absent - - - name: Default interface - ignore_errors: true - cisco.nxos.nxos_config: *id009 - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_l2_interface sanity test diff --git a/tests/integration/targets/nxos_l3_interface/defaults/main.yaml b/tests/integration/targets/nxos_l3_interface/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_l3_interface/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_l3_interface/meta/main.yml b/tests/integration/targets/nxos_l3_interface/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_l3_interface/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_l3_interface/tasks/cli.yaml b/tests/integration/targets/nxos_l3_interface/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_l3_interface/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/tests/integration/targets/nxos_l3_interface/tasks/main.yaml b/tests/integration/targets/nxos_l3_interface/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_l3_interface/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/tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_l3_interface/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_l3_interface/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/tests/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml b/tests/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml deleted file mode 100644 index e2a3f3b7b..000000000 --- a/tests/integration/targets/nxos_l3_interface/tests/cli/sanity.yaml +++ /dev/null @@ -1,132 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START TRANSPORT:CLI nxos_l3_interface sanity test - -- name: Set a fact for 'testint2' - ansible.builtin.set_fact: - testint2: "{{ nxos_int2 }}" - -- name: Set a fact for 'testint3' - ansible.builtin.set_fact: - testint3: "{{ nxos_int3 }}" - -- name: Set a fact for 'ipv6_address' - ansible.builtin.set_fact: - ipv6_address: "" - -- name: Set a fact for 'ipv6_address' - ansible.builtin.set_fact: - ipv6_address: 33:db::2/8 - when: ipv6_supported - -- name: Setup - remove address from interface prior to testing(part1) - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - no ip address 192.168.22.1/24 - parents: no switchport - before: interface {{ testint2 }} - -- name: Setup - remove address from interface prior to testing(part2) - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - no ip address 192.168.20.1/24 - - no ipv6 address 33:db::2/8 - parents: no switchport - before: interface {{ testint3 }} - -- name: Setup - ensure interfaces are layer3 - cisco.nxos.nxos_interface: - aggregate: - - name: "{{ testint2 }}" - - - name: "{{ testint3 }}" - mode: layer3 - -- name: Configure ipv4 address to interface - register: result - cisco.nxos.nxos_l3_interface: &id001 - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Configure ipv4 address to interface(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id001 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove ipv4 address from interface - register: result - cisco.nxos.nxos_l3_interface: &id002 - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Remove ipv4 address from interface(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id002 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Configure address to interfaces aggregate - register: result - cisco.nxos.nxos_l3_interface: &id003 - aggregate: - - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - - - name: "{{ testint3 }}" - ipv4: 192.168.20.1/24 - ipv6: "{{ ipv6_address }}" - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Configure address to interfaces aggregate(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id003 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove address from interfaces aggregate - register: result - cisco.nxos.nxos_l3_interface: &id004 - aggregate: - - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - - - name: "{{ testint3 }}" - ipv4: 192.168.20.1/24 - ipv6: "{{ ipv6_address }}" - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Remove address from interfaces aggregate(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id004 - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END TRANSPORT:CLI nxos_l3_interface sanity test diff --git a/tests/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml b/tests/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml deleted file mode 100644 index 9cd1d6585..000000000 --- a/tests/integration/targets/nxos_l3_interface/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START TRANSPORT:NXAPI nxos_l3_interface sanity test - -- name: Set a fact for 'testint2' - ansible.builtin.set_fact: - testint2: "{{ nxos_int2 }}" - -- name: Set a fact for 'testint3' - ansible.builtin.set_fact: - testint3: "{{ nxos_int3 }}" - -- name: Set a fact for 'ipv6_address' - ansible.builtin.set_fact: - ipv6_address: "" - -- name: Set a fact for 'ipv6_address' - ansible.builtin.set_fact: - ipv6_address: 33:db::2/8 - when: ipv6_supported - -- name: Setup - remove address from interfaces aggregate - ignore_errors: true - cisco.nxos.nxos_l3_interface: - aggregate: - - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - - - name: "{{ testint3 }}" - ipv4: 192.168.20.1/24 - ipv6: "{{ ipv6_address }}" - state: absent - -- name: Setup - ensure interfaces are layer3 - cisco.nxos.nxos_interface: - aggregate: - - name: "{{ testint2 }}" - - - name: "{{ testint3 }}" - mode: layer3 - -- name: Configure ipv4 address to interface - register: result - cisco.nxos.nxos_l3_interface: &id001 - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Configure ipv4 address to interface(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id001 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove ipv4 address from interface - register: result - cisco.nxos.nxos_l3_interface: &id002 - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Remove ipv4 address from interface(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id002 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Configure address to interfaces aggregate - register: result - cisco.nxos.nxos_l3_interface: &id003 - aggregate: - - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - - - name: "{{ testint3 }}" - ipv4: 192.168.20.1/24 - ipv6: "{{ ipv6_address }}" - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Configure address to interfaces aggregate(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id003 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove address from interfaces aggregate - register: result - cisco.nxos.nxos_l3_interface: &id004 - aggregate: - - name: "{{ testint2 }}" - ipv4: 192.168.22.1/24 - - - name: "{{ testint3 }}" - ipv4: 192.168.20.1/24 - ipv6: "{{ ipv6_address }}" - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - -- name: Remove address from interfaces aggregate(idempotence) - register: result - cisco.nxos.nxos_l3_interface: *id004 - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END TRANSPORT:NXAPI nxos_l3_interface sanity test diff --git a/tests/integration/targets/nxos_linkagg/defaults/main.yaml b/tests/integration/targets/nxos_linkagg/defaults/main.yaml deleted file mode 100644 index 9ef5ba516..000000000 --- a/tests/integration/targets/nxos_linkagg/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/tests/integration/targets/nxos_linkagg/meta/main.yml b/tests/integration/targets/nxos_linkagg/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_linkagg/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_linkagg/tasks/cli.yaml b/tests/integration/targets/nxos_linkagg/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_linkagg/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/tests/integration/targets/nxos_linkagg/tasks/main.yaml b/tests/integration/targets/nxos_linkagg/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_linkagg/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/tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml b/tests/integration/targets/nxos_linkagg/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_linkagg/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/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml b/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml deleted file mode 100644 index 961e99ee0..000000000 --- a/tests/integration/targets/nxos_linkagg/tests/common/sanity.yaml +++ /dev/null @@ -1,204 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_linkagg sanity test - -- name: Set a fact for 'testint1' - ansible.builtin.set_fact: - testint1: "{{ nxos_int1 }}" - -- name: Set a fact for 'testint2' - ansible.builtin.set_fact: - testint2: "{{ nxos_int2 }}" - -- name: Enable 'feature lacp' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: lacp - state: enabled - -- name: Setup - remove configuration used in test(part1) - cisco.nxos.nxos_config: - lines: - - no interface port-channel 20 - - no interface port-channel 100 - -- name: Setup - remove configuration used in test(part2) - ignore_errors: true - loop: - - interface {{ testint1 }} - - interface {{ testint2 }} - cisco.nxos.nxos_config: - lines: - - no channel-group 20 - parents: "{{ item }}" - -- name: Put interface in layer 2 mode - when: platform is match("N35") - cisco.nxos.nxos_interface: - aggregate: - - name: "{{testint1}}" - - - name: "{{testint2}}" - mode: layer2 - -- name: Create linkagg - register: result - cisco.nxos.nxos_linkagg: &id001 - group: 20 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"interface port-channel 20" in result.commands' - -- name: Create linkagg(idempotence) - register: result - cisco.nxos.nxos_linkagg: *id001 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Set link aggregation group to members declaratively - register: result - cisco.nxos.nxos_linkagg: &id002 - group: 20 - mode: active - force: true - members: - - "{{ testint1 }}" - - "{{ testint2 }}" - -- ansible.builtin.assert: - that: - - result.changed == true - - '"interface {{ testint1 }}" in result.commands' - - '"channel-group 20 force mode active" in result.commands' - - '"interface {{ testint2 }}" in result.commands' - - '"channel-group 20 force mode active" in result.commands' - -- name: Set link aggregation group to members(idempotence) - register: result - cisco.nxos.nxos_linkagg: *id002 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove link aggregation group from member declaratively - register: result - cisco.nxos.nxos_linkagg: &id003 - group: 20 - mode: active - force: true - members: - - "{{ testint2 }}" - -- ansible.builtin.assert: - that: - - result.changed == true - - '"interface {{ testint1 }}" in result.commands' - - '"no channel-group 20" in result.commands' - -- name: Remove link aggregation group from member(idempotence) - register: result - cisco.nxos.nxos_linkagg: *id003 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove linkagg - register: result - cisco.nxos.nxos_linkagg: &id004 - group: 20 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no interface port-channel 20" in result.commands' - -- name: Remove linkagg(idempotence) - register: result - cisco.nxos.nxos_linkagg: *id004 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Create aggregate of linkagg definitions - register: result - cisco.nxos.nxos_linkagg: &id005 - aggregate: - - group: 20 - min_links: 3 - - - group: 100 - min_links: 4 - -- ansible.builtin.assert: - that: - - result.changed == true - - '"interface port-channel 20" in result.commands' - - '"lacp min-links 3" in result.commands' - - '"interface port-channel 100" in result.commands' - - '"lacp min-links 4" in result.commands' - -- name: Create aggregate of linkagg definitions(idempotence) - register: result - cisco.nxos.nxos_linkagg: *id005 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Remove aggregate of linkagg definitions - register: result - cisco.nxos.nxos_linkagg: &id006 - aggregate: - - group: 20 - min_links: 3 - - - group: 100 - min_links: 4 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no interface port-channel 20" in result.commands' - - '"no interface port-channel 100" in result.commands' - -- name: Remove aggregate of linkagg definitions(idempotence) - register: result - cisco.nxos.nxos_linkagg: *id006 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Teardown - remove configuration used in test(part1) - cisco.nxos.nxos_config: - lines: - - no interface port-channel 20 - - no interface port-channel 100 - -- name: Teardown - remove configuration used in test(part2) - ignore_errors: true - loop: - - interface {{ testint1 }} - - interface {{ testint2 }} - cisco.nxos.nxos_config: - lines: - - no channel-group 20 - parents: "{{ item }}" - -- name: Disable 'feature lacp' - cisco.nxos.nxos_feature: - feature: lacp - state: disabled - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_linkagg sanity test diff --git a/tests/integration/targets/nxos_lldp/defaults/main.yaml b/tests/integration/targets/nxos_lldp/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_lldp/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_lldp/meta/main.yml b/tests/integration/targets/nxos_lldp/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_lldp/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_lldp/tasks/cli.yaml b/tests/integration/targets/nxos_lldp/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_lldp/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/tests/integration/targets/nxos_lldp/tasks/main.yaml b/tests/integration/targets/nxos_lldp/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_lldp/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/tests/integration/targets/nxos_lldp/tasks/nxapi.yaml b/tests/integration/targets/nxos_lldp/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_lldp/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/tests/integration/targets/nxos_lldp/tests/cli/sanity.yaml b/tests/integration/targets/nxos_lldp/tests/cli/sanity.yaml deleted file mode 100644 index d6162dd98..000000000 --- a/tests/integration/targets/nxos_lldp/tests/cli/sanity.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START TRANSPORT:CLI nxos_lldp sanity test - -- name: Make sure lldp is not running before tests - cisco.nxos.nxos_feature: - feature: lldp - state: disabled - -- name: Enable lldp service - register: result - cisco.nxos.nxos_lldp: - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"feature lldp" in result.commands' - -- name: Enable lldp service again (idempotent) - register: result - cisco.nxos.nxos_lldp: - state: present - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Disable lldp service - register: result - cisco.nxos.nxos_lldp: - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no feature lldp" in result.commands' - -- name: Disable lldp service (idempotent) - register: result - cisco.nxos.nxos_lldp: - state: absent - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END TRANSPORT:CLI nxos_lldp sanity test diff --git a/tests/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml b/tests/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml deleted file mode 100644 index c2cbdf2a8..000000000 --- a/tests/integration/targets/nxos_lldp/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START TRANSPORT:NXAPI nxos_lldp sanity test - -- name: Make sure lldp is not running before tests - cisco.nxos.nxos_feature: - feature: lldp - state: disabled - -- name: Enable lldp service - register: result - cisco.nxos.nxos_lldp: - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"feature lldp" in result.commands' - -- name: Enable lldp service again (idempotent) - register: result - cisco.nxos.nxos_lldp: - state: present - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Disable lldp service - register: result - cisco.nxos.nxos_lldp: - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no feature lldp" in result.commands' - -- name: Disable lldp service (idempotent) - register: result - cisco.nxos.nxos_lldp: - state: absent - -- ansible.builtin.assert: - that: - - result.changed == false - -- ansible.builtin.debug: - msg: END TRANSPORT:NXAPI nxos_lldp sanity test diff --git a/tests/integration/targets/nxos_ospf/defaults/main.yaml b/tests/integration/targets/nxos_ospf/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_ospf/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_ospf/meta/main.yml b/tests/integration/targets/nxos_ospf/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_ospf/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_ospf/tasks/cli.yaml b/tests/integration/targets/nxos_ospf/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_ospf/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/tests/integration/targets/nxos_ospf/tasks/main.yaml b/tests/integration/targets/nxos_ospf/tasks/main.yaml deleted file mode 100644 index c9e70304e..000000000 --- a/tests/integration/targets/nxos_ospf/tasks/main.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Run the CLI and NX-API tests - block: - - name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - always: - - name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/tests/integration/targets/nxos_ospf/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospf/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_ospf/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/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml b/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml deleted file mode 100644 index e778c704b..000000000 --- a/tests/integration/targets/nxos_ospf/tests/common/sanity.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_ospf sanity test - -- name: Enable 'feature ospf' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: ospf - state: enabled - -- block: - - name: Configure OSPF - register: result - cisco.nxos.nxos_ospf: &id001 - ospf: 1 - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - rescue: - - name: Disable 'feature ospf' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: ospf - state: disabled - always: - - name: Unconfigure OSPF - register: result - cisco.nxos.nxos_ospf: &id003 - ospf: 1 - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf: *id003 - - - ansible.builtin.assert: *id004 - - - ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_ospf sanity test diff --git a/tests/integration/targets/nxos_ospf_vrf/defaults/main.yaml b/tests/integration/targets/nxos_ospf_vrf/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_ospf_vrf/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_ospf_vrf/meta/main.yml b/tests/integration/targets/nxos_ospf_vrf/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_ospf_vrf/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_ospf_vrf/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/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml deleted file mode 100644 index c9e70304e..000000000 --- a/tests/integration/targets/nxos_ospf_vrf/tasks/main.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Run the CLI and NX-API tests - block: - - name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - always: - - name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_ospf_vrf/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/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml b/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml deleted file mode 100644 index 49a6b9ed7..000000000 --- a/tests/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml +++ /dev/null @@ -1,141 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_ospf_vrf sanity test - -- name: Set a fact for 'def_met_default' - ansible.builtin.set_fact: - def_met_default: default - when: imagetag is not search("I7") - -- name: "Setup: disable features for initial cleanup" - loop: - - ospf - - bfd - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- name: Enable features - loop: - - ospf - - bfd - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: enabled - -- block: - - name: Configure OSPF VRF - register: result - cisco.nxos.nxos_ospf_vrf: &id001 - ospf: 1 - router_id: 192.0.2.1 - timer_throttle_spf_start: 50 - timer_throttle_spf_hold: 1000 - timer_throttle_spf_max: 2000 - timer_throttle_lsa_start: 60 - timer_throttle_lsa_hold: 1100 - timer_throttle_lsa_max: 3000 - vrf: test - bfd: enable - passive_interface: true - state: present - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf_vrf: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Configure OSPF VRF - register: result - cisco.nxos.nxos_ospf_vrf: &id003 - ospf: 2 - auto_cost: 5000 - timer_throttle_spf_hold: 1100 - timer_throttle_lsa_hold: 2220 - timer_throttle_lsa_max: 2222 - default_metric: 1000 - log_adjacency: log - vrf: default - bfd: disable - passive_interface: true - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf_vrf: *id003 - - - ansible.builtin.assert: *id004 - - - name: Configure OSPF VRF - register: result - cisco.nxos.nxos_ospf_vrf: &id005 - ospf: 2 - auto_cost: default - default_metric: "{{def_met_default|default(omit)}}" - log_adjacency: default - timer_throttle_spf_hold: default - passive_interface: false - vrf: default - state: present - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf_vrf: *id005 - - - ansible.builtin.assert: *id004 - - - name: Unconfigure OSPF VRF - register: result - cisco.nxos.nxos_ospf_vrf: &id006 - ospf: 2 - vrf: default - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf_vrf: *id006 - - - ansible.builtin.assert: *id004 - when: def_met_default is defined - - - name: Unconfigure OSPF VRF - register: result - cisco.nxos.nxos_ospf_vrf: &id007 - ospf: 1 - vrf: test - state: absent - - - ansible.builtin.assert: *id002 - - - name: Check idempotence - register: result - cisco.nxos.nxos_ospf_vrf: *id007 - - - ansible.builtin.assert: *id004 - when: def_met_default is defined - always: - - name: Disable features - loop: - - ospf - - bfd - ignore_errors: true - cisco.nxos.nxos_feature: - feature: "{{ item }}" - state: disabled - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_ospf_vrf sanity test diff --git a/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml b/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml index 86a6c0c46..36a4cf45c 100644 --- a/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_pim_interface/tests/common/sanity.yaml @@ -30,12 +30,13 @@ - default interface {{ testint }} - name: Ensure {{testint}} is layer3 - cisco.nxos.nxos_interface: - interface: "{{ testint }}" - mode: layer3 - description: Configured by Ansible - Layer3 - admin_state: up - state: present + cisco.nxos.nxos_interfaces: + config: + - name: "{{ testint }}" + mode: layer3 + description: Configured by Ansible - Layer3 + enabled: true + state: merged - block: - name: Configure nxos_pim_interface state absent diff --git a/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml b/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml index 82530fa8b..916fc90a8 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml @@ -109,58 +109,3 @@ - name: Teardown nxos_config: *clear - -# hit CustomNetworkConfig -- block: - - name: Create static route - cisco.nxos.nxos_static_route: - prefix: "192.168.20.64/24" - next_hop: "192.0.2.3" - route_name: testing - pref: 100 - tag: 5500 - vrf: testing - provider: "{{ connection }}" - register: result - - - ansible.builtin.assert: &true - that: - - "result.changed == true" - - - name: Remove static route - cisco.nxos.nxos_static_route: - prefix: "192.168.20.64/24" - next_hop: "192.0.2.3" - route_name: testing - pref: 100 - tag: 5500 - vrf: testing - state: absent - provider: "{{ connection }}" - register: result - - - ansible.builtin.assert: *true - - always: - - name: Remove static route - cisco.nxos.nxos_static_route: - prefix: "192.168.20.64/24" - next_hop: "192.0.2.3" - route_name: testing - pref: 100 - tag: 5500 - vrf: testing - state: absent - provider: "{{ connection }}" - ignore_errors: true - - - name: Remove static route aggregate - cisco.nxos.nxos_static_route: - aggregate: - - prefix: "192.168.22.64/24" - next_hop: "192.0.2.3" - - prefix: "192.168.24.64/24" - next_hop: "192.0.2.3" - state: absent - provider: "{{ connection }}" - ignore_errors: true diff --git a/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml b/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml index 9908e2464..6a496d0f3 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml @@ -1,7 +1,6 @@ --- # nxos_command -> ComplexList # nxos_config -> to_list -# nxos_interface -> conditional, remove_default_spec - ansible.builtin.debug: msg: START connection={{ ansible_connection }} common/common_utils.yaml @@ -58,49 +57,6 @@ register: result -- name: Check intent arguments - cisco.nxos.nxos_interface: - name: "{{ testint2 }}" - admin_state: up - tx_rate: ge(0) - rx_rate: ge(0) - provider: "{{ connection }}" - register: result - -- ansible.builtin.assert: - that: - - "result.failed == false" - -- name: Check intent arguments (failed condition) - cisco.nxos.nxos_interface: - name: "{{ testint2 }}" - admin_state: down - tx_rate: lt(0) - rx_rate: lt(0) - provider: "{{ connection }}" - ignore_errors: true - register: result - -- ansible.builtin.assert: - that: - - "result.failed == true" - - "'tx_rate lt(0)' in result.failed_conditions" - - "'rx_rate lt(0)' in result.failed_conditions" - -- name: Aggregate definition of interface - cisco.nxos.nxos_interface: - aggregate: - - name: "{{ testint1 }}" - description: "Test aggregation on first interface" - - name: "{{ testint2 }}" - mode: layer3 - provider: "{{ connection }}" - register: result - -- ansible.builtin.assert: - that: - - "result.changed == true" - - name: "Teardown: put interfaces into a default state" cisco.nxos.nxos_config: lines: diff --git a/tests/integration/targets/nxos_static_route/defaults/main.yaml b/tests/integration/targets/nxos_static_route/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/tests/integration/targets/nxos_static_route/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/tests/integration/targets/nxos_static_route/meta/main.yml b/tests/integration/targets/nxos_static_route/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_static_route/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_static_route/tasks/cli.yaml b/tests/integration/targets/nxos_static_route/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_static_route/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/tests/integration/targets/nxos_static_route/tasks/main.yaml b/tests/integration/targets/nxos_static_route/tasks/main.yaml deleted file mode 100644 index c9e70304e..000000000 --- a/tests/integration/targets/nxos_static_route/tasks/main.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Run the CLI and NX-API tests - block: - - name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - always: - - name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/tests/integration/targets/nxos_static_route/tasks/nxapi.yaml b/tests/integration/targets/nxos_static_route/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_static_route/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/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml b/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml deleted file mode 100644 index 68a135e23..000000000 --- a/tests/integration/targets/nxos_static_route/tests/common/sanity.yaml +++ /dev/null @@ -1,213 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_static_route sanity test - -- name: Set a fact for 'test_track_feature' - ansible.builtin.set_fact: - test_track_feature: true - -- name: Configure track - register: cmd_result - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - track 1 ip sla 1 - -- ansible.builtin.debug: - msg: cmd result {{ cmd_result }} - -- name: Set a fact for 'test_track_feature' - ansible.builtin.set_fact: - test_track_feature: false - when: cmd_result.failed - -- ansible.builtin.debug: - msg: Test Track Feature {{ test_track_feature }} - -- name: Setup and teardown, remove test routes if present - with_items: "{{ vrfs }}" - ignore_errors: true - cisco.nxos.nxos_static_route: &id009 - aggregate: - - prefix: 192.168.1.164/32 - next_hop: 192.0.2.3 - - - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - - - prefix: 192.168.22.64/24 - next_hop: 192.0.2.3 - - - prefix: 192.168.24.64/24 - next_hop: 192.0.2.3 - vrf: "{{ item }}" - state: absent - -- name: Setup noise routes to ensure testing while non-test routes present - with_items: "{{ vrfs }}" - cisco.nxos.nxos_static_route: - prefix: 192.168.1.164/32 - next_hop: 192.0.2.3 - vrf: "{{ item }}" - state: present - -- block: - - name: Create static route - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_static_route: &id001 - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: testing - pref: 100 - tag: 5500 - vrf: "{{ item }}" - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Configure static idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_static_route: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Change static route - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_static_route: &id003 - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: default - pref: 10 - tag: default - vrf: "{{ item }}" - - - ansible.builtin.assert: *id002 - - - name: Change idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_static_route: *id003 - - - ansible.builtin.assert: *id004 - - - name: Configure static route with track - with_items: "{{ vrfs }}" - register: result - when: test_track_feature - cisco.nxos.nxos_static_route: &id005 - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: default - pref: 10 - tag: default - track: 1 - vrf: "{{ item }}" - - - ansible.builtin.assert: *id002 - when: test_track_feature - - - name: Config track idempotence - with_items: "{{ vrfs }}" - register: result - when: test_track_feature - cisco.nxos.nxos_static_route: *id005 - - - ansible.builtin.assert: *id004 - when: test_track_feature - - - name: Configure static route with not configured track - with_items: "{{ vrfs }}" - register: result - ignore_errors: true - when: test_track_feature - cisco.nxos.nxos_static_route: - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: default - pref: 10 - tag: default - track: 2 - vrf: "{{ item }}" - - - ansible.builtin.assert: - that: - - result.failed == True - when: test_track_feature - - - name: Remove static route - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_static_route: &id006 - prefix: 192.168.20.64/24 - next_hop: 192.0.2.3 - route_name: testing - pref: 100 - vrf: "{{ item }}" - state: absent - - - ansible.builtin.assert: *id002 - - - name: Remove idempotence - with_items: "{{ vrfs }}" - register: result - cisco.nxos.nxos_static_route: *id006 - - - ansible.builtin.assert: *id004 - - - name: Configure static route(aggregate) - register: result - cisco.nxos.nxos_static_route: &id007 - aggregate: - - prefix: 192.168.22.64/24 - next_hop: 192.0.2.3 - - - prefix: 192.168.24.64/24 - next_hop: 192.0.2.3 - - - ansible.builtin.assert: *id002 - - - name: Configure static route aggregate(idempotence) - register: result - cisco.nxos.nxos_static_route: *id007 - - - ansible.builtin.assert: *id004 - - - name: Remove static route aggregate - register: result - cisco.nxos.nxos_static_route: &id008 - aggregate: - - prefix: 192.168.22.64/24 - next_hop: 192.0.2.3 - - - prefix: 192.168.24.64/24 - next_hop: 192.0.2.3 - state: absent - - - ansible.builtin.assert: *id002 - - - name: Remove static route aggregate(idempotence) - register: result - cisco.nxos.nxos_static_route: *id008 - - - ansible.builtin.assert: *id004 - always: - - name: Remove track - ignore_errors: true - when: test_track_feature - cisco.nxos.nxos_config: - lines: - - no track 1 - - - name: Teardown test routes - with_items: "{{ vrfs }}" - ignore_errors: true - cisco.nxos.nxos_static_route: *id009 - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_static_route sanity test diff --git a/tests/integration/targets/nxos_vlan/defaults/main.yaml b/tests/integration/targets/nxos_vlan/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_vlan/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_vlan/meta/main.yml b/tests/integration/targets/nxos_vlan/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_vlan/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_vlan/tasks/cli.yaml b/tests/integration/targets/nxos_vlan/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_vlan/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/tests/integration/targets/nxos_vlan/tasks/main.yaml b/tests/integration/targets/nxos_vlan/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_vlan/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/tests/integration/targets/nxos_vlan/tasks/nxapi.yaml b/tests/integration/targets/nxos_vlan/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_vlan/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/tests/integration/targets/nxos_vlan/tests/common/agg.yaml b/tests/integration/targets/nxos_vlan/tests/common/agg.yaml deleted file mode 100644 index 57ee9459d..000000000 --- a/tests/integration/targets/nxos_vlan/tests/common/agg.yaml +++ /dev/null @@ -1,122 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/agg.yaml - -- name: Setup - remove VLAN used in test - ignore_errors: true - cisco.nxos.nxos_config: &id005 - lines: - - no vlan 102 - - no vlan 103 - - no vlan 104 - -- name: Configure VLAN with aggregate - register: result - cisco.nxos.nxos_vlan: &id001 - aggregate: - - name: app02 - vlan_id: 102 - - - name: app03 - vlan_id: 103 - vlan_state: active - admin_state: up - -- ansible.builtin.assert: - that: - - result.changed == true - - '"vlan 102" in result.commands' - - '"vlan 103" in result.commands' - - '"no shutdown" in result.commands' - - '"state active" in result.commands' - -- name: Conf1 - idempotence - register: result - cisco.nxos.nxos_vlan: *id001 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Change property of existing VLAN - admin_state down - register: result - cisco.nxos.nxos_vlan: &id002 - aggregate: - - name: app02 - vlan_id: 102 - - - name: app03 - vlan_id: 103 - vlan_state: active - admin_state: down - -- ansible.builtin.assert: - that: - - result.changed == true - - '"vlan 102" in result.commands' - - '"vlan 103" in result.commands' - - '"shutdown" in result.commands' - -- name: Conf2 - idempotence - register: result - cisco.nxos.nxos_vlan: *id002 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Purge - register: result - cisco.nxos.nxos_vlan: &id003 - vlan_id: 1 - purge: true - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no vlan 102" in result.commands' - - '"no vlan 103" in result.commands' - -- name: Purge - idempotence - register: result - cisco.nxos.nxos_vlan: *id003 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Setup for purge test with aggregate add - cisco.nxos.nxos_vlan: - vlan_id: 104 - purge: true - -- name: Purge 104 with aggregate add 102-103 - register: result - cisco.nxos.nxos_vlan: &id004 - aggregate: - - vlan_id: 102 - - - vlan_id: 103 - purge: true - -- ansible.builtin.assert: - that: - - result.changed == true - - '"vlan 102" in result.commands' - - '"vlan 103" in result.commands' - - '"no vlan 104" in result.commands' - -- name: Purge_add - idempotence - register: result - cisco.nxos.nxos_vlan: *id004 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Teardown - ignore_errors: true - cisco.nxos.nxos_config: *id005 - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }}/agg.yaml diff --git a/tests/integration/targets/nxos_vlan/tests/common/interface.yaml b/tests/integration/targets/nxos_vlan/tests/common/interface.yaml deleted file mode 100644 index e1cbe3bbd..000000000 --- a/tests/integration/targets/nxos_vlan/tests/common/interface.yaml +++ /dev/null @@ -1,129 +0,0 @@ ---- -- name: Set a fact for 'testint1' - ansible.builtin.set_fact: - testint1: "{{ nxos_int1 }}" - -- name: Set a fact for 'testint2' - ansible.builtin.set_fact: - testint2: "{{ nxos_int2 }}" - -- name: Setup - remove VLAN used in test - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - no vlan 100 - -- name: Setup - remove VLAN from interfaces used in test(part1) - cisco.nxos.nxos_config: - lines: - - no switchport access vlan 100 - parents: switchport - before: interface {{ testint1 }} - -- name: Setup - remove VLAN from interfaces used in test(part2) - cisco.nxos.nxos_config: - lines: - - no switchport access vlan 100 - parents: switchport - before: interface {{ testint2 }} - -- name: Create VLAN - cisco.nxos.nxos_vlan: - vlan_id: 100 - -- name: Add interfaces to VLAN and check intent (config + intent) - register: result - cisco.nxos.nxos_vlan: &id001 - vlan_id: 100 - interfaces: - - "{{ testint1 }}" - - "{{ testint2 }}" - associated_interfaces: - - "{{ testint1 }}" - - "{{ testint2 }}" - -- ansible.builtin.assert: - that: - - result.changed == true - - '"interface {{ testint1 }}" in result.commands' - - '"switchport" in result.commands' - - '"switchport mode access" in result.commands' - - '"switchport access vlan 100" in result.commands' - - '"interface {{ testint2 }}" in result.commands' - - '"switchport" in result.commands' - - '"switchport mode access" in result.commands' - - '"switchport access vlan 100" in result.commands' - -- name: Add interfaces to vlan(idempotence) - register: result - cisco.nxos.nxos_vlan: *id001 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Check interfaces intent - register: result - cisco.nxos.nxos_vlan: - vlan_id: 100 - associated_interfaces: - - "{{ testint1 }}" - - "{{ testint2 }}" - -- ansible.builtin.assert: - that: - - result.failed == false - -- name: Check interfaces intent fail - register: result - ignore_errors: true - cisco.nxos.nxos_vlan: - vlan_id: 100 - associated_interfaces: - - test - -- ansible.builtin.assert: - that: - - result.failed == True - -- name: Remove interface from VLAN - register: result - cisco.nxos.nxos_vlan: &id002 - vlan_id: 100 - interfaces: - - "{{ testint2 }}" - -- ansible.builtin.assert: - that: - - result.changed == true - - '"interface {{ testint1 }}" in result.commands' - - '"switchport" in result.commands' - - '"switchport mode access" in result.commands' - - '"no switchport access vlan 100" in result.commands' - -- name: Remove interface from vlan(idempotence) - register: result - cisco.nxos.nxos_vlan: *id002 - -- ansible.builtin.assert: - that: - - result.changed == false - -- name: Teardown(part1) - cisco.nxos.nxos_config: - lines: - - no vlan 100 - -- name: Teardown - remove VLAN from interfaces used in test(part1) - cisco.nxos.nxos_config: - lines: - - no switchport access vlan 100 - parents: switchport - before: interface {{ testint1 }} - -- name: Teardown - remove VLAN from interfaces used in test(part2) - cisco.nxos.nxos_config: - lines: - - no switchport access vlan 100 - parents: switchport - before: interface {{ testint2 }} diff --git a/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml b/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml deleted file mode 100644 index 2ffcf0d5e..000000000 --- a/tests/integration/targets/nxos_vlan/tests/common/sanity.yaml +++ /dev/null @@ -1,230 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_vlan sanity test - -- name: Set a fact for 'testint1' - ansible.builtin.set_fact: - testint1: "{{ nxos_int1 }}" - -- name: Set a fact for 'testint2' - ansible.builtin.set_fact: - testint2: "{{ nxos_int2 }}" - -- block: - - name: Install and enable 'feature-set fabricpath' - when: platform is search('N5K|N7K') - cisco.nxos.nxos_config: - lines: - - install feature-set fabricpath - - feature-set fabricpath - - - name: Enable 'feature vn-segment-vlan-based' - when: platform is search('N9K') - cisco.nxos.nxos_config: - commands: - - feature vn-segment-vlan-based - match: none - - - name: Vlan teardown - ignore_errors: true - cisco.nxos.nxos_vlan: &id013 - vlan_range: 2-200 - state: absent - - - name: Ensure a range of vlans are present on the switch - register: result - cisco.nxos.nxos_vlan: &id001 - vlan_range: 2-10,20,50,55-60,100-150 - - - ansible.builtin.assert: &id002 - that: - - result.changed == true - - - name: Vlan idempotence - register: result - cisco.nxos.nxos_vlan: *id001 - - - ansible.builtin.assert: &id004 - that: - - result.changed == false - - - name: Ensure VLAN 50 exists with the name web and is in the shutdown state - register: result - when: platform is search('N9K') - cisco.nxos.nxos_vlan: &id003 - vlan_id: 50 - vlan_state: suspend - admin_state: down - name: WEB - mapped_vni: 5555 - - - ansible.builtin.assert: *id002 - when: platform is search('N9K') - - - name: Web1 idempotence - register: result - when: platform is search('N9K') - cisco.nxos.nxos_vlan: *id003 - - - ansible.builtin.assert: *id004 - when: platform is search('N9K') - - - name: Change name and vni to default - register: result - when: platform is search('N9K') - cisco.nxos.nxos_vlan: &id005 - vlan_id: 50 - vlan_state: active - admin_state: up - name: default - mapped_vni: default - - - ansible.builtin.assert: *id002 - when: platform is search('N9K') - - - name: Web2 idempotence - register: result - when: platform is search('N9K') - cisco.nxos.nxos_vlan: *id005 - - - ansible.builtin.assert: *id004 - when: platform is search('N9K') - - - name: Ensure VLAN 50 exists with the name web and is in the shutdown state - register: result - when: platform is search('N3K|N7K') - cisco.nxos.nxos_vlan: &id006 - vlan_id: 50 - vlan_state: suspend - admin_state: down - name: WEB - - - ansible.builtin.assert: *id002 - when: platform is search('N3K|N7K') - - - name: Web3 idempotence - register: result - when: platform is search('N3K|N7K') - cisco.nxos.nxos_vlan: *id006 - - - ansible.builtin.assert: *id004 - when: platform is search('N3K|N7K') - - - name: Change name to default - register: result - when: platform is search('N3K|N7K') - cisco.nxos.nxos_vlan: &id007 - vlan_id: 50 - vlan_state: active - admin_state: up - name: default - - - ansible.builtin.assert: *id002 - when: platform is search('N3K|N7K') - - - name: Web4 idempotence - register: result - when: platform is search('N3K|N7K') - cisco.nxos.nxos_vlan: *id007 - - - ansible.builtin.assert: *id004 - when: platform is search('N3K|N7K') - - - name: Change mode - register: result - when: platform is search('N5K|N7K') - cisco.nxos.nxos_vlan: &id008 - vlan_id: 50 - mode: fabricpath - - - ansible.builtin.assert: *id002 - when: platform is search('N5K|N7K') - - - name: Mode1 idempotence - register: result - when: platform is search('N5K|N7K') - cisco.nxos.nxos_vlan: *id008 - - - ansible.builtin.assert: *id004 - when: platform is search('N5K|N7K') - - - name: Change mode again - register: result - when: platform is search('N5K|N7K') - cisco.nxos.nxos_vlan: &id009 - vlan_id: 50 - mode: ce - - - ansible.builtin.assert: *id002 - when: platform is search('N5K|N7K') - - - name: Mode2 idempotence - register: result - when: platform is search('N5K|N7K') - cisco.nxos.nxos_vlan: *id009 - - - ansible.builtin.assert: *id004 - when: platform is search('N5K|N7K') - - - name: Ensure VLAN is not on the device - register: result - cisco.nxos.nxos_vlan: &id010 - vlan_id: 50 - state: absent - - - ansible.builtin.assert: *id002 - - - name: No VLAN idempotence - register: result - cisco.nxos.nxos_vlan: *id010 - - - ansible.builtin.assert: *id004 - - - name: Add interfaces to VLAN - register: result - cisco.nxos.nxos_vlan: &id011 - vlan_id: 101 - vlan_state: suspend - interfaces: - - "{{ testint1 }}" - - "{{ testint2 }}" - - - ansible.builtin.assert: *id002 - - - name: Addint idempotence - register: result - cisco.nxos.nxos_vlan: *id011 - - - ansible.builtin.assert: *id004 - - - name: Remove interfaces from VLAN - register: result - cisco.nxos.nxos_vlan: &id012 - vlan_id: 101 - interfaces: default - - - ansible.builtin.assert: *id002 - - - name: Remint idempotence - register: result - cisco.nxos.nxos_vlan: *id012 - - - ansible.builtin.assert: *id004 - always: - - name: Remove int from VLAN - ignore_errors: true - cisco.nxos.nxos_vlan: *id012 - - - name: VLAN teardown final - ignore_errors: true - cisco.nxos.nxos_vlan: *id013 - - - name: Disable 'feature vn-segment-vlan-based' - ignore_errors: true - when: platform is search('N9K') - cisco.nxos.nxos_feature: - feature: vn-segment-vlan-based - state: disabled - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_vlan sanity test diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index 3a367994c..245bf89fc 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -1,32 +1,6 @@ -plugins/modules/nxos_acl.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_acl.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_acl_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_acl_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_l2_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_l2_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_l3_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_l3_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_linkagg.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_linkagg.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_lldp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_lldp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict 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 supported in `deprecated` dict -plugins/modules/nxos_ospf.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_ospf.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_static_route.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_static_route.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_vlan.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_vlan.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_ospf_vrf.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_ospf_vrf.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +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_smu.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_smu.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/modules/nxos_interface_ospf.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/nxos_interface_ospf.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict 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 diff --git a/tests/unit/modules/network/nxos/test_nxos_acl.py b/tests/unit/modules/network/nxos/test_nxos_acl.py deleted file mode 100644 index 34a7d6679..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_acl.py +++ /dev/null @@ -1,100 +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 . - -# Make coding more python3-ish -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -import json - -from ansible_collections.cisco.nxos.plugins.modules import nxos_acl -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosAclModule(TestNxosModule): - - module = nxos_acl - - def setUp(self): - super(TestNxosAclModule, self).setUp() - - self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl.run_commands", - ) - self.run_commands = self.mock_run_commands.start() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl.load_config", - ) - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestNxosAclModule, self).tearDown() - self.mock_run_commands.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None, device=""): - def load_from_file(*args, **kwargs): - module, commands = args - output = list() - - for item in commands: - try: - obj = json.loads(item) - command = obj["command"] - except ValueError: - command = item - filename = "%s.txt" % str(command).split(" | ", 1)[0].replace(" ", "_") - output.append(load_fixture("nxos_acl", filename)) - return output - - self.run_commands.side_effect = load_from_file - self.load_config.return_value = None - - def test_nxos_acl(self): - set_module_args( - dict( - name="ANSIBLE", - seq=10, - action="permit", - proto="tcp", - src="192.0.2.1/24", - dest="any", - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["ip access-list ANSIBLE", "10 permit tcp 192.0.2.1/24 any"], - ) - - def test_nxos_acl_remove(self): - set_module_args(dict(name="copp-system-p-acl-bgp", seq=10, state="absent")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["ip access-list copp-system-p-acl-bgp", "no 10"], - ) - - def test_nxos_acl_delete_acl(self): - set_module_args(dict(name="copp-system-p-acl-bgp", state="delete_acl")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["no ip access-list copp-system-p-acl-bgp"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interface.py b/tests/unit/modules/network/nxos/test_nxos_acl_interface.py deleted file mode 100644 index 26011a376..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interface.py +++ /dev/null @@ -1,96 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -__metacl_interfaceass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_acl_interface -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosAclInterfaceModule(TestNxosModule): - - module = nxos_acl_interface - - def setUp(self): - super(TestNxosAclInterfaceModule, self).setUp() - - self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl_interface.run_commands", - ) - self.run_commands = self.mock_run_commands.start() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_acl_interface.load_config", - ) - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestNxosAclInterfaceModule, self).tearDown() - self.mock_run_commands.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None, device=""): - def load_from_file(*args, **kwargs): - module, commands = args - output = list() - - for item in commands: - try: - command = item["command"] - except ValueError: - command = item - filename = "%s.txt" % str(command).split(" | ", 1)[0].replace(" ", "_") - output.append(load_fixture("nxos_acl_interface", filename)) - return output - - self.run_commands.side_effect = load_from_file - self.load_config.return_value = None - - def test_nxos_acl_interface(self): - set_module_args(dict(name="ANSIBLE", interface="ethernet1/41", direction="egress")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["interface ethernet1/41", "ip access-group ANSIBLE out"], - ) - - def test_nxos_acl_interface_remove(self): - set_module_args( - dict( - name="copp-system-p-acl-bgp", - interface="ethernet1/41", - direction="egress", - state="absent", - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface ethernet1/41", - "no ip access-group copp-system-p-acl-bgp out", - ], - ) diff --git a/tests/unit/modules/network/nxos/test_nxos_interface.py b/tests/unit/modules/network/nxos/test_nxos_interface.py deleted file mode 100644 index 7b8854dd2..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_interface.py +++ /dev/null @@ -1,107 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_interface -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosInterfaceModule(TestNxosModule): - - module = nxos_interface - - def setUp(self): - super(TestNxosInterfaceModule, self).setUp() - self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface.run_commands", - ) - self.run_commands = self.mock_run_commands.start() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface.load_config", - ) - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestNxosInterfaceModule, self).tearDown() - self.mock_run_commands.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None, device=""): - module_name = self.module.__name__.rsplit(".", 1)[1] - - def load_from_file(*args, **kwargs): - module, commands = args - output = list() - - for command in commands: - if type(command) == dict: - command = command["command"] - filename = str(command).split(" | ", 1)[0].replace(" ", "_").replace("/", "_") - print(filename) - output.append(load_fixture(module_name, filename)) - return output - - self.load_config.return_value = None - self.run_commands.side_effect = load_from_file - - def test_nxos_interface_up(self): - set_module_args(dict(interface="loopback0")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["interface loopback0", "no shutdown"]) - - def test_nxos_interface_down(self): - set_module_args(dict(interface="loopback0", admin_state="down")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["interface loopback0", "shutdown"]) - - def test_nxos_interface_delete(self): - set_module_args(dict(interface="loopback0", state="absent")) - result = self.execute_module(changed=False) - self.assertEqual(result["commands"], []) - - def test_nxos_interface_type(self): - set_module_args(dict(interface_type="loopback", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["no interface loopback0"]) - - def test_nxos_interface_mtu(self): - set_module_args(dict(interface="Ethernet2/1", mode="layer2", mtu="1800")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet2/1", - "switchport", - "mtu 1800", - "interface Ethernet2/1", - "no shutdown", - ], - ) - - def test_nxos_interface_speed_idempotence(self): - set_module_args(dict(interface="Ethernet2/1", speed="1000")) - result = self.execute_module(changed=False) - self.assertEqual(result["commands"], []) diff --git a/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py b/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py deleted file mode 100644 index 3ade69e7e..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_interface_ospf.py +++ /dev/null @@ -1,266 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_interface_ospf -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosInterfaceOspfModule(TestNxosModule): - - module = nxos_interface_ospf - - def setUp(self): - super(TestNxosInterfaceOspfModule, self).setUp() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface_ospf.get_config", - ) - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_interface_ospf.load_config", - ) - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestNxosInterfaceOspfModule, self).tearDown() - self.mock_get_config.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None, device=""): - module_name = self.module.__name__.rsplit(".", 1)[1] - self.get_config.return_value = load_fixture(module_name, "config.cfg") - self.load_config.return_value = None - - def test_nxos_interface_ospf(self): - set_module_args(dict(interface="ethernet1/32", ospf=1, area=1)) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/32", - "ip router ospf 1 area 0.0.0.1", - ], - ) - - def test_bfd_1(self): - # default -> enable - set_module_args(dict(interface="ethernet1/33", ospf=1, area=1, bfd="enable")) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/33", - "ip router ospf 1 area 0.0.0.1", - "ip ospf bfd", - ], - ) - - # default -> disable - set_module_args(dict(interface="ethernet1/33", ospf=1, area=1, bfd="disable")) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/33", - "ip router ospf 1 area 0.0.0.1", - "ip ospf bfd disable", - ], - ) - - def test_bfd_2(self): - # default -> default - set_module_args(dict(interface="ethernet1/33.101", ospf=1, area=1, bfd="default")) - self.execute_module(changed=False) - - # enable -> default - set_module_args(dict(interface="ethernet1/36", ospf=1, area=1, bfd="default")) - self.execute_module(changed=True, commands=["interface Ethernet1/36", "no ip ospf bfd"]) - - # disable -> default - set_module_args(dict(interface="ethernet1/37", ospf=1, area=1, bfd="default")) - self.execute_module(changed=True, commands=["interface Ethernet1/37", "no ip ospf bfd"]) - - def test_bfd_3(self): - # enable -> idempotence - set_module_args(dict(interface="ethernet1/36", ospf=1, area=1, bfd="enable")) - self.execute_module(changed=False) - - # disable -> idempotence - set_module_args(dict(interface="ethernet1/37", ospf=1, area=1, bfd="disable")) - self.execute_module(changed=False) - - def test_bfd_4(self): - # None -> absent - set_module_args(dict(interface="ethernet1/33.101", ospf=1, area=1, state="absent")) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/33.101", - "no ip router ospf 1 area 0.0.0.1", - ], - ) - - # enable -> absent - set_module_args( - dict( - interface="ethernet1/36", - ospf=1, - area=1, - bfd="enable", - state="absent", - ), - ) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/36", - "no ip router ospf 1 area 0.0.0.1", - "no ip ospf bfd", - ], - ) - - # disable -> absent - set_module_args( - dict( - interface="ethernet1/37", - ospf=1, - area=1, - bfd="disable", - state="absent", - ), - ) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/37", - "no ip router ospf 1 area 0.0.0.1", - "no ip ospf bfd", - ], - ) - - def test_absent_1(self): - # area only -> absent - set_module_args(dict(interface="ethernet1/33.101", ospf=1, area=1, state="absent")) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/33.101", - "no ip router ospf 1 area 0.0.0.1", - ], - ) - - # None -> absent - set_module_args(dict(interface="ethernet1/33", ospf=1, area=1, state="absent")) - self.execute_module(changed=False) - - def test_loopback_interface_failed(self): - set_module_args(dict(interface="loopback0", ospf=1, area=0, passive_interface=True)) - self.execute_module(failed=True, changed=False) - set_module_args(dict(interface="loopback0", ospf=1, area=0, network="broadcast")) - self.execute_module(failed=True, changed=False) - - def test_nxos_interface_ospf_passive(self): - # default -> True - set_module_args( - dict( - interface="ethernet1/33", - ospf=1, - area=1, - passive_interface=True, - ), - ) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/33", - "ip router ospf 1 area 0.0.0.1", - "ip ospf passive-interface", - ], - ) - # default -> False - set_module_args( - dict( - interface="ethernet1/33", - ospf=1, - area=1, - passive_interface=False, - ), - ) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/33", - "ip router ospf 1 area 0.0.0.1", - "no ip ospf passive-interface", - ], - ) - # True -> False - set_module_args( - dict( - interface="ethernet1/34", - ospf=1, - area=1, - passive_interface=False, - ), - ) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/34", - "no ip ospf passive-interface", - ], - ) - # True -> default (absent) - set_module_args(dict(interface="ethernet1/34", ospf=1, area=1, state="absent")) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/34", - "no ip router ospf 1 area 0.0.0.1", - "default ip ospf passive-interface", - ], - ) - # False -> True - set_module_args( - dict( - interface="ethernet1/35", - ospf=1, - area=1, - passive_interface=True, - ), - ) - self.execute_module( - changed=True, - commands=["interface Ethernet1/35", "ip ospf passive-interface"], - ) - # False -> default (absent) - set_module_args(dict(interface="ethernet1/35", ospf=1, area=1, state="absent")) - self.execute_module( - changed=True, - commands=[ - "interface Ethernet1/35", - "no ip router ospf 1 area 0.0.0.1", - "default ip ospf passive-interface", - ], - ) diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interface.py b/tests/unit/modules/network/nxos/test_nxos_l3_interface.py deleted file mode 100644 index 30dcfe1cb..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interface.py +++ /dev/null @@ -1,377 +0,0 @@ -# Copyright: (c) 2019, Olivier Blin -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_l3_interface -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosL3InterfaceModule(TestNxosModule): - - module = nxos_l3_interface - - def setUp(self): - super(TestNxosL3InterfaceModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_l3_interface.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_l3_interface.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosL3InterfaceModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.load_config.return_value = None - self.get_config.return_value = load_fixture("nxos_l3_interface", self.mode) - - def test_nxos_l3_interface_unknonw_ethernet(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/2", ipv4="192.168.0.1/24")) - result = self.execute_module(changed=False) - - # Add when missing - def test_nxos_l3_interface_add_missing_ipv4(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/1", ipv4="192.168.0.1/24")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["interface Ethernet1/1", "ip address 192.168.0.1/24", "exit"], - ) - - def test_nxos_l3_interface_add_missing_ipv4_on_e11(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="et1/1", ipv4="192.168.0.1/24")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["interface Ethernet1/1", "ip address 192.168.0.1/24", "exit"], - ) - - def test_nxos_l3_interface_add_missing_ipv6(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["interface Ethernet1/1", "ipv6 address 2001:db8::1/124", "exit"], - ) - - def test_nxos_l3_interface_add_missing_ipv4_and_ipv6(self): - self.mode = "ethernet_noshut" - set_module_args( - dict( - name="Ethernet1/1", - ipv4="192.168.0.1/24", - ipv6="2001:db8::1/124", - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "ip address 192.168.0.1/24", - "ipv6 address 2001:db8::1/124", - "exit", - ], - ) - - # Add when existing - def test_nxos_l3_interface_add_existing_ipv4(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv4="192.168.0.1/24")) - result = self.execute_module() - - def test_nxos_l3_interface_add_existing_ipv4_on_e11(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args(dict(name="et1/1", ipv4="192.168.0.1/24")) - result = self.execute_module() - - def test_nxos_l3_interface_add_existing_ipv6(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124")) - result = self.execute_module() - - def test_nxos_l3_interface_add_existing_ipv4_and_ipv6(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args( - dict( - name="Ethernet1/1", - ipv4="192.168.0.1/24", - ipv6="2001:db8::1/124", - ), - ) - result = self.execute_module() - - def test_nxos_l3_interface_new_ipv4_and_ipv6(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args( - dict( - name="Ethernet1/1", - ipv4="192.168.0.2/24", - ipv6="2001:db8::2/124", - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "ip address 192.168.0.2/24", - "ipv6 address 2001:db8::2/124", - "exit", - ], - ) - - # Add when existing with multiple IPv6 - def test_nxos_l3_interface_multiple_ipv6_add_first(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124")) - result = self.execute_module() - - def test_nxos_l3_interface_multiple_ipv6_add_last(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8:2::1/124")) - result = self.execute_module() - - # Add aggregate - def test_nxos_l3_interface_add_missing_with_empty_aggregate(self): - self.mode = "ethernet_noshut" - set_module_args(dict(aggregate=[])) - result = self.execute_module() - - def test_nxos_l3_interface_add_missing_with_aggregate(self): - self.mode = "ethernet_noshut" - set_module_args( - dict( - aggregate=[ - dict( - name="Ethernet1/1", - ipv4="192.168.0.2/24", - ipv6="2001:db8::2/124", - ), - dict(name="Ethernet1/1", ipv6="2001:db8:1::2/124"), - dict(name="Ethernet1/1", ipv6="2001:db8:2::2/124"), - ], - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "ip address 192.168.0.2/24", - "ipv6 address 2001:db8::2/124", - "exit", - "interface Ethernet1/1", - "ipv6 address 2001:db8:1::2/124", - "exit", - "interface Ethernet1/1", - "ipv6 address 2001:db8:2::2/124", - "exit", - ], - ) - - # Rem when missing - def test_nxos_l3_interface_rem_missing_ipv4(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/1", ipv4="192.168.0.1/24", state="absent")) - result = self.execute_module() - - def test_nxos_l3_interface_rem_missing_ipv4_on_e11(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="et1/1", ipv4="192.168.0.1/24", state="absent")) - result = self.execute_module() - - def test_nxos_l3_interface_rem_missing_ipv6(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent")) - result = self.execute_module() - - def test_nxos_l3_interface_rem_missing_ipv4_and_ipv6(self): - self.mode = "ethernet_noshut" - set_module_args( - dict( - name="Ethernet1/1", - ipv4="192.168.0.1/24", - ipv6="2001:db8::1/124", - state="absent", - ), - ) - result = self.execute_module() - - # Rem when existing - def test_nxos_l3_interface_rem_existing_ipv4(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv4="192.168.0.1/24", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["interface Ethernet1/1", "no ip address 192.168.0.1/24", "exit"], - ) - - def test_nxos_l3_interface_rem_existing_ipv4_on_e11(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args(dict(name="et1/1", ipv4="192.168.0.1/24", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["interface Ethernet1/1", "no ip address 192.168.0.1/24", "exit"], - ) - - def test_nxos_l3_interface_rem_existing_ipv6(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "no ipv6 address 2001:db8::1/124", - "exit", - ], - ) - - def test_nxos_l3_interface_rem_existing_ipv4_and_ipv6(self): - self.mode = "ethernet_noshut_ipv4_ipv6" - set_module_args( - dict( - name="Ethernet1/1", - ipv4="192.168.0.1/24", - ipv6="2001:db8::1/124", - state="absent", - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "no ip address 192.168.0.1/24", - "no ipv6 address 2001:db8::1/124", - "exit", - ], - ) - - # Rem when existing with multiple IPv6 - def test_nxos_l3_interface_multiple_ipv6_rem_first(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8::1/124", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "no ipv6 address 2001:db8::1/124", - "exit", - ], - ) - - def test_nxos_l3_interface_multiple_ipv6_rem_last(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args(dict(name="Ethernet1/1", ipv6="2001:db8:2::1/124", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "no ipv6 address 2001:db8:2::1/124", - "exit", - ], - ) - - # Rem when missing with aggregate - def test_nxos_l3_interface_rem_with_empty_aggregate(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args(dict(aggregate=[], state="absent")) - result = self.execute_module() - - def test_nxos_l3_interface_rem_missing_with_aggregate(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args( - dict( - state="absent", - aggregate=[ - dict( - name="Ethernet1/1", - ipv4="192.168.0.2/24", - ipv6="2001:db8::2/124", - ), - dict(name="Ethernet1/1", ipv6="2001:db8:1::2/124"), - dict(name="Ethernet1/1", ipv6="2001:db8:2::2/124"), - ], - ), - ) - result = self.execute_module() - - # Rem when existing with aggregate - def test_nxos_l3_interface_rem_existing_with_aggregate(self): - self.mode = "ethernet_noshut_multiple_ipv6" - set_module_args( - dict( - state="absent", - aggregate=[ - dict( - name="Ethernet1/1", - ipv4="192.168.0.1/24", - ipv6="2001:db8::1/124", - ), - dict(name="Ethernet1/1", ipv6="2001:db8:1::1/124"), - dict(name="Ethernet1/1", ipv6="2001:db8:2::1/124"), - ], - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - [ - "interface Ethernet1/1", - "no ip address 192.168.0.1/24", - "no ipv6 address 2001:db8::1/124", - "exit", - "interface Ethernet1/1", - "no ipv6 address 2001:db8:1::1/124", - "exit", - "interface Ethernet1/1", - "no ipv6 address 2001:db8:2::1/124", - "exit", - ], - ) - - # Add itf only - def test_nxos_l3_interface_add_on_itf_only(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/1")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["interface Ethernet1/1"]) - - # Add unknown interface - def test_nxos_l3_interface_add_on_unknown_itf(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/2", ipv4="192.168.0.1/24")) - result = self.execute_module() - self.assertEqual(result["warnings"], ["Unknown interface Ethernet1/2"]) - - # Rem unknown interface - def test_nxos_l3_interface_rem_on_unknown_itf(self): - self.mode = "ethernet_noshut" - set_module_args(dict(name="Ethernet1/2", ipv4="192.168.0.1/24", state="absent")) - result = self.execute_module() - self.assertEqual(result["warnings"], ["Unknown interface Ethernet1/2"]) diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf.py b/tests/unit/modules/network/nxos/test_nxos_ospf.py deleted file mode 100644 index c1fce6527..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_ospf.py +++ /dev/null @@ -1,64 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_ospf -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, set_module_args - - -class TestNxosOspfModule(TestNxosModule): - - module = nxos_ospf - - def setUp(self): - super(TestNxosOspfModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosOspfModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.load_config.return_value = None - - def test_nxos_ospf_present(self): - set_module_args(dict(ospf=1, state="present")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["router ospf 1"]) - - def test_nxos_ospf_absent(self): - set_module_args(dict(ospf=1, state="absent")) - result = self.execute_module(changed=False) - self.assertEqual(result["commands"], []) diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py b/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py deleted file mode 100644 index 49989cd32..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_vrf.py +++ /dev/null @@ -1,118 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_ospf_vrf -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, set_module_args - - -class TestNxosOspfVrfModule(TestNxosModule): - - module = nxos_ospf_vrf - - def setUp(self): - super(TestNxosOspfVrfModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf_vrf.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_ospf_vrf.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosOspfVrfModule, self).tearDown() - self.mock_load_config.stop() - self.mock_get_config.stop() - - def load_fixtures(self, commands=None, device=""): - self.load_config.return_value = None - - def test_nxos_ospf_vrf_present(self): - set_module_args( - dict( - ospf=1, - vrf="test", - timer_throttle_spf_start=50, - timer_throttle_spf_hold=1000, - timer_throttle_spf_max=2000, - timer_throttle_lsa_start=60, - timer_throttle_lsa_hold=1100, - timer_throttle_lsa_max=3000, - bfd="enable", - state="present", - ), - ) - result = self.execute_module(changed=True) - self.assertEqual( - sorted(result["commands"]), - sorted( - [ - "router ospf 1", - "vrf test", - "timers throttle lsa 60 1100 3000", - "timers throttle spf 50 1000 2000", - "bfd", - ], - ), - ) - - def test_nxos_ospf_vrf_absent(self): - set_module_args(dict(ospf=1, vrf="test", state="absent")) - result = self.execute_module(changed=False) - self.assertEqual(result["commands"], []) - - def test_bfd_1(self): - self.get_config.return_value = "router ospf 1\n bfd\nrouter ospf 2" - # enable -> disable - set_module_args(dict(ospf=1, bfd="disable")) - self.execute_module(changed=True, commands=["router ospf 1", "no bfd"]) - - # disable -> enable - set_module_args(dict(ospf=2, bfd="enable")) - self.execute_module(changed=True, commands=["router ospf 2", "bfd"]) - - def test_bfd_2(self): - # enable idempotence - self.get_config.return_value = "router ospf 1\n bfd\nrouter ospf 2" - set_module_args(dict(ospf=1, bfd="enable")) - self.execute_module(changed=False) - - # disable idempotence - set_module_args(dict(ospf=2, bfd="disable")) - self.execute_module(changed=False) - - def test_bfd_3(self): - # absent tests - self.get_config.return_value = "router ospf 1\n bfd\nrouter ospf 2" - set_module_args(dict(ospf=1, state="absent")) - self.execute_module(changed=True, commands=["router ospf 1", "no bfd"]) - - # absent w/bfd disable - set_module_args(dict(ospf=2, state="absent")) - self.execute_module(changed=False) diff --git a/tests/unit/modules/network/nxos/test_nxos_static_route.py b/tests/unit/modules/network/nxos/test_nxos_static_route.py deleted file mode 100644 index 181249322..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_static_route.py +++ /dev/null @@ -1,114 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -from ansible_collections.cisco.nxos.plugins.modules import nxos_static_route -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosStaticRouteModule(TestNxosModule): - - module = nxos_static_route - - def setUp(self): - super(TestNxosStaticRouteModule, self).setUp() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_static_route.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_static_route.get_config", - ) - self.get_config = self.mock_get_config.start() - - def tearDown(self): - super(TestNxosStaticRouteModule, 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_static_route.cfg") - self.load_config.return_value = None - - def test_nxos_static_route_present(self): - set_module_args(dict(prefix="192.168.20.64/24", next_hop="192.0.2.3")) - self.execute_module(changed=True, commands=["ip route 192.168.20.0/24 192.0.2.3"]) - - def test_nxos_static_route_present_no_defaults(self): - set_module_args( - dict( - prefix="192.168.20.64/24", - next_hop="192.0.2.3", - route_name="testing", - pref=100, - ), - ) - self.execute_module( - changed=True, - commands=["ip route 192.168.20.0/24 192.0.2.3 name testing 100"], - ) - - def test_nxos_static_route_present_vrf(self): - set_module_args(dict(prefix="192.168.20.64/24", next_hop="192.0.2.3", vrf="test")) - self.execute_module( - changed=True, - sort=False, - commands=[ - "vrf context test", - "ip route 192.168.20.0/24 192.0.2.3", - ], - ) - - def test_nxos_static_route_no_change(self): - set_module_args(dict(prefix="10.10.30.64/24", next_hop="1.2.4.8")) - self.execute_module(changed=False, commands=[]) - - def test_nxos_static_route_absent(self): - set_module_args(dict(prefix="10.10.30.12/24", next_hop="1.2.4.8", state="absent")) - self.execute_module(changed=True, commands=["no ip route 10.10.30.0/24 1.2.4.8"]) - - def test_nxos_static_route_absent_no_change(self): - set_module_args(dict(prefix="192.168.20.6/24", next_hop="192.0.2.3", state="absent")) - self.execute_module(changed=False, commands=[]) - - def test_nxos_static_route_absent_vrf(self): - set_module_args( - dict( - prefix="10.11.12.13/14", - next_hop="15.16.17.18", - vrf="test", - state="absent", - ), - ) - self.execute_module( - changed=True, - sort=False, - commands=[ - "vrf context test", - "no ip route 10.8.0.0/14 15.16.17.18", - ], - ) diff --git a/tests/unit/modules/network/nxos/test_nxos_vlan.py b/tests/unit/modules/network/nxos/test_nxos_vlan.py deleted file mode 100644 index 403e265ce..000000000 --- a/tests/unit/modules/network/nxos/test_nxos_vlan.py +++ /dev/null @@ -1,235 +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 . - -# Make coding more python3-ish - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -import json - -from ansible_collections.cisco.nxos.plugins.modules import nxos_vlan -from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch - -from .nxos_module import TestNxosModule, load_fixture, set_module_args - - -class TestNxosVlanModule(TestNxosModule): - - module = nxos_vlan - - def setUp(self): - super(TestNxosVlanModule, self).setUp() - - self.mock_run_commands = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.run_commands", - ) - self.run_commands = self.mock_run_commands.start() - - self.mock_load_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.load_config", - ) - self.load_config = self.mock_load_config.start() - - self.mock_get_config = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.get_config", - ) - self.get_config = self.mock_get_config.start() - - self.mock_get_capabilities = patch( - "ansible_collections.cisco.nxos.plugins.modules.nxos_vlan.get_capabilities", - ) - self.get_capabilities = self.mock_get_capabilities.start() - self.get_capabilities.return_value = { - "device_info": {"network_os_platform": "N9K-9000v"}, - "network_api": "cliconf", - } - - def tearDown(self): - super(TestNxosVlanModule, self).tearDown() - self.mock_run_commands.stop() - self.mock_load_config.stop() - self.mock_get_config.stop() - self.mock_get_capabilities.stop() - - def load_fixtures(self, commands=None, device=""): - def load_from_file(*args, **kwargs): - module, commands = args - output = list() - - for item in commands: - try: - obj = json.loads(item) - command = obj["command"] - except ValueError: - command = item - filename = "%s.txt" % str(command).split(" | ", 1)[0].replace(" ", "_") - output.append(load_fixture("nxos_vlan", filename)) - return output - - def agg_load_from_file(*args, **kwargs): - """Load vlan output for aggregate/purge tests""" - return [load_fixture("nxos_vlan", "agg_show_vlan_brief.txt")] - - if "_agg_" in self._testMethodName: - self.run_commands.side_effect = agg_load_from_file - else: - self.run_commands.side_effect = load_from_file - - self.load_config.return_value = None - self.get_config.return_value = load_fixture("nxos_vlan", "config.cfg") - - def test_nxos_vlan_agg_1(self): - # Aggregate: vlan 4/5 exist -> Add 6 - set_module_args( - dict( - aggregate=[ - {"name": "_5_", "vlan_id": 5}, - {"name": "_6_", "vlan_id": 6}, - ], - ), - ) - self.execute_module( - changed=True, - commands=[ - "vlan 6", - "name _6_", - "state active", - "no shutdown", - "exit", - ], - ) - - def test_nxos_vlan_agg_2(self): - # Aggregate: vlan 4/5 exist -> Add none (idempotence) - set_module_args( - dict( - aggregate=[ - {"name": "_5_", "vlan_id": 5}, - {"name": "_4_", "vlan_id": 4}, - ], - ), - ) - self.execute_module(changed=False) - - def test_nxos_vlan_agg_3(self): - # Aggregate/Purge: vlan 4/5 exist -> Add 6, Purge 4 - set_module_args( - dict( - aggregate=[ - {"name": "_5_", "vlan_id": 5}, - {"name": "_6_", "vlan_id": 6}, - ], - purge=True, - ), - ) - self.execute_module( - changed=True, - commands=[ - "vlan 6", - "name _6_", - "state active", - "no shutdown", - "exit", - "no vlan 4", - ], - ) - - def test_nxos_vlan_agg_4(self): - # Aggregate/Purge: vlan 4/5 exist -> Purge None (idempotence) - set_module_args( - dict( - aggregate=[ - {"name": "_5_", "vlan_id": 5}, - {"name": "_4_", "vlan_id": 4}, - ], - ), - ) - self.execute_module(changed=False) - - def test_nxos_vlan_agg_5(self): - # Purge with Single Vlan: vlan 4/5 exist -> Add 6, Purge 4/5 - set_module_args(dict(vlan_id=6, name="_6_", purge=True)) - self.execute_module( - changed=True, - commands=[ - "vlan 6", - "name _6_", - "state active", - "no shutdown", - "exit", - "no vlan 4", - "no vlan 5", - ], - ) - - def test_nxos_vlan_agg_6(self): - # Purge All: vlan 4/5 exist -> Purge 4/5 - set_module_args(dict(vlan_id=1, purge=True)) - self.execute_module(changed=True, commands=["no vlan 4", "no vlan 5"]) - - def test_nxos_vlan_range(self): - set_module_args(dict(vlan_range="6-10")) - self.execute_module( - changed=True, - commands=["vlan 6", "vlan 7", "vlan 8", "vlan 9", "vlan 10"], - ) - - def test_nxos_vlan_range_absent(self): - set_module_args(dict(vlan_range="1-5", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["no vlan 1"]) - - def test_nxos_vlan_id(self): - set_module_args(dict(vlan_id="15", state="present")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["vlan 15", "state active", "no shutdown", "exit"], - ) - - def test_nxos_vlan_id_absent(self): - set_module_args(dict(vlan_id="1", state="absent")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["no vlan 1"]) - - def test_nxos_vlan_named_vlan(self): - set_module_args(dict(vlan_id="15", name="WEB")) - result = self.execute_module(changed=True) - self.assertEqual( - result["commands"], - ["vlan 15", "name WEB", "state active", "no shutdown", "exit"], - ) - - def test_nxos_vlan_shut_down(self): - set_module_args(dict(vlan_id="1", admin_state="down")) - result = self.execute_module(changed=True) - self.assertEqual(result["commands"], ["vlan 1", "shutdown", "exit"]) - - def test_nxos_vlan_no_change(self): - set_module_args( - dict( - vlan_id="1", - name="default", - vlan_state="active", - admin_state="up", - ), - ) - result = self.execute_module(changed=False) - self.assertEqual(result["commands"], []) From cbe1d01a6aa688716f862f755627e404dbb90e35 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Thu, 13 Oct 2022 11:38:33 +0530 Subject: [PATCH 042/166] Remove tests for net_* modules (#576) Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/remove_net_changes.yaml | 3 ++ .../tests/common/net_logging.yaml | 32 ----------------- .../nxos_system/tests/cli/net_system.yaml | 33 ------------------ .../nxos_system/tests/nxapi/net_system.yaml | 34 ------------------- .../nxos_user/tests/common/net_user.yaml | 29 ---------------- 5 files changed, 3 insertions(+), 128 deletions(-) create mode 100644 changelogs/fragments/remove_net_changes.yaml delete mode 100644 tests/integration/targets/nxos_logging/tests/common/net_logging.yaml delete mode 100644 tests/integration/targets/nxos_system/tests/cli/net_system.yaml delete mode 100644 tests/integration/targets/nxos_system/tests/nxapi/net_system.yaml delete mode 100644 tests/integration/targets/nxos_user/tests/common/net_user.yaml diff --git a/changelogs/fragments/remove_net_changes.yaml b/changelogs/fragments/remove_net_changes.yaml new file mode 100644 index 000000000..4f5a4a2a8 --- /dev/null +++ b/changelogs/fragments/remove_net_changes.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove tests for to-be-removed net_* modules. (https://github.com/ansible-collections/ansible.netcommon/pull/458) diff --git a/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml b/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml deleted file mode 100644 index a2a8548cc..000000000 --- a/tests/integration/targets/nxos_logging/tests/common/net_logging.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos common/net_logging.yaml - -- name: Delete/disable console logging - setup - register: result - ansible.netcommon.net_logging: - dest: console - dest_level: 0 - state: absent - -- name: Set up console logging using platform agnostic module - register: result - ansible.netcommon.net_logging: - dest: console - dest_level: 0 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging console 0" in result.commands' - -- name: Delete/disable console logging - teardown - register: result - ansible.netcommon.net_logging: - dest: console - dest_level: 0 - state: absent - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos common/net_logging.yaml diff --git a/tests/integration/targets/nxos_system/tests/cli/net_system.yaml b/tests/integration/targets/nxos_system/tests/cli/net_system.yaml deleted file mode 100644 index c26d986f4..000000000 --- a/tests/integration/targets/nxos_system/tests/cli/net_system.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START nxos cli/net_system.yaml on connection={{ ansible_connection }} - -- name: Setup - cisco.nxos.nxos_config: - lines: - - no ip domain-list ansible.com - - no ip domain-list redhat.com - match: none - -- name: Configure domain_list using platform agnostic module - register: result - ansible.netcommon.net_system: - domain_search: - - ansible.com - - redhat.com - -- ansible.builtin.assert: - that: - - result.changed == true - - "'ip domain-list ansible.com' in result.commands" - - "'ip domain-list redhat.com' in result.commands" - -- name: Setup - cisco.nxos.nxos_config: - lines: - - no ip domain-list ansible.com - - no ip domain-list redhat.com - match: none - -- ansible.builtin.debug: - msg: END nxos cli/net_system.yaml on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_system/tests/nxapi/net_system.yaml b/tests/integration/targets/nxos_system/tests/nxapi/net_system.yaml deleted file mode 100644 index 40ae623e8..000000000 --- a/tests/integration/targets/nxos_system/tests/nxapi/net_system.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START nxos nxapi/net_system.yaml on connection={{ ansible_connection }} - -- name: Setup - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - no ip domain-list ansible.com - - no ip domain-list redhat.com - match: none - -- name: Configure domain_list using platform agnostic module - register: result - ansible.netcommon.net_system: - domain_search: - - ansible.com - - redhat.com - -- ansible.builtin.assert: - that: - - result.changed == true - - "'ip domain-list ansible.com' in result.commands" - - "'ip domain-list redhat.com' in result.commands" - -- name: Setup - cisco.nxos.nxos_config: - lines: - - no ip domain-list ansible.com - - no ip domain-list redhat.com - match: none - -- ansible.builtin.debug: - msg: END nxos nxapi/net_system.yaml on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_user/tests/common/net_user.yaml b/tests/integration/targets/nxos_user/tests/common/net_user.yaml deleted file mode 100644 index ab5f95009..000000000 --- a/tests/integration/targets/nxos_user/tests/common/net_user.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos common/net_user.yaml - -- name: Remove old entries of user - setup - ansible.netcommon.net_user: - name: ansibletest1 - state: absent - -- name: Create user with platform agnostic module - register: result - ansible.netcommon.net_user: - name: ansibletest1 - roles: network-operator - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"username" in result.commands[0]' - - '"role network-operator" in result.commands[0]' - -- name: Teardown - ansible.netcommon.net_user: - name: ansibletest1 - state: absent - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos common/net_user.yaml From c5ea0ce2c02f0673a6d8a1ba14784f557bb3cacf Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 13 Oct 2022 17:41:02 +0530 Subject: [PATCH 043/166] Remove provider (#578) Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/remove_provider.yaml | 4 + ...cisco.nxos.nxos_aaa_server_host_module.rst | 252 +----------- docs/cisco.nxos.nxos_aaa_server_module.rst | 248 +---------- docs/cisco.nxos.nxos_banner_module.rst | 240 +---------- docs/cisco.nxos.nxos_bfd_global_module.rst | 262 +----------- docs/cisco.nxos.nxos_bgp_af_module.rst | 300 ++------------ docs/cisco.nxos.nxos_bgp_module.rst | 314 ++------------ ...cisco.nxos.nxos_bgp_neighbor_af_module.rst | 306 ++------------ docs/cisco.nxos.nxos_bgp_neighbor_module.rst | 284 ++----------- docs/cisco.nxos.nxos_command_module.rst | 244 +---------- docs/cisco.nxos.nxos_config_module.rst | 234 ----------- docs/cisco.nxos.nxos_evpn_global_module.rst | 238 +---------- docs/cisco.nxos.nxos_evpn_vni_module.rst | 246 +---------- docs/cisco.nxos.nxos_facts_module.rst | 242 +---------- docs/cisco.nxos.nxos_feature_module.rst | 238 +---------- docs/cisco.nxos.nxos_file_copy_module.rst | 262 +----------- docs/cisco.nxos.nxos_gir_module.rst | 246 +---------- ...xos.nxos_gir_profile_management_module.rst | 240 +---------- docs/cisco.nxos.nxos_hsrp_module.rst | 252 +----------- .../cisco.nxos.nxos_igmp_interface_module.rst | 268 +----------- docs/cisco.nxos.nxos_igmp_module.rst | 242 +---------- docs/cisco.nxos.nxos_igmp_snooping_module.rst | 246 +---------- docs/cisco.nxos.nxos_install_os_module.rst | 241 +---------- docs/cisco.nxos.nxos_logging_module.rst | 266 +----------- docs/cisco.nxos.nxos_ntp_auth_module.rst | 246 +---------- docs/cisco.nxos.nxos_ntp_module.rst | 250 +----------- docs/cisco.nxos.nxos_ntp_options_module.rst | 242 +---------- docs/cisco.nxos.nxos_nxapi_module.rst | 254 +----------- .../cisco.nxos.nxos_overlay_global_module.rst | 238 +---------- docs/cisco.nxos.nxos_pim_interface_module.rst | 264 +----------- docs/cisco.nxos.nxos_pim_module.rst | 238 +---------- .../cisco.nxos.nxos_pim_rp_address_module.rst | 246 +---------- docs/cisco.nxos.nxos_ping_module.rst | 248 +---------- docs/cisco.nxos.nxos_reboot_module.rst | 238 +---------- docs/cisco.nxos.nxos_rollback_module.rst | 238 +---------- docs/cisco.nxos.nxos_rpm_module.rst | 234 ----------- docs/cisco.nxos.nxos_snapshot_module.rst | 262 +----------- .../cisco.nxos.nxos_snmp_community_module.rst | 244 +---------- docs/cisco.nxos.nxos_snmp_contact_module.rst | 238 +---------- docs/cisco.nxos.nxos_snmp_host_module.rst | 254 +----------- docs/cisco.nxos.nxos_snmp_location_module.rst | 238 +---------- docs/cisco.nxos.nxos_snmp_traps_module.rst | 238 +---------- docs/cisco.nxos.nxos_snmp_user_module.rst | 248 +---------- docs/cisco.nxos.nxos_system_module.rst | 248 +---------- .../cisco.nxos.nxos_udld_interface_module.rst | 240 +---------- docs/cisco.nxos.nxos_udld_module.rst | 242 +---------- docs/cisco.nxos.nxos_user_module.rst | 238 +---------- docs/cisco.nxos.nxos_vpc_interface_module.rst | 242 +---------- docs/cisco.nxos.nxos_vpc_module.rst | 260 +----------- docs/cisco.nxos.nxos_vrf_af_module.rst | 234 ----------- docs/cisco.nxos.nxos_vrf_interface_module.rst | 240 +---------- docs/cisco.nxos.nxos_vrf_module.rst | 234 ----------- docs/cisco.nxos.nxos_vrrp_module.rst | 252 +----------- docs/cisco.nxos.nxos_vtp_domain_module.rst | 238 +---------- docs/cisco.nxos.nxos_vtp_password_module.rst | 238 +---------- docs/cisco.nxos.nxos_vtp_version_module.rst | 236 +---------- docs/cisco.nxos.nxos_vxlan_vtep_module.rst | 258 +----------- .../cisco.nxos.nxos_vxlan_vtep_vni_module.rst | 254 +----------- plugins/action/nxos.py | 131 +----- plugins/doc_fragments/nxos.py | 112 +---- plugins/module_utils/network/nxos/nxos.py | 384 +----------------- plugins/modules/nxos_aaa_server.py | 3 - plugins/modules/nxos_aaa_server_host.py | 3 - plugins/modules/nxos_banner.py | 3 - plugins/modules/nxos_bfd_global.py | 2 - plugins/modules/nxos_bgp.py | 2 - plugins/modules/nxos_bgp_af.py | 3 - plugins/modules/nxos_bgp_neighbor.py | 2 - plugins/modules/nxos_bgp_neighbor_af.py | 2 - plugins/modules/nxos_command.py | 7 +- plugins/modules/nxos_config.py | 3 - plugins/modules/nxos_evpn_global.py | 3 - plugins/modules/nxos_evpn_vni.py | 3 - plugins/modules/nxos_facts.py | 2 - plugins/modules/nxos_feature.py | 3 - plugins/modules/nxos_file_copy.py | 4 - plugins/modules/nxos_gir.py | 3 - .../modules/nxos_gir_profile_management.py | 3 - plugins/modules/nxos_hsrp.py | 3 - plugins/modules/nxos_igmp.py | 3 - plugins/modules/nxos_igmp_interface.py | 2 - plugins/modules/nxos_igmp_snooping.py | 3 - plugins/modules/nxos_install_os.py | 4 - plugins/modules/nxos_logging.py | 3 - plugins/modules/nxos_ntp.py | 3 - plugins/modules/nxos_ntp_auth.py | 3 - plugins/modules/nxos_ntp_options.py | 3 - plugins/modules/nxos_nxapi.py | 3 - plugins/modules/nxos_overlay_global.py | 3 - plugins/modules/nxos_pim.py | 3 - plugins/modules/nxos_pim_interface.py | 2 - plugins/modules/nxos_pim_rp_address.py | 2 - plugins/modules/nxos_ping.py | 7 +- plugins/modules/nxos_reboot.py | 6 +- plugins/modules/nxos_rollback.py | 7 +- plugins/modules/nxos_rpm.py | 3 - plugins/modules/nxos_snapshot.py | 3 - plugins/modules/nxos_snmp_community.py | 3 - plugins/modules/nxos_snmp_contact.py | 3 - plugins/modules/nxos_snmp_host.py | 3 - plugins/modules/nxos_snmp_location.py | 3 - plugins/modules/nxos_snmp_traps.py | 3 - plugins/modules/nxos_snmp_user.py | 3 - plugins/modules/nxos_system.py | 3 - plugins/modules/nxos_udld.py | 3 - plugins/modules/nxos_udld_interface.py | 3 - plugins/modules/nxos_user.py | 8 +- plugins/modules/nxos_vpc.py | 3 - plugins/modules/nxos_vpc_interface.py | 3 - plugins/modules/nxos_vrf.py | 2 - plugins/modules/nxos_vrf_af.py | 3 - plugins/modules/nxos_vrf_interface.py | 3 - plugins/modules/nxos_vrrp.py | 3 - plugins/modules/nxos_vtp_domain.py | 3 - plugins/modules/nxos_vtp_password.py | 3 - plugins/modules/nxos_vtp_version.py | 3 - plugins/modules/nxos_vxlan_vtep.py | 3 - plugins/modules/nxos_vxlan_vtep_vni.py | 3 - .../nxos_nxapi/tests/nxapi/badtransport.yaml | 1 - .../nxos_smoke/tests/cli/misc_tests.yaml | 1 - .../tests/common/common_config.yaml | 8 - .../nxos_smoke/tests/common/common_utils.yaml | 9 - .../nxos_smoke/tests/common/misc_tests.yaml | 5 - .../targets/nxos_vrf/tests/common/sanity.yaml | 2 - .../unit/modules/network/nxos/nxos_module.py | 3 - 125 files changed, 472 insertions(+), 14595 deletions(-) create mode 100644 changelogs/fragments/remove_provider.yaml diff --git a/changelogs/fragments/remove_provider.yaml b/changelogs/fragments/remove_provider.yaml new file mode 100644 index 000000000..2e3a010ba --- /dev/null +++ b/changelogs/fragments/remove_provider.yaml @@ -0,0 +1,4 @@ +--- +major_changes: + - "This release drops support for `connection: local` and provider dictionary." + - "Please use either of the following connection types - network_cli, httpapi or netconf." diff --git a/docs/cisco.nxos.nxos_aaa_server_host_module.rst b/docs/cisco.nxos.nxos_aaa_server_host_module.rst index c129e1b20..5730e6359 100644 --- a/docs/cisco.nxos.nxos_aaa_server_host_module.rst +++ b/docs/cisco.nxos.nxos_aaa_server_host_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
acct_port @@ -49,7 +49,7 @@ Parameters
+
address @@ -65,7 +65,7 @@ Parameters
+
auth_port @@ -80,7 +80,7 @@ Parameters
+
encrypt_type @@ -99,7 +99,7 @@ Parameters
+
host_timeout @@ -114,7 +114,7 @@ Parameters
+
key @@ -129,241 +129,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
server_type @@ -383,7 +149,7 @@ Parameters
+
state @@ -402,7 +168,7 @@ Parameters
+
tacacs_port diff --git a/docs/cisco.nxos.nxos_aaa_server_module.rst b/docs/cisco.nxos.nxos_aaa_server_module.rst index 065d5eb76..1307c9033 100644 --- a/docs/cisco.nxos.nxos_aaa_server_module.rst +++ b/docs/cisco.nxos.nxos_aaa_server_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
deadtime @@ -49,7 +49,7 @@ Parameters
+
directed_request @@ -69,7 +69,7 @@ Parameters
+
encrypt_type @@ -88,7 +88,7 @@ Parameters
+
global_key @@ -103,241 +103,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
server_timeout @@ -352,7 +118,7 @@ Parameters
+
server_type @@ -372,7 +138,7 @@ Parameters
+
state diff --git a/docs/cisco.nxos.nxos_banner_module.rst b/docs/cisco.nxos.nxos_banner_module.rst index 77a556ad2..16e0ae2cd 100644 --- a/docs/cisco.nxos.nxos_banner_module.rst +++ b/docs/cisco.nxos.nxos_banner_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
banner @@ -54,241 +54,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -307,7 +73,7 @@ Parameters
+
text diff --git a/docs/cisco.nxos.nxos_bfd_global_module.rst b/docs/cisco.nxos.nxos_bfd_global_module.rst index 601382588..8cd86ec48 100644 --- a/docs/cisco.nxos.nxos_bfd_global_module.rst +++ b/docs/cisco.nxos.nxos_bfd_global_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
echo_interface @@ -51,7 +51,7 @@ Parameters
+
echo_rx_interval @@ -66,7 +66,7 @@ Parameters
+
fabricpath_interval @@ -82,7 +82,7 @@ Parameters
+
fabricpath_slow_timer @@ -97,7 +97,7 @@ Parameters
+
fabricpath_vlan @@ -112,7 +112,7 @@ Parameters
+
interval @@ -128,7 +128,7 @@ Parameters
+
ipv4_echo_rx_interval @@ -143,7 +143,7 @@ Parameters
+
ipv4_interval @@ -159,7 +159,7 @@ Parameters
+
ipv4_slow_timer @@ -174,7 +174,7 @@ Parameters
+
ipv6_echo_rx_interval @@ -189,7 +189,7 @@ Parameters
+
ipv6_interval @@ -205,7 +205,7 @@ Parameters
+
ipv6_slow_timer @@ -220,241 +220,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
slow_timer @@ -469,7 +235,7 @@ Parameters
+
startup_timer diff --git a/docs/cisco.nxos.nxos_bgp_af_module.rst b/docs/cisco.nxos.nxos_bgp_af_module.rst index eaeb00f50..98b99d7e9 100644 --- a/docs/cisco.nxos.nxos_bgp_af_module.rst +++ b/docs/cisco.nxos.nxos_bgp_af_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
additional_paths_install @@ -60,7 +60,7 @@ Parameters
+
additional_paths_receive @@ -79,7 +79,7 @@ Parameters
+
additional_paths_selection @@ -94,7 +94,7 @@ Parameters
+
additional_paths_send @@ -113,7 +113,7 @@ Parameters
+
advertise_l2vpn_evpn @@ -132,7 +132,7 @@ Parameters
+
afi @@ -155,7 +155,7 @@ Parameters
+
asn @@ -171,7 +171,7 @@ Parameters
+
client_to_client @@ -190,7 +190,7 @@ Parameters
+
dampen_igp_metric @@ -205,7 +205,7 @@ Parameters
+
dampening_half_time @@ -220,7 +220,7 @@ Parameters
+
dampening_max_suppress_time @@ -235,7 +235,7 @@ Parameters
+
dampening_reuse_time @@ -250,7 +250,7 @@ Parameters
+
dampening_routemap @@ -265,7 +265,7 @@ Parameters
+
dampening_state @@ -284,7 +284,7 @@ Parameters
+
dampening_suppress_time @@ -299,7 +299,7 @@ Parameters
+
default_information_originate @@ -318,7 +318,7 @@ Parameters
+
default_metric @@ -333,7 +333,7 @@ Parameters
+
distance_ebgp @@ -348,7 +348,7 @@ Parameters
+
distance_ibgp @@ -363,7 +363,7 @@ Parameters
+
distance_local @@ -378,7 +378,7 @@ Parameters
+
inject_map @@ -394,7 +394,7 @@ Parameters
+
maximum_paths @@ -409,7 +409,7 @@ Parameters
+
maximum_paths_ibgp @@ -424,7 +424,7 @@ Parameters
+
networks @@ -440,7 +440,7 @@ Parameters
+
next_hop_route_map @@ -455,241 +455,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
redistribute @@ -705,7 +471,7 @@ Parameters
+
retain_route_target @@ -721,7 +487,7 @@ Parameters
+
safi @@ -742,7 +508,7 @@ Parameters
+
state @@ -761,7 +527,7 @@ Parameters
+
suppress_inactive @@ -780,7 +546,7 @@ Parameters
+
table_map @@ -795,7 +561,7 @@ Parameters
+
table_map_filter @@ -814,7 +580,7 @@ Parameters
+
vrf diff --git a/docs/cisco.nxos.nxos_bgp_module.rst b/docs/cisco.nxos.nxos_bgp_module.rst index 3fc82991e..e31ad1d85 100644 --- a/docs/cisco.nxos.nxos_bgp_module.rst +++ b/docs/cisco.nxos.nxos_bgp_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
asn @@ -57,7 +57,7 @@ Parameters
+
bestpath_always_compare_med @@ -76,7 +76,7 @@ Parameters
+
bestpath_aspath_multipath_relax @@ -95,7 +95,7 @@ Parameters
+
bestpath_compare_neighborid @@ -114,7 +114,7 @@ Parameters
+
bestpath_compare_routerid @@ -133,7 +133,7 @@ Parameters
+
bestpath_cost_community_ignore @@ -152,7 +152,7 @@ Parameters
+
bestpath_med_confed @@ -171,7 +171,7 @@ Parameters
+
bestpath_med_missing_as_worst @@ -190,7 +190,7 @@ Parameters
+
bestpath_med_non_deterministic @@ -209,7 +209,7 @@ Parameters
+
cluster_id @@ -224,7 +224,7 @@ Parameters
+
confederation_id @@ -239,7 +239,7 @@ Parameters
+
confederation_peers @@ -255,7 +255,7 @@ Parameters
+
disable_policy_batching @@ -274,7 +274,7 @@ Parameters
+
disable_policy_batching_ipv4_prefix_list @@ -289,7 +289,7 @@ Parameters
+
disable_policy_batching_ipv6_prefix_list @@ -304,7 +304,7 @@ Parameters
+
enforce_first_as @@ -323,7 +323,7 @@ Parameters
+
event_history_cli @@ -347,7 +347,7 @@ Parameters
+
event_history_detail @@ -371,7 +371,7 @@ Parameters
+
event_history_events @@ -395,7 +395,7 @@ Parameters
+
event_history_periodic @@ -419,7 +419,7 @@ Parameters
+
fast_external_fallover @@ -438,7 +438,7 @@ Parameters
+
flush_routes @@ -457,7 +457,7 @@ Parameters
+
graceful_restart @@ -476,7 +476,7 @@ Parameters
+
graceful_restart_helper @@ -495,7 +495,7 @@ Parameters
+
graceful_restart_timers_restart @@ -510,7 +510,7 @@ Parameters
+
graceful_restart_timers_stalepath_time @@ -525,7 +525,7 @@ Parameters
+
isolate @@ -544,7 +544,7 @@ Parameters
+
local_as @@ -559,7 +559,7 @@ Parameters
+
log_neighbor_changes @@ -578,7 +578,7 @@ Parameters
+
maxas_limit @@ -593,7 +593,7 @@ Parameters
+
neighbor_down_fib_accelerate @@ -612,241 +612,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
reconnect_interval @@ -861,7 +627,7 @@ Parameters
+
router_id @@ -876,7 +642,7 @@ Parameters
+
shutdown @@ -895,7 +661,7 @@ Parameters
+
state @@ -914,7 +680,7 @@ Parameters
+
suppress_fib_pending @@ -933,7 +699,7 @@ Parameters
+
timer_bestpath_limit @@ -948,7 +714,7 @@ Parameters
+
timer_bgp_hold @@ -963,7 +729,7 @@ Parameters
+
timer_bgp_keepalive @@ -978,7 +744,7 @@ Parameters
+
vrf diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst index 78af0017d..00f856531 100644 --- a/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst +++ b/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
additional_paths_receive @@ -61,7 +61,7 @@ Parameters
+
additional_paths_send @@ -81,7 +81,7 @@ Parameters
+
advertise_map_exist @@ -97,7 +97,7 @@ Parameters
+
advertise_map_non_exist @@ -113,7 +113,7 @@ Parameters
+
afi @@ -136,7 +136,7 @@ Parameters
+
allowas_in @@ -155,7 +155,7 @@ Parameters
+
allowas_in_max @@ -170,7 +170,7 @@ Parameters
+
as_override @@ -189,7 +189,7 @@ Parameters
+
asn @@ -205,7 +205,7 @@ Parameters
+
default_originate @@ -224,7 +224,7 @@ Parameters
+
default_originate_route_map @@ -239,7 +239,7 @@ Parameters
+
disable_peer_as_check @@ -258,7 +258,7 @@ Parameters
+
filter_list_in @@ -273,7 +273,7 @@ Parameters
+
filter_list_out @@ -288,7 +288,7 @@ Parameters
+
max_prefix_interval @@ -303,7 +303,7 @@ Parameters
+
max_prefix_limit @@ -318,7 +318,7 @@ Parameters
+
max_prefix_threshold @@ -333,7 +333,7 @@ Parameters
+
max_prefix_warning @@ -352,7 +352,7 @@ Parameters
+
neighbor @@ -368,7 +368,7 @@ Parameters
+
next_hop_self @@ -387,7 +387,7 @@ Parameters
+
next_hop_third_party @@ -406,7 +406,7 @@ Parameters
+
prefix_list_in @@ -421,7 +421,7 @@ Parameters
+
prefix_list_out @@ -436,241 +436,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
rewrite_evpn_rt_asn @@ -690,7 +456,7 @@ Parameters
+
route_map_in @@ -705,7 +471,7 @@ Parameters
+
route_map_out @@ -720,7 +486,7 @@ Parameters
+
route_reflector_client @@ -739,7 +505,7 @@ Parameters
+
safi @@ -760,7 +526,7 @@ Parameters
+
send_community @@ -782,7 +548,7 @@ Parameters
+
soft_reconfiguration_in @@ -802,7 +568,7 @@ Parameters
+
soo @@ -817,7 +583,7 @@ Parameters
+
state @@ -836,7 +602,7 @@ Parameters
+
suppress_inactive @@ -855,7 +621,7 @@ Parameters
+
unsuppress_map @@ -870,7 +636,7 @@ Parameters
+
vrf @@ -886,7 +652,7 @@ Parameters
+
weight diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_module.rst index e8b5d56fd..e6f9e8f57 100644 --- a/docs/cisco.nxos.nxos_bgp_neighbor_module.rst +++ b/docs/cisco.nxos.nxos_bgp_neighbor_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
asn @@ -57,7 +57,7 @@ Parameters
+
bfd @@ -77,7 +77,7 @@ Parameters
+
capability_negotiation @@ -96,7 +96,7 @@ Parameters
+
connected_check @@ -115,7 +115,7 @@ Parameters
+
description @@ -130,7 +130,7 @@ Parameters
+
dynamic_capability @@ -149,7 +149,7 @@ Parameters
+
ebgp_multihop @@ -164,7 +164,7 @@ Parameters
+
local_as @@ -179,7 +179,7 @@ Parameters
+
log_neighbor_changes @@ -199,7 +199,7 @@ Parameters
+
low_memory_exempt @@ -218,7 +218,7 @@ Parameters
+
maximum_peers @@ -233,7 +233,7 @@ Parameters
+
neighbor @@ -249,7 +249,7 @@ Parameters
+
peer_type @@ -270,241 +270,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
pwd @@ -519,7 +285,7 @@ Parameters
+
pwd_type @@ -539,7 +305,7 @@ Parameters
+
remote_as @@ -554,7 +320,7 @@ Parameters
+
remove_private_as @@ -575,7 +341,7 @@ Parameters
+
shutdown @@ -594,7 +360,7 @@ Parameters
+
state @@ -613,7 +379,7 @@ Parameters
+
suppress_4_byte_as @@ -632,7 +398,7 @@ Parameters
+
timers_holdtime @@ -647,7 +413,7 @@ Parameters
+
timers_keepalive @@ -662,7 +428,7 @@ Parameters
+
transport_passive_only @@ -681,7 +447,7 @@ Parameters
+
update_source @@ -696,7 +462,7 @@ Parameters
+
vrf diff --git a/docs/cisco.nxos.nxos_command_module.rst b/docs/cisco.nxos.nxos_command_module.rst index 9581bb9c2..cde8dfc5a 100644 --- a/docs/cisco.nxos.nxos_command_module.rst +++ b/docs/cisco.nxos.nxos_command_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
commands @@ -53,7 +53,7 @@ Parameters
+
interval @@ -69,7 +69,7 @@ Parameters
+
match @@ -88,241 +88,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
retries @@ -338,7 +104,7 @@ Parameters
+
wait_for diff --git a/docs/cisco.nxos.nxos_config_module.rst b/docs/cisco.nxos.nxos_config_module.rst index cf2534891..47944508c 100644 --- a/docs/cisco.nxos.nxos_config_module.rst +++ b/docs/cisco.nxos.nxos_config_module.rst @@ -259,240 +259,6 @@ Parameters
The ordered set of parents that uniquely identify the section or hierarchy the commands should be checked against. If the parents argument is omitted, the commands are checked against the set of top level or global commands.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
diff --git a/docs/cisco.nxos.nxos_evpn_global_module.rst b/docs/cisco.nxos.nxos_evpn_global_module.rst index 7e7ee4e02..d1b2a8241 100644 --- a/docs/cisco.nxos.nxos_evpn_global_module.rst +++ b/docs/cisco.nxos.nxos_evpn_global_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
nv_overlay_evpn @@ -53,240 +53,6 @@ Parameters
EVPN control plane.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-

diff --git a/docs/cisco.nxos.nxos_evpn_vni_module.rst b/docs/cisco.nxos.nxos_evpn_vni_module.rst index 1231db8eb..714cd9c20 100644 --- a/docs/cisco.nxos.nxos_evpn_vni_module.rst +++ b/docs/cisco.nxos.nxos_evpn_vni_module.rst @@ -29,246 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
route_distinguisher @@ -283,7 +49,7 @@ Parameters
+
route_target_both @@ -299,7 +65,7 @@ Parameters
+
route_target_export @@ -315,7 +81,7 @@ Parameters
+
route_target_import @@ -331,7 +97,7 @@ Parameters
+
state @@ -350,7 +116,7 @@ Parameters
+
vni diff --git a/docs/cisco.nxos.nxos_facts_module.rst b/docs/cisco.nxos.nxos_facts_module.rst index f9931835c..5bba90b3d 100644 --- a/docs/cisco.nxos.nxos_facts_module.rst +++ b/docs/cisco.nxos.nxos_facts_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
available_network_resources @@ -53,7 +53,7 @@ Parameters
+
gather_network_resources @@ -69,7 +69,7 @@ Parameters
+
gather_subset @@ -85,240 +85,6 @@ Parameters
When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all, hardware, config, legacy, interfaces, and min. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-

diff --git a/docs/cisco.nxos.nxos_feature_module.rst b/docs/cisco.nxos.nxos_feature_module.rst index 030b32243..ee2539180 100644 --- a/docs/cisco.nxos.nxos_feature_module.rst +++ b/docs/cisco.nxos.nxos_feature_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
feature @@ -50,241 +50,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_file_copy_module.rst b/docs/cisco.nxos.nxos_file_copy_module.rst index c8632662d..c73b16aba 100644 --- a/docs/cisco.nxos.nxos_file_copy_module.rst +++ b/docs/cisco.nxos.nxos_file_copy_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
connect_ssh_port @@ -62,7 +62,7 @@ Parameters
+
file_pull @@ -83,7 +83,7 @@ Parameters
+
file_pull_compact @@ -103,7 +103,7 @@ Parameters
+
file_pull_kstack @@ -123,7 +123,7 @@ Parameters
+
file_pull_protocol @@ -147,7 +147,7 @@ Parameters
+
file_pull_timeout @@ -168,7 +168,7 @@ Parameters
+
file_system @@ -184,7 +184,7 @@ Parameters
+
local_file @@ -200,7 +200,7 @@ Parameters
+
local_file_directory @@ -216,241 +216,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
remote_file @@ -466,7 +232,7 @@ Parameters
+
remote_scp_server @@ -482,7 +248,7 @@ Parameters
+
remote_scp_server_password @@ -498,7 +264,7 @@ Parameters
+
remote_scp_server_user @@ -514,7 +280,7 @@ Parameters
+
vrf diff --git a/docs/cisco.nxos.nxos_gir_module.rst b/docs/cisco.nxos.nxos_gir_module.rst index 787a78844..61c809ea0 100644 --- a/docs/cisco.nxos.nxos_gir_module.rst +++ b/docs/cisco.nxos.nxos_gir_module.rst @@ -30,246 +30,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -288,7 +54,7 @@ Parameters
+
system_mode_maintenance @@ -307,7 +73,7 @@ Parameters
+
system_mode_maintenance_dont_generate_profile @@ -326,7 +92,7 @@ Parameters
+
system_mode_maintenance_on_reload_reset_reason @@ -353,7 +119,7 @@ Parameters
+
system_mode_maintenance_shutdown @@ -372,7 +138,7 @@ Parameters
+
system_mode_maintenance_timeout diff --git a/docs/cisco.nxos.nxos_gir_profile_management_module.rst b/docs/cisco.nxos.nxos_gir_profile_management_module.rst index c18fe0e48..98396d508 100644 --- a/docs/cisco.nxos.nxos_gir_profile_management_module.rst +++ b/docs/cisco.nxos.nxos_gir_profile_management_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
commands @@ -50,7 +50,7 @@ Parameters
+
mode @@ -70,241 +70,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_hsrp_module.rst b/docs/cisco.nxos.nxos_hsrp_module.rst index d3a90dcab..0a55a4423 100644 --- a/docs/cisco.nxos.nxos_hsrp_module.rst +++ b/docs/cisco.nxos.nxos_hsrp_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
auth_string @@ -49,7 +49,7 @@ Parameters
+
auth_type @@ -68,7 +68,7 @@ Parameters
+
group @@ -84,7 +84,7 @@ Parameters
+
interface @@ -100,7 +100,7 @@ Parameters
+
preempt @@ -119,7 +119,7 @@ Parameters
+
priority @@ -134,241 +134,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -387,7 +153,7 @@ Parameters
+
version @@ -406,7 +172,7 @@ Parameters
+
vip diff --git a/docs/cisco.nxos.nxos_igmp_interface_module.rst b/docs/cisco.nxos.nxos_igmp_interface_module.rst index b1a1ca9d9..298d5bc10 100644 --- a/docs/cisco.nxos.nxos_igmp_interface_module.rst +++ b/docs/cisco.nxos.nxos_igmp_interface_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
group_timeout @@ -49,7 +49,7 @@ Parameters
+
immediate_leave @@ -68,7 +68,7 @@ Parameters
+
interface @@ -84,7 +84,7 @@ Parameters
+
last_member_qrt @@ -99,7 +99,7 @@ Parameters
+
last_member_query_count @@ -114,7 +114,7 @@ Parameters
+
oif_ps @@ -129,7 +129,7 @@ Parameters
+
oif_routemap @@ -144,241 +144,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
querier_timeout @@ -393,7 +159,7 @@ Parameters
+
query_interval @@ -408,7 +174,7 @@ Parameters
+
query_mrt @@ -423,7 +189,7 @@ Parameters
+
report_llg @@ -442,7 +208,7 @@ Parameters
+
restart @@ -461,7 +227,7 @@ Parameters
+
robustness @@ -476,7 +242,7 @@ Parameters
+
startup_query_count @@ -491,7 +257,7 @@ Parameters
+
startup_query_interval @@ -506,7 +272,7 @@ Parameters
+
state @@ -526,7 +292,7 @@ Parameters
+
version diff --git a/docs/cisco.nxos.nxos_igmp_module.rst b/docs/cisco.nxos.nxos_igmp_module.rst index ce1a14d5f..dbb46206f 100644 --- a/docs/cisco.nxos.nxos_igmp_module.rst +++ b/docs/cisco.nxos.nxos_igmp_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
enforce_rtr_alert @@ -53,7 +53,7 @@ Parameters
+
flush_routes @@ -72,241 +72,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
restart @@ -325,7 +91,7 @@ Parameters
+
state diff --git a/docs/cisco.nxos.nxos_igmp_snooping_module.rst b/docs/cisco.nxos.nxos_igmp_snooping_module.rst index dd35f3cd8..31af97509 100644 --- a/docs/cisco.nxos.nxos_igmp_snooping_module.rst +++ b/docs/cisco.nxos.nxos_igmp_snooping_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
group_timeout @@ -49,7 +49,7 @@ Parameters
+
link_local_grp_supp @@ -68,241 +68,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
report_supp @@ -321,7 +87,7 @@ Parameters
+
snooping @@ -340,7 +106,7 @@ Parameters
+
state @@ -359,7 +125,7 @@ Parameters
+
v3_report_supp diff --git a/docs/cisco.nxos.nxos_install_os_module.rst b/docs/cisco.nxos.nxos_install_os_module.rst index 2e73196c1..2fc4f5be5 100644 --- a/docs/cisco.nxos.nxos_install_os_module.rst +++ b/docs/cisco.nxos.nxos_install_os_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
issu @@ -58,7 +58,7 @@ Parameters
+
kickstart_image_file @@ -73,241 +73,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
system_image_file @@ -365,7 +131,6 @@ Examples - name: Check installed OS for newly installed version nxos_command: commands: [show version | json] - provider: '{{ connection }}' register: output - assert: that: diff --git a/docs/cisco.nxos.nxos_logging_module.rst b/docs/cisco.nxos.nxos_logging_module.rst index 20c3d64b0..288b8a3e1 100644 --- a/docs/cisco.nxos.nxos_logging_module.rst +++ b/docs/cisco.nxos.nxos_logging_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
aggregate @@ -57,7 +57,7 @@ Parameters
+
dest @@ -79,7 +79,7 @@ Parameters
+
dest_level @@ -95,7 +95,7 @@ Parameters
+
event @@ -116,7 +116,7 @@ Parameters
+
facility @@ -131,7 +131,7 @@ Parameters
+
facility_level @@ -146,7 +146,7 @@ Parameters
+
facility_link_status @@ -167,7 +167,7 @@ Parameters
+
file_size @@ -182,7 +182,7 @@ Parameters
+
interface @@ -197,7 +197,7 @@ Parameters
+
interface_message @@ -215,7 +215,7 @@ Parameters
+
name @@ -230,241 +230,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
purge @@ -483,7 +249,7 @@ Parameters
+
remote_server @@ -498,7 +264,7 @@ Parameters
+
state @@ -517,7 +283,7 @@ Parameters
+
timestamp @@ -537,7 +303,7 @@ Parameters
+
use_vrf diff --git a/docs/cisco.nxos.nxos_ntp_auth_module.rst b/docs/cisco.nxos.nxos_ntp_auth_module.rst index fd977ed3a..c825cd017 100644 --- a/docs/cisco.nxos.nxos_ntp_auth_module.rst +++ b/docs/cisco.nxos.nxos_ntp_auth_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
auth_type @@ -60,7 +60,7 @@ Parameters
+
authentication @@ -79,7 +79,7 @@ Parameters
+
key_id @@ -94,7 +94,7 @@ Parameters
+
md5string @@ -109,241 +109,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -362,7 +128,7 @@ Parameters
+
trusted_key diff --git a/docs/cisco.nxos.nxos_ntp_module.rst b/docs/cisco.nxos.nxos_ntp_module.rst index 0a5b0cd14..3fa835a96 100644 --- a/docs/cisco.nxos.nxos_ntp_module.rst +++ b/docs/cisco.nxos.nxos_ntp_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
key_id @@ -56,7 +56,7 @@ Parameters
+
peer @@ -71,7 +71,7 @@ Parameters
+
prefer @@ -90,241 +90,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
server @@ -339,7 +105,7 @@ Parameters
+
source_addr @@ -354,7 +120,7 @@ Parameters
+
source_int @@ -369,7 +135,7 @@ Parameters
+
state @@ -388,7 +154,7 @@ Parameters
+
vrf_name diff --git a/docs/cisco.nxos.nxos_ntp_options_module.rst b/docs/cisco.nxos.nxos_ntp_options_module.rst index a54f80299..e99825641 100644 --- a/docs/cisco.nxos.nxos_ntp_options_module.rst +++ b/docs/cisco.nxos.nxos_ntp_options_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
logging @@ -60,7 +60,7 @@ Parameters
+
master @@ -79,241 +79,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -332,7 +98,7 @@ Parameters
+
stratum diff --git a/docs/cisco.nxos.nxos_nxapi_module.rst b/docs/cisco.nxos.nxos_nxapi_module.rst index 27d48eecd..70d74e998 100644 --- a/docs/cisco.nxos.nxos_nxapi_module.rst +++ b/docs/cisco.nxos.nxos_nxapi_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
http @@ -54,7 +54,7 @@ Parameters
+
http_port @@ -70,7 +70,7 @@ Parameters
+
https @@ -90,7 +90,7 @@ Parameters
+
https_port @@ -106,241 +106,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
sandbox @@ -360,7 +126,7 @@ Parameters
+
ssl_strong_ciphers @@ -379,7 +145,7 @@ Parameters
+
state @@ -398,7 +164,7 @@ Parameters
+
tlsv1_0 @@ -417,7 +183,7 @@ Parameters
+
tlsv1_1 @@ -436,7 +202,7 @@ Parameters
+
tlsv1_2 diff --git a/docs/cisco.nxos.nxos_overlay_global_module.rst b/docs/cisco.nxos.nxos_overlay_global_module.rst index c17a8de2f..1a1b8d975 100644 --- a/docs/cisco.nxos.nxos_overlay_global_module.rst +++ b/docs/cisco.nxos.nxos_overlay_global_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
anycast_gateway_mac @@ -49,240 +49,6 @@ Parameters
Anycast gateway mac of the switch.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-

diff --git a/docs/cisco.nxos.nxos_pim_interface_module.rst b/docs/cisco.nxos.nxos_pim_interface_module.rst index f8c02af0f..d238a7ce3 100644 --- a/docs/cisco.nxos.nxos_pim_interface_module.rst +++ b/docs/cisco.nxos.nxos_pim_interface_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
bfd @@ -56,7 +56,7 @@ Parameters
+
border @@ -75,7 +75,7 @@ Parameters
+
dr_prio @@ -90,7 +90,7 @@ Parameters
+
hello_auth_key @@ -105,7 +105,7 @@ Parameters
+
hello_interval @@ -121,7 +121,7 @@ Parameters
+
hello_interval_ms @@ -142,7 +142,7 @@ Parameters
+
interface @@ -158,7 +158,7 @@ Parameters
+
jp_policy_in @@ -173,7 +173,7 @@ Parameters
+
jp_policy_out @@ -188,7 +188,7 @@ Parameters
+
jp_type_in @@ -207,7 +207,7 @@ Parameters
+
jp_type_out @@ -226,7 +226,7 @@ Parameters
+
neighbor_policy @@ -241,7 +241,7 @@ Parameters
+
neighbor_type @@ -260,241 +260,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
sparse @@ -513,7 +279,7 @@ Parameters
+
state diff --git a/docs/cisco.nxos.nxos_pim_module.rst b/docs/cisco.nxos.nxos_pim_module.rst index 876dc2cdf..056a41699 100644 --- a/docs/cisco.nxos.nxos_pim_module.rst +++ b/docs/cisco.nxos.nxos_pim_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
bfd @@ -54,241 +54,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
ssm_range diff --git a/docs/cisco.nxos.nxos_pim_rp_address_module.rst b/docs/cisco.nxos.nxos_pim_rp_address_module.rst index 7c43ad41a..29246e4df 100644 --- a/docs/cisco.nxos.nxos_pim_rp_address_module.rst +++ b/docs/cisco.nxos.nxos_pim_rp_address_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
bidir @@ -53,7 +53,7 @@ Parameters
+
group_list @@ -68,7 +68,7 @@ Parameters
+
prefix_list @@ -83,241 +83,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
route_map @@ -332,7 +98,7 @@ Parameters
+
rp_address @@ -348,7 +114,7 @@ Parameters
+
state diff --git a/docs/cisco.nxos.nxos_ping_module.rst b/docs/cisco.nxos.nxos_ping_module.rst index d24913b6e..d0d805868 100644 --- a/docs/cisco.nxos.nxos_ping_module.rst +++ b/docs/cisco.nxos.nxos_ping_module.rst @@ -32,12 +32,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
count @@ -53,7 +53,7 @@ Parameters
+
dest @@ -69,7 +69,7 @@ Parameters
+
df_bit @@ -88,241 +88,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
size @@ -337,7 +103,7 @@ Parameters
+
source @@ -352,7 +118,7 @@ Parameters
+
state @@ -371,7 +137,7 @@ Parameters
+
vrf diff --git a/docs/cisco.nxos.nxos_reboot_module.rst b/docs/cisco.nxos.nxos_reboot_module.rst index 8e3593f85..cc94a6762 100644 --- a/docs/cisco.nxos.nxos_reboot_module.rst +++ b/docs/cisco.nxos.nxos_reboot_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
confirm @@ -52,240 +52,6 @@ Parameters
Safeguard boolean. Set to true if you're sure you want to reboot.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-

diff --git a/docs/cisco.nxos.nxos_rollback_module.rst b/docs/cisco.nxos.nxos_rollback_module.rst index ba7d3e520..c948e093a 100644 --- a/docs/cisco.nxos.nxos_rollback_module.rst +++ b/docs/cisco.nxos.nxos_rollback_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
checkpoint_file @@ -49,241 +49,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
rollback_to diff --git a/docs/cisco.nxos.nxos_rpm_module.rst b/docs/cisco.nxos.nxos_rpm_module.rst index 28ff6f269..79d616a59 100644 --- a/docs/cisco.nxos.nxos_rpm_module.rst +++ b/docs/cisco.nxos.nxos_rpm_module.rst @@ -134,240 +134,6 @@ Parameters
Name of the RPM package.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
diff --git a/docs/cisco.nxos.nxos_snapshot_module.rst b/docs/cisco.nxos.nxos_snapshot_module.rst index b90b123a3..fe89b5b7b 100644 --- a/docs/cisco.nxos.nxos_snapshot_module.rst +++ b/docs/cisco.nxos.nxos_snapshot_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
action @@ -57,7 +57,7 @@ Parameters
+
compare_option @@ -77,7 +77,7 @@ Parameters
+
comparison_results_file @@ -92,7 +92,7 @@ Parameters
+
description @@ -107,7 +107,7 @@ Parameters
+
element_key1 @@ -122,7 +122,7 @@ Parameters
+
element_key2 @@ -137,7 +137,7 @@ Parameters
+
path @@ -153,241 +153,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
row_id @@ -402,7 +168,7 @@ Parameters
+
save_snapshot_locally @@ -421,7 +187,7 @@ Parameters
+
section @@ -436,7 +202,7 @@ Parameters
+
show_command @@ -451,7 +217,7 @@ Parameters
+
snapshot1 @@ -466,7 +232,7 @@ Parameters
+
snapshot2 @@ -481,7 +247,7 @@ Parameters
+
snapshot_name diff --git a/docs/cisco.nxos.nxos_snmp_community_module.rst b/docs/cisco.nxos.nxos_snmp_community_module.rst index 931a6f500..584d2d772 100644 --- a/docs/cisco.nxos.nxos_snmp_community_module.rst +++ b/docs/cisco.nxos.nxos_snmp_community_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
access @@ -60,7 +60,7 @@ Parameters
+
acl @@ -75,7 +75,7 @@ Parameters
+
community @@ -91,7 +91,7 @@ Parameters
+
group @@ -106,241 +106,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_snmp_contact_module.rst b/docs/cisco.nxos.nxos_snmp_contact_module.rst index f4fc5f21f..86dcba5a3 100644 --- a/docs/cisco.nxos.nxos_snmp_contact_module.rst +++ b/docs/cisco.nxos.nxos_snmp_contact_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
contact @@ -57,241 +57,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_snmp_host_module.rst b/docs/cisco.nxos.nxos_snmp_host_module.rst index 0a898f0a3..8aef0b21d 100644 --- a/docs/cisco.nxos.nxos_snmp_host_module.rst +++ b/docs/cisco.nxos.nxos_snmp_host_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
community @@ -56,241 +56,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
snmp_host @@ -306,7 +72,7 @@ Parameters
+
snmp_type @@ -325,7 +91,7 @@ Parameters
+
src_intf @@ -340,7 +106,7 @@ Parameters
+
state @@ -359,7 +125,7 @@ Parameters
+
udp @@ -375,7 +141,7 @@ Parameters
+
v3 @@ -395,7 +161,7 @@ Parameters
+
version @@ -415,7 +181,7 @@ Parameters
+
vrf @@ -430,7 +196,7 @@ Parameters
+
vrf_filter diff --git a/docs/cisco.nxos.nxos_snmp_location_module.rst b/docs/cisco.nxos.nxos_snmp_location_module.rst index 25e8eaa61..06f564693 100644 --- a/docs/cisco.nxos.nxos_snmp_location_module.rst +++ b/docs/cisco.nxos.nxos_snmp_location_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
location @@ -57,241 +57,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_snmp_traps_module.rst b/docs/cisco.nxos.nxos_snmp_traps_module.rst index 26d2a68bc..726a4d5fe 100644 --- a/docs/cisco.nxos.nxos_snmp_traps_module.rst +++ b/docs/cisco.nxos.nxos_snmp_traps_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -277,8 +277,8 @@ Examples - name: Merge provided configuration with device configuration cisco.nxos.nxos_fc_interfaces: config: - - name: fc18/10 - analytics: fc-scsi + - name: fc18/10 + analytics: fc-scsi state: merged # Task Output @@ -289,7 +289,7 @@ Examples # speed: auto max 16000 # mode: auto # trunk_mode: on - # enabled: False + # enabled: true # description: $ # analytics: fc-nvme # commands: @@ -300,7 +300,7 @@ Examples # speed: auto max 16000 # mode: auto # trunk_mode: on - # enabled: False + # enabled: true # description: $ # analytics: fc-all @@ -335,13 +335,13 @@ Examples - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_fc_interfaces: config: - - name: fc18/12 - speed: auto max 64000 - mode: auto - trunk_mode: on - enabled: True - description: 1 - analytics: fc-scsi + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: "on" + enabled: true + description: 1 + analytics: fc-scsi state: replaced # Task Output @@ -352,7 +352,7 @@ Examples # speed: auto max 64000 # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: 1 # analytics: fc-all # commands: @@ -364,7 +364,7 @@ Examples # speed: auto max 64000 # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: 1 # analytics: fc-scsi @@ -397,7 +397,7 @@ Examples - name: Delete or return interface parameters to default settings cisco.nxos.nxos_fc_interfaces: config: - - name: fc1/2 + - name: fc1/2 state: deleted # Task Output @@ -408,7 +408,7 @@ Examples # speed: 1000 # mode: E # trunk_mode: off - # enabled: True + # enabled: true # commands: # - interface fc1/2 # - no switchport speed 1000 @@ -420,7 +420,7 @@ Examples # speed: auto # mode: auto # trunk_mode: on - # enabled: False + # enabled: true # After state: # ------------ @@ -459,13 +459,13 @@ Examples - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_fc_interfaces: config: - - name: fc18/12 - speed: auto max 64000 - mode: auto - trunk_mode: on - enabled: True - description: 1 - analytics: fc-scsi + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: "on" + enabled: true + description: 1 + analytics: fc-scsi state: overridden # Task Output @@ -476,14 +476,14 @@ Examples # speed: auto max 64000 # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: 1 # analytics: fc-all # - name: fc18/13 # speed: auto max 64000 # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: 1 # analytics: fc-all # commands: @@ -501,14 +501,14 @@ Examples # speed: auto max 64000 # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: 1 # analytics: fc-scsi # - name: fc18/13 # speed: auto max 64000 # mode: auto # trunk_mode: on - # enabled: False + # enabled: true # After state: # ------------ @@ -526,29 +526,23 @@ Examples # switchport trunk mode on # shutdown - - - - - - # Using rendered - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_fc_interfaces: config: - - 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 - state: rendered + - 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 + state: rendered # Task Output # ----------- @@ -600,13 +594,13 @@ Examples # speed: auto # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: This is a sample line # - name: fc1/2 # speed: 1000 # mode: E # trunk_mode: off - # enabled: True + # enabled: true # Using gathered @@ -639,13 +633,13 @@ Examples # speed: auto # mode: auto # trunk_mode: on - # enabled: True + # enabled: true # description: This is a sample line # - name: fc1/2 # speed: 1000 # mode: E # trunk_mode: off - # enabled: True + # enabled: true diff --git a/docs/cisco.nxos.nxos_gir_profile_management_module.rst b/docs/cisco.nxos.nxos_gir_profile_management_module.rst index 98396d508..95d85ae9b 100644 --- a/docs/cisco.nxos.nxos_gir_profile_management_module.rst +++ b/docs/cisco.nxos.nxos_gir_profile_management_module.rst @@ -114,8 +114,8 @@ Examples - cisco.nxos.nxos_gir_profile_management: mode: maintenance commands: - - router eigrp 11 - - isolate + - router eigrp 11 + - isolate # Remove the maintenance-mode profile - cisco.nxos.nxos_gir_profile_management: diff --git a/docs/cisco.nxos.nxos_hsrp_interfaces_module.rst b/docs/cisco.nxos.nxos_hsrp_interfaces_module.rst index 1fd8dcded..163612413 100644 --- a/docs/cisco.nxos.nxos_hsrp_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_hsrp_interfaces_module.rst @@ -151,8 +151,8 @@ Examples - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - - name: Ethernet1/2 + - name: Ethernet1/1 + - name: Ethernet1/2 operation: deleted @@ -161,10 +161,10 @@ Examples - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - bfd: enable - - name: Ethernet1/2 - bfd: disable + - name: Ethernet1/1 + bfd: enable + - name: Ethernet1/2 + bfd: disable operation: merged @@ -173,10 +173,10 @@ Examples - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - bfd: enable - - name: Ethernet1/2 - bfd: disable + - name: Ethernet1/1 + bfd: enable + - name: Ethernet1/2 + bfd: disable operation: overridden @@ -185,10 +185,10 @@ Examples - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - bfd: enable - - name: Ethernet1/2 - bfd: disable + - name: Ethernet1/1 + bfd: enable + - name: Ethernet1/2 + bfd: disable operation: replaced # Using rendered @@ -196,10 +196,10 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/800 - bfd: enable - - name: Ethernet1/801 - bfd: enable + - name: Ethernet1/800 + bfd: enable + - name: Ethernet1/801 + bfd: enable state: rendered # Task Output (redacted) diff --git a/docs/cisco.nxos.nxos_igmp_interface_module.rst b/docs/cisco.nxos.nxos_igmp_interface_module.rst index 298d5bc10..80384f85a 100644 --- a/docs/cisco.nxos.nxos_igmp_interface_module.rst +++ b/docs/cisco.nxos.nxos_igmp_interface_module.rst @@ -342,8 +342,8 @@ Examples interface: ethernet1/32 startup_query_interval: 30 oif_ps: - - {prefix: 238.2.2.6} - - {source: 192.168.0.1, prefix: 238.2.2.5} + - {prefix: 238.2.2.6} + - {source: 192.168.0.1, prefix: 238.2.2.5} state: present diff --git a/docs/cisco.nxos.nxos_install_os_module.rst b/docs/cisco.nxos.nxos_install_os_module.rst index f10d02f7d..ddd630d01 100644 --- a/docs/cisco.nxos.nxos_install_os_module.rst +++ b/docs/cisco.nxos.nxos_install_os_module.rst @@ -132,9 +132,10 @@ Examples nxos_command: commands: [show version | json] register: output + - assert: that: - - output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I6(1)' + - output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I6(1)' diff --git a/docs/cisco.nxos.nxos_interfaces_module.rst b/docs/cisco.nxos.nxos_interfaces_module.rst index 9ab81a313..bf9e5d9c9 100644 --- a/docs/cisco.nxos.nxos_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_interfaces_module.rst @@ -294,12 +294,12 @@ Examples - name: Merge provided configuration with device configuration cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - description: Configured by Ansible - enabled: true - - name: Ethernet1/2 - description: Configured by Ansible Network - enabled: false + - name: Ethernet1/1 + description: Configured by Ansible + enabled: true + - name: Ethernet1/2 + description: Configured by Ansible Network + enabled: false state: merged # Task Output @@ -358,14 +358,14 @@ Examples - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - description: Configured by Ansible - enabled: true - mtu: 9000 - - name: Ethernet1/2 - description: Configured by Ansible Network - enabled: false - mode: layer2 + - name: Ethernet1/1 + description: Configured by Ansible + enabled: true + mtu: 9000 + - name: Ethernet1/2 + description: Configured by Ansible Network + enabled: false + mode: layer2 state: replaced # Task Output @@ -426,13 +426,13 @@ Examples - name: Override device configuration of all interfaces with provided configuration cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - enabled: true - - name: Ethernet1/2 - description: Configured by Ansible Network - enabled: false - - description: mgmt interface - name: mgmt0 + - name: Ethernet1/1 + enabled: true + - name: Ethernet1/2 + description: Configured by Ansible Network + enabled: false + - description: mgmt interface + name: mgmt0 state: overridden # Task Output @@ -490,7 +490,7 @@ Examples - name: Delete or return interface parameters to default settings cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/2 + - name: Ethernet1/2 state: deleted # Task Output @@ -529,14 +529,14 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - description: outbound-intf - mode: layer3 - speed: 100 - - name: Ethernet1/2 - mode: layer2 - enabled: true - duplex: full + - name: Ethernet1/1 + description: outbound-intf + mode: layer3 + speed: 100 + - name: Ethernet1/2 + mode: layer2 + enabled: true + duplex: full state: rendered # Task Output diff --git a/docs/cisco.nxos.nxos_l2_interfaces_module.rst b/docs/cisco.nxos.nxos_l2_interfaces_module.rst index 2d2248800..bfad0cf31 100644 --- a/docs/cisco.nxos.nxos_l2_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_l2_interfaces_module.rst @@ -251,13 +251,13 @@ Examples - name: Merge provided configuration with device configuration cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - trunk: - native_vlan: 10 - allowed_vlans: 2,4,15 - - name: Ethernet1/2 - access: - vlan: 30 + - name: Ethernet1/1 + trunk: + native_vlan: 10 + allowed_vlans: 2,4,15 + - name: Ethernet1/2 + access: + vlan: 30 state: merged # Task Output @@ -316,10 +316,10 @@ Examples - name: Replace device configuration of specified L2 interfaces with provided configuration. cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - trunk: - native_vlan: 20 - allowed_vlans: 5-10, 15 + - name: Ethernet1/1 + trunk: + native_vlan: 20 + allowed_vlans: 5-10, 15 state: replaced # Task Output @@ -382,9 +382,9 @@ Examples - name: Override device configuration with provided configuration. cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/2 - access: - vlan: 30 + - name: Ethernet1/2 + access: + vlan: 30 state: overridden # Task Output @@ -441,8 +441,8 @@ Examples itself). cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - - name: Ethernet1/2 + - name: Ethernet1/1 + - name: Ethernet1/2 state: deleted # Task Output @@ -483,17 +483,17 @@ Examples - name: Render platform specific configuration lines (without connecting to the device) cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - trunk: - native_vlan: 10 - allowed_vlans: 2,4,15 - - name: Ethernet1/2 - access: - vlan: 30 - - name: Ethernet1/3 - trunk: - native_vlan: 20 - allowed_vlans: 5-10, 15 + - name: Ethernet1/1 + trunk: + native_vlan: 10 + allowed_vlans: 2,4,15 + - name: Ethernet1/2 + access: + vlan: 30 + - name: Ethernet1/3 + trunk: + native_vlan: 20 + allowed_vlans: 5-10, 15 state: rendered # Task Output diff --git a/docs/cisco.nxos.nxos_l3_interfaces_module.rst b/docs/cisco.nxos.nxos_l3_interfaces_module.rst index 9241ff2fe..28a56bdf8 100644 --- a/docs/cisco.nxos.nxos_l3_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_l3_interfaces_module.rst @@ -371,19 +371,19 @@ Examples - name: Merge provided configuration with device configuration. cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/6 - ipv4: - - address: 192.168.1.1/24 - tag: 5 - - address: 10.1.1.1/24 - secondary: true - tag: 10 - ipv6: - - address: fd5d:12c9:2201:2::1/64 - tag: 6 - - name: Ethernet1/7.42 - redirects: false - unreachables: false + - name: Ethernet1/6 + ipv4: + - address: 192.168.1.1/24 + tag: 5 + - address: 10.1.1.1/24 + secondary: true + tag: 10 + ipv6: + - address: fd5d:12c9:2201:2::1/64 + tag: 6 + - name: Ethernet1/7.42 + redirects: false + unreachables: false state: merged # Task Output @@ -470,9 +470,9 @@ Examples - name: Replace device configuration of specified L3 interfaces with provided configuration. cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/6 - ipv4: - - address: 192.168.22.3/24 + - name: Ethernet1/6 + ipv4: + - address: 192.168.22.3/24 state: replaced # Task Output @@ -564,12 +564,12 @@ Examples - name: Override device configuration with provided configuration. cisco.nxos.nxos_l3_interfaces: config: - - ipv4: - - address: dhcp - name: mgmt0 - - name: Ethernet1/6 - ipv4: - - address: 192.168.22.3/24 + - ipv4: + - address: dhcp + name: mgmt0 + - name: Ethernet1/6 + ipv4: + - address: 192.168.22.3/24 state: overridden # Task Output @@ -658,8 +658,8 @@ Examples itself). cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/6 - - name: Ethernet1/2 + - name: Ethernet1/6 + - name: Ethernet1/2 state: deleted # Task Output @@ -709,17 +709,17 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/800 - ipv4: - - address: 192.168.1.100/24 - tag: 5 - - address: 10.1.1.1/24 - secondary: true - tag: 10 - - name: Ethernet1/800 - ipv6: - - address: fd5d:12c9:2201:2::1/64 - tag: 6 + - name: Ethernet1/800 + ipv4: + - address: 192.168.1.100/24 + tag: 5 + - address: 10.1.1.1/24 + secondary: true + tag: 10 + - name: Ethernet1/800 + ipv6: + - address: fd5d:12c9:2201:2::1/64 + tag: 6 state: rendered # Task Output diff --git a/docs/cisco.nxos.nxos_lacp_interfaces_module.rst b/docs/cisco.nxos.nxos_lacp_interfaces_module.rst index 63a082c80..76724ede0 100644 --- a/docs/cisco.nxos.nxos_lacp_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_lacp_interfaces_module.rst @@ -320,9 +320,9 @@ Examples - name: Merge provided configuration with device configuration. cisco.nxos.nxos_lacp_interfaces: config: - - name: Ethernet1/3 - port_priority: 5 - rate: fast + - name: Ethernet1/3 + port_priority: 5 + rate: fast state: merged # After state: @@ -346,9 +346,9 @@ Examples - name: Replace device lacp interfaces configuration with the given configuration. cisco.nxos.nxos_lacp_interfaces: config: - - name: port-channel11 - links: - min: 4 + - name: port-channel11 + links: + min: 4 state: replaced # After state: @@ -374,9 +374,9 @@ Examples on device with provided configuration. cisco.nxos.nxos_lacp_interfaces: config: - - name: port-channel11 - links: - min: 4 + - name: port-channel11 + links: + min: 4 state: overridden # After state: @@ -409,17 +409,17 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_lacp_interfaces: config: - - name: Ethernet1/800 - rate: fast - - name: Ethernet1/801 - rate: fast - port_priority: 32 - - name: port-channel10 - links: - max: 15 - min: 2 - convergence: - graceful: true + - name: Ethernet1/800 + rate: fast + - name: Ethernet1/801 + rate: fast + port_priority: 32 + - name: port-channel10 + links: + max: 15 + min: 2 + convergence: + graceful: true state: rendered # Task Output (redacted) diff --git a/docs/cisco.nxos.nxos_lag_interfaces_module.rst b/docs/cisco.nxos.nxos_lag_interfaces_module.rst index cf2bd9102..7d570dbfc 100644 --- a/docs/cisco.nxos.nxos_lag_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_lag_interfaces_module.rst @@ -215,9 +215,9 @@ Examples - name: Merge provided configuration with device configuration. cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel99 - members: - - member: Ethernet1/4 + - name: port-channel99 + members: + - member: Ethernet1/4 state: merged # After state: @@ -239,9 +239,9 @@ Examples with provided configuration. cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel10 - members: - - member: Ethernet1/4 + - name: port-channel10 + members: + - member: Ethernet1/4 state: replaced # After state: @@ -265,10 +265,10 @@ Examples device with provided configuration. cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel20 - members: - - member: Ethernet1/6 - force: true + - name: port-channel20 + members: + - member: Ethernet1/6 + force: true state: overridden # After state: @@ -291,7 +291,7 @@ Examples itself). cisco.nxos.nxos_lag_interfaces: config: - - port-channel: port-channel99 + - port-channel: port-channel99 state: deleted - name: Delete LAG attributes of all the interfaces @@ -309,15 +309,15 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel10 - members: - - member: Ethernet1/800 - mode: active - - member: Ethernet1/801 - - name: port-channel11 - members: - - member: Ethernet1/802 - mode: passive + - name: port-channel10 + members: + - member: Ethernet1/800 + mode: active + - member: Ethernet1/801 + - name: port-channel11 + members: + - member: Ethernet1/802 + mode: passive state: rendered # Task Output (redacted) diff --git a/docs/cisco.nxos.nxos_lldp_interfaces_module.rst b/docs/cisco.nxos.nxos_lldp_interfaces_module.rst index 7ae7b9f3e..d634e9aa4 100644 --- a/docs/cisco.nxos.nxos_lldp_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_lldp_interfaces_module.rst @@ -227,12 +227,12 @@ Examples - name: Merge provided configuration with device configuration cisco.nxos.nxos_lldp_interfaces: config: - - name: Ethernet1/4 - receive: false - transmit: true - tlv_set: - management_address: 192.168.122.64 - vlan: 12 + - name: Ethernet1/4 + receive: false + transmit: true + tlv_set: + management_address: 192.168.122.64 + vlan: 12 state: merged # After state: @@ -259,10 +259,10 @@ Examples - name: Replace LLDP configuration on interfaces with given configuration cisco.nxos.nxos_lldp_interfaces: config: - - name: Ethernet1/4 - transmit: false - tlv_set: - vlan: 2 + - name: Ethernet1/4 + transmit: false + tlv_set: + vlan: 2 state: replaced @@ -292,10 +292,10 @@ Examples - name: Override LLDP configuration on all interfaces with given configuration cisco.nxos.nxos_lldp_interfaces: config: - - name: Ethernet1/7 - receive: false - tlv_set: - vlan: 12 + - name: Ethernet1/7 + receive: false + tlv_set: + vlan: 12 state: overridden diff --git a/docs/cisco.nxos.nxos_logging_global_module.rst b/docs/cisco.nxos.nxos_logging_global_module.rst index ba49b2331..1cda59a35 100644 --- a/docs/cisco.nxos.nxos_logging_global_module.rst +++ b/docs/cisco.nxos.nxos_logging_global_module.rst @@ -1226,7 +1226,7 @@ Examples facility: local6 use_vrf: default origin_id: - hostname: True + hostname: true # Task output # ------------- @@ -1512,7 +1512,7 @@ Examples facility: local6 use_vrf: default origin_id: - hostname: True + hostname: true # Task Output (redacted) # ----------------------- diff --git a/docs/cisco.nxos.nxos_logging_module.rst b/docs/cisco.nxos.nxos_logging_module.rst index 288b8a3e1..9dafd8e33 100644 --- a/docs/cisco.nxos.nxos_logging_module.rst +++ b/docs/cisco.nxos.nxos_logging_module.rst @@ -404,9 +404,9 @@ Examples - name: Configure logging using aggregate cisco.nxos.nxos_logging: aggregate: - - {dest: console, dest_level: 2} - - {dest: logfile, dest_level: 2, name: testfile} - - {facility: daemon, facility_level: 0} + - {dest: console, dest_level: 2} + - {dest: logfile, dest_level: 2, name: testfile} + - {facility: daemon, facility_level: 0} state: present diff --git a/docs/cisco.nxos.nxos_ntp_global_module.rst b/docs/cisco.nxos.nxos_ntp_global_module.rst index 76d81c6a3..b77fc9440 100644 --- a/docs/cisco.nxos.nxos_ntp_global_module.rst +++ b/docs/cisco.nxos.nxos_ntp_global_module.rst @@ -877,7 +877,7 @@ Examples - access_list: PeerAcl1 serve: - access_list: ServeAcl1 - authenticate: True + authenticate: true authentication_keys: - id: 1001 key: vagwwtKfkv @@ -885,7 +885,7 @@ Examples - id: 1002 key: vagwwtKfkvgthz encryption: 7 - logging: True + logging: true master: stratum: 2 peers: @@ -896,7 +896,7 @@ Examples vrf: default - peer: 192.0.2.2 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -929,7 +929,7 @@ Examples # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 - # authenticate: True + # authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -937,7 +937,7 @@ Examples # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 - # logging: True + # logging: true # master: # stratum: 2 # peers: @@ -948,7 +948,7 @@ Examples # vrf: default # - peer: 192.0.2.2 # key_id: 2 - # prefer: True + # prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -998,7 +998,7 @@ Examples - access_list: PeerAcl2 serve: - access_list: ServeAcl2 - logging: True + logging: true master: stratum: 2 peers: @@ -1009,7 +1009,7 @@ Examples vrf: default - peer: 192.0.2.5 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -1025,7 +1025,7 @@ Examples # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 - # authenticate: True + # authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -1033,7 +1033,7 @@ Examples # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 - # logging: True + # logging: true # master: # stratum: 2 # peers: @@ -1044,7 +1044,7 @@ Examples # vrf: default # - peer: 192.0.2.2 # key_id: 2 - # prefer: True + # prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -1072,7 +1072,7 @@ Examples # - access_list: PeerAcl2 # serve: # - access_list: ServeAcl2 - # logging: True + # logging: true # master: # stratum: 2 # peers: @@ -1083,7 +1083,7 @@ Examples # vrf: default # - peer: 192.0.2.5 # key_id: 2 - # prefer: True + # prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -1119,7 +1119,7 @@ Examples # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 - # authenticate: True + # authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -1127,7 +1127,7 @@ Examples # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 - # logging: True + # logging: true # master: # stratum: 2 # peers: @@ -1138,7 +1138,7 @@ Examples # vrf: default # - peer: 192.0.2.2 # key_id: 2 - # prefer: True + # prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -1178,7 +1178,7 @@ Examples - access_list: PeerAcl1 serve: - access_list: ServeAcl1 - authenticate: True + authenticate: true authentication_keys: - id: 1001 key: vagwwtKfkv @@ -1186,7 +1186,7 @@ Examples - id: 1002 key: vagwwtKfkvgthz encryption: 7 - logging: True + logging: true master: stratum: 2 peers: @@ -1197,7 +1197,7 @@ Examples vrf: default - peer: 192.0.2.2 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -1252,7 +1252,7 @@ Examples # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 - # authenticate: True + # authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -1260,7 +1260,7 @@ Examples # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 - # logging: True + # logging: true # master: # stratum: 2 # peers: @@ -1271,7 +1271,7 @@ Examples # vrf: default # - peer: 192.0.2.2 # key_id: 2 - # prefer: True + # prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 diff --git a/docs/cisco.nxos.nxos_ospf_interfaces_module.rst b/docs/cisco.nxos.nxos_ospf_interfaces_module.rst index 6dbfbd5f5..ff69b6e71 100644 --- a/docs/cisco.nxos.nxos_ospf_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_ospf_interfaces_module.rst @@ -784,46 +784,46 @@ Examples config: - name: Ethernet1/1 address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.11 - - afi: ipv6 - processes: - - process_id: "200" - area: - area_id: 2.2.2.2 + - afi: ipv4 + processes: + - process_id: '100' + area: + area_id: 1.1.1.1 + secondaries: false multi_areas: - - 21.0.0.0 - - process_id: "300" + - 11.11.11.11 + - afi: ipv6 + processes: + - process_id: '200' + area: + area_id: 2.2.2.2 + multi_areas: + - 21.0.0.0 + - process_id: '300' + multi_areas: + - 50.50.50.50 multi_areas: - - 50.50.50.50 - multi_areas: - - 16.10.10.10 + - 16.10.10.10 - name: Ethernet1/2 address_family: - - afi: ipv4 - authentication: - enable: True - key_chain: test-1 - message_digest_key: - key_id: 10 - encryption: 3 - key: abc01d272be25d29 - cost: 100 - - afi: ipv6 - network: broadcast - shutdown: True + - afi: ipv4 + authentication: + enable: true + key_chain: test-1 + message_digest_key: + key_id: 10 + encryption: 3 + key: abc01d272be25d29 + cost: 100 + - afi: ipv6 + network: broadcast + shutdown: true - name: Ethernet1/3 address_family: - - afi: ipv4 - authentication_key: - encryption: 7 - key: 12090404011C03162E + - afi: ipv4 + authentication_key: + encryption: 7 + key: 12090404011C03162E state: merged # Task output: @@ -947,17 +947,17 @@ Examples - name: Replace OSPF configurations of listed interfaces with provided configurations cisco.nxos.nxos_ospf_interfaces: config: - - name: Ethernet1/1 - address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.12 - - name: Ethernet1/3 + - name: Ethernet1/1 + address_family: + - afi: ipv4 + processes: + - process_id: "100" + area: + area_id: 1.1.1.1 + secondaries: false + multi_areas: + - 11.11.11.12 + - name: Ethernet1/3 state: replaced # Task output: @@ -1091,16 +1091,16 @@ Examples - name: Override all OSPF interfaces configuration with provided configuration cisco.nxos.nxos_ospf_interfaces: config: - - name: Ethernet1/1 - address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.12 + - name: Ethernet1/1 + address_family: + - afi: ipv4 + processes: + - process_id: "100" + area: + area_id: 1.1.1.1 + secondaries: false + multi_areas: + - 11.11.11.12 state: overridden # Task output: @@ -1409,53 +1409,56 @@ Examples # Using rendered - - name: Render platform specific configuration lines with state rendered (without connecting to the device) + - name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.nxos.nxos_ospf_interfaces: config: - name: Ethernet1/1 address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.11 - - afi: ipv6 - processes: - - process_id: "200" - area: - area_id: 2.2.2.2 + - afi: ipv4 + processes: + - process_id: '100' + area: + area_id: 1.1.1.1 + secondaries: false multi_areas: - - 21.0.0.0 - - process_id: "300" + - 11.11.11.11 + - afi: ipv6 + processes: + - process_id: '200' + area: + area_id: 2.2.2.2 + multi_areas: + - 21.0.0.0 + - process_id: '300' + multi_areas: + - 50.50.50.50 multi_areas: - - 50.50.50.50 - multi_areas: - - 16.10.10.10 + - 16.10.10.10 - name: Ethernet1/2 address_family: - - afi: ipv4 - authentication: - enable: True - key_chain: test-1 - message_digest_key: - key_id: 10 - encryption: 3 - key: abc01d272be25d29 - cost: 100 - - afi: ipv6 - network: broadcast - shutdown: True + - afi: ipv4 + authentication: + enable: true + key_chain: test-1 + message_digest_key: + key_id: 10 + encryption: 3 + key: abc01d272be25d29 + cost: 100 + - afi: ipv6 + network: broadcast + shutdown: true - name: Ethernet1/3 address_family: - - afi: ipv4 - authentication_key: - encryption: 7 - key: 12090404011C03162E + - afi: ipv4 + authentication_key: + encryption: 7 + key: 12090404011C03162E state: rendered + # Task Output: # ------------ # rendered: diff --git a/docs/cisco.nxos.nxos_ospfv2_module.rst b/docs/cisco.nxos.nxos_ospfv2_module.rst index bc5613068..2115d34f2 100644 --- a/docs/cisco.nxos.nxos_ospfv2_module.rst +++ b/docs/cisco.nxos.nxos_ospfv2_module.rst @@ -4432,56 +4432,56 @@ Examples cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 198.51.100.64/27 - not_advertise: true - - prefix: 198.51.100.96/27 - cost: 120 - - area_id: 0.0.0.101 - authentication: - message_digest: true - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - redistribute: - - protocol: static - route_map: zone1-static-connect - summary_address: - - prefix: 198.51.100.128/27 - tag: 121 - - prefix: 198.51.100.160/27 + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: 198.51.100.64/27 + not_advertise: true + - prefix: 198.51.100.96/27 + cost: 120 + - area_id: 0.0.0.101 + authentication: + message_digest: true + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + redistribute: + - protocol: static + route_map: zone1-static-connect + summary_address: + - prefix: 198.51.100.128/27 + tag: 121 + - prefix: 198.51.100.160/27 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: merged # Task output: @@ -4613,43 +4613,46 @@ Examples # vrf zone2 # auto-cost reference-bandwidth 45 Gbps - - name: Replace device configurations of listed OSPF processes with provided configurations + - name: >- + Replace device configurations of listed OSPF processes with provided + configurations cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 102 - router_id: 198.51.100.1 - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_8 - direction: in - ranges: - - prefix: 198.51.100.64/27 - not_advertise: true - - area_id: 0.0.0.101 - stub: - no_summary: true - redistribute: - - protocol: eigrp - id: 130 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - redistribute: - - protocol: bgp - id: 65563 - route_map: zone1-bgp-connect + - process_id: 102 + router_id: 198.51.100.1 areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_8 + direction: in + ranges: + - prefix: 198.51.100.64/27 + not_advertise: true + - area_id: 0.0.0.101 + stub: + no_summary: true + redistribute: + - protocol: eigrp + id: 130 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + redistribute: + - protocol: bgp + id: 65563 + route_map: zone1-bgp-connect + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true state: replaced + # Task output: # ------------ # before: @@ -4803,11 +4806,11 @@ Examples cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 104 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - shutdown: true + - process_id: 104 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + shutdown: true state: overridden # Task output: @@ -4925,7 +4928,7 @@ Examples cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 102 + - process_id: 102 state: deleted # Task output: @@ -5088,62 +5091,65 @@ Examples # Using rendered - - name: Render platform specific configuration lines (without connecting to the device) + - name: >- + Render platform specific configuration lines (without connecting to the + device) cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 198.51.100.64/27 - not_advertise: true - - prefix: 198.51.100.96/27 - cost: 120 - - area_id: 0.0.0.101 - authentication: - message_digest: true - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - redistribute: - - protocol: static - route_map: zone1-static-connect - summary_address: - - prefix: 198.51.100.128/27 - tag: 121 - - prefix: 198.51.100.160/27 + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: 198.51.100.64/27 + not_advertise: true + - prefix: 198.51.100.96/27 + cost: 120 + - area_id: 0.0.0.101 + authentication: + message_digest: true + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + redistribute: + - protocol: static + route_map: zone1-static-connect + summary_address: + - prefix: 198.51.100.128/27 + tag: 121 + - prefix: 198.51.100.160/27 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: rendered + # Task output: # ------------ # rendered: diff --git a/docs/cisco.nxos.nxos_ospfv3_module.rst b/docs/cisco.nxos.nxos_ospfv3_module.rst index 0c4c9efed..8e7c46ef6 100644 --- a/docs/cisco.nxos.nxos_ospfv3_module.rst +++ b/docs/cisco.nxos.nxos_ospfv3_module.rst @@ -3570,49 +3570,49 @@ Examples cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - address_family: - afi: ipv6 - safi: unicast - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 2001:db2::/32 - not_advertise: true - - prefix: 2001:db3::/32 - cost: 120 - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + address_family: + afi: ipv6 + safi: unicast + areas: + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: '2001:db2::/32' + not_advertise: true + - prefix: '2001:db3::/32' + cost: 120 + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: merged # Task output: @@ -3736,33 +3736,33 @@ Examples cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 102 - router_id: 198.51.100.1 - address_family: - afi: ipv6 - safi: unicast - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_8 - direction: in - ranges: - - not_advertise: true - prefix: 2001:db2::/32 - redistribute: - - protocol: eigrp - id: 130 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: True - no_summary: True + - process_id: 102 + router_id: 198.51.100.1 + address_family: + afi: ipv6 + safi: unicast + areas: + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_8 + direction: in + ranges: + - not_advertise: true + prefix: 2001:db2::/32 + redistribute: + - protocol: eigrp + id: 130 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true state: replaced # Task output: @@ -3902,11 +3902,11 @@ Examples cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 104 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - shutdown: true + - process_id: 104 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + shutdown: true state: overridden # Task output: @@ -4022,7 +4022,7 @@ Examples cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 102 + - process_id: 102 state: deleted # Task output: @@ -4074,7 +4074,7 @@ Examples # vrf: zone2 # # commands: - # - no router ospfv3 102 + # - no router ospfv3 102 # # after: # processes: @@ -4180,49 +4180,49 @@ Examples cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - address_family: - afi: ipv6 - safi: unicast - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 2001:db2::/32 - not_advertise: true - - prefix: 2001:db3::/32 - cost: 120 - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + address_family: + afi: ipv6 + safi: unicast + areas: + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: 2001:db2::/32 + not_advertise: true + - prefix: 2001:db3::/32 + cost: 120 + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: rendered # Task output: @@ -4315,7 +4315,7 @@ Examples # router_id: 192.0.100.2 # - process_id: "102" # router_id: 198.54.100.1 - # shutdown: True + # shutdown: true # Using gathered diff --git a/docs/cisco.nxos.nxos_route_maps_module.rst b/docs/cisco.nxos.nxos_route_maps_module.rst index 6ced43a16..bcdf6a426 100644 --- a/docs/cisco.nxos.nxos_route_maps_module.rst +++ b/docs/cisco.nxos.nxos_route_maps_module.rst @@ -2957,44 +2957,44 @@ Examples - route_map: rmap3 entries: - - sequence: 10 - description: "*** first stanza ***" - action: permit - set: - ip: - next_hop: - verify_availability: - - address: 3.3.3.3 - track: 1 - - address: 4.4.4.4 - track: 3 + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - address: 4.4.4.4 + track: 3 - - sequence: 20 - description: "*** second stanza ***" - action: permit - set: - ip: - next_hop: - address: 6.6.6.6 2.2.2.2 - load_share: true - drop_on_fail: true + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true - - sequence: 30 - description: "*** third stanza ***" - action: permit - set: - ip: - next_hop: - peer_address: true + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true - - sequence: 40 - description: "*** fourth stanza ***" - action: permit - set: - ip: - next_hop: - unchanged: true - redist_unchanged: true + - sequence: 40 + description: "*** fourth stanza ***" + action: permit + set: + ip: + next_hop: + unchanged: true + redist_unchanged: true state: merged # Task output @@ -3259,35 +3259,35 @@ Examples - AllowPrefix1 set: community: - local_as: True + local_as: true - route_map: rmap3 entries: - - sequence: 10 - description: "*** first stanza ***" - action: permit - set: - ip: - next_hop: - verify_availability: - - address: 3.3.3.3 - track: 1 - - sequence: 20 - description: "*** second stanza ***" - action: permit - set: - ip: - next_hop: - peer_address: true - - sequence: 30 - description: "*** third stanza ***" - action: permit - set: - ip: - next_hop: - address: 6.6.6.6 2.2.2.2 - load_share: true - drop_on_fail: true + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true state: replaced # Task output @@ -3446,7 +3446,7 @@ Examples # - AllowPrefix1 # set: # community: - # local_as: True + # local_as: true # # - route_map: rmap2 # entries: @@ -3594,7 +3594,7 @@ Examples - AllowPrefix1 set: community: - local_as: True + local_as: true state: overridden # Task output @@ -3705,7 +3705,7 @@ Examples # - AllowPrefix1 # set: # community: - # local_as: True + # local_as: true # # After state: # ------------ diff --git a/docs/cisco.nxos.nxos_snmp_server_module.rst b/docs/cisco.nxos.nxos_snmp_server_module.rst index 1324c39a1..126e16341 100644 --- a/docs/cisco.nxos.nxos_snmp_server_module.rst +++ b/docs/cisco.nxos.nxos_snmp_server_module.rst @@ -3676,18 +3676,18 @@ Examples location: serverroom-1 traps: aaa: - server_state_change: True + server_state_change: true system: - clock_change_notification: True + clock_change_notification: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: '1' community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.2.2 - informs: True + informs: true version: '3' auth: NMS users: @@ -3697,16 +3697,16 @@ Examples authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true priv: privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -3725,7 +3725,7 @@ Examples # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - # localized_key: True + # localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -3757,9 +3757,9 @@ Examples # location: serverroom-1 # traps: # aaa: - # server_state_change: True + # server_state_change: true # system: - # clock_change_notification: True + # clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -3780,7 +3780,7 @@ Examples # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - # localized_key: True + # localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -3789,7 +3789,7 @@ Examples # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" - # localized_key: True + # localized_key: true # # - authentication: # algorithm: md5 @@ -3863,16 +3863,16 @@ Examples location: serverroom-2 traps: aaa: - server_state_change: True + server_state_change: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: '1' community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.3.2 - informs: True + informs: true version: '3' auth: NMS users: @@ -3882,7 +3882,7 @@ Examples authentication: algorithm: md5 password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - localized_key: True + localized_key: true priv: privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" @@ -3891,17 +3891,17 @@ Examples authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true priv: privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -3922,9 +3922,9 @@ Examples # location: serverroom-1 # traps: # aaa: - # server_state_change: True + # server_state_change: true # system: - # clock_change_notification: True + # clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -3945,7 +3945,7 @@ Examples # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - # localized_key: True + # localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -3954,7 +3954,7 @@ Examples # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" - # localized_key: True + # localized_key: true # # - authentication: # algorithm: md5 @@ -3996,16 +3996,16 @@ Examples # location: serverroom-2 # traps: # aaa: - # server_state_change: True + # server_state_change: true # hosts: # - host: 192.0.2.1 - # traps: True + # traps: true # version: '1' # community: public # - host: 192.0.2.1 # source_interface: Ethernet1/1 # - host: 192.0.3.2 - # informs: True + # informs: true # version: '3' # auth: NMS # users: @@ -4015,7 +4015,7 @@ Examples # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - # localized_key: True + # localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -4024,17 +4024,17 @@ Examples # authentication: # algorithm: md5 # password: '0x5632724fb8ac3699296af26281e1d0f1' - # localized_key: True + # localized_key: true # # - user: snmp_user_2 # group: network-operator # authentication: # algorithm: md5 # password: '0x5632724fb8ac3699296af26281e1d0f1' - # localized_key: True + # localized_key: true # priv: # privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - # aes_128: True + # aes_128: true # # use_acls: # - user: snmp_user_1 @@ -4100,9 +4100,9 @@ Examples # location: serverroom-1 # traps: # aaa: - # server_state_change: True + # server_state_change: true # system: - # clock_change_notification: True + # clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -4123,7 +4123,7 @@ Examples # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - # localized_key: True + # localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -4132,7 +4132,7 @@ Examples # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" - # localized_key: True + # localized_key: true # # - authentication: # algorithm: md5 @@ -4177,7 +4177,7 @@ Examples # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - # localized_key: True + # localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" @@ -4203,18 +4203,18 @@ Examples location: serverroom-1 traps: aaa: - server_state_change: True + server_state_change: true system: - clock_change_notification: True + clock_change_notification: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: '1' community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.2.2 - informs: True + informs: true version: '3' auth: NMS users: @@ -4224,16 +4224,16 @@ Examples authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true priv: privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -4300,9 +4300,9 @@ Examples # location: serverroom-1 # traps: # aaa: - # server_state_change: True + # server_state_change: true # system: - # clock_change_notification: True + # clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -4323,7 +4323,7 @@ Examples # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" - # localized_key: True + # localized_key: true # # - authentication: # algorithm: md5 diff --git a/docs/cisco.nxos.nxos_static_routes_module.rst b/docs/cisco.nxos.nxos_static_routes_module.rst index 264515ecf..0ce8ef2ed 100644 --- a/docs/cisco.nxos.nxos_static_routes_module.rst +++ b/docs/cisco.nxos.nxos_static_routes_module.rst @@ -416,7 +416,7 @@ Examples - name: Delete routes based on VRF cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf + - vrf: trial_vrf state: deleted # Task Output @@ -496,9 +496,9 @@ Examples - name: Delete routes based on AFI in a VRF cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf - address_families: - - afi: ipv4 + - vrf: trial_vrf + address_families: + - afi: ipv4 state: deleted # Task Output @@ -580,28 +580,28 @@ Examples - name: Merge new static route configuration cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.64/24 - next_hops: - - forward_router_address: 192.0.2.22 - tag: 4 - admin_distance: 2 - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.16/24 - next_hops: - - forward_router_address: 192.0.2.24 - route_name: new_route - - afi: ipv6 - routes: - - dest: 2001:db8::/64 - next_hops: - - interface: eth1/3 - forward_router_address: 2001:db8::12 + - vrf: trial_vrf + address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.64/24 + next_hops: + - forward_router_address: 192.0.2.22 + tag: 4 + admin_distance: 2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/24 + next_hops: + - forward_router_address: 192.0.2.24 + route_name: new_route + - afi: ipv6 + routes: + - dest: '2001:db8::/64' + next_hops: + - interface: eth1/3 + forward_router_address: '2001:db8::12' state: merged # Task Output @@ -663,19 +663,19 @@ Examples - name: Overridden existing static route configuration with new configuration cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.16/28 - next_hops: - - 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: Ethernet1/2 + - vrf: trial_vrf + address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/28 + next_hops: + - 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: Ethernet1/2 state: overridden # Task Output @@ -752,18 +752,18 @@ Examples - name: Replaced the existing static configuration of a prefix with new configuration cisco.nxos.nxos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.16/28 - next_hops: - - 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 - interface: Ethernet1/2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/28 + next_hops: + - 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 + interface: Ethernet1/2 state: replaced # Task Output @@ -882,18 +882,18 @@ Examples - name: Render required configuration to be pushed to the device cisco.nxos.nxos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.13 - - afi: ipv6 - routes: - - dest: 2001:db8::/64 - next_hops: - - interface: eth1/3 - forward_router_address: 2001:db8::12 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.13 + - afi: ipv6 + routes: + - dest: 2001:db8::/64 + next_hops: + - interface: eth1/3 + forward_router_address: 2001:db8::12 state: rendered # Task Output diff --git a/docs/cisco.nxos.nxos_system_module.rst b/docs/cisco.nxos.nxos_system_module.rst index 4c573f51b..630ebbaad 100644 --- a/docs/cisco.nxos.nxos_system_module.rst +++ b/docs/cisco.nxos.nxos_system_module.rst @@ -181,14 +181,14 @@ Examples - name: configure name servers cisco.nxos.nxos_system: name_servers: - - 8.8.8.8 - - 8.8.4.4 + - 8.8.8.8 + - 8.8.4.4 - name: configure name servers with VRF support cisco.nxos.nxos_system: name_servers: - - {server: 8.8.8.8, vrf: mgmt} - - {server: 8.8.4.4, vrf: mgmt} + - {server: 8.8.8.8, vrf: mgmt} + - {server: 8.8.4.4, vrf: mgmt} diff --git a/docs/cisco.nxos.nxos_telemetry_module.rst b/docs/cisco.nxos.nxos_telemetry_module.rst index 00dcb28b2..d1394ccf0 100644 --- a/docs/cisco.nxos.nxos_telemetry_module.rst +++ b/docs/cisco.nxos.nxos_telemetry_module.rst @@ -611,41 +611,41 @@ Examples source_interface: Ethernet1/1 vrf: management destination_groups: - - id: 2 - destination: - ip: 192.168.0.2 - port: 50001 - protocol: gRPC - encoding: GPB - - id: 55 - destination: - ip: 192.168.0.55 - port: 60001 - protocol: gRPC - encoding: GPB + - id: 2 + destination: + ip: 192.168.0.2 + port: 50001 + protocol: gRPC + encoding: GPB + - id: 55 + destination: + ip: 192.168.0.55 + port: 60001 + protocol: gRPC + encoding: GPB sensor_groups: - - id: 1 - data_source: NX-API - path: - name: '"show lldp neighbors detail"' - depth: 0 - - id: 55 - data_source: DME - path: - name: sys/ch - depth: unbounded - filter_condition: ne(eqptFt.operSt,"ok") + - id: 1 + data_source: NX-API + path: + name: '"show lldp neighbors detail"' + depth: 0 + - id: 55 + data_source: DME + path: + name: sys/ch + depth: unbounded + filter_condition: ne(eqptFt.operSt,"ok") subscriptions: - - id: 5 - destination_group: 55 - sensor_group: - id: 1 - sample_interval: 1000 - - id: 6 - destination_group: 2 - sensor_group: - id: 55 - sample_interval: 2000 + - id: 5 + destination_group: 55 + sensor_group: + id: 1 + sample_interval: 1000 + - id: 6 + destination_group: 2 + sensor_group: + id: 55 + sample_interval: 2000 state: merged @@ -663,15 +663,15 @@ Examples source_interface: Ethernet1/1 vrf: management destination_groups: - - id: 2 - destination: - ip: 192.168.0.2 - port: 50001 - protocol: gRPC - encoding: GPB + - id: 2 + destination: + ip: 192.168.0.2 + port: 50001 + protocol: gRPC + encoding: GPB subscriptions: - - id: 5 - destination_group: 55 + - id: 5 + destination_group: 55 state: replaced diff --git a/docs/cisco.nxos.nxos_user_module.rst b/docs/cisco.nxos.nxos_user_module.rst index bcd44852b..a03a23a03 100644 --- a/docs/cisco.nxos.nxos_user_module.rst +++ b/docs/cisco.nxos.nxos_user_module.rst @@ -340,8 +340,8 @@ Examples - name: set multiple users role cisco.nxos.nxos_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend role: network-operator state: present diff --git a/docs/cisco.nxos.nxos_vlans_module.rst b/docs/cisco.nxos.nxos_vlans_module.rst index 1da6615e6..a9dc3f41d 100644 --- a/docs/cisco.nxos.nxos_vlans_module.rst +++ b/docs/cisco.nxos.nxos_vlans_module.rst @@ -228,10 +228,10 @@ Examples - name: Merge provided configuration with device configuration. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: test-vlan5 - - vlan_id: 10 - enabled: false + - vlan_id: 5 + name: test-vlan5 + - vlan_id: 10 + enabled: false state: merged # After state: @@ -258,11 +258,11 @@ Examples - name: Replace device configuration of specified vlan with provided configuration. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: test-vlan - enabled: false - - vlan_id: 10 - enabled: false + - vlan_id: 5 + name: test-vlan + enabled: false + - vlan_id: 10 + enabled: false state: replaced # After state: @@ -293,10 +293,10 @@ Examples - name: Override device configuration of all vlans with provided configuration. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: test-vlan - - vlan_id: 10 - state: active + - vlan_id: 5 + name: test-vlan + - vlan_id: 10 + state: active state: overridden # After state: @@ -321,8 +321,8 @@ Examples - name: Delete vlans. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - - vlan_id: 10 + - vlan_id: 5 + - vlan_id: 10 state: deleted # After state: @@ -334,13 +334,13 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: vlan5 - mapped_vni: 100 + - vlan_id: 5 + name: vlan5 + mapped_vni: 100 - - vlan_id: 6 - name: vlan6 - state: suspend + - vlan_id: 6 + name: vlan6 + state: suspend state: rendered # Task Output (redacted) diff --git a/docs/cisco.nxos.nxos_vrf_af_module.rst b/docs/cisco.nxos.nxos_vrf_af_module.rst index a48a43847..236991587 100644 --- a/docs/cisco.nxos.nxos_vrf_af_module.rst +++ b/docs/cisco.nxos.nxos_vrf_af_module.rst @@ -210,55 +210,50 @@ Examples afi: ipv4 route_target_both_auto_evpn: true state: present - - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: import - - rt: 65001:1000 - direction: import - + - rt: '65000:1000' + direction: import + - rt: '65001:1000' + direction: import - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: import - - rt: 65001:1000 - state: absent - + - rt: '65000:1000' + direction: import + - rt: '65001:1000' + state: absent - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: export - - rt: 65001:1000 - direction: export - + - rt: '65000:1000' + direction: export + - rt: '65001:1000' + direction: export - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: export - state: absent - + - rt: '65000:1000' + direction: export + state: absent - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: both - state: present - - rt: 65001:1000 - direction: import - state: present - - rt: 65002:1000 - direction: both - state: absent + - rt: '65000:1000' + direction: both + state: present + - rt: '65001:1000' + direction: import + state: present + - rt: '65002:1000' + direction: both + state: absent diff --git a/docs/cisco.nxos.nxos_vrf_module.rst b/docs/cisco.nxos.nxos_vrf_module.rst index dff7e37cd..6765f78b5 100644 --- a/docs/cisco.nxos.nxos_vrf_module.rst +++ b/docs/cisco.nxos.nxos_vrf_module.rst @@ -400,48 +400,48 @@ Examples name: ntc description: testing state: present - - name: Aggregate definition of VRFs cisco.nxos.nxos_vrf: aggregate: - - {name: test1, description: Testing, admin_state: down} - - {name: test2, interfaces: Ethernet1/2} - + - name: test1 + description: Testing + admin_state: down + - name: test2 + interfaces: Ethernet1/2 - name: Aggregate definitions of VRFs with Purge cisco.nxos.nxos_vrf: aggregate: - - {name: ntc1, description: purge test1} - - {name: ntc2, description: purge test2} + - name: ntc1 + description: purge test1 + - name: ntc2 + description: purge test2 state: present purge: true - - name: Delete VRFs exist on switch cisco.nxos.nxos_vrf: aggregate: - - {name: ntc1} - - {name: ntc2} + - name: ntc1 + - name: ntc2 state: absent - - name: Assign interfaces to VRF declaratively cisco.nxos.nxos_vrf: name: test1 interfaces: - - Ethernet2/3 - - Ethernet2/5 - + - Ethernet2/3 + - Ethernet2/5 - name: Check interfaces assigned to VRF cisco.nxos.nxos_vrf: name: test1 associated_interfaces: - - Ethernet2/3 - - Ethernet2/5 - - - name: Ensure VRF is tagged with interface Ethernet2/5 only (Removes from Ethernet2/3) + - Ethernet2/3 + - Ethernet2/5 + - name: >- + Ensure VRF is tagged with interface Ethernet2/5 only (Removes from + Ethernet2/3) cisco.nxos.nxos_vrf: name: test1 interfaces: - - Ethernet2/5 - + - Ethernet2/5 - name: Delete VRF cisco.nxos.nxos_vrf: name: ntc diff --git a/docs/cisco.nxos.nxos_vsan_module.rst b/docs/cisco.nxos.nxos_vsan_module.rst index c161f11d8..9baa64c68 100644 --- a/docs/cisco.nxos.nxos_vsan_module.rst +++ b/docs/cisco.nxos.nxos_vsan_module.rst @@ -160,25 +160,25 @@ Examples - name: Test that vsan module works cisco.nxos.nxos_vsan: vsan: - - id: 922 - interface: - - fc1/1 - - fc1/2 - - port-channel 1 - name: vsan-SAN-A - remove: false - suspend: false - - id: 923 - interface: - - fc1/11 - - fc1/21 - - port-channel 2 - name: vsan-SAN-B - remove: false - suspend: true - - id: 1923 - name: vsan-SAN-Old - remove: true + - id: 922 + interface: + - fc1/1 + - fc1/2 + - port-channel 1 + name: vsan-SAN-A + remove: false + suspend: false + - id: 923 + interface: + - fc1/11 + - fc1/21 + - port-channel 2 + name: vsan-SAN-B + remove: false + suspend: true + - id: 1923 + name: vsan-SAN-Old + remove: true diff --git a/docs/cisco.nxos.nxos_zone_zoneset_module.rst b/docs/cisco.nxos.nxos_zone_zoneset_module.rst index 4d0c320b7..95ef4972a 100644 --- a/docs/cisco.nxos.nxos_zone_zoneset_module.rst +++ b/docs/cisco.nxos.nxos_zone_zoneset_module.rst @@ -426,54 +426,54 @@ Examples - name: Test that zone/zoneset module works cisco.nxos.nxos_zone_zoneset: zone_zoneset_details: - - mode: enhanced - vsan: 22 - zone: - - members: - - pwwn: 11:11:11:11:11:11:11:11 - - device_alias: test123 - - pwwn: 61:61:62:62:12:12:12:12 - remove: true - name: zoneA - - members: - - pwwn: 10:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:21:21:21:21 - name: zoneB - - name: zoneC - remove: true - zoneset: - - action: activate - members: - - name: zoneA - - name: zoneB - - name: zoneC - remove: true - name: zsetname1 - - action: deactivate - name: zsetTestExtra - remove: true - - mode: basic - smart_zoning: true - vsan: 21 - zone: - - members: - - devtype: both - pwwn: 11:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:12:12:12:12 - - devtype: both - pwwn: 92:62:62:62:12:12:1a:1a - remove: true - name: zone21A - - members: - - pwwn: 10:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:21:21:21:21 - name: zone21B - zoneset: - - action: activate - members: - - name: zone21A - - name: zone21B - name: zsetname212 + - mode: enhanced + vsan: 22 + zone: + - members: + - pwwn: 31314874576271 + - device_alias: test123 + - pwwn: '61:61:62:62:12:12:12:12' + remove: true + name: zoneA + - members: + - pwwn: 28515514576271 + - pwwn: '62:62:62:62:21:21:21:21' + name: zoneB + - name: zoneC + remove: true + zoneset: + - action: activate + members: + - name: zoneA + - name: zoneB + - name: zoneC + remove: true + name: zsetname1 + - action: deactivate + name: zsetTestExtra + remove: true + - mode: basic + smart_zoning: true + vsan: 21 + zone: + - members: + - devtype: both + pwwn: 31314874576271 + - pwwn: '62:62:62:62:12:12:12:12' + - devtype: both + pwwn: '92:62:62:62:12:12:1a:1a' + remove: true + name: zone21A + - members: + - pwwn: 28515514576271 + - pwwn: '62:62:62:62:21:21:21:21' + name: zone21B + zoneset: + - action: activate + members: + - name: zone21A + - name: zone21B + name: zsetname212 diff --git a/meta/runtime.yml b/meta/runtime.yml index d83b291f1..2f4209953 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,5 +1,5 @@ --- -requires_ansible: ">=2.9.10" +requires_ansible: ">=2.14.0" plugin_routing: action: nxos_aaa_server: diff --git a/plugins/modules/nxos_aaa_server_host.py b/plugins/modules/nxos_aaa_server_host.py index d2f84f76d..192b21ab5 100644 --- a/plugins/modules/nxos_aaa_server_host.py +++ b/plugins/modules/nxos_aaa_server_host.py @@ -114,7 +114,6 @@ tacacs_port: 89 host_timeout: 10 address: 5.6.7.8 - """ RETURN = """ @@ -315,7 +314,9 @@ def main(): module.fail_json(msg="tacacs_port can only be used with server_type=tacacs") if (auth_port or acct_port) and server_type != "radius": - module.fail_json(msg="auth_port and acct_port can only be used" "when server_type=radius") + module.fail_json( + msg="auth_port and acct_port can only be used" "when server_type=radius", + ) existing = get_aaa_host_info(module, server_type, address) end_state = existing diff --git a/plugins/modules/nxos_acl_interfaces.py b/plugins/modules/nxos_acl_interfaces.py index e61746ff3..654fc71e6 100644 --- a/plugins/modules/nxos_acl_interfaces.py +++ b/plugins/modules/nxos_acl_interfaces.py @@ -116,28 +116,28 @@ - name: Merge ACL interfaces configuration cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/2 - access_groups: - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in - - - name: Eth1/5 - access_groups: - - afi: ipv4 - acls: - - name: PortACL - direction: in - port: true - - - name: ACL1v4 - direction: out - - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in + - name: Ethernet1/2 + access_groups: + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in + + - name: Eth1/5 + access_groups: + - afi: ipv4 + acls: + - name: PortACL + direction: in + port: true + + - name: ACL1v4 + direction: out + + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in state: merged # After state: @@ -163,20 +163,20 @@ - name: Replace interface configuration with given configuration cisco.nxos.nxos_acl_interfaces: config: - - name: Eth1/5 - access_groups: - - afi: ipv4 - acls: - - name: NewACLv4 - direction: out - - - name: Ethernet1/3 - access_groups: - - afi: ipv6 - acls: - - name: NewACLv6 - direction: in - port: true + - name: Eth1/5 + access_groups: + - afi: ipv4 + acls: + - name: NewACLv4 + direction: out + + - name: Ethernet1/3 + access_groups: + - afi: ipv6 + acls: + - name: NewACLv6 + direction: in + port: true state: replaced # After state: @@ -202,21 +202,21 @@ - name: Override interface configuration with given configuration cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/3 - access_groups: - - afi: ipv4 - acls: - - name: ACL1v4 - direction: out - - - name: PortACL - port: true - direction: in - - afi: ipv6 - acls: - - name: NewACLv6 - direction: in - port: true + - name: Ethernet1/3 + access_groups: + - afi: ipv4 + acls: + - name: ACL1v4 + direction: out + + - name: PortACL + port: true + direction: in + - afi: ipv6 + acls: + - name: NewACLv6 + direction: in + port: true state: overridden # After state: @@ -242,8 +242,8 @@ - name: Delete ACL configuration on interfaces cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/5 - - name: Ethernet1/2 + - name: Ethernet1/5 + - name: Ethernet1/2 state: deleted # After state: @@ -356,28 +356,28 @@ - name: Render required configuration to be pushed to the device cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/2 - access_groups: - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in - - - name: Ethernet1/5 - access_groups: - - afi: ipv4 - acls: - - name: PortACL - direction: in - port: true - - name: ACL1v4 - direction: out - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in + - name: Ethernet1/2 + access_groups: + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in + - name: Ethernet1/5 + access_groups: + - afi: ipv4 + acls: + - name: PortACL + direction: in + port: true + - name: ACL1v4 + direction: out + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in state: rendered + # returns # rendered: # interface Ethernet1/2 @@ -386,7 +386,6 @@ # ipv6 traffic-filter ACL1v6 in # ip access-group ACL1v4 out # ip port access-group PortACL in - """ RETURN = """ before: diff --git a/plugins/modules/nxos_acls.py b/plugins/modules/nxos_acls.py index 133bd3a44..29d610400 100644 --- a/plugins/modules/nxos_acls.py +++ b/plugins/modules/nxos_acls.py @@ -536,13 +536,13 @@ acls: - name: ACL1v6 aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: 2001:db8:12::/32 + protocol: sctp # Task Output # ----------- @@ -974,7 +974,7 @@ - name: Delete all ACLs in given AFI cisco.nxos.nxos_acls: config: - - afi: ipv4 + - afi: ipv4 state: deleted # Task Output @@ -1309,38 +1309,38 @@ - name: Render required configuration to be pushed to the device cisco.nxos.nxos_acls: config: - - afi: ipv4 - acls: - - name: ACL1v4 - aces: - - grant: deny - destination: - address: 192.0.2.64 - wildcard_bits: 0.0.0.255 - source: - any: true - port_protocol: - lt: 55 - protocol: tcp - protocol_options: - tcp: - ack: true - fin: true - sequence: 50 - - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp + - afi: ipv4 + acls: + - name: ACL1v4 + aces: + - grant: deny + destination: + address: 192.0.2.64 + wildcard_bits: 0.0.0.255 + source: + any: true + port_protocol: + lt: 55 + protocol: tcp + protocol_options: + tcp: + ack: true + fin: true + sequence: 50 + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: '2001:db8:12::/32' + protocol: sctp state: rendered + # Task Output # ----------- # diff --git a/plugins/modules/nxos_bfd_interfaces.py b/plugins/modules/nxos_bfd_interfaces.py index 1790f8e01..3465d95bb 100644 --- a/plugins/modules/nxos_bfd_interfaces.py +++ b/plugins/modules/nxos_bfd_interfaces.py @@ -104,12 +104,12 @@ - name: Configure interfaces cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/1 - bfd: enable - echo: enable - - name: Ethernet1/2 - bfd: disable - echo: disable + - name: Ethernet1/1 + bfd: enable + echo: enable + - name: Ethernet1/2 + bfd: disable + echo: disable state: merged @@ -118,12 +118,12 @@ - name: Configure interfaces cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/1 - bfd: enable - echo: enable - - name: Ethernet1/2 - bfd: disable - echo: disable + - name: Ethernet1/1 + bfd: enable + echo: enable + - name: Ethernet1/2 + bfd: disable + echo: disable state: overridden @@ -132,12 +132,12 @@ - name: Configure interfaces cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/1 - bfd: enable - echo: enable - - name: Ethernet1/2 - bfd: disable - echo: disable + - name: Ethernet1/1 + bfd: enable + echo: enable + - name: Ethernet1/2 + bfd: disable + echo: disable state: replaced # Using rendered @@ -145,12 +145,12 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/800 - bfd: enable - echo: enable - - name: Ethernet1/801 - bfd: disable - echo: disable + - name: Ethernet1/800 + bfd: enable + echo: enable + - name: Ethernet1/801 + bfd: disable + echo: disable state: rendered # Task Output (redacted) diff --git a/plugins/modules/nxos_bgp_address_family.py b/plugins/modules/nxos_bgp_address_family.py index ef6e9012c..489b6fa30 100644 --- a/plugins/modules/nxos_bgp_address_family.py +++ b/plugins/modules/nxos_bgp_address_family.py @@ -52,7 +52,7 @@ description: Address Family indicator. type: str choices: ["ipv4", "ipv6", "link-state", "vpnv4", "vpnv6", "l2vpn"] - required: True + required: true safi: description: Sub Address Family indicator. type: str @@ -367,11 +367,11 @@ safi: unicast vrf: site-1 default_information: - originate: True + originate: true aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv6 safi: multicast vrf: site-1 @@ -420,11 +420,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -490,8 +490,8 @@ non_critical_delay: 180 aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: unicast vrf: site-1 @@ -517,11 +517,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -558,8 +558,8 @@ # non_critical_delay: 180 # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # # - afi: ipv4 # safi: unicast @@ -622,8 +622,8 @@ route_map: rmap1 aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: unicast vrf: site-1 @@ -649,11 +649,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -690,8 +690,8 @@ # route_map: rmap1 # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv4 # safi: unicast # vrf: site-1 @@ -759,11 +759,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -788,11 +788,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # After state: # ------------ @@ -846,11 +846,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -900,11 +900,11 @@ safi: unicast vrf: site-1 default_information: - originate: True + originate: true aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv6 safi: multicast vrf: site-1 @@ -977,11 +977,11 @@ # safi: unicast # vrf: site-1 # default_information: -# originate: True +# originate: true # aggregate_address: # - prefix: 203.0.113.0/24 -# as_set: True -# summary_only: True +# as_set: true +# summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 diff --git a/plugins/modules/nxos_bgp_global.py b/plugins/modules/nxos_bgp_global.py index 29e016181..59e7eefd7 100644 --- a/plugins/modules/nxos_bgp_global.py +++ b/plugins/modules/nxos_bgp_global.py @@ -203,7 +203,7 @@ neighbor_address: description: IP address/Prefix of the neighbor or interface. type: str - required: True + required: true bfd: description: Bidirectional Fast Detection for the neighbor. type: dict @@ -543,16 +543,16 @@ router_id: 192.168.1.1 bestpath: as_path: - multipath_relax: True - compare_neighborid: True - cost_community_ignore: True + multipath_relax: true + compare_neighborid: true + cost_community_ignore: true confederation: identifier: 42 peers: - 65020 - 65030 - 65040 - log_neighbor_changes: True + log_neighbor_changes: true maxas_limit: 20 neighbors: - neighbor_address: 192.168.1.100 @@ -562,19 +562,19 @@ remote_as: 65563 description: NBR-1 low_memory: - exempt: True + exempt: true - neighbor_address: 192.168.1.101 remote_as: 65563 password: encryption: 7 key: 12090404011C03162E neighbor_down: - fib_accelerate: True + fib_accelerate: true vrfs: - vrf: site-1 allocate_index: 5000 local_as: 200 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 198.51.100.1 description: site-1-nbr-1 @@ -587,7 +587,7 @@ description: site-1-nbr-2 - vrf: site-2 local_as: 300 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 203.0.113.2 description: site-2-nbr-1 @@ -596,7 +596,7 @@ key: AF92F4C16A0A0EC5BDF56CF58BC030F6 remote_as: 65568 neighbor_down: - fib_accelerate: True + fib_accelerate: true # Task output: # ------------ @@ -795,8 +795,8 @@ as_number: 65563 router_id: 192.168.1.1 bestpath: - compare_neighborid: True - cost_community_ignore: True + compare_neighborid: true + cost_community_ignore: true confederation: identifier: 42 peers: @@ -812,20 +812,20 @@ remote_as: 65563 description: NBR-1 low_memory: - exempt: True + exempt: true neighbor_down: - fib_accelerate: True + fib_accelerate: true vrfs: - vrf: site-2 local_as: 300 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 203.0.113.2 password: encryption: 7 key: 12090404011C03162E neighbor_down: - fib_accelerate: True + fib_accelerate: true state: replaced # Task output: @@ -1258,16 +1258,16 @@ router_id: 192.168.1.1 bestpath: as_path: - multipath_relax: True - compare_neighborid: True - cost_community_ignore: True + multipath_relax: true + compare_neighborid: true + cost_community_ignore: true confederation: identifier: 42 peers: - 65020 - 65030 - 65040 - log_neighbor_changes: True + log_neighbor_changes: true maxas_limit: 20 neighbors: - neighbor_address: 192.168.1.100 @@ -1277,19 +1277,19 @@ remote_as: 65563 description: NBR-1 low_memory: - exempt: True + exempt: true - neighbor_address: 192.168.1.101 remote_as: 65563 password: encryption: 7 key: 12090404011C03162E neighbor_down: - fib_accelerate: True + fib_accelerate: true vrfs: - vrf: site-1 allocate_index: 5000 local_as: 200 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 198.51.100.1 description: site-1-nbr-1 @@ -1302,7 +1302,7 @@ description: site-1-nbr-2 - vrf: site-2 local_as: 300 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 203.0.113.2 description: site-1-nbr-1 @@ -1311,7 +1311,7 @@ key: AF92F4C16A0A0EC5BDF56CF58BC030F6 remote_as: 65568 neighbor_down: - fib_accelerate: True + fib_accelerate: true # Task output: # ------------ @@ -1561,7 +1561,7 @@ as_number: 65536 router_id: 198.51.100.2 maxas_limit: 20 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 192.0.2.1 remote_as: 65537 @@ -1605,7 +1605,7 @@ as_number: 65536 router_id: 198.51.100.2 maxas_limit: 20 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 192.0.2.1 remote_as: 65537 @@ -1615,7 +1615,7 @@ vrfs: - vrf: site-2 neighbor_down: - fib_accelerate: True + fib_accelerate: true state: replaced # Task output: diff --git a/plugins/modules/nxos_bgp_neighbor_address_family.py b/plugins/modules/nxos_bgp_neighbor_address_family.py index e2b72ace3..de41a9bf1 100644 --- a/plugins/modules/nxos_bgp_neighbor_address_family.py +++ b/plugins/modules/nxos_bgp_neighbor_address_family.py @@ -51,7 +51,7 @@ neighbor_address: description: IP/IPv6 address of the neighbor. type: str - required: True + required: true address_family: description: BGP Neighbor Address Family related configurations. type: list @@ -61,7 +61,7 @@ description: Address Family indicator. type: str choices: ["ipv4", "ipv6", "link-state", "vpnv4", "vpnv6", "l2vpn"] - required: True + required: true safi: description: Sub Address Family indicator. type: str @@ -73,7 +73,7 @@ route_map: description: Route-map name. type: str - required: True + required: true exist_map: description: Condition route-map to advertise only when prefix in condition exists. type: str @@ -307,9 +307,9 @@ address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true - neighbor_address: 203.0.113.2 address_family: - afi: ipv6 @@ -317,7 +317,7 @@ - afi: ipv4 safi: multicast send_community: - set: True + set: true # Task output: # ------------ @@ -383,7 +383,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast @@ -472,7 +472,7 @@ - afi: ipv4 safi: multicast send_community: - set: True + set: true state: replaced # Task output: @@ -515,7 +515,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast # @@ -562,7 +562,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast @@ -629,9 +629,9 @@ address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true state: overridden # Task output: @@ -674,7 +674,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast # @@ -708,9 +708,9 @@ # address_family: # - afi: ipv4 # safi: unicast -# suppress_inactive: True +# suppress_inactive: true # next_hop_self: -# set: True +# set: true # After state: # ------------ @@ -809,7 +809,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast # @@ -850,7 +850,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # # After state: # ------------ @@ -942,7 +942,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast # @@ -1008,9 +1008,9 @@ address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true - neighbor_address: 203.0.113.2 address_family: - afi: ipv6 @@ -1018,7 +1018,7 @@ - afi: ipv4 safi: multicast send_community: - set: True + set: true state: rendered # Task output: @@ -1116,7 +1116,7 @@ # - afi: ipv4 # safi: multicast # send_community: -# set: True +# set: true # - afi: ipv6 # safi: unicast """ diff --git a/plugins/modules/nxos_command.py b/plugins/modules/nxos_command.py index 7febbf8a7..6c3c2c384 100644 --- a/plugins/modules/nxos_command.py +++ b/plugins/modules/nxos_command.py @@ -87,32 +87,31 @@ - name: run multiple commands on remote nodes cisco.nxos.nxos_command: commands: - - show version - - show interfaces + - show version + - show interfaces - name: run multiple commands and evaluate the output cisco.nxos.nxos_command: commands: - - show version - - show interfaces + - show version + - show interfaces wait_for: - - result[0] contains Cisco - - result[1] contains loopback0 + - result[0] contains Cisco + - result[1] contains loopback0 - name: run commands and specify the output format cisco.nxos.nxos_command: commands: - - command: show version - output: json + - command: show version + output: json - name: run commands that require answering a prompt cisco.nxos.nxos_command: commands: - - configure terminal - - command: no feature npv - prompt: Do you want to continue - answer: y - + - configure terminal + - command: no feature npv + prompt: Do you want to continue + answer: y """ RETURN = """ diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index 132a62d28..84be30a02 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -246,21 +246,21 @@ - cisco.nxos.nxos_config: lines: - - 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 - - 50 permit ip 192.0.2.5/32 any log + - 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 + - 50 permit ip 192.0.2.5/32 any log parents: ip access-list test before: no ip access-list test match: exact - cisco.nxos.nxos_config: lines: - - 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 + - 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 parents: ip access-list test before: no ip access-list test replace: block @@ -274,7 +274,7 @@ cisco.nxos.nxos_config: lines: # - shut - - shutdown + - shutdown # parents: int eth1/1 parents: interface Ethernet1/1 @@ -407,7 +407,10 @@ def main(): defaults=dict(type="bool", default=False), backup=dict(type="bool", default=False), backup_options=dict(type="dict", options=backup_spec), - save_when=dict(choices=["always", "never", "modified", "changed"], default="never"), + save_when=dict( + choices=["always", "never", "modified", "changed"], + default="never", + ), diff_against=dict(choices=["running", "startup", "intended"]), diff_ignore_lines=dict(type="list", elements="str"), ) @@ -502,10 +505,21 @@ def main(): if module.params["save_when"] == "always": save_config(module, result) elif module.params["save_when"] == "modified": - output = execute_show_commands(module, ["show running-config", "show startup-config"]) + output = execute_show_commands( + module, + ["show running-config", "show startup-config"], + ) - running_config = NetworkConfig(indent=2, contents=output[0], ignore_lines=diff_ignore_lines) - startup_config = NetworkConfig(indent=2, contents=output[1], ignore_lines=diff_ignore_lines) + running_config = NetworkConfig( + indent=2, + contents=output[0], + ignore_lines=diff_ignore_lines, + ) + startup_config = NetworkConfig( + indent=2, + contents=output[1], + ignore_lines=diff_ignore_lines, + ) if running_config.sha1 != startup_config.sha1: save_config(module, result) @@ -520,11 +534,17 @@ def main(): contents = running_config # recreate the object in order to process diff_ignore_lines - running_config = NetworkConfig(indent=2, contents=contents, ignore_lines=diff_ignore_lines) + running_config = NetworkConfig( + indent=2, + contents=contents, + ignore_lines=diff_ignore_lines, + ) if module.params["diff_against"] == "running": if module.check_mode: - module.warn("unable to perform diff against running-config due to check mode") + module.warn( + "unable to perform diff against running-config due to check mode", + ) contents = None else: contents = config.config_text @@ -540,7 +560,11 @@ def main(): contents = module.params["intended_config"] if contents is not None: - base_config = NetworkConfig(indent=2, contents=contents, ignore_lines=diff_ignore_lines) + base_config = NetworkConfig( + indent=2, + contents=contents, + ignore_lines=diff_ignore_lines, + ) if running_config.sha1 != base_config.sha1: before = "" diff --git a/plugins/modules/nxos_devicealias.py b/plugins/modules/nxos_devicealias.py index 71d4ebb67..1aa4c9d75 100644 --- a/plugins/modules/nxos_devicealias.py +++ b/plugins/modules/nxos_devicealias.py @@ -70,23 +70,21 @@ - name: Test that device alias module works cisco.nxos.nxos_devicealias: da: - - name: test1_add - pwwn: 56:2:22:11:22:88:11:67 - - name: test2_add - pwwn: 65:22:22:11:22:22:11:d - - name: dev1 - remove: true - - name: dev2 - remove: true + - name: test1_add + pwwn: 56:2:22:11:22:88:11:67 + - name: test2_add + pwwn: 65:22:22:11:22:22:11:d + - name: dev1 + remove: true + - name: dev2 + remove: true distribute: true mode: enhanced rename: - - new_name: bcd - old_name: abc - - new_name: bcd1 - old_name: abc1 - - + - new_name: bcd + old_name: abc + - new_name: bcd1 + old_name: abc1 """ RETURN = """ @@ -179,11 +177,15 @@ def isNameInDaDatabase(self, name): return name in self.da_dict.keys() def isPwwnInDaDatabase(self, pwwn): - newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) + newpwwn = ":".join( + ["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")], + ) return newpwwn in self.da_dict.values() def isNamePwwnPresentInDatabase(self, name, pwwn): - newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) + newpwwn = ":".join( + ["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")], + ) if name in self.da_dict.keys(): if newpwwn == self.da_dict[name]: return True @@ -196,7 +198,9 @@ def getPwwnByName(self, name): return None def getNameByPwwn(self, pwwn): - newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) + newpwwn = ":".join( + ["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")], + ) for n, p in self.da_dict.items(): if p == newpwwn: return n @@ -331,7 +335,9 @@ def main(): d = shDAStausObj.getDistribute() m = shDAStausObj.getMode() if shDAStausObj.isLocked(): - module.fail_json(msg="device-alias has acquired lock on the switch. Hence cannot procced.") + module.fail_json( + msg="device-alias has acquired lock on the switch. Hence cannot procced.", + ) # Step 1: Process distribute commands = [] @@ -342,7 +348,9 @@ def main(): # but switch distribute is disabled(false), so set it to # true(enabled) commands.append("device-alias distribute") - messages.append("device-alias distribute changed from disabled to enabled") + messages.append( + "device-alias distribute changed from disabled to enabled", + ) else: messages.append( "device-alias distribute remains unchanged. current distribution mode is enabled", @@ -353,7 +361,9 @@ def main(): # but switch distribute is enabled(true), so set it to # false(disabled) commands.append("no device-alias distribute") - messages.append("device-alias distribute changed from enabled to disabled") + messages.append( + "device-alias distribute changed from enabled to disabled", + ) else: messages.append( "device-alias distribute remains unchanged. current distribution mode is disabled", @@ -379,7 +389,9 @@ def main(): commands.append("no device-alias mode enhanced") messages.append("device-alias mode changed from enhanced to basic") else: - messages.append("device-alias mode remains unchanged. current mode is basic") + messages.append( + "device-alias mode remains unchanged. current mode is basic", + ) else: # playbook has mode as enhanced @@ -388,7 +400,9 @@ def main(): commands.append("device-alias mode enhanced") messages.append("device-alias mode changed from basic to enhanced") else: - messages.append("device-alias mode remains unchanged. current mode is enhanced") + messages.append( + "device-alias mode remains unchanged. current mode is enhanced", + ) if commands: if distribute: diff --git a/plugins/modules/nxos_evpn_vni.py b/plugins/modules/nxos_evpn_vni.py index d4490bb7b..89771f374 100644 --- a/plugins/modules/nxos_evpn_vni.py +++ b/plugins/modules/nxos_evpn_vni.py @@ -89,8 +89,8 @@ vni: 6000 route_distinguisher: 60:10 route_target_import: - - 5000:10 - - 4100:100 + - "5000:10" + - "4100:100" route_target_export: auto route_target_both: default """ @@ -215,7 +215,9 @@ def state_present(module, existing, proposed): if target == "default": continue if existing: - if target not in existing.get(key.replace("-", "_").replace(" ", "_")): + if target not in existing.get( + key.replace("-", "_").replace(" ", "_"), + ): commands.append("{0} {1}".format(key, target)) else: commands.append("{0} {1}".format(key, target)) diff --git a/plugins/modules/nxos_facts.py b/plugins/modules/nxos_facts.py index 24e0dad22..77ca123d5 100644 --- a/plugins/modules/nxos_facts.py +++ b/plugins/modules/nxos_facts.py @@ -77,11 +77,11 @@ - name: Gather only the config and default facts cisco.nxos.nxos_facts: gather_subset: - - config + - config - name: Do not gather hardware facts cisco.nxos.nxos_facts: gather_subset: - - '!hardware' + - '!hardware' - name: Gather legacy and resource facts cisco.nxos.nxos_facts: gather_subset: all @@ -89,10 +89,10 @@ - name: Gather only the interfaces resource facts and no legacy facts cisco.nxos.nxos_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces + - interfaces - name: Gather interfaces resource and minimal legacy facts cisco.nxos.nxos_facts: gather_subset: min diff --git a/plugins/modules/nxos_fc_interfaces.py b/plugins/modules/nxos_fc_interfaces.py index b0c58a5e3..a77deffdb 100644 --- a/plugins/modules/nxos_fc_interfaces.py +++ b/plugins/modules/nxos_fc_interfaces.py @@ -50,7 +50,7 @@ enabled: description: - Administrative state of the interface. Set the value to C(true) to - administratively enable the interface or C(false) to disable it + administratively enable the interface or C(true) to disable it type: bool speed: description: @@ -131,8 +131,8 @@ - name: Merge provided configuration with device configuration cisco.nxos.nxos_fc_interfaces: config: - - name: fc18/10 - analytics: fc-scsi + - name: fc18/10 + analytics: fc-scsi state: merged # Task Output @@ -143,7 +143,7 @@ # speed: auto max 16000 # mode: auto # trunk_mode: on -# enabled: False +# enabled: true # description: $ # analytics: fc-nvme # commands: @@ -154,7 +154,7 @@ # speed: auto max 16000 # mode: auto # trunk_mode: on -# enabled: False +# enabled: true # description: $ # analytics: fc-all @@ -189,13 +189,13 @@ - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_fc_interfaces: config: - - name: fc18/12 - speed: auto max 64000 - mode: auto - trunk_mode: on - enabled: True - description: 1 - analytics: fc-scsi + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: "on" + enabled: true + description: 1 + analytics: fc-scsi state: replaced # Task Output @@ -206,7 +206,7 @@ # speed: auto max 64000 # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: 1 # analytics: fc-all # commands: @@ -218,7 +218,7 @@ # speed: auto max 64000 # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: 1 # analytics: fc-scsi @@ -251,7 +251,7 @@ - name: Delete or return interface parameters to default settings cisco.nxos.nxos_fc_interfaces: config: - - name: fc1/2 + - name: fc1/2 state: deleted # Task Output @@ -262,7 +262,7 @@ # speed: 1000 # mode: E # trunk_mode: off -# enabled: True +# enabled: true # commands: # - interface fc1/2 # - no switchport speed 1000 @@ -274,7 +274,7 @@ # speed: auto # mode: auto # trunk_mode: on -# enabled: False +# enabled: true # After state: # ------------ @@ -313,13 +313,13 @@ - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_fc_interfaces: config: - - name: fc18/12 - speed: auto max 64000 - mode: auto - trunk_mode: on - enabled: True - description: 1 - analytics: fc-scsi + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: "on" + enabled: true + description: 1 + analytics: fc-scsi state: overridden # Task Output @@ -330,14 +330,14 @@ # speed: auto max 64000 # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: 1 # analytics: fc-all # - name: fc18/13 # speed: auto max 64000 # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: 1 # analytics: fc-all # commands: @@ -355,14 +355,14 @@ # speed: auto max 64000 # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: 1 # analytics: fc-scsi # - name: fc18/13 # speed: auto max 64000 # mode: auto # trunk_mode: on -# enabled: False +# enabled: true # After state: # ------------ @@ -380,29 +380,23 @@ # switchport trunk mode on # shutdown - - - - - - # Using rendered - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_fc_interfaces: config: - - 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 - state: rendered + - 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 + state: rendered # Task Output # ----------- @@ -454,13 +448,13 @@ # speed: auto # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: This is a sample line # - name: fc1/2 # speed: 1000 # mode: E # trunk_mode: off -# enabled: True +# enabled: true # Using gathered @@ -493,17 +487,13 @@ # speed: auto # mode: auto # trunk_mode: on -# enabled: True +# enabled: true # description: This is a sample line # - name: fc1/2 # speed: 1000 # mode: E # trunk_mode: off -# enabled: True - - - - +# enabled: true """ RETURN = """ diff --git a/plugins/modules/nxos_gir_profile_management.py b/plugins/modules/nxos_gir_profile_management.py index 84cfc1456..2ddf2ce60 100644 --- a/plugins/modules/nxos_gir_profile_management.py +++ b/plugins/modules/nxos_gir_profile_management.py @@ -65,8 +65,8 @@ - cisco.nxos.nxos_gir_profile_management: mode: maintenance commands: - - router eigrp 11 - - isolate + - router eigrp 11 + - isolate # Remove the maintenance-mode profile - cisco.nxos.nxos_gir_profile_management: diff --git a/plugins/modules/nxos_hostname.py b/plugins/modules/nxos_hostname.py index 42e45677a..3f141562c 100644 --- a/plugins/modules/nxos_hostname.py +++ b/plugins/modules/nxos_hostname.py @@ -146,7 +146,6 @@ # ----------------------- # parsed: # hostname: NXOSv-9k - """ RETURN = """ diff --git a/plugins/modules/nxos_hsrp_interfaces.py b/plugins/modules/nxos_hsrp_interfaces.py index e5ac67376..3e11949dc 100644 --- a/plugins/modules/nxos_hsrp_interfaces.py +++ b/plugins/modules/nxos_hsrp_interfaces.py @@ -88,8 +88,8 @@ - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - - name: Ethernet1/2 + - name: Ethernet1/1 + - name: Ethernet1/2 operation: deleted @@ -98,10 +98,10 @@ - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - bfd: enable - - name: Ethernet1/2 - bfd: disable + - name: Ethernet1/1 + bfd: enable + - name: Ethernet1/2 + bfd: disable operation: merged @@ -110,10 +110,10 @@ - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - bfd: enable - - name: Ethernet1/2 - bfd: disable + - name: Ethernet1/1 + bfd: enable + - name: Ethernet1/2 + bfd: disable operation: overridden @@ -122,10 +122,10 @@ - name: Configure hsrp attributes on interfaces cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/1 - bfd: enable - - name: Ethernet1/2 - bfd: disable + - name: Ethernet1/1 + bfd: enable + - name: Ethernet1/2 + bfd: disable operation: replaced # Using rendered @@ -133,10 +133,10 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_hsrp_interfaces: config: - - name: Ethernet1/800 - bfd: enable - - name: Ethernet1/801 - bfd: enable + - name: Ethernet1/800 + bfd: enable + - name: Ethernet1/801 + bfd: enable state: rendered # Task Output (redacted) @@ -199,7 +199,6 @@ # bfd: enable # - name: Ethernet1/2 # bfd: enable - """ RETURN = """ before: diff --git a/plugins/modules/nxos_igmp_interface.py b/plugins/modules/nxos_igmp_interface.py index 105dac5e6..66a2a495e 100644 --- a/plugins/modules/nxos_igmp_interface.py +++ b/plugins/modules/nxos_igmp_interface.py @@ -154,8 +154,8 @@ interface: ethernet1/32 startup_query_interval: 30 oif_ps: - - {prefix: 238.2.2.6} - - {source: 192.168.0.1, prefix: 238.2.2.5} + - {prefix: 238.2.2.6} + - {source: 192.168.0.1, prefix: 238.2.2.5} state: present """ RETURN = """ @@ -385,7 +385,9 @@ def config_igmp_interface(delta, existing, existing_oif_prefix_source): if "source" in each.keys(): src = each["source"] if src: - commands.append("no " + CMDS.get("oif_prefix_source").format(pf, src)) + commands.append( + "no " + CMDS.get("oif_prefix_source").format(pf, src), + ) else: commands.append("no " + CMDS.get("oif_prefix").format(pf)) elif key == "oif_routemap": @@ -450,7 +452,11 @@ def config_default_igmp_interface(existing, delta): proposed = get_igmp_interface_defaults() delta = dict(set(proposed.items()).difference(existing.items())) if delta: - command = config_igmp_interface(delta, existing, existing_oif_prefix_source=None) + command = config_igmp_interface( + delta, + existing, + existing_oif_prefix_source=None, + ) if command: for each in command: @@ -463,7 +469,9 @@ def config_remove_oif(existing, existing_oif_prefix_source): commands = [] command = None if existing.get("oif_routemap"): - commands.append("no ip igmp static-oif route-map {0}".format(existing.get("oif_routemap"))) + commands.append( + "no ip igmp static-oif route-map {0}".format(existing.get("oif_routemap")), + ) elif existing_oif_prefix_source: for each in existing_oif_prefix_source: if each.get("prefix") and each.get("source"): diff --git a/plugins/modules/nxos_install_os.py b/plugins/modules/nxos_install_os.py index 53fe00aac..9b64a8989 100644 --- a/plugins/modules/nxos_install_os.py +++ b/plugins/modules/nxos_install_os.py @@ -95,9 +95,10 @@ nxos_command: commands: [show version | json] register: output + - assert: that: - - output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I6(1)' + - output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I6(1)' """ RETURN = """ @@ -390,7 +391,9 @@ def build_install_cmd_set(issu, image, kick, type, force=True): if kick is None: commands.append("%s nxos %s %s" % (rootcmd, image, issu_cmd)) else: - commands.append("%s %s system %s kickstart %s" % (rootcmd, issu_cmd, image, kick)) + commands.append( + "%s %s system %s kickstart %s" % (rootcmd, issu_cmd, image, kick), + ) return commands diff --git a/plugins/modules/nxos_interfaces.py b/plugins/modules/nxos_interfaces.py index 7884098a7..30045188d 100644 --- a/plugins/modules/nxos_interfaces.py +++ b/plugins/modules/nxos_interfaces.py @@ -142,12 +142,12 @@ - name: Merge provided configuration with device configuration cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - description: Configured by Ansible - enabled: true - - name: Ethernet1/2 - description: Configured by Ansible Network - enabled: false + - name: Ethernet1/1 + description: Configured by Ansible + enabled: true + - name: Ethernet1/2 + description: Configured by Ansible Network + enabled: false state: merged # Task Output @@ -206,14 +206,14 @@ - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - description: Configured by Ansible - enabled: true - mtu: 9000 - - name: Ethernet1/2 - description: Configured by Ansible Network - enabled: false - mode: layer2 + - name: Ethernet1/1 + description: Configured by Ansible + enabled: true + mtu: 9000 + - name: Ethernet1/2 + description: Configured by Ansible Network + enabled: false + mode: layer2 state: replaced # Task Output @@ -274,13 +274,13 @@ - name: Override device configuration of all interfaces with provided configuration cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - enabled: true - - name: Ethernet1/2 - description: Configured by Ansible Network - enabled: false - - description: mgmt interface - name: mgmt0 + - name: Ethernet1/1 + enabled: true + - name: Ethernet1/2 + description: Configured by Ansible Network + enabled: false + - description: mgmt interface + name: mgmt0 state: overridden # Task Output @@ -338,7 +338,7 @@ - name: Delete or return interface parameters to default settings cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/2 + - name: Ethernet1/2 state: deleted # Task Output @@ -377,14 +377,14 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 - description: outbound-intf - mode: layer3 - speed: 100 - - name: Ethernet1/2 - mode: layer2 - enabled: true - duplex: full + - name: Ethernet1/1 + description: outbound-intf + mode: layer3 + speed: 100 + - name: Ethernet1/2 + mode: layer2 + enabled: true + duplex: full state: rendered # Task Output @@ -524,8 +524,6 @@ # interface port-channel11 # interface Ethernet1/1 # interface Ethernet1/2 - - """ RETURN = """ before: diff --git a/plugins/modules/nxos_l2_interfaces.py b/plugins/modules/nxos_l2_interfaces.py index 55149b7bf..c490d65ed 100644 --- a/plugins/modules/nxos_l2_interfaces.py +++ b/plugins/modules/nxos_l2_interfaces.py @@ -130,13 +130,13 @@ - name: Merge provided configuration with device configuration cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - trunk: - native_vlan: 10 - allowed_vlans: 2,4,15 - - name: Ethernet1/2 - access: - vlan: 30 + - name: Ethernet1/1 + trunk: + native_vlan: 10 + allowed_vlans: 2,4,15 + - name: Ethernet1/2 + access: + vlan: 30 state: merged # Task Output @@ -195,10 +195,10 @@ - name: Replace device configuration of specified L2 interfaces with provided configuration. cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - trunk: - native_vlan: 20 - allowed_vlans: 5-10, 15 + - name: Ethernet1/1 + trunk: + native_vlan: 20 + allowed_vlans: 5-10, 15 state: replaced # Task Output @@ -261,9 +261,9 @@ - name: Override device configuration with provided configuration. cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/2 - access: - vlan: 30 + - name: Ethernet1/2 + access: + vlan: 30 state: overridden # Task Output @@ -320,8 +320,8 @@ itself). cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - - name: Ethernet1/2 + - name: Ethernet1/1 + - name: Ethernet1/2 state: deleted # Task Output @@ -362,17 +362,17 @@ - name: Render platform specific configuration lines (without connecting to the device) cisco.nxos.nxos_l2_interfaces: config: - - name: Ethernet1/1 - trunk: - native_vlan: 10 - allowed_vlans: 2,4,15 - - name: Ethernet1/2 - access: - vlan: 30 - - name: Ethernet1/3 - trunk: - native_vlan: 20 - allowed_vlans: 5-10, 15 + - name: Ethernet1/1 + trunk: + native_vlan: 10 + allowed_vlans: 2,4,15 + - name: Ethernet1/2 + access: + vlan: 30 + - name: Ethernet1/3 + trunk: + native_vlan: 20 + allowed_vlans: 5-10, 15 state: rendered # Task Output diff --git a/plugins/modules/nxos_l3_interfaces.py b/plugins/modules/nxos_l3_interfaces.py index 1b4d821b2..5dc3d05a9 100644 --- a/plugins/modules/nxos_l3_interfaces.py +++ b/plugins/modules/nxos_l3_interfaces.py @@ -159,19 +159,19 @@ - name: Merge provided configuration with device configuration. cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/6 - ipv4: - - address: 192.168.1.1/24 - tag: 5 - - address: 10.1.1.1/24 - secondary: true - tag: 10 - ipv6: - - address: fd5d:12c9:2201:2::1/64 - tag: 6 - - name: Ethernet1/7.42 - redirects: false - unreachables: false + - name: Ethernet1/6 + ipv4: + - address: 192.168.1.1/24 + tag: 5 + - address: 10.1.1.1/24 + secondary: true + tag: 10 + ipv6: + - address: fd5d:12c9:2201:2::1/64 + tag: 6 + - name: Ethernet1/7.42 + redirects: false + unreachables: false state: merged # Task Output @@ -258,9 +258,9 @@ - name: Replace device configuration of specified L3 interfaces with provided configuration. cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/6 - ipv4: - - address: 192.168.22.3/24 + - name: Ethernet1/6 + ipv4: + - address: 192.168.22.3/24 state: replaced # Task Output @@ -352,12 +352,12 @@ - name: Override device configuration with provided configuration. cisco.nxos.nxos_l3_interfaces: config: - - ipv4: - - address: dhcp - name: mgmt0 - - name: Ethernet1/6 - ipv4: - - address: 192.168.22.3/24 + - ipv4: + - address: dhcp + name: mgmt0 + - name: Ethernet1/6 + ipv4: + - address: 192.168.22.3/24 state: overridden # Task Output @@ -446,8 +446,8 @@ itself). cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/6 - - name: Ethernet1/2 + - name: Ethernet1/6 + - name: Ethernet1/2 state: deleted # Task Output @@ -497,17 +497,17 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/800 - ipv4: - - address: 192.168.1.100/24 - tag: 5 - - address: 10.1.1.1/24 - secondary: true - tag: 10 - - name: Ethernet1/800 - ipv6: - - address: fd5d:12c9:2201:2::1/64 - tag: 6 + - name: Ethernet1/800 + ipv4: + - address: 192.168.1.100/24 + tag: 5 + - address: 10.1.1.1/24 + secondary: true + tag: 10 + - name: Ethernet1/800 + ipv6: + - address: fd5d:12c9:2201:2::1/64 + tag: 6 state: rendered # Task Output diff --git a/plugins/modules/nxos_lacp_interfaces.py b/plugins/modules/nxos_lacp_interfaces.py index 98e5a6339..d51ea0a71 100644 --- a/plugins/modules/nxos_lacp_interfaces.py +++ b/plugins/modules/nxos_lacp_interfaces.py @@ -143,9 +143,9 @@ - name: Merge provided configuration with device configuration. cisco.nxos.nxos_lacp_interfaces: config: - - name: Ethernet1/3 - port_priority: 5 - rate: fast + - name: Ethernet1/3 + port_priority: 5 + rate: fast state: merged # After state: @@ -169,9 +169,9 @@ - name: Replace device lacp interfaces configuration with the given configuration. cisco.nxos.nxos_lacp_interfaces: config: - - name: port-channel11 - links: - min: 4 + - name: port-channel11 + links: + min: 4 state: replaced # After state: @@ -197,9 +197,9 @@ on device with provided configuration. cisco.nxos.nxos_lacp_interfaces: config: - - name: port-channel11 - links: - min: 4 + - name: port-channel11 + links: + min: 4 state: overridden # After state: @@ -232,17 +232,17 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_lacp_interfaces: config: - - name: Ethernet1/800 - rate: fast - - name: Ethernet1/801 - rate: fast - port_priority: 32 - - name: port-channel10 - links: - max: 15 - min: 2 - convergence: - graceful: true + - name: Ethernet1/800 + rate: fast + - name: Ethernet1/801 + rate: fast + port_priority: 32 + - name: port-channel10 + links: + max: 15 + min: 2 + convergence: + graceful: true state: rendered # Task Output (redacted) diff --git a/plugins/modules/nxos_lag_interfaces.py b/plugins/modules/nxos_lag_interfaces.py index ce06462ed..8d0fabf7a 100644 --- a/plugins/modules/nxos_lag_interfaces.py +++ b/plugins/modules/nxos_lag_interfaces.py @@ -113,9 +113,9 @@ - name: Merge provided configuration with device configuration. cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel99 - members: - - member: Ethernet1/4 + - name: port-channel99 + members: + - member: Ethernet1/4 state: merged # After state: @@ -137,9 +137,9 @@ with provided configuration. cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel10 - members: - - member: Ethernet1/4 + - name: port-channel10 + members: + - member: Ethernet1/4 state: replaced # After state: @@ -163,10 +163,10 @@ device with provided configuration. cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel20 - members: - - member: Ethernet1/6 - force: true + - name: port-channel20 + members: + - member: Ethernet1/6 + force: true state: overridden # After state: @@ -189,7 +189,7 @@ itself). cisco.nxos.nxos_lag_interfaces: config: - - port-channel: port-channel99 + - port-channel: port-channel99 state: deleted - name: Delete LAG attributes of all the interfaces @@ -207,15 +207,15 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_lag_interfaces: config: - - name: port-channel10 - members: - - member: Ethernet1/800 - mode: active - - member: Ethernet1/801 - - name: port-channel11 - members: - - member: Ethernet1/802 - mode: passive + - name: port-channel10 + members: + - member: Ethernet1/800 + mode: active + - member: Ethernet1/801 + - name: port-channel11 + members: + - member: Ethernet1/802 + mode: passive state: rendered # Task Output (redacted) diff --git a/plugins/modules/nxos_lldp_interfaces.py b/plugins/modules/nxos_lldp_interfaces.py index 2006001de..44ac5b09e 100644 --- a/plugins/modules/nxos_lldp_interfaces.py +++ b/plugins/modules/nxos_lldp_interfaces.py @@ -111,12 +111,12 @@ - name: Merge provided configuration with device configuration cisco.nxos.nxos_lldp_interfaces: config: - - name: Ethernet1/4 - receive: false - transmit: true - tlv_set: - management_address: 192.168.122.64 - vlan: 12 + - name: Ethernet1/4 + receive: false + transmit: true + tlv_set: + management_address: 192.168.122.64 + vlan: 12 state: merged # After state: @@ -143,10 +143,10 @@ - name: Replace LLDP configuration on interfaces with given configuration cisco.nxos.nxos_lldp_interfaces: config: - - name: Ethernet1/4 - transmit: false - tlv_set: - vlan: 2 + - name: Ethernet1/4 + transmit: false + tlv_set: + vlan: 2 state: replaced @@ -176,10 +176,10 @@ - name: Override LLDP configuration on all interfaces with given configuration cisco.nxos.nxos_lldp_interfaces: config: - - name: Ethernet1/7 - receive: false - tlv_set: - vlan: 12 + - name: Ethernet1/7 + receive: false + tlv_set: + vlan: 12 state: overridden @@ -209,8 +209,6 @@ # After state: # ------------ # - - """ RETURN = """ before: diff --git a/plugins/modules/nxos_logging.py b/plugins/modules/nxos_logging.py index 7782eb32c..a6e6ccfff 100644 --- a/plugins/modules/nxos_logging.py +++ b/plugins/modules/nxos_logging.py @@ -192,9 +192,9 @@ - name: Configure logging using aggregate cisco.nxos.nxos_logging: aggregate: - - {dest: console, dest_level: 2} - - {dest: logfile, dest_level: 2, name: testfile} - - {facility: daemon, facility_level: 0} + - {dest: console, dest_level: 2} + - {dest: logfile, dest_level: 2, name: testfile} + - {facility: daemon, facility_level: 0} state: present """ diff --git a/plugins/modules/nxos_logging_global.py b/plugins/modules/nxos_logging_global.py index 1c060b01b..759dee67c 100644 --- a/plugins/modules/nxos_logging_global.py +++ b/plugins/modules/nxos_logging_global.py @@ -290,7 +290,7 @@ facility: local6 use_vrf: default origin_id: - hostname: True + hostname: true # Task output # ------------- @@ -576,7 +576,7 @@ facility: local6 use_vrf: default origin_id: - hostname: True + hostname: true # Task Output (redacted) # ----------------------- diff --git a/plugins/modules/nxos_ntp_global.py b/plugins/modules/nxos_ntp_global.py index e99fbef83..18cd851c9 100644 --- a/plugins/modules/nxos_ntp_global.py +++ b/plugins/modules/nxos_ntp_global.py @@ -241,7 +241,7 @@ - access_list: PeerAcl1 serve: - access_list: ServeAcl1 - authenticate: True + authenticate: true authentication_keys: - id: 1001 key: vagwwtKfkv @@ -249,7 +249,7 @@ - id: 1002 key: vagwwtKfkvgthz encryption: 7 - logging: True + logging: true master: stratum: 2 peers: @@ -260,7 +260,7 @@ vrf: default - peer: 192.0.2.2 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -293,7 +293,7 @@ # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 -# authenticate: True +# authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -301,7 +301,7 @@ # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 -# logging: True +# logging: true # master: # stratum: 2 # peers: @@ -312,7 +312,7 @@ # vrf: default # - peer: 192.0.2.2 # key_id: 2 -# prefer: True +# prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -362,7 +362,7 @@ - access_list: PeerAcl2 serve: - access_list: ServeAcl2 - logging: True + logging: true master: stratum: 2 peers: @@ -373,7 +373,7 @@ vrf: default - peer: 192.0.2.5 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -389,7 +389,7 @@ # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 -# authenticate: True +# authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -397,7 +397,7 @@ # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 -# logging: True +# logging: true # master: # stratum: 2 # peers: @@ -408,7 +408,7 @@ # vrf: default # - peer: 192.0.2.2 # key_id: 2 -# prefer: True +# prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -436,7 +436,7 @@ # - access_list: PeerAcl2 # serve: # - access_list: ServeAcl2 -# logging: True +# logging: true # master: # stratum: 2 # peers: @@ -447,7 +447,7 @@ # vrf: default # - peer: 192.0.2.5 # key_id: 2 -# prefer: True +# prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -483,7 +483,7 @@ # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 -# authenticate: True +# authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -491,7 +491,7 @@ # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 -# logging: True +# logging: true # master: # stratum: 2 # peers: @@ -502,7 +502,7 @@ # vrf: default # - peer: 192.0.2.2 # key_id: 2 -# prefer: True +# prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 @@ -542,7 +542,7 @@ - access_list: PeerAcl1 serve: - access_list: ServeAcl1 - authenticate: True + authenticate: true authentication_keys: - id: 1001 key: vagwwtKfkv @@ -550,7 +550,7 @@ - id: 1002 key: vagwwtKfkvgthz encryption: 7 - logging: True + logging: true master: stratum: 2 peers: @@ -561,7 +561,7 @@ vrf: default - peer: 192.0.2.2 key_id: 2 - prefer: True + prefer: true vrf: siteA servers: - server: 198.51.100.1 @@ -616,7 +616,7 @@ # - access_list: PeerAcl1 # serve: # - access_list: ServeAcl1 -# authenticate: True +# authenticate: true # authentication_keys: # - id: 1001 # key: vagwwtKfkv @@ -624,7 +624,7 @@ # - id: 1002 # key: vagwwtKfkvgthz # encryption: 7 -# logging: True +# logging: true # master: # stratum: 2 # peers: @@ -635,7 +635,7 @@ # vrf: default # - peer: 192.0.2.2 # key_id: 2 -# prefer: True +# prefer: true # vrf: siteA # servers: # - server: 198.51.100.1 diff --git a/plugins/modules/nxos_ospf_interfaces.py b/plugins/modules/nxos_ospf_interfaces.py index 81c4ad45b..7ed26117a 100644 --- a/plugins/modules/nxos_ospf_interfaces.py +++ b/plugins/modules/nxos_ospf_interfaces.py @@ -41,7 +41,7 @@ description: - Name/Identifier of the interface. type: str - required: True + required: true address_family: description: - OSPF settings on the interfaces in address-family context. @@ -53,7 +53,7 @@ - Address Family Identifier (AFI) for OSPF settings on the interfaces. type: str choices: ['ipv4', 'ipv6'] - required: True + required: true processes: description: - Interfaces configuration for an OSPF process. @@ -64,7 +64,7 @@ description: - OSPF process tag. type: str - required: True + required: true area: description: - Area associated with interface. @@ -74,7 +74,7 @@ description: - Area ID in IP address format. type: str - required: True + required: true secondaries: description: - Do not include secondary IPv4/IPv6 addresses. @@ -129,7 +129,7 @@ - Valid values are Cisco type 7 ENCRYPTED password, 3DES ENCRYPTED password and UNENCRYPTED (cleartext) password based on the value of encryption key. type: str - required: True + required: true message_digest_key: description: - Message digest authentication password (key) settings. @@ -139,7 +139,7 @@ description: - Key ID. type: int - required: True + required: true encryption: description: - 0 Specifies an UNENCRYPTED ospf password (key) will follow. @@ -152,7 +152,7 @@ - Valid values are Cisco type 7 ENCRYPTED password, 3DES ENCRYPTED password and UNENCRYPTED (cleartext) password based on the value of encryption key. type: str - required: True + required: true cost: description: - Cost associated with interface. @@ -236,46 +236,46 @@ config: - name: Ethernet1/1 address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.11 - - afi: ipv6 - processes: - - process_id: "200" - area: - area_id: 2.2.2.2 + - afi: ipv4 + processes: + - process_id: '100' + area: + area_id: 1.1.1.1 + secondaries: false multi_areas: - - 21.0.0.0 - - process_id: "300" + - 11.11.11.11 + - afi: ipv6 + processes: + - process_id: '200' + area: + area_id: 2.2.2.2 + multi_areas: + - 21.0.0.0 + - process_id: '300' + multi_areas: + - 50.50.50.50 multi_areas: - - 50.50.50.50 - multi_areas: - - 16.10.10.10 + - 16.10.10.10 - name: Ethernet1/2 address_family: - - afi: ipv4 - authentication: - enable: True - key_chain: test-1 - message_digest_key: - key_id: 10 - encryption: 3 - key: abc01d272be25d29 - cost: 100 - - afi: ipv6 - network: broadcast - shutdown: True + - afi: ipv4 + authentication: + enable: true + key_chain: test-1 + message_digest_key: + key_id: 10 + encryption: 3 + key: abc01d272be25d29 + cost: 100 + - afi: ipv6 + network: broadcast + shutdown: true - name: Ethernet1/3 address_family: - - afi: ipv4 - authentication_key: - encryption: 7 - key: 12090404011C03162E + - afi: ipv4 + authentication_key: + encryption: 7 + key: 12090404011C03162E state: merged # Task output: @@ -399,17 +399,17 @@ - name: Replace OSPF configurations of listed interfaces with provided configurations cisco.nxos.nxos_ospf_interfaces: config: - - name: Ethernet1/1 - address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.12 - - name: Ethernet1/3 + - name: Ethernet1/1 + address_family: + - afi: ipv4 + processes: + - process_id: "100" + area: + area_id: 1.1.1.1 + secondaries: false + multi_areas: + - 11.11.11.12 + - name: Ethernet1/3 state: replaced # Task output: @@ -543,16 +543,16 @@ - name: Override all OSPF interfaces configuration with provided configuration cisco.nxos.nxos_ospf_interfaces: config: - - name: Ethernet1/1 - address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.12 + - name: Ethernet1/1 + address_family: + - afi: ipv4 + processes: + - process_id: "100" + area: + area_id: 1.1.1.1 + secondaries: false + multi_areas: + - 11.11.11.12 state: overridden # Task output: @@ -861,53 +861,56 @@ # Using rendered -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.nxos.nxos_ospf_interfaces: config: - name: Ethernet1/1 address_family: - - afi: ipv4 - processes: - - process_id: "100" - area: - area_id: 1.1.1.1 - secondaries: False - multi_areas: - - 11.11.11.11 - - afi: ipv6 - processes: - - process_id: "200" - area: - area_id: 2.2.2.2 + - afi: ipv4 + processes: + - process_id: '100' + area: + area_id: 1.1.1.1 + secondaries: false multi_areas: - - 21.0.0.0 - - process_id: "300" + - 11.11.11.11 + - afi: ipv6 + processes: + - process_id: '200' + area: + area_id: 2.2.2.2 + multi_areas: + - 21.0.0.0 + - process_id: '300' + multi_areas: + - 50.50.50.50 multi_areas: - - 50.50.50.50 - multi_areas: - - 16.10.10.10 + - 16.10.10.10 - name: Ethernet1/2 address_family: - - afi: ipv4 - authentication: - enable: True - key_chain: test-1 - message_digest_key: - key_id: 10 - encryption: 3 - key: abc01d272be25d29 - cost: 100 - - afi: ipv6 - network: broadcast - shutdown: True + - afi: ipv4 + authentication: + enable: true + key_chain: test-1 + message_digest_key: + key_id: 10 + encryption: 3 + key: abc01d272be25d29 + cost: 100 + - afi: ipv6 + network: broadcast + shutdown: true - name: Ethernet1/3 address_family: - - afi: ipv4 - authentication_key: - encryption: 7 - key: 12090404011C03162E + - afi: ipv4 + authentication_key: + encryption: 7 + key: 12090404011C03162E state: rendered + # Task Output: # ------------ # rendered: diff --git a/plugins/modules/nxos_ospfv2.py b/plugins/modules/nxos_ospfv2.py index be23724d2..1d127b707 100644 --- a/plugins/modules/nxos_ospfv2.py +++ b/plugins/modules/nxos_ospfv2.py @@ -1018,56 +1018,56 @@ cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 198.51.100.64/27 - not_advertise: true - - prefix: 198.51.100.96/27 - cost: 120 - - area_id: 0.0.0.101 - authentication: - message_digest: true - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - redistribute: - - protocol: static - route_map: zone1-static-connect - summary_address: - - prefix: 198.51.100.128/27 - tag: 121 - - prefix: 198.51.100.160/27 + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: 198.51.100.64/27 + not_advertise: true + - prefix: 198.51.100.96/27 + cost: 120 + - area_id: 0.0.0.101 + authentication: + message_digest: true + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + redistribute: + - protocol: static + route_map: zone1-static-connect + summary_address: + - prefix: 198.51.100.128/27 + tag: 121 + - prefix: 198.51.100.160/27 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: merged # Task output: @@ -1199,43 +1199,46 @@ # vrf zone2 # auto-cost reference-bandwidth 45 Gbps -- name: Replace device configurations of listed OSPF processes with provided configurations +- name: >- + Replace device configurations of listed OSPF processes with provided + configurations cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 102 - router_id: 198.51.100.1 - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_8 - direction: in - ranges: - - prefix: 198.51.100.64/27 - not_advertise: true - - area_id: 0.0.0.101 - stub: - no_summary: true - redistribute: - - protocol: eigrp - id: 130 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - redistribute: - - protocol: bgp - id: 65563 - route_map: zone1-bgp-connect + - process_id: 102 + router_id: 198.51.100.1 areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_8 + direction: in + ranges: + - prefix: 198.51.100.64/27 + not_advertise: true + - area_id: 0.0.0.101 + stub: + no_summary: true + redistribute: + - protocol: eigrp + id: 130 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + redistribute: + - protocol: bgp + id: 65563 + route_map: zone1-bgp-connect + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true state: replaced + # Task output: # ------------ # before: @@ -1389,11 +1392,11 @@ cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 104 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - shutdown: true + - process_id: 104 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + shutdown: true state: overridden # Task output: @@ -1511,7 +1514,7 @@ cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 102 + - process_id: 102 state: deleted # Task output: @@ -1674,62 +1677,65 @@ # Using rendered -- name: Render platform specific configuration lines (without connecting to the device) +- name: >- + Render platform specific configuration lines (without connecting to the + device) cisco.nxos.nxos_ospfv2: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 198.51.100.64/27 - not_advertise: true - - prefix: 198.51.100.96/27 - cost: 120 - - area_id: 0.0.0.101 - authentication: - message_digest: true - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - redistribute: - - protocol: static - route_map: zone1-static-connect - summary_address: - - prefix: 198.51.100.128/27 - tag: 121 - - prefix: 198.51.100.160/27 + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: 198.51.100.64/27 + not_advertise: true + - prefix: 198.51.100.96/27 + cost: 120 + - area_id: 0.0.0.101 + authentication: + message_digest: true + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + redistribute: + - protocol: static + route_map: zone1-static-connect + summary_address: + - prefix: 198.51.100.128/27 + tag: 121 + - prefix: 198.51.100.160/27 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: rendered + # Task output: # ------------ # rendered: diff --git a/plugins/modules/nxos_ospfv3.py b/plugins/modules/nxos_ospfv3.py index 357afda11..226de291b 100644 --- a/plugins/modules/nxos_ospfv3.py +++ b/plugins/modules/nxos_ospfv3.py @@ -87,7 +87,7 @@ description: - The Area ID in IP Address format. type: str - required: True + required: true default_cost: description: - Specify the default cost. @@ -102,13 +102,13 @@ description: - The Route-map name. type: str - required: True + required: true direction: description: - The direction to apply the route map. type: str choices: [in, out] - required: True + required: true ranges: description: - Configure an address range for the area. @@ -119,7 +119,7 @@ description: - IP in Prefix format (x.x.x.x/len) type: str - required: True + required: true cost: description: - Cost to use for the range. @@ -169,7 +169,7 @@ - The name of the protocol. type: str choices: [bgp, direct, eigrp, isis, lisp, ospfv3, rip, static] - required: True + required: true id: description: - The identifier for the protocol specified. @@ -178,7 +178,7 @@ description: - The route map policy to constrain redistribution. type: str - required: True + required: true summary_address: description: - Configure route summarization for redistribution. @@ -189,7 +189,7 @@ description: - IPv6 prefix format 'xxxx:xxxx/ml', 'xxxx:xxxx::/ml' or 'xxxx::xx/128' type: str - required: True + required: true not_advertise: description: - Suppress advertising the specified summary. @@ -208,7 +208,7 @@ description: - The Route Map name. type: str - required: True + required: true filter: description: - Block the OSPF routes from being sent to RIB. @@ -250,7 +250,7 @@ description: - The Area ID in IP Address format. type: str - required: True + required: true nssa: description: - NSSA settings for the area. @@ -320,12 +320,12 @@ description: - Reference bandwidth used to assign OSPF cost. type: int - required: True + required: true unit: description: - Specify in which unit the reference bandwidth is specified. type: str - required: True + required: true choices: [Gbps, Mbps] flush_routes: description: @@ -378,7 +378,7 @@ description: - Set the maximum number of non self-generated LSAs. type: int - required: True + required: true threshold: description: - Threshold value (%) at which to generate a warning message. @@ -477,7 +477,7 @@ description: - The OSPF process tag. type: str - required: True + required: true router_id: description: - Set OSPF process router-id. @@ -537,7 +537,7 @@ description: - The Area ID in IP Address format. type: str - required: True + required: true nssa: description: - NSSA settings for the area. @@ -607,12 +607,12 @@ description: - Reference bandwidth used to assign OSPF cost. type: int - required: True + required: true unit: description: - Specify in which unit the reference bandwidth is specified. type: str - required: True + required: true choices: [Gbps, Mbps] graceful_restart: description: @@ -657,7 +657,7 @@ description: - Set the maximum number of non self-generated LSAs. type: int - required: True + required: true threshold: description: - Threshold value (%) at which to generate a warning message. @@ -799,7 +799,7 @@ description: - Name/Identifier of the VRF. type: str - required: True + required: true state: description: - The state the configuration should be left in. @@ -826,49 +826,49 @@ cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - address_family: - afi: ipv6 - safi: unicast - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 2001:db2::/32 - not_advertise: true - - prefix: 2001:db3::/32 - cost: 120 - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + address_family: + afi: ipv6 + safi: unicast + areas: + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: '2001:db2::/32' + not_advertise: true + - prefix: '2001:db3::/32' + cost: 120 + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: merged # Task output: @@ -992,33 +992,33 @@ cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 102 - router_id: 198.51.100.1 - address_family: - afi: ipv6 - safi: unicast - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_8 - direction: in - ranges: - - not_advertise: true - prefix: 2001:db2::/32 - redistribute: - - protocol: eigrp - id: 130 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: True - no_summary: True + - process_id: 102 + router_id: 198.51.100.1 + address_family: + afi: ipv6 + safi: unicast + areas: + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_8 + direction: in + ranges: + - not_advertise: true + prefix: 2001:db2::/32 + redistribute: + - protocol: eigrp + id: 130 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true state: replaced # Task output: @@ -1158,11 +1158,11 @@ cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 104 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - shutdown: true + - process_id: 104 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + shutdown: true state: overridden # Task output: @@ -1278,7 +1278,7 @@ cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 102 + - process_id: 102 state: deleted # Task output: @@ -1330,7 +1330,7 @@ # vrf: zone2 # # commands: -# - no router ospfv3 102 +# - no router ospfv3 102 # # after: # processes: @@ -1436,49 +1436,49 @@ cisco.nxos.nxos_ospfv3: config: processes: - - process_id: 100 - router_id: 203.0.113.20 - - process_id: 102 - router_id: 198.51.100.1 - address_family: - afi: ipv6 - safi: unicast - areas: - - area_id: 0.0.0.100 - filter_list: - - route_map: rmap_1 - direction: in - - route_map: rmap_2 - direction: out - ranges: - - prefix: 2001:db2::/32 - not_advertise: true - - prefix: 2001:db3::/32 - cost: 120 - redistribute: - - protocol: eigrp - id: 120 - route_map: rmap_1 - - protocol: direct - route_map: ospf102-direct-connect - vrfs: - - vrf: zone1 - router_id: 198.51.100.129 - areas: - - area_id: 0.0.0.102 - nssa: - default_information_originate: true - no_summary: true - - area_id: 0.0.0.103 - nssa: - no_summary: true - translate: - type7: - always: true - - vrf: zone2 - auto_cost: - reference_bandwidth: 45 - unit: Gbps + - process_id: 100 + router_id: 203.0.113.20 + - process_id: 102 + router_id: 198.51.100.1 + address_family: + afi: ipv6 + safi: unicast + areas: + - area_id: 0.0.0.100 + filter_list: + - route_map: rmap_1 + direction: in + - route_map: rmap_2 + direction: out + ranges: + - prefix: 2001:db2::/32 + not_advertise: true + - prefix: 2001:db3::/32 + cost: 120 + redistribute: + - protocol: eigrp + id: 120 + route_map: rmap_1 + - protocol: direct + route_map: ospf102-direct-connect + vrfs: + - vrf: zone1 + router_id: 198.51.100.129 + areas: + - area_id: 0.0.0.102 + nssa: + default_information_originate: true + no_summary: true + - area_id: 0.0.0.103 + nssa: + no_summary: true + translate: + type7: + always: true + - vrf: zone2 + auto_cost: + reference_bandwidth: 45 + unit: Gbps state: rendered # Task output: @@ -1571,7 +1571,7 @@ # router_id: 192.0.100.2 # - process_id: "102" # router_id: 198.54.100.1 -# shutdown: True +# shutdown: true # Using gathered diff --git a/plugins/modules/nxos_route_maps.py b/plugins/modules/nxos_route_maps.py index bcf7076f0..bf57dcb7a 100644 --- a/plugins/modules/nxos_route_maps.py +++ b/plugins/modules/nxos_route_maps.py @@ -573,44 +573,44 @@ - route_map: rmap3 entries: - - sequence: 10 - description: "*** first stanza ***" - action: permit - set: - ip: - next_hop: - verify_availability: - - address: 3.3.3.3 - track: 1 - - address: 4.4.4.4 - track: 3 + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - address: 4.4.4.4 + track: 3 - - sequence: 20 - description: "*** second stanza ***" - action: permit - set: - ip: - next_hop: - address: 6.6.6.6 2.2.2.2 - load_share: true - drop_on_fail: true + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true - - sequence: 30 - description: "*** third stanza ***" - action: permit - set: - ip: - next_hop: - peer_address: true + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true - - sequence: 40 - description: "*** fourth stanza ***" - action: permit - set: - ip: - next_hop: - unchanged: true - redist_unchanged: true + - sequence: 40 + description: "*** fourth stanza ***" + action: permit + set: + ip: + next_hop: + unchanged: true + redist_unchanged: true state: merged # Task output @@ -875,35 +875,35 @@ - AllowPrefix1 set: community: - local_as: True + local_as: true - route_map: rmap3 entries: - - sequence: 10 - description: "*** first stanza ***" - action: permit - set: - ip: - next_hop: - verify_availability: - - address: 3.3.3.3 - track: 1 - - sequence: 20 - description: "*** second stanza ***" - action: permit - set: - ip: - next_hop: - peer_address: true - - sequence: 30 - description: "*** third stanza ***" - action: permit - set: - ip: - next_hop: - address: 6.6.6.6 2.2.2.2 - load_share: true - drop_on_fail: true + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true state: replaced # Task output @@ -1062,7 +1062,7 @@ # - AllowPrefix1 # set: # community: -# local_as: True +# local_as: true # # - route_map: rmap2 # entries: @@ -1210,7 +1210,7 @@ - AllowPrefix1 set: community: - local_as: True + local_as: true state: overridden # Task output @@ -1321,7 +1321,7 @@ # - AllowPrefix1 # set: # community: -# local_as: True +# local_as: true # # After state: # ------------ diff --git a/plugins/modules/nxos_snmp_server.py b/plugins/modules/nxos_snmp_server.py index 7354dc1ee..d31dbc72c 100644 --- a/plugins/modules/nxos_snmp_server.py +++ b/plugins/modules/nxos_snmp_server.py @@ -727,18 +727,18 @@ location: serverroom-1 traps: aaa: - server_state_change: True + server_state_change: true system: - clock_change_notification: True + clock_change_notification: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: '1' community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.2.2 - informs: True + informs: true version: '3' auth: NMS users: @@ -748,16 +748,16 @@ authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true priv: privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -776,7 +776,7 @@ # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" -# localized_key: True +# localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -808,9 +808,9 @@ # location: serverroom-1 # traps: # aaa: -# server_state_change: True +# server_state_change: true # system: -# clock_change_notification: True +# clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -831,7 +831,7 @@ # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" -# localized_key: True +# localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -840,7 +840,7 @@ # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" -# localized_key: True +# localized_key: true # # - authentication: # algorithm: md5 @@ -914,16 +914,16 @@ location: serverroom-2 traps: aaa: - server_state_change: True + server_state_change: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: '1' community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.3.2 - informs: True + informs: true version: '3' auth: NMS users: @@ -933,7 +933,7 @@ authentication: algorithm: md5 password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" - localized_key: True + localized_key: true priv: privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" @@ -942,17 +942,17 @@ authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true priv: privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -973,9 +973,9 @@ # location: serverroom-1 # traps: # aaa: -# server_state_change: True +# server_state_change: true # system: -# clock_change_notification: True +# clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -996,7 +996,7 @@ # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" -# localized_key: True +# localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -1005,7 +1005,7 @@ # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" -# localized_key: True +# localized_key: true # # - authentication: # algorithm: md5 @@ -1047,16 +1047,16 @@ # location: serverroom-2 # traps: # aaa: -# server_state_change: True +# server_state_change: true # hosts: # - host: 192.0.2.1 -# traps: True +# traps: true # version: '1' # community: public # - host: 192.0.2.1 # source_interface: Ethernet1/1 # - host: 192.0.3.2 -# informs: True +# informs: true # version: '3' # auth: NMS # users: @@ -1066,7 +1066,7 @@ # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" -# localized_key: True +# localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -1075,17 +1075,17 @@ # authentication: # algorithm: md5 # password: '0x5632724fb8ac3699296af26281e1d0f1' -# localized_key: True +# localized_key: true # # - user: snmp_user_2 # group: network-operator # authentication: # algorithm: md5 # password: '0x5632724fb8ac3699296af26281e1d0f1' -# localized_key: True +# localized_key: true # priv: # privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' -# aes_128: True +# aes_128: true # # use_acls: # - user: snmp_user_1 @@ -1151,9 +1151,9 @@ # location: serverroom-1 # traps: # aaa: -# server_state_change: True +# server_state_change: true # system: -# clock_change_notification: True +# clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -1174,7 +1174,7 @@ # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" -# localized_key: True +# localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" # @@ -1183,7 +1183,7 @@ # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" -# localized_key: True +# localized_key: true # # - authentication: # algorithm: md5 @@ -1228,7 +1228,7 @@ # authentication: # algorithm: md5 # password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" -# localized_key: True +# localized_key: true # priv: # privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" @@ -1254,18 +1254,18 @@ location: serverroom-1 traps: aaa: - server_state_change: True + server_state_change: true system: - clock_change_notification: True + clock_change_notification: true hosts: - host: 192.0.2.1 - traps: True + traps: true version: '1' community: public - host: 192.0.2.1 source_interface: Ethernet1/1 - host: 192.0.2.2 - informs: True + informs: true version: '3' auth: NMS users: @@ -1275,16 +1275,16 @@ authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true - user: snmp_user_2 group: network-operator authentication: algorithm: md5 password: '0x5632724fb8ac3699296af26281e1d0f1' - localized_key: True + localized_key: true priv: privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' - aes_128: True + aes_128: true use_acls: - user: snmp_user_1 ipv4: acl1 @@ -1351,9 +1351,9 @@ # location: serverroom-1 # traps: # aaa: -# server_state_change: True +# server_state_change: true # system: -# clock_change_notification: True +# clock_change_notification: true # hosts: # - host: 192.0.2.1 # traps: true @@ -1374,7 +1374,7 @@ # authentication: # algorithm: md5 # password: "0x5632724fb8ac3699296af26281e1d0f1" -# localized_key: True +# localized_key: true # # - authentication: # algorithm: md5 diff --git a/plugins/modules/nxos_static_routes.py b/plugins/modules/nxos_static_routes.py index a7fdf6713..679f5cdb4 100644 --- a/plugins/modules/nxos_static_routes.py +++ b/plugins/modules/nxos_static_routes.py @@ -184,7 +184,7 @@ - name: Delete routes based on VRF cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf + - vrf: trial_vrf state: deleted # Task Output @@ -264,9 +264,9 @@ - name: Delete routes based on AFI in a VRF cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf - address_families: - - afi: ipv4 + - vrf: trial_vrf + address_families: + - afi: ipv4 state: deleted # Task Output @@ -348,28 +348,28 @@ - name: Merge new static route configuration cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.64/24 - next_hops: - - forward_router_address: 192.0.2.22 - tag: 4 - admin_distance: 2 - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.16/24 - next_hops: - - forward_router_address: 192.0.2.24 - route_name: new_route - - afi: ipv6 - routes: - - dest: 2001:db8::/64 - next_hops: - - interface: eth1/3 - forward_router_address: 2001:db8::12 + - vrf: trial_vrf + address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.64/24 + next_hops: + - forward_router_address: 192.0.2.22 + tag: 4 + admin_distance: 2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/24 + next_hops: + - forward_router_address: 192.0.2.24 + route_name: new_route + - afi: ipv6 + routes: + - dest: '2001:db8::/64' + next_hops: + - interface: eth1/3 + forward_router_address: '2001:db8::12' state: merged # Task Output @@ -431,19 +431,19 @@ - name: Overridden existing static route configuration with new configuration cisco.nxos.nxos_static_routes: config: - - vrf: trial_vrf - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.16/28 - next_hops: - - 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: Ethernet1/2 + - vrf: trial_vrf + address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/28 + next_hops: + - 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: Ethernet1/2 state: overridden # Task Output @@ -520,18 +520,18 @@ - name: Replaced the existing static configuration of a prefix with new configuration cisco.nxos.nxos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.16/28 - next_hops: - - 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 - interface: Ethernet1/2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.16/28 + next_hops: + - 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 + interface: Ethernet1/2 state: replaced # Task Output @@ -650,18 +650,18 @@ - name: Render required configuration to be pushed to the device cisco.nxos.nxos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.13 - - afi: ipv6 - routes: - - dest: 2001:db8::/64 - next_hops: - - interface: eth1/3 - forward_router_address: 2001:db8::12 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.13 + - afi: ipv6 + routes: + - dest: 2001:db8::/64 + next_hops: + - interface: eth1/3 + forward_router_address: 2001:db8::12 state: rendered # Task Output diff --git a/plugins/modules/nxos_system.py b/plugins/modules/nxos_system.py index df4bbde0d..dafbf9f1f 100644 --- a/plugins/modules/nxos_system.py +++ b/plugins/modules/nxos_system.py @@ -98,14 +98,14 @@ - name: configure name servers cisco.nxos.nxos_system: name_servers: - - 8.8.8.8 - - 8.8.4.4 + - 8.8.8.8 + - 8.8.4.4 - name: configure name servers with VRF support cisco.nxos.nxos_system: name_servers: - - {server: 8.8.8.8, vrf: mgmt} - - {server: 8.8.4.4, vrf: mgmt} + - {server: 8.8.8.8, vrf: mgmt} + - {server: 8.8.4.4, vrf: mgmt} """ RETURN = """ diff --git a/plugins/modules/nxos_telemetry.py b/plugins/modules/nxos_telemetry.py index 7498ff880..89a58e2d2 100644 --- a/plugins/modules/nxos_telemetry.py +++ b/plugins/modules/nxos_telemetry.py @@ -225,41 +225,41 @@ source_interface: Ethernet1/1 vrf: management destination_groups: - - id: 2 - destination: - ip: 192.168.0.2 - port: 50001 - protocol: gRPC - encoding: GPB - - id: 55 - destination: - ip: 192.168.0.55 - port: 60001 - protocol: gRPC - encoding: GPB + - id: 2 + destination: + ip: 192.168.0.2 + port: 50001 + protocol: gRPC + encoding: GPB + - id: 55 + destination: + ip: 192.168.0.55 + port: 60001 + protocol: gRPC + encoding: GPB sensor_groups: - - id: 1 - data_source: NX-API - path: - name: '"show lldp neighbors detail"' - depth: 0 - - id: 55 - data_source: DME - path: - name: sys/ch - depth: unbounded - filter_condition: ne(eqptFt.operSt,"ok") + - id: 1 + data_source: NX-API + path: + name: '"show lldp neighbors detail"' + depth: 0 + - id: 55 + data_source: DME + path: + name: sys/ch + depth: unbounded + filter_condition: ne(eqptFt.operSt,"ok") subscriptions: - - id: 5 - destination_group: 55 - sensor_group: - id: 1 - sample_interval: 1000 - - id: 6 - destination_group: 2 - sensor_group: - id: 55 - sample_interval: 2000 + - id: 5 + destination_group: 55 + sensor_group: + id: 1 + sample_interval: 1000 + - id: 6 + destination_group: 2 + sensor_group: + id: 55 + sample_interval: 2000 state: merged @@ -277,18 +277,16 @@ source_interface: Ethernet1/1 vrf: management destination_groups: - - id: 2 - destination: - ip: 192.168.0.2 - port: 50001 - protocol: gRPC - encoding: GPB + - id: 2 + destination: + ip: 192.168.0.2 + port: 50001 + protocol: gRPC + encoding: GPB subscriptions: - - id: 5 - destination_group: 55 + - id: 5 + destination_group: 55 state: replaced - - """ RETURN = """ before: diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index 2456c53ac..d3e847359 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -170,8 +170,8 @@ - name: set multiple users role cisco.nxos.nxos_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend role: network-operator state: present """ diff --git a/plugins/modules/nxos_vlans.py b/plugins/modules/nxos_vlans.py index cac276b64..4116f524b 100644 --- a/plugins/modules/nxos_vlans.py +++ b/plugins/modules/nxos_vlans.py @@ -117,10 +117,10 @@ - name: Merge provided configuration with device configuration. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: test-vlan5 - - vlan_id: 10 - enabled: false + - vlan_id: 5 + name: test-vlan5 + - vlan_id: 10 + enabled: false state: merged # After state: @@ -147,11 +147,11 @@ - name: Replace device configuration of specified vlan with provided configuration. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: test-vlan - enabled: false - - vlan_id: 10 - enabled: false + - vlan_id: 5 + name: test-vlan + enabled: false + - vlan_id: 10 + enabled: false state: replaced # After state: @@ -182,10 +182,10 @@ - name: Override device configuration of all vlans with provided configuration. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: test-vlan - - vlan_id: 10 - state: active + - vlan_id: 5 + name: test-vlan + - vlan_id: 10 + state: active state: overridden # After state: @@ -210,8 +210,8 @@ - name: Delete vlans. cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - - vlan_id: 10 + - vlan_id: 5 + - vlan_id: 10 state: deleted # After state: @@ -223,13 +223,13 @@ - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_vlans: config: - - vlan_id: 5 - name: vlan5 - mapped_vni: 100 + - vlan_id: 5 + name: vlan5 + mapped_vni: 100 - - vlan_id: 6 - name: vlan6 - state: suspend + - vlan_id: 6 + name: vlan6 + state: suspend state: rendered # Task Output (redacted) diff --git a/plugins/modules/nxos_vrf.py b/plugins/modules/nxos_vrf.py index 6b81ba99a..6017d3c88 100644 --- a/plugins/modules/nxos_vrf.py +++ b/plugins/modules/nxos_vrf.py @@ -169,48 +169,48 @@ name: ntc description: testing state: present - - name: Aggregate definition of VRFs cisco.nxos.nxos_vrf: aggregate: - - {name: test1, description: Testing, admin_state: down} - - {name: test2, interfaces: Ethernet1/2} - + - name: test1 + description: Testing + admin_state: down + - name: test2 + interfaces: Ethernet1/2 - name: Aggregate definitions of VRFs with Purge cisco.nxos.nxos_vrf: aggregate: - - {name: ntc1, description: purge test1} - - {name: ntc2, description: purge test2} + - name: ntc1 + description: purge test1 + - name: ntc2 + description: purge test2 state: present purge: true - - name: Delete VRFs exist on switch cisco.nxos.nxos_vrf: aggregate: - - {name: ntc1} - - {name: ntc2} + - name: ntc1 + - name: ntc2 state: absent - - name: Assign interfaces to VRF declaratively cisco.nxos.nxos_vrf: name: test1 interfaces: - - Ethernet2/3 - - Ethernet2/5 - + - Ethernet2/3 + - Ethernet2/5 - name: Check interfaces assigned to VRF cisco.nxos.nxos_vrf: name: test1 associated_interfaces: - - Ethernet2/3 - - Ethernet2/5 - -- name: Ensure VRF is tagged with interface Ethernet2/5 only (Removes from Ethernet2/3) + - Ethernet2/3 + - Ethernet2/5 +- name: >- + Ensure VRF is tagged with interface Ethernet2/5 only (Removes from + Ethernet2/3) cisco.nxos.nxos_vrf: name: test1 interfaces: - - Ethernet2/5 - + - Ethernet2/5 - name: Delete VRF cisco.nxos.nxos_vrf: name: ntc @@ -375,7 +375,9 @@ def map_obj_to_commands(updates, module): commands.append("vrf member {0}".format(name)) elif set(interfaces) != set(obj_in_have["interfaces"]): - missing_interfaces = list(set(interfaces) - set(obj_in_have["interfaces"])) + missing_interfaces = list( + set(interfaces) - set(obj_in_have["interfaces"]), + ) for i in missing_interfaces: commands.append("vrf context {0}".format(name)) commands.append("exit") @@ -541,7 +543,9 @@ def check_declarative_intent_params(want, module, element_spec, result): if obj_in_have: interfaces = obj_in_have.get("interfaces") if interfaces is not None and i not in interfaces: - module.fail_json(msg="Interface %s not configured on vrf %s" % (i, w["name"])) + module.fail_json( + msg="Interface %s not configured on vrf %s" % (i, w["name"]), + ) def vrf_error_check(module, commands, responses): diff --git a/plugins/modules/nxos_vrf_af.py b/plugins/modules/nxos_vrf_af.py index bf155ce8f..5bd043706 100644 --- a/plugins/modules/nxos_vrf_af.py +++ b/plugins/modules/nxos_vrf_af.py @@ -103,55 +103,50 @@ afi: ipv4 route_target_both_auto_evpn: true state: present - - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: import - - rt: 65001:1000 - direction: import - + - rt: '65000:1000' + direction: import + - rt: '65001:1000' + direction: import - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: import - - rt: 65001:1000 - state: absent - + - rt: '65000:1000' + direction: import + - rt: '65001:1000' + state: absent - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: export - - rt: 65001:1000 - direction: export - + - rt: '65000:1000' + direction: export + - rt: '65001:1000' + direction: export - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: export - state: absent - + - rt: '65000:1000' + direction: export + state: absent - cisco.nxos.nxos_vrf_af: vrf: ntc afi: ipv4 route_targets: - - rt: 65000:1000 - direction: both - state: present - - rt: 65001:1000 - direction: import - state: present - - rt: 65002:1000 - direction: both - state: absent + - rt: '65000:1000' + direction: both + state: present + - rt: '65001:1000' + direction: import + state: present + - rt: '65002:1000' + direction: both + state: absent """ RETURN = """ @@ -248,10 +243,25 @@ def main(): if platform.startswith("N9K") and rt.get("rt") == "auto": rt_commands = match_current_rt(rt, "both", current, rt_commands) else: - rt_commands = match_current_rt(rt, "import", current, rt_commands) - rt_commands = match_current_rt(rt, "export", current, rt_commands) + rt_commands = match_current_rt( + rt, + "import", + current, + rt_commands, + ) + rt_commands = match_current_rt( + rt, + "export", + current, + rt_commands, + ) else: - rt_commands = match_current_rt(rt, rt.get("direction"), current, rt_commands) + rt_commands = match_current_rt( + rt, + rt.get("direction"), + current, + rt_commands, + ) if rt_commands: commands.extend(rt_commands) diff --git a/plugins/modules/nxos_vsan.py b/plugins/modules/nxos_vsan.py index d95d95a96..70f9b50ee 100644 --- a/plugins/modules/nxos_vsan.py +++ b/plugins/modules/nxos_vsan.py @@ -51,25 +51,25 @@ - name: Test that vsan module works cisco.nxos.nxos_vsan: vsan: - - id: 922 - interface: - - fc1/1 - - fc1/2 - - port-channel 1 - name: vsan-SAN-A - remove: false - suspend: false - - id: 923 - interface: - - fc1/11 - - fc1/21 - - port-channel 2 - name: vsan-SAN-B - remove: false - suspend: true - - id: 1923 - name: vsan-SAN-Old - remove: true + - id: 922 + interface: + - fc1/1 + - fc1/2 + - port-channel 1 + name: vsan-SAN-A + remove: false + suspend: false + - id: 923 + interface: + - fc1/11 + - fc1/21 + - port-channel 2 + name: vsan-SAN-B + remove: false + suspend: true + - id: 1923 + name: vsan-SAN-Old + remove: true """ RETURN = """ @@ -198,7 +198,9 @@ def main(): interface=dict(type="list", elements="str"), ) - argument_spec = dict(vsan=dict(type="list", elements="dict", options=vsan_element_spec)) + argument_spec = dict( + vsan=dict(type="list", elements="dict", options=vsan_element_spec), + ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() @@ -238,7 +240,9 @@ def main(): if vsanremove: # Negative case: if vsanid == "4079" or vsanid == "4094": - messages.append(str(vsanid) + " is a reserved vsan, hence cannot be removed") + messages.append( + str(vsanid) + " is a reserved vsan, hence cannot be removed", + ) continue if vsanid == sw_vsanid: commands.append("no vsan " + str(vsanid)) @@ -270,7 +274,9 @@ def main(): if vsanname is not None: # Negative case: if vsanid == "4079" or vsanid == "4094": - messages.append(str(vsanid) + " is a reserved vsan, and cannot be renamed") + messages.append( + str(vsanid) + " is a reserved vsan, and cannot be renamed", + ) else: if vsanname == sw_vsanname: messages.append( @@ -282,12 +288,16 @@ def main(): ) else: commands.append("vsan " + str(vsanid) + " name " + vsanname) - messages.append("setting vsan name to " + vsanname + " for vsan " + str(vsanid)) + messages.append( + "setting vsan name to " + vsanname + " for vsan " + str(vsanid), + ) if vsansuspend: # Negative case: if vsanid == "4079" or vsanid == "4094": - messages.append(str(vsanid) + " is a reserved vsan, and cannot be suspended") + messages.append( + str(vsanid) + " is a reserved vsan, and cannot be suspended", + ) else: if sw_vsanstate == "suspended": messages.append( @@ -322,7 +332,9 @@ def main(): + " interface list", ) else: - commands.append("vsan " + str(vsanid) + " interface " + each_interface_name) + commands.append( + "vsan " + str(vsanid) + " interface " + each_interface_name, + ) messages.append( "adding interface " + each_interface_name + " to vsan " + str(vsanid), ) diff --git a/plugins/modules/nxos_zone_zoneset.py b/plugins/modules/nxos_zone_zoneset.py index 7c9fba30a..5d519150f 100644 --- a/plugins/modules/nxos_zone_zoneset.py +++ b/plugins/modules/nxos_zone_zoneset.py @@ -10,180 +10,184 @@ module: nxos_zone_zoneset short_description: Configuration of zone/zoneset for Cisco NXOS MDS Switches. description: -- Configuration of zone/zoneset for Cisco MDS NXOS. + - Configuration of zone/zoneset for Cisco MDS NXOS. version_added: 1.0.0 author: -- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) + - Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) notes: -- Tested against Cisco MDS NX-OS 8.4(1) + - Tested against Cisco MDS NX-OS 8.4(1) options: zone_zoneset_details: description: - - List of zone/zoneset details to be added or removed + - List of zone/zoneset details to be added or removed type: list elements: dict suboptions: vsan: description: - - vsan id + - vsan id required: true type: int mode: description: - - mode of the zone for the vsan + - mode of the zone for the vsan choices: - - enhanced - - basic + - enhanced + - basic type: str default_zone: description: - - default zone behaviour for the vsan + - default zone behaviour for the vsan choices: - - permit - - deny + - permit + - deny type: str smart_zoning: description: - - Removes the vsan if True + - Removes the vsan if True type: bool zone: description: - - List of zone options for that vsan + - List of zone options for that vsan type: list elements: dict suboptions: name: description: - - name of the zone + - name of the zone required: true type: str remove: description: - - Deletes the zone if True + - Deletes the zone if True type: bool default: false members: description: - - Members of the zone that needs to be removed or added + - Members of the zone that needs to be removed or added type: list elements: dict suboptions: pwwn: description: - - pwwn member of the zone, use alias 'device_alias' as option for - device_alias member + - >- + pwwn member of the zone, use alias 'device_alias' as option + for device_alias member aliases: - - device_alias + - device_alias required: true type: str remove: description: - - Removes member from the zone if True + - Removes member from the zone if True type: bool default: false devtype: description: - - devtype of the zone member used along with Smart zoning config + - >- + devtype of the zone member used along with Smart zoning + config choices: - - initiator - - target - - both + - initiator + - target + - both type: str zoneset: description: - - List of zoneset options for the vsan + - List of zoneset options for the vsan type: list elements: dict suboptions: name: description: - - name of the zoneset + - name of the zoneset required: true type: str remove: description: - - Removes zoneset if True + - Removes zoneset if True type: bool default: false action: description: - - activates/de-activates the zoneset + - activates/de-activates the zoneset choices: - - activate - - deactivate + - activate + - deactivate type: str members: description: - - Members of the zoneset that needs to be removed or added + - Members of the zoneset that needs to be removed or added type: list elements: dict suboptions: name: description: - - name of the zone that needs to be added to the zoneset or removed - from the zoneset + - >- + name of the zone that needs to be added to the zoneset or + removed from the zoneset required: true type: str remove: description: - - Removes zone member from the zoneset + - Removes zone member from the zoneset type: bool default: false + """ EXAMPLES = """ - name: Test that zone/zoneset module works cisco.nxos.nxos_zone_zoneset: zone_zoneset_details: - - mode: enhanced - vsan: 22 - zone: - - members: - - pwwn: 11:11:11:11:11:11:11:11 - - device_alias: test123 - - pwwn: 61:61:62:62:12:12:12:12 - remove: true - name: zoneA - - members: - - pwwn: 10:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:21:21:21:21 - name: zoneB - - name: zoneC - remove: true - zoneset: - - action: activate - members: - - name: zoneA - - name: zoneB - - name: zoneC - remove: true - name: zsetname1 - - action: deactivate - name: zsetTestExtra - remove: true - - mode: basic - smart_zoning: true - vsan: 21 - zone: - - members: - - devtype: both - pwwn: 11:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:12:12:12:12 - - devtype: both - pwwn: 92:62:62:62:12:12:1a:1a - remove: true - name: zone21A - - members: - - pwwn: 10:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:21:21:21:21 - name: zone21B - zoneset: - - action: activate - members: - - name: zone21A - - name: zone21B - name: zsetname212 - + - mode: enhanced + vsan: 22 + zone: + - members: + - pwwn: 31314874576271 + - device_alias: test123 + - pwwn: '61:61:62:62:12:12:12:12' + remove: true + name: zoneA + - members: + - pwwn: 28515514576271 + - pwwn: '62:62:62:62:21:21:21:21' + name: zoneB + - name: zoneC + remove: true + zoneset: + - action: activate + members: + - name: zoneA + - name: zoneB + - name: zoneC + remove: true + name: zsetname1 + - action: deactivate + name: zsetTestExtra + remove: true + - mode: basic + smart_zoning: true + vsan: 21 + zone: + - members: + - devtype: both + pwwn: 31314874576271 + - pwwn: '62:62:62:62:12:12:12:12' + - devtype: both + pwwn: '92:62:62:62:12:12:1a:1a' + remove: true + name: zone21A + - members: + - pwwn: 28515514576271 + - pwwn: '62:62:62:62:21:21:21:21' + name: zone21B + zoneset: + - action: activate + members: + - name: zone21A + - name: zone21B + name: zsetname212 """ RETURN = """ @@ -472,7 +476,11 @@ def main(): ) argument_spec = dict( - zone_zoneset_details=dict(type="list", elements="dict", options=zonedetails_spec), + zone_zoneset_details=dict( + type="list", + elements="dict", + options=zonedetails_spec, + ), ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) @@ -519,13 +527,17 @@ def main(): if op_default_zone is not None: if op_default_zone != sw_default_zone: if op_default_zone == "permit": - commands_executed.append("zone default-zone permit vsan " + str(vsan)) + commands_executed.append( + "zone default-zone permit vsan " + str(vsan), + ) messages.append( "default zone configuration changed from deny to permit for vsan " + str(vsan), ) else: - commands_executed.append("no zone default-zone permit vsan " + str(vsan)) + commands_executed.append( + "no zone default-zone permit vsan " + str(vsan), + ) messages.append( "default zone configuration changed from permit to deny for vsan " + str(vsan), @@ -565,10 +577,14 @@ def main(): if op_smart_zoning is not None: if op_smart_zoning != sw_smart_zoning_bool: if op_smart_zoning: - commands_executed.append("zone smart-zoning enable vsan " + str(vsan)) + commands_executed.append( + "zone smart-zoning enable vsan " + str(vsan), + ) messages.append("smart-zoning enabled for vsan " + str(vsan)) else: - commands_executed.append("no zone smart-zoning enable vsan " + str(vsan)) + commands_executed.append( + "no zone smart-zoning enable vsan " + str(vsan), + ) messages.append("smart-zoning disabled for vsan " + str(vsan)) else: messages.append( @@ -589,8 +605,12 @@ def main(): removeflag = eachzone["remove"] if removeflag: if shZoneObj.isZonePresent(zname): - messages.append("zone '" + zname + "' is removed from vsan " + str(vsan)) - commands_executed.append("no zone name " + zname + " vsan " + str(vsan)) + messages.append( + "zone '" + zname + "' is removed from vsan " + str(vsan), + ) + commands_executed.append( + "no zone name " + zname + " vsan " + str(vsan), + ) else: messages.append( "zone '" @@ -606,8 +626,12 @@ def main(): "zone '" + zname + "' is already present in vsan " + str(vsan), ) else: - commands_executed.append("zone name " + zname + " vsan " + str(vsan)) - messages.append("zone '" + zname + "' is created in vsan " + str(vsan)) + commands_executed.append( + "zone name " + zname + " vsan " + str(vsan), + ) + messages.append( + "zone '" + zname + "' is created in vsan " + str(vsan), + ) else: cmdmemlist = [] for eachmem in zmembers: @@ -721,7 +745,9 @@ def main(): + str(vsan), ) if len(cmdmemlist) != 0: - commands_executed.append("zone name " + zname + " vsan " + str(vsan)) + commands_executed.append( + "zone name " + zname + " vsan " + str(vsan), + ) commands_executed = commands_executed + cmdmemlist # Process zoneset member options @@ -758,7 +784,10 @@ def main(): zsetmem_name = eachzsmem["name"] zsetmem_removeflag = eachzsmem["remove"] if zsetmem_removeflag: - if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): + if shZonesetObj.isZonePresentInZoneset( + zsetname, + zsetmem_name, + ): cmd = "no member " + zsetmem_name cmdmemlist.append(cmd) messages.append( @@ -780,7 +809,10 @@ def main(): + " ,hence there is nothing to remove", ) else: - if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): + if shZonesetObj.isZonePresentInZoneset( + zsetname, + zsetmem_name, + ): messages.append( "zoneset member '" + zsetmem_name @@ -844,7 +876,9 @@ def main(): messages.append( "activating zoneset '" + zsetname + "' in vsan " + str(vsan), ) - actcmd.append("zoneset activate name " + zsetname + " vsan " + str(vsan)) + actcmd.append( + "zoneset activate name " + zsetname + " vsan " + str(vsan), + ) else: messages.append( "no changes to existing zoneset '" diff --git a/tests/config.yml b/tests/config.yml index 41f529264..c26ea5966 100644 --- a/tests/config.yml +++ b/tests/config.yml @@ -1,3 +1,3 @@ --- modules: - python_requires: ">=3.6" + python_requires: ">=3.9" From ae9b38ae7f3f226c9890d71b4a3edae77ba38be6 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 30 Nov 2023 23:06:45 +0530 Subject: [PATCH 152/166] Prepare for v6.0.0 release (#785) * Prepare for v6.0.0 release Signed-off-by: NilashishC * Readme updates Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update CHANGELOG.rst Co-authored-by: Sagar Paul * Update changelogs/changelog.yaml Co-authored-by: Sagar Paul --------- Signed-off-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sagar Paul --- CHANGELOG.rst | 13 +++++++++++++ README.md | 4 +--- changelogs/changelog.yaml | 13 +++++++++++++ changelogs/fragments/trivial_lint.yaml | 3 --- galaxy.yml | 4 ++-- 5 files changed, 29 insertions(+), 8 deletions(-) delete mode 100644 changelogs/fragments/trivial_lint.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a23f4bf80..6571b46c6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,19 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v6.0.0 +====== + +Release Summary +--------------- + +Starting from this release, the minimum `ansible-core` version this collection requires is `2.14.0`. The last known version compatible with ansible-core<2.14 is `v5.3.0`. + +Major Changes +------------- + +- Bumping `requires_ansible` to `>=2.14.0`, since previous ansible-core versions are EoL now. + v5.3.0 ====== diff --git a/README.md b/README.md index d7e176763..73f6a5717 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ - - # Cisco NX-OS Collection -[![CI](https://zuul-ci.org/gated.svg)](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/cisco.nxos) +[![CI](https://zuul-ci.org/gated.svg)](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/cisco.nxos) [![Codecov](https://codecov.io/gh/ansible-collections/cisco.nxos/branch/main/graph/badge.svg)](https://codecov.io/gh/ansible-collections/cisco.nxos) [![CI](https://github.com/ansible-collections/cisco.nxos/actions/workflows/tests.yml/badge.svg?branch=main&event=schedule)](https://github.com/ansible-collections/cisco.nxos/actions/workflows/tests.yml) diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 055d17154..ad41cda1f 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1023,3 +1023,16 @@ releases: - fix_config_module.yaml - trivial.yaml release_date: "2023-11-29" + 6.0.0: + changes: + major_changes: + - Bumping `requires_ansible` to `>=2.14.0`, since previous ansible-core versions + are EoL now. + release_summary: + Starting from this release, the minimum `ansible-core` version + this collection requires is `2.14.0`. The last known version compatible with + ansible-core<2.14 is `v5.3.0`. + fragments: + - prep_300.yaml + - trivial_lint.yaml + release_date: "2023-11-30" diff --git a/changelogs/fragments/trivial_lint.yaml b/changelogs/fragments/trivial_lint.yaml deleted file mode 100644 index 744f36321..000000000 --- a/changelogs/fragments/trivial_lint.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - "Fix lint action reference." diff --git a/galaxy.yml b/galaxy.yml index da53d0068..d64fdf5d5 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ authors: - Ansible Network Community (ansible-network) dependencies: - "ansible.netcommon": ">=2.6.1" + "ansible.netcommon": ">=6.0.0" license_file: LICENSE name: nxos namespace: cisco @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 5.3.0 +version: 6.0.0 From 8516bb63850c9d396e9af457a656549ed9d8818a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:53:02 +0530 Subject: [PATCH 153/166] [pre-commit.ci] pre-commit autoupdate (#786) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.3](https://github.com/pre-commit/mirrors-prettier/compare/v3.1.0...v4.0.0-alpha.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ac716f311..d29aec64f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" + rev: "v4.0.0-alpha.3" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" From e13021b15f62d57cb920a6e9895ac62d1fc29d03 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:11:18 +0530 Subject: [PATCH 154/166] [pre-commit.ci] pre-commit autoupdate (#790) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v4.0.0-alpha.3 → v4.0.0-alpha.4](https://github.com/pre-commit/mirrors-prettier/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) - [github.com/PyCQA/isort: 5.12.0 → 5.13.0](https://github.com/PyCQA/isort/compare/5.12.0...5.13.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d29aec64f..890c40128 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.3" + rev: "v4.0.0-alpha.4" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" @@ -33,7 +33,7 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.0 hooks: - id: isort name: Sort import statements using isort From e224c1c69d75605969cc5604b1d01539fcf26859 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:50:18 +0530 Subject: [PATCH 155/166] [pre-commit.ci] pre-commit autoupdate (#793) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v4.0.0-alpha.4 → v4.0.0-alpha.7](https://github.com/pre-commit/mirrors-prettier/compare/v4.0.0-alpha.4...v4.0.0-alpha.7) - [github.com/PyCQA/isort: 5.13.0 → 5.13.2](https://github.com/PyCQA/isort/compare/5.13.0...5.13.2) - [github.com/psf/black: 23.11.0 → 23.12.0](https://github.com/psf/black/compare/23.11.0...23.12.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 890c40128..7a88b072d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.4" + rev: "v4.0.0-alpha.7" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" @@ -33,13 +33,13 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: 5.13.0 + rev: 5.13.2 hooks: - id: isort name: Sort import statements using isort args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.0 hooks: - id: black From c4373bba62b4d05d4caf7ac425e11cd3fc21eebc Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 20 Dec 2023 11:30:55 +0530 Subject: [PATCH 156/166] Fix integration tests (#797) Signed-off-by: NilashishC --- .../targets/nxos_file_copy/tests/cli/sanity.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml b/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml index 70c450c39..0f2bdbb0f 100644 --- a/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/cli/sanity.yaml @@ -132,11 +132,11 @@ - result.changed == true - "'copy scp:' in result.copy_cmd" - "'bootflash:' in result.file_system" - - "'bootflash:dir1/dir2/dir3/{{ test_destination_file }}_copy' in result.local_file" - - "'/{{ test_destination_file }}' in result.remote_file" + - "'bootflash:dir1/dir2/dir3/test_destination_file_copy' in result.local_file" + - "'/test_destination_file' in result.remote_file" - "'Received: File copied/pulled to nxos device from remote scp server.' in result.transfer_status" - - "'{{ mgmt0_ip }}' in result.remote_scp_server" + - mgmt0_ip in result.remote_scp_server - ansible.builtin.pause: seconds: 60 @@ -169,11 +169,11 @@ - result.changed == true - "'copy sftp:' in result.copy_cmd" - "'bootflash:' in result.file_system" - - "'bootflash:dir1/dir2/dir3/{{ test_destination_file }}_another_copy' in result.local_file" - - "'/bootflash/{{ test_destination_file }}' in result.remote_file" + - "'bootflash:dir1/dir2/dir3/test_destination_file_another_copy' in result.local_file" + - "'/bootflash/test_destination_file' in result.remote_file" - "'Received: File copied/pulled to nxos device from remote scp server.' in result.transfer_status" - - "'{{ mgmt0_ip }}' in result.remote_scp_server" + - mgmt0_ip in result.remote_scp_server always: - name: Remove file From 40413b03d3e50d10764397753dc26c81200318b5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 27 Dec 2023 15:00:49 +0530 Subject: [PATCH 157/166] [pre-commit.ci] pre-commit autoupdate (#798) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v4.0.0-alpha.7 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v4.0.0-alpha.7...v4.0.0-alpha.8) - [github.com/psf/black: 23.12.0 → 23.12.1](https://github.com/psf/black/compare/23.12.0...23.12.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a88b072d..9661257ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.7" + rev: "v4.0.0-alpha.8" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.12.0 + rev: 23.12.1 hooks: - id: black From 8fa5716d894bfa46fb7060cf54c9616368499602 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 10 Jan 2024 17:32:23 +0530 Subject: [PATCH 158/166] [file_copy] timeout calculation fixes (#791) * [file_copy] timeout calculation fixes Signed-off-by: NilashishC * Fix typo Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/file_copy.yaml | 3 ++ plugins/action/nxos.py | 43 +++++++++++++++++------------ 2 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 changelogs/fragments/file_copy.yaml diff --git a/changelogs/fragments/file_copy.yaml b/changelogs/fragments/file_copy.yaml new file mode 100644 index 000000000..06f9fd37e --- /dev/null +++ b/changelogs/fragments/file_copy.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_file_copy - fix setting file_pull_timeout/persistent_command_timeout value." diff --git a/plugins/action/nxos.py b/plugins/action/nxos.py index 3602c4074..e57c08aeb 100644 --- a/plugins/action/nxos.py +++ b/plugins/action/nxos.py @@ -21,7 +21,6 @@ __metaclass__ = type -from ansible import constants as C from ansible.module_utils.connection import Connection from ansible.utils.display import Display from ansible_collections.ansible.netcommon.plugins.action.network import ( @@ -48,7 +47,7 @@ def run(self, tmp=None, task_vars=None): ): return { "failed": True, - "msg": "Connection httpapi is not valid for '%s' module." % (module_name), + "msg": f"Connection httpapi is not valid for {module_name} module.", } if module_name == "nxos_file_copy": @@ -58,34 +57,43 @@ def run(self, tmp=None, task_vars=None): if persistent_connection != "network_cli": return { "failed": True, - "msg": "Connection type must be fully qualified name for network_cli connection type, got %s" + "msg": ( + f"Connection type must be fully qualified name for " + f"network_cli connection type, got {self._play_context.connection}" + ) % self._play_context.connection, } conn = Connection(self._connection.socket_path) + persistent_command_timeout = conn.get_option("persistent_command_timeout") file_pull = self._task.args.get("file_pull", False) - file_pull_timeout = self._task.args.get("file_pull_timeout", 300) + file_pull_timeout = self._task.args.get("file_pull_timeout") connect_ssh_port = self._task.args.get("connect_ssh_port", 22) if file_pull: - conn.set_option("persistent_command_timeout", file_pull_timeout) + # if file_pull_timeout is explicitly set, use that + if file_pull_timeout: + conn.set_option("persistent_command_timeout", file_pull_timeout) + # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s. + elif persistent_command_timeout < 300: + conn.set_option("persistent_command_timeout", 300) conn.set_option("port", connect_ssh_port) if module_name == "nxos_install_os": connection = self._connection - if connection.transport == "local": - persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT - persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT - else: - persistent_command_timeout = connection.get_option("persistent_command_timeout") - persistent_connect_timeout = connection.get_option("persistent_connect_timeout") + persistent_command_timeout = connection.get_option( + "persistent_command_timeout", + ) + persistent_connect_timeout = connection.get_option( + "persistent_connect_timeout", + ) display.vvvv( - "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout), + f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}", self._play_context.remote_addr, ) display.vvvv( - "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout), + f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}", self._play_context.remote_addr, ) if persistent_command_timeout < 600 or persistent_connect_timeout < 600: @@ -102,18 +110,19 @@ def run(self, tmp=None, task_vars=None): if persistent_connection in ("network_cli", "httpapi"): if module_name == "nxos_gir": conn = Connection(self._connection.socket_path) - persistent_command_timeout = conn.get_option("persistent_command_timeout") + persistent_command_timeout = conn.get_option( + "persistent_command_timeout", + ) gir_timeout = 200 if persistent_command_timeout < gir_timeout: conn.set_option("persistent_command_timeout", gir_timeout) - msg = "timeout value extended to %ss for nxos_gir" % gir_timeout + msg = f"timeout value extended to %ss for nxos_gir {gir_timeout}" display.warning(msg) else: return { "failed": True, - "msg": "Connection type %s is not valid for this module" - % self._play_context.connection, + "msg": f"Connection type {self._play_context.connection} is not valid for this module", } result = super(ActionModule, self).run(task_vars=task_vars) From a19c46d87e6bf6cc752ba8e46fc47a60745878b0 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 17 Jan 2024 12:23:02 +0530 Subject: [PATCH 159/166] Move platform guide to this repo (#802) Signed-off-by: NilashishC --- README.md | 2 +- platform_guide.rst | 167 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 platform_guide.rst diff --git a/README.md b/README.md index 73f6a5717..1878c8646 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ PEP440 is the schema used to describe the versions of Ansible. ### Supported connections -The Cisco NX-OS collection supports ``network_cli`` and ``httpapi`` connections. +The Cisco NX-OS collection supports ``network_cli`` and ``httpapi`` connections. A detailed platform guide can be found [here](https://github.com/ansible-collections/cisco.nxos/blob/main/platform_guide.rst). ## Included content diff --git a/platform_guide.rst b/platform_guide.rst new file mode 100644 index 000000000..250854561 --- /dev/null +++ b/platform_guide.rst @@ -0,0 +1,167 @@ +.. _nxos_platform_options: + +*************************************** +NXOS Platform Options +*************************************** + +The `Cisco NXOS `_ supports multiple connections. This page offers details on how each connection works in Ansible and how to use it. + +.. contents:: + :local: + +Connections available +================================================================================ + +.. table:: + :class: documentation-table + + ==================== ========================================== ========================= + .. CLI NX-API + ==================== ========================================== ========================= + Protocol SSH HTTP(S) + + Credentials uses SSH keys / SSH-agent if present uses HTTPS certificates if + present + accepts ``-u myuser -k`` if using password + + Indirect Access by a bastion (jump host) by a web proxy + + Connection Settings ``ansible_connection:`` ``ansible_connection:`` + ``ansible.netcommon.network_cli`` ``ansible.netcommon.httpapi`` + + Enable Mode supported: use ``ansible_become: true`` not supported by NX-API + with ``ansible_become_method: enable`` + and ``ansible_become_password:`` + + Returned Data Format ``stdout[0].`` ``stdout[0].messages[0].`` + ==================== ========================================== ========================= + + +The ``ansible_connection: local`` has been deprecated. Please use ``ansible_connection: ansible.netcommon.network_cli`` or ``ansible_connection: ansible.netcommon.httpapi`` instead. + +Using CLI in Ansible +==================== + +Example CLI ``group_vars/nxos.yml`` +----------------------------------- + +.. code-block:: yaml + + ansible_connection: ansible.netcommon.network_cli + ansible_network_os: cisco.nxos.nxos + ansible_user: myuser + ansible_password: !vault... + ansible_become: true + ansible_become_method: enable + ansible_become_password: !vault... + ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"' + + +- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_password`` configuration. +- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration. +- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords through environment variables. + +Example CLI task +---------------- + +.. code-block:: yaml + + - name: Backup current switch config (nxos) + cisco.nxos.nxos_config: + backup: yes + register: backup_nxos_location + when: ansible_network_os == 'cisco.nxos.nxos' + + + +Using NX-API in Ansible +======================= + +Enabling NX-API +--------------- + +Before you can use NX-API to connect to a switch, you must enable NX-API. To enable NX-API on a new switch through Ansible, use the ``nxos_nxapi`` module through the CLI connection. Set up group_vars/nxos.yml just like in the CLI example above, then run a playbook task like this: + +.. code-block:: yaml + + - name: Enable NX-API + cisco.nxos.nxos_nxapi: + enable_http: yes + enable_https: yes + when: ansible_network_os == 'cisco.nxos.nxos' + +To find out more about the options for enabling HTTP/HTTPS and local http see the :ref:`nxos_nxapi ` module documentation. + +Once NX-API is enabled, change your ``group_vars/nxos.yml`` to use the NX-API connection. + +Example NX-API ``group_vars/nxos.yml`` +-------------------------------------- + +.. code-block:: yaml + + ansible_connection: ansible.netcommon.httpapi + ansible_network_os: cisco.nxos.nxos + ansible_user: myuser + ansible_password: !vault... + proxy_env: + http_proxy: http://proxy.example.com:8080 + +- If you are accessing your host directly (not through a web proxy) you can remove the ``proxy_env`` configuration. +- If you are accessing your host through a web proxy using ``https``, change ``http_proxy`` to ``https_proxy``. + + +Example NX-API task +------------------- + +.. code-block:: yaml + + - name: Backup current switch config (nxos) + cisco.nxos.nxos_config: + backup: yes + register: backup_nxos_location + environment: "{{ proxy_env }}" + when: ansible_network_os == 'cisco.nxos.nxos' + +In this example the ``proxy_env`` variable defined in ``group_vars`` gets passed to the ``environment`` option of the module used in the task. + +Warning +-------- +Never store passwords in plain text. We recommend using SSH keys to authenticate SSH connections. Ansible supports ssh-agent to manage your SSH keys. If you must use passwords to authenticate SSH connections, we recommend encrypting them with Ansible Vault. + +Cisco Nexus platform support matrix +=================================== + +The following platforms and software versions have been certified by Cisco to work with this version of Ansible. + +.. table:: Platform / Software Minimum Requirements + :align: center + + =================== ===================== + Supported Platforms Minimum NX-OS Version + =================== ===================== + Cisco Nexus N3k 7.0(3)I2(5) and later + Cisco Nexus N9k 7.0(3)I2(5) and later + Cisco Nexus N5k 7.3(0)N1(1) and later + Cisco Nexus N6k 7.3(0)N1(1) and later + Cisco Nexus N7k 7.3(0)D1(1) and later + Cisco Nexus MDS 8.4(1) and later (Please see individual module documentation for compatibility) + =================== ===================== + +.. table:: Platform Models + :align: center + + ======== ============================================== + Platform Description + ======== ============================================== + N3k Support includes N30xx, N31xx and N35xx models + N5k Support includes all N5xxx models + N6k Support includes all N6xxx models + N7k Support includes all N7xxx models + N9k Support includes all N9xxx models + MDS Support includes all MDS 9xxx models + ======== ============================================== + +Notes +----- + +`Setting Timeout Option `_ From 69499b87a6c94767a718bea8f4d7ec9a3135900a Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 29 Jan 2024 17:04:07 +0530 Subject: [PATCH 160/166] fix_module_defaults (#804) --- changelogs/fragments/module_defaults.yaml | 3 + meta/runtime.yml | 325 ---------------------- 2 files changed, 3 insertions(+), 325 deletions(-) create mode 100644 changelogs/fragments/module_defaults.yaml diff --git a/changelogs/fragments/module_defaults.yaml b/changelogs/fragments/module_defaults.yaml new file mode 100644 index 000000000..f1a4bad89 --- /dev/null +++ b/changelogs/fragments/module_defaults.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Prevents module_defaults from were being incorrectly applied to the platform action, instead of the concerned module. diff --git a/meta/runtime.yml b/meta/runtime.yml index 2f4209953..ae5586276 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,331 +1,6 @@ --- requires_ansible: ">=2.14.0" plugin_routing: - action: - nxos_aaa_server: - redirect: cisco.nxos.nxos - aaa_server: - redirect: cisco.nxos.nxos - nxos_aaa_server_host: - redirect: cisco.nxos.nxos - aaa_server_host: - redirect: cisco.nxos.nxos - nxos_acl_interfaces: - redirect: cisco.nxos.nxos - acl_interfaces: - redirect: cisco.nxos.nxos - nxos_acls: - redirect: cisco.nxos.nxos - acls: - redirect: cisco.nxos.nxos - nxos_banner: - redirect: cisco.nxos.nxos - banner: - redirect: cisco.nxos.nxos - nxos_bfd_global: - redirect: cisco.nxos.nxos - bfd_global: - redirect: cisco.nxos.nxos - nxos_bfd_interfaces: - redirect: cisco.nxos.nxos - bfd_interfaces: - redirect: cisco.nxos.nxos - nxos_command: - redirect: cisco.nxos.nxos - command: - redirect: cisco.nxos.nxos - nxos_config: - redirect: cisco.nxos.nxos - config: - redirect: cisco.nxos.nxos - nxos_devicealias: - redirect: cisco.nxos.nxos - devicealias: - redirect: cisco.nxos.nxos - nxos_evpn_global: - redirect: cisco.nxos.nxos - evpn_global: - redirect: cisco.nxos.nxos - nxos_evpn_vni: - redirect: cisco.nxos.nxos - evpn_vni: - redirect: cisco.nxos.nxos - nxos_facts: - redirect: cisco.nxos.nxos - facts: - redirect: cisco.nxos.nxos - nxos_feature: - redirect: cisco.nxos.nxos - feature: - redirect: cisco.nxos.nxos - nxos_gir: - redirect: cisco.nxos.nxos - gir: - redirect: cisco.nxos.nxos - nxos_gir_profile_management: - redirect: cisco.nxos.nxos - gir_profile_management: - redirect: cisco.nxos.nxos - nxos_hostname: - redirect: cisco.nxos.nxos - hostname: - redirect: cisco.nxos.nxos - nxos_hsrp: - redirect: cisco.nxos.nxos - hsrp: - redirect: cisco.nxos.nxos - nxos_hsrp_interfaces: - redirect: cisco.nxos.nxos - hsrp_interfaces: - redirect: cisco.nxos.nxos - nxos_igmp: - redirect: cisco.nxos.nxos - igmp: - redirect: cisco.nxos.nxos - nxos_igmp_interface: - redirect: cisco.nxos.nxos - igmp_interface: - redirect: cisco.nxos.nxos - nxos_igmp_snooping: - redirect: cisco.nxos.nxos - igmp_snooping: - redirect: cisco.nxos.nxos - nxos_install_os: - redirect: cisco.nxos.nxos - install_os: - redirect: cisco.nxos.nxos - nxos_interfaces: - redirect: cisco.nxos.nxos - interfaces: - redirect: cisco.nxos.nxos - nxos_l2_interfaces: - redirect: cisco.nxos.nxos - l2_interfaces: - redirect: cisco.nxos.nxos - nxos_l3_interfaces: - redirect: cisco.nxos.nxos - l3_interfaces: - redirect: cisco.nxos.nxos - nxos_lacp: - redirect: cisco.nxos.nxos - lacp: - redirect: cisco.nxos.nxos - nxos_lacp_interfaces: - redirect: cisco.nxos.nxos - lacp_interfaces: - redirect: cisco.nxos.nxos - nxos_lag_interfaces: - redirect: cisco.nxos.nxos - lag_interfaces: - redirect: cisco.nxos.nxos - nxos_lldp_global: - redirect: cisco.nxos.nxos - lldp_global: - redirect: cisco.nxos.nxos - nxos_lldp_interfaces: - redirect: cisco.nxos.nxos - lldp_interfaces: - redirect: cisco.nxos.nxos - nxos_logging: - redirect: cisco.nxos.nxos - logging: - redirect: cisco.nxos.nxos - nxos_logging_global: - redirect: cisco.nxos.nxos - logging_global: - redirect: cisco.nxos.nxos - nxos_ntp_global: - redirect: cisco.nxos.nxos - ntp_global: - redirect: cisco.nxos.nxos - nxos_ntp: - redirect: cisco.nxos.nxos - ntp: - redirect: cisco.nxos.nxos - nxos_ntp_auth: - redirect: cisco.nxos.nxos - ntp_auth: - redirect: cisco.nxos.nxos - nxos_ntp_options: - redirect: cisco.nxos.nxos - ntp_options: - redirect: cisco.nxos.nxos - nxos_nxapi: - redirect: cisco.nxos.nxos - nxapi: - redirect: cisco.nxos.nxos - nxos_ospf_interfaces: - redirect: cisco.nxos.nxos - ospf_interfaces: - redirect: cisco.nxos.nxos - nxos_bgp_global: - redirect: cisco.nxos.nxos - bgp_global: - redirect: cisco.nxos.nxos - nxos_bgp_address_family: - redirect: cisco.nxos.nxos - bgp_address_family: - redirect: cisco.nxos.nxos - nxos_ospfv2: - redirect: cisco.nxos.nxos - ospfv2: - redirect: cisco.nxos.nxos - nxos_ospfv3: - redirect: cisco.nxos.nxos - ospfv3: - redirect: cisco.nxos.nxos - nxos_overlay_global: - redirect: cisco.nxos.nxos - overlay_global: - redirect: cisco.nxos.nxos - nxos_pim: - redirect: cisco.nxos.nxos - pim: - redirect: cisco.nxos.nxos - nxos_pim_interface: - redirect: cisco.nxos.nxos - pim_interface: - redirect: cisco.nxos.nxos - nxos_pim_rp_address: - redirect: cisco.nxos.nxos - pim_rp_address: - redirect: cisco.nxos.nxos - nxos_ping: - redirect: cisco.nxos.nxos - ping: - redirect: cisco.nxos.nxos - nxos_prefix_lists: - redirect: cisco.nxos.nxos - prefix_lists: - redirect: cisco.nxos.nxos - nxos_reboot: - redirect: cisco.nxos.nxos - reboot: - redirect: cisco.nxos.nxos - nxos_rollback: - redirect: cisco.nxos.nxos - rollback: - redirect: cisco.nxos.nxos - nxos_route_maps: - redirect: cisco.nxos.nxos - route_maps: - redirect: cisco.nxos.nxos - nxos_rpm: - redirect: cisco.nxos.nxos - rpm: - redirect: cisco.nxos.nxos - nxos_snapshot: - redirect: cisco.nxos.nxos - snapshot: - redirect: cisco.nxos.nxos - nxos_snmp_community: - redirect: cisco.nxos.nxos - snmp_community: - redirect: cisco.nxos.nxos - nxos_snmp_contact: - redirect: cisco.nxos.nxos - snmp_contact: - redirect: cisco.nxos.nxos - nxos_snmp_host: - redirect: cisco.nxos.nxos - snmp_host: - redirect: cisco.nxos.nxos - nxos_snmp_location: - redirect: cisco.nxos.nxos - snmp_location: - redirect: cisco.nxos.nxos - nxos_snmp_server: - redirect: cisco.nxos.nxos - snmp_server: - redirect: cisco.nxos.nxos - nxos_snmp_traps: - redirect: cisco.nxos.nxos - snmp_traps: - redirect: cisco.nxos.nxos - nxos_snmp_user: - redirect: cisco.nxos.nxos - snmp_user: - redirect: cisco.nxos.nxos - nxos_static_route: - redirect: cisco.nxos.nxos - static_routes: - redirect: cisco.nxos.nxos - nxos_system: - redirect: cisco.nxos.nxos - system: - redirect: cisco.nxos.nxos - nxos_telemetry: - redirect: cisco.nxos.nxos - telemetry: - redirect: cisco.nxos.nxos - nxos_udld: - redirect: cisco.nxos.nxos - udld: - redirect: cisco.nxos.nxos - nxos_udld_interface: - redirect: cisco.nxos.nxos - udld_interface: - redirect: cisco.nxos.nxos - nxos_user: - redirect: cisco.nxos.nxos - user: - redirect: cisco.nxos.nxos - nxos_vlans: - redirect: cisco.nxos.nxos - vlans: - redirect: cisco.nxos.nxos - nxos_vpc: - redirect: cisco.nxos.nxos - vpc: - redirect: cisco.nxos.nxos - nxos_vpc_interface: - redirect: cisco.nxos.nxos - vpc_interface: - redirect: cisco.nxos.nxos - nxos_vrf: - redirect: cisco.nxos.nxos - vrf: - redirect: cisco.nxos.nxos - nxos_vrf_af: - redirect: cisco.nxos.nxos - vrf_af: - redirect: cisco.nxos.nxos - nxos_vrf_interface: - redirect: cisco.nxos.nxos - vrf_interface: - redirect: cisco.nxos.nxos - nxos_vrrp: - redirect: cisco.nxos.nxos - vrrp: - redirect: cisco.nxos.nxos - nxos_vsan: - redirect: cisco.nxos.nxos - vsan: - redirect: cisco.nxos.nxos - nxos_vtp_domain: - redirect: cisco.nxos.nxos - vtp_domain: - redirect: cisco.nxos.nxos - nxos_vtp_password: - redirect: cisco.nxos.nxos - vtp_password: - redirect: cisco.nxos.nxos - nxos_vtp_version: - redirect: cisco.nxos.nxos - vtp_version: - redirect: cisco.nxos.nxos - nxos_vxlan_vtep: - redirect: cisco.nxos.nxos - vxlan_vtep: - redirect: cisco.nxos.nxos - nxos_vxlan_vtep_vni: - redirect: cisco.nxos.nxos - vxlan_vtep_vni: - redirect: cisco.nxos.nxos - nxos_zone_zoneset: - redirect: cisco.nxos.nxos - zone_zoneset: - redirect: cisco.nxos.nxos modules: aaa_server: redirect: cisco.nxos.nxos_aaa_server From dcf7bc27e967495e5e2e64da776849524bfb1740 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 30 Jan 2024 18:11:20 +0530 Subject: [PATCH 161/166] Prepare for v6.0.1 (#808) Signed-off-by: NilashishC --- CHANGELOG.rst | 9 +++++++++ changelogs/changelog.yaml | 11 +++++++++++ changelogs/fragments/file_copy.yaml | 3 --- changelogs/fragments/module_defaults.yaml | 3 --- 4 files changed, 20 insertions(+), 6 deletions(-) delete mode 100644 changelogs/fragments/file_copy.yaml delete mode 100644 changelogs/fragments/module_defaults.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6571b46c6..3d2c80b79 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,15 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v6.0.1 +====== + +Bugfixes +-------- + +- Prevents module_defaults from were being incorrectly applied to the platform action, instead of the concerned module. +- nxos_file_copy - correctly set file_pull_timeout/persistent_command_timeout value. + v6.0.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index ad41cda1f..0b1922567 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1036,3 +1036,14 @@ releases: - prep_300.yaml - trivial_lint.yaml release_date: "2023-11-30" + 6.0.1: + changes: + bugfixes: + - Prevents module_defaults from were being incorrectly applied to the platform + action, instead of the concerned module. + - nxos_file_copy - corectly set file_pull_timeout/persistent_command_timeout + value. + fragments: + - file_copy.yaml + - module_defaults.yaml + release_date: "2024-01-30" diff --git a/changelogs/fragments/file_copy.yaml b/changelogs/fragments/file_copy.yaml deleted file mode 100644 index 06f9fd37e..000000000 --- a/changelogs/fragments/file_copy.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_file_copy - fix setting file_pull_timeout/persistent_command_timeout value." diff --git a/changelogs/fragments/module_defaults.yaml b/changelogs/fragments/module_defaults.yaml deleted file mode 100644 index f1a4bad89..000000000 --- a/changelogs/fragments/module_defaults.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - Prevents module_defaults from were being incorrectly applied to the platform action, instead of the concerned module. From 472ae1b207eb6389e31f62f0c5505cc54f9b3da5 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Tue, 30 Jan 2024 21:57:25 +0530 Subject: [PATCH 162/166] Update version 6.0.1 in galaxy.yml (#809) --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index d64fdf5d5..dd7a20fac 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 6.0.0 +version: 6.0.1 From 1882f7c58452f4f8586b325af51051f94ba8d41d Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 5 Feb 2024 12:01:51 +0530 Subject: [PATCH 163/166] Update test-requirements.txt --- test-requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 94ff7c9e3..5a90586f2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,9 +1,9 @@ # For ansible-tox-linters -black==23.3.0 ; python_version >= '3.7' +black==23.3.0 flake8 yamllint # Unit test runner -pytest-ansible ; python_version >= '3.9' -git+https://github.com/ansible-community/pytest-ansible-units.git ; python_version < '3.9' +pytest-ansible pytest-xdist +pytest-cov From 3a65be4c08b0defa9d73a6ef9f7f056b377753c0 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 6 Feb 2024 21:42:22 +0530 Subject: [PATCH 164/166] [interfaces] correctly enable interfaces on N3K (#813) Signed-off-by: NilashishC --- changelogs/fragments/fix_749.yaml | 3 +++ .../module_utils/network/nxos/config/interfaces/interfaces.py | 4 ++-- tests/unit/modules/network/nxos/test_nxos_interfaces.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/fix_749.yaml diff --git a/changelogs/fragments/fix_749.yaml b/changelogs/fragments/fix_749.yaml new file mode 100644 index 000000000..d01fd54f7 --- /dev/null +++ b/changelogs/fragments/fix_749.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_interfaces - Correctly enable L3 interfaces on supported N3K platforms (https://github.com/ansible-collections/cisco.nxos/issues/749)." diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index 8bd4f66e7..400f0432f 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -470,13 +470,13 @@ def render_interface_defaults(self, config, intfs): and enabled/shutdown states. The default values for user-defined-default configurations may be different for legacy platforms. Notes: - - L3 enabled default state is False on N9K,N7K but True for N3K,N6K + - L3 enabled default state is False on N9K,N7K,N3K but True for N5K,N6K - Changing L2-L3 modes may change the default enabled value. - '(no) system default switchport shutdown' only applies to L2 interfaces. Run through the gathered interfaces and tag their default enabled state. """ intf_defs = {} - L3_enabled = True if re.search("N[356]K", self.get_platform()) else False + L3_enabled = True if re.search("N[56]K", self.get_platform()) else False intf_defs = { "sysdefs": { "mode": None, diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index fb8dae234..a1d491af1 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -84,7 +84,7 @@ def load_fixtures(self, commands=None, device=""): self.edit_config.return_value = None if device == "legacy": # call execute_module() with device='legacy' to use this codepath - self.get_platform.return_value = "N3K-Cxxx" + self.get_platform.return_value = "N5K-Cxxx" else: self.get_platform.return_value = "N9K-Cxxx" From 5af76abef8b8f74e97c43bd9b47a5b23b4c30072 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 7 Feb 2024 09:00:26 +0530 Subject: [PATCH 165/166] Prepare for v6.0.2 (#814) * Prepare for v6.0.2 Signed-off-by: NilashishC * Fix typo Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- CHANGELOG.rst | 8 ++++++++ changelogs/changelog.yaml | 10 +++++++++- changelogs/fragments/fix_749.yaml | 3 --- galaxy.yml | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) delete mode 100644 changelogs/fragments/fix_749.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3d2c80b79..b92e441a2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,14 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v6.0.2 +====== + +Bugfixes +-------- + +- nxos_interfaces - Correctly enable L3 interfaces on supported N3K platforms (https://github.com/ansible-collections/cisco.nxos/issues/749). + v6.0.1 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 0b1922567..e043cc061 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1041,9 +1041,17 @@ releases: bugfixes: - Prevents module_defaults from were being incorrectly applied to the platform action, instead of the concerned module. - - nxos_file_copy - corectly set file_pull_timeout/persistent_command_timeout + - nxos_file_copy - correctly set file_pull_timeout/persistent_command_timeout value. fragments: - file_copy.yaml - module_defaults.yaml release_date: "2024-01-30" + 6.0.2: + changes: + bugfixes: + - nxos_interfaces - Correctly enable L3 interfaces on supported N3K platforms + (https://github.com/ansible-collections/cisco.nxos/issues/749). + fragments: + - fix_749.yaml + release_date: "2024-02-06" diff --git a/changelogs/fragments/fix_749.yaml b/changelogs/fragments/fix_749.yaml deleted file mode 100644 index d01fd54f7..000000000 --- a/changelogs/fragments/fix_749.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_interfaces - Correctly enable L3 interfaces on supported N3K platforms (https://github.com/ansible-collections/cisco.nxos/issues/749)." diff --git a/galaxy.yml b/galaxy.yml index dd7a20fac..be9792ba9 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 6.0.1 +version: 6.0.2 From 90a5352a8fd70f38dbf46195027123d1016c5875 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Wed, 7 Feb 2024 12:09:53 +0530 Subject: [PATCH 166/166] [GHA] Update reference for GitHub actions (#810) * [GHA] Update reference for GitHub actions * fix lint * revert codecov --- .../workflows/{ack.yml => check_label.yml} | 10 +++---- .github/workflows/codecoverage.yml | 3 ++- .github/workflows/draft_release.yml | 18 +++++++++++++ .github/workflows/lint.yml | 13 --------- .github/workflows/push.yml | 27 ------------------- .github/workflows/release.yml | 4 +-- .github/workflows/tests.yml | 16 ++++++----- tox-ansible.ini | 10 +++++++ 8 files changed, 44 insertions(+), 57 deletions(-) rename .github/workflows/{ack.yml => check_label.yml} (60%) create mode 100644 .github/workflows/draft_release.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/push.yml create mode 100644 tox-ansible.ini diff --git a/.github/workflows/ack.yml b/.github/workflows/check_label.yml similarity index 60% rename from .github/workflows/ack.yml rename to .github/workflows/check_label.yml index fda595dc5..b120bfa32 100644 --- a/.github/workflows/ack.yml +++ b/.github/workflows/check_label.yml @@ -1,15 +1,11 @@ --- -# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml -name: ack - +name: "Check label" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true - on: # yamllint disable-line rule:truthy pull_request_target: types: [opened, labeled, unlabeled, synchronize] - jobs: - ack: - uses: ansible/devtools/.github/workflows/ack.yml@main + check_label: + uses: ansible/ansible-content-actions/.github/workflows/check_label.yaml@main diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml index be2018590..034589bc1 100644 --- a/.github/workflows/codecoverage.yml +++ b/.github/workflows/codecoverage.yml @@ -1,8 +1,9 @@ --- -name: Code Coverage +name: "Code coverage" on: # yamllint disable-line rule:truthy push: + branches: [main] pull_request: branches: [main] diff --git a/.github/workflows/draft_release.yml b/.github/workflows/draft_release.yml new file mode 100644 index 000000000..618f8a379 --- /dev/null +++ b/.github/workflows/draft_release.yml @@ -0,0 +1,18 @@ +--- +name: "Draft release" +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +on: # yamllint disable-line rule:truthy + workflow_dispatch: +env: + NAMESPACE: ${{ github.repository_owner }} + COLLECTION_NAME: nxos + ANSIBLE_COLLECTIONS_PATHS: ./ +jobs: + update_release_draft: + uses: ansible/ansible-content-actions/.github/workflows/draft_release.yaml@main + with: + repo: ${{ github.event.pull_request.head.repo.full_name }} + secrets: + BOT_PAT: ${{ secrets.BOT_PAT }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index fbac38cbf..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: ansible-lint -on: # yamllint disable-line rule:truthy - pull_request: - branches: ["main"] -jobs: - build: - name: Ansible Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run ansible-lint - uses: ansible/ansible-lint@main diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 771dd857a..000000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -# push workflow is shared and expected to perform actions after a merge happens -# on a maintenance branch (default or release). For example updating the -# draft release-notes. -# based on great work from -# https://github.com/T-Systems-MMS/ansible-collection-icinga-director -name: push - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: # yamllint disable-line rule:truthy - workflow_dispatch: - -env: - NAMESPACE: cisco - COLLECTION_NAME: nxos - ANSIBLE_COLLECTIONS_PATHS: ./ - -jobs: - update_release_draft: - uses: ansible/devtools/.github/workflows/push_network.yml@main - with: - repo: ansible-collections/cisco.nxos - secrets: - BOT_PAT: ${{ secrets.BOT_PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb04259d1..6dbb1aa39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,12 @@ --- -name: release +name: "Release collection" on: # yamllint disable-line rule:truthy release: types: [published] jobs: release: - uses: ansible/devtools/.github/workflows/release_collection.yml@main + uses: ansible/ansible-content-actions/.github/workflows/release.yaml@main with: environment: release secrets: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e93330f3a..27291dc81 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,5 @@ --- -name: CI +name: "CI" concurrency: group: ${{ github.head_ref || github.run_id }} @@ -12,15 +12,16 @@ on: # yamllint disable-line rule:truthy schedule: - cron: '0 0 * * *' - jobs: changelog: - uses: ansible-network/github_actions/.github/workflows/changelog.yml@main + uses: ansible/ansible-content-actions/.github/workflows/changelog.yaml@main if: github.event_name == 'pull_request' + ansible-lint: + uses: ansible/ansible-content-actions/.github/workflows/ansible_lint.yaml@main sanity: - uses: ansible-network/github_actions/.github/workflows/sanity.yml@main + uses: ansible/ansible-content-actions/.github/workflows/sanity.yaml@main unit-galaxy: - uses: ansible-network/github_actions/.github/workflows/unit_galaxy.yml@main + uses: ansible/ansible-content-actions/.github/workflows/unit.yaml@main unit-source: uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main with: @@ -33,7 +34,7 @@ jobs: - changelog - sanity - unit-galaxy - - unit-source + - ansible-lint runs-on: ubuntu-latest steps: - run: >- @@ -41,6 +42,7 @@ jobs: set([ '${{ needs.changelog.result }}', '${{ needs.sanity.result }}', - '${{ needs.unit-galaxy.result }}', + '${{ needs.unit-galaxy.result }}' + '${{ needs.ansible-lint.result }}' '${{ needs.unit-source.result }}' ])" diff --git a/tox-ansible.ini b/tox-ansible.ini new file mode 100644 index 000000000..5e1f4b36a --- /dev/null +++ b/tox-ansible.ini @@ -0,0 +1,10 @@ +[ansible] + +skip = + py3.7 + py3.8 + 2.9 + 2.10 + 2.11 + 2.12 + 2.13
ParameterParameter Choices/Defaults Comments
+
group @@ -89,241 +89,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_snmp_user_module.rst b/docs/cisco.nxos.nxos_snmp_user_module.rst index 67139fceb..2d3f6f26c 100644 --- a/docs/cisco.nxos.nxos_snmp_user_module.rst +++ b/docs/cisco.nxos.nxos_snmp_user_module.rst @@ -36,12 +36,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
authentication @@ -60,7 +60,7 @@ Parameters
+
encrypt @@ -79,7 +79,7 @@ Parameters
+
group @@ -94,7 +94,7 @@ Parameters
+
privacy @@ -109,241 +109,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
pwd @@ -358,7 +124,7 @@ Parameters
+
state @@ -377,7 +143,7 @@ Parameters
+
user diff --git a/docs/cisco.nxos.nxos_system_module.rst b/docs/cisco.nxos.nxos_system_module.rst index b114aeed7..4c573f51b 100644 --- a/docs/cisco.nxos.nxos_system_module.rst +++ b/docs/cisco.nxos.nxos_system_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py index 5572b234e..14dfa5b05 100644 --- a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py @@ -323,6 +323,21 @@ class Route_mapsArgs(object): # pylint: disable=R0903 }, }, "extcomm_list": {"type": "str"}, + "extcommunity": { + "type": "dict", + "options": { + "rt": { + "type": "dict", + "options": { + "additive": {"type": "bool"}, + "extcommunity_numbers": { + "type": "list", + "elements": "str", + }, + }, + }, + }, + }, "forwarding_address": {"type": "bool"}, "null_interface": {"type": "str"}, "ip": { diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index 14a9037b6..fa7d57b1b 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -159,6 +159,7 @@ def _compare_entries(self, want, have): begin = len(self.commands) self._compare_lists(wentry, hentry) + self._compare_extcomm(wentry, hentry) self.compare(parsers=self.linear_parsers, want=wentry, have=hentry) if len(self.commands) != begin: @@ -173,6 +174,20 @@ def _compare_entries(self, want, have): for _hk, hentry in iteritems(have): self.commands.append(self._tmplt.render(hentry, "route_map", True)) + def _compare_extcomm(self, want, have): + hentry = get_from_dict(data_dict=have, keypath="set.extcommunity.rt") or {} + wentry = get_from_dict(data_dict=want, keypath="set.extcommunity.rt") or {} + + h_nums = set(hentry.get("extcommunity_numbers", [])) + w_nums = set(wentry.get("extcommunity_numbers", [])) + + if h_nums != w_nums or wentry.get("additive") != hentry.get("additive"): + if self.state not in ["merged", "rendered"]: + # need to explicitly remove existing entry to correctly apply new one + self.commands.append(self._tmplt.render(hentry, "set.extcommunity.rt", negate=True)) + # default CLI behaviour is to 'merge' with existing entry + self.commands.append(self._tmplt.render(wentry, "set.extcommunity.rt", negate=False)) + def _compare_lists(self, want, have): for x in self.complex_parsers: wx = get_from_dict(want, x) or [] diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index cf8f89507..7e876682a 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -22,6 +22,17 @@ ) +def _tmplt_set_extcomm_rt(data): + cmd = "set extcommunity rt" + extcomm_numbers = " ".join(data.get("extcommunity_numbers", [])) + if extcomm_numbers: + cmd += " " + extcomm_numbers + if data.get("additive"): + cmd += " additive" + + return cmd + + def _tmplt_match_ip_multicast(data): cmd = "match ip multicast" multicast = data["match"]["ip"]["multicast"] @@ -1019,6 +1030,34 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "set.extcommunity.rt", + "getval": re.compile( + r""" + \s+set\sextcommunity\srt + (?P(\s\S+:\S+)*)? + (\s(?Padditive))? + \s*$""", re.VERBOSE, + ), + "setval": _tmplt_set_extcomm_rt, + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "extcommunity": { + "rt": { + "additive": "{{ not not additive }}", + "extcommunity_numbers": + "{{ extcommunity_numbers.strip().split(' ') if extcommunity_numbers|d('') else None }}", + }, + }, + }, + }, + }, + }, + }, + }, { "name": "set.forwarding_address", "getval": re.compile( diff --git a/plugins/modules/nxos_route_maps.py b/plugins/modules/nxos_route_maps.py index 123566569..bcf7076f0 100644 --- a/plugins/modules/nxos_route_maps.py +++ b/plugins/modules/nxos_route_maps.py @@ -312,6 +312,23 @@ extcomm_list: description: Set BGP extcommunity list (for deletion). type: str + extcommunity: + description: Set BGP extcommunity attribute. + type: dict + suboptions: + rt: + description: Route-Target. + type: dict + suboptions: + additive: + description: Add to existing rt extcommunity. + type: bool + extcommunity_numbers: + description: + - Extcommunity number. + - "Supported formats are ASN2:NN, ASN4:NN, IPV4:NN." + type: list + elements: str forwarding_address: description: Set the forwarding address. type: bool diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index 53069a1e9..06d76fe38 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -1415,3 +1415,81 @@ def test_nxos_route_maps_next_hop_replaced(self): ] 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)) From 930622605cc064cba1b7cc966383f40cf0b5cda7 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 13 Sep 2023 15:56:16 +0530 Subject: [PATCH 135/166] Remove python dependencies from bindep (#755) * Remove python dependencies from bindep * Add ack back Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- .github/workflows/ack.yml | 15 +++++++++++++++ bindep.txt | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ack.yml diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml new file mode 100644 index 000000000..fda595dc5 --- /dev/null +++ b/.github/workflows/ack.yml @@ -0,0 +1,15 @@ +--- +# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml +name: ack + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + ack: + uses: ansible/devtools/.github/workflows/ack.yml@main diff --git a/bindep.txt b/bindep.txt index ba9c980fb..70fd8dfa5 100644 --- a/bindep.txt +++ b/bindep.txt @@ -2,5 +2,3 @@ # see https://docs.openstack.org/infra/bindep/ for additional information. gcc-c++ [doc test platform:rpm] -python3-devel [test platform:rpm] -python3 [test platform:rpm] From b112477b46d9cadc8003c4dab6028f4a652650d0 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Thu, 14 Sep 2023 12:07:51 +0530 Subject: [PATCH 136/166] [snmp_server] fix user negation when authentication options are present (#657) * fix 439 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update changelogs/fragments/snmp_server_fix.yml * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update changelogs/fragments/snmp_server_fix.yml Co-authored-by: Kate Case --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty Co-authored-by: Kate Case --- changelogs/fragments/snmp_server_fix.yml | 3 +++ .../module_utils/network/nxos/rm_templates/snmp_server.py | 1 + tests/unit/modules/network/nxos/test_nxos_snmp_server.py | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/snmp_server_fix.yml diff --git a/changelogs/fragments/snmp_server_fix.yml b/changelogs/fragments/snmp_server_fix.yml new file mode 100644 index 000000000..ded9a9ca6 --- /dev/null +++ b/changelogs/fragments/snmp_server_fix.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "snmp_server - fix host delete when authentication options are present." diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index be25452df..35451a47b 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -1487,6 +1487,7 @@ def __init__(self, lines=None, module=None): $""", re.VERBOSE, ), "setval": _tmplt_users_auth, + "remval": "snmp-server user {{ user }}", "result": { "users": { "auth": [ diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 1b66d6455..1b7672775 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -793,10 +793,8 @@ def test_nxos_snmp_server_users_replaced(self): 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", ] From adc34162f5644253783db20b8049c16085e2a5d1 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 14 Sep 2023 15:06:06 +0530 Subject: [PATCH 137/166] Prepare for 5.2.0 (#756) * Prepare for 5.2.0 Signed-off-by: NilashishC * Revert pre-commit changes Signed-off-by: NilashishC * Update galaxy.yml Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- .ansible-lint-ignore | 1 + CHANGELOG.rst | 37 +++ changelogs/changelog.yaml | 277 ++++++++---------- .../fragments/_health_check_update_docs.yaml | 9 - changelogs/fragments/bgp_assorted.yaml | 4 - changelogs/fragments/bgp_templates.yaml | 4 - changelogs/fragments/codecov_pr.yml | 3 - changelogs/fragments/fix_713.yaml | 3 - changelogs/fragments/fix_730.yaml | 3 - changelogs/fragments/lag_interfaces.yaml | 3 - changelogs/fragments/nxos.yaml | 3 - changelogs/fragments/nxos_mds_fc.yaml | 3 - changelogs/fragments/route_maps.yaml | 3 - changelogs/fragments/snmp_server_fix.yml | 3 - galaxy.yml | 2 +- 15 files changed, 157 insertions(+), 201 deletions(-) create mode 100644 .ansible-lint-ignore delete mode 100644 changelogs/fragments/_health_check_update_docs.yaml delete mode 100644 changelogs/fragments/bgp_assorted.yaml delete mode 100644 changelogs/fragments/bgp_templates.yaml delete mode 100644 changelogs/fragments/codecov_pr.yml delete mode 100644 changelogs/fragments/fix_713.yaml delete mode 100644 changelogs/fragments/fix_730.yaml delete mode 100644 changelogs/fragments/lag_interfaces.yaml delete mode 100644 changelogs/fragments/nxos.yaml delete mode 100644 changelogs/fragments/nxos_mds_fc.yaml delete mode 100644 changelogs/fragments/route_maps.yaml delete mode 100644 changelogs/fragments/snmp_server_fix.yml diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore new file mode 100644 index 000000000..4a3745083 --- /dev/null +++ b/.ansible-lint-ignore @@ -0,0 +1 @@ +changelogs/changelog.yaml yaml[line-length] diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29a132412..8778fcba8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,43 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v5.2.0 +====== + +Minor Changes +------------- + +- Added new module fc_interfaces +- bgp_global - support remote-as as a route-map (https://github.com/ansible-collections/cisco.nxos/issues/741). +- bgp_neighbor_address_family - support rewrite-rt-asn for ipv4 mvpn (https://github.com/ansible-collections/cisco.nxos/issues/741). +- bgp_templates - Add support for safi evpn (https://github.com/ansible-collections/cisco.nxos/issues/739). +- bgp_templates - Add support for send_community (https://github.com/ansible-collections/cisco.nxos/issues/740). +- route_maps - support extcommunity rt option (https://github.com/ansible-collections/cisco.nxos/issues/743). + +Bugfixes +-------- + +- acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713). +- interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730). +- lag_interfaces - Allow force option to be idempotent (https://github.com/ansible-collections/cisco.nxos/issues/742). +- snmp_server - fix host delete when authentication options are present (https://github.com/ansible-collections/cisco.nxos/issues/439). + +Documentation Changes +--------------------- + +- Update examples for bgp_address_family resource modules using yaml callback plugin. +- Update examples for bgp_global resource modules using yaml callback plugin. +- Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. +- Update examples for bgp_templates resource modules using yaml callback plugin. +- Update examples for ospf_interfaces resource modules using yaml callback plugin. +- Update examples for ospfv2 resource modules using yaml callback plugin. +- Update examples for ospfv3 resource modules using yaml callback plugin. + +New Modules +----------- + +- nxos_fc_interfaces - Fc Interfaces resource module + v5.1.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 404de0b8e..758e60a2c 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1,4 +1,5 @@ -ancestor: null +--- +ancestor: releases: 1.0.0: modules: @@ -8,14 +9,10 @@ releases: - description: Manages AAA server host-specific configuration. name: nxos_aaa_server_host namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages access list entries - for ACLs. + - description: (deprecated, removed after 2022-06-01) Manages access list entries for ACLs. name: nxos_acl namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages applying ACLs to - interfaces. + - description: (deprecated, removed after 2022-06-01) Manages applying ACLs to interfaces. name: nxos_acl_interface namespace: "" - description: ACL interfaces resource module @@ -93,9 +90,7 @@ releases: - description: Set boot options like boot, kickstart image and issu. name: nxos_install_os namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages physical attributes - of interfaces. + - description: (deprecated, removed after 2022-06-01) Manages physical attributes of interfaces. name: nxos_interface namespace: "" - description: Manages configuration of an OSPF interface instance. @@ -104,17 +99,13 @@ releases: - description: Interfaces resource module name: nxos_interfaces namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage Layer-2 interface - on Cisco NXOS devices. + - description: (deprecated, removed after 2022-06-01) Manage Layer-2 interface on Cisco NXOS devices. name: nxos_l2_interface namespace: "" - description: L2 interfaces resource module name: nxos_l2_interfaces namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage L3 interfaces on - Cisco NXOS network devices + - description: (deprecated, removed after 2022-06-01) Manage L3 interfaces on Cisco NXOS network devices name: nxos_l3_interface namespace: "" - description: L3 interfaces resource module @@ -129,14 +120,10 @@ releases: - description: LAG interfaces resource module name: nxos_lag_interfaces namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage link aggregation - groups on Cisco NXOS devices. + - description: (deprecated, removed after 2022-06-01) Manage link aggregation groups on Cisco NXOS devices. name: nxos_linkagg namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage LLDP configuration - on Cisco NXOS network devices. + - description: (deprecated, removed after 2022-06-01) Manage LLDP configuration on Cisco NXOS network devices. name: nxos_lldp namespace: "" - description: LLDP resource module @@ -160,9 +147,7 @@ releases: - description: Manage NXAPI configuration on an NXOS device. name: nxos_nxapi namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages configuration of - an ospf instance. + - description: (deprecated, removed after 2022-06-01) Manages configuration of an ospf instance. name: nxos_ospf namespace: "" - description: Manages a VRF for an OSPF router. @@ -240,9 +225,7 @@ releases: - description: Manage the collection of local users on Nexus devices name: nxos_user namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages VLAN resources and - attributes. + - description: (deprecated, removed after 2022-06-01) Manages VLAN resources and attributes. name: nxos_vlan namespace: "" - description: VLANs resource module @@ -291,23 +274,20 @@ releases: cliconf: - description: Use NX-OS cliconf to run commands on Cisco NX-OS platform name: nxos - namespace: null + namespace: httpapi: - description: Use NX-API to run commands on Cisco NX-OS platform name: nxos - namespace: null + namespace: release_date: "2020-06-23" 1.0.1: changes: bugfixes: - - Element type of `commands` key should be `raw` since it accepts both strings - and dicts (https://github.com/ansible-collections/cisco.nxos/pull/126). + - Element type of `commands` key should be `raw` since it accepts both strings and dicts (https://github.com/ansible-collections/cisco.nxos/pull/126). - Fix nxos_interfaces states replaced and overridden (https://github.com/ansible-collections/cisco.nxos/pull/102). - Fixed force option in lag_interfaces.py (https://github.com/ansible-collections/cisco.nxos/pull/111). - - Make `src`, `backup` and `backup_options` in nxos_config work when module - alias is used (https://github.com/ansible-collections/cisco.nxos/pull/121). - - Makes sure that docstring and argspec are in sync and removes sanity ignores - (https://github.com/ansible-collections/cisco.nxos/pull/112). + - Make `src`, `backup` and `backup_options` in nxos_config work when module alias is used (https://github.com/ansible-collections/cisco.nxos/pull/121). + - Makes sure that docstring and argspec are in sync and removes sanity ignores (https://github.com/ansible-collections/cisco.nxos/pull/112). - Update docs after sanity fixes to modules. - nxos_user - do not fail when a custom role is used (https://github.com/ansible-collections/cisco.nxos/pull/130) minor_changes: @@ -349,13 +329,11 @@ releases: - Preserve whitespaces in banner text (https://github.com/ansible-collections/cisco.nxos/pull/146). deprecated_features: - Deprecated `nxos_smu` in favour of `nxos_rpm` module. - - The `nxos_ospf_vrf` module is deprecated by `nxos_ospfv2` and `nxos_ospfv3` - Resource Modules. + - The `nxos_ospf_vrf` module is deprecated by `nxos_ospfv2` and `nxos_ospfv3` Resource Modules. minor_changes: - Add nxos_ospfv3 module. - - Allow other transfer protocols than scp to pull files from a NXOS device in - nxos_file_copy module. sftp, http, https, tftp and ftp can be choosen as a - transfer protocol, when the file_pull parameter is true.. + - Allow other transfer protocols than scp to pull files from a NXOS device in nxos_file_copy module. sftp, http, https, tftp and ftp can be choosen as a transfer + protocol, when the file_pull parameter is true.. fragments: - 161-transfer_protocol_file_copy.yaml - add_nxos_ospfv3.yaml @@ -378,8 +356,7 @@ releases: - Update regex to accept the platform "N77" as supporting fabricpath. - Vlan config diff was not removing default values deprecated_features: - - Deprecated `nxos_interface_ospf` in favor of `nxos_ospf_interfaces` Resource - Module. + - Deprecated `nxos_interface_ospf` in favor of `nxos_ospf_interfaces` Resource Module. minor_changes: - Add nxos_ospf_interfaces resource module. fragments: @@ -399,8 +376,7 @@ releases: - Add version key to galaxy.yaml to work around ansible-galaxy bug - Allow nxos_user to run with MDS (https://github.com/ansible-collections/cisco.nxos/issues/163). - Fix for nxos_lag_interfaces issue (https://github.com/ansible-collections/cisco.nxos/pull/194). - - Make sure that the OSPF modules work properly when process_id is a string - (https://github.com/ansible-collections/cisco.nxos/issues/198). + - Make sure that the OSPF modules work properly when process_id is a string (https://github.com/ansible-collections/cisco.nxos/issues/198). fragments: - fix_nxos_lag_interfaces_1.yaml - fix_ospf_process_id.yaml @@ -413,24 +389,18 @@ releases: - Add support for interfaces in mode 'fabricpath' to l2_interfaces (https://github.com/ansible-collections/cisco.nxos/issues/220). - Allow enabling `fabric forwarding` feature through nxos_feature (https://github.com/ansible-collections/cisco.nxos/issues/213). - Allow tag updates with state replaced (https://github.com/ansible-collections/cisco.nxos/issues/197). - - Fixes traceback while parsing power supply info in nxos_facts for newer NX-OS - releases (https://github.com/ansible-collections/cisco.nxos/issues/192). + - Fixes traceback while parsing power supply info in nxos_facts for newer NX-OS releases (https://github.com/ansible-collections/cisco.nxos/issues/192). - Handle domain-name properly with vrf contexts (https://github.com/ansible-collections/cisco.nxos/issues/234). - Parse interface contexts properly (https://github.com/ansible-collections/cisco.nxos/issues/195). - Properly handle partial matches in community string (https://github.com/ansible-collections/cisco.nxos/issues/203). - Update argspecs with default value for parameters. - - Update docs to clarify the idemptonecy releated caveat and add it in the output - warnings (https://github.com/ansible-collections/ansible.netcommon/pull/189) - - config replace is actually supported for devices other than N9K and hence - we should not fail, and instead let the device handle it (https://github.com/ansible-collections/cisco.nxos/issues/215). + - Update docs to clarify the idemptonecy releated caveat and add it in the output warnings (https://github.com/ansible-collections/ansible.netcommon/pull/189) + - config replace is actually supported for devices other than N9K and hence we should not fail, and instead let the device handle it (https://github.com/ansible-collections/cisco.nxos/issues/215). deprecated_features: - - Deprecated `nxos_bgp` and `nxos_bgp_neighbor` modules in favor of `nxos_bgp_global` - resource module. + - Deprecated `nxos_bgp` and `nxos_bgp_neighbor` modules in favor of `nxos_bgp_global` resource module. doc_changes: - - Fix error in ``host_reachability`` parameter's example where a default value - is used, which the ``host_reachability`` parameter does not support. Improve - descriptions of some parameters to be more explicit. Correct spelling and - grammar where errors were noticed. + - Fix error in ``host_reachability`` parameter's example where a default value is used, which the ``host_reachability`` parameter does not support. Improve + descriptions of some parameters to be more explicit. Correct spelling and grammar where errors were noticed. minor_changes: - Add `echo_request` option for ICMP. - Add nxos_bgp_global resource module. @@ -460,32 +430,24 @@ releases: 2.0.0: changes: bugfixes: - - Fail gracefully when BGP is already configured with a different ASN when states - merged or replaced is used. - - Fixes to nxos_logging, nxos_igmp_snooping, nxos_l3_interfaces, nxos_ospf_interfaces - and nxos_static_routes to conform with latest CLI behaviour. + - Fail gracefully when BGP is already configured with a different ASN when states merged or replaced is used. + - Fixes to nxos_logging, nxos_igmp_snooping, nxos_l3_interfaces, nxos_ospf_interfaces and nxos_static_routes to conform with latest CLI behaviour. - Properly configure neighbor timers and shutdown state (https://github.com/ansible-collections/cisco.nxos/issues/240). deprecated_features: - Deprecated nxos_bgp_af in favour of nxos_bgp_address_family resource module. - - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family - resource module. + - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family resource module. major_changes: - - "Please refer to - ansible.netcommon - `changelog `_ - for more details." - - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` - and `ansible_network_import_modules`. + - Please refer to ansible.netcommon `changelog `_ + for more details. + - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). - - Add hello_interval_ms option in nxos_pim_interface module to support sub-second - intervals (https://github.com/ansible-collections/cisco.nxos/issues/226). + - Add hello_interval_ms option in nxos_pim_interface module to support sub-second intervals (https://github.com/ansible-collections/cisco.nxos/issues/226). - Add nxos_bgp_address_family Resource Module. - Add nxos_bgp_neighbor_address_family Resource Module. - Add support df_bit and size option for nxos_ping (https://github.com/ansible-collections/cisco.nxos/pull/237). - Adds support for `single_user_mode` command output caching. - - Move nxos_config idempotent warning message with the task response under `warnings` - key if `changed` is `True` + - Move nxos_config idempotent warning message with the task response under `warnings` key if `changed` is `True` fragments: - 237_nxos_ping_df_size.yaml - add_caching_support.yaml @@ -509,8 +471,7 @@ releases: 2.1.0: changes: bugfixes: - - Allow commands to be properly generated with Jinja2 2.10.3 (workaround for - https://github.com/pallets/jinja/issues/710). + - Allow commands to be properly generated with Jinja2 2.10.3 (workaround for https://github.com/pallets/jinja/issues/710). - Allow integer values to be set for dscp key (https://github.com/ansible-collections/cisco.nxos/issues/253). - Do not fail when parsing non rule entries in access-list config (https://github.com/ansible-collections/cisco.nxos/issues/262). minor_changes: @@ -529,8 +490,7 @@ releases: changes: bugfixes: - For versions >=2.1.0, this collection requires ansible.netcommon >=2.0.1. - - Re-releasing this collection with ansible.netcommon dependency requirements - updated. + - Re-releasing this collection with ansible.netcommon dependency requirements updated. fragments: - 275-add_ignore_txt.yml - update_requirement.yaml @@ -539,8 +499,7 @@ releases: changes: minor_changes: - Add nxos_route_maps resource module. - - Add support for ansible_network_resources key allows to fetch the available - resources for a platform (https://github.com/ansible-collections/cisco.nxos/issues/268). + - Add support for ansible_network_resources key allows to fetch the available resources for a platform (https://github.com/ansible-collections/cisco.nxos/issues/268). fragments: - 268_available_network_resources.yaml - add_nxos_route_maps.yaml @@ -553,13 +512,11 @@ releases: 2.3.0: changes: bugfixes: - - Fix how `send_community` attribute is handled in `nxos_bgp_neighbor_address_family` - (https://github.com/ansible-collections/cisco.nxos/issues/281). + - Fix how `send_community` attribute is handled in `nxos_bgp_neighbor_address_family` (https://github.com/ansible-collections/cisco.nxos/issues/281). - Make `passive_interface` work properly when set to False. minor_changes: - Add `default_passive_interface` option in `nxos_ospf_interfaces`. - - Add a netconf subplugin to make netconf_* modules work with older NX-OS versions - (https://github.com/ansible-collections/ansible.netcommon/issues/252). + - Add a netconf subplugin to make netconf_* modules work with older NX-OS versions (https://github.com/ansible-collections/ansible.netcommon/issues/252). fragments: - bgp_nbr_af.yaml - changelog.yaml @@ -571,11 +528,9 @@ releases: - pre_sort.yaml plugins: netconf: - - description: - Use nxos netconf plugin to run netconf commands on Cisco NX-OS - platform. + - description: Use nxos netconf plugin to run netconf commands on Cisco NX-OS platform. name: nxos - namespace: null + namespace: release_date: "2021-05-18" 2.4.0: changes: @@ -598,12 +553,10 @@ releases: changes: bugfixes: - Convert vlan lists to ranges in nxos_l2_interfaces (https://github.com/ansible-collections/cisco.nxos/issues/95). - - Do not expand direction 'both' into 'import' and 'export' for Nexus 9000 platforms - (https://github.com/ansible-collections/cisco.nxos/issues/303). + - Do not expand direction 'both' into 'import' and 'export' for Nexus 9000 platforms (https://github.com/ansible-collections/cisco.nxos/issues/303). - Prevent traceback when parsing unexpected line in nxos_static_routes. deprecated_features: - - The nxos_logging module has been deprecated in favor of the new nxos_logging_global - resource module and will be removed in a release after '2023-08-01'. + - The nxos_logging module has been deprecated in favor of the new nxos_logging_global resource module and will be removed in a release after '2023-08-01'. doc_changes: - Broken link in documentation fixed. minor_changes: @@ -626,8 +579,7 @@ releases: changes: bugfixes: - "`nxos_facts` - Fix gathering CDP neighbor facts from certain N7Ks (https://github.com/ansible-collections/cisco.nxos/issues/329)." - - "`nxos_zone_zoneset` - zone member addition with smart zoning in an already - existing zone should be a no-op (https://github.com/ansible-collections/cisco.nxos/issues/339)." + - "`nxos_zone_zoneset` - zone member addition with smart zoning in an already existing zone should be a no-op (https://github.com/ansible-collections/cisco.nxos/issues/339)." doc_changes: - Added notes in module docs to indicate supportability for Cisco MDS. fragments: @@ -643,8 +595,7 @@ releases: - "`nxos_acls` - Fix traceback with 'port_protocol' range (https://github.com/ansible-collections/cisco.nxos/issues/356)" - "`nxos_facts` - Fix KeyError while gathering CDP neighbor facts (https://github.com/ansible-collections/cisco.nxos/issues/354)." - "`nxos_ospf_interfaces` - Correctly sort interface names before rendering." - - "`nxos_vlans` - switching to `| json-pretty` instead of `| json` as a workaround - for the timeout issue with `libssh` (https://github.com/ansible/pylibssh/issues/208)" + - "`nxos_vlans` - switching to `| json-pretty` instead of `| json` as a workaround for the timeout issue with `libssh` (https://github.com/ansible/pylibssh/issues/208)" deprecated_features: - Deprecated `nxos_ntp`, `nxos_ntp_options`, `nxos_ntp_auth` modules. doc_changes: @@ -672,15 +623,14 @@ releases: minor_changes: - "`nxos_telemetry` - Add support for state gathered" fragments: - - 0-copy_ignore_txt.yml + - "0-copy_ignore_txt.yml" - nxos_telemetry.yaml - readme.yaml release_date: "2021-10-01" 2.7.1: changes: bugfixes: - - "`nxos_acls` - Updating an existing ACE can only be done with states replaced - or overridden. Using state merged will result in a failure." + - "`nxos_acls` - Updating an existing ACE can only be done with states replaced or overridden. Using state merged will result in a failure." - "`nxos_logging_global` - Fix vlan_mgr not being gathered in facts (https://github.com/ansible-collections/cisco.nxos/issues/380)." - "`nxos_vlans` - Fallback to json when json-pretty is not supported (https://github.com/ansible-collections/cisco.nxos/issues/377)." fragments: @@ -710,20 +660,17 @@ releases: 2.8.1: changes: bugfixes: - - nxos_acls - Fix incorrect parsing of remarks if it has 'ip/ipv6 access-list' - in it. + - nxos_acls - Fix incorrect parsing of remarks if it has 'ip/ipv6 access-list' in it. fragments: - nxos_acls.yaml release_date: "2021-12-10" 2.8.2: changes: bugfixes: - - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface - line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." + - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." release_summary: - The v2.8.1 of the cisco.nxos collection is not available on - Ansible Automation Hub. Please download and use v2.8.2 which also contains - an additional bug fix. + The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains an additional + bug fix. fragments: - ignore.yaml - nxos_ntp.yaml @@ -732,8 +679,7 @@ releases: 2.9.0: changes: bugfixes: - - "`nxos_bgp_address_family` - Add hmm as valid option for redistribute protocol - (https://github.com/ansible-collections/cisco.nxos/issues/385)." + - "`nxos_bgp_address_family` - Add hmm as valid option for redistribute protocol (https://github.com/ansible-collections/cisco.nxos/issues/385)." - "`nxos_snmp_server` - Fix rendering context command (https://github.com/ansible-collections/cisco.nxos/issues/406)." minor_changes: - Add nxos_hostname resource module. @@ -752,8 +698,7 @@ releases: bugfixes: - Fix action plugin redirection to make module defaults work properly. - Fix for nxos_vlans issue (https://github.com/ansible-collections/cisco.nxos/issues/425). - - "`nxos_ntp_global` - Aliased `vrf` to `use_vrf` wherever applicable to maintain - consistency with models for other platforms." + - "`nxos_ntp_global` - Aliased `vrf` to `use_vrf` wherever applicable to maintain consistency with models for other platforms." - nxos_snmp_server - Add alias for community (https://github.com/ansible-collections/cisco.nxos/issues/433) doc_changes: - Added notes in module docs to indicate supportability for Cisco MDS. @@ -770,22 +715,17 @@ releases: 3.0.0: changes: bugfixes: - - "`nxos_lag_interfaces` - Fix KeyError with state overridden when port-channel - has no members (https://github.com/ansible-collections/cisco.nxos/issues/452)." - - "`nxos_ntp_global` - correctly propagate CLI failure for non-existent auth - keys (https://github.com/ansible-collections/cisco.nxos/issues/467)." + - "`nxos_lag_interfaces` - Fix KeyError with state overridden when port-channel has no members (https://github.com/ansible-collections/cisco.nxos/issues/452)." + - "`nxos_ntp_global` - correctly propagate CLI failure for non-existent auth keys (https://github.com/ansible-collections/cisco.nxos/issues/467)." - "`nxos_snmp_server` - Properly handle corner cases for snmp-server user (https://github.com/ansible-collections/cisco.nxos/issues/454)." - - "`snmp_server` - Snmp contact/location and location were not gathered if containing - whitespaces." + - "`snmp_server` - Snmp contact/location and location were not gathered if containing whitespaces." major_changes: - The minimum required ansible.netcommon version has been bumped to v2.6.1. - Updated base plugin references to ansible.netcommon. - "`nxos_facts` - change default gather_subset to `min` from `!config` (https://github.com/ansible-collections/cisco.nxos/issues/418)." - - nxos_file_copy has been rewritten as a module. This change also removes the - dependency on pexpect for file_pull operation. Since this now uses AnsibleModule - class for argspec validation, the validation messages will be slighlty different. - Expect changes in the return payload in some cases. All functionality remains - unchanged. + - nxos_file_copy has been rewritten as a module. This change also removes the dependency on pexpect for file_pull operation. Since this now uses AnsibleModule + class for argspec validation, the validation messages will be slighlty different. Expect changes in the return payload in some cases. All functionality + remains unchanged. minor_changes: - "`nxos_snmp_server` - add support for BGP, OSPF and OSPFv3 traps." fragments: @@ -805,13 +745,11 @@ releases: changes: bugfixes: - "`nxos_file_copy` - Skip `vrf` when running against MDS switches (https://github.com/ansible-collections/cisco.nxos/issues/508)." - - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True - (https://github.com/ansible-collections/cisco.nxos/issues/335)." + - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True (https://github.com/ansible-collections/cisco.nxos/issues/335)." - "`nxos_ntp_global` - Ensure idempotence for aliased keys (https://github.com/ansible-collections/cisco.nxos/issues/484)." - "`nxos_snmp_server` - Fix typo for traps link cisco-xcvr-mon-status-chg." doc_changes: - - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global - modules to reflect which options are unsupported on MDS switches. + - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global modules to reflect which options are unsupported on MDS switches. minor_changes: - "`nxos_snmp_server` - Add support for localizedV2key (https://github.com/ansible-collections/cisco.nxos/issues/415)." - "`nxos_snmp_server` - Add support for sha-256 based based user authentication." @@ -852,8 +790,7 @@ releases: 3.1.1: changes: bugfixes: - - Fix issue with modules related to OSPF interfaces failing when the target - NXOS device has subinterfaces. + - Fix issue with modules related to OSPF interfaces failing when the target NXOS device has subinterfaces. fragments: - ospf_subinterface_failure.yaml - paramiko.yaml @@ -862,8 +799,7 @@ releases: 3.1.2: changes: bugfixes: - - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo - entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." + - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." fragments: - nxos_facts.yaml release_date: "2022-09-19" @@ -871,8 +807,7 @@ releases: changes: bugfixes: - "`nxos_telemetry` - Allow destination-group & sensor-group id to be strings." - - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional - properties." + - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional properties." minor_changes: - "`nxos_l3_interfaces` - Add support for toggling ipv6 redirects (https://github.com/ansible-collections/cisco.nxos/issues/569)." fragments: @@ -884,12 +819,10 @@ releases: 4.0.0: changes: major_changes: - - Please use either of the following connection types - network_cli, httpapi - or netconf. + - Please use either of the following connection types - network_cli, httpapi or netconf. - "This release drops support for `connection: local` and provider dictionary." removed_features: - - This release removes the following deprecated plugins that have reached their - end-of-life. + - This release removes the following deprecated plugins that have reached their end-of-life. - nxos_acl - nxos_acl_interface - nxos_interface @@ -912,10 +845,8 @@ releases: changes: bugfixes: - "`nxos_acls` - Parse ICMP echo-reply and echo options correctly (https://github.com/ansible-collections/cisco.nxos/issues/583)." - - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly - (https://github.com/ansible-collections/cisco.nxos/issues/529)." - - "`nxos_acls` - Parse port-protocol options with hypenated names correctly - (https://github.com/ansible-collections/cisco.nxos/issues/557)." + - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly (https://github.com/ansible-collections/cisco.nxos/issues/529)." + - "`nxos_acls` - Parse port-protocol options with hypenated names correctly (https://github.com/ansible-collections/cisco.nxos/issues/557)." fragments: - nxos_acls.yaml - nxos_pim.yaml @@ -926,13 +857,10 @@ releases: - "`nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623)." - "`nxos_file_copy` - stop prepending redundant bootflash: to remote file names" - nxos_acls - Detect duplicate ACE error message from CLI and fail (https://github.com/ansible-collections/cisco.nxos/issues/611). - - nxos_command - Run & evaluate commands at least once even when retries is - set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). + - nxos_command - Run & evaluate commands at least once even when retries is set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). minor_changes: - - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new - options (https://github.com/ansible-collections/cisco.nxos/issues/624)." - - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: - all` does not fail for NX-OS on MDS switches." + - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new options (https://github.com/ansible-collections/cisco.nxos/issues/624)." + - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: all` does not fail for NX-OS on MDS switches." - "`nxos_l2_interfaces` - Add new mode dot1q-tunnel (https://github.com/ansible-collections/cisco.nxos/issues/600)." fragments: - acls.yaml @@ -951,17 +879,14 @@ releases: changes: bugfixes: - "`bgp` - Fix parsing remote-as for Nexus 3K (https://github.com/ansible-collections/cisco.nxos/issues/653)." - - "`facts` - Attempt to execute json output commands with | json-pretty first - and fall back to | json if unsupported. This is a temporary workaround until + - "`facts` - Attempt to execute json output commands with | json-pretty first and fall back to | json if unsupported. This is a temporary workaround until https://github.com/ansible/pylibssh/issues/208 is fixed." - "`interfaces` - Correctly enable/disable VLAN interfaces (https://github.com/ansible-collections/cisco.nxos/issues/539)." - "`route_maps` - resolve route-map description parameter idempotency" - - "`snmp_server` - fix community option to produce proper configuration with - ipv4acl and ipv6acl." + - "`snmp_server` - fix community option to produce proper configuration with ipv4acl and ipv6acl." minor_changes: - "`nxos_route_maps` - add support for 'set ip next-hop <>' command in route-maps" - - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under - nve interface" + - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under nve interface" fragments: - bgp.yaml - bool.yaml @@ -976,9 +901,7 @@ releases: release_date: "2023-04-04" 4.3.0: changes: - release_summary: - Re-releasing v4.2.0 of this collection since the previously - build failed to upload in Automation Hub. + release_summary: Re-releasing v4.2.0 of this collection since the previously build failed to upload in Automation Hub. fragments: - release_430.yaml release_date: "2023-04-05" @@ -989,8 +912,7 @@ releases: - ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670). - nxos_banner - Add support for a custom multiline delimiter - nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440). - - "terminal - attempt privilege escalation only when prompt does not end with - #" + - "terminal - attempt privilege escalation only when prompt does not end with #" doc_changes: - Fix docs of static-routes resource module. - nxos_interfaces - Fixed module documentation and examples. @@ -1014,10 +936,8 @@ releases: 5.0.0: changes: bugfixes: - - nxos_static_routes - Prevent action states to generate terminal configuration - command. - - nxos_static_routes - Update the delete operation of static routes to be similar - to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666) + - nxos_static_routes - Prevent action states to generate terminal configuration command. + - nxos_static_routes - Update the delete operation of static routes to be similar to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666) major_changes: - Refer to **Removed Features** section for details. - This release removes four of the previously deprecated modules from this collection. @@ -1043,3 +963,42 @@ releases: fragments: - cpu_utilization.yml release_date: "2023-07-05" + 5.2.0: + changes: + bugfixes: + - acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713). + - interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730). + - lag_interfaces - Allow force option to be idempotent (https://github.com/ansible-collections/cisco.nxos/issues/742). + - snmp_server - fix host delete when authentication options are present (https://github.com/ansible-collections/cisco.nxos/issues/439). + doc_changes: + - Update examples for bgp_address_family resource modules using yaml callback plugin. + - Update examples for bgp_global resource modules using yaml callback plugin. + - Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. + - Update examples for bgp_templates resource modules using yaml callback plugin. + - Update examples for ospf_interfaces resource modules using yaml callback plugin. + - Update examples for ospfv2 resource modules using yaml callback plugin. + - Update examples for ospfv3 resource modules using yaml callback plugin. + minor_changes: + - Added new module fc_interfaces + - bgp_global - support remote-as as a route-map (https://github.com/ansible-collections/cisco.nxos/issues/741). + - bgp_neighbor_address_family - support rewrite-rt-asn for ipv4 mvpn (https://github.com/ansible-collections/cisco.nxos/issues/741). + - bgp_templates - Add support for safi evpn (https://github.com/ansible-collections/cisco.nxos/issues/739). + - bgp_templates - Add support for send_community (https://github.com/ansible-collections/cisco.nxos/issues/740). + - route_maps - support extcommunity rt option (https://github.com/ansible-collections/cisco.nxos/issues/743). + fragments: + - _health_check_update_docs.yaml + - bgp_assorted.yaml + - bgp_templates.yaml + - codecov_pr.yml + - fix_713.yaml + - fix_730.yaml + - lag_interfaces.yaml + - nxos.yaml + - nxos_mds_fc.yaml + - route_maps.yaml + - snmp_server_fix.yml + modules: + - description: Fc Interfaces resource module + name: nxos_fc_interfaces + namespace: "" + release_date: "2023-09-14" diff --git a/changelogs/fragments/_health_check_update_docs.yaml b/changelogs/fragments/_health_check_update_docs.yaml deleted file mode 100644 index 908e0b5a7..000000000 --- a/changelogs/fragments/_health_check_update_docs.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -doc_changes: - - Update examples for ospfv2 resource modules using yaml callback plugin. - - Update examples for ospfv3 resource modules using yaml callback plugin. - - Update examples for ospf_interfaces resource modules using yaml callback plugin. - - Update examples for bgp_global resource modules using yaml callback plugin. - - Update examples for bgp_address_family resource modules using yaml callback plugin. - - Update examples for bgp_templates resource modules using yaml callback plugin. - - Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. diff --git a/changelogs/fragments/bgp_assorted.yaml b/changelogs/fragments/bgp_assorted.yaml deleted file mode 100644 index 78e47ca1f..000000000 --- a/changelogs/fragments/bgp_assorted.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -minor_changes: - - "bgp_global - support remote-as as a route-map (https://github.com/ansible-collections/cisco.nxos/issues/741)." - - "bgp_neighbor_address_family - support rewrite-rt-asn for ipv4 mvpn (https://github.com/ansible-collections/cisco.nxos/issues/741)." diff --git a/changelogs/fragments/bgp_templates.yaml b/changelogs/fragments/bgp_templates.yaml deleted file mode 100644 index 44ff26ece..000000000 --- a/changelogs/fragments/bgp_templates.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -minor_changes: - - "bgp_templates - Add support for send_community (https://github.com/ansible-collections/cisco.nxos/issues/740)." - - "bgp_templates - Add support for safi evpn (https://github.com/ansible-collections/cisco.nxos/issues/739)." diff --git a/changelogs/fragments/codecov_pr.yml b/changelogs/fragments/codecov_pr.yml deleted file mode 100644 index ad3c08ca7..000000000 --- a/changelogs/fragments/codecov_pr.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - codecov - added a new codecov workflow and changing codecov.yml for added functionality. diff --git a/changelogs/fragments/fix_713.yaml b/changelogs/fragments/fix_713.yaml deleted file mode 100644 index b8bfdebad..000000000 --- a/changelogs/fragments/fix_713.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713)." diff --git a/changelogs/fragments/fix_730.yaml b/changelogs/fragments/fix_730.yaml deleted file mode 100644 index 501ad501f..000000000 --- a/changelogs/fragments/fix_730.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730)." diff --git a/changelogs/fragments/lag_interfaces.yaml b/changelogs/fragments/lag_interfaces.yaml deleted file mode 100644 index b377c1228..000000000 --- a/changelogs/fragments/lag_interfaces.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "lag_interfaces - Allow force option to be idempotent (https://github.com/ansible-collections/cisco.nxos/issues/742)." diff --git a/changelogs/fragments/nxos.yaml b/changelogs/fragments/nxos.yaml deleted file mode 100644 index 53eb6356c..000000000 --- a/changelogs/fragments/nxos.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Drop storage sub-directory and move MDS modules to top-level. diff --git a/changelogs/fragments/nxos_mds_fc.yaml b/changelogs/fragments/nxos_mds_fc.yaml deleted file mode 100644 index 14e9485cc..000000000 --- a/changelogs/fragments/nxos_mds_fc.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - Added new module fc_interfaces diff --git a/changelogs/fragments/route_maps.yaml b/changelogs/fragments/route_maps.yaml deleted file mode 100644 index cbf40bbbd..000000000 --- a/changelogs/fragments/route_maps.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "route_maps - support extcommunity rt option (https://github.com/ansible-collections/cisco.nxos/issues/743)." diff --git a/changelogs/fragments/snmp_server_fix.yml b/changelogs/fragments/snmp_server_fix.yml deleted file mode 100644 index ded9a9ca6..000000000 --- a/changelogs/fragments/snmp_server_fix.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "snmp_server - fix host delete when authentication options are present." diff --git a/galaxy.yml b/galaxy.yml index 9d1c6b596..1813a6727 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 5.1.0 +version: 5.2.0 From 15b1925fccc386231b802f441e4d8e2e87039eca Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Sat, 16 Sep 2023 11:33:16 +0530 Subject: [PATCH 138/166] [vtp_version] allow VTP version 3 (#761) * [vtp_version] allow VTP version 3 Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC * remove top-level auth params from example Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/vtp_version.yaml | 3 +++ docs/cisco.nxos.nxos_vtp_version_module.rst | 4 +--- galaxy.yml | 2 +- plugins/modules/nxos_vtp_version.py | 6 ++---- 4 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/vtp_version.yaml diff --git a/changelogs/fragments/vtp_version.yaml b/changelogs/fragments/vtp_version.yaml new file mode 100644 index 000000000..afe01f592 --- /dev/null +++ b/changelogs/fragments/vtp_version.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "vtp_version - allow VTP version 3 to be configured (https://github.com/ansible-collections/cisco.nxos/issues/704)." diff --git a/docs/cisco.nxos.nxos_vtp_version_module.rst b/docs/cisco.nxos.nxos_vtp_version_module.rst index 9271dbe28..996e950ff 100644 --- a/docs/cisco.nxos.nxos_vtp_version_module.rst +++ b/docs/cisco.nxos.nxos_vtp_version_module.rst @@ -47,6 +47,7 @@ Parameters
    Choices:
  • 1
  • 2
  • +
  • 3
+ + + + + + + + + + + + + + +
ParameterParameter Choices/Defaults Comments
+
domain_lookup @@ -53,7 +53,7 @@ Parameters
+
domain_name @@ -69,7 +69,7 @@ Parameters
+
domain_search @@ -85,7 +85,7 @@ Parameters
+
hostname @@ -100,7 +100,7 @@ Parameters
+
name_servers @@ -116,241 +116,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -369,7 +135,7 @@ Parameters
+
system_mtu diff --git a/docs/cisco.nxos.nxos_udld_interface_module.rst b/docs/cisco.nxos.nxos_udld_interface_module.rst index 67f4c5bed..cba2733c0 100644 --- a/docs/cisco.nxos.nxos_udld_interface_module.rst +++ b/docs/cisco.nxos.nxos_udld_interface_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + diff --git a/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py index b0b122158..22a6666e5 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py @@ -58,7 +58,7 @@ class Bgp_templatesArgs(object): # pylint: disable=R0903 }, "safi": { "type": "str", - "choices": ["unicast", "multicast", "mvpn"], + "choices": ["unicast", "multicast", "mvpn", "evpn"], }, "advertise_map": { "type": "dict", @@ -157,6 +157,10 @@ class Bgp_templatesArgs(object): # pylint: disable=R0903 }, }, "route_reflector_client": {"type": "bool"}, + "send_community": { + "type": "str", + "choices": ["standard", "extended", "both"], + }, "soft_reconfiguration_inbound": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py index dc2f98d53..648db72e6 100644 --- a/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py @@ -17,7 +17,6 @@ necessary to bring the current configuration to its desired end-state is created. """ - from copy import deepcopy from ansible.module_utils.six import iteritems @@ -92,6 +91,8 @@ def __init__(self, module): "prefix_list.outbound", "route_map.inbound", "route_map.outbound", + "send_community_standard", + "send_community_extended", "route_reflector_client", "soft_reconfiguration_inbound", "soo", @@ -190,6 +191,16 @@ def _afs_compare(self, want, have): self.commands.append(self._tmplt.render(hentry, "address_family", True)) def _af_compare(self, want, have): + # "unpack" send_community + for item in [want, have]: + send_comm_val = item.get("send_community", "") + if send_comm_val: + if send_comm_val == "both": + item["send_community_extended"] = True + item["send_community_standard"] = True + else: + key = "send_community_%s" % send_comm_val + item[key] = True self.compare(parsers=self.af_parsers, want=want, have=have) def _list_to_dict(self, data): diff --git a/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py index 7cdb3018e..021e518a7 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py @@ -74,6 +74,17 @@ def populate_facts(self, connection, ansible_facts, data=None): if "address_family" in x: x["address_family"] = list(x["address_family"].values()) + for nbr in objs.get("neighbor", []): + for af in nbr.get("address_family", []): + std = af.pop("send_community_std", False) + ext = af.pop("send_community_ext", False) + if std and ext: + af["send_community"] = "both" + elif std: + af["send_community"] = "standard" + elif ext: + af["send_community"] = "extended" + ansible_facts["ansible_network_resources"].pop("bgp_templates", None) params = utils.remove_empties( diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py b/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py index 9628fdeca..7e7bb5828 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py @@ -1053,6 +1053,48 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "send_community_standard", + "getval": re.compile( + r""" + (?Psend-community) + $""", + re.VERBOSE, + ), + "setval": "send-community", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "send_community_std": "{{ not not send_community_std }}", + }, + }, + }, + }, + }, + }, + { + "name": "send_community_extended", + "getval": re.compile( + r""" + (?Psend-community\sextended) + $""", + re.VERBOSE, + ), + "setval": "send-community extended", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "send_community_ext": "{{ not not send_community_ext }}", + }, + }, + }, + }, + }, + }, { "name": "soft_reconfiguration_inbound", "getval": re.compile( diff --git a/plugins/modules/nxos_bgp_templates.py b/plugins/modules/nxos_bgp_templates.py index 669c833c5..9ad53e348 100644 --- a/plugins/modules/nxos_bgp_templates.py +++ b/plugins/modules/nxos_bgp_templates.py @@ -62,7 +62,7 @@ safi: description: Sub Address Family indicator. type: str - choices: ["unicast", "multicast", "mvpn"] + choices: ["unicast", "multicast", "mvpn", "evpn"] advertise_map: description: Specify route-map for conditional advertisement. type: dict @@ -191,6 +191,10 @@ route_reflector_client: description: Configure a neighbor as Route reflector client. type: bool + send_community: + description: Send Community attribute to this neighbor. + type: str + choices: ["standard", "extended", "both"] soft_reconfiguration_inbound: description: Soft reconfiguration. type: dict diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py b/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py index 1378c4411..8d2fd74b5 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py @@ -140,6 +140,13 @@ def test_nxos_bgp_templates_merged(self): set=True, ), ), + address_family=[ + dict( + afi="l2vpn", + safi="evpn", + send_community="both", + ), + ], ), ], ), @@ -179,6 +186,9 @@ def test_nxos_bgp_templates_merged(self): "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)) @@ -799,3 +809,57 @@ def test_nxos_bgp_templates_af_idempotent(self): 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)) From 88451950723554c0f712773618e1a0736f2e24ce Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 7 Sep 2023 19:35:50 +0530 Subject: [PATCH 129/166] [lag_interfaces] make 'force' option idempotent (#748) * [lag_interfaces] make 'force' option idempotent Signed-off-by: NilashishC * lint fix Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/lag_interfaces.yaml | 3 ++ .../config/lag_interfaces/lag_interfaces.py | 31 ++++++++++++------- .../tests/common/merged.yaml | 4 +-- .../tests/common/overridden.yaml | 2 +- 4 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/lag_interfaces.yaml diff --git a/changelogs/fragments/lag_interfaces.yaml b/changelogs/fragments/lag_interfaces.yaml new file mode 100644 index 000000000..b377c1228 --- /dev/null +++ b/changelogs/fragments/lag_interfaces.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "lag_interfaces - Allow force option to be idempotent (https://github.com/ansible-collections/cisco.nxos/issues/742)." diff --git a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py index 495244b41..fc3202a7f 100644 --- a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py @@ -238,6 +238,7 @@ def diff_list_of_dicts(self, want, have): delta = dict_diff(h_item, w_item) if delta: if h_item: + delta["exists"] = True if ( "mode" in delta.keys() and delta["mode"] == "on" @@ -270,19 +271,27 @@ def add_commands(self, diff, name): commands = [] name = name.strip("port-channel") for d in diff: - commands.append("interface" + " " + d["member"]) - cmd = "" + sub_cmd = "" + final_cmd = "" + member_exists = d.get("exists", False) group_cmd = "channel-group {0}".format(name) - if d.get("force"): - cmd = group_cmd + " force " + + # force does not appear in config + # will only be applied for a net new member + if d.get("force") and not member_exists: + sub_cmd += " force" if "mode" in d: - if cmd: - cmd = cmd + " mode " + d["mode"] - else: - cmd = group_cmd + " mode " + d["mode"] - if not cmd: - cmd = group_cmd - commands.append(cmd) + sub_cmd += " mode %s" % d["mode"] + + if sub_cmd: + final_cmd = group_cmd + sub_cmd + elif not member_exists: + final_cmd = group_cmd + + if final_cmd: + commands.append("interface" + " " + d["member"]) + commands.append(final_cmd) + return commands def set_commands(self, w, have): diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml index 96b74273d..3a8e78976 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml +++ b/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/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml index f2bafafb2..92c357f1d 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml +++ b/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 From 3593fc2b20e223db2947be0c5e66b77f84a7738c Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 8 Sep 2023 11:22:17 +0530 Subject: [PATCH 130/166] [bgp] add support for lesser used options (#746) * [bgp] add support for lesser used options Signed-off-by: NilashishC * Add tests Signed-off-by: NilashishC * Fix sanity issue Signed-off-by: NilashishC * Include pre-commit generated missing docs Signed-off-by: NilashishC * Fix version Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/bgp_assorted.yaml | 4 + docs/cisco.nxos.nxos_bgp_global_module.rst | 35 + ...xos_bgp_neighbor_address_family_module.rst | 45 + docs/cisco.nxos.nxos_fc_interfaces_module.rst | 777 ++++++++++++++++++ .../nxos/argspec/bgp_global/bgp_global.py | 2 + .../bgp_neighbor_address_family.py | 2 + .../nxos/config/bgp_global/bgp_global.py | 2 +- .../bgp_neighbor_address_family.py | 1 + .../nxos/facts/bgp_global/bgp_global.py | 2 +- .../bgp_neighbor_address_family.py | 2 +- .../network/nxos/rm_templates/bgp_global.py | 6 +- .../bgp_neighbor_address_family.py | 26 + plugins/modules/nxos_bgp_global.py | 3 + .../nxos_bgp_neighbor_address_family.py | 3 + plugins/modules/nxos_fc_interfaces.py | 2 +- .../network/nxos/test_nxos_bgp_global.py | 21 + .../test_nxos_bgp_neighbor_address_family.py | 61 ++ 17 files changed, 989 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/bgp_assorted.yaml create mode 100644 docs/cisco.nxos.nxos_fc_interfaces_module.rst diff --git a/changelogs/fragments/bgp_assorted.yaml b/changelogs/fragments/bgp_assorted.yaml new file mode 100644 index 000000000..78e47ca1f --- /dev/null +++ b/changelogs/fragments/bgp_assorted.yaml @@ -0,0 +1,4 @@ +--- +minor_changes: + - "bgp_global - support remote-as as a route-map (https://github.com/ansible-collections/cisco.nxos/issues/741)." + - "bgp_neighbor_address_family - support rewrite-rt-asn for ipv4 mvpn (https://github.com/ansible-collections/cisco.nxos/issues/741)." diff --git a/docs/cisco.nxos.nxos_bgp_global_module.rst b/docs/cisco.nxos.nxos_bgp_global_module.rst index c75def25f..1ef0c27b4 100644 --- a/docs/cisco.nxos.nxos_bgp_global_module.rst +++ b/docs/cisco.nxos.nxos_bgp_global_module.rst @@ -1887,6 +1887,23 @@ Parameters
Specify Autonomous System Number of the neighbor.
+ + + + + + + @@ -4002,6 +4019,24 @@ Parameters
Specify Autonomous System Number of the neighbor.
+ + + + + + + + diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst index 5148c878c..96e3c5e53 100644 --- a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst +++ b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst @@ -853,6 +853,28 @@ Parameters
Auto generate RTs for EBGP neighbor.
+ + + + + + + + @@ -2073,6 +2095,29 @@ Parameters
Auto generate RTs for EBGP neighbor.
+ + + + + + + + + diff --git a/docs/cisco.nxos.nxos_fc_interfaces_module.rst b/docs/cisco.nxos.nxos_fc_interfaces_module.rst new file mode 100644 index 000000000..eaad900f2 --- /dev/null +++ b/docs/cisco.nxos.nxos_fc_interfaces_module.rst @@ -0,0 +1,777 @@ +.. _cisco.nxos.nxos_fc_interfaces_module: + + +***************************** +cisco.nxos.nxos_fc_interfaces +***************************** + +**Fc Interfaces resource module** + + +Version added: 5.2.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages the interface attributes of NX-OS fc interfaces. + + + + +Parameters +---------- + +.. raw:: html + +
ParameterParameter Choices/Defaults Comments
+
interface @@ -50,7 +50,7 @@ Parameters
+
mode @@ -71,241 +71,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state diff --git a/docs/cisco.nxos.nxos_udld_module.rst b/docs/cisco.nxos.nxos_udld_module.rst index 6a271c05e..dc461bc89 100644 --- a/docs/cisco.nxos.nxos_udld_module.rst +++ b/docs/cisco.nxos.nxos_udld_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -169,7 +169,7 @@ Parameters @@ -187,240 +187,6 @@ Parameters
The username to be configured on the remote Cisco Nexus device. This argument accepts a string value and is mutually exclusive with the aggregate argument.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
ParameterParameter Choices/Defaults Comments
+
aggressive @@ -53,7 +53,7 @@ Parameters
+
msg_time @@ -68,241 +68,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
reset @@ -321,7 +87,7 @@ Parameters
+
state diff --git a/docs/cisco.nxos.nxos_user_module.rst b/docs/cisco.nxos.nxos_user_module.rst index bf2dce378..00cfafecc 100644 --- a/docs/cisco.nxos.nxos_user_module.rst +++ b/docs/cisco.nxos.nxos_user_module.rst @@ -63,7 +63,7 @@ Parameters
-
The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device. Please note that this option is not same as provider password.
+
The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device.
-
The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device. Please note that this option is not same as provider password.
+
The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
diff --git a/docs/cisco.nxos.nxos_vpc_interface_module.rst b/docs/cisco.nxos.nxos_vpc_interface_module.rst index 0f874ff88..01138d606 100644 --- a/docs/cisco.nxos.nxos_vpc_interface_module.rst +++ b/docs/cisco.nxos.nxos_vpc_interface_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
ParameterParameter Choices/Defaults Comments
+
peer_link @@ -53,7 +53,7 @@ Parameters
+
portchannel @@ -69,241 +69,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -322,7 +88,7 @@ Parameters
+
vpc diff --git a/docs/cisco.nxos.nxos_vpc_module.rst b/docs/cisco.nxos.nxos_vpc_module.rst index 904a59300..9e0ca3c29 100644 --- a/docs/cisco.nxos.nxos_vpc_module.rst +++ b/docs/cisco.nxos.nxos_vpc_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2775,7 +2775,7 @@ Common return values are documented `here parsed
- list + dictionary
diff --git a/docs/cisco.nxos.nxos_ospf_interfaces_module.rst b/docs/cisco.nxos.nxos_ospf_interfaces_module.rst index 19ba44ab1..6dbfbd5f5 100644 --- a/docs/cisco.nxos.nxos_ospf_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_ospf_interfaces_module.rst @@ -826,122 +826,77 @@ Examples key: 12090404011C03162E state: merged - # Task output - # ------------- - # "before": [ - # { - # "name": "Ethernet1/1" - # }, - # { - # "name": "Ethernet1/2" - # }, - # { - # "name": "Ethernet1/3" - # }, - # ] + # Task output: + # ------------ + # before: + # - name: Ethernet1/1 + # - name: Ethernet1/2 + # - name: Ethernet1/3 # - # "commands": [ - # "interface Ethernet1/1", - # "ip router ospf multi-area 11.11.11.11", - # "ip router ospf 100 area 1.1.1.1 secondaries none", - # "ipv6 router ospfv3 multi-area 16.10.10.10", - # "ipv6 router ospfv3 200 area 2.2.2.2", - # "ipv6 router ospfv3 200 multi-area 21.0.0.0", - # "ipv6 router ospfv3 300 multi-area 50.50.50.50", - # "interface Ethernet1/2", - # "ip ospf authentication key-chain test-1", - # "ip ospf authentication", - # "ip ospf message-digest-key 10 md5 3 abc01d272be25d29", - # "ip ospf cost 100", - # "ospfv3 network broadcast", - # "ospfv3 shutdown", - # "interface Ethernet1/3", - # "ip ospf authentication-key 7 12090404011C03162E" - # ] + # commands: + # - interface Ethernet1/1 + # - ip router ospf multi-area 11.11.11.11 + # - ip router ospf 100 area 1.1.1.1 secondaries none + # - ipv6 router ospfv3 multi-area 16.10.10.10 + # - ipv6 router ospfv3 200 area 2.2.2.2 + # - ipv6 router ospfv3 200 multi-area 21.0.0.0 + # - ipv6 router ospfv3 300 multi-area 50.50.50.50 + # - interface Ethernet1/2 + # - ip ospf authentication key-chain test-1 + # - ip ospf authentication + # - ip ospf message-digest-key 10 md5 3 abc01d272be25d29 + # - ip ospf cost 100 + # - ospfv3 network broadcast + # - ospfv3 shutdown + # - interface Ethernet1/3 + # - ip ospf authentication-key 7 12090404011C03162E # - # "after": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.11" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # }, - # { - # "afi": "ipv6", - # "multi_areas": [ - # "16.10.10.10" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "2.2.2.2" - # }, - # "multi_areas": [ - # "21.0.0.0" - # ], - # "process_id": "200" - # }, - # { - # "multi_areas": [ - # "50.50.50.50" - # ], - # "process_id": "300" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # after: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.11 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # - afi: ipv6 + # multi_areas: + # - 16.10.10.10 + # processes: + # - area: + # area_id: 2.2.2.2 + # multi_areas: + # - 21.0.0.0 + # process_id: '200' + # - multi_areas: + # - 50.50.50.50 + # process_id: '300' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 # After state: - # ------------- + # ------------ # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -967,7 +922,7 @@ Examples # Using replaced # Before state: - # ------------ + # ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -1005,151 +960,92 @@ Examples - name: Ethernet1/3 state: replaced - # Task output - # ------------- - # "before": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.11" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # }, - # { - # "afi": "ipv6", - # "multi_areas": [ - # "16.10.10.10" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "2.2.2.2" - # }, - # "multi_areas": [ - # "21.0.0.0" - # ], - # "process_id": "200" - # }, - # { - # "multi_areas": [ - # "50.50.50.50" - # ], - # "process_id": "300" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # Task output: + # ------------ + # before: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.11 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # - afi: ipv6 + # multi_areas: + # - 16.10.10.10 + # processes: + # - area: + # area_id: 2.2.2.2 + # multi_areas: + # - 21.0.0.0 + # process_id: '200' + # - multi_areas: + # - 50.50.50.50 + # process_id: '300' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 # - # "commands": [ - # "interface Ethernet1/1", - # "ip router ospf multi-area 11.11.11.12", - # "no ip router ospf multi-area 11.11.11.11", - # "no ipv6 router ospfv3 multi-area 16.10.10.10", - # "no ipv6 router ospfv3 200 area 2.2.2.2", - # "no ipv6 router ospfv3 200 multi-area 21.0.0.0", - # "no ipv6 router ospfv3 300 multi-area 50.50.50.50", - # "interface Ethernet1/3", - # "no ip ospf authentication-key 7 12090404011C03162E" - # ] + # commands: + # - interface Ethernet1/1 + # - ip router ospf multi-area 11.11.11.12 + # - no ip router ospf multi-area 11.11.11.11 + # - no ipv6 router ospfv3 multi-area 16.10.10.10 + # - no ipv6 router ospfv3 200 area 2.2.2.2 + # - no ipv6 router ospfv3 200 multi-area 21.0.0.0 + # - no ipv6 router ospfv3 300 multi-area 50.50.50.50 + # - interface Ethernet1/3 + # - no ip ospf authentication-key 7 12090404011C03162E # - # "after": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.12" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "name": "Ethernet1/3" - # }, + # after: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.12 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - name: Ethernet1/3 # # After state: - # ------------- + # ------------ # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -1170,7 +1066,7 @@ Examples # Using overridden # Before state: - # ------------ + # ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -1207,136 +1103,83 @@ Examples - 11.11.11.12 state: overridden - # Task output - # ------------- - # "before": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.11" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # }, - # { - # "afi": "ipv6", - # "multi_areas": [ - # "16.10.10.10" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "2.2.2.2" - # }, - # "multi_areas": [ - # "21.0.0.0" - # ], - # "process_id": "200" - # }, - # { - # "multi_areas": [ - # "50.50.50.50" - # ], - # "process_id": "300" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # Task output: + # ------------ + # before: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.11 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # - afi: ipv6 + # multi_areas: + # - 16.10.10.10 + # processes: + # - area: + # area_id: 2.2.2.2 + # multi_areas: + # - 21.0.0.0 + # process_id: '200' + # - multi_areas: + # - 50.50.50.50 + # process_id: '300' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 # - # "commands": [ - # "interface Ethernet1/2", - # "no ip ospf authentication key-chain test-1", - # "no ip ospf authentication", - # "no ip ospf message-digest-key 10 md5 3 abc01d272be25d29", - # "no ip ospf cost 100", - # "no ospfv3 network broadcast", - # "no ospfv3 shutdown", - # "interface Ethernet1/3", - # "no ip ospf authentication-key 7 12090404011C03162E", - # "interface Ethernet1/1", - # "ip router ospf multi-area 11.11.11.12", - # "no ip router ospf multi-area 11.11.11.11", - # "no ipv6 router ospfv3 multi-area 16.10.10.10", - # "no ipv6 router ospfv3 200 area 2.2.2.2", - # "no ipv6 router ospfv3 200 multi-area 21.0.0.0", - # "no ipv6 router ospfv3 300 multi-area 50.50.50.50" - # ] + # commands: + # - interface Ethernet1/2 + # - no ip ospf authentication key-chain test-1 + # - no ip ospf authentication + # - no ip ospf message-digest-key 10 md5 3 abc01d272be25d29 + # - no ip ospf cost 100 + # - no ospfv3 network broadcast + # - no ospfv3 shutdown + # - interface Ethernet1/3 + # - no ip ospf authentication-key 7 12090404011C03162E + # - interface Ethernet1/1 + # - ip router ospf multi-area 11.11.11.12 + # - no ip router ospf multi-area 11.11.11.11 + # - no ipv6 router ospfv3 multi-area 16.10.10.10 + # - no ipv6 router ospfv3 200 area 2.2.2.2 + # - no ipv6 router ospfv3 200 multi-area 21.0.0.0 + # - no ipv6 router ospfv3 300 multi-area 50.50.50.50 # - # "after": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.12" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "name": "Ethernet1/2" - # }, - # { - # "name": "Ethernet1/3" - # }, - # ] + # after: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.12 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # name: Ethernet1/1 + # - name: Ethernet1/2 + # - name: Ethernet1/3 # After state: # ------------- @@ -1353,7 +1196,7 @@ Examples # Using deleted to delete OSPF config of a single interface # Before state: - # ------------ + # ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -1381,139 +1224,84 @@ Examples - name: Ethernet1/1 state: deleted - # Task output - # ------------- - # "before": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.11" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # }, - # { - # "afi": "ipv6", - # "multi_areas": [ - # "16.10.10.10" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "2.2.2.2" - # }, - # "multi_areas": [ - # "21.0.0.0" - # ], - # "process_id": "200" - # }, - # { - # "multi_areas": [ - # "50.50.50.50" - # ], - # "process_id": "300" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # Task output: + # ------------ + # before: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.11 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # - afi: ipv6 + # multi_areas: + # - 16.10.10.10 + # processes: + # - area: + # area_id: 2.2.2.2 + # multi_areas: + # - 21.0.0.0 + # process_id: '200' + # - multi_areas: + # - 50.50.50.50 + # process_id: '300' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 # - # "commands": [ - # "interface Ethernet1/1", - # "no ip router ospf multi-area 11.11.11.11", - # "no ip router ospf 100 area 1.1.1.1 secondaries none", - # "no ipv6 router ospfv3 multi-area 16.10.10.10", - # "no ipv6 router ospfv3 200 area 2.2.2.2", - # "no ipv6 router ospfv3 200 multi-area 21.0.0.0", - # "no ipv6 router ospfv3 300 multi-area 50.50.50.50" - # ] + # commands: + # - interface Ethernet1/1 + # - no ip router ospf multi-area 11.11.11.11 + # - no ip router ospf 100 area 1.1.1.1 secondaries none + # - no ipv6 router ospfv3 multi-area 16.10.10.10 + # - no ipv6 router ospfv3 200 area 2.2.2.2 + # - no ipv6 router ospfv3 200 multi-area 21.0.0.0 + # - no ipv6 router ospfv3 300 multi-area 50.50.50.50 # - # "before": [ - # { - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # after: + # - name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 + # After state: # ------------ @@ -1535,7 +1323,7 @@ Examples # Using deleted to delete OSPF config from all interfaces # Before state: - # ------------ + # ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -1561,119 +1349,53 @@ Examples cisco.nxos.nxos_ospf_interfaces: state: deleted - # Task output - # ------------- - # "before": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.11" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # }, - # { - # "afi": "ipv6", - # "multi_areas": [ - # "16.10.10.10" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "2.2.2.2" - # }, - # "multi_areas": [ - # "21.0.0.0" - # ], - # "process_id": "200" - # }, - # { - # "multi_areas": [ - # "50.50.50.50" - # ], - # "process_id": "300" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # Task output: + # ------------ + # before: + # - name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 # - # "commands": [ - # "interface Ethernet1/1", - # "no ip router ospf multi-area 11.11.11.11", - # "no ip router ospf 100 area 1.1.1.1 secondaries none", - # "no ipv6 router ospfv3 multi-area 16.10.10.10", - # "no ipv6 router ospfv3 200 area 2.2.2.2", - # "no ipv6 router ospfv3 200 multi-area 21.0.0.0", - # "no ipv6 router ospfv3 300 multi-area 50.50.50.50", - # "interface Ethernet1/2", - # "no ip ospf authentication key-chain test-1", - # "no ip ospf authentication", - # "no ip ospf message-digest-key 10 md5 3 abc01d272be25d29", - # "no ip ospf cost 100", - # "no ospfv3 network broadcast", - # "no ospfv3 shutdown", - # "interface Ethernet1/3", - # "no ip ospf authentication-key 7 12090404011C03162E" - # ] + # commands: + # - interface Ethernet1/1 + # - no ip router ospf multi-area 11.11.11.11 + # - no ip router ospf 100 area 1.1.1.1 secondaries none + # - no ipv6 router ospfv3 multi-area 16.10.10.10 + # - no ipv6 router ospfv3 200 area 2.2.2.2 + # - no ipv6 router ospfv3 200 multi-area 21.0.0.0 + # - no ipv6 router ospfv3 300 multi-area 50.50.50.50 + # - interface Ethernet1/2 + # - no ip ospf authentication key-chain test-1 + # - no ip ospf authentication + # - no ip ospf message-digest-key 10 md5 3 abc01d272be25d29 + # - no ip ospf cost 100 + # - no ospfv3 network broadcast + # - no ospfv3 shutdown + # - interface Ethernet1/3 + # - no ip ospf authentication-key 7 12090404011C03162E # - # "after": [ - # { - # "name": "Ethernet1/1" - # }, - # { - # "name": "Ethernet1/2" - # }, - # { - # "name": "Ethernet1/3" - # }, - # ] + # after: + # - name: Ethernet1/1 + # - name: Ethernet1/2 + # - name: Ethernet1/3 # After state: # ------------ @@ -1734,26 +1456,25 @@ Examples key: 12090404011C03162E state: rendered - # Task Output (redacted) - # ----------------------- - # "rendered": [ - # "interface Ethernet1/1", - # "ip router ospf multi-area 11.11.11.11", - # "ip router ospf 100 area 1.1.1.1 secondaries none", - # "ipv6 router ospfv3 multi-area 16.10.10.10", - # "ipv6 router ospfv3 200 area 2.2.2.2", - # "ipv6 router ospfv3 200 multi-area 21.0.0.0", - # "ipv6 router ospfv3 300 multi-area 50.50.50.50", - # "interface Ethernet1/2", - # "ip ospf authentication key-chain test-1", - # "ip ospf authentication", - # "ip ospf message-digest-key 10 md5 3 abc01d272be25d29", - # "ip ospf cost 100", - # "ospfv3 network broadcast", - # "ospfv3 shutdown", - # "interface Ethernet1/3", - # "ip ospf authentication-key 7 12090404011C03162E" - # ] + # Task Output: + # ------------ + # rendered: + # - interface Ethernet1/1 + # - ip router ospf multi-area 11.11.11.11 + # - ip router ospf 100 area 1.1.1.1 secondaries none + # - ipv6 router ospfv3 multi-area 16.10.10.10 + # - ipv6 router ospfv3 200 area 2.2.2.2 + # - ipv6 router ospfv3 200 multi-area 21.0.0.0 + # - ipv6 router ospfv3 300 multi-area 50.50.50.50 + # - interface Ethernet1/2 + # - ip ospf authentication key-chain test-1 + # - ip ospf authentication + # - ip ospf message-digest-key 10 md5 3 abc01d272be25d29 + # - ip ospf cost 100 + # - ospfv3 network broadcast + # - ospfv3 shutdown + # - interface Ethernet1/3 + # - ip ospf authentication-key 7 12090404011C03162E # Using parsed @@ -1781,88 +1502,51 @@ Examples running_config: "{{ lookup('file', 'ospf_interfaces.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- - # "parsed": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.11" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # }, - # { - # "afi": "ipv6", - # "multi_areas": [ - # "16.10.10.10" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "2.2.2.2" - # }, - # "multi_areas": [ - # "21.0.0.0" - # ], - # "process_id": "200" - # }, - # { - # "multi_areas": [ - # "50.50.50.50" - # ], - # "process_id": "300" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication_key": { - # "encryption": 7, - # "key": "12090404011C03162E" - # } - # } - # ], - # "name": "Ethernet1/3" - # }, - # ] + # Task output: + # ------------ + # parsed: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.11 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # - afi: ipv6 + # multi_areas: + # - 16.10.10.10 + # processes: + # - area: + # area_id: 2.2.2.2 + # multi_areas: + # - 21.0.0.0 + # process_id: '200' + # - multi_areas: + # - 50.50.50.50 + # process_id: '300' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - address_family: + # - afi: ipv4 + # authentication_key: + # encryption: 7 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # name: Ethernet1/3 # Using gathered @@ -1884,55 +1568,34 @@ Examples # interface Ethernet1/3 # no switchport - # Task output (redacted) - # ----------------------- - # "gathered": [ - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "multi_areas": [ - # "11.11.11.12" - # ], - # "processes": [ - # { - # "area": { - # "area_id": "1.1.1.1", - # "secondaries": false - # }, - # "process_id": "100" - # } - # ] - # } - # ], - # "name": "Ethernet1/1" - # }, - # { - # "address_family": [ - # { - # "afi": "ipv4", - # "authentication": { - # "enable": true, - # "key_chain": "test-1" - # }, - # "cost": 100, - # "message_digest_key": { - # "encryption": 3, - # "key": "abc01d272be25d29", - # "key_id": 10 - # } - # }, - # { - # "afi": "ipv6", - # "network": "broadcast", - # "shutdown": true - # } - # ], - # "name": "Ethernet1/2" - # }, - # { - # "name": "Ethernet1/3" - # }, + # Task output: + # ------------ + # gathered: + # - address_family: + # - afi: ipv4 + # multi_areas: + # - 11.11.11.12 + # processes: + # - area: + # area_id: 1.1.1.1 + # secondaries: false + # process_id: '100' + # name: Ethernet1/1 + # - address_family: + # - afi: ipv4 + # authentication: + # enable: true + # key_chain: test-1 + # cost: 100 + # message_digest_key: + # encryption: 3 + # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + # key_id: 10 + # - afi: ipv6 + # network: broadcast + # shutdown: true + # name: Ethernet1/2 + # - name: Ethernet1/3 @@ -2001,6 +1664,57 @@ Common return values are documented `here ['interface Ethernet1/1', 'ip router ospf multi-area 11.11.11.11', 'ip router ospf 100 area 1.1.1.1 secondaries none', 'no ipv6 router ospfv3 multi-area 16.10.10.10', 'ipv6 router ospfv3 200 area 2.2.2.2', 'ipv6 router ospfv3 200 multi-area 21.0.0.0', 'ipv6 router ospfv3 300 multi-area 50.50.50.50', 'interface Ethernet1/2', 'no ip ospf authentication key-chain test-1', 'ip ospf authentication'] + + + + + + + + + + + + + + +
ParameterParameter Choices/Defaults Comments
+
auto_recovery @@ -55,7 +55,7 @@ Parameters
+
auto_recovery_reload_delay @@ -71,7 +71,7 @@ Parameters
+
delay_restore @@ -86,7 +86,7 @@ Parameters
+
delay_restore_interface_vlan @@ -102,7 +102,7 @@ Parameters
+
delay_restore_orphan_port @@ -118,7 +118,7 @@ Parameters
+
domain @@ -134,7 +134,7 @@ Parameters
+
peer_gw @@ -153,7 +153,7 @@ Parameters
+
pkl_dest @@ -169,7 +169,7 @@ Parameters
+
pkl_src @@ -184,7 +184,7 @@ Parameters
+
pkl_vrf @@ -201,241 +201,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
role_priority @@ -450,7 +216,7 @@ Parameters
+
state @@ -469,7 +235,7 @@ Parameters
+
system_priority diff --git a/docs/cisco.nxos.nxos_vrf_af_module.rst b/docs/cisco.nxos.nxos_vrf_af_module.rst index b2274781d..a48a43847 100644 --- a/docs/cisco.nxos.nxos_vrf_af_module.rst +++ b/docs/cisco.nxos.nxos_vrf_af_module.rst @@ -53,240 +53,6 @@ Parameters
Address-Family Identifier (AFI).
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
diff --git a/docs/cisco.nxos.nxos_vrf_interface_module.rst b/docs/cisco.nxos.nxos_vrf_interface_module.rst index 7f7fb2a25..156ded21c 100644 --- a/docs/cisco.nxos.nxos_vrf_interface_module.rst +++ b/docs/cisco.nxos.nxos_vrf_interface_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
ParameterParameter Choices/Defaults Comments
+
interface @@ -50,241 +50,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -303,7 +69,7 @@ Parameters
+
vrf diff --git a/docs/cisco.nxos.nxos_vrf_module.rst b/docs/cisco.nxos.nxos_vrf_module.rst index 20576c8b0..3a9613157 100644 --- a/docs/cisco.nxos.nxos_vrf_module.rst +++ b/docs/cisco.nxos.nxos_vrf_module.rst @@ -303,240 +303,6 @@ Parameters

aliases: vrf
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
diff --git a/docs/cisco.nxos.nxos_vrrp_module.rst b/docs/cisco.nxos.nxos_vrrp_module.rst index 392e5c54c..88183c5af 100644 --- a/docs/cisco.nxos.nxos_vrrp_module.rst +++ b/docs/cisco.nxos.nxos_vrrp_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -945,13 +975,12 @@ Common return values are documented `here list - + @@ -963,12 +992,63 @@ Common return values are documented `here list - + + + + + + + + + + + + + + + +
ParameterParameter Choices/Defaults Comments
+
admin_state @@ -54,7 +54,7 @@ Parameters
+
authentication @@ -69,7 +69,7 @@ Parameters
+
group @@ -85,7 +85,7 @@ Parameters
+
interface @@ -101,7 +101,7 @@ Parameters
+
interval @@ -116,7 +116,7 @@ Parameters
+
preempt @@ -135,7 +135,7 @@ Parameters
+
priority @@ -150,241 +150,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -403,7 +169,7 @@ Parameters
+
vip diff --git a/docs/cisco.nxos.nxos_vtp_domain_module.rst b/docs/cisco.nxos.nxos_vtp_domain_module.rst index c2c3ad6b5..db2e8bd89 100644 --- a/docs/cisco.nxos.nxos_vtp_domain_module.rst +++ b/docs/cisco.nxos.nxos_vtp_domain_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
+
domain @@ -49,240 +49,6 @@ Parameters
VTP domain name.
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-

diff --git a/docs/cisco.nxos.nxos_vtp_password_module.rst b/docs/cisco.nxos.nxos_vtp_password_module.rst index d6f7616c6..084e62b8a 100644 --- a/docs/cisco.nxos.nxos_vtp_password_module.rst +++ b/docs/cisco.nxos.nxos_vtp_password_module.rst @@ -29,246 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterParameter Choices/Defaults Comments
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -287,7 +53,7 @@ Parameters
+
vtp_password diff --git a/docs/cisco.nxos.nxos_vtp_version_module.rst b/docs/cisco.nxos.nxos_vtp_version_module.rst index 35fefd9de..9271dbe28 100644 --- a/docs/cisco.nxos.nxos_vtp_version_module.rst +++ b/docs/cisco.nxos.nxos_vtp_version_module.rst @@ -29,246 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/cisco.nxos.nxos_lacp_module.rst b/docs/cisco.nxos.nxos_lacp_module.rst index 81fcb8fc2..b0410c783 100644 --- a/docs/cisco.nxos.nxos_lacp_module.rst +++ b/docs/cisco.nxos.nxos_lacp_module.rst @@ -171,6 +171,7 @@ Parameters
    Choices:
  • merged ←
  • replaced
  • +
  • overridden
  • deleted
  • gathered
  • rendered
  • @@ -179,6 +180,7 @@ Parameters
ParameterParameter Choices/Defaults Comments
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
version diff --git a/docs/cisco.nxos.nxos_vxlan_vtep_module.rst b/docs/cisco.nxos.nxos_vxlan_vtep_module.rst index f367016b1..61bef90ac 100644 --- a/docs/cisco.nxos.nxos_vxlan_vtep_module.rst +++ b/docs/cisco.nxos.nxos_vxlan_vtep_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/modules/nxos_command.py b/plugins/modules/nxos_command.py index caf2a59d4..7febbf8a7 100644 --- a/plugins/modules/nxos_command.py +++ b/plugins/modules/nxos_command.py @@ -60,9 +60,10 @@ retries: description: - Specifies the number of retries a command should by tried before it is considered - failed. The command is run on the target device every retry and evaluated against + failed. The command is run on the target device every retry and evaluated against the I(wait_for) conditionals. - default: 10 + - The commands are run once when I(retries) is set to C(0). + default: 9 type: int interval: description: @@ -176,7 +177,7 @@ def main(): commands=dict(type="list", required=True, elements="raw"), wait_for=dict(type="list", aliases=["waitfor"], elements="str"), match=dict(default="all", choices=["any", "all"]), - retries=dict(default=10, type="int"), + retries=dict(default=9, type="int"), interval=dict(default=1, type="int"), ) @@ -186,6 +187,7 @@ def main(): result = {"changed": False, "warnings": warnings} commands = parse_commands(module, warnings) wait_for = module.params["wait_for"] or list() + conditionals = [] try: conditionals = [Conditional(c) for c in wait_for] @@ -196,7 +198,7 @@ def main(): interval = module.params["interval"] match = module.params["match"] - while retries > 0: + while retries >= 0: responses = run_commands(module, commands) for item in list(conditionals): diff --git a/tests/unit/modules/network/nxos/test_nxos_command.py b/tests/unit/modules/network/nxos/test_nxos_command.py index ca11ba3a2..cb7c40ba9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_command.py +++ b/tests/unit/modules/network/nxos/test_nxos_command.py @@ -89,7 +89,12 @@ def test_nxos_command_retries(self): wait_for = 'result[0] contains "test string"' set_module_args(dict(commands=["show version"], wait_for=wait_for, retries=2)) self.execute_module(failed=True) - self.assertEqual(self.run_commands.call_count, 2) + self.assertEqual(self.run_commands.call_count, 3) + + def test_nxos_command_retries_0(self): + set_module_args(dict(commands=["show version"], retries=0)) + self.execute_module(failed=False) + self.assertEqual(self.run_commands.call_count, 1) def test_nxos_command_match_any(self): wait_for = [ From bdb6ee431dfd0b7628acd881f57b257843faa2e7 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 8 Feb 2023 12:40:20 +0530 Subject: [PATCH 064/166] [acls] detect and fail for duplicate ACE error (#620) Signed-off-by: NilashishC --- changelogs/fragments/acls.yaml | 3 +++ plugins/terminal/nxos.py | 1 + 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/acls.yaml diff --git a/changelogs/fragments/acls.yaml b/changelogs/fragments/acls.yaml new file mode 100644 index 000000000..2d4f4fcc3 --- /dev/null +++ b/changelogs/fragments/acls.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_acls - Detect duplicate ACE error message from CLI and fail (https://github.com/ansible-collections/cisco.nxos/issues/611)." diff --git a/plugins/terminal/nxos.py b/plugins/terminal/nxos.py index d9cf5af70..ff0ada40d 100644 --- a/plugins/terminal/nxos.py +++ b/plugins/terminal/nxos.py @@ -63,6 +63,7 @@ class TerminalModule(TerminalBase): re.I, ), re.compile(rb"No corresponding (.+) configured", re.I), + re.compile(rb"(.+)please specify sequence number", re.I), ] terminal_config_prompt = re.compile(r"^.*\((?!maint-mode).*\)#$") From e4905fa30fcbf25a0f6f7cf75f71c80a7ade7ae7 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 13 Feb 2023 18:04:40 +0530 Subject: [PATCH 065/166] [acls] fix IPv6 prefix to host conversion (#625) * [acls] fix IPv6 prefix to host conversion Signed-off-by: NilashishC * Remove preceeding whitespace Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/nxos_acls.yaml | 3 +++ .../network/nxos/facts/acls/acls.py | 16 +++++++++---- .../modules/network/nxos/test_nxos_acls.py | 23 +++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/nxos_acls.yaml diff --git a/changelogs/fragments/nxos_acls.yaml b/changelogs/fragments/nxos_acls.yaml new file mode 100644 index 000000000..516918c74 --- /dev/null +++ b/changelogs/fragments/nxos_acls.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623)." diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index b6ddecc4e..27fee6e0e 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -23,6 +23,10 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acls.acls import ( AclsArgs, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + validate_ipv4_addr, + validate_ipv6_addr, +) class AclsFacts(object): @@ -96,11 +100,15 @@ def get_endpoint(self, ace, pro): else: # it could be a.b.c.d or a.b.c.d/x or a.b.c.d/32 if "/" in option: # or 'host' in option: - ip = re.search(r"(.*)/(\d+)", option) - if int(ip.group(2)) < 32 or 32 < int(ip.group(2)) < 128: - ret_dict.update({"prefix": option}) + prefix = re.search(r"(.*)/(\d+)", option) + ip = prefix.group(1) + cidr = prefix.group(2) + if (validate_ipv4_addr(option) and int(cidr) == 32) or ( + validate_ipv6_addr(option) and int(cidr) == 128 + ): + ret_dict.update({"host": ip}) else: - ret_dict.update({"host": ip.group(1)}) + ret_dict.update({"prefix": option}) else: ret_dict.update({"address": option}) wb = ace.split()[1] diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index 715a5c81d..be5fe0d5b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -639,6 +639,9 @@ def test_nxos_acls_parse_remark(self): 10 permit udp any any 20 deny tcp any any 30 remark for resetting to default run resequence ip access-list TEST_RESEQUENCE_ipv6 2 3 + ipv6 access-list TEST_PREFIX_HOST + 10 permit ipv6 fd00:976a::/32 any + 20 permit ipv6 2001:db8:85a3::8a2e:370:7334/128 any """, ) set_module_args(dict(state="gathered")) @@ -669,6 +672,25 @@ def test_nxos_acls_parse_remark(self): }, ], }, + { + "name": "TEST_PREFIX_HOST", + "aces": [ + { + "sequence": 10, + "grant": "permit", + "protocol": "ipv6", + "source": {"prefix": "fd00:976a::/32"}, + "destination": {"any": True}, + }, + { + "sequence": 20, + "grant": "permit", + "protocol": "ipv6", + "source": {"host": "2001:db8:85a3::8a2e:370:7334"}, + "destination": {"any": True}, + }, + ], + }, ], "afi": "ipv6", }, @@ -740,4 +762,5 @@ def test_nxos_acls_parse_remark(self): }, ] result = self.execute_module(changed=False) + print(result["gathered"]) self.assertEqual(result["gathered"], gathered) From 333daed2635c96760030af52fc7ea81f38ad662a Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 16 Feb 2023 13:35:42 +0530 Subject: [PATCH 066/166] Remove unused imports (#627) * Remove unused imports Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/unused_imports.yaml | 3 ++ plugins/cliconf/nxos.py | 5 +-- .../config/acl_interfaces/acl_interfaces.py | 2 -- .../network/nxos/config/acls/acls.py | 2 -- .../bgp_address_family/bgp_address_family.py | 2 -- .../nxos/config/bgp_global/bgp_global.py | 2 -- .../config/hsrp_interfaces/hsrp_interfaces.py | 3 -- .../nxos/config/interfaces/interfaces.py | 1 - .../config/l2_interfaces/l2_interfaces.py | 1 - .../config/l3_interfaces/l3_interfaces.py | 2 -- .../config/ospf_interfaces/ospf_interfaces.py | 2 -- .../network/nxos/config/ospfv2/ospfv2.py | 1 - .../network/nxos/config/ospfv3/ospfv3.py | 2 -- .../nxos/config/route_maps/route_maps.py | 2 -- .../config/static_routes/static_routes.py | 3 -- .../facts/acl_interfaces/acl_interfaces.py | 3 -- .../bgp_address_family/bgp_address_family.py | 2 -- .../nxos/facts/bgp_global/bgp_global.py | 2 -- .../bgp_neighbor_address_family.py | 3 -- .../network/nxos/facts/hostname/hostname.py | 3 -- .../nxos/facts/interfaces/interfaces.py | 3 -- .../facts/lag_interfaces/lag_interfaces.py | 4 --- .../facts/logging_global/logging_global.py | 3 -- .../nxos/facts/ntp_global/ntp_global.py | 3 -- .../facts/ospf_interfaces/ospf_interfaces.py | 3 -- .../network/nxos/facts/ospfv3/ospfv3.py | 1 - .../nxos/facts/route_maps/route_maps.py | 3 -- .../network/nxos/facts/vlans/vlans.py | 1 - plugins/module_utils/network/nxos/nxos.py | 19 ++-------- plugins/modules/storage/nxos_zone_zoneset.py | 1 - tests/unit/compat/builtins.py | 35 ------------------- .../nxos/storage/test_nxos_devicealias.py | 4 --- .../network/nxos/storage/test_nxos_vsan.py | 1 - .../nxos/storage/test_nxos_zone_zoneset.py | 9 ----- .../network/nxos/test_nxos_acl_interfaces.py | 4 +-- .../modules/network/nxos/test_nxos_acls.py | 2 +- .../network/nxos/test_nxos_bfd_global.py | 1 - .../network/nxos/test_nxos_bfd_interfaces.py | 6 +--- .../nxos/test_nxos_bgp_address_family.py | 3 +- .../network/nxos/test_nxos_bgp_global.py | 3 +- .../test_nxos_bgp_neighbor_address_family.py | 3 +- .../network/nxos/test_nxos_hostname.py | 2 -- .../network/nxos/test_nxos_hsrp_interfaces.py | 6 +--- .../network/nxos/test_nxos_interfaces.py | 9 +---- .../network/nxos/test_nxos_l3_interfaces.py | 3 +- .../network/nxos/test_nxos_lacp_interfaces.py | 2 +- .../network/nxos/test_nxos_lldp_interfaces.py | 4 +-- .../network/nxos/test_nxos_logging_global.py | 3 -- .../network/nxos/test_nxos_ntp_global.py | 1 - .../network/nxos/test_nxos_ospf_interfaces.py | 3 +- .../modules/network/nxos/test_nxos_ospfv2.py | 3 +- .../modules/network/nxos/test_nxos_ospfv3.py | 3 +- .../modules/network/nxos/test_nxos_ping.py | 5 +-- .../network/nxos/test_nxos_prefix_lists.py | 3 -- .../network/nxos/test_nxos_route_maps.py | 3 +- .../network/nxos/test_nxos_static_routes.py | 4 +-- .../network/nxos/test_nxos_telemetry.py | 4 --- .../modules/network/nxos/test_nxos_vlans.py | 6 ---- 58 files changed, 26 insertions(+), 196 deletions(-) create mode 100644 changelogs/fragments/unused_imports.yaml delete mode 100644 tests/unit/compat/builtins.py diff --git a/changelogs/fragments/unused_imports.yaml b/changelogs/fragments/unused_imports.yaml new file mode 100644 index 000000000..d54872af1 --- /dev/null +++ b/changelogs/fragments/unused_imports.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove unused imports. diff --git a/plugins/cliconf/nxos.py b/plugins/cliconf/nxos.py index 0dd8f2d2f..1b3bd909b 100644 --- a/plugins/cliconf/nxos.py +++ b/plugins/cliconf/nxos.py @@ -56,10 +56,7 @@ dumps, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list -from ansible_collections.ansible.netcommon.plugins.plugin_utils.cliconf_base import ( - CliconfBase, - enable_mode, -) +from ansible_collections.ansible.netcommon.plugins.plugin_utils.cliconf_base import CliconfBase class Cliconf(CliconfBase): diff --git a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py index 6c0b3b939..5bd15062e 100644 --- a/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/config/acl_interfaces/acl_interfaces.py @@ -19,14 +19,12 @@ ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_diff, remove_empties, to_list, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - flatten_dict, get_interface_type, normalize_interface, search_obj_in_list, diff --git a/plugins/module_utils/network/nxos/config/acls/acls.py b/plugins/module_utils/network/nxos/config/acls/acls.py index 0d620a607..a45cf94a6 100644 --- a/plugins/module_utils/network/nxos/config/acls/acls.py +++ b/plugins/module_utils/network/nxos/config/acls/acls.py @@ -17,8 +17,6 @@ import re -from copy import deepcopy - from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( ConfigBase, diff --git a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py index d7a276677..4443039c3 100644 --- a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py @@ -18,8 +18,6 @@ created. """ -import re - from copy import deepcopy from ansible.module_utils.six import iteritems diff --git a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py index e8bc70bc2..edb6e59bb 100644 --- a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py @@ -18,8 +18,6 @@ created. """ -from copy import deepcopy - from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, diff --git a/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py b/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py index 481578d04..757505e71 100644 --- a/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py +++ b/plugins/module_utils/network/nxos/config/hsrp_interfaces/hsrp_interfaces.py @@ -19,17 +19,14 @@ ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - remove_empties, to_list, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( flatten_dict, - get_interface_type, normalize_interface, search_obj_in_list, - vlan_range_to_list, ) diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index 05aa0187c..32c5f6fe7 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -35,7 +35,6 @@ ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( normalize_interface, - remove_rsvd_interfaces, search_obj_in_list, ) diff --git a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py index e8580f189..e7d91498f 100644 --- a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py @@ -24,7 +24,6 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, remove_empties, - to_list, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts diff --git a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py index 0bb5f4bac..55ac22660 100644 --- a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py @@ -30,9 +30,7 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - get_interface_type, normalize_interface, - remove_rsvd_interfaces, search_obj_in_list, ) diff --git a/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py index 7be8d5ff0..0a1bc5806 100644 --- a/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py @@ -18,8 +18,6 @@ created. """ -from copy import deepcopy - from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, diff --git a/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py b/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py index e84fc2e8d..8a6f42e7a 100644 --- a/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py @@ -15,7 +15,6 @@ necessary to bring the current configuration to it's desired end-state is created """ -from copy import deepcopy from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( diff --git a/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py index 45e55c9d0..e60fc31a2 100644 --- a/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py @@ -18,8 +18,6 @@ created. """ -from copy import deepcopy - from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index a1b9b2173..b098b0654 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -18,8 +18,6 @@ created. """ -from copy import deepcopy - from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, diff --git a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py index f6cfdaed4..721ff82c1 100644 --- a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py @@ -21,15 +21,12 @@ ConfigBase, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - dict_diff, remove_empties, to_list, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - flatten_dict, - get_interface_type, normalize_interface, search_obj_in_list, ) diff --git a/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py b/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py index 4fe468e30..053b56a91 100644 --- a/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/acl_interfaces/acl_interfaces.py @@ -24,9 +24,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acl_interfaces.acl_interfaces import ( Acl_interfacesArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - normalize_interface, -) class Acl_interfacesFacts(object): diff --git a/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py index 97c50ed8c..a1b0bc22d 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/facts/bgp_address_family/bgp_address_family.py @@ -15,8 +15,6 @@ based on the configuration. """ -from copy import deepcopy - from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils diff --git a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py index b0caec1af..621e499fd 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py @@ -15,8 +15,6 @@ based on the configuration. """ -from copy import deepcopy - from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils diff --git a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 681154bce..e26c1826a 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -15,9 +15,6 @@ based on the configuration. """ -from copy import deepcopy - -from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_neighbor_address_family.bgp_neighbor_address_family import ( diff --git a/plugins/module_utils/network/nxos/facts/hostname/hostname.py b/plugins/module_utils/network/nxos/facts/hostname/hostname.py index f672c8272..981648c0c 100644 --- a/plugins/module_utils/network/nxos/facts/hostname/hostname.py +++ b/plugins/module_utils/network/nxos/facts/hostname/hostname.py @@ -15,9 +15,6 @@ based on the configuration. """ -from copy import deepcopy - -from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.hostname.hostname import ( diff --git a/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py b/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py index 4fa4008ac..92592b07c 100644 --- a/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/facts/interfaces/interfaces.py @@ -23,9 +23,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.interfaces.interfaces import ( InterfacesArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - default_intf_enabled, -) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( get_interface_type, ) diff --git a/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py index f8c0db797..b94c57e27 100644 --- a/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/lag_interfaces/lag_interfaces.py @@ -23,10 +23,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.lag_interfaces.lag_interfaces import ( Lag_interfacesArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - get_interface_type, - normalize_interface, -) class Lag_interfacesFacts(object): diff --git a/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py b/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py index 7222ce582..189db0e41 100644 --- a/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py +++ b/plugins/module_utils/network/nxos/facts/logging_global/logging_global.py @@ -15,9 +15,6 @@ based on the configuration. """ -from copy import deepcopy - -from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.logging_global.logging_global import ( diff --git a/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py b/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py index e1798958e..258b68aaf 100644 --- a/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/nxos/facts/ntp_global/ntp_global.py @@ -15,9 +15,6 @@ based on the configuration. """ -from copy import deepcopy - -from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ntp_global.ntp_global import ( diff --git a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py index bfec2d51b..745f373b2 100644 --- a/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/facts/ospf_interfaces/ospf_interfaces.py @@ -15,9 +15,6 @@ based on the configuration. """ -from copy import deepcopy - -from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospf_interfaces.ospf_interfaces import ( diff --git a/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py index 2eb32cf44..796dacfb5 100644 --- a/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/facts/ospfv3/ospfv3.py @@ -14,7 +14,6 @@ for a given resource, parsed, and the facts tree is populated based on the configuration. """ -from copy import deepcopy from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils diff --git a/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py b/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py index 5d843c5b4..d1bad913a 100644 --- a/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/facts/route_maps/route_maps.py @@ -15,9 +15,6 @@ based on the configuration. """ -from copy import deepcopy - -from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.route_maps.route_maps import ( diff --git a/plugins/module_utils/network/nxos/facts/vlans/vlans.py b/plugins/module_utils/network/nxos/facts/vlans/vlans.py index 3b35792b6..32968d2d1 100644 --- a/plugins/module_utils/network/nxos/facts/vlans/vlans.py +++ b/plugins/module_utils/network/nxos/facts/vlans/vlans.py @@ -23,7 +23,6 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( parse_conf_arg, - parse_conf_cmd_arg, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.vlans.vlans import ( diff --git a/plugins/module_utils/network/nxos/nxos.py b/plugins/module_utils/network/nxos/nxos.py index 35b40cbf5..f0e3843e4 100644 --- a/plugins/module_utils/network/nxos/nxos.py +++ b/plugins/module_utils/network/nxos/nxos.py @@ -34,7 +34,6 @@ import json import re -import sys from copy import deepcopy @@ -60,14 +59,6 @@ except ImportError: HAS_YAML = False -try: - if sys.version_info[:2] < (2, 7): - from ordereddict import OrderedDict - else: - from collections import OrderedDict - HAS_ORDEREDDICT = True -except ImportError: - HAS_ORDEREDDICT = False _DEVICE_CONNECTION = None @@ -862,14 +853,8 @@ def compare(playval, existing): def nxosCmdRef_import_check(): """Return import error messages or empty string""" msg = "" - if PY2: - if not HAS_ORDEREDDICT and sys.version_info[:2] < (2, 7): - msg += "Mandatory python library 'ordereddict' is not present, try 'pip install ordereddict'\n" - if not HAS_YAML: - msg += "Mandatory python library 'yaml' is not present, try 'pip install yaml'\n" - elif PY3: - if not HAS_YAML: - msg += "Mandatory python library 'PyYAML' is not present, try 'pip install PyYAML'\n" + if not HAS_YAML: + msg += "Mandatory python library 'PyYAML' is not present, try 'pip install PyYAML'\n" return msg diff --git a/plugins/modules/storage/nxos_zone_zoneset.py b/plugins/modules/storage/nxos_zone_zoneset.py index ea40e1fa4..7c9fba30a 100644 --- a/plugins/modules/storage/nxos_zone_zoneset.py +++ b/plugins/modules/storage/nxos_zone_zoneset.py @@ -213,7 +213,6 @@ """ -import json import re from ansible.module_utils.basic import AnsibleModule diff --git a/tests/unit/compat/builtins.py b/tests/unit/compat/builtins.py deleted file mode 100644 index e898a081e..000000000 --- a/tests/unit/compat/builtins.py +++ /dev/null @@ -1,35 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# 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 . - -# Make coding more python3-ish -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -# -# Compat for python2.7 -# - -# One unittest needs to import builtins via __import__() so we need to have -# the string that represents it -try: - import __builtin__ -except ImportError: - BUILTINS = "builtins" -else: - BUILTINS = "__builtin__" diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py b/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py index 8ae5b9b56..a35896fbe 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py @@ -10,10 +10,6 @@ import pytest from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_devicealias -from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_devicealias import ( - showDeviceAliasDatabase, - showDeviceAliasStatus, -) from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py b/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py index 55a892054..db79f8668 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py @@ -10,7 +10,6 @@ import pytest from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_vsan -from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_vsan import GetVsanInfoFromSwitch from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleFailJson diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py b/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py index 6f91183b8..b49dbf2fd 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py +++ b/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py @@ -8,17 +8,8 @@ __metaclass__ = type -import pytest - from ansible_collections.cisco.nxos.plugins.modules.storage import nxos_zone_zoneset -from ansible_collections.cisco.nxos.plugins.modules.storage.nxos_zone_zoneset import ( - ShowZone, - ShowZoneset, - ShowZonesetActive, - ShowZoneStatus, -) from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch -from ansible_collections.cisco.nxos.tests.unit.modules.utils import AnsibleExitJson, AnsibleFailJson from ..nxos_module import TestNxosModule, load_fixture, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py index 8db951422..ae56208fd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py @@ -9,10 +9,10 @@ __metaclass__ = type from ansible_collections.cisco.nxos.plugins.modules import nxos_acl_interfaces -from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +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, load_fixture +from .nxos_module import TestNxosModule class TestNxosAclInterfacesModule(TestNxosModule): diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index be5fe0d5b..f9a73f125 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -11,7 +11,7 @@ from textwrap import dedent from ansible_collections.cisco.nxos.plugins.modules import nxos_acls -from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +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 diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py index 337637ef6..e0e48ac7a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py @@ -27,7 +27,6 @@ import pytest from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - NxosCmdRef, nxosCmdRef_import_check, ) from ansible_collections.cisco.nxos.plugins.modules import nxos_bfd_global diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py index b160214e0..e40f5fc2e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py @@ -24,14 +24,10 @@ from textwrap import dedent -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bfd_interfaces.bfd_interfaces import ( - Bfd_interfaces, -) from ansible_collections.cisco.nxos.plugins.modules import nxos_bfd_interfaces 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py index b9c905062..d9c6c2357 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_address_family 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index 84ba12420..612c7a1f9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_global 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 0517904a8..2b7e1591c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_bgp_neighbor_address_family 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_hostname.py b/tests/unit/modules/network/nxos/test_nxos_hostname.py index 1286241e0..732f59e7a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hostname.py +++ b/tests/unit/modules/network/nxos/test_nxos_hostname.py @@ -19,8 +19,6 @@ from __future__ import absolute_import, division, print_function -from typing import Sequence - __metaclass__ = type diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py index 67b6ed935..e4f21a825 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py @@ -24,14 +24,10 @@ from textwrap import dedent -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.hsrp_interfaces.hsrp_interfaces import ( - Hsrp_interfaces, -) from ansible_collections.cisco.nxos.plugins.modules import nxos_hsrp_interfaces 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index f44c7cce8..055c441a4 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -24,17 +24,10 @@ from textwrap import dedent -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.interfaces.interfaces import ( - Interfaces, -) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.interfaces.interfaces import ( - InterfacesFacts, -) from ansible_collections.cisco.nxos.plugins.modules import nxos_interfaces 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py index 05100bf65..b0ac68f4d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py @@ -29,9 +29,8 @@ ) from ansible_collections.cisco.nxos.plugins.modules import nxos_l3_interfaces from ansible_collections.cisco.nxos.tests.unit.compat.mock import PropertyMock, 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py index 7d474b9bb..e6850278a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py @@ -25,7 +25,7 @@ from textwrap import dedent from ansible_collections.cisco.nxos.plugins.modules import nxos_lacp_interfaces -from ansible_collections.cisco.nxos.tests.unit.compat.mock import PropertyMock, patch +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch from .nxos_module import TestNxosModule, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py index c1152acdc..c2acfcc49 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py @@ -9,10 +9,10 @@ __metaclass__ = type from ansible_collections.cisco.nxos.plugins.modules import nxos_lldp_interfaces -from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +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, load_fixture +from .nxos_module import TestNxosModule class TestNxosLldpInterfacesModule(TestNxosModule): diff --git a/tests/unit/modules/network/nxos/test_nxos_logging_global.py b/tests/unit/modules/network/nxos/test_nxos_logging_global.py index 06d95ddfc..aea13fc94 100644 --- a/tests/unit/modules/network/nxos/test_nxos_logging_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_logging_global.py @@ -19,8 +19,6 @@ from __future__ import absolute_import, division, print_function -from typing import Sequence - __metaclass__ = type @@ -28,7 +26,6 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_logging_global 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, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py index 36a448cee..7c49d8668 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py @@ -26,7 +26,6 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_ntp_global 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, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py index 0e5e74b29..f22889574 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_ospf_interfaces 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py index b774e4b7e..175570499 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_ospfv2 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py index f883277fd..70a2ae47e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_ospfv3 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_ping.py b/tests/unit/modules/network/nxos/test_nxos_ping.py index 0b7b5d6a9..73535f89e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ping.py +++ b/tests/unit/modules/network/nxos/test_nxos_ping.py @@ -22,13 +22,10 @@ __metaclass__ = type -from textwrap import dedent - from ansible_collections.cisco.nxos.plugins.modules import nxos_ping 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py index 8eb6a5f7a..d94f0b3e0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py +++ b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py @@ -19,8 +19,6 @@ from __future__ import absolute_import, division, print_function -from typing import Sequence - __metaclass__ = type @@ -28,7 +26,6 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_prefix_lists 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, set_module_args diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index 114d27434..aae0699aa 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -26,9 +26,8 @@ from ansible_collections.cisco.nxos.plugins.modules import nxos_route_maps 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, set_module_args ignore_provider_arg = True diff --git a/tests/unit/modules/network/nxos/test_nxos_static_routes.py b/tests/unit/modules/network/nxos/test_nxos_static_routes.py index 7feab35d3..69f5f74bd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_routes.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_routes.py @@ -9,10 +9,10 @@ __metaclass__ = type from ansible_collections.cisco.nxos.plugins.modules import nxos_static_routes -from ansible_collections.cisco.nxos.tests.unit.compat.mock import MagicMock, patch +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, load_fixture +from .nxos_module import TestNxosModule class TestNxosStaticRoutesModule(TestNxosModule): diff --git a/tests/unit/modules/network/nxos/test_nxos_telemetry.py b/tests/unit/modules/network/nxos/test_nxos_telemetry.py index 783f357ef..160804c11 100644 --- a/tests/unit/modules/network/nxos/test_nxos_telemetry.py +++ b/tests/unit/modules/network/nxos/test_nxos_telemetry.py @@ -28,11 +28,7 @@ # shippable, which fails this test due to import yaml & import ordereddict. import pytest -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.telemetry.telemetry import ( - Telemetry, -) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - NxosCmdRef, nxosCmdRef_import_check, ) from ansible_collections.cisco.nxos.plugins.modules import nxos_telemetry diff --git a/tests/unit/modules/network/nxos/test_nxos_vlans.py b/tests/unit/modules/network/nxos/test_nxos_vlans.py index f85fe42cd..97870e76d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vlans.py +++ b/tests/unit/modules/network/nxos/test_nxos_vlans.py @@ -22,14 +22,8 @@ __metaclass__ = type -from textwrap import dedent - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.vlans.vlans import ( - Vlans, -) from ansible_collections.cisco.nxos.plugins.modules import nxos_vlans 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 0321ac9212cc148d0e192cdcb3c4c11b259a5f67 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 16 Feb 2023 18:29:51 +0530 Subject: [PATCH 067/166] [acls] support ICMPv6 options in ACEs (#626) * [acls] support ICMPv6 options in ACEs Signed-off-by: NilashishC * Fix lint Signed-off-by: NilashishC * Add tests Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/acls_icmp.yaml | 3 + docs/cisco.nxos.nxos_acls_module.rst | 764 ++++++++++++++++++ .../network/nxos/argspec/acls/acls.py | 56 ++ .../network/nxos/config/acls/acls.py | 10 +- .../network/nxos/facts/acls/acls.py | 46 +- plugins/modules/nxos_acls.py | 97 +++ .../modules/network/nxos/test_nxos_acls.py | 91 ++- 7 files changed, 1060 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/acls_icmp.yaml diff --git a/changelogs/fragments/acls_icmp.yaml b/changelogs/fragments/acls_icmp.yaml new file mode 100644 index 000000000..7c549e7ac --- /dev/null +++ b/changelogs/fragments/acls_icmp.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new options (https://github.com/ansible-collections/cisco.nxos/issues/624)." diff --git a/docs/cisco.nxos.nxos_acls_module.rst b/docs/cisco.nxos.nxos_acls_module.rst index a6db4aeb9..1c8801e8b 100644 --- a/docs/cisco.nxos.nxos_acls_module.rst +++ b/docs/cisco.nxos.nxos_acls_module.rst @@ -1643,6 +1643,770 @@ Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/module_utils/network/nxos/argspec/acls/acls.py b/plugins/module_utils/network/nxos/argspec/acls/acls.py index f0f17944a..3618248b7 100644 --- a/plugins/module_utils/network/nxos/argspec/acls/acls.py +++ b/plugins/module_utils/network/nxos/argspec/acls/acls.py @@ -154,6 +154,62 @@ class AclsArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "icmpv6": { + "type": "dict", + "options": { + "beyond_scope": {"type": "bool"}, + "destination_unreachable": { + "type": "bool", + }, + "echo_reply": {"type": "bool"}, + "echo_request": {"type": "bool"}, + "fragments": {"type": "bool"}, + "header": {"type": "bool"}, + "hop_limit": {"type": "bool"}, + "mld_query": {"type": "bool"}, + "mld_reduction": {"type": "bool"}, + "mld_report": {"type": "bool"}, + "mldv2": {"type": "bool"}, + "nd_na": {"type": "bool"}, + "nd_ns": {"type": "bool"}, + "next_header": {"type": "bool"}, + "no_admin": {"type": "bool"}, + "no_route": {"type": "bool"}, + "packet_too_big": {"type": "bool"}, + "parameter_option": { + "type": "bool", + }, + "parameter_problem": { + "type": "bool", + }, + "port_unreachable": { + "type": "bool", + }, + "reassembly_timeout": { + "type": "bool", + }, + "renum_command": {"type": "bool"}, + "renum_result": {"type": "bool"}, + "renum_seq_number": { + "type": "bool", + }, + "router_advertisement": { + "type": "bool", + }, + "router_renumbering": { + "type": "bool", + }, + "router_solicitation": { + "type": "bool", + }, + "time_exceeded": {"type": "bool"}, + "unreachable": {"type": "bool"}, + "telemetry_path": {"type": "bool"}, + "telemetry_queue": { + "type": "bool", + }, + }, + }, "igmp": { "mutually_exclusive": [ [ diff --git a/plugins/module_utils/network/nxos/config/acls/acls.py b/plugins/module_utils/network/nxos/config/acls/acls.py index a45cf94a6..5e6f3c34a 100644 --- a/plugins/module_utils/network/nxos/config/acls/acls.py +++ b/plugins/module_utils/network/nxos/config/acls/acls.py @@ -91,11 +91,11 @@ def execute_module(self): else: existing_acls_facts = self.get_acls_facts() commands.extend(self.set_config(existing_acls_facts)) + result["before"] = existing_acls_facts if commands and state in action_states: if not self._module.check_mode: self._connection.edit_config(commands) result["changed"] = True - result["before"] = existing_acls_facts result["commands"] = commands changed_acls_facts = self.get_acls_facts() @@ -614,7 +614,10 @@ def process_ace(self, w_ace): else: command += w_ace["grant"] + " " if "protocol" in ace_keys: - command += w_ace["protocol"] + " " + if w_ace["protocol"] == "icmpv6": + command += "icmp" + " " + else: + command += w_ace["protocol"] + " " src = self.get_address(w_ace["source"], w_ace["protocol"]) dest = self.get_address(w_ace["destination"], w_ace["protocol"]) command += src + dest @@ -624,7 +627,8 @@ def process_ace(self, w_ace): self._module.fail_json(msg="protocol and protocol_options mismatch") flags = "" for k in w_ace["protocol_options"][pro].keys(): - k = re.sub("_", "-", k) + if k not in ["telemetry_queue", "telemetry_path"]: + k = re.sub("_", "-", k) flags += k + " " command += flags if "dscp" in ace_keys: diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index 27fee6e0e..70ebfcdd8 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -201,6 +201,39 @@ def render_config(self, spec, conf): "traceroute", "ttl_exceeded", ], + "icmpv6": [ + "beyond_scope", + "destination_unreachable", + "echo_reply", + "echo_request", + "fragments", + "header", + "hop_limit", + "mld_query", + "mld_reduction", + "mld_report", + "mldv2", + "nd_na", + "nd_ns", + "next_header", + "no_admin", + "no_route", + "packet_too_big", + "parameter_option", + "parameter_problem", + "port_unreachable", + "reassembly_timeout", + "renum_command", + "renum_result", + "renum_seq_number", + "router_advertisement", + "router_renumbering", + "router_solicitation", + "time_exceeded", + "unreachable", + "telemetry_path", + "telemetry_queue", + ], "igmp": ["dvmrp", "host_query", "host_report"], } if conf: @@ -239,8 +272,13 @@ def render_config(self, spec, conf): if not rem and seq: ace = re.sub(grant, "", ace, 1) + pro = ace.split()[0] - entry.update({"protocol": pro}) + if pro == "icmp" and config["afi"] == "ipv6": + entry.update({"protocol": "icmpv6"}) + else: + entry.update({"protocol": pro}) + ace = re.sub(pro, "", ace, 1) ace, source = self.get_endpoint(ace, pro) entry.update({"source": source}) @@ -263,11 +301,13 @@ def render_config(self, spec, conf): if log: entry.update({"log": True}) - if pro == "tcp" or pro == "icmp" or pro == "igmp": + pro = entry.get("protocol", "") + if pro in ["tcp", "icmp", "icmpv6", "igmp"]: pro_options = {} options = {} for option in protocol_options[pro]: - option = re.sub("_", "-", option) + if option not in ["telemetry_path", "telemetry_queue"]: + option = re.sub("_", "-", option) if option in ace: if option == "echo" and ( "echo_request" in options or "echo_reply" in options diff --git a/plugins/modules/nxos_acls.py b/plugins/modules/nxos_acls.py index 7f2638300..51a665047 100644 --- a/plugins/modules/nxos_acls.py +++ b/plugins/modules/nxos_acls.py @@ -352,6 +352,103 @@ unreachable: description: All unreachables type: bool + icmpv6: + description: ICMPv6 protocol options. + type: dict + suboptions: + beyond_scope: + description: Destination beyond scope. + type: bool + destination_unreachable: + description: Destination address is unreachable. + type: bool + echo_reply: + description: Echo reply. + type: bool + echo_request: + description: Echo request (ping). + type: bool + fragments: + description: Check non-initial fragments. + type: bool + header: + description: Parameter header problem. + type: bool + hop_limit: + description: Hop limit exceeded in transit. + type: bool + mld_query: + description: Multicast Listener Discovery Query. + type: bool + mld_reduction: + description: Multicast Listener Discovery Reduction. + type: bool + mld_report: + description: Multicast Listener Discovery Report. + type: bool + mldv2: + description: Multicast Listener Discovery Protocol. + type: bool + nd_na: + description: Neighbor discovery neighbor advertisements. + type: bool + nd_ns: + description: Neighbor discovery neighbor solicitations. + type: bool + next_header: + description: Parameter next header problems. + type: bool + no_admin: + description: Administration prohibited destination. + type: bool + no_route: + description: No route to destination. + type: bool + packet_too_big: + description: Packet too big. + type: bool + parameter_option: + description: Parameter option problems. + type: bool + parameter_problem: + description: All parameter problems. + type: bool + port_unreachable: + description: Port unreachable. + type: bool + reassembly_timeout: + description: Reassembly timeout. + type: bool + renum_command: + description: Router renumbering command. + type: bool + renum_result: + description: Router renumbering result. + type: bool + renum_seq_number: + description: Router renumbering sequence number reset. + type: bool + router_advertisement: + description: Neighbor discovery router advertisements. + type: bool + router_renumbering: + description: All router renumbering. + type: bool + router_solicitation: + description: Neighbor discovery router solicitations. + type: bool + time_exceeded: + description: All time exceeded. + type: bool + unreachable: + description: All unreachable. + type: bool + telemetry_path: + description: IPT enabled. + type: bool + telemetry_queue: + description: Flow of interest for BDC/HDC. + type: bool tcp: description: TCP flags. type: dict diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index f9a73f125..6436e065b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -642,6 +642,9 @@ def test_nxos_acls_parse_remark(self): ipv6 access-list TEST_PREFIX_HOST 10 permit ipv6 fd00:976a::/32 any 20 permit ipv6 2001:db8:85a3::8a2e:370:7334/128 any + ipv6 access-list TEST_ICMPv6 + 10 permit icmp any any nd-na + 20 deny icmp any any nd-ns telemetry_path """, ) set_module_args(dict(state="gathered")) @@ -691,6 +694,36 @@ def test_nxos_acls_parse_remark(self): }, ], }, + { + "name": "TEST_ICMPv6", + "aces": [ + { + "sequence": 10, + "grant": "permit", + "protocol": "icmpv6", + "protocol_options": { + "icmpv6": { + "nd_na": True, + }, + }, + "source": {"any": True}, + "destination": {"any": True}, + }, + { + "sequence": 20, + "grant": "deny", + "protocol": "icmpv6", + "protocol_options": { + "icmpv6": { + "nd_ns": True, + "telemetry_path": True, + }, + }, + "source": {"any": True}, + "destination": {"any": True}, + }, + ], + }, ], "afi": "ipv6", }, @@ -762,5 +795,61 @@ def test_nxos_acls_parse_remark(self): }, ] result = self.execute_module(changed=False) - print(result["gathered"]) self.assertEqual(result["gathered"], gathered) + + def test_nxos_acls_icmpv6_1(self): + self.execute_show_command.return_value = dedent( + """\ + ipv6 access-list TEST_ICMPv6 + 20 deny icmp any any nd-ns telemetry_path + """, + ) + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + acls=[ + dict( + name="TEST_ICMPv6", + aces=[ + dict( + grant="permit", + destination=dict(any=True), + source=dict(host="192.0.2.1"), + sequence=10, + protocol="icmpv6", + protocol_options=dict( + icmpv6=dict( + nd_na=True, + ), + ), + ), + dict( + grant="deny", + destination=dict(any=True), + source=dict(any=True), + sequence=20, + protocol="icmpv6", + protocol_options=dict( + icmpv6=dict( + nd_ns=True, + telemetry_path=True, + ), + ), + ), + ], + ), + ], + ), + ], + state="merged", + ), + ) + + commands = [ + "ipv6 access-list TEST_ICMPv6", + "10 permit icmp host 192.0.2.1 any nd-na", + ] + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], commands) From 11ece6a7be86918b0e3449ffeab96777ce4e9d6d Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 16 Feb 2023 19:28:25 +0530 Subject: [PATCH 068/166] Prepare for v4.1.0 release (#629) Signed-off-by: NilashishC --- CHANGELOG.rst | 18 ++++++++++++++ changelogs/changelog.yaml | 28 ++++++++++++++++++++++ changelogs/fragments/acls.yaml | 3 --- changelogs/fragments/acls_icmp.yaml | 3 --- changelogs/fragments/command.yaml | 3 --- changelogs/fragments/l2_mode.yaml | 3 --- changelogs/fragments/mds.yaml | 3 --- changelogs/fragments/nxos_acls.yaml | 3 --- changelogs/fragments/nxos_file_copy.yaml | 3 --- changelogs/fragments/nxos_snmp_revert.yaml | 3 --- changelogs/fragments/rm_base.yaml | 5 ---- changelogs/fragments/snmp.yaml | 3 --- changelogs/fragments/unused_imports.yaml | 3 --- 13 files changed, 46 insertions(+), 35 deletions(-) delete mode 100644 changelogs/fragments/acls.yaml delete mode 100644 changelogs/fragments/acls_icmp.yaml delete mode 100644 changelogs/fragments/command.yaml delete mode 100644 changelogs/fragments/l2_mode.yaml delete mode 100644 changelogs/fragments/mds.yaml delete mode 100644 changelogs/fragments/nxos_acls.yaml delete mode 100644 changelogs/fragments/nxos_file_copy.yaml delete mode 100644 changelogs/fragments/nxos_snmp_revert.yaml delete mode 100644 changelogs/fragments/rm_base.yaml delete mode 100644 changelogs/fragments/snmp.yaml delete mode 100644 changelogs/fragments/unused_imports.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index efafff9c5..731ebd599 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,24 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v4.1.0 +====== + +Minor Changes +------------- + +- `nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new options (https://github.com/ansible-collections/cisco.nxos/issues/624). +- `nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: all` does not fail for NX-OS on MDS switches. +- `nxos_l2_interfaces` - Add new mode dot1q-tunnel (https://github.com/ansible-collections/cisco.nxos/issues/600). + +Bugfixes +-------- + +- `nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623). +- `nxos_file_copy` - stop prepending redundant bootflash: to remote file names +- nxos_acls - Detect duplicate ACE error message from CLI and fail (https://github.com/ansible-collections/cisco.nxos/issues/611). +- nxos_command - Run & evaluate commands at least once even when retries is set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). + v4.0.1 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 4999116f1..713c844fc 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -919,3 +919,31 @@ releases: - nxos_acls.yaml - nxos_pim.yaml release_date: "2022-11-30" + 4.1.0: + changes: + bugfixes: + - "`nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623)." + - "`nxos_file_copy` - stop prepending redundant bootflash: to remote file names" + - nxos_acls - Detect duplicate ACE error message from CLI and fail + (https://github.com/ansible-collections/cisco.nxos/issues/611). + - nxos_command - Run & evaluate commands at least once even when retries is + set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). + minor_changes: + - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new + options (https://github.com/ansible-collections/cisco.nxos/issues/624)." + - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: + all` does not fail for NX-OS on MDS switches." + - "`nxos_l2_interfaces` - Add new mode dot1q-tunnel (https://github.com/ansible-collections/cisco.nxos/issues/600)." + fragments: + - acls.yaml + - acls_icmp.yaml + - command.yaml + - l2_mode.yaml + - mds.yaml + - nxos_acls.yaml + - nxos_file_copy.yaml + - nxos_snmp_revert.yaml + - rm_base.yaml + - snmp.yaml + - unused_imports.yaml + release_date: "2023-02-16" diff --git a/changelogs/fragments/acls.yaml b/changelogs/fragments/acls.yaml deleted file mode 100644 index 2d4f4fcc3..000000000 --- a/changelogs/fragments/acls.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_acls - Detect duplicate ACE error message from CLI and fail (https://github.com/ansible-collections/cisco.nxos/issues/611)." diff --git a/changelogs/fragments/acls_icmp.yaml b/changelogs/fragments/acls_icmp.yaml deleted file mode 100644 index 7c549e7ac..000000000 --- a/changelogs/fragments/acls_icmp.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new options (https://github.com/ansible-collections/cisco.nxos/issues/624)." diff --git a/changelogs/fragments/command.yaml b/changelogs/fragments/command.yaml deleted file mode 100644 index 0f7b23ee0..000000000 --- a/changelogs/fragments/command.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_command - Run & evaluate commands at least once even when retries is set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607)." diff --git a/changelogs/fragments/l2_mode.yaml b/changelogs/fragments/l2_mode.yaml deleted file mode 100644 index 0d1a9812e..000000000 --- a/changelogs/fragments/l2_mode.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_l2_interfaces` - Add new mode dot1q-tunnel (https://github.com/ansible-collections/cisco.nxos/issues/600)." diff --git a/changelogs/fragments/mds.yaml b/changelogs/fragments/mds.yaml deleted file mode 100644 index d3375adc1..000000000 --- a/changelogs/fragments/mds.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: all` does not fail for NX-OS on MDS switches." diff --git a/changelogs/fragments/nxos_acls.yaml b/changelogs/fragments/nxos_acls.yaml deleted file mode 100644 index 516918c74..000000000 --- a/changelogs/fragments/nxos_acls.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623)." diff --git a/changelogs/fragments/nxos_file_copy.yaml b/changelogs/fragments/nxos_file_copy.yaml deleted file mode 100644 index 46b3d27be..000000000 --- a/changelogs/fragments/nxos_file_copy.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`nxos_file_copy` - stop prepending redundant bootflash: to remote file names" diff --git a/changelogs/fragments/nxos_snmp_revert.yaml b/changelogs/fragments/nxos_snmp_revert.yaml deleted file mode 100644 index 145331cf7..000000000 --- a/changelogs/fragments/nxos_snmp_revert.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Update nxos_snmp_server tests for CI. diff --git a/changelogs/fragments/rm_base.yaml b/changelogs/fragments/rm_base.yaml deleted file mode 100644 index a2d02d495..000000000 --- a/changelogs/fragments/rm_base.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -trivial: - - Move references for ResourceModule to the rm_base package as the - non-rm_base path is going away. - (https://github.com/ansible-collections/ansible.netcommon/pull/496) diff --git a/changelogs/fragments/snmp.yaml b/changelogs/fragments/snmp.yaml deleted file mode 100644 index 9ad0c20ae..000000000 --- a/changelogs/fragments/snmp.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Remove redundant cleanup task. diff --git a/changelogs/fragments/unused_imports.yaml b/changelogs/fragments/unused_imports.yaml deleted file mode 100644 index d54872af1..000000000 --- a/changelogs/fragments/unused_imports.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Remove unused imports. From 414902a4ee770507e6cdcd01c21978b1be1b4cc5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 10 Mar 2023 10:53:29 +0530 Subject: [PATCH 069/166] [pre-commit.ci] pre-commit autoupdate (#634) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.4 → v3.0.0-alpha.6](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.4...v3.0.0-alpha.6) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89fa9a674..96d072083 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.4" + rev: "v3.0.0-alpha.6" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described From 769b7c4ed64713f468e530e4fe6799577c7a4f7e Mon Sep 17 00:00:00 2001 From: roverflow <63404819+roverflow@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:30:10 +0530 Subject: [PATCH 070/166] added codecov via gha (#639) --- .github/workflows/covflow.yml | 75 +++++++++++++++++++++++++++++ .github/workflows/runcov.yml | 15 ++++++ README.md | 1 + changelogs/fragments/ci_codecov.yml | 3 ++ codecov.yml | 10 ++++ 5 files changed, 104 insertions(+) create mode 100644 .github/workflows/covflow.yml create mode 100644 .github/workflows/runcov.yml create mode 100644 changelogs/fragments/ci_codecov.yml create mode 100644 codecov.yml diff --git a/.github/workflows/covflow.yml b/.github/workflows/covflow.yml new file mode 100644 index 000000000..5a5326409 --- /dev/null +++ b/.github/workflows/covflow.yml @@ -0,0 +1,75 @@ +name: CodeCoverage, dependencies from source +on: + workflow_call: + inputs: + collection_pre_install: + required: true + type: string +jobs: + codecoverage: + env: + PY_COLORS: "1" + source_directory: "./source" + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + ansible-version: + - Latest + python-version: + - "3.10" + runs-on: ${{ matrix.os }} + + name: "Code Coverage ${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.ansible-version }}" + steps: + - name: Checkout the collection repository + uses: actions/checkout@v3 + with: + path: ${{ env.source_directory }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: "0" + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install ansible-core (${{ matrix.ansible-version }}) + run: python3 -m pip install ansible-core + + - name: Read collection metadata from galaxy.yml + id: identify + uses: ansible-network/github_actions/.github/actions/identify_collection@main + with: + source_path: ${{ env.source_directory }} + + - name: Pre install collections dependencies first so the collection install does not + run: ansible-galaxy collection install ${{ inputs.collection_pre_install }} -p /home/runner/collections + if: inputs.collection_pre_install != '' + + - name: Build and install the collection + uses: ansible-network/github_actions/.github/actions/build_install_collection@main + with: + install_python_dependencies: true + source_path: ${{ env.source_directory }} + collection_path: ${{ steps.identify.outputs.collection_path }} + tar_file: ${{ steps.identify.outputs.tar_file }} + + - name: Print the ansible version + run: ansible --version + + - name: Print the python dependencies + run: python3 -m pip list + + - name: Run Coverage tests + run: | + ansible-test units --python ${{ matrix.python-version }} --coverage --requirements + ansible-test coverage xml + working-directory: ${{ steps.identify.outputs.collection_path }} + + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v3 + with: + directory: ${{ steps.identify.outputs.collection_path }} + fail_ci_if_error: true diff --git a/.github/workflows/runcov.yml b/.github/workflows/runcov.yml new file mode 100644 index 000000000..f89eb6c09 --- /dev/null +++ b/.github/workflows/runcov.yml @@ -0,0 +1,15 @@ +name: run-cov + +on: + push: + pull_request: + branches: [ main ] + +jobs: + #codecoverage + codecov: + uses: ./.github/workflows/covflow.yml + with: + collection_pre_install: >- + git+https://github.com/ansible-collections/ansible.utils.git + git+https://github.com/ansible-collections/ansible.netcommon.git diff --git a/README.md b/README.md index d5d93b820..add0c7f94 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ # Cisco NX-OS Collection [![CI](https://zuul-ci.org/gated.svg)](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/cisco.nxos) +[![Codecov](https://codecov.io/gh/ansible-collections/cisco.nxos/branch/main/graph/badge.svg)](https://codecov.io/gh/ansible-collections/cisco.nxos) The Ansible Cisco NX-OS collection includes a variety of Ansible content to help automate the management of Cisco NX-OS network appliances. diff --git a/changelogs/fragments/ci_codecov.yml b/changelogs/fragments/ci_codecov.yml new file mode 100644 index 000000000..ea17f51a8 --- /dev/null +++ b/changelogs/fragments/ci_codecov.yml @@ -0,0 +1,3 @@ +--- +trivial: + - added codecov to the CI pipeline diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..816cb4409 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +--- +codecov: + require_ci_to_pass: true +comment: false +coverage: + status: + patch: false + project: + default: + threshold: 0.3% From b418c4dbc5632b6115260a39e7e0544788221ef7 Mon Sep 17 00:00:00 2001 From: tnizharadze <64648821+tnizharadze@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:03:51 +0300 Subject: [PATCH 071/166] Bugfix: route-map description parameter idempotency (#644) * Bugfix: description parameter idempotency * Add bugfix changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: OSKS admin user Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelogs/fragments/route_maps.yaml | 3 +++ plugins/module_utils/network/nxos/rm_templates/route_maps.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/route_maps.yaml diff --git a/changelogs/fragments/route_maps.yaml b/changelogs/fragments/route_maps.yaml new file mode 100644 index 000000000..8ca6784e4 --- /dev/null +++ b/changelogs/fragments/route_maps.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`route_maps` - resolve route-map description parameter idempotency" diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index 8267a905c..b851d5d5a 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -136,7 +136,7 @@ def __init__(self, lines=None, module=None): "name": "description", "getval": re.compile( r""" - \s+description\s(?P\S+) + \s+description\s(?P.+) $""", re.VERBOSE, ), "setval": "description {{ description }}", From e51ed475505afbf5e24c007dd486b5fd87fe39ea Mon Sep 17 00:00:00 2001 From: tnizharadze <64648821+tnizharadze@users.noreply.github.com> Date: Mon, 27 Mar 2023 08:01:08 +0300 Subject: [PATCH 072/166] Add virtual-rmac advertising support (#645) * Add virtual-rmac advertising support * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add some tests and update changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: OSKS admin user Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/nxos_vxlan_vtep.yaml | 3 +++ docs/cisco.nxos.nxos_vxlan_vtep_module.rst | 19 +++++++++++++++++++ plugins/modules/nxos_vxlan_vtep.py | 18 ++++++++++++++++++ .../network/nxos/test_nxos_vxlan_vtep.py | 16 ++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 changelogs/fragments/nxos_vxlan_vtep.yaml diff --git a/changelogs/fragments/nxos_vxlan_vtep.yaml b/changelogs/fragments/nxos_vxlan_vtep.yaml new file mode 100644 index 000000000..a861537b9 --- /dev/null +++ b/changelogs/fragments/nxos_vxlan_vtep.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under nve interface" diff --git a/docs/cisco.nxos.nxos_vxlan_vtep_module.rst b/docs/cisco.nxos.nxos_vxlan_vtep_module.rst index 61bef90ac..57fdc14a3 100644 --- a/docs/cisco.nxos.nxos_vxlan_vtep_module.rst +++ b/docs/cisco.nxos.nxos_vxlan_vtep_module.rst @@ -33,6 +33,25 @@ Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2542,6 +2869,47 @@ Examples group_range: first: 239.0.0.1 last: 239.255.255.255 + + - route_map: rmap3 + entries: + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - address: 4.4.4.4 + track: 3 + + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true + + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true + + - sequence: 40 + description: "*** fourth stanza ***" + action: permit + set: + ip: + next_hop: + unchanged: true + redist_unchanged: true state: merged # Task output @@ -2571,6 +2939,20 @@ Examples # - "match route-type level-1 level-2" # - "match tag 2" # - "description rmap2-40-deny" + # - "route-map rmap3 permit 10" + # - "description *** first stanza ***" + # - "set ip next-hop verify-availability 3.3.3.3 track 1" + # - "set ip next-hop verify-availability 4.4.4.4 track 3" + # - "route-map rmap3 permit 20" + # - "description *** second stanza ***" + # - "set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail" + # - "route-map rmap3 permit 30" + # - "description *** third stanza ***" + # - "set ip next-hop peer-address" + # - "route-map rmap3 permit 40" + # - "description *** fourth stanza ***" + # - "set ip next-hop unchanged" + # - "set ip next-hop redist-unchanged" # # after: # - route_map: rmap1 @@ -2648,6 +3030,47 @@ Examples # tags: # - 2 # sequence: 40 + # + # - route_map: rmap3 + # entries: + # - sequence: 10 + # description: "*** first stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # verify_availability: + # - address: 3.3.3.3 + # track: 1 + # - address: 4.4.4.4 + # track: 3 + # + # - sequence: 20 + # description: "*** second stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # address: 6.6.6.6 2.2.2.2 + # load_share: true + # drop_on_fail: true + # + # - sequence: 30 + # description: "*** third stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # peer_address: true + # + # - sequence: 40 + # description: "*** fourth stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # unchanged: true + # redist_unchanged: true # After state: # ------------ @@ -2674,7 +3097,21 @@ Examples # match route-type level-1 level-2 # match tag 2 # description rmap2-40-deny - + # route-map rmap3 permit 10 + # description *** first stanza *** + # set ip next-hop verify-availability 3.3.3.3 track 1 + # set ip next-hop verify-availability 4.4.4.4 track 3 + # route-map rmap3 permit 20 + # description *** second stanza *** + # set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail + # route-map rmap3 permit 30 + # description *** third stanza *** + # set ip next-hop peer-address + # route-map rmap3 permit 40 + # description *** fourth stanza *** + # set ip next-hop unchanged + # set ip next-hop redist-unchanged + # # Using replaced # (for the listed route-map(s), sequences that are in running-config but not in the task are negated) @@ -2703,7 +3140,21 @@ Examples # match route-type level-1 level-2 # match tag 2 # description rmap2-40-deny - + # route-map rmap3 permit 10 + # description *** first stanza *** + # set ip next-hop verify-availability 3.3.3.3 track 1 + # set ip next-hop verify-availability 4.4.4.4 track 3 + # route-map rmap3 permit 20 + # description *** second stanza *** + # set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail + # route-map rmap3 permit 30 + # description *** third stanza *** + # set ip next-hop peer-address + # route-map rmap3 permit 40 + # description *** fourth stanza *** + # set ip next-hop unchanged + # set ip next-hop redist-unchanged + # - name: Replace route-maps configurations of listed route-maps with provided configurations cisco.nxos.nxos_route_maps: config: @@ -2724,6 +3175,34 @@ Examples set: community: local_as: True + + - route_map: rmap3 + entries: + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true state: replaced # Task output @@ -2805,6 +3284,47 @@ Examples # - 2 # sequence: 40 # + # - route_map: rmap3 + # entries: + # - sequence: 10 + # description: "*** first stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # verify_availability: + # - address: 3.3.3.3 + # track: 1 + # - address: 4.4.4.4 + # track: 3 + # + # - sequence: 20 + # description: "*** second stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # address: 6.6.6.6 2.2.2.2 + # load_share: true + # drop_on_fail: true + # + # - sequence: 30 + # description: "*** third stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # peer_address: true + # + # - sequence: 40 + # description: "*** fourth stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # unchanged: true + # redist_unchanged: true + # # commands: # - no route-map rmap1 permit 10 # - route-map rmap1 deny 20 @@ -2814,6 +3334,15 @@ Examples # - match ip address prefix-list AllowPrefix1 # - no set dampening 30 1500 10000 120 # - set community local-AS + # - route-map rmap3 permit 10 + # - no set ip next-hop verify-availability 4.4.4.4 track 3 + # - route-map rmap3 permit 20 + # - no set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail + # - set ip next-hop peer-address + # - route-map rmap3 permit 30 + # - no set ip next-hop peer-address + # - set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail + # - no route-map rmap3 permit 40 # # after: # - route_map: rmap1 @@ -2875,6 +3404,33 @@ Examples # - 2 # sequence: 40 # + # - route_map: rmap3 + # entries: + # - sequence: 10 + # description: "*** first stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # verify_availability: + # - address: 3.3.3.3 + # track: 1 + # - sequence: 20 + # description: "*** second stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # peer_address: true + # - sequence: 30 + # description: "*** third stanza ***" + # action: permit + # set: + # ip: + # next_hop: + # address: 6.6.6.6 2.2.2.2 + # load_share: true + # drop_on_fail: true # After state: # ------------ @@ -2896,6 +3452,15 @@ Examples # match route-type level-1 level-2 # match tag 2 # description rmap2-40-deny + # route-map rmap3 permit 10 + # description *** first stanza *** + # set ip next-hop verify-availability 3.3.3.3 track 1 + # route-map rmap3 permit 20 + # description *** second stanza *** + # set ip next-hop peer-address + # route-map rmap3 permit 30 + # description *** third stanza *** + # set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail # Using overridden diff --git a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py index 25e40d6bc..5572b234e 100644 --- a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py @@ -333,6 +333,55 @@ class Route_mapsArgs(object): # pylint: disable=R0903 "options": {"prefix_list": {"type": "str"}}, }, "precedence": {"type": "str"}, + "next_hop": { + "type": "dict", + "mutually_exclusive": [ + [ + "address", + "peer_address", + "redist_unchanged", + "verify_availability", + ], + [ + "address", + "peer_address", + "unchanged", + "verify_availability", + ], + ], + "options": { + "address": {"type": "str"}, + "drop_on_fail": {"type": "bool", "default": False}, + "force_order": {"type": "bool", "default": False}, + "load_share": {"type": "bool", "default": False}, + "peer_address": {"type": "bool"}, + "redist_unchanged": {"type": "bool"}, + "unchanged": {"type": "bool"}, + "verify_availability": { + "type": "list", + "elements": "dict", + "options": { + "address": { + "type": "str", + "required": True, + }, + "track": {"type": "int", "required": True}, + "drop_on_fail": { + "type": "bool", + "default": False, + }, + "force_order": { + "type": "bool", + "default": False, + }, + "load_share": { + "type": "bool", + "default": False, + }, + }, + }, + }, + }, }, }, "ipv6": { diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index b098b0654..14a9037b6 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -70,6 +70,9 @@ def __init__(self, module): "set.path_selection", "set.tag", "set.weight", + "set.ip.next_hop.peer_address", + "set.ip.next_hop.redist_unchanged", + "set.ip.next_hop.unchanged", ] self.complex_parsers = [ "match.as_number.asn", @@ -99,6 +102,8 @@ def __init__(self, module): "set.distance", "set.evpn.gateway_ip", "set.community", + "set.ip.next_hop", + "set.ip.next_hop.verify_availability", ] def execute_module(self): @@ -157,6 +162,12 @@ def _compare_entries(self, want, have): self.compare(parsers=self.linear_parsers, want=wentry, have=hentry) if len(self.commands) != begin: + # all 'no ' commands must be executed first to avoid NXOS command incompatibility errors + pos = begin + for i in range(begin, len(self.commands)): + if self.commands[i][0:3] == "no ": + self.commands.insert(pos, self.commands.pop(i)) + pos += 1 self.commands.insert(begin, self._tmplt.render(wentry, "route_map", False)) # remove superfluos entries from have for _hk, hentry in iteritems(have): @@ -167,6 +178,41 @@ def _compare_lists(self, want, have): wx = get_from_dict(want, x) or [] hx = get_from_dict(have, x) or [] + if x == "set.ip.next_hop.verify_availability": + w_set = {} + for i in range(0, len(wx)): + w_set[wx[i]["address"]] = wx[i] + h_set = {} + for i in range(0, len(hx)): + h_set[hx[i]["address"]] = hx[i] + sum_set = list(set(list(w_set) + list(h_set))) + for each in sum_set: + if each in w_set and each in h_set and w_set[each] == h_set[each]: + for i in range( + 0, + len(want["set"]["ip"]["next_hop"]["verify_availability"]), + ): + if ( + want["set"]["ip"]["next_hop"]["verify_availability"][i]["address"] + == each + ): + want["set"]["ip"]["next_hop"]["verify_availability"].pop(i) + break + for i in range( + 0, + len(have["set"]["ip"]["next_hop"]["verify_availability"]), + ): + if ( + have["set"]["ip"]["next_hop"]["verify_availability"][i]["address"] + == each + ): + have["set"]["ip"]["next_hop"]["verify_availability"].pop(i) + break + w_set.pop(each) + h_set.pop(each) + wx = w_set + hx = h_set + if isinstance(wx, list): wx = set(wx) if isinstance(hx, list): diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index b851d5d5a..cf8f89507 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -85,6 +85,21 @@ def _tmplt_set_metric(data): return cmd +def _tmplt_set_ip_next_hop_verify_availability(data): + cmd = [] + for each in data["set"]["ip"]["next_hop"]["verify_availability"]: + cmd_tmpl = "set ip next-hop verify-availability" + cmd_tmpl += " {address} track {track}".format(**each) + if "load_share" in each and each["load_share"]: + cmd_tmpl += " load-share" + if "force_order" in each and each["force_order"]: + cmd_tmpl += " force-order" + if "drop_on_fail" in each and each["drop_on_fail"]: + cmd_tmpl += " drop-on-fail" + cmd.append(cmd_tmpl) + return cmd + + class Route_mapsTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): super(Route_mapsTemplate, self).__init__(lines=lines, tmplt=self, module=module) @@ -1094,6 +1109,152 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "set.ip.next_hop", + "getval": re.compile( + r""" + \s+set\sip\snext-hop + \s(?P
(\s?((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4})+) + (\s+(?Pload-share))? + (\s+(?Pforce-order))? + (\s+(?Pdrop-on-fail))? + \s*$""", re.VERBOSE, + ), + "setval": "set ip next-hop {{ set.ip.next_hop.address }}" + "{{ ' load-share' if set.ip.next_hop.load_share else '' }}" + "{{ ' force-order' if set.ip.next_hop.force_order else '' }}" + "{{ ' drop-on-fail' if set.ip.next_hop.drop_on_fail else '' }}", + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "ip": { + "next_hop": { + "address": "{{ address }}", + "load_share": "{{ not not load_share|d(False) }}", + "force_order": "{{ not not force_order|d(False) }}", + "drop_on_fail": "{{ not not drop_on_fail|d(False) }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "set.ip.next_hop.peer_address", + "getval": re.compile( + r""" + \s+set\sip\snext-hop + \s(?Ppeer-address) + \s*$""", re.VERBOSE, + ), + "setval": "set ip next-hop peer-address", + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "ip": { + "next_hop": { + "peer_address": "{{ not not peer_address }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "set.ip.next_hop.redist_unchanged", + "getval": re.compile( + r""" + \s+set\sip\snext-hop + \s(?Predist-unchanged) + \s*$""", re.VERBOSE, + ), + "setval": "set ip next-hop redist-unchanged", + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "ip": { + "next_hop": { + "redist_unchanged": "{{ not not redist_unchanged }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "set.ip.next_hop.unchanged", + "getval": re.compile( + r""" + \s+set\sip\snext-hop + \s(?Punchanged) + \s*$""", re.VERBOSE, + ), + "setval": "set ip next-hop unchanged", + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "ip": { + "next_hop": { + "unchanged": "{{ not not unchanged }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "set.ip.next_hop.verify_availability", + "getval": re.compile( + r""" + \s+set\sip\snext-hop\sverify-availability + \s(?P
\S+) + \strack\s(?P\d) + (\s(?Pload-share))? + (\s(?Pforce-order))? + (\s(?Pdrop-on-fail))? + \s*$""", re.VERBOSE, + ), + "setval": _tmplt_set_ip_next_hop_verify_availability, + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "ip": { + "next_hop": { + "verify_availability": [ + { + "address": "{{ address }}", + "track": "{{ track }}", + "load_share": "{{ not not load_share|d(False) }}", + "force_order": "{{ not not force_order|d(False) }}", + "drop_on_fail": "{{ not not drop_on_fail|d(False) }}", + }, + ], + }, + }, + }, + }, + }, + }, + }, + }, { "name": "set.ipv6.address.prefix_list", "getval": re.compile( diff --git a/plugins/modules/nxos_route_maps.py b/plugins/modules/nxos_route_maps.py index 111cc4daf..123566569 100644 --- a/plugins/modules/nxos_route_maps.py +++ b/plugins/modules/nxos_route_maps.py @@ -332,10 +332,77 @@ precedence: description: Set precedence field. type: str + next_hop: + description: Set next-hop IP address (for policy-based routing) + type: dict + suboptions: + address: + description: Set space-separated list of next-hop IP addresses. Address ordering is important. Also don`t use unnecessary spaces. + type: str + drop_on_fail: + description: Drop packets instead of using default routing when the configured next hop becomes unreachable + type: bool + default: false + force_order: + description: Enable next-hop ordering as specified in the address parameter. + type: bool + default: false + load_share: + description: Enable traffic load balancing across a maximum of 32 next-hop addresses + type: bool + default: false + peer_address: + description: + - BGP prefix next hop is set to the local address of the peer. + - If no next hop is set in the route map, the next hop is set to the one stored in the path. + type: bool + redist_unchanged: + description: + - Set for next-hop address conservation for non-local generated routes. + - Used with redistribute command. Available to maintain BGP routing compliant with RFC 4271 on Nexus OS. + type: bool + unchanged: + description: Set for next-hop address conservation in eBGP outgoing updates + type: bool + verify_availability: + description: Set next-hop ip address tracking with IP SLA + type: list + elements: dict + suboptions: + address: + description: Set one next-hop address + type: str + required: true + track: + description: Set track number + type: int + required: true + drop_on_fail: + description: Drop packets instead of using default routing when the configured next hop becomes unreachable + type: bool + default: false + force_order: + description: Enable next-hop ordering as specified in the address parameter. + type: bool + default: false + load_share: + description: Enable traffic load balancing across a maximum of 32 next-hop addresses + type: bool + default: false ipv6: description: Configure IPv6 features. type: dict - suboptions: *id002 + suboptions: + address: + description: Specify IP address. + type: dict + suboptions: + prefix_list: + description: Name of prefix list (Max Size 63). + type: str + precedence: + description: Set precedence field. + type: str label_index: description: Set Segment Routing (SR) label index of route. type: int @@ -486,6 +553,47 @@ group_range: first: 239.0.0.1 last: 239.255.255.255 + + - route_map: rmap3 + entries: + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - address: 4.4.4.4 + track: 3 + + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true + + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true + + - sequence: 40 + description: "*** fourth stanza ***" + action: permit + set: + ip: + next_hop: + unchanged: true + redist_unchanged: true state: merged # Task output @@ -515,6 +623,20 @@ # - "match route-type level-1 level-2" # - "match tag 2" # - "description rmap2-40-deny" +# - "route-map rmap3 permit 10" +# - "description *** first stanza ***" +# - "set ip next-hop verify-availability 3.3.3.3 track 1" +# - "set ip next-hop verify-availability 4.4.4.4 track 3" +# - "route-map rmap3 permit 20" +# - "description *** second stanza ***" +# - "set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail" +# - "route-map rmap3 permit 30" +# - "description *** third stanza ***" +# - "set ip next-hop peer-address" +# - "route-map rmap3 permit 40" +# - "description *** fourth stanza ***" +# - "set ip next-hop unchanged" +# - "set ip next-hop redist-unchanged" # # after: # - route_map: rmap1 @@ -592,6 +714,47 @@ # tags: # - 2 # sequence: 40 +# +# - route_map: rmap3 +# entries: +# - sequence: 10 +# description: "*** first stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# verify_availability: +# - address: 3.3.3.3 +# track: 1 +# - address: 4.4.4.4 +# track: 3 +# +# - sequence: 20 +# description: "*** second stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# address: 6.6.6.6 2.2.2.2 +# load_share: true +# drop_on_fail: true +# +# - sequence: 30 +# description: "*** third stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# peer_address: true +# +# - sequence: 40 +# description: "*** fourth stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# unchanged: true +# redist_unchanged: true # After state: # ------------ @@ -618,7 +781,21 @@ # match route-type level-1 level-2 # match tag 2 # description rmap2-40-deny - +# route-map rmap3 permit 10 +# description *** first stanza *** +# set ip next-hop verify-availability 3.3.3.3 track 1 +# set ip next-hop verify-availability 4.4.4.4 track 3 +# route-map rmap3 permit 20 +# description *** second stanza *** +# set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail +# route-map rmap3 permit 30 +# description *** third stanza *** +# set ip next-hop peer-address +# route-map rmap3 permit 40 +# description *** fourth stanza *** +# set ip next-hop unchanged +# set ip next-hop redist-unchanged +# # Using replaced # (for the listed route-map(s), sequences that are in running-config but not in the task are negated) @@ -647,7 +824,21 @@ # match route-type level-1 level-2 # match tag 2 # description rmap2-40-deny - +# route-map rmap3 permit 10 +# description *** first stanza *** +# set ip next-hop verify-availability 3.3.3.3 track 1 +# set ip next-hop verify-availability 4.4.4.4 track 3 +# route-map rmap3 permit 20 +# description *** second stanza *** +# set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail +# route-map rmap3 permit 30 +# description *** third stanza *** +# set ip next-hop peer-address +# route-map rmap3 permit 40 +# description *** fourth stanza *** +# set ip next-hop unchanged +# set ip next-hop redist-unchanged +# - name: Replace route-maps configurations of listed route-maps with provided configurations cisco.nxos.nxos_route_maps: config: @@ -668,6 +859,34 @@ set: community: local_as: True + + - route_map: rmap3 + entries: + - sequence: 10 + description: "*** first stanza ***" + action: permit + set: + ip: + next_hop: + verify_availability: + - address: 3.3.3.3 + track: 1 + - sequence: 20 + description: "*** second stanza ***" + action: permit + set: + ip: + next_hop: + peer_address: true + - sequence: 30 + description: "*** third stanza ***" + action: permit + set: + ip: + next_hop: + address: 6.6.6.6 2.2.2.2 + load_share: true + drop_on_fail: true state: replaced # Task output @@ -749,6 +968,47 @@ # - 2 # sequence: 40 # +# - route_map: rmap3 +# entries: +# - sequence: 10 +# description: "*** first stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# verify_availability: +# - address: 3.3.3.3 +# track: 1 +# - address: 4.4.4.4 +# track: 3 +# +# - sequence: 20 +# description: "*** second stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# address: 6.6.6.6 2.2.2.2 +# load_share: true +# drop_on_fail: true +# +# - sequence: 30 +# description: "*** third stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# peer_address: true +# +# - sequence: 40 +# description: "*** fourth stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# unchanged: true +# redist_unchanged: true +# # commands: # - no route-map rmap1 permit 10 # - route-map rmap1 deny 20 @@ -758,6 +1018,15 @@ # - match ip address prefix-list AllowPrefix1 # - no set dampening 30 1500 10000 120 # - set community local-AS +# - route-map rmap3 permit 10 +# - no set ip next-hop verify-availability 4.4.4.4 track 3 +# - route-map rmap3 permit 20 +# - no set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail +# - set ip next-hop peer-address +# - route-map rmap3 permit 30 +# - no set ip next-hop peer-address +# - set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail +# - no route-map rmap3 permit 40 # # after: # - route_map: rmap1 @@ -819,6 +1088,33 @@ # - 2 # sequence: 40 # +# - route_map: rmap3 +# entries: +# - sequence: 10 +# description: "*** first stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# verify_availability: +# - address: 3.3.3.3 +# track: 1 +# - sequence: 20 +# description: "*** second stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# peer_address: true +# - sequence: 30 +# description: "*** third stanza ***" +# action: permit +# set: +# ip: +# next_hop: +# address: 6.6.6.6 2.2.2.2 +# load_share: true +# drop_on_fail: true # After state: # ------------ @@ -840,6 +1136,15 @@ # match route-type level-1 level-2 # match tag 2 # description rmap2-40-deny +# route-map rmap3 permit 10 +# description *** first stanza *** +# set ip next-hop verify-availability 3.3.3.3 track 1 +# route-map rmap3 permit 20 +# description *** second stanza *** +# set ip next-hop peer-address +# route-map rmap3 permit 30 +# description *** third stanza *** +# set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail # Using overridden diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index aae0699aa..53069a1e9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -1011,3 +1011,407 @@ def test_nxos_route_maps_gathered_empty(self): result = self.execute_module(changed=False) self.assertEqual(result["gathered"], []) + + def test_nxos_route_maps_next_hop_gathered(self): + # test gathered for empty config + self.get_config.return_value = dedent( + """\ + route-map TEST permit 10 + description *** first stanza *** + set ip next-hop verify-availability 3.3.3.3 track 1 + set ip next-hop verify-availability 5.5.5.5 track 3 + route-map TEST permit 20 + set ip next-hop 2.2.2.2 5.5.5.5 load-share + route-map TEST permit 30 + set ip next-hop peer-address + route-map TEST permit 40 + set ip next-hop unchanged + set ip next-hop redist-unchanged + """, + ) + set_module_args(dict(state="gathered"), ignore_provider_arg) + + gathered = [ + dict( + route_map="TEST", + entries=[ + dict( + action="permit", + sequence=10, + description="*** first stanza ***", + set=dict( + ip=dict( + next_hop=dict( + verify_availability=[ + dict( + address="3.3.3.3", + track=1, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + dict( + address="5.5.5.5", + track=3, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + ], + ), + tag=True, + ), + ), + ), + dict( + action="permit", + sequence=20, + set=dict( + ip=dict( + next_hop=dict( + address="2.2.2.2 5.5.5.5", + drop_on_fail=False, + force_order=False, + load_share=True, + ), + tag=True, + ), + ), + ), + dict( + action="permit", + sequence=30, + set=dict( + ip=dict( + next_hop=dict( + peer_address=True, + ), + tag=True, + ), + ), + ), + dict( + action="permit", + sequence=30, + set=dict( + ip=dict( + next_hop=dict( + unchanged=True, + redist_unchanged=True, + ), + tag=True, + ), + ), + ), + ], + ), + ] + + result = self.execute_module(changed=False) + self.assertEqual(set(result["gathered"][0]), set(gathered[0])) + + def test_nxos_route_maps_next_hop_merged_idempotent(self): + # test merged + self.get_config.return_value = dedent( + """\ + route-map TEST permit 10 + description *** first stanza *** + set ip next-hop verify-availability 3.3.3.3 track 1 + set ip next-hop verify-availability 5.5.5.5 track 3 + route-map TEST permit 20 + set ip next-hop 5.5.5.5 2.2.2.2 load-share drop-on-fail + route-map TEST permit 30 + set ip next-hop peer-address + route-map TEST permit 40 + set ip next-hop unchanged + set ip next-hop redist-unchanged + """, + ) + set_module_args( + dict( + config=[ + dict( + route_map="TEST", + entries=[ + dict( + action="permit", + sequence=10, + description="*** first stanza ***", + set=dict( + ip=dict( + next_hop=dict( + verify_availability=[ + dict( + address="3.3.3.3", + track=1, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + dict( + address="5.5.5.5", + track=3, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + ], + ), + ), + ), + ), + dict( + action="permit", + sequence=20, + set=dict( + ip=dict( + next_hop=dict( + address="5.5.5.5 2.2.2.2", + drop_on_fail=True, + force_order=False, + load_share=True, + ), + ), + ), + ), + dict( + action="permit", + sequence=30, + set=dict( + ip=dict( + next_hop=dict( + peer_address=True, + ), + ), + ), + ), + dict( + action="permit", + sequence=40, + set=dict( + ip=dict( + next_hop=dict( + unchanged=True, + redist_unchanged=True, + ), + ), + ), + ), + ], + ), + ], + state="merged", + ), + ignore_provider_arg, + ) + commands = [] + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], commands) + + def test_nxos_route_maps_next_hop_linear_merged(self): + # test merged for linear attributes + self.get_config.return_value = dedent( + """\ + """, + ) + set_module_args( + dict( + config=[ + dict( + route_map="TEST", + entries=[ + dict( + action="permit", + sequence=10, + description="*** first stanza ***", + set=dict( + ip=dict( + next_hop=dict( + verify_availability=[ + dict( + address="3.3.3.3", + track=1, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + dict( + address="5.5.5.5", + track=3, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + ], + ), + ), + ), + ), + dict( + action="permit", + sequence=20, + set=dict( + ip=dict( + next_hop=dict( + address="5.5.5.5 2.2.2.2", + drop_on_fail=True, + force_order=False, + load_share=True, + ), + ), + ), + ), + dict( + action="permit", + sequence=30, + set=dict( + ip=dict( + next_hop=dict( + peer_address=True, + ), + ), + ), + ), + dict( + action="permit", + sequence=40, + set=dict( + ip=dict( + next_hop=dict( + unchanged=True, + redist_unchanged=True, + ), + ), + ), + ), + ], + ), + ], + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "route-map TEST permit 10", + "description *** first stanza ***", + "set ip next-hop verify-availability 3.3.3.3 track 1", + "set ip next-hop verify-availability 5.5.5.5 track 3", + "route-map TEST permit 20", + "set ip next-hop 5.5.5.5 2.2.2.2 load-share drop-on-fail", + "route-map TEST permit 30", + "set ip next-hop peer-address", + "route-map TEST permit 40", + "set ip next-hop unchanged", + "set ip next-hop redist-unchanged", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_route_maps_next_hop_replaced(self): + # test replaced for linear attributes + self.get_config.return_value = dedent( + """\ + route-map TEST permit 10 + set ip next-hop 5.5.5.5 2.2.2.2 load-share drop-on-fail + route-map TEST permit 20 + description *** second stanza *** + set ip next-hop verify-availability 3.3.3.3 track 1 + set ip next-hop verify-availability 5.5.5.5 track 3 + route-map TEST permit 30 + set ip next-hop peer-address + route-map TEST permit 40 + set ip next-hop unchanged + set ip next-hop redist-unchanged + """, + ) + set_module_args( + dict( + config=[ + dict( + route_map="TEST", + entries=[ + dict( + action="permit", + sequence=10, + description="*** first stanza ***", + set=dict( + ip=dict( + next_hop=dict( + verify_availability=[ + dict( + address="3.3.3.3", + track=1, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + dict( + address="5.5.5.5", + track=3, + drop_on_fail=False, + force_order=False, + load_share=False, + ), + ], + ), + ), + ), + ), + dict( + action="permit", + sequence=20, + set=dict( + ip=dict( + next_hop=dict( + address="5.5.5.5 2.2.2.2", + drop_on_fail=True, + force_order=False, + load_share=True, + ), + ), + ), + ), + dict( + action="permit", + sequence=30, + set=dict( + ip=dict( + next_hop=dict( + peer_address=True, + ), + ), + ), + ), + dict( + action="permit", + sequence=40, + set=dict( + ip=dict( + next_hop=dict( + unchanged=True, + redist_unchanged=True, + ), + ), + ), + ), + ], + ), + ], + state="replaced", + ), + ignore_provider_arg, + ) + commands = [ + "route-map TEST permit 10", + "no set ip next-hop verify-availability 3.3.3.3 track 1", + "no set ip next-hop verify-availability 5.5.5.5 track 3", + "no description *** second stanza ***", + "set ip next-hop 5.5.5.5 2.2.2.2 load-share drop-on-fail", + "route-map TEST permit 20", + "no set ip next-hop 5.5.5.5 2.2.2.2 load-share drop-on-fail", + "set ip next-hop verify-availability 3.3.3.3 track 1", + "set ip next-hop verify-availability 5.5.5.5 track 3", + "description *** first stanza ***", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) From f6d90272d39ad38dd81ffd8518e4dc8e395a3f23 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 3 Apr 2023 13:00:24 +0530 Subject: [PATCH 076/166] [interfaces] correctly enable interface vlans (#652) Signed-off-by: NilashishC Co-authored-by: Sagar Paul --- changelogs/fragments/intf_vlans.yaml | 3 ++ plugins/module_utils/network/nxos/nxos.py | 2 + .../network/nxos/test_nxos_interfaces.py | 39 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 changelogs/fragments/intf_vlans.yaml diff --git a/changelogs/fragments/intf_vlans.yaml b/changelogs/fragments/intf_vlans.yaml new file mode 100644 index 000000000..a8d2a03c3 --- /dev/null +++ b/changelogs/fragments/intf_vlans.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`interfaces` - Correctly enable/disable VLAN interfaces (https://github.com/ansible-collections/cisco.nxos/issues/539)." diff --git a/plugins/module_utils/network/nxos/nxos.py b/plugins/module_utils/network/nxos/nxos.py index f0e3843e4..f34046b39 100644 --- a/plugins/module_utils/network/nxos/nxos.py +++ b/plugins/module_utils/network/nxos/nxos.py @@ -1009,6 +1009,8 @@ def default_intf_enabled(name="", sysdefs=None, mode=None): if re.search("port-channel|loopback", name): default = True + elif re.search("Vlan", name): + default = False else: if mode is None: # intf 'switchport' cli is not present so use the user-system-default diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 055c441a4..7dac77c98 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -733,3 +733,42 @@ def test_7_purged(self): set_module_args(playbook, ignore_provider_arg) result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) + + def test_vlan_enabled(self): + sysdefs = dedent( + """\ + ! + ! Interfaces default to L3 !! + ! + no system default switchport + no system default switchport shutdown + """, + ) + intf = dedent( + """\ + interface Vlan9 + no shutdown + interface Vlan10 + """, + ) + self.get_resource_connection_facts.return_value = {self.SHOW_RUN_INTF: intf} + self.get_system_defaults.return_value = sysdefs + + playbook = dict( + config=[ + dict(name="Vlan9", enabled=False), + dict(name="Vlan10", enabled=True), + dict(name="Vlan11", enabled=True), + ], + ) + merged = [ + "interface Vlan9", + "shutdown", + "interface Vlan10", + "no shutdown", + "interface Vlan11", + "no shutdown", + ] + playbook["state"] = "merged" + set_module_args(playbook, ignore_provider_arg) + self.execute_module(changed=True, commands=merged) From 882879a0320dee63253424232c2f65f5970cc7b1 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 3 Apr 2023 13:12:08 +0530 Subject: [PATCH 077/166] Normalize booleans in examples (#651) * Normalize booleans in examples Signed-off-by: NilashishC added codecov workflow (#647) * added codecov workflow * added codecov in different fie --------- Co-authored-by: Nilashish Chakraborty * Fix changelog Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/bool.yaml | 3 +++ docs/cisco.nxos.nxos_config_module.rst | 2 +- docs/cisco.nxos.nxos_install_os_module.rst | 2 +- docs/cisco.nxos.nxos_lldp_global_module.rst | 4 ++-- docs/cisco.nxos.nxos_lldp_interfaces_module.rst | 4 ++-- docs/cisco.nxos.nxos_nxapi_module.rst | 4 ++-- docs/cisco.nxos.nxos_user_module.rst | 2 +- docs/cisco.nxos.nxos_vrf_module.rst | 2 +- plugins/modules/nxos_config.py | 6 +++--- plugins/modules/nxos_install_os.py | 2 +- plugins/modules/nxos_lldp_global.py | 4 ++-- plugins/modules/nxos_lldp_interfaces.py | 4 ++-- plugins/modules/nxos_nxapi.py | 4 ++-- plugins/modules/nxos_snapshot.py | 2 +- plugins/modules/nxos_user.py | 4 ++-- plugins/modules/nxos_vrf.py | 4 ++-- 16 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 changelogs/fragments/bool.yaml diff --git a/changelogs/fragments/bool.yaml b/changelogs/fragments/bool.yaml new file mode 100644 index 000000000..407781788 --- /dev/null +++ b/changelogs/fragments/bool.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Normalize booleans in examples. diff --git a/docs/cisco.nxos.nxos_config_module.rst b/docs/cisco.nxos.nxos_config_module.rst index 47944508c..3d7b0cad1 100644 --- a/docs/cisco.nxos.nxos_config_module.rst +++ b/docs/cisco.nxos.nxos_config_module.rst @@ -414,7 +414,7 @@ Examples - name: configurable backup path cisco.nxos.nxos_config: - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user diff --git a/docs/cisco.nxos.nxos_install_os_module.rst b/docs/cisco.nxos.nxos_install_os_module.rst index 2fc4f5be5..f10d02f7d 100644 --- a/docs/cisco.nxos.nxos_install_os_module.rst +++ b/docs/cisco.nxos.nxos_install_os_module.rst @@ -115,7 +115,7 @@ Examples .. code-block:: yaml - name: Install OS on N9k - check_mode: no + check_mode: false cisco.nxos.nxos_install_os: system_image_file: nxos.7.0.3.I6.1.bin issu: desired diff --git a/docs/cisco.nxos.nxos_lldp_global_module.rst b/docs/cisco.nxos.nxos_lldp_global_module.rst index f5d90b856..0f012f985 100644 --- a/docs/cisco.nxos.nxos_lldp_global_module.rst +++ b/docs/cisco.nxos.nxos_lldp_global_module.rst @@ -525,8 +525,8 @@ Examples port_id: 1 reinit: 5 tlv_select: - dcbxp: yes - power_management: yes + dcbxp: true + power_management: true state: rendered # Task Output (redacted) diff --git a/docs/cisco.nxos.nxos_lldp_interfaces_module.rst b/docs/cisco.nxos.nxos_lldp_interfaces_module.rst index cc83a3184..7ae7b9f3e 100644 --- a/docs/cisco.nxos.nxos_lldp_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_lldp_interfaces_module.rst @@ -260,7 +260,7 @@ Examples cisco.nxos.nxos_lldp_interfaces: config: - name: Ethernet1/4 - transmit: no + transmit: false tlv_set: vlan: 2 state: replaced @@ -293,7 +293,7 @@ Examples cisco.nxos.nxos_lldp_interfaces: config: - name: Ethernet1/7 - receive: no + receive: false tlv_set: vlan: 12 state: overridden diff --git a/docs/cisco.nxos.nxos_nxapi_module.rst b/docs/cisco.nxos.nxos_nxapi_module.rst index 70d74e998..182fe1516 100644 --- a/docs/cisco.nxos.nxos_nxapi_module.rst +++ b/docs/cisco.nxos.nxos_nxapi_module.rst @@ -248,8 +248,8 @@ Examples cisco.nxos.nxos_nxapi: enable_http: false https_port: 9443 - https: yes - enable_sandbox: no + https: true + enable_sandbox: false - name: remove NXAPI configuration cisco.nxos.nxos_nxapi: diff --git a/docs/cisco.nxos.nxos_user_module.rst b/docs/cisco.nxos.nxos_user_module.rst index 00cfafecc..4fc5e70bc 100644 --- a/docs/cisco.nxos.nxos_user_module.rst +++ b/docs/cisco.nxos.nxos_user_module.rst @@ -304,7 +304,7 @@ Examples - name: remove all users except admin cisco.nxos.nxos_user: - purge: yes + purge: true - name: set multiple users role cisco.nxos.nxos_user: diff --git a/docs/cisco.nxos.nxos_vrf_module.rst b/docs/cisco.nxos.nxos_vrf_module.rst index 3a9613157..dff7e37cd 100644 --- a/docs/cisco.nxos.nxos_vrf_module.rst +++ b/docs/cisco.nxos.nxos_vrf_module.rst @@ -413,7 +413,7 @@ Examples - {name: ntc1, description: purge test1} - {name: ntc2, description: purge test2} state: present - purge: yes + purge: true - name: Delete VRFs exist on switch cisco.nxos.nxos_vrf: diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index 457891249..8cccae68f 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -125,7 +125,7 @@ playbook root directory or role root directory, if playbook is part of an ansible role. If the directory does not exist, it is created. type: bool - default: no + default: false running_config: description: - The module, by default, will connect to the remote device and retrieve the current @@ -146,7 +146,7 @@ the running-config is append with the all keyword. When the value is set to false, the command is issued without the all keyword type: bool - default: no + default: false save_when: description: - When changes are made to the device running-configuration, the changes are not @@ -280,7 +280,7 @@ - name: configurable backup path cisco.nxos.nxos_config: - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user diff --git a/plugins/modules/nxos_install_os.py b/plugins/modules/nxos_install_os.py index 2327ab541..53fe00aac 100644 --- a/plugins/modules/nxos_install_os.py +++ b/plugins/modules/nxos_install_os.py @@ -78,7 +78,7 @@ EXAMPLES = """ - name: Install OS on N9k - check_mode: no + check_mode: false cisco.nxos.nxos_install_os: system_image_file: nxos.7.0.3.I6.1.bin issu: desired diff --git a/plugins/modules/nxos_lldp_global.py b/plugins/modules/nxos_lldp_global.py index 3bd3c5539..d238213bc 100644 --- a/plugins/modules/nxos_lldp_global.py +++ b/plugins/modules/nxos_lldp_global.py @@ -229,8 +229,8 @@ port_id: 1 reinit: 5 tlv_select: - dcbxp: yes - power_management: yes + dcbxp: true + power_management: true state: rendered # Task Output (redacted) diff --git a/plugins/modules/nxos_lldp_interfaces.py b/plugins/modules/nxos_lldp_interfaces.py index cf49a9ac2..2006001de 100644 --- a/plugins/modules/nxos_lldp_interfaces.py +++ b/plugins/modules/nxos_lldp_interfaces.py @@ -144,7 +144,7 @@ cisco.nxos.nxos_lldp_interfaces: config: - name: Ethernet1/4 - transmit: no + transmit: false tlv_set: vlan: 2 state: replaced @@ -177,7 +177,7 @@ cisco.nxos.nxos_lldp_interfaces: config: - name: Ethernet1/7 - receive: no + receive: false tlv_set: vlan: 12 state: overridden diff --git a/plugins/modules/nxos_nxapi.py b/plugins/modules/nxos_nxapi.py index cfd7cc877..400a7a5f5 100644 --- a/plugins/modules/nxos_nxapi.py +++ b/plugins/modules/nxos_nxapi.py @@ -139,8 +139,8 @@ cisco.nxos.nxos_nxapi: enable_http: false https_port: 9443 - https: yes - enable_sandbox: no + https: true + enable_sandbox: false - name: remove NXAPI configuration cisco.nxos.nxos_nxapi: diff --git a/plugins/modules/nxos_snapshot.py b/plugins/modules/nxos_snapshot.py index 9697a1280..7d59810a8 100644 --- a/plugins/modules/nxos_snapshot.py +++ b/plugins/modules/nxos_snapshot.py @@ -92,7 +92,7 @@ description: - Specify to locally store a new created snapshot, to be used when C(action=create). type: bool - default: no + default: false path: description: - Specify the path of the file where new created snapshot or snapshots comparison diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index 83c22a765..3e8ee7a2d 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -132,7 +132,7 @@ absolute. It will remove any previously configured usernames on the device with the exception of the `admin` user which cannot be deleted per nxos constraints. type: bool - default: no + default: false state: description: - The C(state) argument configures the state of the username definition as it @@ -155,7 +155,7 @@ - name: remove all users except admin cisco.nxos.nxos_user: - purge: yes + purge: true - name: set multiple users role cisco.nxos.nxos_user: diff --git a/plugins/modules/nxos_vrf.py b/plugins/modules/nxos_vrf.py index 66fa43aba..6b81ba99a 100644 --- a/plugins/modules/nxos_vrf.py +++ b/plugins/modules/nxos_vrf.py @@ -142,7 +142,7 @@ description: - Purge VRFs not defined in the I(aggregate) parameter. type: bool - default: no + default: false state: description: - Manages desired state of the resource. @@ -182,7 +182,7 @@ - {name: ntc1, description: purge test1} - {name: ntc2, description: purge test2} state: present - purge: yes + purge: true - name: Delete VRFs exist on switch cisco.nxos.nxos_vrf: From b6eb539f807839bb30848823471083653a343258 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 3 Apr 2023 15:35:22 +0530 Subject: [PATCH 078/166] [bgp] fix parsing remote-as for Nexus 3K (#658) Signed-off-by: NilashishC --- changelogs/fragments/bgp.yaml | 3 ++ .../network/nxos/rm_templates/bgp_global.py | 2 ++ .../bgp_neighbor_address_family.py | 1 + .../network/nxos/test_nxos_bgp_global.py | 33 ++++++++++++++++++ .../test_nxos_bgp_neighbor_address_family.py | 34 +++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 changelogs/fragments/bgp.yaml diff --git a/changelogs/fragments/bgp.yaml b/changelogs/fragments/bgp.yaml new file mode 100644 index 000000000..6989b7d6c --- /dev/null +++ b/changelogs/fragments/bgp.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "[bgp] Fix parsing remote-as for Nexus 3K (https://github.com/ansible-collections/cisco.nxos/issues/653)." diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py index fa99397a5..d2ca65aad 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py @@ -634,6 +634,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor\s(?P\S+) + (\sremote-as\s(?P\S+))? $""", re.VERBOSE, ), "setval": "neighbor {{ neighbor_address }}", @@ -643,6 +644,7 @@ def __init__(self, lines=None, module=None): "neighbors": { "{{ neighbor_address }}": { "neighbor_address": "{{ neighbor_address }}", + "remote_as": "{{ remote_as }}", }, }, }, diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py index 327ba4d23..26dad82af 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py @@ -59,6 +59,7 @@ def __init__(self, lines=None): r""" (vrf\s(?P\S+))? \s*neighbor\s(?P\S+) + (\sremote-as\s\S+)? \saddress-family \s(?P\S+) (\s(?P\S+))? diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index 612c7a1f9..c2b2d5db2 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -972,3 +972,36 @@ def test_nxos_bgp_global_purged(self): result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_global_neighbor_3K(self): + run_cfg = dedent( + """\ + router bgp 65535 + neighbor 192.168.20.2 remote-as 56789 + address-family ipv4 unicast + soft-reconfiguration inbound always + """, + ) + self.get_config.return_value = "" + self.cfg_get_config.return_value = "" + + set_module_args( + dict( + running_config=run_cfg, + state="parsed", + ), + ignore_provider_arg, + ) + + parsed = { + "as_number": "65535", + "neighbors": [ + { + "neighbor_address": "192.168.20.2", + "remote_as": "56789", + }, + ], + } + + result = self.execute_module(changed=False) + self.assertEqual(result["parsed"], parsed) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 2b7e1591c..8f12a4279 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -2679,3 +2679,37 @@ def test_nxos_bgp_af_send_community(self): ] result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_bgp_nbr_parsed_3K(self): + # test parsed for neighbor remote-as 3K config + set_module_args( + dict( + running_config=dedent( + """\ + router bgp 65535 + neighbor 192.168.20.2 remote-as 56789 + address-family ipv4 unicast + soft-reconfiguration inbound always + """, + ), + state="parsed", + ), + ignore_provider_arg, + ) + parsed = dict( + as_number="65535", + neighbors=[ + dict( + neighbor_address="192.168.20.2", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + soft_reconfiguration_inbound=dict(always=True), + ), + ], + ), + ], + ) + result = self.execute_module(changed=False) + self.assertEqual(result["parsed"], parsed) From 168e2bbcc226b602651818de760f7a60927ce07e Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 4 Apr 2023 12:30:02 +0530 Subject: [PATCH 079/166] [facts] use |json-pretty and fallback to |json (#650) * [facts] use |json-pretty and fallback to |json Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix changelog Signed-off-by: NilashishC * Fix output check Signed-off-by: NilashishC * Fix condition Signed-off-by: NilashishC * Fix issue Signed-off-by: NilashishC * Add ignore for stable-2.16 Signed-off-by: NilashishC --------- Signed-off-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelogs/fragments/facts_libssh.yaml | 4 ++++ plugins/cliconf/nxos.py | 9 +++++---- .../network/nxos/facts/legacy/base.py | 18 +++++++++++++++++- tests/sanity/ignore-2.16.txt | 3 +++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/facts_libssh.yaml create mode 100644 tests/sanity/ignore-2.16.txt diff --git a/changelogs/fragments/facts_libssh.yaml b/changelogs/fragments/facts_libssh.yaml new file mode 100644 index 000000000..c912d7688 --- /dev/null +++ b/changelogs/fragments/facts_libssh.yaml @@ -0,0 +1,4 @@ +--- +bugfixes: + - "`facts` - Attempt to execute json output commands with | json-pretty first and fall back to | json if unsupported. + This is a temporary workaround until https://github.com/ansible/pylibssh/issues/208 is fixed." diff --git a/plugins/cliconf/nxos.py b/plugins/cliconf/nxos.py index 1b3bd909b..58c6a7121 100644 --- a/plugins/cliconf/nxos.py +++ b/plugins/cliconf/nxos.py @@ -314,7 +314,7 @@ def get_option_values(self): "format": ["text", "json"], "diff_match": ["line", "strict", "exact", "none"], "diff_replace": ["line", "block", "config"], - "output": ["text", "json"], + "output": ["text", "json", "json-pretty"], } def get_capabilities(self): @@ -402,6 +402,7 @@ def set_cli_prompt_context(self): out = self._connection.get_prompt() def _get_command_with_output(self, command, output): + output_re = r".+\|\s*json(?:-pretty)?$" options_values = self.get_option_values() if output not in options_values["output"]: raise ValueError( @@ -409,15 +410,15 @@ def _get_command_with_output(self, command, output): % (output, ",".join(options_values["output"])), ) - if output == "json" and not command.endswith("| json"): + if output in ["json", "json-pretty"] and not re.search(output_re, command): device_info = self.get_device_info() model = device_info.get("network_os_model", "") platform = device_info.get("network_os_platform", "") if platform.startswith("DS-") and "MDS" in model: cmd = "%s | json native" % command else: - cmd = "%s | json" % command - elif output == "text" and command.endswith("| json"): + cmd = "%s | %s" % (command, output) + elif output == "text" and re.search(output_re, command): cmd = command.rsplit("|", 1)[0] else: cmd = command diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index 2244e222b..3cf87f59c 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -38,8 +38,24 @@ def populate(self): def run(self, command, output="text"): command_string = command + if output == "json": + # Not all devices support | json-pretty but is a workaround for + # libssh issue https://github.com/ansible/pylibssh/issues/208 + output = "json-pretty" + + resp = [] command = {"command": command, "output": output} - resp = run_commands(self.module, [command], check_rc="retry_json") + try: + resp = run_commands(self.module, [command], check_rc="retry_json") + except Exception: + if output == "json-pretty": + # reattempt with | json + resp = run_commands( + self.module, + [{"command": command, "output": "json"}], + check_rc="retry_json", + ) + try: return resp[0] except IndexError: diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt new file mode 100644 index 000000000..c2ac0a10b --- /dev/null +++ b/tests/sanity/ignore-2.16.txt @@ -0,0 +1,3 @@ +plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` +plugins/cliconf/nxos.py pylint:arguments-renamed +tests/unit/mock/loader.py pylint:arguments-renamed From 735b6a98763214485a152344eec6c4f8adef799b Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 4 Apr 2023 17:44:33 +0530 Subject: [PATCH 080/166] Prepare for v4.2.0 release (#660) Signed-off-by: NilashishC --- CHANGELOG.rst | 20 +++++++++++++- changelogs/changelog.yaml | 27 +++++++++++++++++++ changelogs/fragments/bgp.yaml | 3 --- changelogs/fragments/bool.yaml | 3 --- changelogs/fragments/ci_codecov.yml | 3 --- changelogs/fragments/codecov_from_repo.yml | 3 --- changelogs/fragments/facts_libssh.yaml | 4 --- changelogs/fragments/intf_vlans.yaml | 3 --- changelogs/fragments/nxos_route_maps.yaml | 3 --- changelogs/fragments/nxos_vxlan_vtep.yaml | 3 --- changelogs/fragments/route_maps.yaml | 3 --- .../fragments/snmp_server_issues_fix.yaml | 3 --- 12 files changed, 46 insertions(+), 32 deletions(-) delete mode 100644 changelogs/fragments/bgp.yaml delete mode 100644 changelogs/fragments/bool.yaml delete mode 100644 changelogs/fragments/ci_codecov.yml delete mode 100644 changelogs/fragments/codecov_from_repo.yml delete mode 100644 changelogs/fragments/facts_libssh.yaml delete mode 100644 changelogs/fragments/intf_vlans.yaml delete mode 100644 changelogs/fragments/nxos_route_maps.yaml delete mode 100644 changelogs/fragments/nxos_vxlan_vtep.yaml delete mode 100644 changelogs/fragments/route_maps.yaml delete mode 100644 changelogs/fragments/snmp_server_issues_fix.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 731ebd599..615b52831 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,24 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v4.2.0 +====== + +Minor Changes +------------- + +- `nxos_route_maps` - add support for 'set ip next-hop <>' command in route-maps +- `nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under nve interface + +Bugfixes +-------- + +- `bgp` - Fix parsing remote-as for Nexus 3K (https://github.com/ansible-collections/cisco.nxos/issues/653). +- `facts` - Attempt to execute json output commands with | json-pretty first and fall back to | json if unsupported. This is a temporary workaround until https://github.com/ansible/pylibssh/issues/208 is fixed. +- `interfaces` - Correctly enable/disable VLAN interfaces (https://github.com/ansible-collections/cisco.nxos/issues/539). +- `route_maps` - resolve route-map description parameter idempotency +- `snmp_server` - fix community option to produce proper configuration with ipv4acl and ipv6acl. + v4.1.0 ====== @@ -404,8 +422,8 @@ v2.0.0 Major Changes ------------- -- Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. - Please refer to ansible.netcommon `changelog `_ for more details. +- Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. Minor Changes ------------- diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 713c844fc..7b297f1f0 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -947,3 +947,30 @@ releases: - snmp.yaml - unused_imports.yaml release_date: "2023-02-16" + 4.2.0: + changes: + bugfixes: + - "`bgp` - Fix parsing remote-as for Nexus 3K (https://github.com/ansible-collections/cisco.nxos/issues/653)." + - "`facts` - Attempt to execute json output commands with | json-pretty first + and fall back to | json if unsupported. This is a temporary workaround until + https://github.com/ansible/pylibssh/issues/208 is fixed." + - "`interfaces` - Correctly enable/disable VLAN interfaces (https://github.com/ansible-collections/cisco.nxos/issues/539)." + - "`route_maps` - resolve route-map description parameter idempotency" + - "`snmp_server` - fix community option to produce proper configuration with + ipv4acl and ipv6acl." + minor_changes: + - "`nxos_route_maps` - add support for 'set ip next-hop <>' command in route-maps" + - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under + nve interface" + fragments: + - bgp.yaml + - bool.yaml + - ci_codecov.yml + - codecov_from_repo.yml + - facts_libssh.yaml + - intf_vlans.yaml + - nxos_route_maps.yaml + - nxos_vxlan_vtep.yaml + - route_maps.yaml + - snmp_server_issues_fix.yaml + release_date: "2023-04-04" diff --git a/changelogs/fragments/bgp.yaml b/changelogs/fragments/bgp.yaml deleted file mode 100644 index 6989b7d6c..000000000 --- a/changelogs/fragments/bgp.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "[bgp] Fix parsing remote-as for Nexus 3K (https://github.com/ansible-collections/cisco.nxos/issues/653)." diff --git a/changelogs/fragments/bool.yaml b/changelogs/fragments/bool.yaml deleted file mode 100644 index 407781788..000000000 --- a/changelogs/fragments/bool.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Normalize booleans in examples. diff --git a/changelogs/fragments/ci_codecov.yml b/changelogs/fragments/ci_codecov.yml deleted file mode 100644 index ea17f51a8..000000000 --- a/changelogs/fragments/ci_codecov.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - added codecov to the CI pipeline diff --git a/changelogs/fragments/codecov_from_repo.yml b/changelogs/fragments/codecov_from_repo.yml deleted file mode 100644 index e91794a41..000000000 --- a/changelogs/fragments/codecov_from_repo.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Added codecov to run from the ansible-network/github_actions repo and changed workflow file name for concsistency. diff --git a/changelogs/fragments/facts_libssh.yaml b/changelogs/fragments/facts_libssh.yaml deleted file mode 100644 index c912d7688..000000000 --- a/changelogs/fragments/facts_libssh.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -bugfixes: - - "`facts` - Attempt to execute json output commands with | json-pretty first and fall back to | json if unsupported. - This is a temporary workaround until https://github.com/ansible/pylibssh/issues/208 is fixed." diff --git a/changelogs/fragments/intf_vlans.yaml b/changelogs/fragments/intf_vlans.yaml deleted file mode 100644 index a8d2a03c3..000000000 --- a/changelogs/fragments/intf_vlans.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`interfaces` - Correctly enable/disable VLAN interfaces (https://github.com/ansible-collections/cisco.nxos/issues/539)." diff --git a/changelogs/fragments/nxos_route_maps.yaml b/changelogs/fragments/nxos_route_maps.yaml deleted file mode 100644 index 21769fdf7..000000000 --- a/changelogs/fragments/nxos_route_maps.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_route_maps` - add support for 'set ip next-hop <>' command in route-maps" diff --git a/changelogs/fragments/nxos_vxlan_vtep.yaml b/changelogs/fragments/nxos_vxlan_vtep.yaml deleted file mode 100644 index a861537b9..000000000 --- a/changelogs/fragments/nxos_vxlan_vtep.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under nve interface" diff --git a/changelogs/fragments/route_maps.yaml b/changelogs/fragments/route_maps.yaml deleted file mode 100644 index 8ca6784e4..000000000 --- a/changelogs/fragments/route_maps.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`route_maps` - resolve route-map description parameter idempotency" diff --git a/changelogs/fragments/snmp_server_issues_fix.yaml b/changelogs/fragments/snmp_server_issues_fix.yaml deleted file mode 100644 index fbedba72e..000000000 --- a/changelogs/fragments/snmp_server_issues_fix.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "`snmp_server` - fix community option to produce proper configuration with ipv4acl and ipv6acl." From a04f9ae83fdcd07fdfb210ef68ded8bd11046ca9 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 5 Apr 2023 21:16:50 +0530 Subject: [PATCH 081/166] Prepare for v4.3.0 release (#663) Signed-off-by: NilashishC --- CHANGELOG.rst | 8 ++++++++ changelogs/changelog.yaml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 615b52831..4f24e52a4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,14 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v4.3.0 +====== + +Release Summary +--------------- + +Re-releasing v4.2.0 of this collection since the previously build failed to upload in Automation Hub. + v4.2.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 7b297f1f0..9a150d2db 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -974,3 +974,11 @@ releases: - route_maps.yaml - snmp_server_issues_fix.yaml release_date: "2023-04-04" + 4.3.0: + changes: + release_summary: + Re-releasing v4.2.0 of this collection since the previously + build failed to upload in Automation Hub. + fragments: + - release_430.yaml + release_date: "2023-04-05" From e402f0e3bff72893fd274506d652c6c3e22be77d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Apr 2023 13:26:39 +0530 Subject: [PATCH 082/166] [pre-commit.ci] pre-commit autoupdate (#659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0) - [github.com/ansible-network/collection_prep: 1.1.0 → 1.1.1](https://github.com/ansible-network/collection_prep/compare/1.1.0...1.1.1) * Update .pre-commit-config.yaml Co-authored-by: Kate Case * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty Co-authored-by: Kate Case --- .pre-commit-config.yaml | 5 +++-- galaxy.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96d072083..18887e1c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,11 +48,12 @@ repos: name: Sort import statements using isort - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/ansible-network/collection_prep - rev: 1.1.0 + rev: 1.1.1 hooks: - id: update-docs + - id: autoversion diff --git a/galaxy.yml b/galaxy.yml index 52b124b72..dadfdc820 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 0.0.0 +version: 4.3.0 From 89ec19f5a2edfcfc6d8945b55e7599ebe6811748 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:29:30 +0530 Subject: [PATCH 083/166] [pre-commit.ci] pre-commit autoupdate (#668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.6 → v3.0.0-alpha.9-for-vscode](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.6...v3.0.0-alpha.9-for-vscode) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 18887e1c6..08b2db27b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.6" + rev: "v3.0.0-alpha.9-for-vscode" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described From ec33ae9e84b5ef8fa9fb220d7c5ad7f219957766 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 26 Apr 2023 18:37:22 +0530 Subject: [PATCH 084/166] Run GHA periodically (#667) * Run GHA periodically Signed-off-by: NilashishC * Fix condition Signed-off-by: NilashishC * Update Signed-off-by: NilashishC * Fallback to run_id when event is schedule Signed-off-by: NilashishC * updates Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- .github/workflows/tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e77967b34..aae5ce9a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,19 +2,23 @@ name: Test collection concurrency: - group: ${{ github.head_ref }} + group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true on: # yamllint disable-line rule:truthy pull_request: branches: [main] workflow_dispatch: + schedule: + - cron: '0 0 * * *' + jobs: ansible-lint: uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main changelog: uses: ansible-network/github_actions/.github/workflows/changelog.yml@main + if: github.event_name != 'schedule' sanity: uses: ansible-network/github_actions/.github/workflows/sanity.yml@main unit-galaxy: @@ -26,7 +30,7 @@ jobs: git+https://github.com/ansible-collections/ansible.utils.git git+https://github.com/ansible-collections/ansible.netcommon.git all_green: - if: ${{ always() }} + if: ${{ always() && (github.event_name != 'schedule') }} needs: - ansible-lint - changelog From 0d2da23184de23ffe6a409033a730e372132a601 Mon Sep 17 00:00:00 2001 From: Rasul Gasanov Date: Wed, 10 May 2023 10:34:54 +0300 Subject: [PATCH 085/166] nxos_ntp_global: fix "prefer" parameter incorrect handling (#671) * nxos_ntp_global: fix prefer incorrect handling * Add changelog Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: NilashishC Co-authored-by: Rasul Gasanov@app-noc01 Co-authored-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelogs/fragments/ntp_global.yaml | 3 +++ galaxy.yml | 2 +- plugins/module_utils/network/nxos/rm_templates/ntp_global.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/ntp_global.yaml diff --git a/changelogs/fragments/ntp_global.yaml b/changelogs/fragments/ntp_global.yaml new file mode 100644 index 000000000..ee69128f5 --- /dev/null +++ b/changelogs/fragments/ntp_global.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670)." diff --git a/galaxy.yml b/galaxy.yml index dadfdc820..1b1dbb24c 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 4.3.0 +version: 4.3.1-dev diff --git a/plugins/module_utils/network/nxos/rm_templates/ntp_global.py b/plugins/module_utils/network/nxos/rm_templates/ntp_global.py index 8d5a354df..9fd6e4d6e 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ntp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/ntp_global.py @@ -226,7 +226,7 @@ def __init__(self, lines=None, module=None): $""", re.VERBOSE, ), "setval": "ntp peer {{ peer }}" - "{{ ' prefer' if prefer is defined else ''}}" + "{{ ' prefer' if prefer|d(False) else ''}}" "{{ (' use-vrf ' + vrf) if vrf is defined else '' }}" "{{ (' key ' + key_id|string) if key_id is defined else '' }}" "{{ (' minpoll ' + minpoll|string) if minpoll is defined else '' }}" @@ -258,7 +258,7 @@ def __init__(self, lines=None, module=None): $""", re.VERBOSE, ), "setval": "ntp server {{ server }}" - "{{ ' prefer' if prefer is defined else ''}}" + "{{ ' prefer' if prefer|d(False) else ''}}" "{{ (' use-vrf ' + vrf) if vrf is defined else '' }}" "{{ (' key ' + key_id|string) if key_id is defined else '' }}" "{{ (' minpoll ' + minpoll|string) if minpoll is defined else '' }}" From 82bb833ed89a498d6828b1b6e8194e6a99043753 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 18 May 2023 15:15:10 +0530 Subject: [PATCH 086/166] Fix lint failures (#679) * Fix lint failures Signed-off-by: NilashishC * Remove ignore Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/lint.yaml | 3 +++ plugins/cliconf/nxos.py | 4 ++-- tests/sanity/ignore-2.12.txt | 2 -- tests/sanity/ignore-2.13.txt | 2 -- tests/sanity/ignore-2.14.txt | 2 -- tests/sanity/ignore-2.15.txt | 2 -- tests/sanity/ignore-2.16.txt | 2 -- tests/unit/mock/loader.py | 10 +++++----- 8 files changed, 10 insertions(+), 17 deletions(-) create mode 100644 changelogs/fragments/lint.yaml diff --git a/changelogs/fragments/lint.yaml b/changelogs/fragments/lint.yaml new file mode 100644 index 000000000..f356148d1 --- /dev/null +++ b/changelogs/fragments/lint.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix ansible-lint issues. diff --git a/plugins/cliconf/nxos.py b/plugins/cliconf/nxos.py index 58c6a7121..4f6393858 100644 --- a/plugins/cliconf/nxos.py +++ b/plugins/cliconf/nxos.py @@ -182,7 +182,7 @@ def get_diff( diff["config_diff"] = dumps(configdiffobjs, "commands") if configdiffobjs else "" return diff - def get_config(self, source="running", format="text", flags=None): + def get_config(self, source="running", flags=None, format="text"): options_values = self.get_option_values() if format not in options_values["format"]: raise ValueError( @@ -243,8 +243,8 @@ def get( prompt=None, answer=None, sendonly=False, - output=None, newline=True, + output=None, check_all=False, ): if output: diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 33c91076f..d7b9bbd97 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -34,5 +34,3 @@ plugins/module_utils/network/nxos/config/ntp_global/ntp_global.py import-2.6!ski plugins/module_utils/network/nxos/config/ntp_global/ntp_global.py compile-2.6!skip plugins/module_utils/network/nxos/utils/utils.py import-2.6!skip plugins/module_utils/network/nxos/utils/utils.py compile-2.6!skip -plugins/cliconf/nxos.py pylint:arguments-renamed -tests/unit/mock/loader.py pylint:arguments-renamed diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index c2ac0a10b..46cfbc643 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -1,3 +1 @@ plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` -plugins/cliconf/nxos.py pylint:arguments-renamed -tests/unit/mock/loader.py pylint:arguments-renamed diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index c2ac0a10b..46cfbc643 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -1,3 +1 @@ plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` -plugins/cliconf/nxos.py pylint:arguments-renamed -tests/unit/mock/loader.py pylint:arguments-renamed diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index c2ac0a10b..46cfbc643 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -1,3 +1 @@ plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` -plugins/cliconf/nxos.py pylint:arguments-renamed -tests/unit/mock/loader.py pylint:arguments-renamed diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index c2ac0a10b..46cfbc643 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -1,3 +1 @@ plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` -plugins/cliconf/nxos.py pylint:arguments-renamed -tests/unit/mock/loader.py pylint:arguments-renamed diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index 2b5eb36a1..ebff16f63 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -47,12 +47,12 @@ def load_from_file(self, path, cache=True, unsafe=False): # TODO: the real _get_file_contents returns a bytestring, so we actually convert the # unicode/text it's created with to utf-8 - def _get_file_contents(self, path): - path = to_text(path) - if path in self._file_mapping: - return (to_bytes(self._file_mapping[path]), False) + def _get_file_contents(self, file_name): + file_name = to_text(file_name) + if file_name in self._file_mapping: + return (to_bytes(self._file_mapping[file_name]), False) else: - raise AnsibleParserError("file not found: %s" % path) + raise AnsibleParserError("file not found: %s" % file_name) def path_exists(self, path): path = to_text(path) From 07ee7352e59b3d59934005f0b7c8233ef249eb99 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 18 May 2023 18:37:49 +0530 Subject: [PATCH 087/166] [snmp_server] downstream test fix (#681) * [snmp_server] downstream test fix Signed-off-by: NilashishC * Always push the command Signed-off-by: NilashishC * Lint fix Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/tests.yaml | 3 +++ tests/integration/targets/nxos_snmp_server/tasks/main.yaml | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 changelogs/fragments/tests.yaml diff --git a/changelogs/fragments/tests.yaml b/changelogs/fragments/tests.yaml new file mode 100644 index 000000000..ef37de24b --- /dev/null +++ b/changelogs/fragments/tests.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix downstream snmp-server test. diff --git a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index cb885dee9..bf5addfbf 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -47,3 +47,9 @@ ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi + +- name: "Add back snmp-server user zuul" + cisco.nxos.nxos_config: + lines: + - "snmp-server user zuul network-admin auth md5 {{ zuul_snmp_passwd }} priv {{ zuul_snmp_passwd }} localizedkey" + match: none From 61c78f87929ce84b59964335e8504dfee5cfff87 Mon Sep 17 00:00:00 2001 From: Ashley Tayles Date: Thu, 18 May 2023 14:09:20 +0100 Subject: [PATCH 088/166] [nxos_user] add hashed_password option (#677) * add hashed_password * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nxos_user hashed password * change check to "is not None" instead of merely checking for existence * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add unit test for hashed pw * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/ntp_user.yaml | 3 ++ docs/cisco.nxos.nxos_user_module.rst | 31 +++++++++++++++++++ galaxy.yml | 2 +- plugins/modules/nxos_user.py | 24 +++++++++++++- .../modules/network/nxos/test_nxos_user.py | 15 +++++++++ 5 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ntp_user.yaml diff --git a/changelogs/fragments/ntp_user.yaml b/changelogs/fragments/ntp_user.yaml new file mode 100644 index 000000000..f3a5e5e1d --- /dev/null +++ b/changelogs/fragments/ntp_user.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "nxos_user - Add support for hashed passwords. (https://github.com/ansible-collections/cisco.nxos/issues/370)." diff --git a/docs/cisco.nxos.nxos_user_module.rst b/docs/cisco.nxos.nxos_user_module.rst index 4fc5e70bc..bcd44852b 100644 --- a/docs/cisco.nxos.nxos_user_module.rst +++ b/docs/cisco.nxos.nxos_user_module.rst @@ -66,6 +66,22 @@ Parameters
The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device.
+ + + + + + + + + + + + + + + + @@ -354,7 +354,19 @@ Examples # Before state: # ------------- # + # router# show running-config | section interface # interface Ethernet1/6 + # description Configured by Ansible Network + # no switchport + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management - name: Merge provided configuration with device configuration. cisco.nxos.nxos_l3_interfaces: @@ -370,23 +382,65 @@ Examples - address: fd5d:12c9:2201:2::1/64 tag: 6 - name: Ethernet1/7.42 - dot1q: 42 redirects: false unreachables: false state: merged + # Task Output + # ----------- + # + # before: + # - name: Ethernet1/6 + # - name: Ethernet1/7 + # - ipv4: + # - address: dhcp + # name: mgmt0 + # commands: + # - interface Ethernet1/6 + # - ip address 192.168.1.1/24 tag 5 + # - ip address 10.1.1.1/24 secondary tag 10 + # - ipv6 address fd5d:12c9:2201:2::1/64 tag 6 + # - interface Ethernet1/7 + # - no ip redirects + # after: + # - ipv4: + # - address: 192.168.1.1/24 + # tag: 5 + # - address: 10.1.1.1/24 + # secondary: true + # tag: 10 + # ipv6: + # - address: fd5d:12c9:2201:2::1/64 + # tag: 6 + # name: Ethernet1/6 + # redirects: false + # - name: Ethernet1/7 + # redirects: false + # - ipv4: + # - address: dhcp + # name: mgmt0 + # After state: # ------------ # + # router# show running-config | section interface # interface Ethernet1/6 - # ip address 192.168.22.1/24 tag 5 + # description Configured by Ansible Network + # no switchport + # no ip redirects + # ip address 192.168.1.1/24 tag 5 # ip address 10.1.1.1/24 secondary tag 10 - # interface Ethernet1/6 # ipv6 address fd5d:12c9:2201:2::1/64 tag 6 - # interface Ethernet1/7.42 - # encapsulation dot1q 42 + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport # no ip redirects - # no ip unreachables + # no shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management # Using replaced @@ -394,9 +448,24 @@ Examples # Before state: # ------------- # + # router# show running-config | section interface # interface Ethernet1/6 - # ip address 192.168.22.1/24 - # ipv6 address "fd5d:12c9:2201:1::1/64" + # description Configured by Ansible Network + # no switchport + # no ip redirects + # ip address 192.168.1.1/24 tag 5 + # ip address 10.1.1.1/24 secondary tag 10 + # ipv6 address fd5d:12c9:2201:2::1/64 tag 6 + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no ip redirects + # no shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management - name: Replace device configuration of specified L3 interfaces with provided configuration. cisco.nxos.nxos_l3_interfaces: @@ -406,48 +475,184 @@ Examples - address: 192.168.22.3/24 state: replaced + # Task Output + # ----------- + # + # before: + # - ipv4: + # - address: 192.168.1.1/24 + # tag: 5 + # - address: 10.1.1.1/24 + # secondary: true + # tag: 10 + # ipv6: + # - address: fd5d:12c9:2201:2::1/64 + # tag: 6 + # name: Ethernet1/6 + # redirects: false + # - name: Ethernet1/7 + # redirects: false + # - ipv4: + # - address: dhcp + # name: mgmt0 + # commands: + # - interface Ethernet1/6 + # - ip address 192.168.22.3/24 + # - no ipv6 address fd5d:12c9:2201:2::1/64 + # - ip redirects + # after: + # - ipv4: + # - address: 192.168.22.3/24 + # - address: 10.1.1.1/24 + # secondary: true + # tag: 10 + # name: Ethernet1/6 + # redirects: false + # - name: Ethernet1/7 + # redirects: false + # - ipv4: + # - address: dhcp + # name: mgmt0 + # After state: # ------------ # + # router# show running-config | section interface # interface Ethernet1/6 + # description Configured by Ansible Network + # no switchport + # no ip redirects # ip address 192.168.22.3/24 - + # ip address 10.1.1.1/24 secondary tag 10 + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no ip redirects + # no shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management # Using overridden # Before state: # ------------- # - # interface Ethernet1/2 - # ip address 192.168.22.1/24 + # router# show running-config | section interface # interface Ethernet1/6 - # ipv6 address "fd5d:12c9:2201:1::1/64" + # description Configured by Ansible Network + # no switchport + # no ip redirects + # ip address 192.168.1.1/24 tag 5 + # ip address 10.1.1.1/24 secondary tag 10 + # ipv6 address fd5d:12c9:2201:2::1/64 tag 6 + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no ip redirects + # no shutdown + # interface Ethernet1/7.42 + # no ip redirects + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management - - name: Override device configuration of all L3 interfaces on device with provided - configuration. + - name: Override device configuration with provided configuration. cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/2 - ipv4: 192.168.22.3/4 + - ipv4: + - address: dhcp + name: mgmt0 + - name: Ethernet1/6 + ipv4: + - address: 192.168.22.3/24 state: overridden + # Task Output + # ----------- + # + # before: + # - ipv4: + # - address: 192.168.1.1/24 + # tag: 5 + # - address: 10.1.1.1/24 + # secondary: true + # tag: 10 + # ipv6: + # - address: fd5d:12c9:2201:2::1/64 + # tag: 6 + # name: Ethernet1/6 + # redirects: false + # - name: Ethernet1/7 + # redirects: false + # - name: Ethernet1/7.42 + # redirects: false + # - ipv4: + # - address: dhcp + # name: mgmt0 + # commands: + # - interface Ethernet1/6 + # - no ipv6 address fd5d:12c9:2201:2::1/64 + # - no ip address 10.1.1.1/24 secondary + # - ip address 192.168.22.3/24 + # - ip redirects + # - interface Ethernet1/7 + # - ip redirects + # - interface Ethernet1/7.42 + # - ip redirects + # after: + # - ipv4: + # - address: 192.168.22.3/24 + # name: Ethernet1/6 + # - name: Ethernet1/7 + # - name: Ethernet1/7.42 + # - ipv4: + # - address: dhcp + # name: mgmt0 + # After state: # ------------ # - # interface Ethernet1/2 - # ipv4 address 192.168.22.3/24 + # router# show running-config | section interface # interface Ethernet1/6 - + # description Configured by Ansible Network + # no switchport + # ip address 192.168.22.3/24 + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no shutdown + # interface Ethernet1/7.42 + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management # Using deleted # Before state: # ------------- # + # router# show running-config | section interface # interface Ethernet1/6 - # ip address 192.168.22.1/24 - # interface Ethernet1/2 - # ipv6 address "fd5d:12c9:2201:1::1/64" + # description Configured by Ansible Network + # no switchport + # ip address 192.168.22.3/24 + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no shutdown + # interface Ethernet1/7.42 + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management - name: Delete L3 attributes of given interfaces (This won't delete the interface itself). @@ -457,11 +662,47 @@ Examples - name: Ethernet1/2 state: deleted + # Task Output + # ----------- + # + # before: + # - name: Ethernet1/2 + # - ipv4: + # - address: 192.168.22.3/24 + # name: Ethernet1/6 + # - name: Ethernet1/7 + # - name: Ethernet1/7.42 + # - ipv4: + # - address: dhcp + # name: mgmt0 + # commands: + # - interface Ethernet1/6 + # - no ip address + # after: + # - name: Ethernet1/2 + # - name: Ethernet1/7 + # - name: Ethernet1/7.42 + # - ipv4: + # - address: dhcp + # name: mgmt0 + # After state: # ------------ # + # router# show running-config | section interface # interface Ethernet1/6 - # interface Ethernet1/2 + # description Configured by Ansible Network + # no switchport + # no shutdown + # interface Ethernet1/7 + # description Configured by Ansible + # no switchport + # no shutdown + # interface Ethernet1/7.42 + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management # Using rendered @@ -481,20 +722,21 @@ Examples tag: 6 state: rendered - # Task Output (redacted) - # ----------------------- - + # Task Output + # ----------- + # # rendered: - # - "interface Ethernet1/800" - # - "ip address 192.168.1.100/24 tag 5" - # - "ip address 10.1.1.1/24 secondary tag 10" - # - "interface Ethernet1/800" - # - "ipv6 address fd5d:12c9:2201:2::1/64 tag 6" + # - interface Ethernet1/800 + # - ip address 192.168.1.100/24 tag 5 + # - ip address 10.1.1.1/24 secondary tag 10 + # - interface Ethernet1/800 + # - ipv6 address fd5d:12c9:2201:2::1/64 tag 6 # Using parsed # parsed.cfg - # ------------ + # ---------- + # # interface Ethernet1/800 # ip address 192.168.1.100/24 tag 5 # ip address 10.1.1.1/24 secondary tag 10 @@ -511,9 +753,9 @@ Examples running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- - + # Task output + # ----------- + # # parsed: # - name: Ethernet1/800 # ipv4: @@ -531,8 +773,9 @@ Examples # Using gathered - # Existing device config state - # ------------------------------- + # Before state: + # ------------- + # # interface Ethernet1/1 # ip address 192.0.2.100/24 # interface Ethernet1/2 @@ -545,9 +788,9 @@ Examples cisco.nxos.nxos_l3_interfaces: state: gathered - # Task output (redacted) - # ----------------------- - + # Task output + # ----------- + # # gathered: # - name: Ethernet1/1 # ipv4: diff --git a/plugins/modules/nxos_interfaces.py b/plugins/modules/nxos_interfaces.py index f03f746bd..7884098a7 100644 --- a/plugins/modules/nxos_interfaces.py +++ b/plugins/modules/nxos_interfaces.py @@ -67,8 +67,8 @@ type: str enabled: description: - - Administrative state of the interface. Set the value to C(true) to administratively - enable the interface or C(false) to disable it + - Administrative state of the interface. Set the value to C(true) to + administratively enable the interface or C(false) to disable it type: bool speed: description: @@ -131,9 +131,13 @@ # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 # description testing -# mtu 1800 +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management - name: Merge provided configuration with device configuration cisco.nxos.nxos_interfaces: @@ -146,26 +150,58 @@ enabled: false state: merged +# Task Output +# ----------- +# +# before: +# - description: testing +# name: Ethernet1/1 +# - description: mgmt interface +# name: mgmt0 +# commands: +# - interface Ethernet1/1 +# - description Configured by Ansible +# - interface Ethernet1/2 +# - description Configured by Ansible Network +# - shutdown +# after: +# - description: Configured by Ansible +# name: Ethernet1/1 +# - description: Configured by Ansible Network +# enabled: false +# name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 -# description Configured by Ansible -# no shutdown -# mtu 1800 -# interface Ethernet2 -# description Configured by Ansible Network -# shutdown - +# description Configured by Ansible +# interface Ethernet1/2 +# description Configured by Ansible Network +# shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management # Using replaced # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# description Interface 1/1 +# description Updated by Ansible # interface Ethernet1/2 +# description Configured by Ansible Network +# shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_interfaces: @@ -173,37 +209,67 @@ - name: Ethernet1/1 description: Configured by Ansible enabled: true - mtu: 2000 + mtu: 9000 - name: Ethernet1/2 description: Configured by Ansible Network enabled: false mode: layer2 state: replaced +# Task Output +# ----------- +# +# before: +# - description: Updated by Ansible +# name: Ethernet1/1 +# - description: Configured by Ansible Network +# enabled: false +# name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 +# commands: +# - interface Ethernet1/1 +# - mtu 1500 +# - interface Ethernet1/2 +# - description Updated by Ansible +# after: +# - description: Updated by Ansible +# name: Ethernet1/1 +# - description: Updated by Ansible +# enabled: false +# name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 -# description Configured by Ansible -# no shutdown -# mtu 1500 -# interface Ethernet2/2 -# description Configured by Ansible Network -# shutdown -# switchport - +# description Updated by Ansible +# interface Ethernet1/2 +# description Updated by Ansible +# shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management # Using overridden # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# description Interface Ethernet1/1 +# description Updated by Ansible # interface Ethernet1/2 +# description Updated by Ansible +# shutdown # interface mgmt0 -# description Management interface -# ip address dhcp +# description mgmt interface +# ip address dhcp +# vrf member management - name: Override device configuration of all interfaces with provided configuration cisco.nxos.nxos_interfaces: @@ -213,45 +279,98 @@ - name: Ethernet1/2 description: Configured by Ansible Network enabled: false + - description: mgmt interface + name: mgmt0 state: overridden +# Task Output +# ----------- +# +# before: +# - description: Updated by Ansible +# name: Ethernet1/1 +# - description: Updated by Ansible +# enabled: false +# name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 +# commands: +# - interface Ethernet1/1 +# - no description +# - interface Ethernet1/2 +# - description Configured by Ansible Network +# after: +# - name: Ethernet1/1 +# - description: Configured by Ansible Network +# enabled: false +# name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 -# description Configured by Ansible Network -# shutdown +# description Configured by Ansible Network +# shutdown # interface mgmt0 -# ip address dhcp - +# description mgmt interface +# ip address dhcp +# vrf member management # Using deleted # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# description Interface Ethernet1/1 # interface Ethernet1/2 +# description Configured by Ansible Network +# shutdown # interface mgmt0 -# description Management interface -# ip address dhcp +# description mgmt interface +# ip address dhcp +# vrf member management - name: Delete or return interface parameters to default settings cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 + - name: Ethernet1/2 state: deleted +# Task Output +# ----------- +# +# before: +# - name: Ethernet1/1 +# - description: Configured by Ansible Network +# enabled: false +# name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 +# commands: +# - interface Ethernet1/2 +# - no description +# - no shutdown +# after: +# - name: Ethernet1/1 +# - name: Ethernet1/2 +# - description: mgmt interface +# name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 # interface mgmt0 -# description Management interface -# ip address dhcp +# description mgmt interface +# ip address dhcp +# vrf member management # Using rendered @@ -268,9 +387,9 @@ duplex: full state: rendered -# Task Output (redacted) -# ----------------------- - +# Task Output +# ----------- +# # rendered: # - "interface Ethernet1/1" # - "description outbound-intf" @@ -284,6 +403,7 @@ # parsed.cfg # ------------ +# # interface Ethernet1/800 # description test-1 # speed 1000 @@ -301,8 +421,9 @@ running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output +# ----------- +# # parsed: # - description: "test-1" # duplex: "half" @@ -310,7 +431,6 @@ # mode: "layer3" # name: "Ethernet1/800" # speed: "1000" -# # - description: "test-2" # enabled: true # mode: "layer2" @@ -319,8 +439,10 @@ # Using gathered -# Existing device config state -# ----------------------------- +# Before state: +# ------------- +# +# switch# show running-config | section interface # interface Ethernet1/1 # description outbound-intf # switchport @@ -336,8 +458,9 @@ cisco.nxos.nxos_interfaces: state: gathered -# Task output (redacted) -# ----------------------- +# Task output +# ----------- +# # - name: Ethernet1/1 # description: outbound-intf # mode: layer2 @@ -348,8 +471,10 @@ # Using purged -# Existing device config state -# ----------------------------- +# Before state: +# ------------- +# +# switch# show running-config | section interface # interface Vlan1 # interface Vlan42 # mtu 1800 @@ -370,6 +495,7 @@ # Task output # ------------ +# # before: # - name: Vlan1 # - mtu: '1800' @@ -380,17 +506,26 @@ # - name: Ethernet1/2 # - description: sub-intf # name: Ethernet1/2.100 -# # commands: # - no interface port-channel10 # - no interface Ethernet1/2.100 # - no interface Vlan42 -# # after: # - name: Vlan1 # - name: port-channel11 # - name: Ethernet1/1 # - name: Ethernet1/2 + +# After state: +# ------------- +# +# switch# show running-config | section interface +# interface Vlan1 +# interface port-channel11 +# interface Ethernet1/1 +# interface Ethernet1/2 + + """ RETURN = """ before: diff --git a/plugins/modules/nxos_l2_interfaces.py b/plugins/modules/nxos_l2_interfaces.py index 3e73c4320..55149b7bf 100644 --- a/plugins/modules/nxos_l2_interfaces.py +++ b/plugins/modules/nxos_l2_interfaces.py @@ -111,23 +111,23 @@ - rendered - parsed default: merged - """ + EXAMPLES = """ # Using merged # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# switchport access vlan 20 # interface Ethernet1/2 # switchport trunk native vlan 20 # interface mgmt0 # ip address dhcp # ipv6 address auto-config -- name: Merge provided configuration with device configuration. +- name: Merge provided configuration with device configuration cisco.nxos.nxos_l2_interfaces: config: - name: Ethernet1/1 @@ -139,9 +139,35 @@ vlan: 30 state: merged +# Task Output +# ----------- +# +# before: +# - name: Loopback999 +# - name: Ethernet1/2 +# - name: mgmt0 +# - name: Ethernet1/1 +# commands: +# - interface Ethernet1/1 +# - switchport trunk allowed vlan 2,4,15 +# - switchport trunk native vlan 10 +# - interface Ethernet1/2 +# - switchport access vlan 30 +# after: +# - name: Ethernet1/1 +# trunk: +# allowed_vlans: 2,4,15 +# native_vlan: 10 +# - access: +# vlan: 30 +# name: Ethernet1/2 +# - name: mgmt0 +# - name: Loopback999 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 # switchport trunk native vlan 10 # switchport trunk allowed vlans 2,4,15 @@ -151,16 +177,17 @@ # ip address dhcp # ipv6 address auto-config - # Using replaced # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# switchport access vlan 20 +# switchport trunk native vlan 10 +# switchport trunk allowed vlans 2,4,15 # interface Ethernet1/2 -# switchport trunk native vlan 20 +# switchport access vlan 30 # interface mgmt0 # ip address dhcp # ipv6 address auto-config @@ -174,9 +201,37 @@ allowed_vlans: 5-10, 15 state: replaced +# Task Output +# ----------- +# +# before: +# - name: Ethernet1/1 +# trunk: +# allowed_vlans: 2,4,15 +# native_vlan: 10 +# - access: +# vlan: 30 +# name: Ethernet1/2 +# - name: mgmt0 +# commands: +# - interface Ethernet1/1 +# - no switchport trunk native vlan +# - switchport trunk allowed vlan 5-10,15 +# - switchport trunk native vlan 20 +# after: +# - name: Ethernet1/1 +# trunk: +# allowed_vlans: 5-10,15 +# native_vlan: 20 +# - access: +# vlan: 30 +# name: Ethernet1/2 +# - name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 # switchport trunk native vlan 20 # switchport trunk allowed vlan 5-10,15 @@ -187,22 +242,23 @@ # ip address dhcp # ipv6 address auto-config - # Using overridden # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# switchport access vlan 20 +# switchport trunk native vlan 20 +# switchport trunk allowed vlan 5-10,15 # interface Ethernet1/2 # switchport trunk native vlan 20 +# switchport mode trunk # interface mgmt0 # ip address dhcp # ipv6 address auto-config -- name: Override device configuration of all L2 interfaces on device with provided - configuration. +- name: Override device configuration with provided configuration. cisco.nxos.nxos_l2_interfaces: config: - name: Ethernet1/2 @@ -210,9 +266,33 @@ vlan: 30 state: overridden +# Task Output +# ----------- +# +# before: +# - name: Ethernet1/1 +# trunk: +# allowed_vlans: 5,6,7,8,9,10,15 +# native_vlan: 20 +# - access: +# vlan: 30 +# name: Ethernet1/2 +# - name: mgmt0 +# commands: +# - interface Ethernet1/1 +# - no switchport trunk allowed vlan +# - no switchport trunk native vlan +# after: +# - name: Ethernet1/1 +# - access: +# vlan: 30 +# name: Ethernet1/2 +# - name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 # switchport access vlan 30 @@ -226,10 +306,12 @@ # Before state: # ------------- # +# switch# show running-config | section interface # interface Ethernet1/1 -# switchport access vlan 20 +# switchport trunk native vlan 10 +# switchport trunk allowed vlan 2,4,15 # interface Ethernet1/2 -# switchport trunk native vlan 20 +# switchport access vlan 30 # interface mgmt0 # ip address dhcp # ipv6 address auto-config @@ -242,9 +324,33 @@ - name: Ethernet1/2 state: deleted +# Task Output +# ----------- +# +# before: +# - name: Ethernet1/1 +# trunk: +# allowed_vlans: 2,4,15 +# native_vlan: 10 +# - access: +# vlan: 30 +# name: Ethernet1/2 +# - name: mgmt0 +# commands: +# - interface Ethernet1/1 +# - no switchport trunk allowed vlan +# - no switchport trunk native vlan +# - interface Ethernet1/2 +# - no switchport access vlan +# after: +# - name: Ethernet1/1 +# - name: Ethernet1/2 +# - name: mgmt0 + # After state: # ------------ # +# switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 # interface mgmt0 @@ -269,23 +375,24 @@ allowed_vlans: 5-10, 15 state: rendered -# Task Output (redacted) -# ----------------------- - +# Task Output +# ----------- +# # rendered: -# - "interface Ethernet1/1" -# - "switchport trunk allowed vlan 2,4,15" -# - "switchport trunk native vlan 10" -# - "interface Ethernet1/2" -# - "switchport access vlan 30" -# - "interface Ethernet1/3" -# - "switchport trunk allowed vlan 5,6,7,8,9,10,15" -# - "switchport trunk native vlan 20" +# - interface Ethernet1/1 +# - switchport trunk allowed vlan 2,4,15 +# - switchport trunk native vlan 10 +# - interface Ethernet1/2 +# - switchport access vlan 30 +# - interface Ethernet1/3 +# - switchport trunk allowed vlan 5-10,15 +# - switchport trunk native vlan 20 # Using parsed # parsed.cfg # ------------ +# # interface Ethernet1/800 # switchport access vlan 18 # switchport trunk allowed vlan 210 @@ -297,8 +404,9 @@ running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output +# ----------- +# # parsed: # - name: Ethernet1/800 # access: @@ -311,9 +419,10 @@ # Using gathered -# Existing device config state -# ------------------------------- -# Nexus9kvI5# sh running-config | section ^interface +# Before state: +# ------------- +# +# switch# sh running-config | section ^interface # interface Ethernet1/1 # switchport access vlan 6 # switchport trunk allowed vlan 200 @@ -324,19 +433,20 @@ cisco.nxos.nxos_l2_interfaces: state: gathered -# Task output (redacted) -# ----------------------- +# Task output +# ----------- +# # gathered: # - name: "Ethernet1/1" # access: # vlan: 6 # trunk: # allowed_vlans: "200" -# # - name: "Ethernet1/2" # trunk: # native_vlan: 10 """ + RETURN = """ before: description: The configuration as structured data prior to module invocation. diff --git a/plugins/modules/nxos_l3_interfaces.py b/plugins/modules/nxos_l3_interfaces.py index 7b5cb7a63..1b4d821b2 100644 --- a/plugins/modules/nxos_l3_interfaces.py +++ b/plugins/modules/nxos_l3_interfaces.py @@ -107,7 +107,7 @@ type: bool unreachables: description: - - Enables/disables ip redirects + - Enables/disables ip redirects. type: bool evpn_multisite_tracking: description: @@ -142,7 +142,19 @@ # Before state: # ------------- # +# router# show running-config | section interface # interface Ethernet1/6 +# description Configured by Ansible Network +# no switchport +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management - name: Merge provided configuration with device configuration. cisco.nxos.nxos_l3_interfaces: @@ -158,23 +170,65 @@ - address: fd5d:12c9:2201:2::1/64 tag: 6 - name: Ethernet1/7.42 - dot1q: 42 redirects: false unreachables: false state: merged +# Task Output +# ----------- +# +# before: +# - name: Ethernet1/6 +# - name: Ethernet1/7 +# - ipv4: +# - address: dhcp +# name: mgmt0 +# commands: +# - interface Ethernet1/6 +# - ip address 192.168.1.1/24 tag 5 +# - ip address 10.1.1.1/24 secondary tag 10 +# - ipv6 address fd5d:12c9:2201:2::1/64 tag 6 +# - interface Ethernet1/7 +# - no ip redirects +# after: +# - ipv4: +# - address: 192.168.1.1/24 +# tag: 5 +# - address: 10.1.1.1/24 +# secondary: true +# tag: 10 +# ipv6: +# - address: fd5d:12c9:2201:2::1/64 +# tag: 6 +# name: Ethernet1/6 +# redirects: false +# - name: Ethernet1/7 +# redirects: false +# - ipv4: +# - address: dhcp +# name: mgmt0 + # After state: # ------------ # +# router# show running-config | section interface # interface Ethernet1/6 -# ip address 192.168.22.1/24 tag 5 +# description Configured by Ansible Network +# no switchport +# no ip redirects +# ip address 192.168.1.1/24 tag 5 # ip address 10.1.1.1/24 secondary tag 10 -# interface Ethernet1/6 # ipv6 address fd5d:12c9:2201:2::1/64 tag 6 -# interface Ethernet1/7.42 -# encapsulation dot1q 42 +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport # no ip redirects -# no ip unreachables +# no shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management # Using replaced @@ -182,9 +236,24 @@ # Before state: # ------------- # +# router# show running-config | section interface # interface Ethernet1/6 -# ip address 192.168.22.1/24 -# ipv6 address "fd5d:12c9:2201:1::1/64" +# description Configured by Ansible Network +# no switchport +# no ip redirects +# ip address 192.168.1.1/24 tag 5 +# ip address 10.1.1.1/24 secondary tag 10 +# ipv6 address fd5d:12c9:2201:2::1/64 tag 6 +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no ip redirects +# no shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management - name: Replace device configuration of specified L3 interfaces with provided configuration. cisco.nxos.nxos_l3_interfaces: @@ -194,48 +263,184 @@ - address: 192.168.22.3/24 state: replaced +# Task Output +# ----------- +# +# before: +# - ipv4: +# - address: 192.168.1.1/24 +# tag: 5 +# - address: 10.1.1.1/24 +# secondary: true +# tag: 10 +# ipv6: +# - address: fd5d:12c9:2201:2::1/64 +# tag: 6 +# name: Ethernet1/6 +# redirects: false +# - name: Ethernet1/7 +# redirects: false +# - ipv4: +# - address: dhcp +# name: mgmt0 +# commands: +# - interface Ethernet1/6 +# - ip address 192.168.22.3/24 +# - no ipv6 address fd5d:12c9:2201:2::1/64 +# - ip redirects +# after: +# - ipv4: +# - address: 192.168.22.3/24 +# - address: 10.1.1.1/24 +# secondary: true +# tag: 10 +# name: Ethernet1/6 +# redirects: false +# - name: Ethernet1/7 +# redirects: false +# - ipv4: +# - address: dhcp +# name: mgmt0 + # After state: # ------------ # +# router# show running-config | section interface # interface Ethernet1/6 +# description Configured by Ansible Network +# no switchport +# no ip redirects # ip address 192.168.22.3/24 - +# ip address 10.1.1.1/24 secondary tag 10 +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no ip redirects +# no shutdown +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management # Using overridden # Before state: # ------------- # -# interface Ethernet1/2 -# ip address 192.168.22.1/24 +# router# show running-config | section interface # interface Ethernet1/6 -# ipv6 address "fd5d:12c9:2201:1::1/64" +# description Configured by Ansible Network +# no switchport +# no ip redirects +# ip address 192.168.1.1/24 tag 5 +# ip address 10.1.1.1/24 secondary tag 10 +# ipv6 address fd5d:12c9:2201:2::1/64 tag 6 +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no ip redirects +# no shutdown +# interface Ethernet1/7.42 +# no ip redirects +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management -- name: Override device configuration of all L3 interfaces on device with provided - configuration. +- name: Override device configuration with provided configuration. cisco.nxos.nxos_l3_interfaces: config: - - name: Ethernet1/2 - ipv4: 192.168.22.3/4 + - ipv4: + - address: dhcp + name: mgmt0 + - name: Ethernet1/6 + ipv4: + - address: 192.168.22.3/24 state: overridden +# Task Output +# ----------- +# +# before: +# - ipv4: +# - address: 192.168.1.1/24 +# tag: 5 +# - address: 10.1.1.1/24 +# secondary: true +# tag: 10 +# ipv6: +# - address: fd5d:12c9:2201:2::1/64 +# tag: 6 +# name: Ethernet1/6 +# redirects: false +# - name: Ethernet1/7 +# redirects: false +# - name: Ethernet1/7.42 +# redirects: false +# - ipv4: +# - address: dhcp +# name: mgmt0 +# commands: +# - interface Ethernet1/6 +# - no ipv6 address fd5d:12c9:2201:2::1/64 +# - no ip address 10.1.1.1/24 secondary +# - ip address 192.168.22.3/24 +# - ip redirects +# - interface Ethernet1/7 +# - ip redirects +# - interface Ethernet1/7.42 +# - ip redirects +# after: +# - ipv4: +# - address: 192.168.22.3/24 +# name: Ethernet1/6 +# - name: Ethernet1/7 +# - name: Ethernet1/7.42 +# - ipv4: +# - address: dhcp +# name: mgmt0 + # After state: # ------------ # -# interface Ethernet1/2 -# ipv4 address 192.168.22.3/24 +# router# show running-config | section interface # interface Ethernet1/6 - +# description Configured by Ansible Network +# no switchport +# ip address 192.168.22.3/24 +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no shutdown +# interface Ethernet1/7.42 +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management # Using deleted # Before state: # ------------- # +# router# show running-config | section interface # interface Ethernet1/6 -# ip address 192.168.22.1/24 -# interface Ethernet1/2 -# ipv6 address "fd5d:12c9:2201:1::1/64" +# description Configured by Ansible Network +# no switchport +# ip address 192.168.22.3/24 +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no shutdown +# interface Ethernet1/7.42 +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management - name: Delete L3 attributes of given interfaces (This won't delete the interface itself). @@ -245,11 +450,47 @@ - name: Ethernet1/2 state: deleted +# Task Output +# ----------- +# +# before: +# - name: Ethernet1/2 +# - ipv4: +# - address: 192.168.22.3/24 +# name: Ethernet1/6 +# - name: Ethernet1/7 +# - name: Ethernet1/7.42 +# - ipv4: +# - address: dhcp +# name: mgmt0 +# commands: +# - interface Ethernet1/6 +# - no ip address +# after: +# - name: Ethernet1/2 +# - name: Ethernet1/7 +# - name: Ethernet1/7.42 +# - ipv4: +# - address: dhcp +# name: mgmt0 + # After state: # ------------ # +# router# show running-config | section interface # interface Ethernet1/6 -# interface Ethernet1/2 +# description Configured by Ansible Network +# no switchport +# no shutdown +# interface Ethernet1/7 +# description Configured by Ansible +# no switchport +# no shutdown +# interface Ethernet1/7.42 +# interface mgmt0 +# description mgmt interface +# ip address dhcp +# vrf member management # Using rendered @@ -269,20 +510,21 @@ tag: 6 state: rendered -# Task Output (redacted) -# ----------------------- - +# Task Output +# ----------- +# # rendered: -# - "interface Ethernet1/800" -# - "ip address 192.168.1.100/24 tag 5" -# - "ip address 10.1.1.1/24 secondary tag 10" -# - "interface Ethernet1/800" -# - "ipv6 address fd5d:12c9:2201:2::1/64 tag 6" +# - interface Ethernet1/800 +# - ip address 192.168.1.100/24 tag 5 +# - ip address 10.1.1.1/24 secondary tag 10 +# - interface Ethernet1/800 +# - ipv6 address fd5d:12c9:2201:2::1/64 tag 6 # Using parsed # parsed.cfg -# ------------ +# ---------- +# # interface Ethernet1/800 # ip address 192.168.1.100/24 tag 5 # ip address 10.1.1.1/24 secondary tag 10 @@ -299,9 +541,9 @@ running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- - +# Task output +# ----------- +# # parsed: # - name: Ethernet1/800 # ipv4: @@ -319,8 +561,9 @@ # Using gathered -# Existing device config state -# ------------------------------- +# Before state: +# ------------- +# # interface Ethernet1/1 # ip address 192.0.2.100/24 # interface Ethernet1/2 @@ -333,9 +576,9 @@ cisco.nxos.nxos_l3_interfaces: state: gathered -# Task output (redacted) -# ----------------------- - +# Task output +# ----------- +# # gathered: # - name: Ethernet1/1 # ipv4: From d27e1d9c6502b09ac250cd6b81a6eee5e9a9ca0b Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 29 May 2023 13:33:20 +0530 Subject: [PATCH 095/166] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aae5ce9a0..f38212efe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,5 @@ --- -name: Test collection +name: CI concurrency: group: ${{ github.head_ref || github.run_id }} From d233e8128ecaa4a96468391b84be7f8d082424c3 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 29 May 2023 13:34:12 +0530 Subject: [PATCH 096/166] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index add0c7f94..e5cc9f459 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # Cisco NX-OS Collection [![CI](https://zuul-ci.org/gated.svg)](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/cisco.nxos) [![Codecov](https://codecov.io/gh/ansible-collections/cisco.nxos/branch/main/graph/badge.svg)](https://codecov.io/gh/ansible-collections/cisco.nxos) +[![CI](https://github.com/ansible-collections/cisco.nxos/actions/workflows/tests.yml/badge.svg?branch=main&event=schedule)](https://github.com/ansible-collections/cisco.nxos/actions/workflows/tests.yml) The Ansible Cisco NX-OS collection includes a variety of Ansible content to help automate the management of Cisco NX-OS network appliances. From 2d03100f22087a2cc250b7439b79345ce01d3ad5 Mon Sep 17 00:00:00 2001 From: Ashwini Mhatre Date: Mon, 29 May 2023 15:25:26 +0530 Subject: [PATCH 097/166] Fix docs for static routes RM. (#655) Co-authored-by: Nilashish Chakraborty --- .../fragments/fix_docs_static_routes.yaml | 3 + docs/cisco.nxos.nxos_static_routes_module.rst | 282 +++++++++++++++++- plugins/modules/nxos_static_routes.py | 282 +++++++++++++++++- 3 files changed, 547 insertions(+), 20 deletions(-) create mode 100644 changelogs/fragments/fix_docs_static_routes.yaml diff --git a/changelogs/fragments/fix_docs_static_routes.yaml b/changelogs/fragments/fix_docs_static_routes.yaml new file mode 100644 index 000000000..2034ca241 --- /dev/null +++ b/changelogs/fragments/fix_docs_static_routes.yaml @@ -0,0 +1,3 @@ +--- +doc_changes: + - Fix docs of static-routes resource module. diff --git a/docs/cisco.nxos.nxos_static_routes_module.rst b/docs/cisco.nxos.nxos_static_routes_module.rst index f490bf282..4c5be4a96 100644 --- a/docs/cisco.nxos.nxos_static_routes_module.rst +++ b/docs/cisco.nxos.nxos_static_routes_module.rst @@ -372,6 +372,25 @@ Examples cisco.nxos.nxos_static_routes: state: deleted + # Task Output + # ----------- + # before: + # - address_families: + # - afi: ipv4 + # routes: + # - dest: 192.0.2.0/24 + # next_hops: + # - forward_router_address: 192.0.2.13 + # tag: 12 + # - dest: 192.0.2.32/28 + # next_hops: + # - forward_router_address: 192.0.2.12 + # route_name: new_route + # commands: + # - configure terminal + # - no ip route 192.0.2.0/24 192.0.2.13 tag 12 + # - no ip route 192.0.2.32/28 192.0.2.12 name new_route + # after: [] # After state: # ------------ # @@ -393,6 +412,56 @@ Examples - vrf: trial_vrf state: deleted + # Task Output + # ----------- + # before: + # - 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 + # - afi: ipv6 + # routes: + # - dest: '2200:10::/36' + # next_hops: + # - admin_distance: 5 + # dest_vrf: dest + # forward_router_address: '2048:ae12::1' + # 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 + # commands: + # - vrf context trial_vrf + # - 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 + # - no ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 + # after: + # - 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 + # After state: # ----------- # ip route 192.0.2.16/28 192.0.2.24 name new_route @@ -418,21 +487,71 @@ Examples - afi: ipv4 state: deleted - # After state: + # Task Output # ----------- - # ip route 192.0.2.16/28 192.0.2.24 name new_route - # ip route 192.0.2.80/28 192.0.2.26 tag 12 - # vrf context trial_vrf - # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 - + # before: + # - 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 + # - afi: ipv6 + # routes: + # - dest: '2200:10::/36' + # next_hops: + # - admin_distance: 5 + # dest_vrf: dest + # forward_router_address: '2048:ae12::1' + # 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 + # commands: + # - vrf context trial_vrf + # - 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 + # after: + # - address_families: + # - afi: ipv6 + # routes: + # - dest: '2200:10::/36' + # next_hops: + # - admin_distance: 5 + # dest_vrf: dest + # forward_router_address: '2048:ae12::1' + # 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 - # Before state: + # After state: # ----------- # ip route 192.0.2.16/28 192.0.2.24 name new_route + # ip route 192.0.2.80/28 192.0.2.26 tag 12 # vrf context trial_vrf # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 - # Using merged # Before state: @@ -467,6 +586,40 @@ Examples forward_router_address: 2001:db8::12 state: merged + # Task Output + # ----------- + # before:[] + # commands: + # - vrf context trial_vrf + # - ip route 192.0.2.64/24 192.0.2.22 tag 4 2 + # - configure terminal + # - ip route 192.0.2.16/24 192.0.2.24 name new_route + # - ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 + # after: + # - vrf: trial_vrf + # address_families: + # - afi: ipv4 + # routes: + # - dest: 192.0.2.64/24 + # next_hops: + # - forward_router_address: 192.0.2.22 + # tag: 4 + # admin_distance: 2 + # + # - address_families: + # - afi: ipv4 + # routes: + # - dest: 192.0.2.16/24 + # next_hops: + # - forward_router_address: 192.0.2.24 + # route_name: new_route + # - afi: ipv6 + # routes: + # - dest: 2001:db8::/64 + # next_hops: + # - interface: eth1/3 + # forward_router_address: 2 + # After state: # ------------ # @@ -506,11 +659,61 @@ Examples interface: Ethernet1/2 state: overridden + # Task Output + # ----------- + # before: + # - 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 + # commands: + # - configure terminal + # - no ip route 192.0.2.16/28 192.0.2.24 name new_route + # - no ip route 192.0.2.80/28 192.0.2.26 tag 12 + # - vrf context trial_vrf + # - 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 + # - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 + # - ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2 + # after: + # - address_families: + # - afi: ipv4 + # routes: + # - dest: 192.0.2.16/28 + # next_hops: + # - admin_distance: 3 + # forward_router_address: 192.0.2.23 + # route_name: overridden_route1 + # - dest_vrf: destinationVRF + # forward_router_address: 192.0.2.45 + # interface: Ethernet1/2 + # route_name: overridden_route2 + # vrf: trial_vrf + # After state: # ------------ # - # 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 + # vrf context trial_vrf + # ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 + # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2 # Using replaced: @@ -541,6 +744,65 @@ Examples interface: Ethernet1/2 state: replaced + # Task Output + # ----------- + # before: + # - 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 + # commands: + # - configure terminal + # - no ip route 192.0.2.16/28 192.0.2.24 name new_route + # - 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 + # after: + # - 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: + # - admin_distance: 3 + # forward_router_address: 192.0.2.23 + # route_name: replaced_route1 + # - dest_vrf: destinationVRF + # forward_router_address: 192.0.2.45 + # interface: Ethernet1/2 + # route_name: replaced_route2 + # - dest: 192.0.2.80/28 + # next_hops: + # - forward_router_address: 192.0.2.26 + # tag: 12 + # After state: # ----------- # ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3 diff --git a/plugins/modules/nxos_static_routes.py b/plugins/modules/nxos_static_routes.py index 15b8e6903..f8042aede 100644 --- a/plugins/modules/nxos_static_routes.py +++ b/plugins/modules/nxos_static_routes.py @@ -156,6 +156,25 @@ cisco.nxos.nxos_static_routes: state: deleted +# Task Output +# ----------- +# before: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.0/24 +# next_hops: +# - forward_router_address: 192.0.2.13 +# tag: 12 +# - dest: 192.0.2.32/28 +# next_hops: +# - forward_router_address: 192.0.2.12 +# route_name: new_route +# commands: +# - configure terminal +# - no ip route 192.0.2.0/24 192.0.2.13 tag 12 +# - no ip route 192.0.2.32/28 192.0.2.12 name new_route +# after: [] # After state: # ------------ # @@ -177,6 +196,56 @@ - vrf: trial_vrf state: deleted +# Task Output +# ----------- +# before: +# - 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 +# - afi: ipv6 +# routes: +# - dest: '2200:10::/36' +# next_hops: +# - admin_distance: 5 +# dest_vrf: dest +# forward_router_address: '2048:ae12::1' +# 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 +# commands: +# - vrf context trial_vrf +# - 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 +# - no ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 +# after: +# - 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 + # After state: # ----------- # ip route 192.0.2.16/28 192.0.2.24 name new_route @@ -202,21 +271,71 @@ - afi: ipv4 state: deleted -# After state: +# Task Output # ----------- -# ip route 192.0.2.16/28 192.0.2.24 name new_route -# ip route 192.0.2.80/28 192.0.2.26 tag 12 -# vrf context trial_vrf -# ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 - +# before: +# - 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 +# - afi: ipv6 +# routes: +# - dest: '2200:10::/36' +# next_hops: +# - admin_distance: 5 +# dest_vrf: dest +# forward_router_address: '2048:ae12::1' +# 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 +# commands: +# - vrf context trial_vrf +# - 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 +# after: +# - address_families: +# - afi: ipv6 +# routes: +# - dest: '2200:10::/36' +# next_hops: +# - admin_distance: 5 +# dest_vrf: dest +# forward_router_address: '2048:ae12::1' +# 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 -# Before state: +# After state: # ----------- # ip route 192.0.2.16/28 192.0.2.24 name new_route +# ip route 192.0.2.80/28 192.0.2.26 tag 12 # vrf context trial_vrf # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 - # Using merged # Before state: @@ -251,6 +370,40 @@ forward_router_address: 2001:db8::12 state: merged +# Task Output +# ----------- +# before:[] +# commands: +# - vrf context trial_vrf +# - ip route 192.0.2.64/24 192.0.2.22 tag 4 2 +# - configure terminal +# - ip route 192.0.2.16/24 192.0.2.24 name new_route +# - ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 +# after: +# - vrf: trial_vrf +# address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.64/24 +# next_hops: +# - forward_router_address: 192.0.2.22 +# tag: 4 +# admin_distance: 2 +# +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/24 +# next_hops: +# - forward_router_address: 192.0.2.24 +# route_name: new_route +# - afi: ipv6 +# routes: +# - dest: 2001:db8::/64 +# next_hops: +# - interface: eth1/3 +# forward_router_address: 2 + # After state: # ------------ # @@ -290,11 +443,61 @@ interface: Ethernet1/2 state: overridden +# Task Output +# ----------- +# before: +# - 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 +# commands: +# - configure terminal +# - no ip route 192.0.2.16/28 192.0.2.24 name new_route +# - no ip route 192.0.2.80/28 192.0.2.26 tag 12 +# - vrf context trial_vrf +# - 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 +# - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 +# - ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2 +# after: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - admin_distance: 3 +# forward_router_address: 192.0.2.23 +# route_name: overridden_route1 +# - dest_vrf: destinationVRF +# forward_router_address: 192.0.2.45 +# interface: Ethernet1/2 +# route_name: overridden_route2 +# vrf: trial_vrf + # After state: # ------------ # -# 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 +# vrf context trial_vrf +# ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 +# ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2 # Using replaced: @@ -325,6 +528,65 @@ interface: Ethernet1/2 state: replaced +# Task Output +# ----------- +# before: +# - 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 +# commands: +# - configure terminal +# - no ip route 192.0.2.16/28 192.0.2.24 name new_route +# - 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 +# after: +# - 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: +# - admin_distance: 3 +# forward_router_address: 192.0.2.23 +# route_name: replaced_route1 +# - dest_vrf: destinationVRF +# forward_router_address: 192.0.2.45 +# interface: Ethernet1/2 +# route_name: replaced_route2 +# - dest: 192.0.2.80/28 +# next_hops: +# - forward_router_address: 192.0.2.26 +# tag: 12 + # After state: # ----------- # ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3 From c4682476d290aee1910c5222748f6bb3ad7984c1 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 29 May 2023 18:25:32 +0530 Subject: [PATCH 098/166] Prepare for v4.4.0 (#689) * Prepare for v4.4.0 Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.rst | 25 +++++++++++++++++ changelogs/changelog.yaml | 28 +++++++++++++++++++ changelogs/fragments/banner.yaml | 3 -- changelogs/fragments/downstream.yaml | 3 -- .../fragments/fix_docs_static_routes.yaml | 3 -- changelogs/fragments/l3.yaml | 3 -- changelogs/fragments/lint.yaml | 3 -- changelogs/fragments/ntp_global.yaml | 3 -- changelogs/fragments/ntp_user.yaml | 3 -- changelogs/fragments/nxos_facts.yaml | 3 -- changelogs/fragments/terminal.yaml | 3 -- changelogs/fragments/tests.yaml | 3 -- changelogs/fragments/update_inft_docs.yaml | 5 ---- galaxy.yml | 2 +- 14 files changed, 54 insertions(+), 36 deletions(-) delete mode 100644 changelogs/fragments/banner.yaml delete mode 100644 changelogs/fragments/downstream.yaml delete mode 100644 changelogs/fragments/fix_docs_static_routes.yaml delete mode 100644 changelogs/fragments/l3.yaml delete mode 100644 changelogs/fragments/lint.yaml delete mode 100644 changelogs/fragments/ntp_global.yaml delete mode 100644 changelogs/fragments/ntp_user.yaml delete mode 100644 changelogs/fragments/nxos_facts.yaml delete mode 100644 changelogs/fragments/terminal.yaml delete mode 100644 changelogs/fragments/tests.yaml delete mode 100644 changelogs/fragments/update_inft_docs.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4f24e52a4..34a945461 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,31 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v4.4.0 +====== + +Minor Changes +------------- + +- nxos_user - Add support for hashed passwords. (https://github.com/ansible-collections/cisco.nxos/issues/370). + +Bugfixes +-------- + +- l3_interfaces - Append tag when updating IP address with state replaced (https://github.com/ansible-collections/cisco.nxos/issues/678). +- ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670). +- nxos_banner - Add support for a custom multiline delimiter +- nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440). +- terminal - attempt privilege escalation only when prompt does not end with # + +Documentation Changes +--------------------- + +- Fix docs of static-routes resource module. +- nxos_interfaces - Fixed module documentation and examples. +- nxos_l2_interfaces - Fixed module documentation and examples. +- nxos_l3_interfaces - Fixed module documentation and examples. + v4.3.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 9a150d2db..0ae1adf75 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -982,3 +982,31 @@ releases: fragments: - release_430.yaml release_date: "2023-04-05" + 4.4.0: + changes: + bugfixes: + - l3_interfaces - Append tag when updating IP address with state replaced (https://github.com/ansible-collections/cisco.nxos/issues/678). + - ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670). + - nxos_banner - Add support for a custom multiline delimiter + - nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440). + - "terminal - attempt privilege escalation only when prompt does not end with #" + doc_changes: + - Fix docs of static-routes resource module. + - nxos_interfaces - Fixed module documentation and examples. + - nxos_l2_interfaces - Fixed module documentation and examples. + - nxos_l3_interfaces - Fixed module documentation and examples. + minor_changes: + - nxos_user - Add support for hashed passwords. (https://github.com/ansible-collections/cisco.nxos/issues/370). + fragments: + - banner.yaml + - downstream.yaml + - fix_docs_static_routes.yaml + - l3.yaml + - lint.yaml + - ntp_global.yaml + - ntp_user.yaml + - nxos_facts.yaml + - terminal.yaml + - tests.yaml + - update_inft_docs.yaml + release_date: "2023-05-29" diff --git a/changelogs/fragments/banner.yaml b/changelogs/fragments/banner.yaml deleted file mode 100644 index cc0f68e9c..000000000 --- a/changelogs/fragments/banner.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_banner - Add support for a custom multiline delimiter" diff --git a/changelogs/fragments/downstream.yaml b/changelogs/fragments/downstream.yaml deleted file mode 100644 index a424272fb..000000000 --- a/changelogs/fragments/downstream.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fixes for downstream testing. diff --git a/changelogs/fragments/fix_docs_static_routes.yaml b/changelogs/fragments/fix_docs_static_routes.yaml deleted file mode 100644 index 2034ca241..000000000 --- a/changelogs/fragments/fix_docs_static_routes.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -doc_changes: - - Fix docs of static-routes resource module. diff --git a/changelogs/fragments/l3.yaml b/changelogs/fragments/l3.yaml deleted file mode 100644 index e96eaed23..000000000 --- a/changelogs/fragments/l3.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "l3_interfaces - Append tag when updating IP address with state replaced (https://github.com/ansible-collections/cisco.nxos/issues/678)." diff --git a/changelogs/fragments/lint.yaml b/changelogs/fragments/lint.yaml deleted file mode 100644 index f356148d1..000000000 --- a/changelogs/fragments/lint.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix ansible-lint issues. diff --git a/changelogs/fragments/ntp_global.yaml b/changelogs/fragments/ntp_global.yaml deleted file mode 100644 index ee69128f5..000000000 --- a/changelogs/fragments/ntp_global.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670)." diff --git a/changelogs/fragments/ntp_user.yaml b/changelogs/fragments/ntp_user.yaml deleted file mode 100644 index f3a5e5e1d..000000000 --- a/changelogs/fragments/ntp_user.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "nxos_user - Add support for hashed passwords. (https://github.com/ansible-collections/cisco.nxos/issues/370)." diff --git a/changelogs/fragments/nxos_facts.yaml b/changelogs/fragments/nxos_facts.yaml deleted file mode 100644 index ed12c2650..000000000 --- a/changelogs/fragments/nxos_facts.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440)." diff --git a/changelogs/fragments/terminal.yaml b/changelogs/fragments/terminal.yaml deleted file mode 100644 index 6ba4b5ef4..000000000 --- a/changelogs/fragments/terminal.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "terminal - attempt privilege escalation only when prompt does not end with #" diff --git a/changelogs/fragments/tests.yaml b/changelogs/fragments/tests.yaml deleted file mode 100644 index ef37de24b..000000000 --- a/changelogs/fragments/tests.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix downstream snmp-server test. diff --git a/changelogs/fragments/update_inft_docs.yaml b/changelogs/fragments/update_inft_docs.yaml deleted file mode 100644 index 8aa14b89c..000000000 --- a/changelogs/fragments/update_inft_docs.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -doc_changes: - - nxos_interfaces - Fixed module documentation and examples. - - nxos_l2_interfaces - Fixed module documentation and examples. - - nxos_l3_interfaces - Fixed module documentation and examples. diff --git a/galaxy.yml b/galaxy.yml index 3ceb203df..836de0940 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 4.4.0-dev +version: 4.4.0 From fa98d2be96a45417ef6e4a2e78d55f0125409ec9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:35:00 +0530 Subject: [PATCH 099/166] [pre-commit.ci] pre-commit autoupdate (#695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v2.4.0 → v2.5.1](https://github.com/asottile/add-trailing-comma/compare/v2.4.0...v2.5.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 08b2db27b..7edab1a11 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v2.4.0 + rev: v2.5.1 hooks: - id: add-trailing-comma From 9d36de2495833d4fe05e5d6b3242d1c1f1511a44 Mon Sep 17 00:00:00 2001 From: Thomas Bridge Date: Mon, 19 Jun 2023 14:12:54 +0100 Subject: [PATCH 100/166] Added dev-ops role to BUILTINS (#691) * Added dev-ops role to BUILTINS * Added changelog entry * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Thomas Bridge Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/nxos_user.yml | 3 +++ galaxy.yml | 2 +- plugins/modules/nxos_user.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/nxos_user.yml diff --git a/changelogs/fragments/nxos_user.yml b/changelogs/fragments/nxos_user.yml new file mode 100644 index 000000000..2e31198d6 --- /dev/null +++ b/changelogs/fragments/nxos_user.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "nxos_user - Added dev-ops role to BUILTINS (https://github.com/ansible-collections/cisco.nxos/issues/690)" diff --git a/galaxy.yml b/galaxy.yml index 836de0940..1af93f2b4 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 4.4.0 +version: 4.5.0-dev diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index 92a0a5c01..2456c53ac 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -225,6 +225,7 @@ "priv-2", "priv-1", "priv-0", + "dev-ops", ] From 3e5b1c9fe7327920757256f5e944f36f75fe4387 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 23 Jun 2023 17:31:24 +0530 Subject: [PATCH 101/166] Add nxos_bgp_templates module (#630) * Add nxos_bgp_templates module Signed-off-by: NilashishC * Update Signed-off-by: NilashishC * Lint fixes Signed-off-by: NilashishC * Update Signed-off-by: NilashishC * Fix lint Signed-off-by: NilashishC * Updates Signed-off-by: NilashishC * Updates Signed-off-by: NilashishC * Update config code Signed-off-by: NilashishC * Add unit tests Signed-off-by: NilashishC * Fix sanity Signed-off-by: NilashishC * Add integrationt tests Signed-off-by: NilashishC * Add examples Signed-off-by: NilashishC * Minor test update Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- README.md | 1 + changelogs/fragments/templates.yaml | 3 + docs/__init__.py | 0 docs/cisco.nxos.nxos_bgp_templates_module.rst | 2817 +++++++++++++++++ meta/__init__.py | 0 .../nxos/argspec/bgp_templates/__init__.py | 0 .../argspec/bgp_templates/bgp_templates.py | 310 ++ .../nxos/config/bgp_templates/__init__.py | 0 .../config/bgp_templates/bgp_templates.py | 227 ++ .../nxos/config/interfaces/interfaces.py | 2 +- .../nxos/facts/bgp_templates/__init__.py | 0 .../nxos/facts/bgp_templates/bgp_templates.py | 102 + .../module_utils/network/nxos/facts/facts.py | 4 + .../nxos/rm_templates/bgp_templates.py | 1166 +++++++ plugins/modules/nxos_bgp_templates.py | 1011 ++++++ .../nxos_bgp_templates/defaults/main.yaml | 2 + .../targets/nxos_bgp_templates/meta/main.yml | 1 + .../targets/nxos_bgp_templates/tasks/cli.yaml | 32 + .../nxos_bgp_templates/tasks/main.yaml | 26 + .../nxos_bgp_templates/tasks/nxapi.yaml | 32 + .../tests/common/_populate_config.yaml | 25 + .../tests/common/_remove_config.yaml | 8 + .../tests/common/deleted.yaml | 44 + .../tests/common/empty_config.yaml | 61 + .../tests/common/fixtures/parsed.cfg | 20 + .../tests/common/gathered.yaml | 20 + .../tests/common/merged.yaml | 72 + .../tests/common/overridden.yaml | 61 + .../tests/common/parsed.yaml | 14 + .../tests/common/rendered.yaml | 59 + .../tests/common/replaced.yaml | 61 + .../targets/nxos_bgp_templates/vars/main.yml | 142 + .../nxos_facts/tests/common/all_facts.yaml | 6 +- .../targets/nxos_facts/vars/main.yml | 30 + .../targets/nxos_snmp_server/tasks/main.yaml | 6 +- .../network/nxos/test_nxos_bgp_templates.py | 801 +++++ 36 files changed, 7157 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/templates.yaml create mode 100644 docs/__init__.py create mode 100644 docs/cisco.nxos.nxos_bgp_templates_module.rst create mode 100644 meta/__init__.py create mode 100644 plugins/module_utils/network/nxos/argspec/bgp_templates/__init__.py create mode 100644 plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py create mode 100644 plugins/module_utils/network/nxos/config/bgp_templates/__init__.py create mode 100644 plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py create mode 100644 plugins/module_utils/network/nxos/facts/bgp_templates/__init__.py create mode 100644 plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py create mode 100644 plugins/module_utils/network/nxos/rm_templates/bgp_templates.py create mode 100644 plugins/modules/nxos_bgp_templates.py create mode 100644 tests/integration/targets/nxos_bgp_templates/defaults/main.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/meta/main.yml create mode 100644 tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tasks/main.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/_populate_config.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/_remove_config.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/deleted.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/empty_config.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/fixtures/parsed.cfg create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/gathered.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/merged.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/overridden.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/parsed.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/rendered.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/tests/common/replaced.yaml create mode 100644 tests/integration/targets/nxos_bgp_templates/vars/main.yml create mode 100644 tests/integration/targets/nxos_facts/vars/main.yml create mode 100644 tests/unit/modules/network/nxos/test_nxos_bgp_templates.py diff --git a/README.md b/README.md index e5cc9f459..b1be92bae 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Name | Description [cisco.nxos.nxos_bgp_neighbor](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_neighbor_module.rst)|(deprecated, removed after 2023-01-27) Manages BGP neighbors configurations. [cisco.nxos.nxos_bgp_neighbor_address_family](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst)|BGP Neighbor Address Family resource module. [cisco.nxos.nxos_bgp_neighbor_af](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst)|(deprecated, removed after 2023-02-24) Manages BGP address-family's neighbors configuration. +[cisco.nxos.nxos_bgp_templates](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_templates_module.rst)|BGP Templates resource module. [cisco.nxos.nxos_command](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_command_module.rst)|Run arbitrary command on Cisco NXOS devices [cisco.nxos.nxos_config](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_config_module.rst)|Manage Cisco NXOS configuration sections [cisco.nxos.nxos_devicealias](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_devicealias_module.rst)|Configuration of device alias for Cisco NXOS MDS Switches. diff --git a/changelogs/fragments/templates.yaml b/changelogs/fragments/templates.yaml new file mode 100644 index 000000000..3115b98bc --- /dev/null +++ b/changelogs/fragments/templates.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Add nxos_bgp_templates module. diff --git a/docs/__init__.py b/docs/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/cisco.nxos.nxos_bgp_templates_module.rst b/docs/cisco.nxos.nxos_bgp_templates_module.rst new file mode 100644 index 000000000..3a2f9dc39 --- /dev/null +++ b/docs/cisco.nxos.nxos_bgp_templates_module.rst @@ -0,0 +1,2817 @@ +.. _cisco.nxos.nxos_bgp_templates_module: + + +***************************** +cisco.nxos.nxos_bgp_templates +***************************** + +**BGP Templates resource module.** + + +Version added: 4.2.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages BGP templates on devices running Cisco NX-OS. + + + + +Parameters +---------- + +.. raw:: html + +
ParameterParameter Choices/Defaults Comments
+
description @@ -49,7 +49,7 @@ Parameters
+
global_ingress_replication_bgp @@ -68,7 +68,7 @@ Parameters
+
global_mcast_group_L2 @@ -83,7 +83,7 @@ Parameters
+
global_mcast_group_L3 @@ -98,7 +98,7 @@ Parameters
+
global_suppress_arp @@ -117,7 +117,7 @@ Parameters
+
host_reachability @@ -136,7 +136,7 @@ Parameters
+
interface @@ -152,7 +152,7 @@ Parameters
+
multisite_border_gateway_interface @@ -168,241 +168,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
shutdown @@ -421,7 +187,7 @@ Parameters
+
source_interface @@ -436,7 +202,7 @@ Parameters
+
source_interface_hold_down_time @@ -451,7 +217,7 @@ Parameters
+
state diff --git a/docs/cisco.nxos.nxos_vxlan_vtep_vni_module.rst b/docs/cisco.nxos.nxos_vxlan_vtep_vni_module.rst index e27325e0d..d000c9959 100644 --- a/docs/cisco.nxos.nxos_vxlan_vtep_vni_module.rst +++ b/docs/cisco.nxos.nxos_vxlan_vtep_vni_module.rst @@ -29,12 +29,12 @@ Parameters - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -65,7 +65,8 @@ Parameters @@ -82,7 +83,7 @@ Parameters Default:
"min"
ParameterParameter Choices/Defaults Comments
+
assoc_vrf @@ -53,7 +53,7 @@ Parameters
+
ingress_replication @@ -73,7 +73,7 @@ Parameters
+
interface @@ -89,7 +89,7 @@ Parameters
+
multicast_group @@ -104,7 +104,7 @@ Parameters
+
multisite_ingress_replication @@ -125,7 +125,7 @@ Parameters
+
peer_list @@ -141,241 +141,7 @@ Parameters
-
- provider - -
- dictionary -
-
- -
Deprecated
-
Starting with Ansible 2.5 we recommend using connection: network_cli.
-
Starting with Ansible 2.6 we recommend using connection: httpapi for NX-API.
-
This option will be removed in a release after 2022-06-01.
- -

-
A dict object containing connection details.
-
-
- auth_pass - -
- string -
-
- -
Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead.
-
-
- authorize - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead.
-
-
- host - -
- string -
-
- -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
-
-
- password - -
- string -
-
- -
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or nxapi transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
-
-
- port - -
- integer -
-
- -
Specifies the port to use when building the connection to the remote device. This value applies to either cli or nxapi. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443).
-
-
- ssh_keyfile - -
- string -
-
- -
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
-
-
- timeout - -
- integer -
-
- -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. NX-API can be slow to return on long-running commands (sh mac, sh bgp, etc).
-
-
- transport - -
- string -
-
-
    Choices: -
  • cli ←
  • -
  • nxapi
  • -
-
-
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over cli (ssh) or nxapi.
-
-
- use_proxy - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
If no, the environment variables http_proxy and https_proxy will be ignored.
-
-
- use_ssl - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Configures the transport to use SSL if set to yes only when the transport=nxapi, otherwise this value is ignored.
-
-
- username - -
- string -
-
- -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the nxapi authentication depending on which transport is used. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. If the transport argument is not nxapi, this value is ignored.
-
state @@ -394,7 +160,7 @@ Parameters
+
suppress_arp @@ -413,7 +179,7 @@ Parameters
+
suppress_arp_disable @@ -432,7 +198,7 @@ Parameters
+
vni diff --git a/plugins/action/nxos.py b/plugins/action/nxos.py index 36bd2a155..3602c4074 100644 --- a/plugins/action/nxos.py +++ b/plugins/action/nxos.py @@ -21,21 +21,12 @@ __metaclass__ = type -import copy -import re -import sys - from ansible import constants as C from ansible.module_utils.connection import Connection from ansible.utils.display import Display from ansible_collections.ansible.netcommon.plugins.action.network import ( ActionModule as ActionNetworkModule, ) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - load_provider, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_provider_spec display = Display() @@ -51,13 +42,13 @@ def run(self, tmp=None, task_vars=None): warnings = [] - if ( - self._play_context.connection in ("httpapi", "local") - or self._task.args.get("provider", {}).get("transport") == "nxapi" - ) and module_name in ("nxos_file_copy", "nxos_nxapi"): + if (self._play_context.connection == "httpapi") and module_name in ( + "nxos_file_copy", + "nxos_nxapi", + ): return { "failed": True, - "msg": "Transport type 'nxapi' is not valid for '%s' module." % (module_name), + "msg": "Connection httpapi is not valid for '%s' module." % (module_name), } if module_name == "nxos_file_copy": @@ -109,14 +100,6 @@ def run(self, tmp=None, task_vars=None): return {"failed": True, "msg": msg} if persistent_connection in ("network_cli", "httpapi"): - provider = self._task.args.get("provider", {}) - if any(provider.values()): - display.warning( - "provider is unnecessary when using %s and will be ignored" - % self._play_context.connection, - ) - del self._task.args["provider"] - if module_name == "nxos_gir": conn = Connection(self._connection.socket_path) persistent_command_timeout = conn.get_option("persistent_command_timeout") @@ -126,81 +109,6 @@ def run(self, tmp=None, task_vars=None): msg = "timeout value extended to %ss for nxos_gir" % gir_timeout display.warning(msg) - elif self._play_context.connection == "local": - provider = load_provider(nxos_provider_spec, self._task.args) - transport = provider["transport"] or "cli" - - display.vvvv( - "connection transport is %s" % transport, - self._play_context.remote_addr, - ) - - if transport == "cli": - pc = copy.deepcopy(self._play_context) - pc.connection = "ansible.netcommon.network_cli" - pc.network_os = "cisco.nxos.nxos" - pc.remote_addr = provider["host"] or self._play_context.remote_addr - pc.port = int(provider["port"] or self._play_context.port or 22) - pc.remote_user = provider["username"] or self._play_context.connection_user - pc.password = provider["password"] or self._play_context.password - pc.private_key_file = provider["ssh_keyfile"] or self._play_context.private_key_file - pc.become = provider["authorize"] or False - if pc.become: - pc.become_method = "enable" - pc.become_pass = provider["auth_pass"] - - connection = self._shared_loader_obj.connection_loader.get( - "ansible.netcommon.persistent", - pc, - sys.stdin, - task_uuid=self._task._uuid, - ) - - # TODO: Remove below code after ansible minimal is cut out - if connection is None: - pc.connection = "network_cli" - pc.network_os = "nxos" - connection = self._shared_loader_obj.connection_loader.get( - "persistent", - pc, - sys.stdin, - task_uuid=self._task._uuid, - ) - - display.vvv( - "using connection plugin %s (was local)" % pc.connection, - pc.remote_addr, - ) - - command_timeout = ( - int(provider["timeout"]) - if provider["timeout"] - else connection.get_option("persistent_command_timeout") - ) - connection.set_options(direct={"persistent_command_timeout": command_timeout}) - - socket_path = connection.run() - display.vvvv("socket_path: %s" % socket_path, pc.remote_addr) - if not socket_path: - return { - "failed": True, - "msg": "unable to open shell. Please see: " - + "https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell", - } - - task_vars["ansible_socket"] = socket_path - - else: - self._task.args["provider"] = ActionModule.nxapi_implementation( - provider, - self._play_context, - ) - warnings.append( - [ - "connection local support for this module is deprecated and will be removed in version 2.14," - " use connection either httpapi or ansible.netcommon.httpapi (whichever is applicable)", - ], - ) else: return { "failed": True, @@ -215,32 +123,3 @@ def run(self, tmp=None, task_vars=None): else: result["warnings"] = warnings return result - - @staticmethod - def nxapi_implementation(provider, play_context): - provider["transport"] = "nxapi" - if provider.get("host") is None: - provider["host"] = play_context.remote_addr - - if provider.get("port") is None: - if provider.get("use_ssl"): - provider["port"] = 443 - else: - provider["port"] = 80 - - if provider.get("timeout") is None: - provider["timeout"] = C.PERSISTENT_COMMAND_TIMEOUT - - if provider.get("username") is None: - provider["username"] = play_context.connection_user - - if provider.get("password") is None: - provider["password"] = play_context.password - - if provider.get("use_ssl") is None: - provider["use_ssl"] = False - - if provider.get("validate_certs") is None: - provider["validate_certs"] = True - - return provider diff --git a/plugins/doc_fragments/nxos.py b/plugins/doc_fragments/nxos.py index fde64c59f..4f7edb765 100644 --- a/plugins/doc_fragments/nxos.py +++ b/plugins/doc_fragments/nxos.py @@ -11,110 +11,12 @@ class ModuleDocFragment(object): # Standard files documentation fragment - DOCUMENTATION = r"""options: - provider: - description: - - B(Deprecated) - - 'Starting with Ansible 2.5 we recommend using C(connection: network_cli).' - - 'Starting with Ansible 2.6 we recommend using C(connection: httpapi) for NX-API.' - - This option will be removed in a release after 2022-06-01. - - For more information please see the U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_nxos.html). - - HORIZONTALLINE - - A dict object containing connection details. - type: dict - suboptions: - host: - description: - - Specifies the DNS host name or address for connecting to the remote device - over the specified transport. The value of host is used as the destination - address for the transport. - type: str - port: - description: - - Specifies the port to use when building the connection to the remote device. This - value applies to either I(cli) or I(nxapi). The port value will default - to the appropriate transport common port if none is provided in the task. (cli=22, - http=80, https=443). - type: int - username: - description: - - Configures the username to use to authenticate the connection to the remote - device. This value is used to authenticate either the CLI login or the - nxapi authentication depending on which transport is used. If the value - is not specified in the task, the value of environment variable C(ANSIBLE_NET_USERNAME) - will be used instead. - type: str - password: - description: - - Specifies the password to use to authenticate the connection to the remote - device. This is a common argument used for either I(cli) or I(nxapi) transports. - If the value is not specified in the task, the value of environment variable - C(ANSIBLE_NET_PASSWORD) will be used instead. - type: str - authorize: - description: - - Instructs the module to enter privileged mode on the remote device before - sending any commands. If not specified, the device will attempt to execute - all commands in non-privileged mode. If the value is not specified in the - task, the value of environment variable C(ANSIBLE_NET_AUTHORIZE) will be - used instead. - type: bool - default: false - auth_pass: - description: - - Specifies the password to use if required to enter privileged mode on the - remote device. If I(authorize) is false, then this argument does nothing. - If the value is not specified in the task, the value of environment variable - C(ANSIBLE_NET_AUTH_PASS) will be used instead. - type: str - timeout: - description: - - Specifies the timeout in seconds for communicating with the network device - for either connecting or sending commands. If the timeout is exceeded before - the operation is completed, the module will error. NX-API can be slow to - return on long-running commands (sh mac, sh bgp, etc). - type: int - ssh_keyfile: - description: - - Specifies the SSH key to use to authenticate the connection to the remote - device. This argument is only used for the I(cli) transport. If the value - is not specified in the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE) - will be used instead. - type: str - transport: - description: - - Configures the transport connection to use when connecting to the remote - device. The transport argument supports connectivity to the device over - cli (ssh) or nxapi. - type: str - choices: - - cli - - nxapi - default: cli - use_ssl: - description: - - Configures the I(transport) to use SSL if set to C(yes) only when the C(transport=nxapi), - otherwise this value is ignored. - type: bool - default: false - validate_certs: - description: - - If C(no), SSL certificates will not be validated. This should only be used - on personally controlled sites using self-signed certificates. If the transport - argument is not nxapi, this value is ignored. - type: bool - default: False - use_proxy: - description: - - If C(no), the environment variables C(http_proxy) and C(https_proxy) will - be ignored. - type: bool - default: true + DOCUMENTATION = r"""options: {} notes: -- For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide - ` -- For more information on using Ansible to manage network devices see the :ref:`Ansible - Network Guide ` -- For more information on using Ansible to manage Cisco devices see the `Cisco integration - page `_. + - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide + ` + - For more information on using Ansible to manage network devices see the :ref:`Ansible + Network Guide ` + - For more information on using Ansible to manage Cisco devices see the `Cisco integration + page `_. """ diff --git a/plugins/module_utils/network/nxos/nxos.py b/plugins/module_utils/network/nxos/nxos.py index a605c4242..35b40cbf5 100644 --- a/plugins/module_utils/network/nxos/nxos.py +++ b/plugins/module_utils/network/nxos/nxos.py @@ -32,7 +32,6 @@ __metaclass__ = type -import collections import json import re import sys @@ -40,11 +39,9 @@ from copy import deepcopy from ansible.module_utils._text import to_text -from ansible.module_utils.basic import env_fallback from ansible.module_utils.common._collections_compat import Mapping from ansible.module_utils.connection import Connection, ConnectionError -from ansible.module_utils.six import PY2, PY3, iteritems -from ansible.module_utils.urls import fetch_url +from ansible.module_utils.six import PY2, PY3 from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( CustomNetworkConfig, NetworkConfig, @@ -74,62 +71,16 @@ _DEVICE_CONNECTION = None -nxos_provider_spec = { - "host": dict(type="str"), - "port": dict(type="int"), - "username": dict(type="str", fallback=(env_fallback, ["ANSIBLE_NET_USERNAME"])), - "password": dict( - type="str", - no_log=True, - fallback=(env_fallback, ["ANSIBLE_NET_PASSWORD"]), - ), - "ssh_keyfile": dict( - type="str", - fallback=(env_fallback, ["ANSIBLE_NET_SSH_KEYFILE"]), - no_log=False, - ), - "authorize": dict( - type="bool", - default=False, - fallback=(env_fallback, ["ANSIBLE_NET_AUTHORIZE"]), - ), - "auth_pass": dict( - type="str", - no_log=True, - fallback=(env_fallback, ["ANSIBLE_NET_AUTH_PASS"]), - ), - "use_ssl": dict(type="bool", default=False), - "use_proxy": dict(type="bool", default=True), - "validate_certs": dict(type="bool", default=False), - "timeout": dict(type="int"), - "transport": dict(type="str", default="cli", choices=["cli", "nxapi"]), -} -nxos_argument_spec = { - "provider": dict( - type="dict", - options=nxos_provider_spec, - removed_at_date="2022-06-01", - removed_from_collection="cisco.nxos", - ), -} - - -def get_provider_argspec(): - return nxos_provider_spec - def get_connection(module): global _DEVICE_CONNECTION if not _DEVICE_CONNECTION: - if is_local_nxapi(module): - conn = LocalNxapi(module) - else: - connection_proxy = Connection(module._socket_path) - cap = json.loads(connection_proxy.get_capabilities()) - if cap["network_api"] == "cliconf": - conn = Cli(module) - elif cap["network_api"] == "nxapi": - conn = HttpApi(module) + connection_proxy = Connection(module._socket_path) + cap = json.loads(connection_proxy.get_capabilities()) + if cap["network_api"] == "cliconf": + conn = Cli(module) + elif cap["network_api"] == "nxapi": + conn = HttpApi(module) _DEVICE_CONNECTION = conn return _DEVICE_CONNECTION @@ -276,313 +227,6 @@ def save_module_context(self, module_key, module_context): return None -class LocalNxapi: - - OUTPUT_TO_COMMAND_TYPE = { - "text": "cli_show_ascii", - "json": "cli_show", - "bash": "bash", - "config": "cli_conf", - } - - def __init__(self, module): - self._module = module - self._nxapi_auth = None - self._device_configs = {} - self._module_context = {} - - provider = self._module.params.get("provider") or {} - self._module.params["url_username"] = provider.get("username") - self._module.params["url_password"] = provider.get("password") - - host = provider.get("host") - port = provider.get("port") - - if provider.get("use_ssl"): - proto = "https" - port = port or 443 - else: - proto = "http" - port = port or 80 - - self._url = "%s://%s:%s/ins" % (proto, host, port) - - def _error(self, msg, **kwargs): - self._nxapi_auth = None - if "url" not in kwargs: - kwargs["url"] = self._url - self._module.fail_json(msg=msg, **kwargs) - - def _request_builder(self, commands, output, version="1.0", chunk="0", sid=None): - """Encodes a NXAPI JSON request message""" - try: - command_type = self.OUTPUT_TO_COMMAND_TYPE[output] - except KeyError: - msg = "invalid format, received %s, expected one of %s" % ( - output, - ",".join(self.OUTPUT_TO_COMMAND_TYPE.keys()), - ) - self._error(msg=msg) - - if isinstance(commands, (list, set, tuple)): - commands = " ;".join(commands) - - # Order should not matter but some versions of NX-OS software fail - # to process the payload properly if 'input' gets serialized before - # 'type' and the payload of 'input' contains the word 'type'. - msg = collections.OrderedDict() - msg["version"] = version - msg["type"] = command_type - msg["chunk"] = chunk - msg["sid"] = sid - msg["input"] = commands - msg["output_format"] = "json" - - return dict(ins_api=msg) - - def send_request( - self, - commands, - output="text", - check_status=True, - return_error=False, - opts=None, - ): - # only 10 show commands can be encoded in each request - # messages sent to the remote device - if opts is None: - opts = {} - if output != "config": - commands = collections.deque(to_list(commands)) - stack = list() - requests = list() - - while commands: - stack.append(commands.popleft()) - if len(stack) == 10: - body = self._request_builder(stack, output) - data = self._module.jsonify(body) - requests.append(data) - stack = list() - - if stack: - body = self._request_builder(stack, output) - data = self._module.jsonify(body) - requests.append(data) - - else: - body = self._request_builder(commands, "config") - requests = [self._module.jsonify(body)] - - headers = {"Content-Type": "application/json"} - result = list() - timeout = self._module.params["provider"]["timeout"] - use_proxy = self._module.params["provider"]["use_proxy"] - - for req in requests: - if self._nxapi_auth: - headers["Cookie"] = self._nxapi_auth - - response, headers = fetch_url( - self._module, - self._url, - data=req, - headers=headers, - timeout=timeout, - method="POST", - use_proxy=use_proxy, - ) - self._nxapi_auth = headers.get("set-cookie") - - if opts.get("ignore_timeout") and re.search(r"(-1|5\d\d)", str(headers["status"])): - result.append(headers["status"]) - return result - elif headers["status"] != 200: - self._error(**headers) - - try: - response = self._module.from_json(response.read()) - except ValueError: - self._module.fail_json(msg="unable to parse response") - - if response["ins_api"].get("outputs"): - output = response["ins_api"]["outputs"]["output"] - for item in to_list(output): - if check_status is True and item["code"] != "200": - if return_error: - result.append(item) - else: - self._error(output=output, **item) - elif "body" in item: - result.append(item["body"]) - # else: - # error in command but since check_status is disabled - # silently drop it. - # result.append(item['msg']) - - return result - - def get_config(self, flags=None): - """Retrieves the current config from the device or cache""" - flags = [] if flags is None else flags - - cmd = "show running-config " - cmd += " ".join(flags) - cmd = cmd.strip() - - try: - return self._device_configs[cmd] - except KeyError: - out = self.send_request(cmd) - cfg = str(out[0]).strip() - self._device_configs[cmd] = cfg - return cfg - - def run_commands(self, commands, check_rc=True): - """Run list of commands on remote device and return results""" - output = None - queue = list() - responses = list() - - def _send(commands, output): - return self.send_request(commands, output, check_status=check_rc) - - for item in to_list(commands): - if is_json(item["command"]): - item["command"] = str(item["command"]).rsplit("|", 1)[0] - item["output"] = "json" - - if all((output == "json", item["output"] == "text")) or all( - (output == "text", item["output"] == "json"), - ): - responses.extend(_send(queue, output)) - queue = list() - - output = item["output"] or "json" - queue.append(item["command"]) - - if queue: - responses.extend(_send(queue, output)) - - return responses - - def load_config(self, commands, return_error=False, opts=None, replace=None): - """Sends the ordered set of commands to the device""" - - if opts is None: - opts = {} - - responses = [] - - if replace: - device_info = self.get_device_info() - if "9K" not in device_info.get("network_os_platform", ""): - self._module.fail_json(msg="replace is supported only on Nexus 9K devices") - commands = "config replace {0}".format(replace) - - commands = to_list(commands) - try: - resp = self.send_request( - commands, - output="config", - check_status=True, - return_error=return_error, - opts=opts, - ) - except ValueError as exc: - code = getattr(exc, "code", 1) - message = getattr(exc, "err", exc) - err = to_text(message, errors="surrogate_then_replace") - if opts.get("ignore_timeout") and code: - responses.append(code) - return responses - elif code and "no graceful-restart" in err: - if "ISSU/HA will be affected if Graceful Restart is disabled" in err: - msg = [""] - responses.extend(msg) - return responses - else: - self._module.fail_json(msg=err) - elif code: - self._module.fail_json(msg=err) - - if return_error: - return resp - else: - return responses.extend(resp) - - def get_diff( - self, - candidate=None, - running=None, - diff_match="line", - diff_ignore_lines=None, - path=None, - diff_replace="line", - ): - diff = {} - - # prepare candidate configuration - candidate_obj = NetworkConfig(indent=2) - candidate_obj.load(candidate) - - if running and diff_match != "none" and diff_replace != "config": - # running configuration - running_obj = NetworkConfig(indent=2, contents=running, ignore_lines=diff_ignore_lines) - configdiffobjs = candidate_obj.difference( - running_obj, - path=path, - match=diff_match, - replace=diff_replace, - ) - - else: - configdiffobjs = candidate_obj.items - - diff["config_diff"] = dumps(configdiffobjs, "commands") if configdiffobjs else "" - return diff - - def get_device_info(self): - device_info = {} - - device_info["network_os"] = "nxos" - reply = self.run_commands({"command": "show version", "output": "json"}) - data = reply[0] - - platform_reply = self.run_commands({"command": "show inventory", "output": "json"}) - platform_info = platform_reply[0] - - device_info["network_os_version"] = data.get("sys_ver_str") or data.get("kickstart_ver_str") - device_info["network_os_model"] = data["chassis_id"] - device_info["network_os_hostname"] = data["host_name"] - device_info["network_os_image"] = data.get("isan_file_name") or data.get("kick_file_name") - - if platform_info: - inventory_table = platform_info["TABLE_inv"]["ROW_inv"] - for info in inventory_table: - if "Chassis" in info["name"]: - device_info["network_os_platform"] = info["productid"] - - return device_info - - def get_capabilities(self): - result = {} - result["device_info"] = self.get_device_info() - result["network_api"] = "nxapi" - return result - - def read_module_context(self, module_key): - if self._module_context.get(module_key): - return self._module_context[module_key] - - return None - - def save_module_context(self, module_key, module_context): - self._module_context[module_key] = module_context - - return None - - class HttpApi: def __init__(self, module): self._module = module @@ -1237,23 +881,11 @@ def is_text(cmd): return not is_json(cmd) -def is_local_nxapi(module): - provider = module.params.get("provider") - if provider: - return provider.get("transport") == "nxapi" - return False - - def to_command(module, commands): - if is_local_nxapi(module): - default_output = "json" - else: - default_output = "text" - transform = ComplexList( dict( command=dict(key=True), - output=dict(default=default_output), + output=dict(type="str", default="text"), prompt=dict(type="list"), answer=dict(type="list"), newline=dict(type="bool", default=True), diff --git a/plugins/modules/nxos_aaa_server.py b/plugins/modules/nxos_aaa_server.py index ffdf7f826..9103f931f 100644 --- a/plugins/modules/nxos_aaa_server.py +++ b/plugins/modules/nxos_aaa_server.py @@ -129,7 +129,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -262,8 +261,6 @@ def main(): state=dict(choices=["default", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_aaa_server_host.py b/plugins/modules/nxos_aaa_server_host.py index 24eb5aeb3..d2f84f76d 100644 --- a/plugins/modules/nxos_aaa_server_host.py +++ b/plugins/modules/nxos_aaa_server_host.py @@ -154,7 +154,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, load_config, - nxos_argument_spec, run_commands, ) @@ -281,8 +280,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_banner.py b/plugins/modules/nxos_banner.py index 2655fa1fa..f946dc0ac 100644 --- a/plugins/modules/nxos_banner.py +++ b/plugins/modules/nxos_banner.py @@ -102,7 +102,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -185,8 +184,6 @@ def main(): state=dict(default="present", choices=["present", "absent"]), ) - argument_spec.update(nxos_argument_spec) - required_if = [("state", "present", ("text",))] module = AnsibleModule( diff --git a/plugins/modules/nxos_bfd_global.py b/plugins/modules/nxos_bfd_global.py index 4842446ed..6ae1a88da 100644 --- a/plugins/modules/nxos_bfd_global.py +++ b/plugins/modules/nxos_bfd_global.py @@ -142,7 +142,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( NxosCmdRef, load_config, - nxos_argument_spec, ) @@ -308,7 +307,6 @@ def main(): fabricpath_slow_timer=dict(required=False, type="int"), fabricpath_vlan=dict(required=False, type="int"), ) - argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_bgp.py b/plugins/modules/nxos_bgp.py index ba5612138..2c56f412e 100644 --- a/plugins/modules/nxos_bgp.py +++ b/plugins/modules/nxos_bgp.py @@ -287,7 +287,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -689,7 +688,6 @@ def main(): timer_bgp_keepalive=dict(required=False, type="str"), state=dict(choices=["present", "absent"], default="present", required=False), ) - argument_spec.update(nxos_argument_spec) module = AnsibleModule( argument_spec=argument_spec, diff --git a/plugins/modules/nxos_bgp_af.py b/plugins/modules/nxos_bgp_af.py index 94c247461..290f241dc 100644 --- a/plugins/modules/nxos_bgp_af.py +++ b/plugins/modules/nxos_bgp_af.py @@ -261,7 +261,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -791,8 +790,6 @@ def main(): retain_route_target=dict(required=False, type="str"), ) - argument_spec.update(nxos_argument_spec) - mutually_exclusive = [ ("dampening_state", "dampening_routemap"), ("dampening_state", "dampening_half_time"), diff --git a/plugins/modules/nxos_bgp_neighbor.py b/plugins/modules/nxos_bgp_neighbor.py index d87c2e405..2c5283caa 100644 --- a/plugins/modules/nxos_bgp_neighbor.py +++ b/plugins/modules/nxos_bgp_neighbor.py @@ -222,7 +222,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -507,7 +506,6 @@ def main(): choices=["disable", "fabric_border_leaf", "fabric_external"], ), ) - argument_spec.update(nxos_argument_spec) module = AnsibleModule( argument_spec=argument_spec, diff --git a/plugins/modules/nxos_bgp_neighbor_af.py b/plugins/modules/nxos_bgp_neighbor_af.py index 7d0912bbb..cc5624eef 100644 --- a/plugins/modules/nxos_bgp_neighbor_af.py +++ b/plugins/modules/nxos_bgp_neighbor_af.py @@ -281,7 +281,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -694,7 +693,6 @@ def main(): state=dict(choices=["present", "absent"], default="present", required=False), rewrite_evpn_rt_asn=dict(required=False, type="bool"), ) - argument_spec.update(nxos_argument_spec) module = AnsibleModule( argument_spec=argument_spec, diff --git a/plugins/modules/nxos_command.py b/plugins/modules/nxos_command.py index bcdbb8535..caf2a59d4 100644 --- a/plugins/modules/nxos_command.py +++ b/plugins/modules/nxos_command.py @@ -144,10 +144,7 @@ transform_commands, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, - run_commands, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import run_commands def parse_commands(module, warnings): @@ -183,8 +180,6 @@ def main(): interval=dict(default=1, type="int"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index 56274b2f9..a0cc2fd7b 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -336,7 +336,6 @@ get_config, get_connection, load_config, - nxos_argument_spec, run_commands, ) @@ -413,8 +412,6 @@ def main(): diff_ignore_lines=dict(type="list", elements="str"), ) - argument_spec.update(nxos_argument_spec) - mutually_exclusive = [("lines", "src", "replace_src"), ("parents", "src")] required_if = [ diff --git a/plugins/modules/nxos_evpn_global.py b/plugins/modules/nxos_evpn_global.py index 639bc658a..83ef78392 100644 --- a/plugins/modules/nxos_evpn_global.py +++ b/plugins/modules/nxos_evpn_global.py @@ -60,15 +60,12 @@ get_capabilities, get_config, load_config, - nxos_argument_spec, ) def main(): argument_spec = dict(nv_overlay_evpn=dict(required=True, type="bool")) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) result = {"changed": False} diff --git a/plugins/modules/nxos_evpn_vni.py b/plugins/modules/nxos_evpn_vni.py index a8fa99c5a..d4490bb7b 100644 --- a/plugins/modules/nxos_evpn_vni.py +++ b/plugins/modules/nxos_evpn_vni.py @@ -113,7 +113,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -256,8 +255,6 @@ def main(): state=dict(choices=["present", "absent"], default="present", required=False), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_facts.py b/plugins/modules/nxos_facts.py index 4b5bf2791..aa9b8b103 100644 --- a/plugins/modules/nxos_facts.py +++ b/plugins/modules/nxos_facts.py @@ -221,7 +221,6 @@ FACT_RESOURCE_SUBSETS, Facts, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_argument_spec def main(): @@ -231,7 +230,6 @@ def main(): :returns: ansible_facts """ argument_spec = FactsArgs.argument_spec - argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/plugins/modules/nxos_feature.py b/plugins/modules/nxos_feature.py index 48df234f3..c9229c4d5 100644 --- a/plugins/modules/nxos_feature.py +++ b/plugins/modules/nxos_feature.py @@ -85,7 +85,6 @@ get_capabilities, get_config, load_config, - nxos_argument_spec, run_commands, ) @@ -269,8 +268,6 @@ def main(): state=dict(choices=["enabled", "disabled"], default="enabled"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_file_copy.py b/plugins/modules/nxos_file_copy.py index 05dfb9c69..6f3051afe 100644 --- a/plugins/modules/nxos_file_copy.py +++ b/plugins/modules/nxos_file_copy.py @@ -234,8 +234,6 @@ get_resource_connection, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import nxos_argument_spec - class FileCopy: def __init__(self, module): @@ -471,8 +469,6 @@ def main(): remote_scp_server_password=dict(no_log=True), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, required_if=[("file_pull", True, ("remote_file", "remote_scp_server"))], diff --git a/plugins/modules/nxos_gir.py b/plugins/modules/nxos_gir.py index 6d0e0e82f..c473ff5ac 100644 --- a/plugins/modules/nxos_gir.py +++ b/plugins/modules/nxos_gir.py @@ -169,7 +169,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -291,8 +290,6 @@ def main(): state=dict(choices=["absent", "present"], default="present", required=False), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, mutually_exclusive=[ diff --git a/plugins/modules/nxos_gir_profile_management.py b/plugins/modules/nxos_gir_profile_management.py index 03cc5afef..84cfc1456 100644 --- a/plugins/modules/nxos_gir_profile_management.py +++ b/plugins/modules/nxos_gir_profile_management.py @@ -114,7 +114,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -171,8 +170,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_hsrp.py b/plugins/modules/nxos_hsrp.py index 3443e0259..73a969b0e 100644 --- a/plugins/modules/nxos_hsrp.py +++ b/plugins/modules/nxos_hsrp.py @@ -149,7 +149,6 @@ get_capabilities, get_interface_type, load_config, - nxos_argument_spec, run_commands, ) @@ -387,8 +386,6 @@ def main(): state=dict(choices=["absent", "present"], required=False, default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_igmp.py b/plugins/modules/nxos_igmp.py index 7e3a3d134..937706162 100644 --- a/plugins/modules/nxos_igmp.py +++ b/plugins/modules/nxos_igmp.py @@ -89,7 +89,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -117,8 +116,6 @@ def main(): state=dict(choices=["present", "default"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_igmp_interface.py b/plugins/modules/nxos_igmp_interface.py index a39d8e2c8..105dac5e6 100644 --- a/plugins/modules/nxos_igmp_interface.py +++ b/plugins/modules/nxos_igmp_interface.py @@ -196,7 +196,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_interface_type, load_config, - nxos_argument_spec, run_commands, ) @@ -502,7 +501,6 @@ def main(): state=dict(choices=["present", "absent", "default"], default="present"), ) - argument_spec.update(nxos_argument_spec) mutually_exclusive = [("oif_ps", "oif_routemap")] module = AnsibleModule( diff --git a/plugins/modules/nxos_igmp_snooping.py b/plugins/modules/nxos_igmp_snooping.py index 9a8c8e0ca..6d14ba17b 100644 --- a/plugins/modules/nxos_igmp_snooping.py +++ b/plugins/modules/nxos_igmp_snooping.py @@ -103,7 +103,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -263,8 +262,6 @@ def main(): state=dict(choices=["present", "default"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_install_os.py b/plugins/modules/nxos_install_os.py index 126577647..2327ab541 100644 --- a/plugins/modules/nxos_install_os.py +++ b/plugins/modules/nxos_install_os.py @@ -94,7 +94,6 @@ - name: Check installed OS for newly installed version nxos_command: commands: [show version | json] - provider: '{{ connection }}' register: output - assert: that: @@ -130,7 +129,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -565,8 +563,6 @@ def main(): issu=dict(choices=["required", "desired", "no", "yes"], default="no"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_logging.py b/plugins/modules/nxos_logging.py index 97b54f17a..7782eb32c 100644 --- a/plugins/modules/nxos_logging.py +++ b/plugins/modules/nxos_logging.py @@ -218,7 +218,6 @@ get_config, load_config, normalize_interface, - nxos_argument_spec, read_module_context, run_commands, save_module_context, @@ -895,8 +894,6 @@ def main(): purge=dict(default=False, type="bool"), ) - argument_spec.update(nxos_argument_spec) - required_if = [ ("dest", "logfile", ["name"]), ("dest", "server", ["remote_server"]), diff --git a/plugins/modules/nxos_ntp.py b/plugins/modules/nxos_ntp.py index 1ddc97374..046436d47 100644 --- a/plugins/modules/nxos_ntp.py +++ b/plugins/modules/nxos_ntp.py @@ -122,7 +122,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -331,8 +330,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, mutually_exclusive=[["server", "peer"], ["source_addr", "source_int"]], diff --git a/plugins/modules/nxos_ntp_auth.py b/plugins/modules/nxos_ntp_auth.py index e89afc585..3e5643812 100644 --- a/plugins/modules/nxos_ntp_auth.py +++ b/plugins/modules/nxos_ntp_auth.py @@ -107,7 +107,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -256,8 +255,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_ntp_options.py b/plugins/modules/nxos_ntp_options.py index c86659aa7..28fd1aac6 100644 --- a/plugins/modules/nxos_ntp_options.py +++ b/plugins/modules/nxos_ntp_options.py @@ -87,7 +87,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -119,8 +118,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_nxapi.py b/plugins/modules/nxos_nxapi.py index f0355a419..cfd7cc877 100644 --- a/plugins/modules/nxos_nxapi.py +++ b/plugins/modules/nxos_nxapi.py @@ -163,7 +163,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, load_config, - nxos_argument_spec, run_commands, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import Version @@ -394,8 +393,6 @@ def main(): tlsv1_2=dict(type="bool", default=False), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_overlay_global.py b/plugins/modules/nxos_overlay_global.py index 98ff8000f..70b25246a 100644 --- a/plugins/modules/nxos_overlay_global.py +++ b/plugins/modules/nxos_overlay_global.py @@ -67,7 +67,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -167,8 +166,6 @@ def normalize_mac(proposed_mac, module): def main(): argument_spec = dict(anycast_gateway_mac=dict(required=True, type="str")) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_pim.py b/plugins/modules/nxos_pim.py index 600700819..0475bfcde 100644 --- a/plugins/modules/nxos_pim.py +++ b/plugins/modules/nxos_pim.py @@ -87,7 +87,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -160,8 +159,6 @@ def main(): ssm_range=dict(required=False, type="list", default=[], elements="str"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() result = {"changed": False, "commands": [], "warnings": warnings} diff --git a/plugins/modules/nxos_pim_interface.py b/plugins/modules/nxos_pim_interface.py index e2c45fbb0..755f5c28b 100644 --- a/plugins/modules/nxos_pim_interface.py +++ b/plugins/modules/nxos_pim_interface.py @@ -174,7 +174,6 @@ get_config, get_interface_type, load_config, - nxos_argument_spec, run_commands, ) @@ -532,7 +531,6 @@ def main(): choices=["absent", "default", "present"], ), ) - argument_spec.update(nxos_argument_spec) required_by = {"hello_interval_ms": "hello_interval"} module = AnsibleModule( diff --git a/plugins/modules/nxos_pim_rp_address.py b/plugins/modules/nxos_pim_rp_address.py index 576d95d1e..df4c06d7d 100644 --- a/plugins/modules/nxos_pim_rp_address.py +++ b/plugins/modules/nxos_pim_rp_address.py @@ -92,7 +92,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -191,7 +190,6 @@ def main(): bidir=dict(required=False, type="bool"), state=dict(choices=["present", "absent"], default="present", required=False), ) - argument_spec.update(nxos_argument_spec) module = AnsibleModule( argument_spec=argument_spec, diff --git a/plugins/modules/nxos_ping.py b/plugins/modules/nxos_ping.py index 2e29dc3bf..31c8517a7 100644 --- a/plugins/modules/nxos_ping.py +++ b/plugins/modules/nxos_ping.py @@ -132,10 +132,7 @@ """ from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, - run_commands, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import run_commands def get_summary(results_list, reference_point): @@ -221,8 +218,6 @@ def main(): state=dict(required=False, choices=["present", "absent"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) destination = module.params["dest"] diff --git a/plugins/modules/nxos_reboot.py b/plugins/modules/nxos_reboot.py index dafaff33c..51d0d70af 100644 --- a/plugins/modules/nxos_reboot.py +++ b/plugins/modules/nxos_reboot.py @@ -60,10 +60,7 @@ from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - nxos_argument_spec, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import load_config def reboot(module): @@ -74,7 +71,6 @@ def reboot(module): def main(): argument_spec = dict(confirm=dict(default=False, type="bool")) - argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/plugins/modules/nxos_rollback.py b/plugins/modules/nxos_rollback.py index f06bc2f6b..4b26919d1 100644 --- a/plugins/modules/nxos_rollback.py +++ b/plugins/modules/nxos_rollback.py @@ -77,10 +77,7 @@ from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - nxos_argument_spec, - run_commands, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import run_commands def checkpoint(filename, module): @@ -104,8 +101,6 @@ def rollback(filename, module): def main(): argument_spec = dict(checkpoint_file=dict(required=False), rollback_to=dict(required=False)) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, mutually_exclusive=[["checkpoint_file", "rollback_to"]], diff --git a/plugins/modules/nxos_rpm.py b/plugins/modules/nxos_rpm.py index eedb4395b..7d7ab4db4 100644 --- a/plugins/modules/nxos_rpm.py +++ b/plugins/modules/nxos_rpm.py @@ -112,7 +112,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -345,8 +344,6 @@ def main(): argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) - required_one_of = [["pkg", "aggregate"]] mutually_exclusive = [["pkg", "aggregate"]] diff --git a/plugins/modules/nxos_snapshot.py b/plugins/modules/nxos_snapshot.py index c08304507..9697a1280 100644 --- a/plugins/modules/nxos_snapshot.py +++ b/plugins/modules/nxos_snapshot.py @@ -152,7 +152,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -345,8 +344,6 @@ def main(): path=dict(type="str", default="./"), ) - argument_spec.update(nxos_argument_spec) - required_if = [ ( "action", diff --git a/plugins/modules/nxos_snmp_community.py b/plugins/modules/nxos_snmp_community.py index 4406ab735..4e94b1f00 100644 --- a/plugins/modules/nxos_snmp_community.py +++ b/plugins/modules/nxos_snmp_community.py @@ -92,7 +92,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -189,8 +188,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, required_one_of=[["access", "group"]], diff --git a/plugins/modules/nxos_snmp_contact.py b/plugins/modules/nxos_snmp_contact.py index 5ab6b7ec1..49dbc8a83 100644 --- a/plugins/modules/nxos_snmp_contact.py +++ b/plugins/modules/nxos_snmp_contact.py @@ -78,7 +78,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -117,8 +116,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_snmp_host.py b/plugins/modules/nxos_snmp_host.py index 6a2f257a0..ed25502cf 100644 --- a/plugins/modules/nxos_snmp_host.py +++ b/plugins/modules/nxos_snmp_host.py @@ -129,7 +129,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -402,8 +401,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_snmp_location.py b/plugins/modules/nxos_snmp_location.py index bf7c7cac9..d7526a9ee 100644 --- a/plugins/modules/nxos_snmp_location.py +++ b/plugins/modules/nxos_snmp_location.py @@ -83,7 +83,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -122,8 +121,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_snmp_traps.py b/plugins/modules/nxos_snmp_traps.py index 54b04b13a..fce1a8a20 100644 --- a/plugins/modules/nxos_snmp_traps.py +++ b/plugins/modules/nxos_snmp_traps.py @@ -115,7 +115,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, load_config, - nxos_argument_spec, run_commands, ) @@ -292,8 +291,6 @@ def main(): ), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_snmp_user.py b/plugins/modules/nxos_snmp_user.py index 0ce4c094c..a3b0b5fa8 100644 --- a/plugins/modules/nxos_snmp_user.py +++ b/plugins/modules/nxos_snmp_user.py @@ -105,7 +105,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -312,8 +311,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, required_together=[["authentication", "pwd"], ["encrypt", "privacy"]], diff --git a/plugins/modules/nxos_system.py b/plugins/modules/nxos_system.py index a369fdd9b..df4bbde0d 100644 --- a/plugins/modules/nxos_system.py +++ b/plugins/modules/nxos_system.py @@ -131,7 +131,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -374,8 +373,6 @@ def main(): state=dict(default="present", choices=["present", "absent"]), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_udld.py b/plugins/modules/nxos_udld.py index 72b7148c5..83955e151 100644 --- a/plugins/modules/nxos_udld.py +++ b/plugins/modules/nxos_udld.py @@ -113,7 +113,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -197,8 +196,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_udld_interface.py b/plugins/modules/nxos_udld_interface.py index 6736e39ad..b78ed5c7a 100644 --- a/plugins/modules/nxos_udld_interface.py +++ b/plugins/modules/nxos_udld_interface.py @@ -123,7 +123,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( load_config, - nxos_argument_spec, run_commands, ) @@ -233,8 +232,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index 7e15c6969..83c22a765 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -55,8 +55,7 @@ configured_password: description: - The password to be configured on the network device. The password needs to be - provided in cleartext and it will be encrypted on the device. Please note that - this option is not same as C(provider password). + provided in cleartext and it will be encrypted on the device. type: str update_password: description: @@ -100,8 +99,7 @@ configured_password: description: - The password to be configured on the network device. The password needs to be - provided in cleartext and it will be encrypted on the device. Please note that - this option is not same as C(provider password). + provided in cleartext and it will be encrypted on the device. type: str update_password: description: @@ -192,7 +190,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, run_commands, ) @@ -425,7 +422,6 @@ def main(): ) argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) mutually_exclusive = [("name", "aggregate")] diff --git a/plugins/modules/nxos_vpc.py b/plugins/modules/nxos_vpc.py index 092d92ab9..bf2f45be1 100644 --- a/plugins/modules/nxos_vpc.py +++ b/plugins/modules/nxos_vpc.py @@ -161,7 +161,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, run_commands, ) @@ -370,8 +369,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - mutually_exclusive = [("auto_recovery", "auto_recovery_reload_delay")] module = AnsibleModule( argument_spec=argument_spec, diff --git a/plugins/modules/nxos_vpc_interface.py b/plugins/modules/nxos_vpc_interface.py index 620b45d3d..5e3184578 100644 --- a/plugins/modules/nxos_vpc_interface.py +++ b/plugins/modules/nxos_vpc_interface.py @@ -83,7 +83,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, run_commands, ) @@ -248,8 +247,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule( argument_spec=argument_spec, mutually_exclusive=[["vpc", "peer_link"]], diff --git a/plugins/modules/nxos_vrf.py b/plugins/modules/nxos_vrf.py index d7e4b83ab..1a73e7456 100644 --- a/plugins/modules/nxos_vrf.py +++ b/plugins/modules/nxos_vrf.py @@ -243,7 +243,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_interface_type, load_config, - nxos_argument_spec, run_commands, ) @@ -583,7 +582,6 @@ def main(): ) argument_spec.update(element_spec) - argument_spec.update(nxos_argument_spec) required_one_of = [["name", "aggregate"]] mutually_exclusive = [["name", "aggregate"]] diff --git a/plugins/modules/nxos_vrf_af.py b/plugins/modules/nxos_vrf_af.py index eb008c4b6..bf155ce8f 100644 --- a/plugins/modules/nxos_vrf_af.py +++ b/plugins/modules/nxos_vrf_af.py @@ -172,7 +172,6 @@ get_capabilities, get_config, load_config, - nxos_argument_spec, ) @@ -204,8 +203,6 @@ def main(): ), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vrf_interface.py b/plugins/modules/nxos_vrf_interface.py index 697d92d16..9e9a0cef2 100644 --- a/plugins/modules/nxos_vrf_interface.py +++ b/plugins/modules/nxos_vrf_interface.py @@ -91,7 +91,6 @@ get_interface_type, load_config, normalize_interface, - nxos_argument_spec, run_commands, ) @@ -185,8 +184,6 @@ def main(): state=dict(default="present", choices=["present", "absent"], required=False), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vrrp.py b/plugins/modules/nxos_vrrp.py index 6a7d44b6f..665e450ed 100644 --- a/plugins/modules/nxos_vrrp.py +++ b/plugins/modules/nxos_vrrp.py @@ -130,7 +130,6 @@ get_capabilities, get_interface_type, load_config, - nxos_argument_spec, run_commands, ) @@ -350,8 +349,6 @@ def main(): authentication=dict(required=False, type="str", no_log=True), state=dict(choices=["absent", "present"], required=False, default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vtp_domain.py b/plugins/modules/nxos_vtp_domain.py index 3e6d9a08c..d1e3c39fd 100644 --- a/plugins/modules/nxos_vtp_domain.py +++ b/plugins/modules/nxos_vtp_domain.py @@ -97,7 +97,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, load_config, - nxos_argument_spec, run_commands, ) @@ -171,8 +170,6 @@ def get_vtp_password(module): def main(): argument_spec = dict(domain=dict(type="str", required=True)) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vtp_password.py b/plugins/modules/nxos_vtp_password.py index 0d0ee64d5..c6e9cabdb 100644 --- a/plugins/modules/nxos_vtp_password.py +++ b/plugins/modules/nxos_vtp_password.py @@ -110,7 +110,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, load_config, - nxos_argument_spec, run_commands, ) @@ -201,8 +200,6 @@ def main(): state=dict(choices=["absent", "present"], default="present"), ) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vtp_version.py b/plugins/modules/nxos_vtp_version.py index ef2b0d525..8c5305a08 100644 --- a/plugins/modules/nxos_vtp_version.py +++ b/plugins/modules/nxos_vtp_version.py @@ -92,7 +92,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_capabilities, load_config, - nxos_argument_spec, run_commands, ) @@ -166,8 +165,6 @@ def get_vtp_password(module): def main(): argument_spec = dict(version=dict(type="str", choices=["1", "2"], required=True)) - argument_spec.update(nxos_argument_spec) - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() diff --git a/plugins/modules/nxos_vxlan_vtep.py b/plugins/modules/nxos_vxlan_vtep.py index da43cc82b..ce3113883 100644 --- a/plugins/modules/nxos_vxlan_vtep.py +++ b/plugins/modules/nxos_vxlan_vtep.py @@ -137,7 +137,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, run_commands, ) @@ -401,8 +400,6 @@ def main(): multisite_border_gateway_interface=dict(required=False, type="str"), ) - argument_spec.update(nxos_argument_spec) - mutually_exclusive = [("global_ingress_replication_bgp", "global_mcast_group_L2")] module = AnsibleModule( diff --git a/plugins/modules/nxos_vxlan_vtep_vni.py b/plugins/modules/nxos_vxlan_vtep_vni.py index 862615e7f..d58bd6c95 100644 --- a/plugins/modules/nxos_vxlan_vtep_vni.py +++ b/plugins/modules/nxos_vxlan_vtep_vni.py @@ -123,7 +123,6 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( get_config, load_config, - nxos_argument_spec, ) @@ -359,8 +358,6 @@ def main(): ), ) - argument_spec.update(nxos_argument_spec) - mutually_exclusive = [ ("suppress_arp", "suppress_arp_disable"), ("assoc_vrf", "multicast_group"), diff --git a/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml b/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml index 1916114b1..5e81ff9be 100644 --- a/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml @@ -9,7 +9,6 @@ enable_http: false enable_sandbox: false https_port: 9443 - provider: "{{ nxapi }}" - ansible.builtin.assert: that: diff --git a/tests/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml b/tests/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml index ed47994b4..e26c0c131 100644 --- a/tests/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml +++ b/tests/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml @@ -6,6 +6,5 @@ - name: Test that provider values are properly ignored cisco.nxos.nxos_command: commands: show version - provider: "{{ nxapi }}" when: "ansible_connection != 'local'" diff --git a/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml b/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml index 916fc90a8..29c9ea8c8 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/common_config.yaml @@ -6,9 +6,6 @@ # Select interface for test - ansible.builtin.debug: msg: START connection={{ ansible_connection }} common/common_config.yaml -- ansible.builtin.debug: - msg: Using provider={{ connection.transport }} - when: ansible_connection == "local" - name: Set a fact for 'intname' ansible.builtin.set_fact: @@ -22,7 +19,6 @@ parents: - "interface {{ intname }}" match: none - provider: "{{ connection }}" - name: Collect any backup files ansible.builtin.find: &backups @@ -45,7 +41,6 @@ parents: - "interface {{ intname }}" backup: true - provider: "{{ connection }}" register: result - ansible.builtin.assert: @@ -66,7 +61,6 @@ - name: Setup cisco.nxos.nxos_config: &clear lines: no ip access-list test - provider: "{{ connection }}" match: none ignore_errors: true @@ -80,7 +74,6 @@ - 40 permit ip 192.0.2.4/32 any log parents: ip access-list test replace: block - provider: "{{ connection }}" match: exact register: result @@ -103,7 +96,6 @@ - 40 permit ip 192.0.2.4/32 any log parents: ip access-list test replace: block - provider: "{{ connection }}" match: strict register: result diff --git a/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml b/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml index 6a496d0f3..9472c65c7 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/common_utils.yaml @@ -4,28 +4,22 @@ - ansible.builtin.debug: msg: START connection={{ ansible_connection }} common/common_utils.yaml -- ansible.builtin.debug: - msg: Using provider={{ connection.transport }} - when: ansible_connection == "local" # hit ComplexList - name: Test contains operator cisco.nxos.nxos_command: commands: - show version - provider: "{{ connection }}" # hit to_list() - name: Setup cisco.nxos.nxos_config: lines: hostname switch - provider: "{{ connection }}" match: none - name: Configure top level command cisco.nxos.nxos_config: lines: hostname foo - provider: "{{ connection }}" register: result - ansible.builtin.assert: @@ -36,7 +30,6 @@ - name: Setup cisco.nxos.nxos_config: lines: hostname switch - provider: "{{ connection }}" match: none # hit conditional() @@ -52,7 +45,6 @@ lines: - "default interface {{ testint1 }}" - "default interface {{ testint2 }}" - provider: "{{ connection }}" ignore_errors: true register: result @@ -62,5 +54,4 @@ lines: - "default interface {{ testint1 }}" - "default interface {{ testint2 }}" - provider: "{{ connection }}" ignore_errors: true diff --git a/tests/integration/targets/nxos_smoke/tests/common/misc_tests.yaml b/tests/integration/targets/nxos_smoke/tests/common/misc_tests.yaml index 85f3f39bf..d1f2c4414 100644 --- a/tests/integration/targets/nxos_smoke/tests/common/misc_tests.yaml +++ b/tests/integration/targets/nxos_smoke/tests/common/misc_tests.yaml @@ -1,9 +1,6 @@ --- - ansible.builtin.debug: msg: START connection={{ ansible_connection }} common/misc_tests.yaml -- ansible.builtin.debug: - msg: Using provider={{ connection.transport }} - when: ansible_connection == "local" - name: Hit conditional for lists of 10 or more commands cisco.nxos.nxos_command: @@ -18,7 +15,6 @@ - show hostname - show hostname - show hostname - provider: "{{ connection }}" register: result - ansible.builtin.assert: @@ -29,4 +25,3 @@ cisco.nxos.nxos_command: commands: - show hostname - provider: "{{ connection | combine({'timeout': 500}) }}" diff --git a/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml b/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml index 86c1609d0..c4ef8c1ca 100644 --- a/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_vrf/tests/common/sanity.yaml @@ -42,7 +42,6 @@ cisco.nxos.nxos_config: commands: - nv overlay evpn - provider: "{{ connection }}" - block: - name: Ensure NTC VRF exists on switch @@ -112,7 +111,6 @@ cisco.nxos.nxos_config: commands: - no nv overlay evpn - provider: "{{ connection }}" - name: Disable 'feature bgp' ignore_errors: true diff --git a/tests/unit/modules/network/nxos/nxos_module.py b/tests/unit/modules/network/nxos/nxos_module.py index 851cb9545..b6271c609 100644 --- a/tests/unit/modules/network/nxos/nxos_module.py +++ b/tests/unit/modules/network/nxos/nxos_module.py @@ -35,9 +35,6 @@ def set_module_args(args, ignore_provider=None): - if "provider" not in args and not ignore_provider: - args["provider"] = {"transport": args.get("transport") or "cli"} - return _set_module_args(args) From 3c683be6aa1079608bb5ecae300a4c75f908b7bd Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 13 Oct 2022 18:06:08 +0530 Subject: [PATCH 044/166] Prepare for release v4.0.0 (#579) * Prepare 4.0.0 Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC Signed-off-by: NilashishC --- CHANGELOG.rst | 27 +++++++++++++++++ changelogs/changelog.yaml | 32 +++++++++++++++++--- changelogs/fragments/remove_deprecated.yaml | 17 ----------- changelogs/fragments/remove_net_changes.yaml | 3 -- changelogs/fragments/remove_provider.yaml | 4 --- 5 files changed, 55 insertions(+), 28 deletions(-) delete mode 100644 changelogs/fragments/remove_deprecated.yaml delete mode 100644 changelogs/fragments/remove_net_changes.yaml delete mode 100644 changelogs/fragments/remove_provider.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ff72437e9..5df4c145c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,33 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v4.0.0 +====== + +Major Changes +------------- + +- Please use either of the following connection types - network_cli, httpapi or netconf. +- This release drops support for `connection: local` and provider dictionary. + +Removed Features (previously deprecated) +---------------------------------------- + +- This release removes the following deprecated plugins that have reached their end-of-life. +- nxos_acl +- nxos_acl_interface +- nxos_interface +- nxos_interface_ospf +- nxos_l2_interface +- nxos_l3_interface +- nxos_linkagg +- nxos_lldp +- nxos_ospf +- nxos_ospf_vrf +- nxos_smu +- nxos_static_route +- nxos_vlan + v3.2.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 84c4e67ce..7e668500c 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -474,7 +474,7 @@ releases: and `ansible_network_import_modules`. - "Please refer to ansible.netcommon - `changelog ` + `changelog `_ for more details." minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). @@ -723,9 +723,7 @@ releases: release_summary: "The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains - an additional bug fix. - - " + an additional bug fix." fragments: - ignore.yaml - nxos_ntp.yaml @@ -883,3 +881,29 @@ releases: - passwd_lookup.yaml - telemetry.yaml release_date: "2022-10-12" + 4.0.0: + changes: + major_changes: + - Please use either of the following connection types - network_cli, httpapi + or netconf. + - "This release drops support for `connection: local` and provider dictionary." + removed_features: + - This release removes the following deprecated plugins that have reached their end-of-life. + - nxos_acl + - nxos_acl_interface + - nxos_interface + - nxos_interface_ospf + - nxos_l2_interface + - nxos_l3_interface + - nxos_linkagg + - nxos_lldp + - nxos_ospf + - nxos_ospf_vrf + - nxos_smu + - nxos_static_route + - nxos_vlan + fragments: + - remove_deprecated.yaml + - remove_net_changes.yaml + - remove_provider.yaml + release_date: "2022-10-13" diff --git a/changelogs/fragments/remove_deprecated.yaml b/changelogs/fragments/remove_deprecated.yaml deleted file mode 100644 index 36d9e5668..000000000 --- a/changelogs/fragments/remove_deprecated.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -removed_features: - - "This release removes all deprecated plugins that have reached their end-of-life." - - "This includes the following modules:" - - "nxos_acl" - - "nxos_acl_interface" - - "nxos_interface" - - "nxos_interface_ospf" - - "nxos_l2_interface" - - "nxos_l3_interface" - - "nxos_linkagg" - - "nxos_lldp" - - "nxos_ospf" - - "nxos_ospf_vrf" - - "nxos_smu" - - "nxos_static_route" - - "nxos_vlan" diff --git a/changelogs/fragments/remove_net_changes.yaml b/changelogs/fragments/remove_net_changes.yaml deleted file mode 100644 index 4f5a4a2a8..000000000 --- a/changelogs/fragments/remove_net_changes.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Remove tests for to-be-removed net_* modules. (https://github.com/ansible-collections/ansible.netcommon/pull/458) diff --git a/changelogs/fragments/remove_provider.yaml b/changelogs/fragments/remove_provider.yaml deleted file mode 100644 index 2e3a010ba..000000000 --- a/changelogs/fragments/remove_provider.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -major_changes: - - "This release drops support for `connection: local` and provider dictionary." - - "Please use either of the following connection types - network_cli, httpapi or netconf." From 79eb1bcf0be9afe7e5cf94183a0b074a238cc376 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 30 Oct 2022 22:21:34 +0530 Subject: [PATCH 045/166] [pre-commit.ci] pre-commit autoupdate (#580) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.1 → v3.0.0-alpha.3](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.1...v3.0.0-alpha.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95ab26318..2626a68c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.1" + rev: "v3.0.0-alpha.3" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described From 4c884a2dfb42c4104ea2b7a7a219a88f98add4ea Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 18:36:15 +0530 Subject: [PATCH 046/166] [pre-commit.ci] pre-commit autoupdate (#582) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.3 → v3.0.0-alpha.4](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2626a68c1..376512faa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.3" + rev: "v3.0.0-alpha.4" hooks: - id: prettier # Original hook implementation is flaky due to *several* bugs described From 9ff3c1d9c8534dd16efb5db6953fb0669b4d8a1c Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 10 Nov 2022 19:54:49 +0530 Subject: [PATCH 047/166] Fix sanity failure (#588) Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/nxos_pim.yaml | 3 +++ docs/cisco.nxos.nxos_pim_module.rst | 1 + plugins/modules/nxos_pim.py | 1 + 3 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/nxos_pim.yaml diff --git a/changelogs/fragments/nxos_pim.yaml b/changelogs/fragments/nxos_pim.yaml new file mode 100644 index 000000000..4a5c1ab1a --- /dev/null +++ b/changelogs/fragments/nxos_pim.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - "`nxos_pim` - Fix sanity failures." diff --git a/docs/cisco.nxos.nxos_pim_module.rst b/docs/cisco.nxos.nxos_pim_module.rst index 056a41699..e19eee567 100644 --- a/docs/cisco.nxos.nxos_pim_module.rst +++ b/docs/cisco.nxos.nxos_pim_module.rst @@ -64,6 +64,7 @@ Parameters
+ Default:
[]
Configure group ranges for Source Specific Multicast (SSM). Valid values are multicast addresses or the keyword none or keyword default. none removes all SSM group ranges. default will set ssm_range to the default multicast address. If you set multicast address, please ensure that it is not the same as the default, otherwise use the default option.
diff --git a/plugins/modules/nxos_pim.py b/plugins/modules/nxos_pim.py index 0475bfcde..d9fc6f469 100644 --- a/plugins/modules/nxos_pim.py +++ b/plugins/modules/nxos_pim.py @@ -49,6 +49,7 @@ address. If you set multicast address, please ensure that it is not the same as the C(default), otherwise use the C(default) option. type: list + default: [] elements: str """ EXAMPLES = """ From c1128ca9391d4eb5119906b4f822c15b082f918f Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 14 Nov 2022 10:55:07 +0530 Subject: [PATCH 048/166] [acls] Fix port_protocol parsing and ICMP options (#587) * [acls] Fix port_protocol parsing and ICMP options Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC * Update changelog Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/nxos_acls.yaml | 5 +++ .../network/nxos/facts/acls/acls.py | 12 ++++-- .../modules/network/nxos/test_nxos_acls.py | 43 +++++++++++++++++-- 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/nxos_acls.yaml diff --git a/changelogs/fragments/nxos_acls.yaml b/changelogs/fragments/nxos_acls.yaml new file mode 100644 index 000000000..d92880dda --- /dev/null +++ b/changelogs/fragments/nxos_acls.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: + - "`nxos_acls` - Parse ICMP echo-reply and echo options correctly (https://github.com/ansible-collections/cisco.nxos/issues/583)." + - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly (https://github.com/ansible-collections/cisco.nxos/issues/529)." + - "`nxos_acls` - Parse port-protocol options with hypenated names correctly (https://github.com/ansible-collections/cisco.nxos/issues/557)." diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index 8440fdb17..b6ddecc4e 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -111,7 +111,7 @@ def get_endpoint(self, ace, pro): keywords = ["eq", "lt", "gt", "neq", "range"] if len(ace.split()) and ace.split()[0] in keywords: port_protocol = {} - port_pro = re.search(r"(eq|lt|gt|neq) (\w*)", ace) + port_pro = re.search(r"(eq|lt|gt|neq) (\S+)", ace) if port_pro: port_protocol.update({port_pro.group(1): port_pro.group(2)}) ace = re.sub(port_pro.group(1), "", ace, 1) @@ -153,8 +153,8 @@ def render_config(self, spec, conf): "dod_host_prohibited", "dod_net_prohibited", "echo_request", - "echo", "echo_reply", + "echo", "general_parameter_problem", "host_isolated", "host_precedence_unreachable", @@ -180,6 +180,7 @@ def render_config(self, spec, conf): "port_unreachable", "precedence_unreachable", "protocol_unreachable", + "unreachable", "reassembly_timeout", "redirect", "router_advertisement", @@ -191,7 +192,6 @@ def render_config(self, spec, conf): "timestamp_request", "traceroute", "ttl_exceeded", - "unreachable", ], "igmp": ["dvmrp", "host_query", "host_report"], } @@ -261,7 +261,11 @@ def render_config(self, spec, conf): for option in protocol_options[pro]: option = re.sub("_", "-", option) if option in ace: - if option == "echo" and "echo_request" in options: + if option == "echo" and ( + "echo_request" in options or "echo_reply" in options + ): + continue + elif option == "unreachable" and "port_unreachable" in options: continue option = re.sub("-", "_", option) options.update({option: True}) diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index 258c5a070..86f50a949 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -632,7 +632,9 @@ def test_nxos_acls_parse_remark(self): """\ ip access-list TEST_RESEQUENCE 10 permit ip 10.0.0.0/24 any - 20 deny udp any any eq domain + 20 deny tcp any eq ftp-data any eq domain + 25 permit icmp any any echo-reply + 27 permit icmp any any port-unreachable 30 remark for resetting to default run resequence ip access-list TEST_RESEQUENCE 2 3 ipv6 access-list TEST_RESEQUENCE_ipv6 10 permit udp any any @@ -686,13 +688,48 @@ def test_nxos_acls_parse_remark(self): { "sequence": 20, "grant": "deny", - "protocol": "udp", - "source": {"any": True}, + "protocol": "tcp", + "source": { + "any": True, + "port_protocol": {"eq": "ftp-data"}, + }, "destination": { "any": True, "port_protocol": {"eq": "domain"}, }, }, + { + "sequence": 25, + "grant": "permit", + "protocol": "icmp", + "protocol_options": { + "icmp": { + "echo_reply": True, + }, + }, + "source": { + "any": True, + }, + "destination": { + "any": True, + }, + }, + { + "sequence": 27, + "grant": "permit", + "protocol": "icmp", + "protocol_options": { + "icmp": { + "port_unreachable": True, + }, + }, + "source": { + "any": True, + }, + "destination": { + "any": True, + }, + }, { "sequence": 30, "remark": "for resetting to default run resequence ip access-list TEST_RESEQUENCE 2 3", From e1e84cff6a0e404f8ba64cc2df667019a8f54ae3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Nov 2022 11:15:53 +0530 Subject: [PATCH 049/166] [pre-commit.ci] pre-commit autoupdate (#590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/ansible-network/collection_prep: 1.0.0 → 1.0.1](https://github.com/ansible-network/collection_prep/compare/1.0.0...1.0.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 376512faa..9a19276ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,6 @@ repos: - id: black - repo: https://github.com/ansible-network/collection_prep - rev: 1.0.0 + rev: 1.0.1 hooks: - id: update-docs From 9a46049a89c91c05d6651f9b9655ecb1e5082608 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 14:44:56 +0530 Subject: [PATCH 050/166] [pre-commit.ci] pre-commit autoupdate (#592) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a19276ab..03659556e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-merge-conflict - id: check-symlinks From f33d5a0c89af1935dfdd48d49e1852ac9c672a49 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 30 Nov 2022 19:24:42 +0530 Subject: [PATCH 051/166] Prepare for v4.0.1 (#594) * Prepare for v4.0.1 Signed-off-by: NilashishC * Revert redundant changes Signed-off-by: NilashishC Signed-off-by: NilashishC --- CHANGELOG.rst | 11 ++++++++++- changelogs/changelog.yaml | 12 ++++++++++++ changelogs/fragments/nxos_acls.yaml | 5 ----- changelogs/fragments/nxos_pim.yaml | 3 --- 4 files changed, 22 insertions(+), 9 deletions(-) delete mode 100644 changelogs/fragments/nxos_acls.yaml delete mode 100644 changelogs/fragments/nxos_pim.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5df4c145c..efafff9c5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,16 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v4.0.1 +====== + +Bugfixes +-------- + +- `nxos_acls` - Parse ICMP echo-reply and echo options correctly (https://github.com/ansible-collections/cisco.nxos/issues/583). +- `nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly (https://github.com/ansible-collections/cisco.nxos/issues/529). +- `nxos_acls` - Parse port-protocol options with hypenated names correctly (https://github.com/ansible-collections/cisco.nxos/issues/557). + v4.0.0 ====== @@ -151,7 +161,6 @@ Release Summary The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains an additional bug fix. - Bugfixes -------- diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 7e668500c..4999116f1 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -907,3 +907,15 @@ releases: - remove_net_changes.yaml - remove_provider.yaml release_date: "2022-10-13" + 4.0.1: + changes: + bugfixes: + - "`nxos_acls` - Parse ICMP echo-reply and echo options correctly (https://github.com/ansible-collections/cisco.nxos/issues/583)." + - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly + (https://github.com/ansible-collections/cisco.nxos/issues/529)." + - "`nxos_acls` - Parse port-protocol options with hypenated names correctly + (https://github.com/ansible-collections/cisco.nxos/issues/557)." + fragments: + - nxos_acls.yaml + - nxos_pim.yaml + release_date: "2022-11-30" diff --git a/changelogs/fragments/nxos_acls.yaml b/changelogs/fragments/nxos_acls.yaml deleted file mode 100644 index d92880dda..000000000 --- a/changelogs/fragments/nxos_acls.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -bugfixes: - - "`nxos_acls` - Parse ICMP echo-reply and echo options correctly (https://github.com/ansible-collections/cisco.nxos/issues/583)." - - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly (https://github.com/ansible-collections/cisco.nxos/issues/529)." - - "`nxos_acls` - Parse port-protocol options with hypenated names correctly (https://github.com/ansible-collections/cisco.nxos/issues/557)." diff --git a/changelogs/fragments/nxos_pim.yaml b/changelogs/fragments/nxos_pim.yaml deleted file mode 100644 index 4a5c1ab1a..000000000 --- a/changelogs/fragments/nxos_pim.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - "`nxos_pim` - Fix sanity failures." From 129beecbcf44281c8f2a916b2fa8d8985f554850 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 18:23:38 +0530 Subject: [PATCH 052/166] [pre-commit.ci] pre-commit autoupdate (#599) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v2.3.0 → v2.4.0](https://github.com/asottile/add-trailing-comma/compare/v2.3.0...v2.4.0) - [github.com/PyCQA/isort: 5.10.1 → 5.11.1](https://github.com/PyCQA/isort/compare/5.10.1...5.11.1) - [github.com/psf/black: 22.10.0 → 22.12.0](https://github.com/psf/black/compare/22.10.0...22.12.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03659556e..edc5e1587 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v2.3.0 + rev: v2.4.0 hooks: - id: add-trailing-comma @@ -42,13 +42,13 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.1 hooks: - id: isort name: Sort import statements using isort - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black From 1406773e7585c29357d647714d92851aad4cef18 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 21 Dec 2022 18:27:38 +0530 Subject: [PATCH 053/166] [pre-commit.ci] pre-commit autoupdate (#601) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/isort: 5.11.1 → v5.11.3](https://github.com/PyCQA/isort/compare/5.11.1...v5.11.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index edc5e1587..cde2ead6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: 5.11.1 + rev: v5.11.3 hooks: - id: isort name: Sort import statements using isort From c8c492c5b22b8df834a826e7ebe51b2de33f13ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Dec 2022 21:54:49 +0530 Subject: [PATCH 054/166] [pre-commit.ci] pre-commit autoupdate (#603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/isort: v5.11.3 → 5.11.4](https://github.com/PyCQA/isort/compare/v5.11.3...5.11.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cde2ead6d..4975fbc38 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: v5.11.3 + rev: 5.11.4 hooks: - id: isort name: Sort import statements using isort From b05bf9ffee143f6bb6437deaa6e3e011d055ff1f Mon Sep 17 00:00:00 2001 From: Kate Case Date: Mon, 9 Jan 2023 14:46:33 -0500 Subject: [PATCH 055/166] Redirect ResourceModule to new location (#602) * Redirect ResourceModule to new location --- changelogs/fragments/rm_base.yaml | 5 +++++ .../nxos/config/bgp_address_family/bgp_address_family.py | 2 +- .../network/nxos/config/bgp_global/bgp_global.py | 2 +- .../bgp_neighbor_address_family.py | 2 +- .../network/nxos/config/ospf_interfaces/ospf_interfaces.py | 2 +- plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py | 2 +- plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py | 2 +- .../network/nxos/config/route_maps/route_maps.py | 2 +- .../network/nxos/rm_templates/bgp_address_family.py | 2 +- plugins/module_utils/network/nxos/rm_templates/bgp_global.py | 2 +- .../network/nxos/rm_templates/bgp_neighbor_address_family.py | 2 +- .../network/nxos/rm_templates/ospf_interfaces.py | 2 +- plugins/module_utils/network/nxos/rm_templates/ospfv2.py | 2 +- plugins/module_utils/network/nxos/rm_templates/ospfv3.py | 2 +- plugins/module_utils/network/nxos/rm_templates/route_maps.py | 2 +- 15 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/rm_base.yaml diff --git a/changelogs/fragments/rm_base.yaml b/changelogs/fragments/rm_base.yaml new file mode 100644 index 000000000..a2d02d495 --- /dev/null +++ b/changelogs/fragments/rm_base.yaml @@ -0,0 +1,5 @@ +--- +trivial: + - Move references for ResourceModule to the rm_base package as the + non-rm_base path is going away. + (https://github.com/ansible-collections/ansible.netcommon/pull/496) diff --git a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py index 4de52705b..d7a276677 100644 --- a/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_address_family/bgp_address_family.py @@ -23,7 +23,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py index c174d790d..e8bc70bc2 100644 --- a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py @@ -21,7 +21,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py index f553e6e7c..96902987d 100644 --- a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -20,7 +20,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py index 5897c7f50..7be8d5ff0 100644 --- a/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/config/ospf_interfaces/ospf_interfaces.py @@ -21,7 +21,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py b/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py index d90a806df..e84fc2e8d 100644 --- a/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/nxos/config/ospfv2/ospfv2.py @@ -18,7 +18,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py b/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py index 663326a6c..45e55c9d0 100644 --- a/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/nxos/config/ospfv3/ospfv3.py @@ -21,7 +21,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index 28881745f..a1b9b2173 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -21,7 +21,7 @@ from copy import deepcopy from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py index ef98c5968..942e993e3 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_address_family.py @@ -17,7 +17,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py index 7a5454fb2..fa99397a5 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py @@ -17,7 +17,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py index 9a00cbbf9..327ba4d23 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py @@ -17,7 +17,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py b/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py index aa01db1d7..2321fcaf1 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospf_interfaces.py @@ -17,7 +17,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/plugins/module_utils/network/nxos/rm_templates/ospfv2.py b/plugins/module_utils/network/nxos/rm_templates/ospfv2.py index 9d6600996..c8b518dd6 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospfv2.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospfv2.py @@ -5,7 +5,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/plugins/module_utils/network/nxos/rm_templates/ospfv3.py b/plugins/module_utils/network/nxos/rm_templates/ospfv3.py index 6c9c78b8f..b46c3cf4e 100644 --- a/plugins/module_utils/network/nxos/rm_templates/ospfv3.py +++ b/plugins/module_utils/network/nxos/rm_templates/ospfv3.py @@ -17,7 +17,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index dfbfc88e9..8267a905c 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -17,7 +17,7 @@ import re -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) From 05e71bb2f4901b6e5d8e39b51e0d00cd0caf0561 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 12 Jan 2023 19:30:49 +0530 Subject: [PATCH 056/166] [snmp_server] test updates (#608) * [snmp_server] test updates Signed-off-by: NilashishC * Updates Signed-off-by: NilashishC Signed-off-by: NilashishC --- changelogs/fragments/nxos_snmp_revert.yaml | 3 +++ .../targets/nxos_snmp_server/tasks/main.yaml | 8 ++++++ .../tests/common/overridden.yaml | 10 +++++++ .../tests/common/replaced.yaml | 10 +++++++ .../targets/nxos_snmp_server/vars/main.yml | 26 +++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 changelogs/fragments/nxos_snmp_revert.yaml diff --git a/changelogs/fragments/nxos_snmp_revert.yaml b/changelogs/fragments/nxos_snmp_revert.yaml new file mode 100644 index 000000000..145331cf7 --- /dev/null +++ b/changelogs/fragments/nxos_snmp_revert.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Update nxos_snmp_server tests for CI. diff --git a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index 29d07397d..cb885dee9 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -30,6 +30,14 @@ ansible.builtin.set_fact: admin_snmp_engineid_2: "{{ admin_snmp_engineid_2[0] }}" +- name: Grep zuul user SNMP localized key + ansible.builtin.set_fact: + zuul_snmp_passwd: "{{ result['stdout'][0] | regex_search('zuul network-admin auth (md5|sha) (\\S+)', '\\2') }}" + +- name: Find zuul user SNMP localized key + ansible.builtin.set_fact: + zuul_snmp_passwd: "{{ zuul_snmp_passwd[0] }}" + - name: Include the CLI tasks ansible.builtin.include_tasks: cli.yaml tags: diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/overridden.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/overridden.yaml index 47ab9d666..7438475a7 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/overridden.yaml @@ -69,6 +69,16 @@ priv: privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" aes_128: true + + - authentication: + algorithm: md5 + localized_key: true + password: "{{ zuul_snmp_passwd }}" + priv: + privacy_password: "{{ zuul_snmp_passwd }}" + group: network-admin + user: zuul + use_acls: - user: snmp_user_1 ipv4: acl1 diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/replaced.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/replaced.yaml index 35b492296..590657d96 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/replaced.yaml @@ -69,6 +69,16 @@ priv: privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" aes_128: true + + - authentication: + algorithm: md5 + localized_key: true + password: "{{ zuul_snmp_passwd }}" + priv: + privacy_password: "{{ zuul_snmp_passwd }}" + group: network-admin + user: zuul + use_acls: - user: snmp_user_1 ipv4: acl1 diff --git a/tests/integration/targets/nxos_snmp_server/vars/main.yml b/tests/integration/targets/nxos_snmp_server/vars/main.yml index fb04c030f..33b13d451 100644 --- a/tests/integration/targets/nxos_snmp_server/vars/main.yml +++ b/tests/integration/targets/nxos_snmp_server/vars/main.yml @@ -19,6 +19,14 @@ merged: priv: privacy_password: "{{ admin_snmp_passwd_2 }}" user: admin + - authentication: + algorithm: md5 + localized_key: true + password: "{{ zuul_snmp_passwd }}" + priv: + privacy_password: "{{ zuul_snmp_passwd }}" + group: network-admin + user: zuul commands: - snmp-server contact nxosswitchadmin@localhost - snmp-server location serverroom-1 @@ -93,6 +101,14 @@ merged: privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" group: network-operator user: snmp_user_2 + - authentication: + algorithm: md5 + localized_key: true + password: "{{ zuul_snmp_passwd }}" + priv: + privacy_password: "{{ zuul_snmp_passwd }}" + group: network-admin + user: zuul use_acls: - ipv4: acl1 ipv6: acl2 @@ -171,6 +187,16 @@ replaced: priv: privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" aes_128: true + + - authentication: + algorithm: md5 + localized_key: true + password: "{{ zuul_snmp_passwd }}" + priv: + privacy_password: "{{ zuul_snmp_passwd }}" + group: network-admin + user: zuul + use_acls: - user: snmp_user_1 ipv4: acl1 From 4d9dac8eaf12775b653711fdb643da67b657fba4 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 25 Jan 2023 12:18:13 +0530 Subject: [PATCH 057/166] [file_copy] fix full remote path generation (#612) Signed-off-by: NilashishC Move changelog fragment to correct place Signed-off-by: NilashishC Signed-off-by: NilashishC --- .config/ansible-lint.yml | 3 +++ changelogs/fragments/nxos_file_copy.yaml | 3 +++ plugins/modules/nxos_file_copy.py | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .config/ansible-lint.yml create mode 100644 changelogs/fragments/nxos_file_copy.yaml diff --git a/.config/ansible-lint.yml b/.config/ansible-lint.yml new file mode 100644 index 000000000..a401eae2a --- /dev/null +++ b/.config/ansible-lint.yml @@ -0,0 +1,3 @@ +--- +skip_list: + - galaxy[version-incorrect] diff --git a/changelogs/fragments/nxos_file_copy.yaml b/changelogs/fragments/nxos_file_copy.yaml new file mode 100644 index 000000000..46b3d27be --- /dev/null +++ b/changelogs/fragments/nxos_file_copy.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`nxos_file_copy` - stop prepending redundant bootflash: to remote file names" diff --git a/plugins/modules/nxos_file_copy.py b/plugins/modules/nxos_file_copy.py index 6f3051afe..4847a446e 100644 --- a/plugins/modules/nxos_file_copy.py +++ b/plugins/modules/nxos_file_copy.py @@ -311,8 +311,11 @@ def transfer_file_to_device(self, remote_file): self._module.fail_json("Could not transfer file. Not enough space on device.") # frp = full_remote_path, flp = full_local_path - frp = "{0}{1}".format(file_system, remote_file) + frp = remote_file + if not file_system.startswith("bootflash:"): + frp = "{0}{1}".format(file_system, remote_file) flp = os.path.join(os.path.abspath(local_file)) + try: self._connection.copy_file( source=flp, From 0c701e600d66443c2a4bef511740b4d82e66bb71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:37:02 +0530 Subject: [PATCH 058/166] [pre-commit.ci] pre-commit autoupdate (#616) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/isort: 5.11.4 → 5.12.0](https://github.com/PyCQA/isort/compare/5.11.4...5.12.0) - [github.com/ansible-network/collection_prep: 1.0.1 → 1.1.0](https://github.com/ansible-network/collection_prep/compare/1.0.1...1.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4975fbc38..98f65a037 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: 5.11.4 + rev: 5.12.0 hooks: - id: isort name: Sort import statements using isort @@ -53,6 +53,6 @@ repos: - id: black - repo: https://github.com/ansible-network/collection_prep - rev: 1.0.1 + rev: 1.1.0 hooks: - id: update-docs From 64820d7af8c2685b61cf20f4d737283673ef4815 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 6 Feb 2023 20:44:18 +0530 Subject: [PATCH 059/166] [l2_interfaces] add dot1q-tunnel mode (#617) * [l2_interfaces] add dot1q-tunnel mode Signed-off-by: NilashishC * Fix pylint issues Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/l2_mode.yaml | 3 +++ docs/cisco.nxos.nxos_l2_interfaces_module.rst | 1 + .../network/nxos/argspec/l2_interfaces/l2_interfaces.py | 2 +- plugins/modules/nxos_config.py | 2 ++ plugins/modules/nxos_l2_interfaces.py | 1 + .../targets/nxos_l2_interfaces/tests/common/parsed.yaml | 2 ++ tests/integration/targets/nxos_l2_interfaces/vars/main.yml | 2 ++ 7 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/l2_mode.yaml diff --git a/changelogs/fragments/l2_mode.yaml b/changelogs/fragments/l2_mode.yaml new file mode 100644 index 000000000..0d1a9812e --- /dev/null +++ b/changelogs/fragments/l2_mode.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_l2_interfaces` - Add new mode dot1q-tunnel (https://github.com/ansible-collections/cisco.nxos/issues/600)." diff --git a/docs/cisco.nxos.nxos_l2_interfaces_module.rst b/docs/cisco.nxos.nxos_l2_interfaces_module.rst index 07bc67963..e3292a2e6 100644 --- a/docs/cisco.nxos.nxos_l2_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_l2_interfaces_module.rst @@ -95,6 +95,7 @@ Parameters
    Choices: +
  • dot1q-tunnel
  • access
  • trunk
  • fex-fabric
  • diff --git a/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py index 4e9aaf10f..046511c72 100644 --- a/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/argspec/l2_interfaces/l2_interfaces.py @@ -44,7 +44,7 @@ class L2_interfacesArgs(object): # pylint: disable=R0903 }, "mode": { "type": "str", - "choices": ["access", "trunk", "fex-fabric", "fabricpath"], + "choices": ["access", "dot1q-tunnel", "trunk", "fex-fabric", "fabricpath"], }, "name": {"required": True, "type": "str"}, "trunk": { diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index a0cc2fd7b..457891249 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -543,6 +543,8 @@ def main(): base_config = NetworkConfig(indent=2, contents=contents, ignore_lines=diff_ignore_lines) if running_config.sha1 != base_config.sha1: + before = "" + after = "" if module.params["diff_against"] == "intended": before = running_config after = base_config diff --git a/plugins/modules/nxos_l2_interfaces.py b/plugins/modules/nxos_l2_interfaces.py index 9477e4863..3e73c4320 100644 --- a/plugins/modules/nxos_l2_interfaces.py +++ b/plugins/modules/nxos_l2_interfaces.py @@ -93,6 +93,7 @@ as changed=True. type: str choices: + - dot1q-tunnel - access - trunk - fex-fabric diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml index 05a60aa63..023049ee4 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/parsed.yaml @@ -13,6 +13,8 @@ host-reachability protocol bgp advertise virtual-rmac source-interface loopback1 + interface Ethernet1/799 + switchport mode dot1q-tunnel interface Ethernet1/800 switchport access vlan 18 switchport trunk allowed vlan 210 diff --git a/tests/integration/targets/nxos_l2_interfaces/vars/main.yml b/tests/integration/targets/nxos_l2_interfaces/vars/main.yml index fa6cc810e..71d7f0b52 100644 --- a/tests/integration/targets/nxos_l2_interfaces/vars/main.yml +++ b/tests/integration/targets/nxos_l2_interfaces/vars/main.yml @@ -12,6 +12,8 @@ gathered: parsed: - name: nve1 + - name: Ethernet1/799 + mode: dot1q-tunnel - name: Ethernet1/800 access: vlan: 18 From 2a50071c0e6a9d5920db6176cc72aa9d6a83f692 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 7 Feb 2023 11:28:47 +0530 Subject: [PATCH 060/166] [snmp_server] test updates (#618) Signed-off-by: NilashishC --- changelogs/fragments/snmp.yaml | 3 +++ .../targets/nxos_snmp_server/tests/common/_remove_config.yaml | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/snmp.yaml diff --git a/changelogs/fragments/snmp.yaml b/changelogs/fragments/snmp.yaml new file mode 100644 index 000000000..9ad0c20ae --- /dev/null +++ b/changelogs/fragments/snmp.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove redundant cleanup task. diff --git a/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml index f770d3c45..ce86eaec3 100644 --- a/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_snmp_server/tests/common/_remove_config.yaml @@ -21,7 +21,3 @@ - no snmp-server host 192.0.2.2 informs version 3 auth NMS - no snmp-server host 192.0.3.2 informs version 3 auth NMS ignore_errors: true - -- name: Remove remaining configuration - cisco.nxos.nxos_snmp_server: - state: deleted From 572ac447ee89e8c05d81585298e5777c738933c5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:52:41 +0530 Subject: [PATCH 061/166] [pre-commit.ci] pre-commit autoupdate (#619) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- .pre-commit-config.yaml | 2 +- plugins/doc_fragments/nxos.py | 1 - plugins/module_utils/network/nxos/facts/legacy/base.py | 1 - plugins/modules/nxos_hsrp.py | 2 +- plugins/modules/nxos_pim_interface.py | 1 - plugins/modules/nxos_pim_rp_address.py | 1 - plugins/modules/nxos_snmp_host.py | 2 +- plugins/modules/nxos_vpc.py | 1 - plugins/modules/nxos_vrf.py | 1 - plugins/modules/nxos_vrrp.py | 2 +- plugins/modules/storage/nxos_zone_zoneset.py | 2 -- plugins/terminal/nxos.py | 1 - tests/unit/modules/network/nxos/nxos_module.py | 1 - tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_acls.py | 1 - tests/unit/modules/network/nxos/test_nxos_banner.py | 1 - tests/unit/modules/network/nxos/test_nxos_bfd_global.py | 1 - tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_bgp.py | 2 -- tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py | 1 - tests/unit/modules/network/nxos/test_nxos_bgp_af.py | 1 - tests/unit/modules/network/nxos/test_nxos_bgp_global.py | 1 - tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py | 1 - .../network/nxos/test_nxos_bgp_neighbor_address_family.py | 1 - tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py | 1 - tests/unit/modules/network/nxos/test_nxos_command.py | 1 - tests/unit/modules/network/nxos/test_nxos_config.py | 1 - tests/unit/modules/network/nxos/test_nxos_evpn_global.py | 1 - tests/unit/modules/network/nxos/test_nxos_evpn_vni.py | 1 - tests/unit/modules/network/nxos/test_nxos_feature.py | 2 -- tests/unit/modules/network/nxos/test_nxos_hostname.py | 1 - tests/unit/modules/network/nxos/test_nxos_hsrp.py | 1 - tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_logging_global.py | 1 - tests/unit/modules/network/nxos/test_nxos_ntp_global.py | 1 - tests/unit/modules/network/nxos/test_nxos_nxapi.py | 1 - tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py | 1 - tests/unit/modules/network/nxos/test_nxos_ospfv2.py | 1 - tests/unit/modules/network/nxos/test_nxos_ospfv3.py | 1 - tests/unit/modules/network/nxos/test_nxos_overlay_global.py | 1 - tests/unit/modules/network/nxos/test_nxos_pim.py | 1 - tests/unit/modules/network/nxos/test_nxos_pim_interface.py | 2 -- tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py | 1 - tests/unit/modules/network/nxos/test_nxos_prefix_lists.py | 1 - tests/unit/modules/network/nxos/test_nxos_route_maps.py | 1 - tests/unit/modules/network/nxos/test_nxos_snmp_server.py | 1 - tests/unit/modules/network/nxos/test_nxos_static_routes.py | 1 - tests/unit/modules/network/nxos/test_nxos_system.py | 1 - tests/unit/modules/network/nxos/test_nxos_telemetry.py | 1 - tests/unit/modules/network/nxos/test_nxos_user.py | 1 - tests/unit/modules/network/nxos/test_nxos_vlans.py | 1 - tests/unit/modules/network/nxos/test_nxos_vpc.py | 1 - tests/unit/modules/network/nxos/test_nxos_vpc_interface.py | 1 - tests/unit/modules/network/nxos/test_nxos_vrf.py | 1 - tests/unit/modules/network/nxos/test_nxos_vrf_af.py | 1 - tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py | 1 - tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py | 1 - 61 files changed, 4 insertions(+), 65 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98f65a037..89fa9a674 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: name: Sort import statements using isort - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black diff --git a/plugins/doc_fragments/nxos.py b/plugins/doc_fragments/nxos.py index 4f7edb765..d3c6afe5d 100644 --- a/plugins/doc_fragments/nxos.py +++ b/plugins/doc_fragments/nxos.py @@ -9,7 +9,6 @@ class ModuleDocFragment(object): - # Standard files documentation fragment DOCUMENTATION = r"""options: {} notes: diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index 62912b8b0..2244e222b 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -163,7 +163,6 @@ def parse_memfree_mb(self, data): class Interfaces(FactsBase): - INTERFACE_MAP = frozenset( [ ("state", "state"), diff --git a/plugins/modules/nxos_hsrp.py b/plugins/modules/nxos_hsrp.py index 73a969b0e..ee59b7ddc 100644 --- a/plugins/modules/nxos_hsrp.py +++ b/plugins/modules/nxos_hsrp.py @@ -363,7 +363,7 @@ def is_default(interface, module): return True else: return False - except (KeyError): + except KeyError: return "DNE" diff --git a/plugins/modules/nxos_pim_interface.py b/plugins/modules/nxos_pim_interface.py index 755f5c28b..4d0f1052b 100644 --- a/plugins/modules/nxos_pim_interface.py +++ b/plugins/modules/nxos_pim_interface.py @@ -423,7 +423,6 @@ def config_pim_interface(delta, existing, jp_bidir, isauth): def get_pim_interface_defaults(): - args = dict( dr_prio=PARAM_TO_DEFAULT_KEYMAP.get("dr_prio"), bfd=PARAM_TO_DEFAULT_KEYMAP.get("bfd"), diff --git a/plugins/modules/nxos_pim_rp_address.py b/plugins/modules/nxos_pim_rp_address.py index df4c06d7d..fe9989ed9 100644 --- a/plugins/modules/nxos_pim_rp_address.py +++ b/plugins/modules/nxos_pim_rp_address.py @@ -102,7 +102,6 @@ def get_existing(module, args, gl): pim_address_re = r"ip pim rp-address (?P.*)$" for line in re.findall(pim_address_re, config, re.M): - values = line.split() if values[0] != address: continue diff --git a/plugins/modules/nxos_snmp_host.py b/plugins/modules/nxos_snmp_host.py index ed25502cf..3c23374c8 100644 --- a/plugins/modules/nxos_snmp_host.py +++ b/plugins/modules/nxos_snmp_host.py @@ -248,7 +248,7 @@ def get_snmp_host(host, udp, module): if find: fix_find = {} - for (key, value) in find.items(): + for key, value in find.items(): if isinstance(value, str): fix_find[key] = value.strip() else: diff --git a/plugins/modules/nxos_vpc.py b/plugins/modules/nxos_vpc.py index bf2f45be1..f660efc10 100644 --- a/plugins/modules/nxos_vpc.py +++ b/plugins/modules/nxos_vpc.py @@ -198,7 +198,6 @@ def flatten_list(command_lists): def get_vrf_list(module): - try: body = run_commands(module, ["show vrf all | json"])[0] vrf_table = body["TABLE_vrf"]["ROW_vrf"] diff --git a/plugins/modules/nxos_vrf.py b/plugins/modules/nxos_vrf.py index 1a73e7456..66fa43aba 100644 --- a/plugins/modules/nxos_vrf.py +++ b/plugins/modules/nxos_vrf.py @@ -521,7 +521,6 @@ def map_config_to_obj(want, element_spec, module): def check_declarative_intent_params(want, module, element_spec, result): - have = None is_delay = False diff --git a/plugins/modules/nxos_vrrp.py b/plugins/modules/nxos_vrrp.py index 665e450ed..b5a026c4b 100644 --- a/plugins/modules/nxos_vrrp.py +++ b/plugins/modules/nxos_vrrp.py @@ -177,7 +177,7 @@ def is_default(interface, module): return True else: return False - except (KeyError): + except KeyError: return "DNE" diff --git a/plugins/modules/storage/nxos_zone_zoneset.py b/plugins/modules/storage/nxos_zone_zoneset.py index 76101c3df..ea40e1fa4 100644 --- a/plugins/modules/storage/nxos_zone_zoneset.py +++ b/plugins/modules/storage/nxos_zone_zoneset.py @@ -372,7 +372,6 @@ def execute_show_zone_status_cmd(self): return output def update(self): - output = self.execute_show_zone_status_cmd().split("\n") patfordefzone = "VSAN: " + str(self.vsan) + r" default-zone:\s+(\S+).*" @@ -439,7 +438,6 @@ def getMemType(supported_choices, allmemkeys, default="pwwn"): def main(): - supported_choices = ["device_alias"] zone_member_spec = dict( pwwn=dict(required=True, type="str", aliases=["device_alias"]), diff --git a/plugins/terminal/nxos.py b/plugins/terminal/nxos.py index b54664df2..d9cf5af70 100644 --- a/plugins/terminal/nxos.py +++ b/plugins/terminal/nxos.py @@ -30,7 +30,6 @@ class TerminalModule(TerminalBase): - terminal_stdout_re = [ re.compile( rb"[\r\n](?!\s*<)?(\x1b\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\s*)(\x1b\S+)*$", diff --git a/tests/unit/modules/network/nxos/nxos_module.py b/tests/unit/modules/network/nxos/nxos_module.py index b6271c609..99e324da0 100644 --- a/tests/unit/modules/network/nxos/nxos_module.py +++ b/tests/unit/modules/network/nxos/nxos_module.py @@ -89,7 +89,6 @@ def execute_module_devices( return retvals def execute_module(self, failed=False, changed=False, commands=None, sort=True, device=""): - self.load_fixtures(commands, device=device) if failed: diff --git a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py index 016f89b27..8db951422 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_acl_interfaces.py @@ -16,7 +16,6 @@ class TestNxosAclInterfacesModule(TestNxosModule): - module = nxos_acl_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index 86f50a949..715a5c81d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -18,7 +18,6 @@ class TestNxosAclsModule(TestNxosModule): - module = nxos_acls def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_banner.py b/tests/unit/modules/network/nxos/test_nxos_banner.py index cb269f01c..7f8faf3a9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_banner.py +++ b/tests/unit/modules/network/nxos/test_nxos_banner.py @@ -27,7 +27,6 @@ class TestNxosBannerModule(TestNxosModule): - module = nxos_banner def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py index 9b41f2806..337637ef6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_global.py @@ -41,7 +41,6 @@ @pytest.mark.skipif(len(msg), reason=msg) class TestNxosBfdGlobalModule(TestNxosModule): - module = nxos_bfd_global def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py index 0a1ad4091..b160214e0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_bfd_interfaces.py @@ -38,7 +38,6 @@ class TestNxosBfdInterfacesModule(TestNxosModule): - module = nxos_bfd_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp.py b/tests/unit/modules/network/nxos/test_nxos_bgp.py index a02266bdb..9c57817ca 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp.py @@ -29,7 +29,6 @@ class TestNxosBgpModule(TestNxosModule): - module = nxos_bgp def setUp(self): @@ -113,7 +112,6 @@ def test_nxos_bgp_default_value(self): class TestNxosBgp32BitsAS(TestNxosModule): - module = nxos_bgp def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py index b22d5aed6..b9c905062 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_address_family.py @@ -35,7 +35,6 @@ class TestNxosBGPAddressFamilyModule(TestNxosModule): - # Testing strategy # ------------------ # (a) The unit tests cover `merged` and `replaced` for every attribute. diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py index d9773bd73..a72095c8f 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py @@ -29,7 +29,6 @@ class TestNxosBgpAfModule(TestNxosModule): - module = nxos_bgp_af def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index e1c57815c..84ba12420 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -35,7 +35,6 @@ class TestNxosBgpGlobalModule(TestNxosModule): - module = nxos_bgp_global def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py index b911d9f76..677e6f7dd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py @@ -29,7 +29,6 @@ class TestNxosBgpNeighborModule(TestNxosModule): - module = nxos_bgp_neighbor def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 9dba98030..0517904a8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -35,7 +35,6 @@ class TestNxosBGPNeighborAddressFamilyModule(TestNxosModule): - # Testing strategy # ------------------ # (a) The unit tests cover `merged` and `replaced` for every attribute. diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py index 8e93f6499..8b918d0e8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py @@ -29,7 +29,6 @@ class TestNxosBgpNeighborAfModule(TestNxosModule): - module = nxos_bgp_neighbor_af def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_command.py b/tests/unit/modules/network/nxos/test_nxos_command.py index b6ce92f8a..ca11ba3a2 100644 --- a/tests/unit/modules/network/nxos/test_nxos_command.py +++ b/tests/unit/modules/network/nxos/test_nxos_command.py @@ -31,7 +31,6 @@ class TestNxosCommandModule(TestNxosModule): - module = nxos_command def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_config.py b/tests/unit/modules/network/nxos/test_nxos_config.py index 800bea77b..83e58722a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_config.py +++ b/tests/unit/modules/network/nxos/test_nxos_config.py @@ -30,7 +30,6 @@ class TestNxosConfigModule(TestNxosModule): - module = nxos_config def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_evpn_global.py b/tests/unit/modules/network/nxos/test_nxos_evpn_global.py index 8b9fc698b..c9fa7911e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_evpn_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_evpn_global.py @@ -30,7 +30,6 @@ class TestNxosEvpnGlobalModule(TestNxosModule): - module = nxos_evpn_global def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py b/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py index f191c7cf3..0211a5a31 100644 --- a/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py +++ b/tests/unit/modules/network/nxos/test_nxos_evpn_vni.py @@ -29,7 +29,6 @@ class TestNxosEvpnVniModule(TestNxosModule): - module = nxos_evpn_vni def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_feature.py b/tests/unit/modules/network/nxos/test_nxos_feature.py index 798f2d10e..1c79537f1 100644 --- a/tests/unit/modules/network/nxos/test_nxos_feature.py +++ b/tests/unit/modules/network/nxos/test_nxos_feature.py @@ -31,7 +31,6 @@ class TestNxosFeatureModule(TestNxosModule): - module = nxos_feature def setUp(self): @@ -95,7 +94,6 @@ def test_nxos_feature_disable(self): class TestNxosFeatureModuleMDS(TestNxosModule): - module = nxos_feature def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_hostname.py b/tests/unit/modules/network/nxos/test_nxos_hostname.py index 3363e7f6a..1286241e0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hostname.py +++ b/tests/unit/modules/network/nxos/test_nxos_hostname.py @@ -36,7 +36,6 @@ class TestNxosHostnameModule(TestNxosModule): - module = nxos_hostname def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp.py b/tests/unit/modules/network/nxos/test_nxos_hsrp.py index def01d998..4ffcc43f3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp.py @@ -29,7 +29,6 @@ class TestNxosHsrpModule(TestNxosModule): - module = nxos_hsrp def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py index 299c225f8..67b6ed935 100644 --- a/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py @@ -38,7 +38,6 @@ class TestNxosHsrpInterfacesModule(TestNxosModule): - module = nxos_hsrp_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 03434f7ce..f44c7cce8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -41,7 +41,6 @@ class TestNxosInterfacesModule(TestNxosModule): - module = nxos_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py index cb41e0ab2..05100bf65 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py @@ -38,7 +38,6 @@ class TestNxosL3InterfacesModule(TestNxosModule): - module = nxos_l3_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py index ed7f41738..7d474b9bb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lacp_interfaces.py @@ -34,7 +34,6 @@ class TestNxosLacpInterfacesModule(TestNxosModule): - module = nxos_lacp_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py index 2632d21bf..c1152acdc 100644 --- a/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_lldp_interfaces.py @@ -16,7 +16,6 @@ class TestNxosLldpInterfacesModule(TestNxosModule): - module = nxos_lldp_interfaces def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_logging_global.py b/tests/unit/modules/network/nxos/test_nxos_logging_global.py index 48723fa93..06d95ddfc 100644 --- a/tests/unit/modules/network/nxos/test_nxos_logging_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_logging_global.py @@ -37,7 +37,6 @@ class TestNxosLoggingGlobalModule(TestNxosModule): - module = nxos_logging_global def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py index 99224383a..36a448cee 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ntp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_ntp_global.py @@ -35,7 +35,6 @@ class TestNxosNtpGlobalModule(TestNxosModule): - module = nxos_ntp_global def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_nxapi.py b/tests/unit/modules/network/nxos/test_nxos_nxapi.py index 4690658e0..7eb12a21c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_nxapi.py +++ b/tests/unit/modules/network/nxos/test_nxos_nxapi.py @@ -29,7 +29,6 @@ class TestNxosNxapiModule(TestNxosModule): - module = nxos_nxapi def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py index a6795aa41..0e5e74b29 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospf_interfaces.py @@ -35,7 +35,6 @@ class TestNxosOspfInterfacesModule(TestNxosModule): - # Testing strategy # ------------------ # (a) The unit tests cover `merged` and `replaced` for every attribute. diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py index 30334f454..b774e4b7e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv2.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv2.py @@ -35,7 +35,6 @@ class TestNxosOspfv2Module(TestNxosModule): - module = nxos_ospfv2 def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py index bf7980997..f883277fd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ospfv3.py +++ b/tests/unit/modules/network/nxos/test_nxos_ospfv3.py @@ -35,7 +35,6 @@ class TestNxosOspfv3Module(TestNxosModule): - # Testing strategy # ------------------ # (a) The unit tests cover `merged` and `replaced` for every attribute. diff --git a/tests/unit/modules/network/nxos/test_nxos_overlay_global.py b/tests/unit/modules/network/nxos/test_nxos_overlay_global.py index 59c190805..976aa0964 100644 --- a/tests/unit/modules/network/nxos/test_nxos_overlay_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_overlay_global.py @@ -29,7 +29,6 @@ class TestNxosOverlayGlobalModule(TestNxosModule): - module = nxos_overlay_global def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_pim.py b/tests/unit/modules/network/nxos/test_nxos_pim.py index dde259605..eea384836 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim.py @@ -29,7 +29,6 @@ class TestNxosPimModule(TestNxosModule): - module = nxos_pim def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py index 7b9a537d1..886a77940 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py @@ -29,7 +29,6 @@ class TestNxosIPInterfaceModule(TestNxosModule): - module = nxos_pim_interface def setUp(self): @@ -123,7 +122,6 @@ def test_nxos_pim_interface_ip_absent(self): class TestNxosPimInterfaceBfdModule(TestNxosModule): - module = nxos_pim_interface def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py b/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py index d068ee566..f4dbd13ac 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_rp_address.py @@ -29,7 +29,6 @@ class TestNxosPimRpAddressModule(TestNxosModule): - module = nxos_pim_rp_address def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py index a1d18615f..8eb6a5f7a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py +++ b/tests/unit/modules/network/nxos/test_nxos_prefix_lists.py @@ -37,7 +37,6 @@ class TestNxosPrefixListsModule(TestNxosModule): - # Testing strategy # ------------------ # (a) The unit tests cover `merged` and `replaced` for every attribute. diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index 8008725e3..114d27434 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -35,7 +35,6 @@ class TestNxosRouteMapsModule(TestNxosModule): - # Testing strategy # ------------------ # (a) The unit tests cover `merged` and `replaced` for every attribute. diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 25e90e330..38e1b659b 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -34,7 +34,6 @@ class TestNxosSnmpServerModule(TestNxosModule): - module = nxos_snmp_server def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_static_routes.py b/tests/unit/modules/network/nxos/test_nxos_static_routes.py index 37ffc1ae5..7feab35d3 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_routes.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_routes.py @@ -16,7 +16,6 @@ class TestNxosStaticRoutesModule(TestNxosModule): - module = nxos_static_routes def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_system.py b/tests/unit/modules/network/nxos/test_nxos_system.py index f8744d109..ea7eec95c 100644 --- a/tests/unit/modules/network/nxos/test_nxos_system.py +++ b/tests/unit/modules/network/nxos/test_nxos_system.py @@ -30,7 +30,6 @@ class TestNxosSystemModule(TestNxosModule): - module = nxos_system def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_telemetry.py b/tests/unit/modules/network/nxos/test_nxos_telemetry.py index 9418ad90d..783f357ef 100644 --- a/tests/unit/modules/network/nxos/test_nxos_telemetry.py +++ b/tests/unit/modules/network/nxos/test_nxos_telemetry.py @@ -48,7 +48,6 @@ @pytest.mark.skipif(len(msg), reason=msg) class TestNxosTelemetryModule(TestNxosModule): - module = nxos_telemetry def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_user.py b/tests/unit/modules/network/nxos/test_nxos_user.py index 91942320f..b634ca4f1 100644 --- a/tests/unit/modules/network/nxos/test_nxos_user.py +++ b/tests/unit/modules/network/nxos/test_nxos_user.py @@ -32,7 +32,6 @@ class TestNxosUserModule(TestNxosModule): - module = nxos_user def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vlans.py b/tests/unit/modules/network/nxos/test_nxos_vlans.py index 2afceacdd..f85fe42cd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vlans.py +++ b/tests/unit/modules/network/nxos/test_nxos_vlans.py @@ -38,7 +38,6 @@ class TestNxosVlansModule(TestNxosModule): - module = nxos_vlans def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vpc.py b/tests/unit/modules/network/nxos/test_nxos_vpc.py index fec32d618..a74525e86 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vpc.py +++ b/tests/unit/modules/network/nxos/test_nxos_vpc.py @@ -29,7 +29,6 @@ class TestNxosVpcModule(TestNxosModule): - module = nxos_vpc def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py b/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py index 6e5560b84..de7ad79bd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_vpc_interface.py @@ -29,7 +29,6 @@ class TestNxosVpcModule(TestNxosModule): - module = nxos_vpc_interface def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vrf.py b/tests/unit/modules/network/nxos/test_nxos_vrf.py index 602e57ca0..8f2a2ae1d 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vrf.py +++ b/tests/unit/modules/network/nxos/test_nxos_vrf.py @@ -29,7 +29,6 @@ class TestNxosVrfModule(TestNxosModule): - module = nxos_vrf def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vrf_af.py b/tests/unit/modules/network/nxos/test_nxos_vrf_af.py index 2df95473c..bfc2adef8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vrf_af.py +++ b/tests/unit/modules/network/nxos/test_nxos_vrf_af.py @@ -29,7 +29,6 @@ class TestNxosVrfafModule(TestNxosModule): - module = nxos_vrf_af def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py index e0c419f5e..68c499fe0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py @@ -29,7 +29,6 @@ class TestNxosVxlanVtepVniModule(TestNxosModule): - module = nxos_vxlan_vtep def setUp(self): diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py index 2f626d9c3..c6dc6e8d8 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep_vni.py @@ -29,7 +29,6 @@ class TestNxosVxlanVtepVniModule(TestNxosModule): - module = nxos_vxlan_vtep_vni def setUp(self): From fa2a35a93882f32fbe5a082d6a4e367cd4e4f3bb Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 7 Feb 2023 18:25:37 +0530 Subject: [PATCH 062/166] [facts] Updates for MDS platform (#595) * [facts] Updates for MDS platform Signed-off-by: NilashishC * Drop interfaces from MDS subset Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/mds.yaml | 3 ++ docs/cisco.nxos.nxos_facts_module.rst | 9 ++-- .../module_utils/network/nxos/facts/facts.py | 26 ++++++++-- plugins/modules/nxos_facts.py | 48 +++++++++++++------ 4 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 changelogs/fragments/mds.yaml diff --git a/changelogs/fragments/mds.yaml b/changelogs/fragments/mds.yaml new file mode 100644 index 000000000..d3375adc1 --- /dev/null +++ b/changelogs/fragments/mds.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: all` does not fail for NX-OS on MDS switches." diff --git a/docs/cisco.nxos.nxos_facts_module.rst b/docs/cisco.nxos.nxos_facts_module.rst index 5bba90b3d..0e344b470 100644 --- a/docs/cisco.nxos.nxos_facts_module.rst +++ b/docs/cisco.nxos.nxos_facts_module.rst @@ -17,7 +17,7 @@ Version added: 1.0.0 Synopsis -------- -- Collects facts from Cisco Nexus devices running the NX-OS operating system. Fact collection is supported over both Cli and Nxapi transports. This module prepends all of the base network fact keys with ``ansible_net_``. The facts module will always collect a base set of facts from the device and can enable or disable collection of additional facts. +- Collects facts from Cisco Nexus devices running the NX-OS operating system. Fact collection is supported over both ``network_cli`` and ``httpapi``. This module prepends all of the base network fact keys with ``ansible_net_``. The facts module will always collect a base set of facts from the device and can enable or disable collection of additional facts. @@ -49,7 +49,7 @@ Parameters
-
When 'True' a list of network resources for which resource modules are available will be provided.
+
When set to true a list of network resources for which resource modules are available will be provided.
-
When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all and the resources like interfaces, vlans etc. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected. Valid subsets are all, bfd_interfaces, lag_interfaces, telemetry, vlans, lacp, lacp_interfaces, interfaces, l3_interfaces, l2_interfaces, lldp_global, acls, acl_interfaces, ospfv2, ospfv3, ospf_interfaces, bgp_global, bgp_address_family, route_maps, prefix_lists, logging_global, ntp_global, snmp_server.
+
When supplied, this argument will gather configuration facts only for the given subset. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected.
+
Valid subsets are all, bfd_interfaces, lag_interfaces, telemetry, vlans, lacp, lacp_interfaces, interfaces, l3_interfaces, l2_interfaces, lldp_global, acls, acl_interfaces, ospfv2, ospfv3, ospf_interfaces, bgp_global, bgp_address_family, route_maps, prefix_lists, logging_global, ntp_global, snmp_server, hostname.
-
When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all, hardware, config, legacy, interfaces, and min. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected.
+
When supplied, this argument will gather operational facts only for the given subset. Possible values for this argument include all, hardware, config, legacy, interfaces, and min. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected.
diff --git a/plugins/module_utils/network/nxos/facts/facts.py b/plugins/module_utils/network/nxos/facts/facts.py index 04eeb9c40..b70cb590d 100644 --- a/plugins/module_utils/network/nxos/facts/facts.py +++ b/plugins/module_utils/network/nxos/facts/facts.py @@ -115,7 +115,7 @@ config=Config, features=Features, ) -FACT_RESOURCE_SUBSETS = dict( +NX_FACT_RESOURCE_SUBSETS = dict( bfd_interfaces=Bfd_interfacesFacts, hsrp_interfaces=Hsrp_interfacesFacts, lag_interfaces=Lag_interfacesFacts, @@ -144,16 +144,30 @@ snmp_server=Snmp_serverFacts, hostname=HostnameFacts, ) +MDS_FACT_RESOURCE_SUBSETS = dict( + logging_global=Logging_globalFacts, + ntp_global=Ntp_globalFacts, + snmp_server=Snmp_serverFacts, +) class Facts(FactsBase): """The fact class for nxos""" VALID_LEGACY_GATHER_SUBSETS = frozenset(FACT_LEGACY_SUBSETS.keys()) - VALID_RESOURCE_SUBSETS = frozenset(FACT_RESOURCE_SUBSETS.keys()) - def __init__(self, module): + def __init__(self, module, chassis_type="nexus"): super(Facts, self).__init__(module) + self.chassis_type = chassis_type + + def get_resource_subsets(self): + """Return facts resource subsets based on + target device model. + """ + facts_resource_subsets = NX_FACT_RESOURCE_SUBSETS + if self.chassis_type == "mds": + facts_resource_subsets = MDS_FACT_RESOURCE_SUBSETS + return facts_resource_subsets def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None): """Collect the facts for nxos @@ -163,8 +177,10 @@ def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None) :rtype: dict :return: the facts gathered """ - if self.VALID_RESOURCE_SUBSETS: - self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data) + VALID_RESOURCE_SUBSETS = self.get_resource_subsets() + + if frozenset(VALID_RESOURCE_SUBSETS.keys()): + self.get_network_resources_facts(VALID_RESOURCE_SUBSETS, resource_facts_type, data) if self.VALID_LEGACY_GATHER_SUBSETS: self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type) diff --git a/plugins/modules/nxos_facts.py b/plugins/modules/nxos_facts.py index aa9b8b103..24e0dad22 100644 --- a/plugins/modules/nxos_facts.py +++ b/plugins/modules/nxos_facts.py @@ -28,8 +28,8 @@ short_description: Gets facts about NX-OS switches description: - Collects facts from Cisco Nexus devices running the NX-OS operating system. Fact - collection is supported over both Cli and Nxapi transports. This module prepends - all of the base network fact keys with C(ansible_net_). The facts module + collection is supported over both C(network_cli) and C(httpapi). This module prepends + all of the base network fact keys with C(ansible_net_). The facts module will always collect a base set of facts from the device and can enable or disable collection of additional facts. version_added: 1.0.0 @@ -42,7 +42,7 @@ options: gather_subset: description: - - When supplied, this argument will restrict the facts collected to a given subset. Possible + - When supplied, this argument will gather operational facts only for the given subset. Possible values for this argument include C(all), C(hardware), C(config), C(legacy), C(interfaces), and C(min). Can specify a list of values to include a larger subset. Values can also be used with an initial C(!) to specify that a specific subset should not be collected. @@ -52,19 +52,20 @@ elements: str gather_network_resources: description: - - When supplied, this argument will restrict the facts collected to a given subset. - Possible values for this argument include all and the resources like interfaces, - vlans etc. Can specify a list of values to include a larger subset. Values can + - When supplied, this argument will gather configuration facts only for the given subset. + Can specify a list of values to include a larger subset. Values can also be used with an initial C(!) to specify that a specific subset should - not be collected. Valid subsets are C(all), C(bfd_interfaces), C(lag_interfaces), + not be collected. + - Valid subsets are C(all), C(bfd_interfaces), C(lag_interfaces), C(telemetry), C(vlans), C(lacp), C(lacp_interfaces), C(interfaces), C(l3_interfaces), C(l2_interfaces), C(lldp_global), C(acls), C(acl_interfaces), C(ospfv2), C(ospfv3), C(ospf_interfaces), - C(bgp_global), C(bgp_address_family), C(route_maps), C(prefix_lists), C(logging_global), C(ntp_global), C(snmp_server). + C(bgp_global), C(bgp_address_family), C(route_maps), C(prefix_lists), C(logging_global), C(ntp_global), + C(snmp_server), C(hostname). required: false type: list elements: str available_network_resources: - description: When 'True' a list of network resources for which resource modules are available will be provided. + description: When set to C(true) a list of network resources for which resource modules are available will be provided. type: bool default: false """ @@ -213,14 +214,28 @@ """ from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.connection import Connection from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.facts.facts import ( FactsArgs, ) -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import ( - FACT_RESOURCE_SUBSETS, - Facts, -) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts + + +def get_chassis_type(connection): + """Return facts resource subsets based on + chassis model. + """ + target_type = "nexus" + + device_info = connection.get_device_info() + model = device_info.get("network_os_model", "") + platform = device_info.get("network_os_platform", "") + + if platform.startswith("DS-") and "MDS" in model: + target_type = "mds" + + return target_type def main(): @@ -232,13 +247,16 @@ def main(): argument_spec = FactsArgs.argument_spec module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + connection = Connection(module._socket_path) + facts = Facts(module, chassis_type=get_chassis_type(connection)) warnings = [] ansible_facts = {} if module.params.get("available_network_resources"): - ansible_facts["available_network_resources"] = sorted(FACT_RESOURCE_SUBSETS.keys()) - result = Facts(module).get_facts() + ansible_facts["available_network_resources"] = sorted(facts.get_resource_subsets().keys()) + + result = facts.get_facts() additional_facts, additional_warnings = result ansible_facts.update(additional_facts) warnings.extend(additional_warnings) From aaaf7e60617eeb8732cf9b4e859e3ac0542a2390 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 8 Feb 2023 09:24:59 +0530 Subject: [PATCH 063/166] [command] do not fail when retries is 0 (#621) * [command] do not fail when retries is 0 Signed-off-by: NilashishC * Fix lint Signed-off-by: NilashishC * decrease retry count Signed-off-by: NilashishC * Fix typo Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/command.yaml | 3 +++ docs/cisco.nxos.nxos_command_module.rst | 5 +++-- plugins/modules/nxos_command.py | 10 ++++++---- tests/unit/modules/network/nxos/test_nxos_command.py | 7 ++++++- 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/command.yaml diff --git a/changelogs/fragments/command.yaml b/changelogs/fragments/command.yaml new file mode 100644 index 000000000..0f7b23ee0 --- /dev/null +++ b/changelogs/fragments/command.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_command - Run & evaluate commands at least once even when retries is set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607)." diff --git a/docs/cisco.nxos.nxos_command_module.rst b/docs/cisco.nxos.nxos_command_module.rst index cde8dfc5a..e7fbbc048 100644 --- a/docs/cisco.nxos.nxos_command_module.rst +++ b/docs/cisco.nxos.nxos_command_module.rst @@ -97,10 +97,11 @@ Parameters
- Default:
10
+ Default:
9
-
Specifies the number of retries a command should by tried before it is considered failed. The command is run on the target device every retry and evaluated against the wait_for conditionals.
+
Specifies the number of retries a command should by tried before it is considered failed. The command is run on the target device every retry and evaluated against the wait_for conditionals.
+
The commands are run once when retries is set to 0.
+
+ icmpv6 + +
+ dictionary +
+
+ +
ICMPv6 protocol options.
+
+
+ beyond_scope + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Destination beyond scope.
+
+
+ destination_unreachable + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Destination address is unreachable.
+
+
+ echo_reply + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Echo reply.
+
+
+ echo_request + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Echo request (ping).
+
+
+ fragments + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Check non-initial fragments.
+
+
+ header + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Parameter header problem.
+
+
+ hop_limit + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Hop limit exceeded in transit.
+
+
+ mld_query + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Multicast Listener Discovery Query.
+
+
+ mld_reduction + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Multicast Listener Discovery Reduction.
+
+
+ mld_report + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Multicast Listener Discovery Report.
+
+
+ mldv2 + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Multicast Listener Discovery Protocol.
+
+
+ nd_na + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Neighbor discovery neighbor advertisements.
+
+
+ nd_ns + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Neighbor discovery neighbor solicitations.
+
+
+ next_header + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Parameter next header problems.
+
+
+ no_admin + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Administration prohibited destination.
+
+
+ no_route + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
No route to destination.
+
+
+ packet_too_big + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Packet too big.
+
+
+ parameter_option + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Parameter option problems.
+
+
+ parameter_problem + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
All parameter problems.
+
+
+ port_unreachable + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Port unreachable.
+
+
+ reassembly_timeout + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Reassembly timeout.
+
+
+ renum_command + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Router renumbering command.
+
+
+ renum_result + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Router renumbering result.
+
+
+ renum_seq_number + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Router renumbering sequence number reset.
+
+
+ router_advertisement + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Neighbor discovery router advertisements.
+
+
+ router_renumbering + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
All router renumbering.
+
+
+ router_solicitation + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Neighbor discovery router solicitations.
+
+
+ telemetry_path + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
IPT enabled.
+
+
+ telemetry_queue + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Flow of interest for BDC/HDC.
+
+
+ time_exceeded + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
All time exceeded.
+
+
+ unreachable + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
All unreachable.
+
Choices/Defaults Comments
+
+ advertise_virtual_rmac + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
The advertise_virtual_rmac parameter lets BGP to use the VMAC with VIP as next-hop when advertising type-2 routes. Should be used together with advertise_pip parameter from cisco.nxos.nxos_bgp_address_family module.
+
diff --git a/plugins/modules/nxos_vxlan_vtep.py b/plugins/modules/nxos_vxlan_vtep.py index ce3113883..f62b995c0 100644 --- a/plugins/modules/nxos_vxlan_vtep.py +++ b/plugins/modules/nxos_vxlan_vtep.py @@ -104,6 +104,12 @@ an existing gateway config. type: str version_added: 1.1.0 + advertise_virtual_rmac: + description: + - The advertise_virtual_rmac parameter lets BGP to use the VMAC with VIP as next-hop when + advertising type-2 routes. Should be used together with advertise_pip parameter from + cisco.nxos.nxos_bgp_address_family module. + type: bool """ EXAMPLES = """ - cisco.nxos.nxos_vxlan_vtep: @@ -146,6 +152,7 @@ "host_reachability", "global_ingress_replication_bgp", "global_suppress_arp", + "advertise_virtual_rmac", ] PARAM_TO_COMMAND_KEYMAP = { "description": "description", @@ -159,6 +166,7 @@ "source_interface": "source-interface", "source_interface_hold_down_time": "source-interface hold-down-time", "multisite_border_gateway_interface": "multisite border-gateway interface", + "advertise_virtual_rmac": "advertise virtual-rmac", } PARAM_TO_DEFAULT_KEYMAP = { "description": False, @@ -170,6 +178,7 @@ def get_value(arg, config, module): if arg in BOOL_PARAMS: REGEX = re.compile(r"\s+{0}\s*$".format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M) + NO_REGEX = re.compile(r"\s+no\s{0}\s*$".format(PARAM_TO_COMMAND_KEYMAP[arg]), re.M) NO_SHUT_REGEX = re.compile(r"\s+no shutdown\s*$", re.M) value = False if arg == "shutdown": @@ -180,6 +189,14 @@ def get_value(arg, config, module): value = True except TypeError: value = False + elif arg == "advertise_virtual_rmac": + try: + if NO_REGEX.search(config): + value = False + elif REGEX.search(config): + value = True + except TypeError: + value = False else: try: if REGEX.search(config): @@ -398,6 +415,7 @@ def main(): source_interface_hold_down_time=dict(required=False, type="str"), state=dict(choices=["present", "absent"], default="present", required=False), multisite_border_gateway_interface=dict(required=False, type="str"), + advertise_virtual_rmac=dict(required=False, type="bool"), ) mutually_exclusive = [("global_ingress_replication_bgp", "global_mcast_group_L2")] diff --git a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py index 68c499fe0..f6862a77e 100644 --- a/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py +++ b/tests/unit/modules/network/nxos/test_nxos_vxlan_vtep.py @@ -100,3 +100,19 @@ def test_nxos_vxlan_vtep_multisite_exists(self): ), ) self.execute_module(changed=False, commands=[]) + + def test_nxos_vxlan_vtep_advertise_virtual_rmac(self): + set_module_args( + dict( + interface="nve1", + advertise_virtual_rmac="true", + ), + ) + self.execute_module( + changed=True, + commands=[ + "interface nve1", + "terminal dont-ask", + "advertise virtual-rmac", + ], + ) From 3115215027c03a6cceadb25cac12626b9c1fdf0e Mon Sep 17 00:00:00 2001 From: roverflow <63404819+roverflow@users.noreply.github.com> Date: Wed, 29 Mar 2023 18:29:12 +0530 Subject: [PATCH 073/166] added codecov workflow (#647) * added codecov workflow * added codecov in different fie --------- Co-authored-by: Nilashish Chakraborty --- .../{runcov.yml => codecoverage.yml} | 8 +- .github/workflows/covflow.yml | 75 ------------------- .github/workflows/{test.yml => tests.yml} | 30 ++++---- changelogs/fragments/codecov_from_repo.yml | 3 + 4 files changed, 22 insertions(+), 94 deletions(-) rename .github/workflows/{runcov.yml => codecoverage.yml} (64%) delete mode 100644 .github/workflows/covflow.yml rename .github/workflows/{test.yml => tests.yml} (67%) create mode 100644 changelogs/fragments/codecov_from_repo.yml diff --git a/.github/workflows/runcov.yml b/.github/workflows/codecoverage.yml similarity index 64% rename from .github/workflows/runcov.yml rename to .github/workflows/codecoverage.yml index f89eb6c09..3ed9832a7 100644 --- a/.github/workflows/runcov.yml +++ b/.github/workflows/codecoverage.yml @@ -1,4 +1,5 @@ -name: run-cov +--- +name: Code Coverage on: push: @@ -6,9 +7,8 @@ on: branches: [ main ] jobs: - #codecoverage - codecov: - uses: ./.github/workflows/covflow.yml + codecoverage: + uses: ansible-network/github_actions/.github/workflows/coverage_network_devices.yml@main with: collection_pre_install: >- git+https://github.com/ansible-collections/ansible.utils.git diff --git a/.github/workflows/covflow.yml b/.github/workflows/covflow.yml deleted file mode 100644 index 5a5326409..000000000 --- a/.github/workflows/covflow.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: CodeCoverage, dependencies from source -on: - workflow_call: - inputs: - collection_pre_install: - required: true - type: string -jobs: - codecoverage: - env: - PY_COLORS: "1" - source_directory: "./source" - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - ansible-version: - - Latest - python-version: - - "3.10" - runs-on: ${{ matrix.os }} - - name: "Code Coverage ${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.ansible-version }}" - steps: - - name: Checkout the collection repository - uses: actions/checkout@v3 - with: - path: ${{ env.source_directory }} - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: "0" - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install ansible-core (${{ matrix.ansible-version }}) - run: python3 -m pip install ansible-core - - - name: Read collection metadata from galaxy.yml - id: identify - uses: ansible-network/github_actions/.github/actions/identify_collection@main - with: - source_path: ${{ env.source_directory }} - - - name: Pre install collections dependencies first so the collection install does not - run: ansible-galaxy collection install ${{ inputs.collection_pre_install }} -p /home/runner/collections - if: inputs.collection_pre_install != '' - - - name: Build and install the collection - uses: ansible-network/github_actions/.github/actions/build_install_collection@main - with: - install_python_dependencies: true - source_path: ${{ env.source_directory }} - collection_path: ${{ steps.identify.outputs.collection_path }} - tar_file: ${{ steps.identify.outputs.tar_file }} - - - name: Print the ansible version - run: ansible --version - - - name: Print the python dependencies - run: python3 -m pip list - - - name: Run Coverage tests - run: | - ansible-test units --python ${{ matrix.python-version }} --coverage --requirements - ansible-test coverage xml - working-directory: ${{ steps.identify.outputs.collection_path }} - - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v3 - with: - directory: ${{ steps.identify.outputs.collection_path }} - fail_ci_if_error: true diff --git a/.github/workflows/test.yml b/.github/workflows/tests.yml similarity index 67% rename from .github/workflows/test.yml rename to .github/workflows/tests.yml index 1fcf4c9a2..e77967b34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/tests.yml @@ -1,10 +1,11 @@ +--- name: Test collection concurrency: group: ${{ github.head_ref }} cancel-in-progress: true -on: +on: # yamllint disable-line rule:truthy pull_request: branches: [main] workflow_dispatch: @@ -24,22 +25,21 @@ jobs: collection_pre_install: >- git+https://github.com/ansible-collections/ansible.utils.git git+https://github.com/ansible-collections/ansible.netcommon.git - all_green: if: ${{ always() }} needs: - - ansible-lint - - changelog - - sanity - - unit-galaxy - - unit-source + - ansible-lint + - changelog + - sanity + - unit-galaxy + - unit-source runs-on: ubuntu-latest steps: - - run: >- - python -c "assert set([ - '${{ needs.ansible-lint.result }}', - '${{ needs.changelog.result }}', - '${{ needs.sanity.result }}', - '${{ needs.unit-galaxy.result }}', - '${{ needs.unit-source.result }}' - ]) == {'success'}" + - run: >- + python -c "assert set([ + '${{ needs.ansible-lint.result }}', + '${{ needs.changelog.result }}', + '${{ needs.sanity.result }}', + '${{ needs.unit-galaxy.result }}', + '${{ needs.unit-source.result }}' + ]) == {'success'}" diff --git a/changelogs/fragments/codecov_from_repo.yml b/changelogs/fragments/codecov_from_repo.yml new file mode 100644 index 000000000..e91794a41 --- /dev/null +++ b/changelogs/fragments/codecov_from_repo.yml @@ -0,0 +1,3 @@ +--- +trivial: + - Added codecov to run from the ansible-network/github_actions repo and changed workflow file name for concsistency. From 914dfa3df0e7d81c3521993ad62b2b43b17e84c0 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Sun, 2 Apr 2023 14:09:46 +0530 Subject: [PATCH 074/166] [snmp_server] fix snmp_server.community command generation (#649) * fix 636 * fix 439 * fix sanity * changelog * rever 439 * revert changelog --------- Co-authored-by: Nilashish Chakraborty --- .../fragments/snmp_server_issues_fix.yaml | 3 +++ .../network/nxos/rm_templates/snmp_server.py | 26 +++++-------------- .../network/nxos/test_nxos_snmp_server.py | 10 +++++-- 3 files changed, 18 insertions(+), 21 deletions(-) create mode 100644 changelogs/fragments/snmp_server_issues_fix.yaml diff --git a/changelogs/fragments/snmp_server_issues_fix.yaml b/changelogs/fragments/snmp_server_issues_fix.yaml new file mode 100644 index 000000000..fbedba72e --- /dev/null +++ b/changelogs/fragments/snmp_server_issues_fix.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "`snmp_server` - fix community option to produce proper configuration with ipv4acl and ipv6acl." diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index 8615bb2c3..be25452df 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -76,23 +76,6 @@ def _tmplt_users_auth(data): return cmd -def _template_communities(data): - cmd = "snmp-server community {0}".format(data["name"]) - - if "group" in data: - cmd += " group {0}".format(data["group"]) - elif "use_ipv4acl" in data: - cmd += " use-ipv4acl {0}".format(data["use_ipv4acl"]) - elif "use_ipv6acl" in data: - cmd += " use-ipv6acl {0}".format(data["use_ipv6acl"]) - elif data.get("ro", False): - cmd += " ro" - elif data.get("rw", False): - cmd += " rw" - - return cmd - - class Snmp_serverTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): super(Snmp_serverTemplate, self).__init__(lines=lines, tmplt=self, module=module) @@ -125,7 +108,13 @@ def __init__(self, lines=None, module=None): (\suse-ipv6acl\s(?P\S+))? $""", re.VERBOSE, ), - "setval": _template_communities, + "setval": "snmp-server community " + "{{ name }}" + "{{ (' group ' + group) if group is defined else '' }}" + "{{ (' use-ipv4acl ' + use_ipv4acl) if use_ipv4acl is defined else '' }}" + "{{ (' use-ipv6acl ' + use_ipv6acl) if use_ipv6acl is defined else '' }}" + "{{ ' ro' if ro|d(False) else ''}}" + "{{ ' rw' if rw|d(False) else ''}}", "result": { "communities": [ { @@ -1515,7 +1504,6 @@ def __init__(self, lines=None, module=None): "aes_128": "{{ not not aes_128 }}", }, }, - }, ], }, diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 38e1b659b..1b66d6455 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -854,7 +854,7 @@ def test_nxos_snmp_server_parsed(self): running_config=dedent( """\ snmp-server community private group network-admin - snmp-server community public use-ipv4acl myacl + snmp-server community public use-ipv4acl myacl use-ipv6acl myaclv6 snmp-server globalEnforcePriv snmp-server tcp-session auth snmp-server counter cache timeout 1800 @@ -885,7 +885,7 @@ def test_nxos_snmp_server_parsed(self): contact="testswitch@localhost", communities=[ dict(name="private", group="network-admin"), - dict(name="public", use_ipv4acl="myacl"), + dict(name="public", use_ipv4acl="myacl", use_ipv6acl="myaclv6"), ], context=dict(name="public", vrf="siteA"), counter=dict(cache=dict(timeout=1800)), @@ -935,6 +935,10 @@ def test_nxos_snmp_server_rendered(self): contact="testswitch@localhost", context=dict(name="public", vrf="siteA"), counter=dict(cache=dict(timeout=1800)), + communities=[ + dict(name="private", group="network-admin"), + dict(name="public", use_ipv4acl="myacl", use_ipv6acl="myaclv6"), + ], drop=dict(unknown_engine_id=True, unknown_user=True), engine_id=dict(local="'00:00:00:63:00:01:00:10:20:15:10:03'"), global_enforce_priv=True, @@ -967,6 +971,8 @@ def test_nxos_snmp_server_rendered(self): "snmp-server location lab", "snmp-server mib community-map public context public1", "snmp-server source-interface traps Ethernet1/2", + "snmp-server community private group network-admin", + "snmp-server community public use-ipv4acl myacl use-ipv6acl myaclv6", ] result = self.execute_module(changed=False) self.assertEqual(set(result["rendered"]), set(rendered)) From 188de70c33af25cc4f550ea84b08869ea325a6f3 Mon Sep 17 00:00:00 2001 From: tnizharadze <64648821+tnizharadze@users.noreply.github.com> Date: Mon, 3 Apr 2023 07:46:05 +0300 Subject: [PATCH 075/166] Add route map next hop support (#646) * Add "set ip next-hop
" support in cisco.nxos.nxos_route_map * Modify _compare_lists for correct comparison of 'verify_availability' parameter * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update plugins/modules/nxos_route_maps.py Co-authored-by: Nilashish Chakraborty * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert to 49f3efd commit. * Add unit tests, usage examples and changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix sanity issues Signed-off-by: NilashishC * Fix sanity Signed-off-by: NilashishC --------- Signed-off-by: NilashishC Co-authored-by: OSKS admin user Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/nxos_route_maps.yaml | 3 + docs/cisco.nxos.nxos_route_maps_module.rst | 569 +++++++++++++++++- .../nxos/argspec/route_maps/route_maps.py | 49 ++ .../nxos/config/route_maps/route_maps.py | 46 ++ .../network/nxos/rm_templates/route_maps.py | 161 +++++ plugins/modules/nxos_route_maps.py | 311 +++++++++- .../network/nxos/test_nxos_route_maps.py | 404 +++++++++++++ 7 files changed, 1538 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/nxos_route_maps.yaml diff --git a/changelogs/fragments/nxos_route_maps.yaml b/changelogs/fragments/nxos_route_maps.yaml new file mode 100644 index 000000000..21769fdf7 --- /dev/null +++ b/changelogs/fragments/nxos_route_maps.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "`nxos_route_maps` - add support for 'set ip next-hop <>' command in route-maps" diff --git a/docs/cisco.nxos.nxos_route_maps_module.rst b/docs/cisco.nxos.nxos_route_maps_module.rst index 9b2da5a5c..817967670 100644 --- a/docs/cisco.nxos.nxos_route_maps_module.rst +++ b/docs/cisco.nxos.nxos_route_maps_module.rst @@ -1962,6 +1962,333 @@ Parameters
+
+ next_hop + +
+ dictionary +
+
+ +
Set next-hop IP address (for policy-based routing)
+
+
+ address + +
+ string +
+
+ +
Set space-separated list of next-hop IP addresses. Address ordering is important. Also don`t use unnecessary spaces.
+
+
+ drop_on_fail + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Drop packets instead of using default routing when the configured next hop becomes unreachable
+
+
+ force_order + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Enable next-hop ordering as specified in the address parameter.
+
+
+ load_share + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Enable traffic load balancing across a maximum of 32 next-hop addresses
+
+
+ peer_address + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
BGP prefix next hop is set to the local address of the peer.
+
If no next hop is set in the route map, the next hop is set to the one stored in the path.
+
+
+ redist_unchanged + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set for next-hop address conservation for non-local generated routes.
+
Used with redistribute command. Available to maintain BGP routing compliant with RFC 4271 on Nexus OS.
+
+
+ unchanged + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set for next-hop address conservation in eBGP outgoing updates
+
+
+ verify_availability + +
+ list + / elements=dictionary +
+
+ +
Set next-hop ip address tracking with IP SLA
+
+
+ address + +
+ string + / required +
+
+ +
Set one next-hop address
+
+
+ drop_on_fail + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Drop packets instead of using default routing when the configured next hop becomes unreachable
+
+
+ force_order + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Enable next-hop ordering as specified in the address parameter.
+
+
+ load_share + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Enable traffic load balancing across a maximum of 32 next-hop addresses
+
+
+ track + +
+ integer + / required +
+
+ +
Set track number
+
+
+ hashed_password + +
+ string +
+
+ +
The hashed password to be configured on the network device. The password needs to already be encrypted.
+
@@ -172,6 +188,21 @@ Parameters
The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device.
+
+ hashed_password + +
+ string +
+
+ +
The hashed password to be configured on the network device. The password needs to already be encrypted.
+
diff --git a/galaxy.yml b/galaxy.yml index 1b1dbb24c..3ceb203df 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 4.3.1-dev +version: 4.4.0-dev diff --git a/plugins/modules/nxos_user.py b/plugins/modules/nxos_user.py index 3e8ee7a2d..92a0a5c01 100644 --- a/plugins/modules/nxos_user.py +++ b/plugins/modules/nxos_user.py @@ -57,6 +57,11 @@ - The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device. type: str + hashed_password: + description: + - The hashed password to be configured on the network device. The password needs to + already be encrypted. + type: str update_password: description: - Since passwords are encrypted in the device running config, this argument will @@ -101,6 +106,11 @@ - The password to be configured on the network device. The password needs to be provided in cleartext and it will be encrypted on the device. type: str + hashed_password: + description: + - The hashed password to be configured on the network device. The password needs to + already be encrypted. + type: str update_password: description: - Since passwords are encrypted in the device running config, this argument will @@ -278,6 +288,10 @@ def configure_roles(): if update_password == "always" or not have: add("password %s" % want["configured_password"]) + if needs_update("hashed_password"): + if update_password == "always" or not have: + add("password 5 %s" % want["hashed_password"]) + if needs_update("sshkey"): add("sshkey %s" % want["sshkey"]) @@ -315,6 +329,7 @@ def map_config_to_obj(module): { "name": item["usr_name"], "configured_password": parse_password(item), + "hashed_password": parse_password(item), "sshkey": item.get("sshkey_info"), "roles": parse_roles(item), "state": "present", @@ -364,6 +379,7 @@ def map_params_to_obj(module): item.update( { "configured_password": get_value("configured_password"), + "hashed_password": get_value("hashed_password"), "sshkey": get_value("sshkey"), "roles": get_value("roles"), "state": get_value("state"), @@ -400,6 +416,7 @@ def main(): element_spec = dict( name=dict(), configured_password=dict(no_log=True), + hashed_password=dict(no_log=True), update_password=dict(default="always", choices=["on_create", "always"]), roles=dict(type="list", aliases=["role"], elements="str"), sshkey=dict(no_log=False), @@ -423,7 +440,7 @@ def main(): argument_spec.update(element_spec) - mutually_exclusive = [("name", "aggregate")] + mutually_exclusive = [("name", "aggregate"), ("configured_password", "hashed_password")] module = AnsibleModule( argument_spec=argument_spec, @@ -453,6 +470,11 @@ def main(): if "no username admin" in commands: module.fail_json(msg="cannot delete the `admin` account") + # check if provided hashed password is infact a hash + if module.params["hashed_password"] is not None: + if not re.match(r"^\$5\$......\$.*$", module.params["hashed_password"]): + module.fail_json(msg="Provided hash is not valid") + if commands: if not module.check_mode: responses = load_config(module, commands) diff --git a/tests/unit/modules/network/nxos/test_nxos_user.py b/tests/unit/modules/network/nxos/test_nxos_user.py index b634ca4f1..c397c82cb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_user.py +++ b/tests/unit/modules/network/nxos/test_nxos_user.py @@ -100,3 +100,18 @@ def test_mds(self): "username ansible-test-2 password ansible", ], ) + + def test_nxos_hashed_password(self): + set_module_args( + dict( + name="ansible", + hashed_password="$5$JFHICC$u.zXRUgprAkkYLiEns8VrhsNEIOj7FzVrn67tuJdtKB", + ), + ) + self.execute_module( + changed=True, + commands=[ + "username ansible", + "username ansible password 5 $5$JFHICC$u.zXRUgprAkkYLiEns8VrhsNEIOj7FzVrn67tuJdtKB", + ], + ) From 3e63a7a1bc783635046496f6ae44fc60394493a0 Mon Sep 17 00:00:00 2001 From: Ashley Tayles Date: Fri, 19 May 2023 08:49:27 +0100 Subject: [PATCH 089/166] nxos_facts: Fix Missing SVI Facts (#682) * add hashed_password * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nxos_user hashed password * change check to "is not None" instead of merely checking for existence * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add unit test for hashed pw * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * correctly identify svi --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/nxos_facts.yaml | 3 +++ plugins/module_utils/network/nxos/facts/legacy/base.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/nxos_facts.yaml diff --git a/changelogs/fragments/nxos_facts.yaml b/changelogs/fragments/nxos_facts.yaml new file mode 100644 index 000000000..ed12c2650 --- /dev/null +++ b/changelogs/fragments/nxos_facts.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440)." diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index 3cf87f59c..b8cfbf475 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -272,7 +272,7 @@ def populate_structured_interfaces(self, data): name = item["interface"] intf = dict() - if "type" in item: + if any(key.startswith("svi_") for key in item): intf.update(self.transform_dict(item, self.INTERFACE_SVI_MAP)) else: intf.update(self.transform_dict(item, self.INTERFACE_MAP)) From 22952aff7a2c503c0815ad56905da8d1c91274c9 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 19 May 2023 15:19:07 +0530 Subject: [PATCH 090/166] Downstream test updates (#684) * Downstream test updates Signed-off-by: NilashishC * Remove default setting Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/downstream.yaml | 3 +++ tests/integration/targets/nxos_snmp_server/tasks/main.yaml | 6 ------ tests/integration/targets/prepare_nxos_tests/tasks/main.yml | 5 +++++ 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/downstream.yaml diff --git a/changelogs/fragments/downstream.yaml b/changelogs/fragments/downstream.yaml new file mode 100644 index 000000000..a424272fb --- /dev/null +++ b/changelogs/fragments/downstream.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fixes for downstream testing. diff --git a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index bf5addfbf..cb885dee9 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml @@ -47,9 +47,3 @@ ansible.builtin.include_tasks: nxapi.yaml tags: - nxapi - -- name: "Add back snmp-server user zuul" - cisco.nxos.nxos_config: - lines: - - "snmp-server user zuul network-admin auth md5 {{ zuul_snmp_passwd }} priv {{ zuul_snmp_passwd }} localizedkey" - match: none diff --git a/tests/integration/targets/prepare_nxos_tests/tasks/main.yml b/tests/integration/targets/prepare_nxos_tests/tasks/main.yml index 78729cdd2..e89e80269 100644 --- a/tests/integration/targets/prepare_nxos_tests/tasks/main.yml +++ b/tests/integration/targets/prepare_nxos_tests/tasks/main.yml @@ -22,6 +22,11 @@ prepare_nxos_tests_task: false titanium: false +- name: Reload golden config + cisco.nxos.nxos_command: + commands: configure replace bootflash:///golden_config non-interactive + when: reload_nxos_config | default(False) | bool + - name: Run the prepare steps if requested ansible.builtin.include_tasks: prepare.yml when: prepare_nxos_tests_task | default(False) | bool From 6fed3bffed572f61ebf45414d2803487658736ed Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 19 May 2023 18:56:08 +0530 Subject: [PATCH 091/166] [l3_interfaces] append tag with state replaced (#685) Signed-off-by: NilashishC --- changelogs/fragments/l3.yaml | 3 +++ .../config/l3_interfaces/l3_interfaces.py | 3 +-- .../network/nxos/test_nxos_l3_interfaces.py | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/l3.yaml diff --git a/changelogs/fragments/l3.yaml b/changelogs/fragments/l3.yaml new file mode 100644 index 000000000..e96eaed23 --- /dev/null +++ b/changelogs/fragments/l3.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "l3_interfaces - Append tag when updating IP address with state replaced (https://github.com/ansible-collections/cisco.nxos/issues/678)." diff --git a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py index 55ac22660..d4da881f5 100644 --- a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py @@ -200,7 +200,6 @@ def _state_replaced(self, want, have): cmds.extend(self.generate_delete_commands(rmv)) else: diff = want - cmds.extend(self.add_commands(diff, name=name)) cmds.extend(v4_cmds) cmds.extend(v6_cmds) @@ -311,7 +310,7 @@ def _v4_cmds(self, want, have, state=None): if diff: addr = diff.get("address") or pri_w.get("address") cmd = "ip address %s" % addr - tag = diff.get("tag") + tag = diff.get("tag") or pri_w.get("tag") cmd += " tag %s" % tag if tag else "" cmds.append(cmd) diff --git a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py index b0ac68f4d..289c36ffd 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l3_interfaces.py @@ -1021,3 +1021,26 @@ def test_12_gathered(self): set_module_args(playbook, ignore_provider_arg) result = self.execute_module(changed=False) self.assertEqual(result["gathered"], gathered_facts) + + def test_replaced_tag(self): + existing = dedent( + """\ + interface Vlan10 + ip address 192.168.1.10/24 tag 20 + """, + ) + self.get_resource_connection_facts.return_value = {self.SHOW_CMD: existing} + playbook = dict( + config=[ + dict( + name="Vlan10", + ipv4=[{"address": "192.168.1.11/24", "tag": 20}], + ), + ], + state="replaced", + ) + + commands = ["interface Vlan10", "ip address 192.168.1.11/24 tag 20"] + playbook["state"] = "replaced" + set_module_args(playbook, ignore_provider_arg) + self.execute_module(changed=True, commands=commands) From ba7a8557dc027e9985a72a2d6c35c28320a101c9 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 24 May 2023 14:53:31 +0530 Subject: [PATCH 092/166] [terminal] fix privilege escalation (#687) Signed-off-by: NilashishC --- changelogs/fragments/terminal.yaml | 3 +++ plugins/terminal/nxos.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/terminal.yaml diff --git a/changelogs/fragments/terminal.yaml b/changelogs/fragments/terminal.yaml new file mode 100644 index 000000000..6ba4b5ef4 --- /dev/null +++ b/changelogs/fragments/terminal.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "terminal - attempt privilege escalation only when prompt does not end with #" diff --git a/plugins/terminal/nxos.py b/plugins/terminal/nxos.py index ff0ada40d..0df2956fb 100644 --- a/plugins/terminal/nxos.py +++ b/plugins/terminal/nxos.py @@ -69,7 +69,7 @@ class TerminalModule(TerminalBase): terminal_config_prompt = re.compile(r"^.*\((?!maint-mode).*\)#$") def on_become(self, passwd=None): - if self._get_prompt().strip().endswith(b"enable#"): + if self._get_prompt().strip().endswith(b"#"): return out = self._exec_cli_command("show privilege") From 931f81179c4d84cfb3ec03385dda2ee8e83c2294 Mon Sep 17 00:00:00 2001 From: Ashley Tayles Date: Thu, 25 May 2023 07:26:24 +0100 Subject: [PATCH 093/166] nxos_banner - multiline_delimiter (#686) * add support for customer delimiter * add custom delimiter support * fix typo in banner unit test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add default to docstring * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * put at symbol in quotes * Add back docs Signed-off-by: NilashishC --------- Signed-off-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/banner.yaml | 3 +++ docs/cisco.nxos.nxos_banner_module.rst | 16 ++++++++++++++++ plugins/modules/nxos_banner.py | 9 ++++++++- .../modules/network/nxos/test_nxos_banner.py | 14 ++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/banner.yaml diff --git a/changelogs/fragments/banner.yaml b/changelogs/fragments/banner.yaml new file mode 100644 index 000000000..cc0f68e9c --- /dev/null +++ b/changelogs/fragments/banner.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_banner - Add support for a custom multiline delimiter" diff --git a/docs/cisco.nxos.nxos_banner_module.rst b/docs/cisco.nxos.nxos_banner_module.rst index 16e0ae2cd..7502173b7 100644 --- a/docs/cisco.nxos.nxos_banner_module.rst +++ b/docs/cisco.nxos.nxos_banner_module.rst @@ -53,6 +53,22 @@ Parameters
Specifies which banner that should be configured on the remote device.
+
+ multiline_delimiter + +
+ string +
+
+ Default:
"@"
+
+
Specify the delimiting character than will be used for configuration.
+
diff --git a/plugins/modules/nxos_banner.py b/plugins/modules/nxos_banner.py index f946dc0ac..1a170783a 100644 --- a/plugins/modules/nxos_banner.py +++ b/plugins/modules/nxos_banner.py @@ -45,6 +45,10 @@ - exec - motd type: str + multiline_delimiter: + description: Specify the delimiting character than will be used for configuration. + default: "@" + type: str text: description: - The banner text that should be present in the remote device running configuration. @@ -126,9 +130,11 @@ def map_obj_to_commands(want, have, module): commands.append("no banner %s" % module.params["banner"]) elif state == "present" and want.get("text") != have.get("text"): - banner_cmd = "banner %s @\n%s\n@" % ( + banner_cmd = "banner %s %s\n%s\n%s" % ( module.params["banner"], + module.params["multiline_delimiter"], want["text"], + module.params["multiline_delimiter"], ) commands.append(banner_cmd) @@ -181,6 +187,7 @@ def main(): argument_spec = dict( banner=dict(required=True, choices=["exec", "motd"]), text=dict(), + multiline_delimiter=dict(default="@"), state=dict(default="present", choices=["present", "absent"]), ) diff --git a/tests/unit/modules/network/nxos/test_nxos_banner.py b/tests/unit/modules/network/nxos/test_nxos_banner.py index 7f8faf3a9..c9d564ddb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_banner.py +++ b/tests/unit/modules/network/nxos/test_nxos_banner.py @@ -100,3 +100,17 @@ def test_nxos_banner_with_preserved_spaces(self): commands = ["banner motd @\n foo \n\n@"] self.run_commands.return_value = commands self.execute_module(changed=True, commands=commands) + + def test_nxos_banner_multiline_delimiter(self): + set_module_args( + dict( + banner="exec", + text="this is my exec banner\nthat contains my email address email@address.com \nand it's a multiline string\n", + multiline_delimiter="*", + ), + ) + commands = [ + "banner exec *\nthis is my exec banner\nthat contains my email address email@address.com \nand it's a multiline string\n\n*", + ] + self.run_commands.return_value = commands + self.execute_module(changed=True, commands=commands) From d4ade0984286bee68ab9a4f4720b9a8f9e9afc71 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Mon, 29 May 2023 12:19:23 +0530 Subject: [PATCH 094/166] Health check doc update example fix (#643) * junos_interfaces docs updated * sync docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make l2_interfaces doc sane * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make l3_interfaces sane * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix sanity * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Nilashish Chakraborty Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelogs/fragments/update_inft_docs.yaml | 5 + docs/cisco.nxos.nxos_interfaces_module.rst | 223 +++++++++--- docs/cisco.nxos.nxos_l2_interfaces_module.rst | 169 +++++++-- docs/cisco.nxos.nxos_l3_interfaces_module.rst | 325 +++++++++++++++--- plugins/modules/nxos_interfaces.py | 229 +++++++++--- plugins/modules/nxos_l2_interfaces.py | 172 +++++++-- plugins/modules/nxos_l3_interfaces.py | 325 +++++++++++++++--- 7 files changed, 1213 insertions(+), 235 deletions(-) create mode 100644 changelogs/fragments/update_inft_docs.yaml diff --git a/changelogs/fragments/update_inft_docs.yaml b/changelogs/fragments/update_inft_docs.yaml new file mode 100644 index 000000000..8aa14b89c --- /dev/null +++ b/changelogs/fragments/update_inft_docs.yaml @@ -0,0 +1,5 @@ +--- +doc_changes: + - nxos_interfaces - Fixed module documentation and examples. + - nxos_l2_interfaces - Fixed module documentation and examples. + - nxos_l3_interfaces - Fixed module documentation and examples. diff --git a/docs/cisco.nxos.nxos_interfaces_module.rst b/docs/cisco.nxos.nxos_interfaces_module.rst index 687232c90..9ab81a313 100644 --- a/docs/cisco.nxos.nxos_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_interfaces_module.rst @@ -283,9 +283,13 @@ Examples # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 # description testing - # mtu 1800 + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management - name: Merge provided configuration with device configuration cisco.nxos.nxos_interfaces: @@ -298,26 +302,58 @@ Examples enabled: false state: merged + # Task Output + # ----------- + # + # before: + # - description: testing + # name: Ethernet1/1 + # - description: mgmt interface + # name: mgmt0 + # commands: + # - interface Ethernet1/1 + # - description Configured by Ansible + # - interface Ethernet1/2 + # - description Configured by Ansible Network + # - shutdown + # after: + # - description: Configured by Ansible + # name: Ethernet1/1 + # - description: Configured by Ansible Network + # enabled: false + # name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 - # description Configured by Ansible - # no shutdown - # mtu 1800 - # interface Ethernet2 - # description Configured by Ansible Network - # shutdown - + # description Configured by Ansible + # interface Ethernet1/2 + # description Configured by Ansible Network + # shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management # Using replaced # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # description Interface 1/1 + # description Updated by Ansible # interface Ethernet1/2 + # description Configured by Ansible Network + # shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management - name: Replaces device configuration of listed interfaces with provided configuration cisco.nxos.nxos_interfaces: @@ -325,37 +361,67 @@ Examples - name: Ethernet1/1 description: Configured by Ansible enabled: true - mtu: 2000 + mtu: 9000 - name: Ethernet1/2 description: Configured by Ansible Network enabled: false mode: layer2 state: replaced + # Task Output + # ----------- + # + # before: + # - description: Updated by Ansible + # name: Ethernet1/1 + # - description: Configured by Ansible Network + # enabled: false + # name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # commands: + # - interface Ethernet1/1 + # - mtu 1500 + # - interface Ethernet1/2 + # - description Updated by Ansible + # after: + # - description: Updated by Ansible + # name: Ethernet1/1 + # - description: Updated by Ansible + # enabled: false + # name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 - # description Configured by Ansible - # no shutdown - # mtu 1500 - # interface Ethernet2/2 - # description Configured by Ansible Network - # shutdown - # switchport - + # description Updated by Ansible + # interface Ethernet1/2 + # description Updated by Ansible + # shutdown + # interface mgmt0 + # description mgmt interface + # ip address dhcp + # vrf member management # Using overridden # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # description Interface Ethernet1/1 + # description Updated by Ansible # interface Ethernet1/2 + # description Updated by Ansible + # shutdown # interface mgmt0 - # description Management interface - # ip address dhcp + # description mgmt interface + # ip address dhcp + # vrf member management - name: Override device configuration of all interfaces with provided configuration cisco.nxos.nxos_interfaces: @@ -365,45 +431,98 @@ Examples - name: Ethernet1/2 description: Configured by Ansible Network enabled: false + - description: mgmt interface + name: mgmt0 state: overridden + # Task Output + # ----------- + # + # before: + # - description: Updated by Ansible + # name: Ethernet1/1 + # - description: Updated by Ansible + # enabled: false + # name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # commands: + # - interface Ethernet1/1 + # - no description + # - interface Ethernet1/2 + # - description Configured by Ansible Network + # after: + # - name: Ethernet1/1 + # - description: Configured by Ansible Network + # enabled: false + # name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 - # description Configured by Ansible Network - # shutdown + # description Configured by Ansible Network + # shutdown # interface mgmt0 - # ip address dhcp - + # description mgmt interface + # ip address dhcp + # vrf member management # Using deleted # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # description Interface Ethernet1/1 # interface Ethernet1/2 + # description Configured by Ansible Network + # shutdown # interface mgmt0 - # description Management interface - # ip address dhcp + # description mgmt interface + # ip address dhcp + # vrf member management - name: Delete or return interface parameters to default settings cisco.nxos.nxos_interfaces: config: - - name: Ethernet1/1 + - name: Ethernet1/2 state: deleted + # Task Output + # ----------- + # + # before: + # - name: Ethernet1/1 + # - description: Configured by Ansible Network + # enabled: false + # name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # commands: + # - interface Ethernet1/2 + # - no description + # - no shutdown + # after: + # - name: Ethernet1/1 + # - name: Ethernet1/2 + # - description: mgmt interface + # name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 # interface mgmt0 - # description Management interface - # ip address dhcp + # description mgmt interface + # ip address dhcp + # vrf member management # Using rendered @@ -420,9 +539,9 @@ Examples duplex: full state: rendered - # Task Output (redacted) - # ----------------------- - + # Task Output + # ----------- + # # rendered: # - "interface Ethernet1/1" # - "description outbound-intf" @@ -436,6 +555,7 @@ Examples # parsed.cfg # ------------ + # # interface Ethernet1/800 # description test-1 # speed 1000 @@ -453,8 +573,9 @@ Examples running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output + # ----------- + # # parsed: # - description: "test-1" # duplex: "half" @@ -462,7 +583,6 @@ Examples # mode: "layer3" # name: "Ethernet1/800" # speed: "1000" - # # - description: "test-2" # enabled: true # mode: "layer2" @@ -471,8 +591,10 @@ Examples # Using gathered - # Existing device config state - # ----------------------------- + # Before state: + # ------------- + # + # switch# show running-config | section interface # interface Ethernet1/1 # description outbound-intf # switchport @@ -488,8 +610,9 @@ Examples cisco.nxos.nxos_interfaces: state: gathered - # Task output (redacted) - # ----------------------- + # Task output + # ----------- + # # - name: Ethernet1/1 # description: outbound-intf # mode: layer2 @@ -500,8 +623,10 @@ Examples # Using purged - # Existing device config state - # ----------------------------- + # Before state: + # ------------- + # + # switch# show running-config | section interface # interface Vlan1 # interface Vlan42 # mtu 1800 @@ -522,6 +647,7 @@ Examples # Task output # ------------ + # # before: # - name: Vlan1 # - mtu: '1800' @@ -532,18 +658,25 @@ Examples # - name: Ethernet1/2 # - description: sub-intf # name: Ethernet1/2.100 - # # commands: # - no interface port-channel10 # - no interface Ethernet1/2.100 # - no interface Vlan42 - # # after: # - name: Vlan1 # - name: port-channel11 # - name: Ethernet1/1 # - name: Ethernet1/2 + # After state: + # ------------- + # + # switch# show running-config | section interface + # interface Vlan1 + # interface port-channel11 + # interface Ethernet1/1 + # interface Ethernet1/2 + Return Values diff --git a/docs/cisco.nxos.nxos_l2_interfaces_module.rst b/docs/cisco.nxos.nxos_l2_interfaces_module.rst index e3292a2e6..2d2248800 100644 --- a/docs/cisco.nxos.nxos_l2_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_l2_interfaces_module.rst @@ -240,15 +240,15 @@ Examples # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # switchport access vlan 20 # interface Ethernet1/2 # switchport trunk native vlan 20 # interface mgmt0 # ip address dhcp # ipv6 address auto-config - - name: Merge provided configuration with device configuration. + - name: Merge provided configuration with device configuration cisco.nxos.nxos_l2_interfaces: config: - name: Ethernet1/1 @@ -260,9 +260,35 @@ Examples vlan: 30 state: merged + # Task Output + # ----------- + # + # before: + # - name: Loopback999 + # - name: Ethernet1/2 + # - name: mgmt0 + # - name: Ethernet1/1 + # commands: + # - interface Ethernet1/1 + # - switchport trunk allowed vlan 2,4,15 + # - switchport trunk native vlan 10 + # - interface Ethernet1/2 + # - switchport access vlan 30 + # after: + # - name: Ethernet1/1 + # trunk: + # allowed_vlans: 2,4,15 + # native_vlan: 10 + # - access: + # vlan: 30 + # name: Ethernet1/2 + # - name: mgmt0 + # - name: Loopback999 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 # switchport trunk native vlan 10 # switchport trunk allowed vlans 2,4,15 @@ -272,16 +298,17 @@ Examples # ip address dhcp # ipv6 address auto-config - # Using replaced # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # switchport access vlan 20 + # switchport trunk native vlan 10 + # switchport trunk allowed vlans 2,4,15 # interface Ethernet1/2 - # switchport trunk native vlan 20 + # switchport access vlan 30 # interface mgmt0 # ip address dhcp # ipv6 address auto-config @@ -295,9 +322,37 @@ Examples allowed_vlans: 5-10, 15 state: replaced + # Task Output + # ----------- + # + # before: + # - name: Ethernet1/1 + # trunk: + # allowed_vlans: 2,4,15 + # native_vlan: 10 + # - access: + # vlan: 30 + # name: Ethernet1/2 + # - name: mgmt0 + # commands: + # - interface Ethernet1/1 + # - no switchport trunk native vlan + # - switchport trunk allowed vlan 5-10,15 + # - switchport trunk native vlan 20 + # after: + # - name: Ethernet1/1 + # trunk: + # allowed_vlans: 5-10,15 + # native_vlan: 20 + # - access: + # vlan: 30 + # name: Ethernet1/2 + # - name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 # switchport trunk native vlan 20 # switchport trunk allowed vlan 5-10,15 @@ -308,22 +363,23 @@ Examples # ip address dhcp # ipv6 address auto-config - # Using overridden # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # switchport access vlan 20 + # switchport trunk native vlan 20 + # switchport trunk allowed vlan 5-10,15 # interface Ethernet1/2 # switchport trunk native vlan 20 + # switchport mode trunk # interface mgmt0 # ip address dhcp # ipv6 address auto-config - - name: Override device configuration of all L2 interfaces on device with provided - configuration. + - name: Override device configuration with provided configuration. cisco.nxos.nxos_l2_interfaces: config: - name: Ethernet1/2 @@ -331,9 +387,33 @@ Examples vlan: 30 state: overridden + # Task Output + # ----------- + # + # before: + # - name: Ethernet1/1 + # trunk: + # allowed_vlans: 5,6,7,8,9,10,15 + # native_vlan: 20 + # - access: + # vlan: 30 + # name: Ethernet1/2 + # - name: mgmt0 + # commands: + # - interface Ethernet1/1 + # - no switchport trunk allowed vlan + # - no switchport trunk native vlan + # after: + # - name: Ethernet1/1 + # - access: + # vlan: 30 + # name: Ethernet1/2 + # - name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 # switchport access vlan 30 @@ -347,10 +427,12 @@ Examples # Before state: # ------------- # + # switch# show running-config | section interface # interface Ethernet1/1 - # switchport access vlan 20 + # switchport trunk native vlan 10 + # switchport trunk allowed vlan 2,4,15 # interface Ethernet1/2 - # switchport trunk native vlan 20 + # switchport access vlan 30 # interface mgmt0 # ip address dhcp # ipv6 address auto-config @@ -363,9 +445,33 @@ Examples - name: Ethernet1/2 state: deleted + # Task Output + # ----------- + # + # before: + # - name: Ethernet1/1 + # trunk: + # allowed_vlans: 2,4,15 + # native_vlan: 10 + # - access: + # vlan: 30 + # name: Ethernet1/2 + # - name: mgmt0 + # commands: + # - interface Ethernet1/1 + # - no switchport trunk allowed vlan + # - no switchport trunk native vlan + # - interface Ethernet1/2 + # - no switchport access vlan + # after: + # - name: Ethernet1/1 + # - name: Ethernet1/2 + # - name: mgmt0 + # After state: # ------------ # + # switch# show running-config | section interface # interface Ethernet1/1 # interface Ethernet1/2 # interface mgmt0 @@ -390,23 +496,24 @@ Examples allowed_vlans: 5-10, 15 state: rendered - # Task Output (redacted) - # ----------------------- - + # Task Output + # ----------- + # # rendered: - # - "interface Ethernet1/1" - # - "switchport trunk allowed vlan 2,4,15" - # - "switchport trunk native vlan 10" - # - "interface Ethernet1/2" - # - "switchport access vlan 30" - # - "interface Ethernet1/3" - # - "switchport trunk allowed vlan 5,6,7,8,9,10,15" - # - "switchport trunk native vlan 20" + # - interface Ethernet1/1 + # - switchport trunk allowed vlan 2,4,15 + # - switchport trunk native vlan 10 + # - interface Ethernet1/2 + # - switchport access vlan 30 + # - interface Ethernet1/3 + # - switchport trunk allowed vlan 5-10,15 + # - switchport trunk native vlan 20 # Using parsed # parsed.cfg # ------------ + # # interface Ethernet1/800 # switchport access vlan 18 # switchport trunk allowed vlan 210 @@ -418,8 +525,9 @@ Examples running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output + # ----------- + # # parsed: # - name: Ethernet1/800 # access: @@ -432,9 +540,10 @@ Examples # Using gathered - # Existing device config state - # ------------------------------- - # Nexus9kvI5# sh running-config | section ^interface + # Before state: + # ------------- + # + # switch# sh running-config | section ^interface # interface Ethernet1/1 # switchport access vlan 6 # switchport trunk allowed vlan 200 @@ -445,15 +554,15 @@ Examples cisco.nxos.nxos_l2_interfaces: state: gathered - # Task output (redacted) - # ----------------------- + # Task output + # ----------- + # # gathered: # - name: "Ethernet1/1" # access: # vlan: 6 # trunk: # allowed_vlans: "200" - # # - name: "Ethernet1/2" # trunk: # native_vlan: 10 diff --git a/docs/cisco.nxos.nxos_l3_interfaces_module.rst b/docs/cisco.nxos.nxos_l3_interfaces_module.rst index 0f46e95d2..9241ff2fe 100644 --- a/docs/cisco.nxos.nxos_l3_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_l3_interfaces_module.rst @@ -285,7 +285,7 @@ Parameters
-
Enables/disables ip redirects
+
Enables/disables ip redirects.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ config + +
+ dictionary +
+
+ +
A list of BGP templates.
+
+
+ as_number + +
+ string +
+
+ +
Autonomous System Number of the router.
+
+
+ neighbor + +
+ list + / elements=dictionary +
+
+ +
Configure BGP peer templates.
+
+
+ address_family + +
+ list + / elements=dictionary +
+
+ +
Configure an address-family for peer.
+
+
+ advertise_map + +
+ dictionary +
+
+ +
Specify route-map for conditional advertisement.
+
+
+ exist_map + +
+ string +
+
+ +
Condition route-map to advertise only when prefix in condition exists.
+
+
+ non_exist_map + +
+ string +
+
+ +
Condition route-map to advertise only when prefix in condition does not exist.
+
+
+ route_map + +
+ string + / required +
+
+ +
Route-map name.
+
+
+ advertisement_interval + +
+ integer +
+
+ +
Minimum interval between sending BGP routing updates.
+
+
+ afi + +
+ string + / required +
+
+
    Choices: +
  • ipv4
  • +
  • ipv6
  • +
  • link-state
  • +
  • l2vpn
  • +
+
+
Address Family indicator.
+
+
+ allowas_in + +
+ dictionary +
+
+ +
Accept as-path with my AS present in it.
+
+
+ max_occurences + +
+ integer +
+
+ +
Number of occurrences of AS number, default is 3.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Activate allowas-in property.
+
+
+ as_override + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Override matching AS-number while sending update.
+
+
+ capability + +
+ dictionary +
+
+ +
Advertise capability to the peer.
+
+
+ additional_paths + +
+ dictionary +
+
+ +
Additional paths capability.
+
+
+ receive + +
+ string +
+
+
    Choices: +
  • enable
  • +
  • disable
  • +
+
+
Additional paths Receive capability.
+
+
+ send + +
+ string +
+
+
    Choices: +
  • enable
  • +
  • disable
  • +
+
+
Additional paths Send capability.
+
+
+ default_originate + +
+ dictionary +
+
+ +
Originate a default toward this peer.
+
+
+ route_map + +
+ string +
+
+ +
Route-map to specify criteria for originating default.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set default-originate attribute.
+
+
+ disable_peer_as_check + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Disable checking of peer AS-number while advertising.
+
+
+ filter_list + +
+ dictionary +
+
+ +
Name of filter-list.
+
+
+ inbound + +
+ string +
+
+ +
Apply policy to incoming routes.
+
+
+ outbound + +
+ string +
+
+ +
Apply policy to outgoing routes.
+
+
+ inherit + +
+ dictionary +
+
+ +
Inherit a peer-policy template.
+
+
+ peer_policy + +
+ string +
+
+ +
Peer-policy template to inherit.
+
+
+ maximum_prefix + +
+ dictionary +
+
+ +
Maximum number of prefixes from this neighbor.
+
+
+ generate_warning_threshold + +
+ integer +
+
+ +
Threshold percentage at which to generate a warning.
+
+
+ max_prefix_limit + +
+ integer +
+
+ +
Maximum prefix limit.
+
+
+ restart_interval + +
+ integer +
+
+ +
Restart bgp connection after limit is exceeded.
+
+
+ warning_only + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Only give a warning message when limit is exceeded.
+
+
+ next_hop_self + +
+ dictionary +
+
+ +
Set our address as nexthop (non-reflected).
+
+
+ all_routes + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set our address as nexthop for all routes.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set next-hop-self attribute.
+
+
+ next_hop_third_party + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Compute a third-party nexthop if possible.
+
+
+ prefix_list + +
+ dictionary +
+
+ +
Apply prefix-list.
+
+
+ inbound + +
+ string +
+
+ +
Apply policy to incoming routes.
+
+
+ outbound + +
+ string +
+
+ +
Apply policy to outgoing routes.
+
+
+ route_map + +
+ dictionary +
+
+ +
Apply route-map to neighbor.
+
+
+ inbound + +
+ string +
+
+ +
Name of policy to apply to incoming routes.
+
+
+ outbound + +
+ string +
+
+ +
Name of policy to apply to outgoing routes.
+
+
+ route_reflector_client + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Configure a neighbor as Route reflector client.
+
+
+ safi + +
+ string +
+
+
    Choices: +
  • unicast
  • +
  • multicast
  • +
  • mvpn
  • +
+
+
Sub Address Family indicator.
+
+
+ soft_reconfiguration_inbound + +
+ dictionary +
+
+ +
Soft reconfiguration.
+
+
+ always + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Always perform inbound soft reconfiguration.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set soft-reconfiguration inbound attribute.
+
+
+ soo + +
+ string +
+
+ +
Specify Site-of-origin extcommunity.
+
+
+ suppress_inactive + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Advertise only active routes to peer.
+
+
+ unsuppress_map + +
+ string +
+
+ +
Route-map to selectively unsuppress suppressed routes.
+
+
+ weight + +
+ integer +
+
+ +
Set default weight for routes from this neighbor.
+
+
+ bfd + +
+ dictionary +
+
+ +
Bidirectional Fast Detection for the neighbor.
+
+
+ multihop + +
+ dictionary +
+
+ +
Multihop session.
+
+
+ interval + +
+ dictionary +
+
+ +
Configure BFD session interval parameters.
+
+
+ min_rx_interval + +
+ integer + / required +
+
+ +
Minimum RX interval.
+
+
+ multiplier + +
+ integer + / required +
+
+ +
Detect Multiplier.
+
+
+ tx_interval + +
+ integer + / required +
+
+ +
TX interval in milliseconds.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set BFD multihop.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set BFD for this neighbor.
+
+
+ singlehop + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Single-hop session.
+
+
+ bmp_activate_server + +
+ integer +
+
+ +
Specify server ID for activating BMP monitoring for the peer.
+
+
+ capability + +
+ dictionary +
+
+ +
Capability.
+
+
+ suppress_4_byte_as + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Suppress 4-byte AS Capability.
+
+
+ description + +
+ string +
+
+ +
Neighbor specific descripion.
+
+
+ disable_connected_check + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Disable check for directly connected peer.
+
+
+ dont_capability_negotiate + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Don't negotiate capability with this neighbor.
+
+
+ dscp + +
+ string +
+
+ +
Set dscp value for tcp transport.
+
+
+ dynamic_capability + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Dynamic Capability
+
+
+ ebgp_multihop + +
+ integer +
+
+ +
Specify multihop TTL for remote peer.
+
+
+ graceful_shutdown + +
+ dictionary +
+
+ +
Graceful-shutdown for this neighbor.
+
+
+ activate + +
+ dictionary +
+
+ +
Send graceful-shutdown community.
+
+
+ route_map + +
+ string +
+
+ +
Apply route-map to modify attributes for outbound.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set activate.
+
+
+ inherit + +
+ dictionary +
+
+ +
Inherit a template.
+
+
+ peer_session + +
+ string +
+
+ +
Peer-session template to inherit.
+
+
+ local_as + +
+ string +
+
+ +
Specify the local-as number for the eBGP neighbor.
+
+
+ log_neighbor_changes + +
+ dictionary +
+
+ +
Log message for neighbor up/down event.
+
+
+ disable + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Disable logging of neighbor up/down event.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Set log-neighbor-changes.
+
+
+ low_memory + +
+ dictionary +
+
+ +
Behaviour in low memory situations.
+
+
+ exempt + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Do not shutdown this peer when under memory pressure.
+
+
+ name + +
+ string +
+
+ +
Name of the BGP peer template.
+
+
+ password + +
+ dictionary +
+
+ +
Configure a password for neighbor.
+
+
+ encryption + +
+ integer +
+
+ +
0 specifies an UNENCRYPTED neighbor password.
+
3 specifies an 3DES ENCRYPTED neighbor password will follow.
+
7 specifies a Cisco type 7 ENCRYPTED neighbor password will follow.
+
+
+ key + +
+ string +
+
+ +
Authentication password.
+
+
+ path_attribute + +
+ list + / elements=dictionary +
+
+ +
BGP path attribute optional filtering.
+
+
+ action + +
+ string +
+
+
    Choices: +
  • discard
  • +
  • treat-as-withdraw
  • +
+
+
Action.
+
+
+ range + +
+ dictionary +
+
+ +
Path attribute range.
+
+
+ end + +
+ integer +
+
+ +
Path attribute range end value.
+
+
+ start + +
+ integer +
+
+ +
Path attribute range start value.
+
+
+ type + +
+ integer +
+
+ +
Path attribute type
+
+
+ remote_as + +
+ string +
+
+ +
Specify Autonomous System Number of the neighbor.
+
+
+ remove_private_as + +
+ dictionary +
+
+ +
Remove private AS number from outbound updates.
+
+
+ all + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
All.
+
+
+ replace_as + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Replace.
+
+
+ set + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Remove private AS.
+
+
+ shutdown + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Administratively shutdown this neighbor.
+
+
+ timers + +
+ dictionary +
+
+ +
Configure keepalive and hold timers.
+
+
+ holdtime + +
+ integer +
+
+ +
Holdtime (seconds).
+
+
+ keepalive + +
+ integer +
+
+ +
Keepalive interval (seconds).
+
+
+ transport + +
+ dictionary +
+
+ +
BGP transport connection.
+
+
+ connection_mode + +
+ dictionary +
+
+ +
Specify type of connection.
+
+
+ passive + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Allow passive connection setup only.
+
+
+ ttl_security + +
+ dictionary +
+
+ +
Enable TTL Security Mechanism.
+
+
+ hops + +
+ integer +
+
+ +
Specify hop count for remote peer.
+
+
+ update_source + +
+ string +
+
+ +
Specify source of BGP session and updates.
+
+
+ running_config + +
+ string +
+
+ +
This option is used only with state parsed.
+
The value of this option should be the output received from the NX-OS device by executing the command show running-config bgp | section 'template'.
+
The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the parsed key within the result.
+
+
+ state + +
+ string +
+
+
    Choices: +
  • merged ←
  • +
  • replaced
  • +
  • overridden
  • +
  • deleted
  • +
  • parsed
  • +
  • gathered
  • +
  • rendered
  • +
+
+
The state the configuration should be left in.
+
Refer to examples for more details.
+
+
+ + +Notes +----- + +.. note:: + - Tested against NX-OS 9.3.6. + - Unsupported for Cisco MDS + - This module works with connection ``network_cli`` and ``httpapi``. + + + +Examples +-------- + +.. code-block:: yaml + + # Using merged + + # Before state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # nxos9k# + + - name: Merge the provided configuration with the existing running configuration + 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 + # Task Output + # ----------- + # before: {} + # + # commands: + # - 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 + # + # 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 + + # After state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # router bgp 65536 + # template peer neighbor_tmplt_1 + # capability suppress 4-byte-as + # bmp-activate-server 2 + # 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 + + # Using replaced + + # Before state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # router bgp 65536 + # template peer neighbor_tmplt_1 + # capability suppress 4-byte-as + # description Test_BGP_PEER_TEMPLATE_1 + # bmp-activate-server 2 + # 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 + + - name: Replace BGP templates configuration with provided configuration + 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 + inherit: + peer_session: psession1 + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65537 + state: replaced + + # Task Output + # ----------- + # + # before: + # 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 + # + # 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 + + # After state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # router bgp 65536 + # template peer neighbor_tmplt_1 + # inherit peer-session psession1 + # description Test_BGP_PEER_TEMPLATE_1 + # local-as 65537 + # 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 + # bmp-activate-server 2 + # timers 45 100 + # address-family ipv4 multicast + # advertise-map rmap1 exist-map emap1 + # as-override + # filter-list flist1 in + # filter-list flist2 out + + # Using overridden + # + # Before state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # router bgp 65536 + # template peer neighbor_tmplt_1 + # capability suppress 4-byte-as + # description Test_BGP_PEER_TEMPLATE_1 + # bmp-activate-server 2 + # 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 + + - name: Override BGP templates configuration with provided configuration + 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 + inherit: + peer_session: psession1 + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65537 + state: overridden + + # Task Output + # ----------- + # + # before: + # 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 + # + # 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" + + # After state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # router bgp 65536 + # template peer neighbor_tmplt_1 + # inherit peer-session psession1 + # description Test_BGP_PEER_TEMPLATE_1 + # local-as 65537 + # address-family ipv4 unicast + # advertise-map rmap1 non-exist-map nemap1 + # advertisement-interval 60 + # disable-peer-as-check + + # Using deleted + + # Before state: + # -------------- + # + # nxos9k# show running-config | section "^router bgp" + # router bgp 65536 + # template peer neighbor_tmplt_1 + # capability suppress 4-byte-as + # description Test_BGP_PEER_TEMPLATE_1 + # bmp-activate-server 2 + # 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 + + - name: Delete BGP configs handled by this module + cisco.nxos.nxos_bgp_templates: + state: deleted + + # Task Output + # ----------- + # + # before: + # 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 + # + # commands: + # - router bgp 65536 + # - no template peer neighbor_tmplt_1 + # - no template peer neighbor_tmplt_2 + # + # after: {} + + # After state: + # ------------- + # nxos9k# show running-config | section "^router bgp" + # nxos9k# + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ after + +
+ dictionary +
+
when changed +
The resulting configuration after module execution.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ before + +
+ dictionary +
+
when state is merged, replaced, overridden, deleted or purged +
The configuration prior to the module execution.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ commands + +
+ list +
+
when state is merged, replaced, overridden, deleted or purged +
The set of commands pushed to the remote device.
+
+
Sample:
+
['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']
+
+
+ gathered + +
+ list +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ list +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['router bgp 65536', 'template peer neighbor_tmplt_1', 'bmp-activate-server 2', 'no capability suppress 4-byte-as', 'no template peer neighbor_tmplt_2']
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Nilashish Chakraborty (@NilashishC) diff --git a/meta/__init__.py b/meta/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/argspec/bgp_templates/__init__.py b/plugins/module_utils/network/nxos/argspec/bgp_templates/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py new file mode 100644 index 000000000..b0b122158 --- /dev/null +++ b/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py @@ -0,0 +1,310 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the +# ansible.content_builder. +# +# Manually editing this file is not advised. +# +# To update the argspec make the desired changes +# in the module docstring and re-run +# ansible.content_builder. +# +############################################# + +""" +The arg spec for the nxos_bgp_templates module +""" + + +class Bgp_templatesArgs(object): # pylint: disable=R0903 + """The arg spec for the nxos_bgp_templates module""" + + argument_spec = { + "running_config": {"type": "str"}, + "config": { + "type": "dict", + "options": { + "as_number": {"type": "str"}, + "neighbor": { + "type": "list", + "elements": "dict", + "options": { + "name": {"type": "str"}, + "address_family": { + "type": "list", + "elements": "dict", + "options": { + "afi": { + "type": "str", + "choices": [ + "ipv4", + "ipv6", + "link-state", + "l2vpn", + ], + "required": True, + }, + "safi": { + "type": "str", + "choices": ["unicast", "multicast", "mvpn"], + }, + "advertise_map": { + "type": "dict", + "options": { + "route_map": { + "type": "str", + "required": True, + }, + "exist_map": {"type": "str"}, + "non_exist_map": {"type": "str"}, + }, + }, + "advertisement_interval": {"type": "int"}, + "allowas_in": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "max_occurences": {"type": "int"}, + }, + }, + "as_override": {"type": "bool"}, + "capability": { + "type": "dict", + "options": { + "additional_paths": { + "type": "dict", + "options": { + "receive": { + "type": "str", + "choices": [ + "enable", + "disable", + ], + }, + "send": { + "type": "str", + "choices": [ + "enable", + "disable", + ], + }, + }, + }, + }, + }, + "default_originate": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "route_map": {"type": "str"}, + }, + }, + "disable_peer_as_check": {"type": "bool"}, + "filter_list": { + "type": "dict", + "options": { + "inbound": {"type": "str"}, + "outbound": {"type": "str"}, + }, + }, + "inherit": { + "type": "dict", + "options": {"peer_policy": {"type": "str"}}, + }, + "maximum_prefix": { + "type": "dict", + "options": { + "max_prefix_limit": {"type": "int"}, + "generate_warning_threshold": { + "type": "int", + }, + "restart_interval": {"type": "int"}, + "warning_only": {"type": "bool"}, + }, + }, + "next_hop_self": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "all_routes": {"type": "bool"}, + }, + }, + "next_hop_third_party": {"type": "bool"}, + "prefix_list": { + "type": "dict", + "options": { + "inbound": {"type": "str"}, + "outbound": {"type": "str"}, + }, + }, + "route_map": { + "type": "dict", + "options": { + "inbound": {"type": "str"}, + "outbound": {"type": "str"}, + }, + }, + "route_reflector_client": {"type": "bool"}, + "soft_reconfiguration_inbound": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "always": {"type": "bool"}, + }, + }, + "soo": {"type": "str"}, + "suppress_inactive": {"type": "bool"}, + "unsuppress_map": {"type": "str"}, + "weight": {"type": "int"}, + }, + }, + "bfd": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "singlehop": {"type": "bool"}, + "multihop": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "interval": { + "type": "dict", + "options": { + "tx_interval": {"type": "int", "required": True}, + "min_rx_interval": { + "type": "int", + "required": True, + }, + "multiplier": {"type": "int", "required": True}, + }, + }, + }, + }, + }, + }, + "bmp_activate_server": {"type": "int"}, + "capability": { + "type": "dict", + "options": {"suppress_4_byte_as": {"type": "bool"}}, + }, + "description": {"type": "str"}, + "disable_connected_check": {"type": "bool"}, + "dont_capability_negotiate": {"type": "bool"}, + "dscp": {"type": "str"}, + "dynamic_capability": {"type": "bool"}, + "ebgp_multihop": {"type": "int"}, + "graceful_shutdown": { + "type": "dict", + "options": { + "activate": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "route_map": {"type": "str"}, + }, + }, + }, + }, + "inherit": { + "type": "dict", + "options": {"peer_session": {"type": "str"}}, + }, + "local_as": {"type": "str"}, + "log_neighbor_changes": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + }, + }, + "low_memory": { + "type": "dict", + "options": {"exempt": {"type": "bool"}}, + }, + "password": { + "type": "dict", + "no_log": False, + "options": { + "encryption": {"type": "int"}, + "key": {"type": "str", "no_log": True}, + }, + }, + "path_attribute": { + "type": "list", + "elements": "dict", + "options": { + "action": { + "type": "str", + "choices": ["discard", "treat-as-withdraw"], + }, + "type": {"type": "int"}, + "range": { + "type": "dict", + "options": { + "start": {"type": "int"}, + "end": {"type": "int"}, + }, + }, + }, + }, + "remote_as": {"type": "str"}, + "remove_private_as": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "replace_as": {"type": "bool"}, + "all": {"type": "bool"}, + }, + }, + "shutdown": {"type": "bool"}, + "timers": { + "type": "dict", + "options": { + "keepalive": {"type": "int"}, + "holdtime": {"type": "int"}, + }, + }, + "transport": { + "type": "dict", + "options": { + "connection_mode": { + "type": "dict", + "options": {"passive": {"type": "bool"}}, + }, + }, + }, + "ttl_security": { + "type": "dict", + "options": {"hops": {"type": "int"}}, + }, + "update_source": {"type": "str"}, + }, + }, + }, + }, + "state": { + "type": "str", + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "parsed", + "gathered", + "rendered", + ], + "default": "merged", + }, + } # pylint: disable=C0301 diff --git a/plugins/module_utils/network/nxos/config/bgp_templates/__init__.py b/plugins/module_utils/network/nxos/config/bgp_templates/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py new file mode 100644 index 000000000..dc2f98d53 --- /dev/null +++ b/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py @@ -0,0 +1,227 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The nxos_bgp_templates config file. +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to its desired end-state is +created. +""" + +from copy import deepcopy + +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( + ResourceModule, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, +) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_templates import ( + Bgp_templatesTemplate, +) + + +class Bgp_templates(ResourceModule): + """ + The nxos_bgp_templates config class + """ + + def __init__(self, module): + super(Bgp_templates, self).__init__( + empty_fact_val={}, + facts_module=Facts(module), + module=module, + resource="bgp_templates", + tmplt=Bgp_templatesTemplate(), + ) + self.parsers = [ + "bfd", + "bfd.multihop.interval", + "bmp_activate_server", + "capability", + "description", + "disable_connected_check", + "dont_capability_negotiate", + "dscp", + "dynamic_capability", + "ebgp_multihop", + "graceful_shutdown", + "inherit.peer_session", + "local_as", + "log_neighbor_changes", + "low_memory", + "password", + "remote_as", + "remove_private_as", + "shutdown", + "timers", + "transport", + "ttl_security", + "update_source", + ] + self.af_parsers = [ + "advertise_map.exist_map", + "advertise_map.non_exist_map", + "advertisement_interval", + "allowas_in", + "as_override", + "capability.additional_paths.receive", + "capability.additional_paths.send", + "default_originate", + "disable_peer_as_check", + "filter_list.inbound", + "inherit.peer_policy", + "filter_list.outbound", + "maximum_prefix", + "next_hop_self", + "next_hop_third_party", + "prefix_list.inbound", + "prefix_list.outbound", + "route_map.inbound", + "route_map.outbound", + "route_reflector_client", + "soft_reconfiguration_inbound", + "soo", + "suppress_inactive", + "unsuppress_map", + "weight", + ] + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + if self.state not in ["parsed", "gathered"]: + self.generate_commands() + self.run_commands() + return self.result + + def generate_commands(self): + """Generate configuration commands to send based on + want, have and desired state. + """ + wantd = self._list_to_dict(deepcopy(self.want)) + haved = self._list_to_dict(deepcopy(self.have)) + + # if state is merged, merge want onto have and then compare + if self.state == "merged": + wantd = dict_merge(haved, wantd) + + w_asn = wantd.pop("as_number", "") + h_asn = haved.pop("as_number", "") + + asn = w_asn or h_asn + + # if state is deleted, empty out wantd and set haved to wantd + if self.state == "deleted": + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} + wantd = {} + + # remove superfluous config for overridden and deleted + if self.state in ["overridden", "deleted"]: + cmds = [] + for k, have in iteritems(haved): + if k not in wantd: + cmds.append("no template peer {0}".format(have["name"])) + self.commands.extend(cmds) + + for k, want in iteritems(wantd): + begin = len(self.commands) + self._compare(want=want, have=haved.pop(k, {})) + if len(self.commands) != begin: + self.commands.insert(begin, "template peer {0}".format(want["name"])) + + if self.commands: + self.commands.insert(0, "router bgp {0}".format(asn)) + + def _compare(self, want, have): + """Leverages the base class `compare()` method and + populates the list of commands to be run by comparing + the `want` and `have` data with the `parsers` defined + for the Bgp_templates network resource. + """ + self.compare(parsers=self.parsers, want=want, have=have) + self._compare_path_attribute(want=want, have=have) + + w_af = want.get("address_family", {}) + h_af = have.get("address_family", {}) + self._afs_compare(want=w_af, have=h_af) + + def _compare_path_attribute(self, want, have): + """Custom handling of neighbor path_attribute + option. + + :params want: the want neighbor dictionary + :params have: the have neighbor dictionary + """ + w_p_attr = want.get("path_attribute", {}) + h_p_attr = have.get("path_attribute", {}) + + for wkey, wentry in iteritems(w_p_attr): + if wentry != h_p_attr.pop(wkey, {}): + self.addcmd(wentry, "path_attribute", False) + + # remove remaining items in have for replaced + for hkey, hentry in iteritems(h_p_attr): + self.addcmd(hentry, "path_attribute", True) + + def _afs_compare(self, want, have): + for name, wentry in iteritems(want): + begin = len(self.commands) + self._af_compare(want=wentry, have=have.pop(name, {})) + if begin != len(self.commands): + self.commands.insert(begin, self._tmplt.render(wentry, "address_family", False)) + for name, hentry in iteritems(have): + self.commands.append(self._tmplt.render(hentry, "address_family", True)) + + def _af_compare(self, want, have): + self.compare(parsers=self.af_parsers, want=want, have=have) + + def _list_to_dict(self, data): + def _build_key(x): + """Build primary key for path_attribute + option. + :params x: path_attribute dictionary + :returns: primary key as tuple + """ + key_1 = "start_{0}".format(x.get("range", {}).get("start", "")) + key_2 = "end_{0}".format(x.get("range", {}).get("end", "")) + key_3 = "type_{0}".format(x.get("type", "")) + key_4 = x["action"] + + return (key_1, key_2, key_3, key_4) + + new_data = {} + new_data["as_number"] = data.pop("as_number", None) + + for k, v in iteritems(data): + for entry in v: + if "address_family" in entry: + entry["address_family"] = { + (x["afi"], x.get("safi")): x for x in entry["address_family"] + } + if "path_attribute" in entry: + entry["path_attribute"] = { + _build_key(x): x for x in entry.get("path_attribute", []) + } + + # attach top-level keys with their values + tmp = {(k + "_" + x["name"]): x for x in v} + new_data.update(tmp) + + return new_data diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index 32c5f6fe7..dd1e4aa32 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -83,7 +83,7 @@ def get_system_defaults(self): def edit_config(self, commands): """Wrapper method for `_connection.edit_config()` - This method exists solely to allow the unit test framework to mock device connection calls. + This method exists solely to allow the unit test framework to mcdock device connection calls. """ return self._connection.edit_config(commands) diff --git a/plugins/module_utils/network/nxos/facts/bgp_templates/__init__.py b/plugins/module_utils/network/nxos/facts/bgp_templates/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py new file mode 100644 index 000000000..7cdb3018e --- /dev/null +++ b/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The nxos bgp_templates fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_templates.bgp_templates import ( + Bgp_templatesArgs, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.bgp_templates import ( + Bgp_templatesTemplate, +) + + +class Bgp_templatesFacts(object): + """The nxos bgp_templates facts class""" + + def __init__(self, module): + self._module = module + self.argument_spec = Bgp_templatesArgs.argument_spec + + def get_config(self, connection): + """Wrapper method for `connection.get()` + This method exists solely to allow the unit test framework to mock device connection calls. + """ + as_number = connection.get("show running-config bgp | include 'router bgp'") + templates = connection.get("show running-config bgp | section 'template'") + + return as_number + "\n" + templates + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for Bgp_templates network resource + + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + + :rtype: dictionary + :returns: facts + """ + facts = {} + + if not data: + data = self.get_config(connection) + + data = self._flatten_config(data) + + # parse native config using the Bgp_templates template + bgp_templates_parser = Bgp_templatesTemplate(lines=data, module=self._module) + parsed = bgp_templates_parser.parse() + + objs = {} + # pop top-level keys and assign values to them + for k, v in iteritems(parsed): + if k == "as_number": + objs[k] = v + else: + objs[k] = list(v.values()) + for x in objs[k]: + if "address_family" in x: + x["address_family"] = list(x["address_family"].values()) + + ansible_facts["ansible_network_resources"].pop("bgp_templates", None) + + params = utils.remove_empties( + bgp_templates_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), + ) + + facts["bgp_templates"] = params.get("config", {}) + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts + + def _flatten_config(self, data): + flattened_data = [] + cur_peer = "" + data = data.split("\n") + + for x in data: + x = x.strip() + if x.startswith("template peer"): + cur_peer = x + " " + elif x.startswith("address-family"): + # a template peer <> line has to preceed AF line + x = cur_peer + x + flattened_data.append(x) + + return flattened_data diff --git a/plugins/module_utils/network/nxos/facts/facts.py b/plugins/module_utils/network/nxos/facts/facts.py index b70cb590d..4daaa6b75 100644 --- a/plugins/module_utils/network/nxos/facts/facts.py +++ b/plugins/module_utils/network/nxos/facts/facts.py @@ -34,6 +34,9 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_neighbor_address_family.bgp_neighbor_address_family import ( Bgp_neighbor_address_familyFacts, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_templates.bgp_templates import ( + Bgp_templatesFacts, +) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname import ( HostnameFacts, ) @@ -143,6 +146,7 @@ ntp_global=Ntp_globalFacts, snmp_server=Snmp_serverFacts, hostname=HostnameFacts, + bgp_templates=Bgp_templatesFacts, ) MDS_FACT_RESOURCE_SUBSETS = dict( logging_global=Logging_globalFacts, diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py b/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py new file mode 100644 index 000000000..9628fdeca --- /dev/null +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py @@ -0,0 +1,1166 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The Bgp_templates parser templates file. This contains +a list of parser definitions and associated functions that +facilitates both facts gathering and native command generation for +the given network resource. +""" + +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( + NetworkTemplate, +) + + +def _tmplt_bfd(proc): + bfd = proc.get("bfd", {}) + cmd = None + + if bfd.get("set"): + cmd = "bfd" + if bfd.get("singlehop"): + cmd = "bfd singlehop" + elif bfd.get("multihop", {}).get("set"): + cmd = "bfd multihop" + + return cmd + + +def _tmplt_path_attribute(proc): + cmd = "path-attribute {action}".format(**proc) + + if "type" in proc: + cmd += " {type}".format(**proc) + elif "range" in proc: + cmd += " range {start} {end}".format(**proc["range"]) + cmd += " in" + return cmd + + +class Bgp_templatesTemplate(NetworkTemplate): + def __init__(self, lines=None, module=None): + super(Bgp_templatesTemplate, self).__init__(lines=lines, tmplt=self, module=module) + + # fmt: off + PARSERS = [ + { + "name": "as_number", + "getval": re.compile( + r""" + ^router\sbgp\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "router bgp {{ as_number }}", + "result": { + "as_number": "{{ as_number }}", + }, + }, + { + "name": "peer.name", + "getval": re.compile( + r""" + template\speer\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "template peer {{ name }}", + "result": { + "neighbor": { + "{{ name }}": { + "name": "{{ name }}", + }, + }, + }, + "shared": True, + }, + { + "name": "bfd", + "getval": re.compile( + r""" + (?Pbfd) + (\s(?Psinglehop))? + (\s(?Pmultihop))? + $""", re.VERBOSE, + ), + "setval": _tmplt_bfd, + "result": { + "neighbor": { + "{{ name }}": { + "bfd": { + "set": "{{ True if bfd is defined and singlehop is undefined and multihop is undefined else None }}", + "singlehop": "{{ not not singlehop }}", + "multihop": { + "set": "{{ not not multihop }}", + }, + }, + }, + }, + }, + }, + { + "name": "bfd.multihop.interval", + "getval": re.compile( + r""" + bfd\smultihop\sinterval + \s(?P\d+) + \smin_rx\s(?P\d+) + \smultiplier\s(?P\d+) + $""", re.VERBOSE, + ), + "setval": "bfd multihop interval" + " {{ bfd.multihop.interval.tx_interval }}" + " min_rx {{ bfd.multihop.interval.min_rx_interval }}" + " multiplier {{ bfd.multihop.interval.multiplier }}", + "result": { + "neighbor": { + "{{ name }}": { + "bfd": { + "multihop": { + "interval": { + "tx_interval": "{{ tx_interval }}", + "min_rx_interval": "{{ min_rx_interval }}", + "multiplier": "{{ multiplier }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "bmp_activate_server", + "getval": re.compile( + r""" + bmp-activate-server\s(?P\d+) + $""", re.VERBOSE, + ), + "setval": "bmp-activate-server {{ bmp_activate_server }}", + "result": { + "neighbor": { + "{{ name }}": { + "bmp_activate_server": "{{ bmp_activate_server }}", + }, + }, + }, + }, + { + "name": "capability", + "getval": re.compile( + r""" + capability\ssuppress\s(?P4-byte-as) + $""", re.VERBOSE, + ), + "setval": "capability suppress 4-byte-as", + "result": { + "neighbor": { + "{{ name }}": { + "capability": { + "suppress_4_byte_as": "{{ not not suppress_4_byte_as }}", + }, + }, + }, + }, + }, + { + "name": "description", + "getval": re.compile( + r""" + description\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "description {{ description }}", + "result": { + "neighbor": { + "{{ name }}": { + "description": "{{ description }}", + }, + }, + }, + }, + { + "name": "disable_connected_check", + "getval": re.compile( + r""" + (?Pdisable-connected-check) + $""", re.VERBOSE, + ), + "setval": "disable-connected-check", + "result": { + "neighbor": { + "{{ name }}": { + "disable_connected_check": "{{ not not disable_connected_check }}", + }, + }, + }, + }, + { + "name": "dont_capability_negotiate", + "getval": re.compile( + r""" + (?Pdont-capability-negotiate) + $""", re.VERBOSE, + ), + "setval": "dont-capability-negotiate", + "result": { + "neighbor": { + "{{ name }}": { + "dont_capability_negotiate": "{{ not not dont_capability_negotiate }}", + }, + }, + }, + }, + { + "name": "dscp", + "getval": re.compile( + r""" + dscp\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "dscp {{ dscp }}", + "result": { + "neighbor": { + "{{ name }}": { + "dscp": "{{ dscp }}", + }, + }, + }, + }, + { + "name": "dynamic_capability", + "getval": re.compile( + r""" + (?Pdynamic-capability) + $""", re.VERBOSE, + ), + "setval": "dynamic-capability", + "result": { + "neighbor": { + "{{ name }}": { + "dynamic_capability": "{{ not not dynamic_capability }}", + }, + }, + }, + }, + { + "name": "ebgp_multihop", + "getval": re.compile( + r""" + ebgp-multihop\s(?P\d+) + $""", re.VERBOSE, + ), + "setval": "ebgp-multihop {{ ebgp_multihop }}", + "result": { + "neighbor": { + "{{ name }}": { + "ebgp_multihop": "{{ ebgp_multihop }}", + }, + }, + }, + }, + { + "name": "graceful_shutdown", + "getval": re.compile( + r""" + graceful-shutdown + \s(?Pactivate) + (\sroute-map\s(?P\S+))? + $""", re.VERBOSE, + ), + "setval": "graceful-shutdown activate" + "{{ (' route-map ' + graceful_shutdown.activate.route_map) if graceful_shutdown.activate.route_map is defined }}", + "result": { + "neighbor": { + "{{ name }}": { + "graceful_shutdown": { + "activate": { + "set": "{{ True if activate is defined and route_map is undefined else None }}", + "route_map": "{{ route_map }}", + }, + }, + }, + }, + }, + }, + { + "name": "inherit.peer_session", + "getval": re.compile( + r""" + inherit + \speer-session\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "inherit peer-session {{ inherit.peer_session }}", + "result": { + "neighbor": { + "{{ name }}": { + "inherit": { + "peer_session": "{{ peer_session }}", + }, + }, + }, + }, + }, + { + "name": "local_as", + "getval": re.compile( + r""" + local-as\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "local-as {{ local_as }}", + "result": { + "neighbor": { + "{{ name }}": { + "local_as": "{{ local_as }}", + }, + }, + }, + }, + { + "name": "log_neighbor_changes", + "getval": re.compile( + r""" + (?Plog-neighbor-changes) + (\s(?Pdisable))? + $""", re.VERBOSE, + ), + "setval": "log-neighbor-changes{{ ' disable' if log_neighbor_changes.disable is defined }}", + "result": { + "neighbor": { + "{{ name }}": { + "log_neighbor_changes": { + "set": "{{ True if log_neighbor_changes is defined and disable is undefined }}", + "disable": "{{ not not disable }}", + }, + }, + }, + }, + }, + { + "name": "low_memory", + "getval": re.compile( + r""" + low-memory\s(?Pexempt) + $""", re.VERBOSE, + ), + "setval": "low-memory exempt", + "result": { + "neighbor": { + "{{ name }}": { + "low_memory": { + "exempt": "{{ not not exempt }}", + }, + }, + }, + }, + }, + { + "name": "password", + "getval": re.compile( + r""" + password\s(?P\d+)\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "password{{ (' ' + password.encryption|string) if password.encryption is defined }} {{ password.key }}", + "result": { + "neighbor": { + "{{ name }}": { + "password": { + "encryption": "{{ encryption }}", + "key": "{{ key }}", + }, + }, + }, + }, + }, + { + "name": "path_attribute", + "getval": re.compile( + r""" + path-attribute\s(?P\S+)\s + (?P\d+)? + (range\s(?P\d+)\s(?P\d+))? + \sin + $""", re.VERBOSE, + ), + "setval": _tmplt_path_attribute, + "result": { + "neighbor": { + "{{ name }}": { + "path_attribute": [ + { + "action": "{{ action }}", + "type": "{{ type if type is defined else None }}", + "range": { + "start": "{{ start if start is defined }}", + "end": "{{ end if end is defined }}", + }, + }, + ], + }, + }, + }, + }, + { + "name": "remote_as", + "getval": re.compile( + r""" + remote-as\s(?P.+) + $""", re.VERBOSE, + ), + "setval": "remote-as {{ remote_as }}", + "result": { + "neighbor": { + "{{ name }}": { + "remote_as": "{{ remote_as|string }}", + }, + }, + }, + }, + { + "name": "remove_private_as", + "getval": re.compile( + r""" + (?Premove-private-as) + (\s(?Pall))? + (\s(?Preplace-as))? + $""", re.VERBOSE, + ), + "setval": "remove-private-as" + "{{ ' replace-as' if remove_private_as.replace_as|d(False) else '' }}" + "{{ ' all' if remove_private_as.all|d(False) else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "remove_private_as": { + "set": "{{ True if remove_private_as is defined and replace_as is undefined and all is undefined else None }}", + "replace_as": "{{ not not replace_as }}", + "all": "{{ not not all }}", + }, + }, + }, + }, + }, + { + "name": "shutdown", + "getval": re.compile( + r""" + (?Pshutdown) + $""", re.VERBOSE, + ), + "setval": "shutdown", + "result": { + "neighbor": { + "{{ name }}": { + "shutdown": "{{ not not shutdown }}", + }, + }, + }, + }, + { + "name": "timers", + "getval": re.compile( + r""" + timers\s(?P\d+)\s(?P\d+) + $""", re.VERBOSE, + ), + "setval": "timers {{ timers.keepalive }} {{ timers.holdtime }}", + "result": { + "neighbor": { + "{{ name }}": { + "timers": { + "keepalive": "{{ keepalive }}", + "holdtime": "{{ holdtime }}", + }, + }, + }, + }, + }, + { + "name": "transport", + "getval": re.compile( + r""" + transport\sconnection-mode + \s(?Ppassive) + $""", re.VERBOSE, + ), + "setval": "transport connection-mode passive", + "result": { + "neighbor": { + "{{ name }}": { + "transport": { + "connection_mode": { + "passive": "{{ not not passive }}", + }, + }, + }, + }, + }, + }, + { + "name": "ttl_security", + "getval": re.compile( + r""" + ttl-security\shops\s(?P\d+) + $""", re.VERBOSE, + ), + "setval": "ttl-security hops {{ ttl_security.hops|string }}", + "result": { + "neighbor": { + "{{ name }}": { + "ttl_security": { + "hops": "{{ hops }}", + }, + }, + }, + }, + }, + { + "name": "update_source", + "getval": re.compile( + r""" + update-source\s(?P\S+) + $""", re.VERBOSE, + ), + "setval": "update-source {{ update_source }}", + "result": { + "neighbor": { + "{{ name }}": { + "update_source": "{{ update_source }}", + }, + }, + }, + }, + # start template AF parsers + { + "name": "address_family", + "getval": re.compile( + r""" + template\speer\s(?P\S+) + \saddress-family\s(?P\S+)\s(?P\S+) + $""", + re.VERBOSE, + ), + "setval": "address-family {{ afi }}{{ (' ' + safi) if safi is defined else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + "{{ afi + '_' + safi|d() }}": { + "afi": "{{ afi }}", + "safi": "{{ safi }}", + }, + }, + }, + }, + }, + "shared": True, + }, + { + "name": "advertise_map.exist_map", + "getval": re.compile( + r""" + advertise-map + \s(?P\S+) + \sexist-map\s(?P\S+) + $""", + re.VERBOSE, + ), + "setval": "advertise-map {{ advertise_map.route_map }} exist-map {{ advertise_map.exist_map }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "advertise_map": { + "route_map": "{{ route_map }}", + "exist_map": "{{ exist_map }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "advertise_map.non_exist_map", + "getval": re.compile( + r""" + advertise-map + \s(?P\S+) + \snon-exist-map\s(?P\S+) + $""", + re.VERBOSE, + ), + "setval": "advertise-map {{ advertise_map.route_map }} non-exist-map {{ advertise_map.non_exist_map }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "advertise_map": { + "route_map": "{{ route_map }}", + "non_exist_map": "{{ non_exist_map }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "advertisement_interval", + "getval": re.compile( + r""" + advertisement-interval + \s(?P\d+) + $""", + re.VERBOSE, + ), + "setval": "advertisement-interval {{ advertisement_interval }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "advertisement_interval": "{{ advertisement_interval }}", + }, + }, + }, + }, + }, + }, + { + "name": "allowas_in", + "getval": re.compile( + r""" + (?Pallowas-in)\s(?P\d+) + $""", + re.VERBOSE, + ), + "setval": "allowas-in{{ ' ' + allowas_in.max_occurences|string if allowas_in.max_occurences is defined else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + "{{ afi + '_' + safi|d() }}": { + "allowas_in": { + "set": "{{ True if allowas_in is defined and max_occurences is undefined }}", + "max_occurences": "{{ max_occurences }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "as_override", + "getval": re.compile( + r""" + (?Pas-override) + $""", + re.VERBOSE, + ), + "setval": "as-override", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + "{{ afi + '_' + safi|d() }}": { + "as_override": "{{ not not as_override }}", + }, + }, + }, + }, + }, + }, + { + "name": "capability.additional_paths.receive", + "getval": re.compile( + r""" + capability\sadditional-paths + \s(?Preceive) + (\s(?Pdisable))? + $""", + re.VERBOSE, + ), + "setval": "capability additional-paths receive{{ ' disable' if capability.additional_paths.receive == 'disable' else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + "{{ afi + '_' + safi|d() }}": { + "capability": { + "additional_paths": { + "receive": "{{ 'disable' if disable is defined else 'enable' }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "capability.additional_paths.send", + "getval": re.compile( + r""" + capability\sadditional-paths + \s(?Psend) + (\s(?Pdisable))? + $""", + re.VERBOSE, + ), + "setval": "capability additional-paths send{{ ' disable' if capability.additional_paths.send == 'disable' else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "capability": { + "additional_paths": { + "send": "{{ 'disable' if disable is defined else 'enable' }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "default_originate", + "getval": re.compile( + r""" + (?Pdefault-originate) + (\sroute-map\s(?P\S+))? + $""", + re.VERBOSE, + ), + "setval": "default-originate{{ ' route-map ' + default_originate.route_map if default_originate.route_map is defined else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "default_originate": { + "set": "{{ True if default_originate is defined and route_map is not defined }}", + "route_map": "{{ route_map }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "disable_peer_as_check", + "getval": re.compile( + r""" + (?Pdisable-peer-as-check) + $""", + re.VERBOSE, + ), + "setval": "disable-peer-as-check", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "disable_peer_as_check": "{{ not not disable_peer_as_check }}", + }, + }, + }, + }, + }, + }, + { + "name": "filter_list.inbound", + "getval": re.compile( + r""" + filter-list + \s(?P\S+)\s(?:in) + $""", + re.VERBOSE, + ), + "setval": "filter-list {{ filter_list.inbound }} in", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "filter_list": { + "inbound": "{{ in }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "filter_list.outbound", + "getval": re.compile( + r""" + filter-list + \s(?P\S+)\s(?:out) + $""", + re.VERBOSE, + ), + "setval": "filter-list {{ filter_list.outbound }} out", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "filter_list": { + "outbound": "{{ out }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "inherit.peer_policy", + "getval": re.compile( + r""" + inherit\speer-policy + \s(?P\S+) + $""", + re.VERBOSE, + ), + "setval": "inherit peer-policy {{ inherit.peer_policy }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "inherit": { + "peer_policy": "{{ peer_policy }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "maximum_prefix", + "getval": re.compile( + r""" + maximum-prefix + \s(?P\d+) + (\s(?P\d+))? + (\srestart\s(?P\d+))? + (\s(?Pwarning-only))? + $""", + re.VERBOSE, + ), + "setval": "maximum-prefix" + "{{ ' ' + maximum_prefix.max_prefix_limit|string if maximum_prefix.max_prefix_limit|d(None) else '' }}" + "{{ ' ' + maximum_prefix.generate_warning_threshold|string if maximum_prefix.generate_warning_threshold|d(None) else '' }}" + "{{ ' restart ' + maximum_prefix.restart_interval|string if maximum_prefix.restart_interval|d(None) else '' }}" + "{{ ' warning-only' if maximum_prefix.warning_only|d(False) else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "maximum_prefix": { + "max_prefix_limit": "{{ max_prefix_limit }}", + "generate_warning_threshold": "{{ generate_warning_threshold }}", + "restart_interval": "{{ restart_interval }}", + "warning_only": "{{ not not warning_only }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "next_hop_self", + "getval": re.compile( + r""" + (?Pnext-hop-self) + (\s(?Pall))? + $""", + re.VERBOSE, + ), + "setval": "next-hop-self{{ ' all' if next_hop_self.all_routes|d(False) else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "next_hop_self": { + "set": "{{ True if next_hop_self is defined and all_routes is not defined }}", + "all_routes": "{{ not not all_routes }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "next_hop_third_party", + "getval": re.compile( + r""" + no\s(?Pnext-hop-third-party) + $""", + re.VERBOSE, + ), + "setval": "next-hop-third-party", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "next_hop_third_party": "{{ not next_hop_third_party }}", + }, + }, + }, + }, + }, + }, + { + "name": "prefix_list.inbound", + "getval": re.compile( + r""" + prefix-list + \s(?P\S+)\s(?:in) + $""", + re.VERBOSE, + ), + "setval": "prefix-list {{ prefix_list.inbound }} in", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "prefix_list": { + "inbound": "{{ in }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "prefix_list.outbound", + "getval": re.compile( + r""" + prefix-list + \s(?P\S+)\s(?:out) + $""", + re.VERBOSE, + ), + "setval": "prefix-list {{ prefix_list.outbound }} out", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "prefix_list": { + "outbound": "{{ out }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "route_map.inbound", + "getval": re.compile( + r""" + route-map + \s(?P\S+)\s(?:in) + $""", + re.VERBOSE, + ), + "setval": "route-map {{ route_map.inbound }} in", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "route_map": { + "inbound": "{{ in }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "route_map.outbound", + "getval": re.compile( + r""" + route-map + \s(?P\S+)\s(?:out) + $""", + re.VERBOSE, + ), + "setval": "route-map {{ route_map.outbound }} out", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "route_map": { + "outbound": "{{ out }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "route_reflector_client", + "getval": re.compile( + r""" + (?Proute-reflector-client) + $""", + re.VERBOSE, + ), + "setval": "route-reflector-client", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "route_reflector_client": "{{ not not route_reflector_client }}", + }, + }, + }, + }, + }, + }, + { + "name": "soft_reconfiguration_inbound", + "getval": re.compile( + r""" + (?Psoft-reconfiguration\sinbound) + (\s(?Palways))? + $""", + re.VERBOSE, + ), + "setval": "soft-reconfiguration inbound{{ ' always' if soft_reconfiguration_inbound.always|d(False) else '' }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "soft_reconfiguration_inbound": { + "set": "{{ True if soft_reconfiguration_inbound is defined and always is undefined }}", + "always": "{{ not not always }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "soo", + "getval": re.compile( + r""" + soo\s(?P\S+) + $""", + re.VERBOSE, + ), + "setval": "soo {{ soo }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "soo": "{{ soo }}", + }, + }, + }, + }, + }, + }, + { + "name": "suppress_inactive", + "getval": re.compile( + r""" + (?Psuppress-inactive) + $""", + re.VERBOSE, + ), + "setval": "suppress-inactive", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "suppress_inactive": "{{ not not suppress_inactive }}", + }, + }, + }, + }, + }, + }, + { + "name": "unsuppress_map", + "getval": re.compile( + r""" + unsuppress-map\s(?P\S+) + $""", + re.VERBOSE, + ), + "setval": "unsuppress-map {{ unsuppress_map }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "unsuppress_map": "{{ unsuppress_map }}", + }, + }, + }, + }, + }, + }, + { + "name": "weight", + "getval": re.compile( + r""" + weight\s(?P\d+) + $""", + re.VERBOSE, + ), + "setval": "weight {{ weight }}", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "weight": "{{ weight }}", + }, + }, + }, + }, + }, + }, + ] + # fmt: on diff --git a/plugins/modules/nxos_bgp_templates.py b/plugins/modules/nxos_bgp_templates.py new file mode 100644 index 000000000..97ecb69bb --- /dev/null +++ b/plugins/modules/nxos_bgp_templates.py @@ -0,0 +1,1011 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" +The module file for nxos_bgp_templates +""" + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +DOCUMENTATION = """ +module: nxos_bgp_templates +short_description: BGP Templates resource module. +description: +- This module manages BGP templates on devices running Cisco NX-OS. +version_added: 4.2.0 +notes: +- Tested against NX-OS 9.3.6. +- Unsupported for Cisco MDS +- This module works with connection C(network_cli) and C(httpapi). +author: Nilashish Chakraborty (@NilashishC) +options: + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the NX-OS device + by executing the command B(show running-config bgp | section 'template'). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + config: + description: A list of BGP templates. + type: dict + suboptions: + as_number: + description: Autonomous System Number of the router. + type: str + neighbor: + description: Configure BGP peer templates. + type: list + elements: dict + suboptions: + name: + description: Name of the BGP peer template. + type: str + address_family: + description: Configure an address-family for peer. + type: list + elements: dict + suboptions: + afi: + description: Address Family indicator. + type: str + choices: ["ipv4", "ipv6", "link-state", "l2vpn"] + required: True + safi: + description: Sub Address Family indicator. + type: str + choices: ["unicast", "multicast", "mvpn"] + advertise_map: + description: Specify route-map for conditional advertisement. + type: dict + suboptions: + route_map: + description: Route-map name. + type: str + required: True + exist_map: + description: Condition route-map to advertise only when prefix in condition exists. + type: str + non_exist_map: + description: Condition route-map to advertise only when prefix in condition does not exist. + type: str + advertisement_interval: + description: Minimum interval between sending BGP routing updates. + type: int + allowas_in: + description: Accept as-path with my AS present in it. + type: dict + suboptions: + set: + description: Activate allowas-in property. + type: bool + max_occurences: + description: Number of occurrences of AS number, default is 3. + type: int + as_override: + description: Override matching AS-number while sending update. + type: bool + capability: + description: Advertise capability to the peer. + type: dict + suboptions: + additional_paths: + description: Additional paths capability. + type: dict + suboptions: + receive: + description: Additional paths Receive capability. + type: str + choices: ["enable", "disable"] + send: + description: Additional paths Send capability. + type: str + choices: ["enable", "disable"] + default_originate: + description: Originate a default toward this peer. + type: dict + suboptions: + set: + description: Set default-originate attribute. + type: bool + route_map: + description: Route-map to specify criteria for originating default. + type: str + disable_peer_as_check: + description: Disable checking of peer AS-number while advertising. + type: bool + filter_list: + description: Name of filter-list. + type: dict + suboptions: + inbound: + description: Apply policy to incoming routes. + type: str + outbound: + description: Apply policy to outgoing routes. + type: str + inherit: + description: Inherit a peer-policy template. + type: dict + suboptions: + peer_policy: + description: Peer-policy template to inherit. + type: str + maximum_prefix: + description: Maximum number of prefixes from this neighbor. + type: dict + suboptions: + max_prefix_limit: + description: Maximum prefix limit. + type: int + generate_warning_threshold: + description: Threshold percentage at which to generate a warning. + type: int + restart_interval: + description: Restart bgp connection after limit is exceeded. + type: int + warning_only: + description: Only give a warning message when limit is exceeded. + type: bool + next_hop_self: + description: Set our address as nexthop (non-reflected). + type: dict + suboptions: + set: + description: Set next-hop-self attribute. + type: bool + all_routes: + description: Set our address as nexthop for all routes. + type: bool + next_hop_third_party: + description: Compute a third-party nexthop if possible. + type: bool + prefix_list: + description: Apply prefix-list. + type: dict + suboptions: + inbound: + description: Apply policy to incoming routes. + type: str + outbound: + description: Apply policy to outgoing routes. + type: str + route_map: + description: Apply route-map to neighbor. + type: dict + suboptions: + inbound: + description: Name of policy to apply to incoming routes. + type: str + outbound: + description: Name of policy to apply to outgoing routes. + type: str + route_reflector_client: + description: Configure a neighbor as Route reflector client. + type: bool + soft_reconfiguration_inbound: + description: Soft reconfiguration. + type: dict + suboptions: + set: + description: Set soft-reconfiguration inbound attribute. + type: bool + always: + description: Always perform inbound soft reconfiguration. + type: bool + soo: + description: Specify Site-of-origin extcommunity. + type: str + suppress_inactive: + description: Advertise only active routes to peer. + type: bool + unsuppress_map: + description: Route-map to selectively unsuppress suppressed routes. + type: str + weight: + description: Set default weight for routes from this neighbor. + type: int + bfd: + description: Bidirectional Fast Detection for the neighbor. + type: dict + suboptions: + set: + description: Set BFD for this neighbor. + type: bool + singlehop: + description: Single-hop session. + type: bool + multihop: + description: Multihop session. + type: dict + suboptions: + set: + description: Set BFD multihop. + type: bool + interval: + description: Configure BFD session interval parameters. + type: dict + suboptions: + tx_interval: + description: TX interval in milliseconds. + type: int + required: true + min_rx_interval: + description: Minimum RX interval. + type: int + required: true + multiplier: + description: Detect Multiplier. + type: int + required: true + bmp_activate_server: + description: Specify server ID for activating BMP monitoring for the peer. + type: int + capability: + description: Capability. + type: dict + suboptions: + suppress_4_byte_as: + description: Suppress 4-byte AS Capability. + type: bool + description: + description: Neighbor specific descripion. + type: str + disable_connected_check: + description: Disable check for directly connected peer. + type: bool + dont_capability_negotiate: + description: Don't negotiate capability with this neighbor. + type: bool + dscp: + description: Set dscp value for tcp transport. + type: str + dynamic_capability: + description: Dynamic Capability + type: bool + ebgp_multihop: + description: Specify multihop TTL for remote peer. + type: int + graceful_shutdown: + description: Graceful-shutdown for this neighbor. + type: dict + suboptions: + activate: + description: Send graceful-shutdown community. + type: dict + suboptions: + set: + description: Set activate. + type: bool + route_map: + description: Apply route-map to modify attributes for outbound. + type: str + inherit: + description: Inherit a template. + type: dict + suboptions: + peer_session: + description: Peer-session template to inherit. + type: str + local_as: + description: Specify the local-as number for the eBGP neighbor. + type: str + log_neighbor_changes: + description: Log message for neighbor up/down event. + type: dict + suboptions: + set: + description: + - Set log-neighbor-changes. + type: bool + disable: + description: + - Disable logging of neighbor up/down event. + type: bool + low_memory: + description: Behaviour in low memory situations. + type: dict + suboptions: + exempt: + description: Do not shutdown this peer when under memory pressure. + type: bool + password: + description: Configure a password for neighbor. + type: dict + suboptions: + encryption: + description: + - 0 specifies an UNENCRYPTED neighbor password. + - 3 specifies an 3DES ENCRYPTED neighbor password will follow. + - 7 specifies a Cisco type 7 ENCRYPTED neighbor password will follow. + type: int + key: + description: Authentication password. + type: str + path_attribute: + description: BGP path attribute optional filtering. + type: list + elements: dict + suboptions: + action: + description: Action. + type: str + choices: ["discard", "treat-as-withdraw"] + type: + description: Path attribute type + type: int + range: + description: Path attribute range. + type: dict + suboptions: + start: + description: Path attribute range start value. + type: int + end: + description: Path attribute range end value. + type: int + remote_as: + description: Specify Autonomous System Number of the neighbor. + type: str + remove_private_as: + description: Remove private AS number from outbound updates. + type: dict + suboptions: + set: + description: Remove private AS. + type: bool + replace_as: + description: Replace. + type: bool + all: + description: All. + type: bool + shutdown: + description: Administratively shutdown this neighbor. + type: bool + timers: + description: Configure keepalive and hold timers. + type: dict + suboptions: + keepalive: + description: Keepalive interval (seconds). + type: int + holdtime: + description: Holdtime (seconds). + type: int + transport: + description: BGP transport connection. + type: dict + suboptions: + connection_mode: + description: Specify type of connection. + type: dict + suboptions: + passive: + description: Allow passive connection setup only. + type: bool + ttl_security: + description: Enable TTL Security Mechanism. + type: dict + suboptions: + hops: + description: Specify hop count for remote peer. + type: int + update_source: + description: Specify source of BGP session and updates. + type: str + state: + description: + - The state the configuration should be left in. + - Refer to examples for more details. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - parsed + - gathered + - rendered + default: merged +""" + +EXAMPLES = """ +# Using merged + +# Before state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# nxos9k# + +- name: Merge the provided configuration with the existing running configuration + 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 +# Task Output +# ----------- +# before: {} +# +# commands: +# - 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 +# +# 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 + +# After state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# router bgp 65536 +# template peer neighbor_tmplt_1 +# capability suppress 4-byte-as +# bmp-activate-server 2 +# 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 + +# Using replaced + +# Before state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# router bgp 65536 +# template peer neighbor_tmplt_1 +# capability suppress 4-byte-as +# description Test_BGP_PEER_TEMPLATE_1 +# bmp-activate-server 2 +# 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 + +- name: Replace BGP templates configuration with provided configuration + 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 + inherit: + peer_session: psession1 + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65537 + state: replaced + +# Task Output +# ----------- +# +# before: +# 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 +# +# 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 + +# After state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# router bgp 65536 +# template peer neighbor_tmplt_1 +# inherit peer-session psession1 +# description Test_BGP_PEER_TEMPLATE_1 +# local-as 65537 +# 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 +# bmp-activate-server 2 +# timers 45 100 +# address-family ipv4 multicast +# advertise-map rmap1 exist-map emap1 +# as-override +# filter-list flist1 in +# filter-list flist2 out + +# Using overridden +# +# Before state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# router bgp 65536 +# template peer neighbor_tmplt_1 +# capability suppress 4-byte-as +# description Test_BGP_PEER_TEMPLATE_1 +# bmp-activate-server 2 +# 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 + +- name: Override BGP templates configuration with provided configuration + 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 + inherit: + peer_session: psession1 + description: Test_BGP_PEER_TEMPLATE_1 + local_as: 65537 + state: overridden + +# Task Output +# ----------- +# +# before: +# 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 +# +# 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" + +# After state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# router bgp 65536 +# template peer neighbor_tmplt_1 +# inherit peer-session psession1 +# description Test_BGP_PEER_TEMPLATE_1 +# local-as 65537 +# address-family ipv4 unicast +# advertise-map rmap1 non-exist-map nemap1 +# advertisement-interval 60 +# disable-peer-as-check + +# Using deleted + +# Before state: +# -------------- +# +# nxos9k# show running-config | section "^router bgp" +# router bgp 65536 +# template peer neighbor_tmplt_1 +# capability suppress 4-byte-as +# description Test_BGP_PEER_TEMPLATE_1 +# bmp-activate-server 2 +# 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 + +- name: Delete BGP configs handled by this module + cisco.nxos.nxos_bgp_templates: + state: deleted + +# Task Output +# ----------- +# +# before: +# 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 +# +# commands: +# - router bgp 65536 +# - no template peer neighbor_tmplt_1 +# - no template peer neighbor_tmplt_2 +# +# after: {} + +# After state: +# ------------- +# nxos9k# show running-config | section "^router bgp" +# nxos9k# +""" + +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - 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 +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router bgp 65536 + - template peer neighbor_tmplt_1 + - bmp-activate-server 2 + - no capability suppress 4-byte-as + - no template peer neighbor_tmplt_2 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_templates.bgp_templates import ( + Bgp_templatesArgs, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_templates.bgp_templates import ( + Bgp_templates, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule( + argument_spec=Bgp_templatesArgs.argument_spec, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, + ) + + result = Bgp_templates(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/nxos_bgp_templates/defaults/main.yaml b/tests/integration/targets/nxos_bgp_templates/defaults/main.yaml new file mode 100644 index 000000000..871ea460c --- /dev/null +++ b/tests/integration/targets/nxos_bgp_templates/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "[^_].*" diff --git a/tests/integration/targets/nxos_bgp_templates/meta/main.yml b/tests/integration/targets/nxos_bgp_templates/meta/main.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/tests/integration/targets/nxos_bgp_templates/meta/main.yml @@ -0,0 +1 @@ +--- diff --git a/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml new file mode 100644 index 000000000..9e4fb34bc --- /dev/null +++ b/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml @@ -0,0 +1,32 @@ +--- +- name: Collect common test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + use_regex: true + 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 diff --git a/tests/integration/targets/nxos_bgp_templates/tasks/main.yaml b/tests/integration/targets/nxos_bgp_templates/tasks/main.yaml new file mode 100644 index 000000000..026b6e477 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml new file mode 100644 index 000000000..5cb76e671 --- /dev/null +++ b/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml @@ -0,0 +1,32 @@ +--- +- name: Collect common test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + use_regex: true + 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 diff --git a/tests/integration/targets/nxos_bgp_templates/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/_populate_config.yaml new file mode 100644 index 000000000..2fe977e28 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/_remove_config.yaml new file mode 100644 index 000000000..af7092576 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/deleted.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/deleted.yaml new file mode 100644 index 000000000..ab2efb521 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/empty_config.yaml new file mode 100644 index 000000000..f57679e8b --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/fixtures/parsed.cfg b/tests/integration/targets/nxos_bgp_templates/tests/common/fixtures/parsed.cfg new file mode 100644 index 000000000..615f7fa21 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/gathered.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/gathered.yaml new file mode 100644 index 000000000..1cdf9a2f2 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/merged.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/merged.yaml new file mode 100644 index 000000000..acacacd02 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/overridden.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/overridden.yaml new file mode 100644 index 000000000..c66b10284 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/parsed.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/parsed.yaml new file mode 100644 index 000000000..0a04fa376 --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/rendered.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/rendered.yaml new file mode 100644 index 000000000..411e8761f --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/tests/common/replaced.yaml b/tests/integration/targets/nxos_bgp_templates/tests/common/replaced.yaml new file mode 100644 index 000000000..73bd4b73f --- /dev/null +++ b/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/tests/integration/targets/nxos_bgp_templates/vars/main.yml b/tests/integration/targets/nxos_bgp_templates/vars/main.yml new file mode 100644 index 000000000..77acf1516 --- /dev/null +++ b/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/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index cce7c66a0..9ace4ebff 100644 --- a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -26,16 +26,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/tests/integration/targets/nxos_facts/vars/main.yml b/tests/integration/targets/nxos_facts/vars/main.yml new file mode 100644 index 000000000..5965c4191 --- /dev/null +++ b/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/tests/integration/targets/nxos_snmp_server/tasks/main.yaml b/tests/integration/targets/nxos_snmp_server/tasks/main.yaml index cb885dee9..b46cbf998 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/main.yaml +++ b/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/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py b/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py new file mode 100644 index 000000000..1378c4411 --- /dev/null +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py @@ -0,0 +1,801 @@ +# (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 . + +# 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, + ), + ), + ), + ], + ), + 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", + ] + 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"], []) From e004a11076aabb62f3019dbb56fccbfed13ba615 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Sat, 24 Jun 2023 16:18:31 +0530 Subject: [PATCH 102/166] Removed deprecated module for major release (#700) * Remove deprecated modules for major release Signed-off-by: NilashishC * Update docs and galaxy.yml Signed-off-by: NilashishC * Update runtime.yml Signed-off-by: NilashishC * Remove redundant ignores Signed-off-by: NilashishC * Update test Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- README.md | 4 - changelogs/fragments/drop.yaml | 8 + docs/cisco.nxos.nxos_bgp_af_module.rst | 677 -------------- docs/cisco.nxos.nxos_bgp_module.rst | 840 ----------------- ...cisco.nxos.nxos_bgp_neighbor_af_module.rst | 749 --------------- docs/cisco.nxos.nxos_bgp_neighbor_module.rst | 561 ----------- galaxy.yml | 2 +- meta/runtime.yml | 52 -- plugins/modules/nxos_bgp.py | 761 --------------- plugins/modules/nxos_bgp_af.py | 877 ------------------ plugins/modules/nxos_bgp_neighbor.py | 569 ------------ plugins/modules/nxos_bgp_neighbor_af.py | 781 ---------------- .../targets/nxos_bgp/defaults/main.yaml | 5 - .../targets/nxos_bgp/meta/main.yml | 3 - .../targets/nxos_bgp/tasks/cli.yaml | 32 - .../targets/nxos_bgp/tasks/main.yaml | 10 - .../targets/nxos_bgp/tasks/nxapi.yaml | 32 - .../nxos_bgp/tests/common/dis_policy.yaml | 85 -- .../targets/nxos_bgp/tests/common/hels.yaml | 101 -- .../nxos_bgp/tests/common/isolate.yaml | 81 -- .../targets/nxos_bgp/tests/common/param.yaml | 258 ------ .../targets/nxos_bgp/tests/common/sanity.yaml | 138 --- .../nxos_bgp/tests/common/supp_fib.yaml | 120 --- .../targets/nxos_bgp_af/defaults/main.yaml | 5 - .../targets/nxos_bgp_af/meta/main.yml | 3 - .../targets/nxos_bgp_af/tasks/cli.yaml | 32 - .../targets/nxos_bgp_af/tasks/main.yaml | 10 - .../targets/nxos_bgp_af/tasks/nxapi.yaml | 32 - .../nxos_bgp_af/tests/common/multisite.yaml | 132 --- .../nxos_bgp_af/tests/common/sanity.yaml | 342 ------- .../nxos_bgp_neighbor/defaults/main.yaml | 5 - .../targets/nxos_bgp_neighbor/meta/main.yml | 3 - .../targets/nxos_bgp_neighbor/tasks/cli.yaml | 32 - .../targets/nxos_bgp_neighbor/tasks/main.yaml | 10 - .../nxos_bgp_neighbor/tasks/nxapi.yaml | 32 - .../tests/common/multisite.yaml | 123 --- .../tests/common/sanity.yaml | 357 ------- .../nxos_bgp_neighbor_af/defaults/main.yaml | 2 - .../nxos_bgp_neighbor_af/meta/main.yml | 3 - .../nxos_bgp_neighbor_af/tasks/cli.yaml | 32 - .../nxos_bgp_neighbor_af/tasks/main.yaml | 10 - .../nxos_bgp_neighbor_af/tasks/nxapi.yaml | 32 - .../tests/common/multisite.yaml | 117 --- .../tests/common/sanity.yaml | 295 ------ .../nxos_command/tests/cli/sanity.yaml | 9 +- tests/sanity/ignore-2.9.txt | 8 - .../modules/network/nxos/test_nxos_bgp.py | 150 --- .../modules/network/nxos/test_nxos_bgp_af.py | 175 ---- .../network/nxos/test_nxos_bgp_neighbor.py | 138 --- .../network/nxos/test_nxos_bgp_neighbor_af.py | 259 ------ 50 files changed, 14 insertions(+), 9080 deletions(-) create mode 100644 changelogs/fragments/drop.yaml delete mode 100644 docs/cisco.nxos.nxos_bgp_af_module.rst delete mode 100644 docs/cisco.nxos.nxos_bgp_module.rst delete mode 100644 docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst delete mode 100644 docs/cisco.nxos.nxos_bgp_neighbor_module.rst delete mode 100644 plugins/modules/nxos_bgp.py delete mode 100644 plugins/modules/nxos_bgp_af.py delete mode 100644 plugins/modules/nxos_bgp_neighbor.py delete mode 100644 plugins/modules/nxos_bgp_neighbor_af.py delete mode 100644 tests/integration/targets/nxos_bgp/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp/meta/main.yml delete mode 100644 tests/integration/targets/nxos_bgp/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tests/common/hels.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tests/common/isolate.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tests/common/param.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml delete mode 100644 tests/integration/targets/nxos_bgp_af/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp_af/meta/main.yml delete mode 100644 tests/integration/targets/nxos_bgp_af/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_bgp_af/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml delete mode 100644 tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/meta/main.yml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml delete mode 100644 tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml delete mode 100644 tests/unit/modules/network/nxos/test_nxos_bgp.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_bgp_af.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py delete mode 100644 tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py diff --git a/README.md b/README.md index b1be92bae..c038ee93e 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,9 @@ Name | Description [cisco.nxos.nxos_banner](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_banner_module.rst)|Manage multiline banners on Cisco NXOS devices [cisco.nxos.nxos_bfd_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bfd_global_module.rst)|Bidirectional Forwarding Detection (BFD) global-level configuration [cisco.nxos.nxos_bfd_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bfd_interfaces_module.rst)|BFD interfaces resource module -[cisco.nxos.nxos_bgp](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_module.rst)|(deprecated, removed after 2023-01-27) Manages BGP configuration. [cisco.nxos.nxos_bgp_address_family](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_address_family_module.rst)|BGP Address Family resource module. -[cisco.nxos.nxos_bgp_af](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_af_module.rst)|(deprecated, removed after 2023-02-24) Manages BGP Address-family configuration. [cisco.nxos.nxos_bgp_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_global_module.rst)|BGP Global resource module. -[cisco.nxos.nxos_bgp_neighbor](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_neighbor_module.rst)|(deprecated, removed after 2023-01-27) Manages BGP neighbors configurations. [cisco.nxos.nxos_bgp_neighbor_address_family](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst)|BGP Neighbor Address Family resource module. -[cisco.nxos.nxos_bgp_neighbor_af](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst)|(deprecated, removed after 2023-02-24) Manages BGP address-family's neighbors configuration. [cisco.nxos.nxos_bgp_templates](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_bgp_templates_module.rst)|BGP Templates resource module. [cisco.nxos.nxos_command](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_command_module.rst)|Run arbitrary command on Cisco NXOS devices [cisco.nxos.nxos_config](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_config_module.rst)|Manage Cisco NXOS configuration sections diff --git a/changelogs/fragments/drop.yaml b/changelogs/fragments/drop.yaml new file mode 100644 index 000000000..e0071b198 --- /dev/null +++ b/changelogs/fragments/drop.yaml @@ -0,0 +1,8 @@ +--- +removed_features: + - The nxos_bgp module has been removed with this release. + - The nxos_bgp_af module has been removed with this release. + - The nxos_bgp_neighbor module has been removed with this release. + - The nxos_bgp_neighbor_af module has been removed with this release. +major_changes: + - This release removes four of the previously deprecated modules from this collection. Refer to **Removed Features** section for details. diff --git a/docs/cisco.nxos.nxos_bgp_af_module.rst b/docs/cisco.nxos.nxos_bgp_af_module.rst deleted file mode 100644 index 98b99d7e9..000000000 --- a/docs/cisco.nxos.nxos_bgp_af_module.rst +++ /dev/null @@ -1,677 +0,0 @@ -.. _cisco.nxos.nxos_bgp_af_module: - - -********************** -cisco.nxos.nxos_bgp_af -********************** - -**(deprecated, removed after 2023-02-24) Manages BGP Address-family configuration.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2023-02-24 -:Why: Updated module released with more functionality. -:Alternative: nxos_bgp_address_family - - - -Synopsis --------- -- Manages BGP Address-family configurations on NX-OS switches. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- additional_paths_install - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Install a backup path into the forwarding table and provide prefix independent convergence (PIC) in case of a PE-CE link failure.
-
-
- additional_paths_receive - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enables the receive capability of additional paths for all of the neighbors under this address family for which the capability has not been disabled.
-
-
- additional_paths_selection - -
- string -
-
- -
Configures the capability of selecting additional paths for a prefix. Valid values are a string defining the name of the route-map.
-
-
- additional_paths_send - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enables the send capability of additional paths for all of the neighbors under this address family for which the capability has not been disabled.
-
-
- advertise_l2vpn_evpn - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Advertise evpn routes.
-
-
- afi - -
- string - / required -
-
-
    Choices: -
  • ipv4
  • -
  • ipv6
  • -
  • vpnv4
  • -
  • vpnv6
  • -
  • l2vpn
  • -
-
-
Address Family Identifier.
-
-
- asn - -
- string - / required -
-
- -
BGP autonomous system number. Valid values are String, Integer in ASPLAIN or ASDOT notation.
-
-
- client_to_client - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Configure client-to-client route reflection.
-
-
- dampen_igp_metric - -
- string -
-
- -
Specify dampen value for IGP metric-related changes, in seconds. Valid values are integer and keyword 'default'.
-
-
- dampening_half_time - -
- string -
-
- -
Specify decay half-life in minutes for route-flap dampening. Valid values are integer and keyword 'default'.
-
-
- dampening_max_suppress_time - -
- string -
-
- -
Specify max suppress time for route-flap dampening stable route. Valid values are integer and keyword 'default'.
-
-
- dampening_reuse_time - -
- string -
-
- -
Specify route reuse time for route-flap dampening. Valid values are integer and keyword 'default'.
-
-
- dampening_routemap - -
- string -
-
- -
Specify route-map for route-flap dampening. Valid values are a string defining the name of the route-map.
-
-
- dampening_state - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/disable route-flap dampening.
-
-
- dampening_suppress_time - -
- string -
-
- -
Specify route suppress time for route-flap dampening. Valid values are integer and keyword 'default'.
-
-
- default_information_originate - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Default information originate.
-
-
- default_metric - -
- string -
-
- -
Sets default metrics for routes redistributed into BGP. Valid values are Integer or keyword 'default'
-
-
- distance_ebgp - -
- string -
-
- -
Sets the administrative distance for eBGP routes. Valid values are Integer or keyword 'default'.
-
-
- distance_ibgp - -
- string -
-
- -
Sets the administrative distance for iBGP routes. Valid values are Integer or keyword 'default'.
-
-
- distance_local - -
- string -
-
- -
Sets the administrative distance for local BGP routes. Valid values are Integer or keyword 'default'.
-
-
- inject_map - -
- list - / elements=list -
-
- -
An array of route-map names which will specify prefixes to inject. Each array entry must first specify the inject-map name, secondly an exist-map name, and optionally the copy-attributes keyword which indicates that attributes should be copied from the aggregate. For example [['lax_inject_map', 'lax_exist_map'], ['nyc_inject_map', 'nyc_exist_map', 'copy-attributes'], ['fsd_inject_map', 'fsd_exist_map']].
-
-
- maximum_paths - -
- string -
-
- -
Configures the maximum number of equal-cost paths for load sharing. Valid value is an integer in the range 1-64.
-
-
- maximum_paths_ibgp - -
- string -
-
- -
Configures the maximum number of ibgp equal-cost paths for load sharing. Valid value is an integer in the range 1-64.
-
-
- networks - -
- list - / elements=list -
-
- -
Networks to configure. Valid value is a list of network prefixes to advertise. The list must be in the form of an array. Each entry in the array must include a prefix address and an optional route-map. For example [['10.0.0.0/16', 'routemap_LA'], ['192.168.1.1', 'Chicago'], ['192.168.2.0/24'], ['192.168.3.0/24', 'routemap_NYC']].
-
-
- next_hop_route_map - -
- string -
-
- -
Configure a route-map for valid nexthops. Valid values are a string defining the name of the route-map.
-
-
- redistribute - -
- list - / elements=list -
-
- -
A list of redistribute directives. Multiple redistribute entries are allowed. The list must be in the form of a nested array. the first entry of each array defines the source-protocol to redistribute from; the second entry defines a route-map name. A route-map is highly advised but may be optional on some platforms, in which case it may be omitted from the array list. For example [['direct', 'rm_direct'], ['lisp', 'rm_lisp']].
-
-
- retain_route_target - -
- string -
-
added in 1.1.0
-
- -
Retains all of the routes or the routes which are part of configured route-map. Valid values are route-map names or keyword all or keyword default. all retains all the routes regardless of Target-VPN community. default will disable the retain route target option. If you are using route-map name please ensure that the name is not same as all and default.
-
-
- safi - -
- string - / required -
-
-
    Choices: -
  • unicast
  • -
  • multicast
  • -
  • evpn
  • -
-
-
Sub Address Family Identifier.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Determines whether the config should be present or not on the device.
-
-
- suppress_inactive - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Advertises only active routes to peers.
-
-
- table_map - -
- string -
-
- -
Apply table-map to filter routes downloaded into URIB. Valid values are a string.
-
-
- table_map_filter - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Filters routes rejected by the route-map and does not download them to the RIB.
-
-
- vrf - -
- string -
-
- Default:
"default"
-
-
Name of the VRF. The name 'default' is a valid VRF representing the global bgp.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - ``state=absent`` removes the whole BGP ASN configuration - - Default, where supported, restores params default value. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - # configure a simple address-family - - cisco.nxos.nxos_bgp_af: - asn: 65535 - vrf: TESTING - afi: ipv4 - safi: unicast - advertise_l2vpn_evpn: true - state: present - retain_route_target: all - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['router bgp 65535', 'vrf TESTING', 'address-family ipv4 unicast', 'advertise l2vpn evpn', 'retain route-target all']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2023-02-24. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_bgp_module.rst b/docs/cisco.nxos.nxos_bgp_module.rst deleted file mode 100644 index e31ad1d85..000000000 --- a/docs/cisco.nxos.nxos_bgp_module.rst +++ /dev/null @@ -1,840 +0,0 @@ -.. _cisco.nxos.nxos_bgp_module: - - -******************* -cisco.nxos.nxos_bgp -******************* - -**(deprecated, removed after 2023-01-27) Manages BGP configuration.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2023-01-27 -:Why: Updated module released with more functionality. -:Alternative: nxos_bgp_global - - - -Synopsis --------- -- Manages BGP configurations on NX-OS switches. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- asn - -
- string - / required -
-
- -
BGP autonomous system number. Valid values are String, Integer in ASPLAIN or ASDOT notation.
-
-
- bestpath_always_compare_med - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable MED comparison on paths from different autonomous systems.
-
-
- bestpath_aspath_multipath_relax - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable load sharing across the providers with different (but equal-length) AS paths.
-
-
- bestpath_compare_neighborid - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable neighborid. Use this when more paths available than max path config.
-
-
- bestpath_compare_routerid - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable comparison of router IDs for identical eBGP paths.
-
-
- bestpath_cost_community_ignore - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable Ignores the cost community for BGP best-path calculations.
-
-
- bestpath_med_confed - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable enforcement of bestpath to do a MED comparison only between paths originated within a confederation.
-
-
- bestpath_med_missing_as_worst - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable assigns the value of infinity to received routes that do not carry the MED attribute, making these routes the least desirable.
-
-
- bestpath_med_non_deterministic - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable deterministic selection of the best MED pat from among the paths from the same autonomous system.
-
-
- cluster_id - -
- string -
-
- -
Route Reflector Cluster-ID.
-
-
- confederation_id - -
- string -
-
- -
Routing domain confederation AS.
-
-
- confederation_peers - -
- list - / elements=string -
-
- -
AS confederation parameters.
-
-
- disable_policy_batching - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable the batching evaluation of prefix advertisement to all peers.
-
-
- disable_policy_batching_ipv4_prefix_list - -
- string -
-
- -
Enable/Disable the batching evaluation of prefix advertisements to all peers with prefix list.
-
-
- disable_policy_batching_ipv6_prefix_list - -
- string -
-
- -
Enable/Disable the batching evaluation of prefix advertisements to all peers with prefix list.
-
-
- enforce_first_as - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable enforces the neighbor autonomous system to be the first AS number listed in the AS path attribute for eBGP. On NX-OS, this property is only supported in the global BGP context.
-
-
- event_history_cli - -
- string -
-
-
    Choices: -
  • size_small
  • -
  • size_medium
  • -
  • size_large
  • -
  • size_disable
  • -
  • default
  • -
  • true
  • -
  • false
  • -
-
-
Enable/Disable cli event history buffer.
-
-
- event_history_detail - -
- string -
-
-
    Choices: -
  • size_small
  • -
  • size_medium
  • -
  • size_large
  • -
  • size_disable
  • -
  • default
  • -
  • true
  • -
  • false
  • -
-
-
Enable/Disable detail event history buffer.
-
-
- event_history_events - -
- string -
-
-
    Choices: -
  • size_small
  • -
  • size_medium
  • -
  • size_large
  • -
  • size_disable
  • -
  • default
  • -
  • true
  • -
  • false
  • -
-
-
Enable/Disable event history buffer.
-
-
- event_history_periodic - -
- string -
-
-
    Choices: -
  • size_small
  • -
  • size_medium
  • -
  • size_large
  • -
  • size_disable
  • -
  • default
  • -
  • true
  • -
  • false
  • -
-
-
Enable/Disable periodic event history buffer.
-
-
- fast_external_fallover - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable immediately reset the session if the link to a directly connected BGP peer goes down. Only supported in the global BGP context.
-
-
- flush_routes - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable flush routes in RIB upon controlled restart. On NX-OS, this property is only supported in the global BGP context.
-
-
- graceful_restart - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable graceful restart.
-
-
- graceful_restart_helper - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable graceful restart helper mode.
-
-
- graceful_restart_timers_restart - -
- string -
-
- -
Set maximum time for a restart sent to the BGP peer.
-
-
- graceful_restart_timers_stalepath_time - -
- string -
-
- -
Set maximum time that BGP keeps the stale routes from the restarting BGP peer.
-
-
- isolate - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable isolate this router from BGP perspective.
-
-
- local_as - -
- string -
-
- -
Local AS number to be used within a VRF instance.
-
-
- log_neighbor_changes - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable message logging for neighbor up/down event.
-
-
- maxas_limit - -
- string -
-
- -
Specify Maximum number of AS numbers allowed in the AS-path attribute. Valid values are between 1 and 512.
-
-
- neighbor_down_fib_accelerate - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable handle BGP neighbor down event, due to various reasons.
-
-
- reconnect_interval - -
- string -
-
- -
The BGP reconnection interval for dropped sessions. Valid values are between 1 and 60.
-
-
- router_id - -
- string -
-
- -
Router Identifier (ID) of the BGP router VRF instance.
-
-
- shutdown - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Administratively shutdown the BGP protocol.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Determines whether the config should be present or not on the device.
-
-
- suppress_fib_pending - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Enable/Disable advertise only routes programmed in hardware to peers.
-
-
- timer_bestpath_limit - -
- string -
-
- -
Specify timeout for the first best path after a restart, in seconds.
-
-
- timer_bgp_hold - -
- string -
-
- -
Set BGP hold timer.
-
-
- timer_bgp_keepalive - -
- string -
-
- -
Set BGP keepalive timer.
-
-
- vrf - -
- string -
-
- Default:
"default"
-
-
Name of the VRF. The name 'default' is a valid VRF representing the global BGP.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - ``state=absent`` removes the whole BGP ASN configuration when ``vrf=default`` or the whole VRF instance within the BGP process when using a different VRF. - - Default when supported restores params default value. - - Configuring global params is only permitted if ``vrf=default``. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: Configure a simple ASN - cisco.nxos.nxos_bgp: - asn: 65535 - vrf: test - router_id: 192.0.2.1 - state: present - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['router bgp 65535', 'vrf test', 'router-id 192.0.2.1']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2023-01-27. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Jason Edelman (@jedelman8) -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst deleted file mode 100644 index 00f856531..000000000 --- a/docs/cisco.nxos.nxos_bgp_neighbor_af_module.rst +++ /dev/null @@ -1,749 +0,0 @@ -.. _cisco.nxos.nxos_bgp_neighbor_af_module: - - -******************************* -cisco.nxos.nxos_bgp_neighbor_af -******************************* - -**(deprecated, removed after 2023-02-24) Manages BGP address-family's neighbors configuration.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2023-02-24 -:Why: Updated module released with more functionality. -:Alternative: nxos_bgp_neighbor_address_family - - - -Synopsis --------- -- Manages BGP address-family's neighbors configurations on NX-OS switches. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- additional_paths_receive - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
  • inherit
  • -
-
-
Valid values are enable for basic command enablement; disable for disabling the command at the neighbor af level (it adds the disable keyword to the basic command); and inherit to remove the command at this level (the command value is inherited from a higher BGP layer).
-
-
- additional_paths_send - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
  • inherit
  • -
-
-
Valid values are enable for basic command enablement; disable for disabling the command at the neighbor af level (it adds the disable keyword to the basic command); and inherit to remove the command at this level (the command value is inherited from a higher BGP layer).
-
-
- advertise_map_exist - -
- list - / elements=string -
-
- -
Conditional route advertisement. This property requires two route maps, an advertise-map and an exist-map. Valid values are an array specifying both the advertise-map name and the exist-map name, or simply 'default' e.g. ['my_advertise_map', 'my_exist_map']. This command is mutually exclusive with the advertise_map_non_exist property.
-
-
- advertise_map_non_exist - -
- list - / elements=string -
-
- -
Conditional route advertisement. This property requires two route maps, an advertise-map and an exist-map. Valid values are an array specifying both the advertise-map name and the non-exist-map name, or simply 'default' e.g. ['my_advertise_map', 'my_non_exist_map']. This command is mutually exclusive with the advertise_map_exist property.
-
-
- afi - -
- string - / required -
-
-
    Choices: -
  • ipv4
  • -
  • ipv6
  • -
  • vpnv4
  • -
  • vpnv6
  • -
  • l2vpn
  • -
-
-
Address Family Identifier.
-
-
- allowas_in - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Activate allowas-in property
-
-
- allowas_in_max - -
- string -
-
- -
Max-occurrences value for allowas_in. Valid values are an integer value or 'default'. This is mutually exclusive with allowas_in.
-
-
- as_override - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Activate the as-override feature.
-
-
- asn - -
- string - / required -
-
- -
BGP autonomous system number. Valid values are String, Integer in ASPLAIN or ASDOT notation.
-
-
- default_originate - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Activate the default-originate feature.
-
-
- default_originate_route_map - -
- string -
-
- -
Route-map for the default_originate property. Valid values are a string defining a route-map name, or 'default'. This is mutually exclusive with default_originate.
-
-
- disable_peer_as_check - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Disable checking of peer AS-number while advertising
-
-
- filter_list_in - -
- string -
-
- -
Valid values are a string defining a filter-list name, or 'default'.
-
-
- filter_list_out - -
- string -
-
- -
Valid values are a string defining a filter-list name, or 'default'.
-
-
- max_prefix_interval - -
- string -
-
- -
Optional restart interval. Valid values are an integer. Requires max_prefix_limit. May not be combined with max_prefix_warning.
-
-
- max_prefix_limit - -
- string -
-
- -
maximum-prefix limit value. Valid values are an integer value or 'default'.
-
-
- max_prefix_threshold - -
- string -
-
- -
Optional threshold percentage at which to generate a warning. Valid values are an integer value. Requires max_prefix_limit.
-
-
- max_prefix_warning - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Optional warning-only keyword. Requires max_prefix_limit. May not be combined with max_prefix_interval.
-
-
- neighbor - -
- string - / required -
-
- -
Neighbor Identifier. Valid values are string. Neighbors may use IPv4 or IPv6 notation, with or without prefix length.
-
-
- next_hop_self - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Activate the next-hop-self feature.
-
-
- next_hop_third_party - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Activate the next-hop-third-party feature.
-
-
- prefix_list_in - -
- string -
-
- -
Valid values are a string defining a prefix-list name, or 'default'.
-
-
- prefix_list_out - -
- string -
-
- -
Valid values are a string defining a prefix-list name, or 'default'.
-
-
- rewrite_evpn_rt_asn - -
- boolean -
-
added in 1.1.0
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Auto generate route targets for EBGP neighbor.
-
-
- route_map_in - -
- string -
-
- -
Valid values are a string defining a route-map name, or 'default'.
-
-
- route_map_out - -
- string -
-
- -
Valid values are a string defining a route-map name, or 'default'.
-
-
- route_reflector_client - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Router reflector client.
-
-
- safi - -
- string - / required -
-
-
    Choices: -
  • unicast
  • -
  • multicast
  • -
  • evpn
  • -
-
-
Sub Address Family Identifier.
-
-
- send_community - -
- string -
-
-
    Choices: -
  • none
  • -
  • both
  • -
  • extended
  • -
  • standard
  • -
  • default
  • -
-
-
send-community attribute.
-
-
- soft_reconfiguration_in - -
- string -
-
-
    Choices: -
  • enable
  • -
  • always
  • -
  • inherit
  • -
-
-
Valid values are 'enable' for basic command enablement; 'always' to add the always keyword to the basic command; and 'inherit' to remove the command at this level (the command value is inherited from a higher BGP layer).
-
-
- soo - -
- string -
-
- -
Site-of-origin. Valid values are a string defining a VPN extcommunity or 'default'.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Determines whether the config should be present or not on the device.
-
-
- suppress_inactive - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
suppress-inactive feature.
-
-
- unsuppress_map - -
- string -
-
- -
unsuppress-map. Valid values are a string defining a route-map name or 'default'.
-
-
- vrf - -
- string -
-
- Default:
"default"
-
-
Name of the VRF. The name 'default' is a valid VRF representing the global bgp.
-
-
- weight - -
- string -
-
- -
Weight value. Valid values are an integer value or 'default'.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - ``state=absent`` removes the whole BGP address-family's neighbor configuration. - - Default, when supported, removes properties - - In order to default maximum-prefix configuration, only ``max_prefix_limit=default`` is needed. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: configure RR client - cisco.nxos.nxos_bgp_neighbor_af: - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - route_reflector_client: true - state: present - rewrite_evpn_rt_asn: true - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['router bgp 65535', 'neighbor 192.0.2.3', 'address-family ipv4 unicast', 'route-reflector-client', 'rewrite-evpn-rt-asn']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2023-02-24. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_module.rst deleted file mode 100644 index e6f9e8f57..000000000 --- a/docs/cisco.nxos.nxos_bgp_neighbor_module.rst +++ /dev/null @@ -1,561 +0,0 @@ -.. _cisco.nxos.nxos_bgp_neighbor_module: - - -**************************** -cisco.nxos.nxos_bgp_neighbor -**************************** - -**(deprecated, removed after 2023-01-27) Manages BGP neighbors configurations.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2023-01-27 -:Why: Updated module released with more functionality. -:Alternative: nxos_bgp_global - - - -Synopsis --------- -- Manages BGP neighbors configurations on NX-OS switches. - - - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- asn - -
- string - / required -
-
- -
BGP autonomous system number. Valid values are string, Integer in ASPLAIN or ASDOT notation.
-
-
- bfd - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
-
-
Enables/Disables BFD for a given neighbor.
-
Dependency: ''feature bfd''
-
-
- capability_negotiation - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Configure whether or not to negotiate capability with this neighbor.
-
-
- connected_check - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Configure whether or not to check for directly connected peer.
-
-
- description - -
- string -
-
- -
Description of the neighbor.
-
-
- dynamic_capability - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Configure whether or not to enable dynamic capability.
-
-
- ebgp_multihop - -
- string -
-
- -
Specify multihop TTL for a remote peer. Valid values are integers between 2 and 255, or keyword 'default' to disable this property.
-
-
- local_as - -
- string -
-
- -
Specify the local-as number for the eBGP neighbor. Valid values are String or Integer in ASPLAIN or ASDOT notation, or 'default', which means not to configure it.
-
-
- log_neighbor_changes - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
  • inherit
  • -
-
-
Specify whether or not to enable log messages for neighbor up/down event.
-
-
- low_memory_exempt - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Specify whether or not to shut down this neighbor under memory pressure.
-
-
- maximum_peers - -
- string -
-
- -
Specify Maximum number of peers for this neighbor prefix Valid values are between 1 and 1000, or 'default', which does not impose the limit. Note that this parameter is accepted only on neighbors with address/prefix.
-
-
- neighbor - -
- string - / required -
-
- -
Neighbor Identifier. Valid values are string. Neighbors may use IPv4 or IPv6 notation, with or without prefix length.
-
-
- peer_type - -
- string -
-
added in 1.1.0
-
-
    Choices: -
  • fabric_border_leaf
  • -
  • fabric_external
  • -
  • disable
  • -
-
-
Specify the peer type for BGP session.
-
-
- pwd - -
- string -
-
- -
Specify the password for neighbor. Valid value is string.
-
-
- pwd_type - -
- string -
-
-
    Choices: -
  • 3des
  • -
  • cisco_type_7
  • -
  • default
  • -
-
-
Specify the encryption type the password will use. Valid values are '3des' or 'cisco_type_7' encryption or keyword 'default'.
-
-
- remote_as - -
- string -
-
- -
Specify Autonomous System Number of the neighbor. Valid values are String or Integer in ASPLAIN or ASDOT notation, or 'default', which means not to configure it.
-
-
- remove_private_as - -
- string -
-
-
    Choices: -
  • enable
  • -
  • disable
  • -
  • all
  • -
  • replace-as
  • -
-
-
Specify the config to remove private AS number from outbound updates. Valid values are 'enable' to enable this config, 'disable' to disable this config, 'all' to remove all private AS number, or 'replace-as', to replace the private AS number.
-
-
- shutdown - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Configure to administratively shutdown this neighbor.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Determines whether the config should be present or not on the device.
-
-
- suppress_4_byte_as - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Configure to suppress 4-byte AS Capability.
-
-
- timers_holdtime - -
- string -
-
- -
Specify holdtime timer value. Valid values are integers between 0 and 3600 in terms of seconds, or 'default', which is 180.
-
-
- timers_keepalive - -
- string -
-
- -
Specify keepalive timer value. Valid values are integers between 0 and 3600 in terms of seconds, or 'default', which is 60.
-
-
- transport_passive_only - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Specify whether or not to only allow passive connection setup. Valid values are 'true', 'false', and 'default', which defaults to 'false'. This property can only be configured when the neighbor is in 'ip' address format without prefix length.
-
-
- update_source - -
- string -
-
- -
Specify source interface of BGP session and updates.
-
-
- vrf - -
- string -
-
- Default:
"default"
-
-
Name of the VRF. The name 'default' is a valid VRF representing the global bgp.
-
-
- - -Notes ------ - -.. note:: - - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - Unsupported for Cisco MDS - - ``state=absent`` removes the whole BGP neighbor configuration. - - Default, where supported, restores params default value. - - For information on using CLI and NX-API see the :ref:`NXOS Platform Options guide ` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - # create a new neighbor - - cisco.nxos.nxos_bgp_neighbor: - asn: 65535 - neighbor: 192.0.2.3 - local_as: 20 - remote_as: 30 - bfd: enable - description: just a description - update_source: Ethernet1/3 - state: present - peer_type: fabric_external - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- commands - -
- list -
-
always -
commands sent to the device
-
-
Sample:
-
['router bgp 65535', 'neighbor 192.0.2.3', 'remote-as 30', 'update-source Ethernet1/3', 'description just a description', 'local-as 20', 'peer-type fabric-external']
-
-

- - -Status ------- - - -- This module will be removed in a release after 2023-01-27. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Gabriele Gerbino (@GGabriele) diff --git a/galaxy.yml b/galaxy.yml index 1af93f2b4..71bf73130 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 4.5.0-dev +version: 5.0.0-dev diff --git a/meta/runtime.yml b/meta/runtime.yml index 1f30b0e9c..d83b291f1 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -30,22 +30,6 @@ plugin_routing: redirect: cisco.nxos.nxos bfd_interfaces: redirect: cisco.nxos.nxos - nxos_bgp: - redirect: cisco.nxos.nxos - bgp: - redirect: cisco.nxos.nxos - nxos_bgp_af: - redirect: cisco.nxos.nxos - bgp_af: - redirect: cisco.nxos.nxos - nxos_bgp_neighbor: - redirect: cisco.nxos.nxos - bgp_neighbor: - redirect: cisco.nxos.nxos - nxos_bgp_neighbor_af: - redirect: cisco.nxos.nxos - bgp_neighbor_af: - redirect: cisco.nxos.nxos nxos_command: redirect: cisco.nxos.nxos command: @@ -357,42 +341,6 @@ plugin_routing: redirect: cisco.nxos.nxos_bfd_global bfd_interfaces: redirect: cisco.nxos.nxos_bfd_interfaces - bgp: - redirect: cisco.nxos.nxos_bgp - deprecation: - removal_date: "2023-01-27" - warning_text: See the plugin documentation for more details - nxos_bgp: - deprecation: - removal_date: "2023-01-27" - warning_text: See the plugin documentation for more details - bgp_af: - redirect: cisco.nxos.nxos_bgp_af - deprecation: - removal_date: "2023-02-24" - warning_text: See the plugin documentation for more details - nxos_bgp_af: - deprecation: - removal_date: "2023-02-24" - warning_text: See the plugin documentation for more details - bgp_neighbor: - redirect: cisco.nxos.nxos_bgp_neighbor - deprecation: - removal_date: "2023-01-27" - warning_text: See the plugin documentation for more details - nxos_bgp_neighbor: - deprecation: - removal_date: "2023-01-27" - warning_text: See the plugin documentation for more details - bgp_neighbor_af: - redirect: cisco.nxos.nxos_bgp_neighbor_af - deprecation: - removal_date: "2023-02-24" - warning_text: See the plugin documentation for more details - nxos_bgp_neighbor_af: - deprecation: - removal_date: "2023-02-24" - warning_text: See the plugin documentation for more details command: redirect: cisco.nxos.nxos_command config: diff --git a/plugins/modules/nxos_bgp.py b/plugins/modules/nxos_bgp.py deleted file mode 100644 index 2c56f412e..000000000 --- a/plugins/modules/nxos_bgp.py +++ /dev/null @@ -1,761 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_bgp -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2023-01-27) Manages BGP configuration. -description: -- Manages BGP configurations on NX-OS switches. -version_added: 1.0.0 -author: -- Jason Edelman (@jedelman8) -- Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_bgp_global - why: Updated module released with more functionality. - removed_at_date: '2023-01-27' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- C(state=absent) removes the whole BGP ASN configuration when C(vrf=default) or the - whole VRF instance within the BGP process when using a different VRF. -- Default when supported restores params default value. -- Configuring global params is only permitted if C(vrf=default). -options: - asn: - description: - - BGP autonomous system number. Valid values are String, Integer in ASPLAIN or - ASDOT notation. - required: true - type: str - vrf: - description: - - Name of the VRF. The name 'default' is a valid VRF representing the global BGP. - default: 'default' - type: str - bestpath_always_compare_med: - description: - - Enable/Disable MED comparison on paths from different autonomous systems. - type: bool - bestpath_aspath_multipath_relax: - description: - - Enable/Disable load sharing across the providers with different (but equal-length) - AS paths. - type: bool - bestpath_compare_routerid: - description: - - Enable/Disable comparison of router IDs for identical eBGP paths. - type: bool - bestpath_compare_neighborid: - description: - - Enable/Disable neighborid. Use this when more paths available than max path - config. - type: bool - bestpath_cost_community_ignore: - description: - - Enable/Disable Ignores the cost community for BGP best-path calculations. - type: bool - bestpath_med_confed: - description: - - Enable/Disable enforcement of bestpath to do a MED comparison only between paths - originated within a confederation. - type: bool - bestpath_med_missing_as_worst: - description: - - Enable/Disable assigns the value of infinity to received routes that do not - carry the MED attribute, making these routes the least desirable. - type: bool - bestpath_med_non_deterministic: - description: - - Enable/Disable deterministic selection of the best MED pat from among the paths - from the same autonomous system. - type: bool - cluster_id: - description: - - Route Reflector Cluster-ID. - type: str - confederation_id: - description: - - Routing domain confederation AS. - type: str - confederation_peers: - description: - - AS confederation parameters. - type: list - elements: str - disable_policy_batching: - description: - - Enable/Disable the batching evaluation of prefix advertisement to all peers. - type: bool - disable_policy_batching_ipv4_prefix_list: - description: - - Enable/Disable the batching evaluation of prefix advertisements to all peers - with prefix list. - type: str - disable_policy_batching_ipv6_prefix_list: - description: - - Enable/Disable the batching evaluation of prefix advertisements to all peers - with prefix list. - type: str - enforce_first_as: - description: - - Enable/Disable enforces the neighbor autonomous system to be the first AS number - listed in the AS path attribute for eBGP. On NX-OS, this property is only supported - in the global BGP context. - type: bool - event_history_cli: - description: - - Enable/Disable cli event history buffer. - choices: - - size_small - - size_medium - - size_large - - size_disable - - default - - 'true' - - 'false' - type: str - event_history_detail: - description: - - Enable/Disable detail event history buffer. - choices: - - size_small - - size_medium - - size_large - - size_disable - - default - - 'true' - - 'false' - type: str - event_history_events: - description: - - Enable/Disable event history buffer. - choices: - - size_small - - size_medium - - size_large - - size_disable - - default - - 'true' - - 'false' - type: str - event_history_periodic: - description: - - Enable/Disable periodic event history buffer. - choices: - - size_small - - size_medium - - size_large - - size_disable - - default - - 'true' - - 'false' - type: str - fast_external_fallover: - description: - - Enable/Disable immediately reset the session if the link to a directly connected - BGP peer goes down. Only supported in the global BGP context. - type: bool - flush_routes: - description: - - Enable/Disable flush routes in RIB upon controlled restart. On NX-OS, this property - is only supported in the global BGP context. - type: bool - graceful_restart: - description: - - Enable/Disable graceful restart. - type: bool - graceful_restart_helper: - description: - - Enable/Disable graceful restart helper mode. - type: bool - graceful_restart_timers_restart: - description: - - Set maximum time for a restart sent to the BGP peer. - type: str - graceful_restart_timers_stalepath_time: - description: - - Set maximum time that BGP keeps the stale routes from the restarting BGP peer. - type: str - isolate: - description: - - Enable/Disable isolate this router from BGP perspective. - type: bool - local_as: - description: - - Local AS number to be used within a VRF instance. - type: str - log_neighbor_changes: - description: - - Enable/Disable message logging for neighbor up/down event. - type: bool - maxas_limit: - description: - - Specify Maximum number of AS numbers allowed in the AS-path attribute. Valid - values are between 1 and 512. - type: str - neighbor_down_fib_accelerate: - description: - - Enable/Disable handle BGP neighbor down event, due to various reasons. - type: bool - reconnect_interval: - description: - - The BGP reconnection interval for dropped sessions. Valid values are between - 1 and 60. - type: str - router_id: - description: - - Router Identifier (ID) of the BGP router VRF instance. - type: str - shutdown: - description: - - Administratively shutdown the BGP protocol. - type: bool - suppress_fib_pending: - description: - - Enable/Disable advertise only routes programmed in hardware to peers. - type: bool - timer_bestpath_limit: - description: - - Specify timeout for the first best path after a restart, in seconds. - type: str - timer_bgp_hold: - description: - - Set BGP hold timer. - type: str - timer_bgp_keepalive: - description: - - Set BGP keepalive timer. - type: str - state: - description: - - Determines whether the config should be present or not on the device. - default: present - choices: - - present - - absent - type: str -""" - - -EXAMPLES = """ -- name: Configure a simple ASN - cisco.nxos.nxos_bgp: - asn: 65535 - vrf: test - router_id: 192.0.2.1 - state: present -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["router bgp 65535", "vrf test", "router-id 192.0.2.1"] -""" - -import re - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, -) - - -BOOL_PARAMS = [ - "bestpath_always_compare_med", - "bestpath_aspath_multipath_relax", - "bestpath_compare_neighborid", - "bestpath_compare_routerid", - "bestpath_cost_community_ignore", - "bestpath_med_confed", - "bestpath_med_missing_as_worst", - "bestpath_med_non_deterministic", - "disable_policy_batching", - "enforce_first_as", - "fast_external_fallover", - "flush_routes", - "graceful_restart", - "graceful_restart_helper", - "isolate", - "log_neighbor_changes", - "neighbor_down_fib_accelerate", - "shutdown", - "suppress_fib_pending", -] -GLOBAL_PARAMS = [ - "disable_policy_batching", - "disable_policy_batching_ipv4_prefix_list", - "disable_policy_batching_ipv6_prefix_list", - "enforce_first_as", - "event_history_cli", - "event_history_detail", - "event_history_events", - "event_history_periodic", - "fast_external_fallover", - "flush_routes", - "isolate", - "suppress_fib_pending", - "shutdown", -] -PARAM_TO_DEFAULT_KEYMAP = { - "timer_bgp_keepalive": "60", - "timer_bgp_hold": "180", - "timer_bestpath_limit": "300", - "graceful_restart": True, - "graceful_restart_timers_restart": "120", - "graceful_restart_timers_stalepath_time": "300", - "reconnect_interval": "60", - "suppress_fib_pending": True, - "fast_external_fallover": True, - "enforce_first_as": True, - "event_history_cli": True, - "event_history_detail": False, - "event_history_events": True, - "event_history_periodic": True, - "maxas_limit": "", - "router_id": "", - "cluster_id": "", - "disable_policy_batching_ipv4_prefix_list": "", - "disable_policy_batching_ipv6_prefix_list": "", - "local_as": "", - "confederation_id": "", -} -PARAM_TO_COMMAND_KEYMAP = { - "asn": "router bgp", - "bestpath_always_compare_med": "bestpath always-compare-med", - "bestpath_aspath_multipath_relax": "bestpath as-path multipath-relax", - "bestpath_compare_neighborid": "bestpath compare-neighborid", - "bestpath_compare_routerid": "bestpath compare-routerid", - "bestpath_cost_community_ignore": "bestpath cost-community ignore", - "bestpath_med_confed": "bestpath med confed", - "bestpath_med_missing_as_worst": "bestpath med missing-as-worst", - "bestpath_med_non_deterministic": "bestpath med non-deterministic", - "cluster_id": "cluster-id", - "confederation_id": "confederation identifier", - "confederation_peers": "confederation peers", - "disable_policy_batching": "disable-policy-batching", - "disable_policy_batching_ipv4_prefix_list": "disable-policy-batching ipv4 prefix-list", - "disable_policy_batching_ipv6_prefix_list": "disable-policy-batching ipv6 prefix-list", - "enforce_first_as": "enforce-first-as", - "event_history_cli": "event-history cli", - "event_history_detail": "event-history detail", - "event_history_events": "event-history events", - "event_history_periodic": "event-history periodic", - "fast_external_fallover": "fast-external-fallover", - "flush_routes": "flush-routes", - "graceful_restart": "graceful-restart", - "graceful_restart_helper": "graceful-restart-helper", - "graceful_restart_timers_restart": "graceful-restart restart-time", - "graceful_restart_timers_stalepath_time": "graceful-restart stalepath-time", - "isolate": "isolate", - "local_as": "local-as", - "log_neighbor_changes": "log-neighbor-changes", - "maxas_limit": "maxas-limit", - "neighbor_down_fib_accelerate": "neighbor-down fib-accelerate", - "reconnect_interval": "reconnect-interval", - "router_id": "router-id", - "shutdown": "shutdown", - "suppress_fib_pending": "suppress-fib-pending", - "timer_bestpath_limit": "timers bestpath-limit", - "timer_bgp_hold": "timers bgp", - "timer_bgp_keepalive": "timers bgp", - "vrf": "vrf", -} - - -def get_value(arg, config): - command = PARAM_TO_COMMAND_KEYMAP.get(arg) - - if command.split()[0] == "event-history": - has_size = re.search(r"^\s+{0} size\s(?P.*)$".format(command), config, re.M) - - if command == "event-history detail": - value = False - else: - value = "size_small" - - if has_size: - value = "size_%s" % has_size.group("value") - - elif arg in ["enforce_first_as", "fast_external_fallover"]: - no_command_re = re.compile(r"no\s+{0}\s*".format(command), re.M) - value = True - - if no_command_re.search(config): - value = False - - elif arg in BOOL_PARAMS: - has_command = re.search(r"^\s+{0}\s*$".format(command), config, re.M) - value = False - - if has_command: - value = True - else: - command_val_re = re.compile(r"(?:{0}\s)(?P.*)".format(command), re.M) - value = "" - - has_command = command_val_re.search(config) - if has_command: - found_value = has_command.group("value") - - if arg == "confederation_peers": - value = found_value.split() - elif arg == "timer_bgp_keepalive": - value = found_value.split()[0] - elif arg == "timer_bgp_hold": - split_values = found_value.split() - if len(split_values) == 2: - value = split_values[1] - elif found_value: - value = found_value - - return value - - -def get_existing(module, args, warnings): - existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=["bgp all"])) - - asn_re = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S) - asn_match = asn_re.match(str(netcfg)) - - if asn_match: - existing_asn = asn_match.group("existing_asn") - bgp_parent = "router bgp {0}".format(existing_asn) - - if module.params["vrf"] != "default": - parents = [bgp_parent, "vrf {0}".format(module.params["vrf"])] - else: - parents = [bgp_parent] - - config = netcfg.get_section(parents) - if config: - for arg in args: - if arg != "asn" and (module.params["vrf"] == "default" or arg not in GLOBAL_PARAMS): - existing[arg] = get_value(arg, config) - - existing["asn"] = existing_asn - if module.params["vrf"] == "default": - existing["vrf"] = "default" - - if not existing and module.params["vrf"] != "default" and module.params["state"] == "present": - msg = "VRF {0} doesn't exist.".format(module.params["vrf"]) - warnings.append(msg) - - return existing - - -def apply_key_map(key_map, table): - new_dict = {} - for key in table: - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = table.get(key) - - return new_dict - - -def state_present(module, existing, proposed, candidate): - commands = list() - proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - - for key, value in proposed_commands.items(): - if value is True: - commands.append(key) - elif value is False: - commands.append("no {0}".format(key)) - elif value == "default": - default_value = PARAM_TO_DEFAULT_KEYMAP.get(key) - existing_value = existing_commands.get(key) - - if default_value: - commands.append("{0} {1}".format(key, default_value)) - elif existing_value: - if key == "confederation peers": - existing_value = " ".join(existing_value) - commands.append("no {0} {1}".format(key, existing_value)) - elif not value: - existing_value = existing_commands.get(key) - if existing_value: - commands.append("no {0} {1}".format(key, existing_value)) - elif key == "confederation peers": - commands.append("{0} {1}".format(key, value)) - elif key.startswith("timers bgp"): - command = "timers bgp {0} {1}".format( - proposed["timer_bgp_keepalive"], - proposed["timer_bgp_hold"], - ) - if command not in commands: - commands.append(command) - else: - if value.startswith("size"): - value = value.replace("_", " ") - command = "{0} {1}".format(key, value) - commands.append(command) - - parents = [] - if commands: - commands = fix_commands(commands) - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - elif proposed: - if module.params["vrf"] != "default": - commands.append("vrf {0}".format(module.params["vrf"])) - parents = ["router bgp {0}".format(module.params["asn"])] - else: - commands.append("router bgp {0}".format(module.params["asn"])) - - candidate.add(commands, parents=parents) - - -def state_absent(module, existing, candidate): - commands = [] - parents = [] - if module.params["vrf"] == "default": - commands.append("no router bgp {0}".format(module.params["asn"])) - elif existing.get("vrf") == module.params["vrf"]: - commands.append("no vrf {0}".format(module.params["vrf"])) - parents = ["router bgp {0}".format(module.params["asn"])] - - candidate.add(commands, parents=parents) - - -def fix_commands(commands): - local_as_command = "" - confederation_id_command = "" - confederation_peers_command = "" - - for command in commands: - if "local-as" in command: - local_as_command = command - elif "confederation identifier" in command: - confederation_id_command = command - elif "confederation peers" in command: - confederation_peers_command = command - - if local_as_command and confederation_id_command: - if "no" in confederation_id_command: - commands.pop(commands.index(local_as_command)) - commands.pop(commands.index(confederation_id_command)) - commands.append(confederation_id_command) - commands.append(local_as_command) - else: - commands.pop(commands.index(local_as_command)) - commands.pop(commands.index(confederation_id_command)) - commands.append(local_as_command) - commands.append(confederation_id_command) - - if confederation_peers_command and confederation_id_command: - if local_as_command: - if "no" in local_as_command: - commands.pop(commands.index(local_as_command)) - commands.pop(commands.index(confederation_id_command)) - commands.pop(commands.index(confederation_peers_command)) - commands.append(confederation_id_command) - commands.append(confederation_peers_command) - commands.append(local_as_command) - else: - commands.pop(commands.index(local_as_command)) - commands.pop(commands.index(confederation_id_command)) - commands.pop(commands.index(confederation_peers_command)) - commands.append(local_as_command) - commands.append(confederation_id_command) - commands.append(confederation_peers_command) - else: - commands.pop(commands.index(confederation_peers_command)) - commands.pop(commands.index(confederation_id_command)) - commands.append(confederation_id_command) - commands.append(confederation_peers_command) - - return commands - - -def main(): - argument_spec = dict( - asn=dict(required=True, type="str"), - vrf=dict(required=False, type="str", default="default"), - bestpath_always_compare_med=dict(required=False, type="bool"), - bestpath_aspath_multipath_relax=dict(required=False, type="bool"), - bestpath_compare_neighborid=dict(required=False, type="bool"), - bestpath_compare_routerid=dict(required=False, type="bool"), - bestpath_cost_community_ignore=dict(required=False, type="bool"), - bestpath_med_confed=dict(required=False, type="bool"), - bestpath_med_missing_as_worst=dict(required=False, type="bool"), - bestpath_med_non_deterministic=dict(required=False, type="bool"), - cluster_id=dict(required=False, type="str"), - confederation_id=dict(required=False, type="str"), - confederation_peers=dict(required=False, type="list", elements="str"), - disable_policy_batching=dict(required=False, type="bool"), - disable_policy_batching_ipv4_prefix_list=dict(required=False, type="str"), - disable_policy_batching_ipv6_prefix_list=dict(required=False, type="str"), - enforce_first_as=dict(required=False, type="bool"), - event_history_cli=dict( - required=False, - choices=[ - "true", - "false", - "default", - "size_small", - "size_medium", - "size_large", - "size_disable", - ], - ), - event_history_detail=dict( - required=False, - choices=[ - "true", - "false", - "default", - "size_small", - "size_medium", - "size_large", - "size_disable", - ], - ), - event_history_events=dict( - required=False, - choices=[ - "true", - "false", - "default", - "size_small", - "size_medium", - "size_large", - "size_disable", - ], - ), - event_history_periodic=dict( - required=False, - choices=[ - "true", - "false", - "default", - "size_small", - "size_medium", - "size_large", - "size_disable", - ], - ), - fast_external_fallover=dict(required=False, type="bool"), - flush_routes=dict(required=False, type="bool"), - graceful_restart=dict(required=False, type="bool"), - graceful_restart_helper=dict(required=False, type="bool"), - graceful_restart_timers_restart=dict(required=False, type="str"), - graceful_restart_timers_stalepath_time=dict(required=False, type="str"), - isolate=dict(required=False, type="bool"), - local_as=dict(required=False, type="str"), - log_neighbor_changes=dict(required=False, type="bool"), - maxas_limit=dict(required=False, type="str"), - neighbor_down_fib_accelerate=dict(required=False, type="bool"), - reconnect_interval=dict(required=False, type="str"), - router_id=dict(required=False, type="str"), - shutdown=dict(required=False, type="bool"), - suppress_fib_pending=dict(required=False, type="bool"), - timer_bestpath_limit=dict(required=False, type="str"), - timer_bgp_hold=dict(required=False, type="str"), - timer_bgp_keepalive=dict(required=False, type="str"), - state=dict(choices=["present", "absent"], default="present", required=False), - ) - - module = AnsibleModule( - argument_spec=argument_spec, - required_together=[["timer_bgp_hold", "timer_bgp_keepalive"]], - supports_check_mode=True, - ) - - warnings = list() - result = dict(changed=False, warnings=warnings) - - state = module.params["state"] - - if module.params["vrf"] != "default": - for param in GLOBAL_PARAMS: - if module.params[param]: - module.fail_json( - msg='Global params can be modified only under "default" VRF.', - vrf=module.params["vrf"], - global_param=param, - ) - - args = PARAM_TO_COMMAND_KEYMAP.keys() - existing = get_existing(module, args, warnings) - - if existing.get("asn") and state == "present": - if existing.get("asn") != module.params["asn"]: - module.fail_json( - msg="Another BGP ASN already exists.", - proposed_asn=module.params["asn"], - existing_asn=existing.get("asn"), - ) - - proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) - proposed = {} - for key, value in proposed_args.items(): - if key not in ["asn", "vrf"]: - if str(value).lower() == "default": - value = PARAM_TO_DEFAULT_KEYMAP.get(key, "default") - if key == "confederation_peers": - if value[0] == "default": - if existing.get(key): - proposed[key] = "default" - else: - v = set([int(i) for i in value]) - ex = set([int(i) for i in existing.get(key)]) - if v != ex: - proposed[key] = " ".join(str(s) for s in v) - else: - if existing.get(key) != value: - proposed[key] = value - - candidate = CustomNetworkConfig(indent=3) - if state == "present": - state_present(module, existing, proposed, candidate) - elif existing.get("asn") == module.params["asn"]: - state_absent(module, existing, candidate) - - if candidate: - candidate = candidate.items_text() - if not module.check_mode: - load_config(module, candidate) - result["changed"] = True - result["commands"] = candidate - else: - result["commands"] = [] - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_bgp_af.py b/plugins/modules/nxos_bgp_af.py deleted file mode 100644 index 290f241dc..000000000 --- a/plugins/modules/nxos_bgp_af.py +++ /dev/null @@ -1,877 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_bgp_af -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2023-02-24) Manages BGP Address-family configuration. -description: -- Manages BGP Address-family configurations on NX-OS switches. -version_added: 1.0.0 -author: Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_bgp_address_family - why: Updated module released with more functionality. - removed_at_date: '2023-02-24' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- C(state=absent) removes the whole BGP ASN configuration -- Default, where supported, restores params default value. -options: - asn: - description: - - BGP autonomous system number. Valid values are String, Integer in ASPLAIN or - ASDOT notation. - required: true - type: str - vrf: - description: - - Name of the VRF. The name 'default' is a valid VRF representing the global bgp. - default: 'default' - type: str - afi: - description: - - Address Family Identifier. - required: true - choices: - - ipv4 - - ipv6 - - vpnv4 - - vpnv6 - - l2vpn - type: str - safi: - description: - - Sub Address Family Identifier. - required: true - choices: - - unicast - - multicast - - evpn - type: str - additional_paths_install: - description: - - Install a backup path into the forwarding table and provide prefix independent - convergence (PIC) in case of a PE-CE link failure. - type: bool - additional_paths_receive: - description: - - Enables the receive capability of additional paths for all of the neighbors - under this address family for which the capability has not been disabled. - type: bool - additional_paths_selection: - description: - - Configures the capability of selecting additional paths for a prefix. Valid - values are a string defining the name of the route-map. - type: str - additional_paths_send: - description: - - Enables the send capability of additional paths for all of the neighbors under - this address family for which the capability has not been disabled. - type: bool - advertise_l2vpn_evpn: - description: - - Advertise evpn routes. - type: bool - client_to_client: - description: - - Configure client-to-client route reflection. - type: bool - dampen_igp_metric: - description: - - Specify dampen value for IGP metric-related changes, in seconds. Valid values - are integer and keyword 'default'. - type: str - dampening_state: - description: - - Enable/disable route-flap dampening. - type: bool - dampening_half_time: - description: - - Specify decay half-life in minutes for route-flap dampening. Valid values are - integer and keyword 'default'. - type: str - dampening_max_suppress_time: - description: - - Specify max suppress time for route-flap dampening stable route. Valid values - are integer and keyword 'default'. - type: str - dampening_reuse_time: - description: - - Specify route reuse time for route-flap dampening. Valid values are integer - and keyword 'default'. - type: str - dampening_routemap: - description: - - Specify route-map for route-flap dampening. Valid values are a string defining - the name of the route-map. - type: str - dampening_suppress_time: - description: - - Specify route suppress time for route-flap dampening. Valid values are integer - and keyword 'default'. - type: str - default_information_originate: - description: - - Default information originate. - type: bool - default_metric: - description: - - Sets default metrics for routes redistributed into BGP. Valid values are Integer - or keyword 'default' - type: str - distance_ebgp: - description: - - Sets the administrative distance for eBGP routes. Valid values are Integer or - keyword 'default'. - type: str - distance_ibgp: - description: - - Sets the administrative distance for iBGP routes. Valid values are Integer or - keyword 'default'. - type: str - distance_local: - description: - - Sets the administrative distance for local BGP routes. Valid values are Integer - or keyword 'default'. - type: str - inject_map: - description: - - An array of route-map names which will specify prefixes to inject. Each array - entry must first specify the inject-map name, secondly an exist-map name, and - optionally the copy-attributes keyword which indicates that attributes should - be copied from the aggregate. For example [['lax_inject_map', 'lax_exist_map'], - ['nyc_inject_map', 'nyc_exist_map', 'copy-attributes'], ['fsd_inject_map', 'fsd_exist_map']]. - type: list - elements: list - maximum_paths: - description: - - Configures the maximum number of equal-cost paths for load sharing. Valid value - is an integer in the range 1-64. - type: str - maximum_paths_ibgp: - description: - - Configures the maximum number of ibgp equal-cost paths for load sharing. Valid - value is an integer in the range 1-64. - type: str - networks: - description: - - Networks to configure. Valid value is a list of network prefixes to advertise. - The list must be in the form of an array. Each entry in the array must include - a prefix address and an optional route-map. For example [['10.0.0.0/16', 'routemap_LA'], - ['192.168.1.1', 'Chicago'], ['192.168.2.0/24'], ['192.168.3.0/24', 'routemap_NYC']]. - type: list - elements: list - next_hop_route_map: - description: - - Configure a route-map for valid nexthops. Valid values are a string defining - the name of the route-map. - type: str - redistribute: - description: - - A list of redistribute directives. Multiple redistribute entries are allowed. - The list must be in the form of a nested array. the first entry of each array - defines the source-protocol to redistribute from; the second entry defines a - route-map name. A route-map is highly advised but may be optional on some platforms, - in which case it may be omitted from the array list. For example [['direct', - 'rm_direct'], ['lisp', 'rm_lisp']]. - type: list - elements: list - suppress_inactive: - description: - - Advertises only active routes to peers. - type: bool - table_map: - description: - - Apply table-map to filter routes downloaded into URIB. Valid values are a string. - type: str - table_map_filter: - description: - - Filters routes rejected by the route-map and does not download them to the RIB. - type: bool - state: - description: - - Determines whether the config should be present or not on the device. - default: present - choices: - - present - - absent - type: str - retain_route_target: - description: - - Retains all of the routes or the routes which are part of configured route-map. - Valid values are route-map names or keyword C(all) or keyword C(default). C(all) - retains all the routes regardless of Target-VPN community. C(default) will disable - the retain route target option. If you are using route-map name please ensure - that the name is not same as C(all) and C(default). - type: str - version_added: 1.1.0 -""" -EXAMPLES = """ -# configure a simple address-family -- cisco.nxos.nxos_bgp_af: - asn: 65535 - vrf: TESTING - afi: ipv4 - safi: unicast - advertise_l2vpn_evpn: true - state: present - retain_route_target: all -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["router bgp 65535", "vrf TESTING", - "address-family ipv4 unicast", "advertise l2vpn evpn", - "retain route-target all"] -""" - -import re - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, -) - - -BOOL_PARAMS = [ - "additional_paths_install", - "additional_paths_receive", - "additional_paths_send", - "advertise_l2vpn_evpn", - "dampening_state", - "default_information_originate", - "suppress_inactive", -] -PARAM_TO_DEFAULT_KEYMAP = { - "maximum_paths": "1", - "maximum_paths_ibgp": "1", - "client_to_client": True, - "distance_ebgp": "20", - "distance_ibgp": "200", - "distance_local": "220", - "dampen_igp_metric": "600", -} -PARAM_TO_COMMAND_KEYMAP = { - "asn": "router bgp", - "afi": "address-family", - "safi": "address-family", - "additional_paths_install": "additional-paths install backup", - "additional_paths_receive": "additional-paths receive", - "additional_paths_selection": "additional-paths selection route-map", - "additional_paths_send": "additional-paths send", - "advertise_l2vpn_evpn": "advertise l2vpn evpn", - "client_to_client": "client-to-client reflection", - "dampen_igp_metric": "dampen-igp-metric", - "dampening_state": "dampening", - "dampening_half_time": "dampening", - "dampening_max_suppress_time": "dampening", - "dampening_reuse_time": "dampening", - "dampening_routemap": "dampening route-map", - "dampening_suppress_time": "dampening", - "default_information_originate": "default-information originate", - "default_metric": "default-metric", - "distance_ebgp": "distance", - "distance_ibgp": "distance", - "distance_local": "distance", - "inject_map": "inject-map", - "maximum_paths": "maximum-paths", - "maximum_paths_ibgp": "maximum-paths ibgp", - "networks": "network", - "redistribute": "redistribute", - "next_hop_route_map": "nexthop route-map", - "suppress_inactive": "suppress-inactive", - "table_map": "table-map", - "table_map_filter": "table-map-filter", - "vrf": "vrf", - "retain_route_target": "retain route-target", -} -DAMPENING_PARAMS = [ - "dampening_half_time", - "dampening_suppress_time", - "dampening_reuse_time", - "dampening_max_suppress_time", -] - - -def get_value(arg, config, module): - command = PARAM_TO_COMMAND_KEYMAP[arg] - command_val_re = re.compile(r"(?:{0}\s)(?P.*)$".format(command), re.M) - has_command_val = command_val_re.search(config) - - if arg in ["networks", "redistribute", "inject_map"]: - value = [] - for ele in command_val_re.findall(config): - tl = ele.split() - if "exist-map" in tl: - tl.remove("exist-map") - elif "route-map" in tl: - tl.remove("route-map") - value.append(tl) - - elif command == "distance": - distance_re = r".*distance\s(?P\w+)\s(?P\w+)\s(?P\w+)" - match_distance = re.match(distance_re, config, re.DOTALL) - - value = "" - if match_distance: - distance_group = match_distance.groupdict() - - if arg == "distance_ebgp": - value = distance_group["d_ebgp"] - elif arg == "distance_ibgp": - value = distance_group["d_ibgp"] - elif arg == "distance_local": - value = distance_group["d_local"] - - elif command.split()[0] == "dampening": - value = "" - if arg == "dampen_igp_metric" or arg == "dampening_routemap": - if command in config: - value = has_command_val.group("value") - else: - dampening_re = r".*dampening\s(?P\w+)\s(?P\w+)\s(?P\w+)\s(?P\w+)" - match_dampening = re.match(dampening_re, config, re.DOTALL) - if match_dampening: - dampening_group = match_dampening.groupdict() - - if arg == "dampening_half_time": - value = dampening_group["half"] - elif arg == "dampening_reuse_time": - value = dampening_group["reuse"] - elif arg == "dampening_suppress_time": - value = dampening_group["suppress"] - elif arg == "dampening_max_suppress_time": - value = dampening_group["max_suppress"] - else: - if arg == "dampening_state": - value = True if "dampening" in config else False - elif arg == "table_map_filter": - tmf_regex = re.compile(r"\s+table-map.*filter$", re.M) - value = False - if tmf_regex.search(config): - value = True - - elif arg == "table_map": - tm_regex = re.compile(r"(?:table-map\s)(?P\S+)(\sfilter)?$", re.M) - has_tablemap = tm_regex.search(config) - value = "" - if has_tablemap: - value = has_tablemap.group("value") - - elif arg == "client_to_client": - no_command_re = re.compile(r"^\s+no\s{0}\s*$".format(command), re.M) - value = True - - if no_command_re.search(config): - value = False - - elif arg == "retain_route_target": - value = "" - if command in config: - route_target = has_command_val.group("value") - if route_target: - if route_target == "all": - value = "all" - elif "route-map" in route_target: - value = route_target.replace("route-map ", "") - - elif arg in BOOL_PARAMS: - command_re = re.compile(r"^\s+{0}\s*$".format(command), re.M) - value = False - - if command_re.search(config): - value = True - - else: - value = "" - - if has_command_val: - value = has_command_val.group("value") - - return value - - -def get_existing(module, args, warnings): - existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - - asn_regex = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.DOTALL) - match_asn = asn_regex.match(str(netcfg)) - - if match_asn: - existing_asn = match_asn.group("existing_asn") - parents = ["router bgp {0}".format(existing_asn)] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - parents.append("address-family {0} {1}".format(module.params["afi"], module.params["safi"])) - config = netcfg.get_section(parents) - - if config: - for arg in args: - if arg not in ["asn", "afi", "safi", "vrf"]: - gv = get_value(arg, config, module) - if gv: - existing[arg] = gv - else: - if arg != "client_to_client" and arg in PARAM_TO_DEFAULT_KEYMAP.keys(): - existing[arg] = PARAM_TO_DEFAULT_KEYMAP.get(arg) - else: - existing[arg] = gv - - existing["asn"] = existing_asn - existing["afi"] = module.params["afi"] - existing["safi"] = module.params["safi"] - existing["vrf"] = module.params["vrf"] - else: - warnings.append( - "The BGP process {0} didn't exist but the task just created it.".format( - module.params["asn"], - ), - ) - - return existing - - -def apply_key_map(key_map, table): - new_dict = {} - for key, value in table.items(): - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = value - - return new_dict - - -def fix_proposed(module, proposed, existing): - commands = list() - command = "" - fixed_proposed = {} - for key, value in proposed.items(): - if key in DAMPENING_PARAMS: - if value != "default": - command = "dampening {0} {1} {2} {3}".format( - proposed.get("dampening_half_time"), - proposed.get("dampening_reuse_time"), - proposed.get("dampening_suppress_time"), - proposed.get("dampening_max_suppress_time"), - ) - else: - if existing.get(key): - command = "no dampening {0} {1} {2} {3}".format( - existing["dampening_half_time"], - existing["dampening_reuse_time"], - existing["dampening_suppress_time"], - existing["dampening_max_suppress_time"], - ) - if "default" in command: - command = "" - elif key.startswith("distance"): - command = "distance {0} {1} {2}".format( - proposed.get("distance_ebgp"), - proposed.get("distance_ibgp"), - proposed.get("distance_local"), - ) - else: - fixed_proposed[key] = value - - if command: - if command not in commands: - commands.append(command) - - return fixed_proposed, commands - - -def default_existing(existing_value, key, value): - commands = [] - if key == "network": - for network in existing_value: - if len(network) == 2: - commands.append("no network {0} route-map {1}".format(network[0], network[1])) - elif len(network) == 1: - commands.append("no network {0}".format(network[0])) - - elif key == "inject-map": - for maps in existing_value: - if len(maps) == 2: - commands.append("no inject-map {0} exist-map {1}".format(maps[0], maps[1])) - elif len(maps) == 3: - commands.append( - "no inject-map {0} exist-map {1} " "copy-attributes".format(maps[0], maps[1]), - ) - - elif key == "redistribute": - for maps in existing_value: - commands.append("no redistribute {0} route-map {1}".format(maps[0], maps[1])) - - elif key == "retain route-target": - if existing_value == "all": - commands.append("no {0} {1}".format(key, existing_value)) - elif existing_value != "default": - commands.append("no {0} route-map {1}".format(key, existing_value)) - - else: - commands.append("no {0} {1}".format(key, existing_value)) - return commands - - -def get_network_command(existing, key, value): - commands = [] - existing_networks = existing.get("networks", []) - for inet in value: - if not isinstance(inet, list): - inet = [inet] - if inet not in existing_networks: - if len(inet) == 1: - command = "{0} {1}".format(key, inet[0]) - elif len(inet) == 2: - command = "{0} {1} route-map {2}".format(key, inet[0], inet[1]) - if command: - commands.append(command) - for enet in existing_networks: - if enet not in value: - if len(enet) == 1: - command = "no {0} {1}".format(key, enet[0]) - elif len(enet) == 2: - command = "no {0} {1} route-map {2}".format(key, enet[0], enet[1]) - if command: - commands.append(command) - return commands - - -def get_inject_map_command(existing, key, value): - commands = [] - existing_maps = existing.get("inject_map", []) - for maps in value: - if not isinstance(maps, list): - maps = [maps] - if maps not in existing_maps: - if len(maps) == 2: - command = "inject-map {0} exist-map {1}".format(maps[0], maps[1]) - elif len(maps) == 3: - command = "inject-map {0} exist-map {1} " "copy-attributes".format(maps[0], maps[1]) - if command: - commands.append(command) - for emaps in existing_maps: - if emaps not in value: - if len(emaps) == 2: - command = "no inject-map {0} exist-map {1}".format(emaps[0], emaps[1]) - elif len(emaps) == 3: - command = "no inject-map {0} exist-map {1} " "copy-attributes".format( - emaps[0], - emaps[1], - ) - if command: - commands.append(command) - return commands - - -def get_redistribute_command(existing, key, value): - commands = [] - existing_rules = existing.get("redistribute", []) - for rule in value: - if not isinstance(rule, list): - rule = [rule] - if rule not in existing_rules: - command = "redistribute {0} route-map {1}".format(rule[0], rule[1]) - commands.append(command) - for erule in existing_rules: - if erule not in value: - command = "no redistribute {0} route-map {1}".format(erule[0], erule[1]) - commands.append(command) - return commands - - -def get_table_map_command(module, existing, key, value): - commands = [] - if key == "table-map": - if value != "default": - command = "{0} {1}".format(key, module.params["table_map"]) - if ( - module.params["table_map_filter"] is not None - and module.params["table_map_filter"] != "default" - ): - command += " filter" - commands.append(command) - else: - if existing.get("table_map"): - command = "no {0} {1}".format(key, existing.get("table_map")) - commands.append(command) - return commands - - -def get_retain_route_target_command(existing, key, value): - commands = [] - if key == "retain route-target": - if value != "default": - if value == "all": - command = "{0} {1}".format(key, value) - else: - command = "{0} route-map {1}".format(key, value) - else: - existing_value = existing.get("retain_route_target") - if existing_value == "all": - command = "no {0} {1}".format(key, existing_value) - else: - command = "no {0} route-map {1}".format(key, existing_value) - commands.append(command) - return commands - - -def get_default_table_map_filter(existing): - commands = [] - existing_table_map_filter = existing.get("table_map_filter") - if existing_table_map_filter: - existing_table_map = existing.get("table_map") - if existing_table_map: - command = "table-map {0}".format(existing_table_map) - commands.append(command) - return commands - - -def state_present(module, existing, proposed, candidate): - fixed_proposed, commands = fix_proposed(module, proposed, existing) - proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, fixed_proposed) - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.items(): - if key == "address-family": - addr_family_command = "address-family {0} {1}".format( - module.params["afi"], - module.params["safi"], - ) - if addr_family_command not in commands: - commands.append(addr_family_command) - - elif key.startswith("table-map"): - table_map_commands = get_table_map_command(module, existing, key, value) - if table_map_commands: - commands.extend(table_map_commands) - - elif value is True: - commands.append(key) - - elif value is False: - commands.append("no {0}".format(key)) - - elif value == "default": - if key in PARAM_TO_DEFAULT_KEYMAP: - commands.append("{0} {1}".format(key, PARAM_TO_DEFAULT_KEYMAP[key])) - - elif existing_commands.get(key): - if key == "table-map-filter": - default_tmf_command = get_default_table_map_filter(existing) - - if default_tmf_command: - commands.extend(default_tmf_command) - else: - existing_value = existing_commands.get(key) - default_command = default_existing(existing_value, key, value) - if default_command: - commands.extend(default_command) - else: - if key == "network": - network_commands = get_network_command(existing, key, value) - if network_commands: - commands.extend(network_commands) - - elif key == "inject-map": - inject_map_commands = get_inject_map_command(existing, key, value) - if inject_map_commands: - commands.extend(inject_map_commands) - - elif key == "redistribute": - redistribute_commands = get_redistribute_command(existing, key, value) - if redistribute_commands: - commands.extend(redistribute_commands) - - elif key == "retain route-target": - retain_route_target_commands = get_retain_route_target_command(existing, key, value) - if retain_route_target_commands: - commands.extend(retain_route_target_commands) - - else: - command = "{0} {1}".format(key, value) - commands.append(command) - - if commands: - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - addr_family_command = "address-family {0} {1}".format( - module.params["afi"], - module.params["safi"], - ) - parents.append(addr_family_command) - if addr_family_command in commands: - commands.remove(addr_family_command) - candidate.add(commands, parents=parents) - - -def state_absent(module, candidate): - commands = [] - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - commands.append("no address-family {0} {1}".format(module.params["afi"], module.params["safi"])) - candidate.add(commands, parents=parents) - - -def main(): - argument_spec = dict( - asn=dict(required=True, type="str"), - vrf=dict(required=False, type="str", default="default"), - safi=dict(required=True, type="str", choices=["unicast", "multicast", "evpn"]), - afi=dict( - required=True, - type="str", - choices=["ipv4", "ipv6", "vpnv4", "vpnv6", "l2vpn"], - ), - additional_paths_install=dict(required=False, type="bool"), - additional_paths_receive=dict(required=False, type="bool"), - additional_paths_selection=dict(required=False, type="str"), - additional_paths_send=dict(required=False, type="bool"), - advertise_l2vpn_evpn=dict(required=False, type="bool"), - client_to_client=dict(required=False, type="bool"), - dampen_igp_metric=dict(required=False, type="str"), - dampening_state=dict(required=False, type="bool"), - dampening_half_time=dict(required=False, type="str"), - dampening_max_suppress_time=dict(required=False, type="str"), - dampening_reuse_time=dict(required=False, type="str"), - dampening_routemap=dict(required=False, type="str"), - dampening_suppress_time=dict(required=False, type="str"), - default_information_originate=dict(required=False, type="bool"), - default_metric=dict(required=False, type="str"), - distance_ebgp=dict(required=False, type="str"), - distance_ibgp=dict(required=False, type="str"), - distance_local=dict(required=False, type="str"), - inject_map=dict(required=False, type="list", elements="list"), - maximum_paths=dict(required=False, type="str"), - maximum_paths_ibgp=dict(required=False, type="str"), - networks=dict(required=False, type="list", elements="list"), - next_hop_route_map=dict(required=False, type="str"), - redistribute=dict(required=False, type="list", elements="list"), - suppress_inactive=dict(required=False, type="bool"), - table_map=dict(required=False, type="str"), - table_map_filter=dict(required=False, type="bool"), - state=dict(choices=["present", "absent"], default="present", required=False), - retain_route_target=dict(required=False, type="str"), - ) - - mutually_exclusive = [ - ("dampening_state", "dampening_routemap"), - ("dampening_state", "dampening_half_time"), - ("dampening_state", "dampening_suppress_time"), - ("dampening_state", "dampening_reuse_time"), - ("dampening_state", "dampening_max_suppress_time"), - ("dampening_routemap", "dampening_half_time"), - ("dampening_routemap", "dampening_suppress_time"), - ("dampening_routemap", "dampening_reuse_time"), - ("dampening_routemap", "dampening_max_suppress_time"), - ] - - module = AnsibleModule( - argument_spec=argument_spec, - mutually_exclusive=mutually_exclusive, - required_together=[ - DAMPENING_PARAMS, - ["distance_ibgp", "distance_ebgp", "distance_local"], - ], - supports_check_mode=True, - ) - - warnings = list() - result = dict(changed=False, warnings=warnings) - - state = module.params["state"] - - if module.params["advertise_l2vpn_evpn"]: - if module.params["vrf"] == "default": - module.fail_json( - msg="It is not possible to advertise L2VPN " - "EVPN in the default VRF. Please specify " - "another one.", - vrf=module.params["vrf"], - ) - - if module.params["table_map_filter"] and not module.params["table_map"]: - module.fail_json(msg="table_map param is needed when using" " table_map_filter filter.") - - args = PARAM_TO_COMMAND_KEYMAP.keys() - existing = get_existing(module, args, warnings) - - if existing.get("asn") and state == "present": - if existing.get("asn") != module.params["asn"]: - module.fail_json( - msg="Another BGP ASN already exists.", - proposed_asn=module.params["asn"], - existing_asn=existing.get("asn"), - ) - - proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) - - for arg in ["networks", "inject_map", "redistribute"]: - if proposed_args.get(arg): - if proposed_args[arg][0] == "default": - proposed_args[arg] = "default" - - proposed = {} - for key, value in proposed_args.items(): - if key not in ["asn", "vrf"]: - if str(value).lower() == "default": - value = PARAM_TO_DEFAULT_KEYMAP.get(key, "default") - if existing.get(key) != value: - proposed[key] = value - - candidate = CustomNetworkConfig(indent=3) - if state == "present": - state_present(module, existing, proposed, candidate) - elif state == "absent" and existing: - state_absent(module, candidate) - - if candidate: - candidate = candidate.items_text() - if not module.check_mode: - load_config(module, candidate) - result["changed"] = True - result["commands"] = candidate - else: - result["commands"] = [] - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_bgp_neighbor.py b/plugins/modules/nxos_bgp_neighbor.py deleted file mode 100644 index 2c5283caa..000000000 --- a/plugins/modules/nxos_bgp_neighbor.py +++ /dev/null @@ -1,569 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_bgp_neighbor -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2023-01-27) Manages BGP neighbors configurations. -description: -- Manages BGP neighbors configurations on NX-OS switches. -version_added: 1.0.0 -author: Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_bgp_global - why: Updated module released with more functionality. - removed_at_date: '2023-01-27' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- C(state=absent) removes the whole BGP neighbor configuration. -- Default, where supported, restores params default value. -options: - asn: - description: - - BGP autonomous system number. Valid values are string, Integer in ASPLAIN or - ASDOT notation. - required: true - type: str - vrf: - description: - - Name of the VRF. The name 'default' is a valid VRF representing the global bgp. - default: default - type: str - neighbor: - description: - - Neighbor Identifier. Valid values are string. Neighbors may use IPv4 or IPv6 - notation, with or without prefix length. - required: true - type: str - description: - description: - - Description of the neighbor. - type: str - bfd: - description: - - Enables/Disables BFD for a given neighbor. - - "Dependency: ''feature bfd''" - type: str - choices: - - enable - - disable - connected_check: - description: - - Configure whether or not to check for directly connected peer. - type: bool - capability_negotiation: - description: - - Configure whether or not to negotiate capability with this neighbor. - type: bool - dynamic_capability: - description: - - Configure whether or not to enable dynamic capability. - type: bool - ebgp_multihop: - description: - - Specify multihop TTL for a remote peer. Valid values are integers between 2 - and 255, or keyword 'default' to disable this property. - type: str - local_as: - description: - - Specify the local-as number for the eBGP neighbor. Valid values are String or - Integer in ASPLAIN or ASDOT notation, or 'default', which means not to configure - it. - type: str - log_neighbor_changes: - description: - - Specify whether or not to enable log messages for neighbor up/down event. - choices: - - enable - - disable - - inherit - type: str - low_memory_exempt: - description: - - Specify whether or not to shut down this neighbor under memory pressure. - type: bool - maximum_peers: - description: - - Specify Maximum number of peers for this neighbor prefix Valid values are between - 1 and 1000, or 'default', which does not impose the limit. Note that this parameter - is accepted only on neighbors with address/prefix. - type: str - pwd: - description: - - Specify the password for neighbor. Valid value is string. - type: str - pwd_type: - description: - - Specify the encryption type the password will use. Valid values are '3des' or - 'cisco_type_7' encryption or keyword 'default'. - choices: - - 3des - - cisco_type_7 - - default - type: str - remote_as: - description: - - Specify Autonomous System Number of the neighbor. Valid values are String or - Integer in ASPLAIN or ASDOT notation, or 'default', which means not to configure - it. - type: str - remove_private_as: - description: - - Specify the config to remove private AS number from outbound updates. Valid - values are 'enable' to enable this config, 'disable' to disable this config, - 'all' to remove all private AS number, or 'replace-as', to replace the private - AS number. - choices: - - enable - - disable - - all - - replace-as - type: str - shutdown: - description: - - Configure to administratively shutdown this neighbor. - type: bool - suppress_4_byte_as: - description: - - Configure to suppress 4-byte AS Capability. - type: bool - timers_keepalive: - description: - - Specify keepalive timer value. Valid values are integers between 0 and 3600 - in terms of seconds, or 'default', which is 60. - type: str - timers_holdtime: - description: - - Specify holdtime timer value. Valid values are integers between 0 and 3600 in - terms of seconds, or 'default', which is 180. - type: str - transport_passive_only: - description: - - Specify whether or not to only allow passive connection setup. Valid values - are 'true', 'false', and 'default', which defaults to 'false'. This property - can only be configured when the neighbor is in 'ip' address format without prefix - length. - type: bool - update_source: - description: - - Specify source interface of BGP session and updates. - type: str - state: - description: - - Determines whether the config should be present or not on the device. - default: present - choices: - - present - - absent - type: str - peer_type: - description: - - Specify the peer type for BGP session. - choices: - - fabric_border_leaf - - fabric_external - - disable - type: str - version_added: 1.1.0 -""" -EXAMPLES = """ -# create a new neighbor -- cisco.nxos.nxos_bgp_neighbor: - asn: 65535 - neighbor: 192.0.2.3 - local_as: 20 - remote_as: 30 - bfd: enable - description: just a description - update_source: Ethernet1/3 - state: present - peer_type: fabric_external -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["router bgp 65535", "neighbor 192.0.2.3", - "remote-as 30", "update-source Ethernet1/3", - "description just a description", "local-as 20", "peer-type fabric-external"] -""" - -import re - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, -) - - -BOOL_PARAMS = [ - "capability_negotiation", - "shutdown", - "connected_check", - "dynamic_capability", - "low_memory_exempt", - "suppress_4_byte_as", - "transport_passive_only", -] -PARAM_TO_COMMAND_KEYMAP = { - "asn": "router bgp", - "bfd": "bfd", - "capability_negotiation": "dont-capability-negotiate", - "connected_check": "disable-connected-check", - "description": "description", - "dynamic_capability": "dynamic-capability", - "ebgp_multihop": "ebgp-multihop", - "local_as": "local-as", - "log_neighbor_changes": "log-neighbor-changes", - "low_memory_exempt": "low-memory exempt", - "maximum_peers": "maximum-peers", - "neighbor": "neighbor", - "pwd": "password", - "pwd_type": "password", - "remote_as": "remote-as", - "remove_private_as": "remove-private-as", - "shutdown": "shutdown", - "suppress_4_byte_as": "capability suppress 4-byte-as", - "timers_keepalive": "timers", - "timers_holdtime": "timers", - "transport_passive_only": "transport connection-mode passive", - "update_source": "update-source", - "vrf": "vrf", - "peer_type": "peer-type", -} -PARAM_TO_DEFAULT_KEYMAP = { - "bfd": "disable", - "shutdown": False, - "dynamic_capability": True, - "timers_keepalive": 60, - "timers_holdtime": 180, - "peer_type": "disable", -} - - -def get_value(arg, config): - command = PARAM_TO_COMMAND_KEYMAP[arg] - has_command = re.search(r"^\s+{0}$".format(command), config, re.M) - has_command_val = re.search(r"(?:\s+{0}\s*)(?P.*)$".format(command), config, re.M) - - if arg == "dynamic_capability": - has_no_command = re.search(r"\s+no\s{0}\s*$".format(command), config, re.M) - value = True - if has_no_command: - value = False - elif arg in BOOL_PARAMS: - value = False - if has_command: - value = True - elif arg == "log_neighbor_changes": - value = "" - if has_command: - value = "enable" - elif has_command_val: - value = "disable" - - elif arg == "remove_private_as": - value = "disable" - if has_command: - value = "enable" - elif has_command_val: - value = has_command_val.group("value") - elif arg == "bfd": - value = "enable" if has_command else "disable" - - elif arg == "peer_type": - value = "disable" - if has_command_val: - value = has_command_val.group("value").replace("-", "_") - else: - value = "" - - if has_command_val: - value = has_command_val.group("value") - - if command in ["timers", "password"]: - split_value = value.split() - value = "" - - if arg in ["timers_keepalive", "pwd_type"]: - value = split_value[0] - elif arg in ["timers_holdtime", "pwd"] and len(split_value) == 2: - value = split_value[1] - - return value - - -def get_existing(module, args, warnings): - existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - - asn_regex = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S) - match_asn = asn_regex.match(str(netcfg)) - - if match_asn: - existing_asn = match_asn.group("existing_asn") - parents = ["router bgp {0}".format(existing_asn)] - - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - parents.append("neighbor {0}".format(module.params["neighbor"])) - config = netcfg.get_section(parents) - if config: - for arg in args: - if arg not in ["asn", "vrf", "neighbor"]: - existing[arg] = get_value(arg, config) - - existing["asn"] = existing_asn - existing["neighbor"] = module.params["neighbor"] - existing["vrf"] = module.params["vrf"] - else: - warnings.append("The BGP process didn't exist but the task just created it.") - return existing - - -def apply_key_map(key_map, table): - new_dict = {} - for key in table: - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = table.get(key) - - return new_dict - - -def state_present(module, existing, proposed, candidate): - commands = list() - proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - - for key, value in proposed_commands.items(): - if value is True: - commands.append(key) - elif value is False: - commands.append("no {0}".format(key)) - elif value == "default": - if existing_commands.get(key): - if key == "password": - commands.append("no password") - else: - existing_value = existing_commands.get(key) - commands.append("no {0} {1}".format(key, existing_value)) - else: - if key == "log-neighbor-changes": - if value == "enable": - commands.append("{0}".format(key)) - elif value == "disable": - commands.append("{0} {1}".format(key, value)) - elif value == "inherit": - if existing_commands.get(key): - commands.append("no {0}".format(key)) - elif key == "password": - pwd_type = module.params["pwd_type"] - if pwd_type == "3des": - pwd_type = 3 - else: - pwd_type = 7 - command = "{0} {1} {2}".format(key, pwd_type, value) - if command not in commands: - commands.append(command) - elif key == "remove-private-as": - if value == "enable": - command = "{0}".format(key) - commands.append(command) - elif value == "disable": - if existing_commands.get(key) != "disable": - command = "no {0}".format(key) - commands.append(command) - else: - command = "{0} {1}".format(key, value) - commands.append(command) - elif key == "timers": - if proposed["timers_keepalive"] != PARAM_TO_DEFAULT_KEYMAP.get( - "timers_keepalive", - ) or proposed["timers_holdtime"] != PARAM_TO_DEFAULT_KEYMAP.get("timers_holdtime"): - command = "timers {0} {1}".format( - proposed["timers_keepalive"], - proposed["timers_holdtime"], - ) - if command not in commands: - commands.append(command) - elif key == "bfd": - no_cmd = "no " if value == "disable" else "" - commands.append(no_cmd + key) - elif key == "peer-type": - if value == "disable": - if existing_commands.get(key) != "disable": - command = "no {0}".format(key) - commands.append(command) - elif value == "fabric_external": - ptype = "fabric-external" - command = "{0} {1}".format(key, ptype) - commands.append(command) - elif value == "fabric_border_leaf": - ptype = "fabric-border-leaf" - command = "{0} {1}".format(key, ptype) - commands.append(command) - else: - command = "{0} {1}".format(key, value) - commands.append(command) - - if commands: - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - parents.append("neighbor {0}".format(module.params["neighbor"])) - - # make sure that local-as is the last command in the list. - local_as_command = "local-as {0}".format(module.params["local_as"]) - if local_as_command in commands: - commands.remove(local_as_command) - commands.append(local_as_command) - candidate.add(commands, parents=parents) - - -def state_absent(module, existing, proposed, candidate): - commands = [] - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - commands.append("no neighbor {0}".format(module.params["neighbor"])) - candidate.add(commands, parents=parents) - - -def main(): - argument_spec = dict( - asn=dict(required=True, type="str"), - vrf=dict(required=False, type="str", default="default"), - neighbor=dict(required=True, type="str"), - description=dict(required=False, type="str"), - bfd=dict(required=False, type="str", choices=["enable", "disable"]), - capability_negotiation=dict(required=False, type="bool"), - connected_check=dict(required=False, type="bool"), - dynamic_capability=dict(required=False, type="bool"), - ebgp_multihop=dict(required=False, type="str"), - local_as=dict(required=False, type="str"), - log_neighbor_changes=dict( - required=False, - type="str", - choices=["enable", "disable", "inherit"], - ), - low_memory_exempt=dict(required=False, type="bool"), - maximum_peers=dict(required=False, type="str"), - pwd=dict(required=False, type="str"), - pwd_type=dict( - required=False, - type="str", - choices=["3des", "cisco_type_7", "default"], - ), - remote_as=dict(required=False, type="str"), - remove_private_as=dict( - required=False, - type="str", - choices=["enable", "disable", "all", "replace-as"], - ), - shutdown=dict(required=False, type="bool"), - suppress_4_byte_as=dict(required=False, type="bool"), - timers_keepalive=dict(required=False, type="str"), - timers_holdtime=dict(required=False, type="str"), - transport_passive_only=dict(required=False, type="bool"), - update_source=dict(required=False, type="str"), - state=dict(choices=["present", "absent"], default="present", required=False), - peer_type=dict( - required=False, - type="str", - choices=["disable", "fabric_border_leaf", "fabric_external"], - ), - ) - - module = AnsibleModule( - argument_spec=argument_spec, - required_together=[ - ["timers_holdtime", "timers_keepalive"], - ["pwd", "pwd_type"], - ], - supports_check_mode=True, - ) - - warnings = list() - result = dict(changed=False, warnings=warnings) - - state = module.params["state"] - - if module.params["pwd_type"] == "default": - module.params["pwd_type"] = "0" - - args = PARAM_TO_COMMAND_KEYMAP.keys() - existing = get_existing(module, args, warnings) - - if existing.get("asn") and state == "present": - if existing["asn"] != module.params["asn"]: - module.fail_json( - msg="Another BGP ASN already exists.", - proposed_asn=module.params["asn"], - existing_asn=existing.get("asn"), - ) - - proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) - proposed = {} - for key, value in proposed_args.items(): - if key not in ["asn", "vrf", "neighbor", "pwd_type"]: - if str(value).lower() == "default": - value = PARAM_TO_DEFAULT_KEYMAP.get(key, "default") - if key == "bfd": - if existing.get("bfd", "disable") != value: - proposed[key] = value - elif existing.get(key) != value: - proposed[key] = value - - candidate = CustomNetworkConfig(indent=3) - if state == "present": - state_present(module, existing, proposed, candidate) - elif state == "absent" and existing: - state_absent(module, existing, proposed, candidate) - - if candidate: - candidate = candidate.items_text() - if not module.check_mode: - load_config(module, candidate) - result["changed"] = True - result["commands"] = candidate - else: - result["commands"] = [] - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/nxos_bgp_neighbor_af.py b/plugins/modules/nxos_bgp_neighbor_af.py deleted file mode 100644 index cc5624eef..000000000 --- a/plugins/modules/nxos_bgp_neighbor_af.py +++ /dev/null @@ -1,781 +0,0 @@ -#!/usr/bin/python -# -# 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 . -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: nxos_bgp_neighbor_af -extends_documentation_fragment: -- cisco.nxos.nxos -short_description: (deprecated, removed after 2023-02-24) Manages BGP address-family's neighbors configuration. -description: -- Manages BGP address-family's neighbors configurations on NX-OS switches. -version_added: 1.0.0 -author: Gabriele Gerbino (@GGabriele) -deprecated: - alternative: nxos_bgp_neighbor_address_family - why: Updated module released with more functionality. - removed_at_date: '2023-02-24' -notes: -- Tested against NXOSv 7.3.(0)D1(1) on VIRL -- Unsupported for Cisco MDS -- C(state=absent) removes the whole BGP address-family's neighbor configuration. -- Default, when supported, removes properties -- In order to default maximum-prefix configuration, only C(max_prefix_limit=default) - is needed. -options: - asn: - description: - - BGP autonomous system number. Valid values are String, Integer in ASPLAIN or - ASDOT notation. - required: true - type: str - vrf: - description: - - Name of the VRF. The name 'default' is a valid VRF representing the global bgp. - default: default - type: str - neighbor: - description: - - Neighbor Identifier. Valid values are string. Neighbors may use IPv4 or IPv6 - notation, with or without prefix length. - required: true - type: str - afi: - description: - - Address Family Identifier. - required: true - choices: - - ipv4 - - ipv6 - - vpnv4 - - vpnv6 - - l2vpn - type: str - safi: - description: - - Sub Address Family Identifier. - required: true - choices: - - unicast - - multicast - - evpn - type: str - additional_paths_receive: - description: - - Valid values are enable for basic command enablement; disable for disabling - the command at the neighbor af level (it adds the disable keyword to the basic - command); and inherit to remove the command at this level (the command value - is inherited from a higher BGP layer). - choices: - - enable - - disable - - inherit - type: str - additional_paths_send: - description: - - Valid values are enable for basic command enablement; disable for disabling - the command at the neighbor af level (it adds the disable keyword to the basic - command); and inherit to remove the command at this level (the command value - is inherited from a higher BGP layer). - choices: - - enable - - disable - - inherit - type: str - advertise_map_exist: - description: - - Conditional route advertisement. This property requires two route maps, an advertise-map - and an exist-map. Valid values are an array specifying both the advertise-map - name and the exist-map name, or simply 'default' e.g. ['my_advertise_map', 'my_exist_map']. - This command is mutually exclusive with the advertise_map_non_exist property. - type: list - elements: str - advertise_map_non_exist: - description: - - Conditional route advertisement. This property requires two route maps, an advertise-map - and an exist-map. Valid values are an array specifying both the advertise-map - name and the non-exist-map name, or simply 'default' e.g. ['my_advertise_map', - 'my_non_exist_map']. This command is mutually exclusive with the advertise_map_exist - property. - type: list - elements: str - allowas_in: - description: - - Activate allowas-in property - type: bool - allowas_in_max: - description: - - Max-occurrences value for allowas_in. Valid values are an integer value or 'default'. - This is mutually exclusive with allowas_in. - type: str - as_override: - description: - - Activate the as-override feature. - type: bool - default_originate: - description: - - Activate the default-originate feature. - type: bool - default_originate_route_map: - description: - - Route-map for the default_originate property. Valid values are a string defining - a route-map name, or 'default'. This is mutually exclusive with default_originate. - type: str - disable_peer_as_check: - description: - - Disable checking of peer AS-number while advertising - type: bool - filter_list_in: - description: - - Valid values are a string defining a filter-list name, or 'default'. - type: str - filter_list_out: - description: - - Valid values are a string defining a filter-list name, or 'default'. - type: str - max_prefix_limit: - description: - - maximum-prefix limit value. Valid values are an integer value or 'default'. - type: str - max_prefix_interval: - description: - - Optional restart interval. Valid values are an integer. Requires max_prefix_limit. - May not be combined with max_prefix_warning. - type: str - max_prefix_threshold: - description: - - Optional threshold percentage at which to generate a warning. Valid values are - an integer value. Requires max_prefix_limit. - type: str - max_prefix_warning: - description: - - Optional warning-only keyword. Requires max_prefix_limit. May not be combined - with max_prefix_interval. - type: bool - next_hop_self: - description: - - Activate the next-hop-self feature. - type: bool - next_hop_third_party: - description: - - Activate the next-hop-third-party feature. - type: bool - prefix_list_in: - description: - - Valid values are a string defining a prefix-list name, or 'default'. - type: str - prefix_list_out: - description: - - Valid values are a string defining a prefix-list name, or 'default'. - type: str - route_map_in: - description: - - Valid values are a string defining a route-map name, or 'default'. - type: str - route_map_out: - description: - - Valid values are a string defining a route-map name, or 'default'. - type: str - route_reflector_client: - description: - - Router reflector client. - type: bool - send_community: - description: - - send-community attribute. - choices: - - none - - both - - extended - - standard - - default - type: str - soft_reconfiguration_in: - description: - - Valid values are 'enable' for basic command enablement; 'always' to add the - always keyword to the basic command; and 'inherit' to remove the command at - this level (the command value is inherited from a higher BGP layer). - choices: - - enable - - always - - inherit - type: str - soo: - description: - - Site-of-origin. Valid values are a string defining a VPN extcommunity or 'default'. - type: str - suppress_inactive: - description: - - suppress-inactive feature. - type: bool - unsuppress_map: - description: - - unsuppress-map. Valid values are a string defining a route-map name or 'default'. - type: str - weight: - description: - - Weight value. Valid values are an integer value or 'default'. - type: str - state: - description: - - Determines whether the config should be present or not on the device. - default: present - choices: - - present - - absent - type: str - rewrite_evpn_rt_asn: - description: - - Auto generate route targets for EBGP neighbor. - type: bool - version_added: 1.1.0 -""" -EXAMPLES = """ -- name: configure RR client - cisco.nxos.nxos_bgp_neighbor_af: - asn: 65535 - neighbor: 192.0.2.3 - afi: ipv4 - safi: unicast - route_reflector_client: true - state: present - rewrite_evpn_rt_asn: true -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: ["router bgp 65535", "neighbor 192.0.2.3", - "address-family ipv4 unicast", "route-reflector-client", - "rewrite-evpn-rt-asn"] -""" - -import re - -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - CustomNetworkConfig, -) - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - get_config, - load_config, -) - - -BOOL_PARAMS = [ - "allowas_in", - "as_override", - "default_originate", - "disable_peer_as_check", - "next_hop_self", - "next_hop_third_party", - "route_reflector_client", - "suppress_inactive", - "rewrite_evpn_rt_asn", -] -PARAM_TO_COMMAND_KEYMAP = { - "afi": "address-family", - "asn": "router bgp", - "neighbor": "neighbor", - "additional_paths_receive": "capability additional-paths receive", - "additional_paths_send": "capability additional-paths send", - "advertise_map_exist": "advertise-map exist-map", - "advertise_map_non_exist": "advertise-map non-exist-map", - "allowas_in": "allowas-in", - "allowas_in_max": "allowas-in", - "as_override": "as-override", - "default_originate": "default-originate", - "default_originate_route_map": "default-originate route-map", - "disable_peer_as_check": "disable-peer-as-check", - "filter_list_in": "filter-list in", - "filter_list_out": "filter-list out", - "max_prefix_limit": "maximum-prefix", - "max_prefix_interval": "maximum-prefix interval", - "max_prefix_threshold": "maximum-prefix threshold", - "max_prefix_warning": "maximum-prefix warning", - "next_hop_self": "next-hop-self", - "next_hop_third_party": "next-hop-third-party", - "prefix_list_in": "prefix-list in", - "prefix_list_out": "prefix-list out", - "route_map_in": "route-map in", - "route_map_out": "route-map out", - "route_reflector_client": "route-reflector-client", - "safi": "address-family", - "send_community": "send-community", - "soft_reconfiguration_in": "soft-reconfiguration inbound", - "soo": "soo", - "suppress_inactive": "suppress-inactive", - "unsuppress_map": "unsuppress-map", - "weight": "weight", - "vrf": "vrf", - "rewrite_evpn_rt_asn": "rewrite-evpn-rt-asn", -} - - -def get_value(arg, config, module): - custom = [ - "additional_paths_send", - "additional_paths_receive", - "max_prefix_limit", - "max_prefix_interval", - "max_prefix_threshold", - "max_prefix_warning", - "send_community", - "soft_reconfiguration_in", - ] - command = PARAM_TO_COMMAND_KEYMAP[arg] - has_command = re.search(r"^\s+{0}\s*".format(command), config, re.M) - has_command_val = re.search(r"(?:{0}\s)(?P.*)$".format(command), config, re.M) - value = "" - - if arg in custom: - value = get_custom_value(arg, config, module) - - elif arg == "next_hop_third_party": - has_no_command = re.search(r"^\s+no\s+{0}\s*$".format(command), config, re.M) - value = False - if not has_no_command: - value = True - - elif arg in BOOL_PARAMS: - value = False - if has_command: - value = True - - elif command.startswith("advertise-map"): - value = [] - has_adv_map = re.search( - r"{0}\s(?P.*)\s{1}\s(?P.*)$".format(*command.split()), - config, - re.M, - ) - if has_adv_map: - value = list(has_adv_map.groups()) - - elif command.split()[0] in ["filter-list", "prefix-list", "route-map"]: - has_cmd_direction_val = re.search( - r"{0}\s(?P.*)\s{1}$".format(*command.split()), - config, - re.M, - ) - if has_cmd_direction_val: - value = has_cmd_direction_val.group("value") - - elif has_command_val: - value = has_command_val.group("value") - - return value - - -def get_custom_value(arg, config, module): - command = PARAM_TO_COMMAND_KEYMAP.get(arg) - splitted_config = config.splitlines() - value = "" - - if arg.startswith("additional_paths"): - value = "inherit" - for line in splitted_config: - if command in line: - if "disable" in line: - value = "disable" - else: - value = "enable" - elif arg.startswith("max_prefix"): - for line in splitted_config: - if "maximum-prefix" in line: - splitted_line = line.split() - if arg == "max_prefix_limit": - value = splitted_line[1] - elif arg == "max_prefix_interval" and "restart" in line: - value = splitted_line[-1] - elif arg == "max_prefix_threshold" and len(splitted_line) > 2: - try: - int(splitted_line[2]) - value = splitted_line[2] - except ValueError: - value = "" - elif arg == "max_prefix_warning": - value = "warning-only" in line - elif arg == "soft_reconfiguration_in": - value = "inherit" - for line in splitted_config: - if command in line: - if "always" in line: - value = "always" - else: - value = "enable" - - elif arg == "send_community": - value = "none" - for line in splitted_config: - if command in line: - if "extended" in line: - if value == "standard": - value = "both" - else: - value = "extended" - elif "both" in line: - value = "both" - else: - value = "standard" - - return value - - -def get_existing(module, args, warnings): - existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) - - asn_regex = re.compile(r".*router\sbgp\s(?P\d+(\.\d+)?).*", re.S) - match_asn = asn_regex.match(str(netcfg)) - - if match_asn: - existing_asn = match_asn.group("existing_asn") - parents = ["router bgp {0}".format(existing_asn)] - - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - parents.append("neighbor {0}".format(module.params["neighbor"])) - parents.append("address-family {0} {1}".format(module.params["afi"], module.params["safi"])) - config = netcfg.get_section(parents) - - if config: - for arg in args: - if arg not in ["asn", "vrf", "neighbor", "afi", "safi"]: - existing[arg] = get_value(arg, config, module) - - existing["asn"] = existing_asn - existing["neighbor"] = module.params["neighbor"] - existing["vrf"] = module.params["vrf"] - existing["afi"] = module.params["afi"] - existing["safi"] = module.params["safi"] - else: - warnings.append("The BGP process didn't exist but the task just created it.") - - return existing - - -def apply_key_map(key_map, table): - new_dict = {} - for key in table: - new_key = key_map.get(key) - if new_key: - new_dict[new_key] = table.get(key) - - return new_dict - - -def get_default_command(key, value, existing_commands): - command = "" - if existing_commands.get(key): - existing_value = existing_commands.get(key) - if value == "inherit": - if existing_value != "inherit": - command = "no {0}".format(key) - else: - if key == "advertise-map exist-map": - command = "no advertise-map {0} exist-map {1}".format( - existing_value[0], - existing_value[1], - ) - elif key == "advertise-map non-exist-map": - command = "no advertise-map {0} non-exist-map {1}".format( - existing_value[0], - existing_value[1], - ) - elif key == "filter-list in": - command = "no filter-list {0} in".format(existing_value) - elif key == "filter-list out": - command = "no filter-list {0} out".format(existing_value) - elif key == "prefix-list in": - command = "no prefix-list {0} in".format(existing_value) - elif key == "prefix-list out": - command = "no prefix-list {0} out".format(existing_value) - elif key == "route-map in": - command = "no route-map {0} in".format(existing_value) - elif key == "route-map out": - command = "no route-map {0} out".format(existing_value) - elif key.startswith("maximum-prefix"): - command = "no maximum-prefix" - elif key == "allowas-in max": - command = ["no allowas-in {0}".format(existing_value)] - command.append("allowas-in") - else: - command = "no {0} {1}".format(key, existing_value) - else: - if key.replace(" ", "_").replace("-", "_") in BOOL_PARAMS: - command = "no {0}".format(key) - return command - - -def fix_proposed(module, existing, proposed): - allowas_in = proposed.get("allowas_in") - allowas_in_max = proposed.get("allowas_in_max") - - if allowas_in_max and not allowas_in: - proposed.pop("allowas_in_max") - elif allowas_in and allowas_in_max: - proposed.pop("allowas_in") - - if existing.get("send_community") == "none" and proposed.get("send_community") == "default": - proposed.pop("send_community") - return proposed - - -def state_present(module, existing, proposed, candidate): - commands = list() - proposed = fix_proposed(module, existing, proposed) - - proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) - existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.items(): - if value in ["inherit", "default"]: - command = get_default_command(key, value, existing_commands) - - if isinstance(command, str): - if command and command not in commands: - commands.append(command) - elif isinstance(command, list): - for cmd in command: - if cmd not in commands: - commands.append(cmd) - - elif key.startswith("maximum-prefix"): - if module.params["max_prefix_limit"] != "default": - command = "maximum-prefix {0}".format(module.params["max_prefix_limit"]) - if module.params["max_prefix_threshold"]: - command += " {0}".format(module.params["max_prefix_threshold"]) - if module.params["max_prefix_interval"]: - command += " restart {0}".format(module.params["max_prefix_interval"]) - elif module.params["max_prefix_warning"]: - command += " warning-only" - commands.append(command) - - elif value is True: - commands.append(key) - elif value is False: - commands.append("no {0}".format(key)) - elif key == "address-family": - commands.append( - "address-family {0} {1}".format(module.params["afi"], module.params["safi"]), - ) - elif key.startswith("capability additional-paths"): - command = key - if value == "disable": - command += " disable" - commands.append(command) - elif key.startswith("advertise-map"): - direction = key.split()[1] - commands.append("advertise-map {1} {0} {2}".format(direction, *value)) - elif key.split()[0] in ["filter-list", "prefix-list", "route-map"]: - commands.append("{1} {0} {2}".format(value, *key.split())) - - elif key == "soft-reconfiguration inbound": - command = "" - if value == "enable": - command = key - elif value == "always": - command = "{0} {1}".format(key, value) - commands.append(command) - elif key == "send-community": - command = key - if value in ["standard", "extended"]: - commands.append("no " + key + " both") - command += " {0}".format(value) - commands.append(command) - else: - command = "{0} {1}".format(key, value) - commands.append(command) - - if commands: - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - parents.append("neighbor {0}".format(module.params["neighbor"])) - - af_command = "address-family {0} {1}".format(module.params["afi"], module.params["safi"]) - parents.append(af_command) - if af_command in commands: - commands.remove(af_command) - candidate.add(commands, parents=parents) - - -def state_absent(module, existing, candidate): - commands = [] - parents = ["router bgp {0}".format(module.params["asn"])] - if module.params["vrf"] != "default": - parents.append("vrf {0}".format(module.params["vrf"])) - - parents.append("neighbor {0}".format(module.params["neighbor"])) - commands.append("no address-family {0} {1}".format(module.params["afi"], module.params["safi"])) - candidate.add(commands, parents=parents) - - -def main(): - argument_spec = dict( - asn=dict(required=True, type="str"), - vrf=dict(required=False, type="str", default="default"), - neighbor=dict(required=True, type="str"), - afi=dict( - required=True, - type="str", - choices=["ipv4", "ipv6", "vpnv4", "vpnv6", "l2vpn"], - ), - safi=dict(required=True, type="str", choices=["unicast", "multicast", "evpn"]), - additional_paths_receive=dict( - required=False, - type="str", - choices=["enable", "disable", "inherit"], - ), - additional_paths_send=dict( - required=False, - type="str", - choices=["enable", "disable", "inherit"], - ), - advertise_map_exist=dict(required=False, type="list", elements="str"), - advertise_map_non_exist=dict(required=False, type="list", elements="str"), - allowas_in=dict(required=False, type="bool"), - allowas_in_max=dict(required=False, type="str"), - as_override=dict(required=False, type="bool"), - default_originate=dict(required=False, type="bool"), - default_originate_route_map=dict(required=False, type="str"), - disable_peer_as_check=dict(required=False, type="bool"), - filter_list_in=dict(required=False, type="str"), - filter_list_out=dict(required=False, type="str"), - max_prefix_limit=dict(required=False, type="str"), - max_prefix_interval=dict(required=False, type="str"), - max_prefix_threshold=dict(required=False, type="str"), - max_prefix_warning=dict(required=False, type="bool"), - next_hop_self=dict(required=False, type="bool"), - next_hop_third_party=dict(required=False, type="bool"), - prefix_list_in=dict(required=False, type="str"), - prefix_list_out=dict(required=False, type="str"), - route_map_in=dict(required=False, type="str"), - route_map_out=dict(required=False, type="str"), - route_reflector_client=dict(required=False, type="bool"), - send_community=dict( - required=False, - choices=["none", "both", "extended", "standard", "default"], - ), - soft_reconfiguration_in=dict( - required=False, - type="str", - choices=["enable", "always", "inherit"], - ), - soo=dict(required=False, type="str"), - suppress_inactive=dict(required=False, type="bool"), - unsuppress_map=dict(required=False, type="str"), - weight=dict(required=False, type="str"), - state=dict(choices=["present", "absent"], default="present", required=False), - rewrite_evpn_rt_asn=dict(required=False, type="bool"), - ) - - module = AnsibleModule( - argument_spec=argument_spec, - mutually_exclusive=[ - ["advertise_map_exist", "advertise_map_non_exist"], - ["max_prefix_interval", "max_prefix_warning"], - ["default_originate", "default_originate_route_map"], - ["allowas_in", "allowas_in_max"], - ], - supports_check_mode=True, - ) - - warnings = list() - result = dict(changed=False, warnings=warnings) - - state = module.params["state"] - for key in [ - "max_prefix_interval", - "max_prefix_warning", - "max_prefix_threshold", - ]: - if module.params[key] and not module.params["max_prefix_limit"]: - module.fail_json(msg="max_prefix_limit is required when using %s" % key) - if module.params["vrf"] == "default" and module.params["soo"]: - module.fail_json(msg="SOO is only allowed in non-default VRF") - - args = PARAM_TO_COMMAND_KEYMAP.keys() - existing = get_existing(module, args, warnings) - - if existing.get("asn") and state == "present": - if existing.get("asn") != module.params["asn"]: - module.fail_json( - msg="Another BGP ASN already exists.", - proposed_asn=module.params["asn"], - existing_asn=existing.get("asn"), - ) - - for param in ["advertise_map_exist", "advertise_map_non_exist"]: - if module.params[param] == ["default"]: - module.params[param] = "default" - - proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) - - proposed = {} - for key, value in proposed_args.items(): - if key not in ["asn", "vrf", "neighbor"]: - if not isinstance(value, list): - if str(value).lower() == "true": - value = True - elif str(value).lower() == "false": - value = False - elif str(value).lower() == "default": - if key in BOOL_PARAMS: - value = False - else: - value = "default" - elif key == "send_community" and str(value).lower() == "none": - value = "default" - if existing.get(key) != value: - proposed[key] = value - - candidate = CustomNetworkConfig(indent=3) - if state == "present": - state_present(module, existing, proposed, candidate) - elif state == "absent" and existing: - state_absent(module, existing, candidate) - - if candidate: - candidate = candidate.items_text() - if not module.check_mode: - responses = load_config(module, candidate) - if responses: - for resp in responses: - if resp: - if resp.endswith("is valid only for EBGP peers"): - module.fail_json(msg=resp) - result["changed"] = True - result["commands"] = candidate - else: - result["commands"] = [] - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/tests/integration/targets/nxos_bgp/defaults/main.yaml b/tests/integration/targets/nxos_bgp/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/tests/integration/targets/nxos_bgp/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/tests/integration/targets/nxos_bgp/meta/main.yml b/tests/integration/targets/nxos_bgp/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_bgp/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_bgp/tasks/cli.yaml b/tests/integration/targets/nxos_bgp/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/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/tests/integration/targets/nxos_bgp/tasks/main.yaml b/tests/integration/targets/nxos_bgp/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/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/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/tests/integration/targets/nxos_bgp/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/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml b/tests/integration/targets/nxos_bgp/tests/common/dis_policy.yaml deleted file mode 100644 index 0f4bd883e..000000000 --- a/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/tests/integration/targets/nxos_bgp/tests/common/hels.yaml b/tests/integration/targets/nxos_bgp/tests/common/hels.yaml deleted file mode 100644 index 65b7c7251..000000000 --- a/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/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml b/tests/integration/targets/nxos_bgp/tests/common/isolate.yaml deleted file mode 100644 index de4bafb11..000000000 --- a/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/tests/integration/targets/nxos_bgp/tests/common/param.yaml b/tests/integration/targets/nxos_bgp/tests/common/param.yaml deleted file mode 100644 index a4d7c2ffa..000000000 --- a/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/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp/tests/common/sanity.yaml deleted file mode 100644 index dc2b018cc..000000000 --- a/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/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml b/tests/integration/targets/nxos_bgp/tests/common/supp_fib.yaml deleted file mode 100644 index ead5a515e..000000000 --- a/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/tests/integration/targets/nxos_bgp_af/defaults/main.yaml b/tests/integration/targets/nxos_bgp_af/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/tests/integration/targets/nxos_bgp_af/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/tests/integration/targets/nxos_bgp_af/meta/main.yml b/tests/integration/targets/nxos_bgp_af/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_bgp_af/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_af/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/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/tests/integration/targets/nxos_bgp_af/tasks/main.yaml b/tests/integration/targets/nxos_bgp_af/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/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/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_af/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/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/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml b/tests/integration/targets/nxos_bgp_af/tests/common/multisite.yaml deleted file mode 100644 index 93eb7654c..000000000 --- a/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/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_af/tests/common/sanity.yaml deleted file mode 100644 index fa06c19f9..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml b/tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml deleted file mode 100644 index 525b7aab9..000000000 --- a/tests/integration/targets/nxos_bgp_neighbor/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: "*" -vrfs: - - default - - myvrf diff --git a/tests/integration/targets/nxos_bgp_neighbor/meta/main.yml b/tests/integration/targets/nxos_bgp_neighbor/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_bgp_neighbor/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/tests/integration/targets/nxos_bgp_neighbor/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/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml b/tests/integration/targets/nxos_bgp_neighbor/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml b/tests/integration/targets/nxos_bgp_neighbor/tests/common/multisite.yaml deleted file mode 100644 index f567a6e04..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_neighbor/tests/common/sanity.yaml deleted file mode 100644 index c2fff45a0..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_bgp_neighbor_af/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml b/tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_bgp_neighbor_af/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/cli.yaml deleted file mode 100644 index f6096901f..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tasks/nxapi.yaml deleted file mode 100644 index b4ed55204..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/multisite.yaml deleted file mode 100644 index 12c31f7a2..000000000 --- a/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/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml b/tests/integration/targets/nxos_bgp_neighbor_af/tests/common/sanity.yaml deleted file mode 100644 index 3b680ad59..000000000 --- a/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/tests/integration/targets/nxos_command/tests/cli/sanity.yaml b/tests/integration/targets/nxos_command/tests/cli/sanity.yaml index 74c777bd5..bb8a3db43 100644 --- a/tests/integration/targets/nxos_command/tests/cli/sanity.yaml +++ b/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/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index 245bf89fc..ada896a7b 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/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/tests/unit/modules/network/nxos/test_nxos_bgp.py b/tests/unit/modules/network/nxos/test_nxos_bgp.py deleted file mode 100644 index 9c57817ca..000000000 --- a/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 . - -# 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/tests/unit/modules/network/nxos/test_nxos_bgp_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_af.py deleted file mode 100644 index a72095c8f..000000000 --- a/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 . - -# 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/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor.py deleted file mode 100644 index 677e6f7dd..000000000 --- a/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 . - -# 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/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_af.py deleted file mode 100644 index 8b918d0e8..000000000 --- a/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 . - -# 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=[]) From 55fd847fd19e36828a5a2f0d281b6899b9632d00 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 28 Jun 2023 13:22:37 +0530 Subject: [PATCH 103/166] Add support for state overridden where it is missing (#701) Signed-off-by: NilashishC --- changelogs/fragments/overridden.yaml | 3 + docs/cisco.nxos.nxos_bgp_global_module.rst | 4 +- docs/cisco.nxos.nxos_lacp_module.rst | 2 + docs/cisco.nxos.nxos_lldp_global_module.rst | 4 +- .../nxos/argspec/bgp_global/bgp_global.py | 1 + .../network/nxos/argspec/lacp/lacp.py | 1 + .../nxos/argspec/lldp_global/lldp_global.py | 1 + .../network/nxos/config/lacp/lacp.py | 2 +- .../nxos/config/lldp_global/lldp_global.py | 2 +- plugins/modules/nxos_bgp_global.py | 6 +- plugins/modules/nxos_lacp.py | 2 + plugins/modules/nxos_lldp_global.py | 4 +- .../nxos_lacp/tests/common/overridden.yaml | 104 ++++++++++++++++++ .../tests/common/overridden.yml | 92 ++++++++++++++++ .../network/nxos/test_nxos_bgp_global.py | 87 +++++++++++++++ 15 files changed, 308 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/overridden.yaml create mode 100644 tests/integration/targets/nxos_lacp/tests/common/overridden.yaml create mode 100644 tests/integration/targets/nxos_lldp_global/tests/common/overridden.yml diff --git a/changelogs/fragments/overridden.yaml b/changelogs/fragments/overridden.yaml new file mode 100644 index 000000000..3aedb1933 --- /dev/null +++ b/changelogs/fragments/overridden.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Add support for overridden wherever valid and is missing. diff --git a/docs/cisco.nxos.nxos_bgp_global_module.rst b/docs/cisco.nxos.nxos_bgp_global_module.rst index a658b46ad..519faf025 100644 --- a/docs/cisco.nxos.nxos_bgp_global_module.rst +++ b/docs/cisco.nxos.nxos_bgp_global_module.rst @@ -4544,6 +4544,7 @@ Parameters
    Choices:
  • merged ←
  • replaced
  • +
  • overridden
  • deleted
  • purged
  • parsed
  • @@ -4556,7 +4557,8 @@ Parameters
    State purged removes all the BGP configurations from the target device. Use caution with this state.
    State deleted only removes BGP attributes that this modules manages and does not negate the BGP process completely. Thereby, preserving address-family related configurations under BGP context.
    Running states deleted and replaced will result in an error if there are address-family configuration lines present under a neighbor, or a vrf context that is to be removed. Please use the cisco.nxos.nxos_bgp_af or cisco.nxos.nxos_bgp_neighbor_af modules for prior cleanup.
    -
    States merged and replaced will result in a failure if BGP is already configured with a different ASN than what is provided in the task. In such cases, please use state purged to remove the existing BGP process and proceed further.
    +
    States merged and replaced will result in a failure if BGP is already configured with a different ASN than what is provided in the task. In such cases, please use state purged to remove the existing BGP process and proceed further.
    +
    States replaced and overridden have the same behaviour for this module.
    Refer to examples for more details.
The state of the configuration after module completion.
+
States replaced and overridden have the same behaviour for this module.
diff --git a/docs/cisco.nxos.nxos_lldp_global_module.rst b/docs/cisco.nxos.nxos_lldp_global_module.rst index 0f012f985..57252cfe0 100644 --- a/docs/cisco.nxos.nxos_lldp_global_module.rst +++ b/docs/cisco.nxos.nxos_lldp_global_module.rst @@ -414,6 +414,7 @@ Parameters
    Choices:
  • merged ←
  • replaced
  • +
  • overridden
  • deleted
  • gathered
  • rendered
  • @@ -421,7 +422,8 @@ Parameters
-
The state of the configuration after module completion
+
The state of the configuration after module completion.
+
States replaced and overridden have the same behaviour for this module.
diff --git a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py index d47f7e429..bfe4e5d66 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py @@ -538,6 +538,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "choices": [ "merged", "replaced", + "overridden", "deleted", "purged", "parsed", diff --git a/plugins/module_utils/network/nxos/argspec/lacp/lacp.py b/plugins/module_utils/network/nxos/argspec/lacp/lacp.py index 3c2ac06a3..6eddf5893 100644 --- a/plugins/module_utils/network/nxos/argspec/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/argspec/lacp/lacp.py @@ -60,6 +60,7 @@ class LacpArgs(object): "choices": [ "merged", "replaced", + "overridden", "deleted", "gathered", "rendered", diff --git a/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py b/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py index 8fad5eba7..abcbc08fa 100644 --- a/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/nxos/argspec/lldp_global/lldp_global.py @@ -77,6 +77,7 @@ class Lldp_globalArgs(object): # pylint: disable=R0903 "choices": [ "merged", "replaced", + "overridden", "deleted", "gathered", "parsed", diff --git a/plugins/module_utils/network/nxos/config/lacp/lacp.py b/plugins/module_utils/network/nxos/config/lacp/lacp.py index 4d334badb..526d70b85 100644 --- a/plugins/module_utils/network/nxos/config/lacp/lacp.py +++ b/plugins/module_utils/network/nxos/config/lacp/lacp.py @@ -141,7 +141,7 @@ def set_state(self, want, have): commands.extend(self._state_deleted(want, have)) elif state in ["merged", "rendered"]: commands.extend(self._state_merged(want, have)) - elif state == "replaced": + elif state in ["replaced", "overridden"]: commands.extend(self._state_replaced(want, have)) return commands diff --git a/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py b/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py index 68d986212..85f39682c 100644 --- a/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/nxos/config/lldp_global/lldp_global.py @@ -138,7 +138,7 @@ def set_state(self, want, have): commands = self._state_deleted(have) elif state in ["merged", "rendered"]: commands = self._state_merged(want, have) - elif state == "replaced": + elif state in ["replaced", "overridden"]: commands = self._state_replaced(want, have) return commands diff --git a/plugins/modules/nxos_bgp_global.py b/plugins/modules/nxos_bgp_global.py index b3072d66e..15dcb5d16 100644 --- a/plugins/modules/nxos_bgp_global.py +++ b/plugins/modules/nxos_bgp_global.py @@ -508,14 +508,16 @@ or a vrf context that is to be removed. Please use the M(cisco.nxos.nxos_bgp_af) or M(cisco.nxos.nxos_bgp_neighbor_af) modules for prior cleanup. - - States I(merged) and I(replaced) will result in a failure if BGP is already configured + - States C(merged) and C(replaced) will result in a failure if BGP is already configured with a different ASN than what is provided in the task. In such cases, please use - state I(purged) to remove the existing BGP process and proceed further. + state C(purged) to remove the existing BGP process and proceed further. + - States C(replaced) and C(overridden) have the same behaviour for this module. - Refer to examples for more details. type: str choices: - merged - replaced + - overridden - deleted - purged - parsed diff --git a/plugins/modules/nxos_lacp.py b/plugins/modules/nxos_lacp.py index 233491138..257c1384e 100644 --- a/plugins/modules/nxos_lacp.py +++ b/plugins/modules/nxos_lacp.py @@ -85,10 +85,12 @@ state: description: - The state of the configuration after module completion. + - States C(replaced) and C(overridden) have the same behaviour for this module. type: str choices: - merged - replaced + - overridden - deleted - gathered - rendered diff --git a/plugins/modules/nxos_lldp_global.py b/plugins/modules/nxos_lldp_global.py index d238213bc..56b7a04eb 100644 --- a/plugins/modules/nxos_lldp_global.py +++ b/plugins/modules/nxos_lldp_global.py @@ -134,11 +134,13 @@ type: bool state: description: - - The state of the configuration after module completion + - The state of the configuration after module completion. + - States C(replaced) and C(overridden) have the same behaviour for this module. type: str choices: - merged - replaced + - overridden - deleted - gathered - rendered diff --git a/tests/integration/targets/nxos_lacp/tests/common/overridden.yaml b/tests/integration/targets/nxos_lacp/tests/common/overridden.yaml new file mode 100644 index 000000000..d6eb4fb93 --- /dev/null +++ b/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/tests/integration/targets/nxos_lldp_global/tests/common/overridden.yml b/tests/integration/targets/nxos_lldp_global/tests/common/overridden.yml new file mode 100644 index 000000000..58c41c1f8 --- /dev/null +++ b/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/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index c2b2d5db2..9f2377fb6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -465,6 +465,93 @@ def test_nxos_bgp_global_replaced(self): 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( """\ From deec47a9a57b9252dea688b26c0134585d4663d2 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Wed, 28 Jun 2023 15:41:20 +0530 Subject: [PATCH 104/166] [static routes] Make deleted state alike other platforms, implemented as templates based resource module (#672) * hold changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * parsers and facts * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * revert debugpy * facts processing with issues * facts good * config base code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * hold debug code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * config code fixed * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * UTs fixed * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update integration tests * doc and changelog updated * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix lint * fix tests * integration test fixes * added back overridden * Update tests/integration/targets/nxos_static_routes/tests/common/parsed.yml * Update plugins/modules/nxos_static_routes.py Co-authored-by: Nilashish Chakraborty * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update plugins/modules/nxos_static_routes.py Co-authored-by: Nilashish Chakraborty * Update plugins/modules/nxos_static_routes.py Co-authored-by: Nilashish Chakraborty * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * cleanup as review * add comment * Update changelogs/fragments/update_static_routes.yml * Update changelogs/fragments/update_static_routes.yml * push fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update pre test variable --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ashwini Mhatre Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/update_static_routes.yml | 5 + docs/cisco.nxos.nxos_static_routes_module.rst | 155 +- .../argspec/static_routes/static_routes.py | 53 +- .../config/static_routes/static_routes.py | 695 +++------ .../nxos/facts/static_routes/static_routes.py | 279 ++-- .../nxos/rm_templates/static_routes.py | 126 ++ plugins/modules/nxos_static_routes.py | 175 ++- .../nxos_static_routes/tasks/main.yaml | 15 + .../tests/common/deleted.yml | 31 - .../tests/common/merged.yml | 6 +- .../tests/common/overridden.yml | 6 +- .../tests/common/parsed.yml | 12 +- .../tests/common/rendered.yml | 5 +- .../tests/common/replaced.yml | 2 - .../nxos_static_routes/tests/common/rtt.yml | 6 +- .../targets/nxos_static_routes/vars/main.yml | 46 +- .../network/nxos/test_nxos_static_routes.py | 1288 +++++++++++++---- 17 files changed, 1718 insertions(+), 1187 deletions(-) create mode 100644 changelogs/fragments/update_static_routes.yml create mode 100644 plugins/module_utils/network/nxos/rm_templates/static_routes.py diff --git a/changelogs/fragments/update_static_routes.yml b/changelogs/fragments/update_static_routes.yml new file mode 100644 index 000000000..6c8cf8aa9 --- /dev/null +++ b/changelogs/fragments/update_static_routes.yml @@ -0,0 +1,5 @@ +--- +bugfixes: + - nxos_static_routes - Update the delete operation of static routes to be similar to other platforms. + (https://github.com/ansible-collections/cisco.nxos/issues/666) + - nxos_static_routes - Prevent action states to generate terminal configuration command. diff --git a/docs/cisco.nxos.nxos_static_routes_module.rst b/docs/cisco.nxos.nxos_static_routes_module.rst index 4c5be4a96..264515ecf 100644 --- a/docs/cisco.nxos.nxos_static_routes_module.rst +++ b/docs/cisco.nxos.nxos_static_routes_module.rst @@ -348,7 +348,7 @@ Notes ----- .. note:: - - Tested against NX-OS 7.3.(0)D1(1) on VIRL + - Tested against Nexus 9300v running NX-OS 9.3.6 on CML. - Unsupported for Cisco MDS - When a route is configured for a non-existent VRF, the VRF is created and the route is added to it. - When deleting routes for a VRF, all routes inside the VRF are deleted, but the VRF is not deleted. @@ -360,13 +360,15 @@ Examples .. code-block:: yaml - # Using deleted: + # Using deleted - delete all # Before state: # ------------- # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.32/28 192.0.2.12 name new_route # ip route 192.0.2.26/24 192.0.2.13 tag 12 + # switch# show running-config | section '^vrf context' - name: Delete all routes cisco.nxos.nxos_static_routes: @@ -374,6 +376,7 @@ Examples # Task Output # ----------- + # # before: # - address_families: # - afi: ipv4 @@ -387,20 +390,24 @@ Examples # - forward_router_address: 192.0.2.12 # route_name: new_route # commands: - # - configure terminal # - no ip route 192.0.2.0/24 192.0.2.13 tag 12 # - no ip route 192.0.2.32/28 192.0.2.12 name new_route # after: [] + # After state: # ------------ - # + # switch# show running-config | include '^ip(v6)* route' + # switch# show running-config | section '^vrf context' + # Using deleted - vrf based # Before state: # ------------ # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 + # switch# show running-config | section '^vrf context' # 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 @@ -414,6 +421,7 @@ Examples # Task Output # ----------- + # # before: # - address_families: # - afi: ipv4 @@ -464,16 +472,22 @@ Examples # After state: # ----------- + # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 + # switch# show running-config | section '^vrf context' # vrf context trial_vrf + # Using deleted - afi based # Before state: # ------------ # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 + # switch# show running-config | section '^vrf context' # 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 @@ -489,6 +503,7 @@ Examples # Task Output # ----------- + # # before: # - address_families: # - afi: ipv4 @@ -547,8 +562,11 @@ Examples # After state: # ----------- + # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 + # switch# show running-config | section '^vrf context' # vrf context trial_vrf # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 @@ -556,7 +574,8 @@ Examples # Before state: # ------------- - # + # switch# show running-config | include '^ip(v6)* route' + # switch# show running-config | section '^vrf context' - name: Merge new static route configuration cisco.nxos.nxos_static_routes: @@ -570,7 +589,6 @@ Examples - forward_router_address: 192.0.2.22 tag: 4 admin_distance: 2 - - address_families: - afi: ipv4 routes: @@ -588,11 +606,11 @@ Examples # Task Output # ----------- + # # before:[] # commands: # - vrf context trial_vrf # - ip route 192.0.2.64/24 192.0.2.22 tag 4 2 - # - configure terminal # - ip route 192.0.2.16/24 192.0.2.24 name new_route # - ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 # after: @@ -605,7 +623,6 @@ Examples # - forward_router_address: 192.0.2.22 # tag: 4 # admin_distance: 2 - # # - address_families: # - afi: ipv4 # routes: @@ -623,24 +640,27 @@ Examples # After state: # ------------ # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/24 192.0.2.24 name new_route # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 + # switch# show running-config | section '^vrf context' # vrf context trial_vrf # ip route 192.0.2.0/24 192.0.2.22 tag 4 2 - - # Using overridden: + # Using overridden # Before state: # ------------- # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 + # switch# show running-config | section '^vrf context' # 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 - - name: Overriden existing static route configuration with new configuration + - name: Overridden existing static route configuration with new configuration cisco.nxos.nxos_static_routes: config: - vrf: trial_vrf @@ -652,7 +672,6 @@ Examples - 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 @@ -661,6 +680,7 @@ Examples # Task Output # ----------- + # # before: # - address_families: # - afi: ipv4 @@ -685,7 +705,6 @@ Examples # - forward_router_address: 192.0.2.26 # tag: 12 # commands: - # - configure terminal # - no ip route 192.0.2.16/28 192.0.2.24 name new_route # - no ip route 192.0.2.80/28 192.0.2.26 tag 12 # - vrf context trial_vrf @@ -711,17 +730,21 @@ Examples # After state: # ------------ # + # switch# show running-config | include '^ip(v6)* route' + # switch# show running-config | section '^vrf context' # vrf context trial_vrf # ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2 - - # Using replaced: + # Using replaced # Before state: # ------------ + # + # switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 + # switch# show running-config | section '^vrf context' # 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 @@ -737,7 +760,6 @@ Examples - 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 @@ -746,6 +768,7 @@ Examples # Task Output # ----------- + # # before: # - address_families: # - afi: ipv4 @@ -770,7 +793,6 @@ Examples # - forward_router_address: 192.0.2.26 # tag: 12 # commands: - # - configure terminal # - no ip route 192.0.2.16/28 192.0.2.24 name new_route # - 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 @@ -804,29 +826,37 @@ Examples # tag: 12 # After state: - # ----------- + # ------------ + # + # switch# show running-config | include '^ip(v6)* route' # 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 + # switch# show running-config | section '^vrf context' # 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 - # Using gathered: + # Using gathered # Before state: # ------------- + # + # switch# show running-config | include '^ip(v6)* route' # ipv6 route 2001:db8:12::/32 2001:db8::12 + # switch# show running-config | section '^vrf context' # 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 - - name: Gather the exisitng condiguration + - name: Gather the existing configuration cisco.nxos.nxos_static_routes: state: gathered - # returns: + # Task Output + # ----------- + # # gathered: # - vrf: Test # address_families: @@ -847,7 +877,7 @@ Examples # - forward_router_address: 2001:db8::12 - # Using rendered: + # Using rendered - name: Render required configuration to be pushed to the device cisco.nxos.nxos_static_routes: @@ -858,7 +888,6 @@ Examples - dest: 192.0.2.48/28 next_hops: - forward_router_address: 192.0.2.13 - - afi: ipv6 routes: - dest: 2001:db8::/64 @@ -867,24 +896,28 @@ Examples forward_router_address: 2001:db8::12 state: rendered - # returns + # Task Output + # ----------- + # # rendered: # vrf context default # ip route 192.0.2.48/28 192.0.2.13 # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 - # Using parsed - name: Parse the config to structured data cisco.nxos.nxos_static_routes: + state: parsed running_config: | ipv6 route 2002:db8:12::/32 2002:db8:12::1 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 - # returns: + # Task Output + # ----------- + # # parsed: # - vrf: Test # address_families: @@ -893,10 +926,8 @@ Examples # - dest: 192.0.2.48/28 # next_hops: # - forward_router_address: 192.0.2.13 - # # - forward_router_address: 192.0.2.14 # admin_distance: 5 - # # - address_families: # - afi: ipv6 # routes: @@ -929,11 +960,10 @@ Common return values are documented `here
when changed -
The resulting configuration model invocation.
+
The resulting configuration after module execution.

Sample:
-
The configuration returned will always be in the same format - of the parameters above.
+
This output will always be in the same format as the module argspec.
alwayswhen state is merged, replaced, overridden, deleted or purged -
The configuration prior to the model invocation.
+
The configuration prior to the module execution.

Sample:
-
The configuration returned will always be in the same format - of the parameters above.
+
This output will always be in the same format as the module argspec.
alwayswhen state is merged, replaced, overridden, deleted or purged
The set of commands pushed to the remote device.

Sample:
-
['ip route 192.0.2.48/28 192.0.2.12 Ethernet1/2 name sample_route', 'ipv6 route 2001:db8:3000::/36 2001:db8:200:2::2', 'vrf context test', 'ip route 192.0.2.48/28 192.0.2.121']
+
['ip route 192.0.2.16/28 192.0.2.24 name new_route', 'vrf context trial_vrf', 'ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3']
+
+
+ gathered + +
+ list +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ list +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['ip route 192.0.2.16/28 192.0.2.24 name new_route', 'vrf context trial_vrf', 'ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3']
@@ -983,3 +1063,4 @@ Authors ~~~~~~~ - Adharsh Srivats Rangarajan (@adharshsrivatsr) +- Sagar Paul (@KB-perByte) diff --git a/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py b/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py index 58a669bd5..25b78da1b 100644 --- a/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/argspec/static_routes/static_routes.py @@ -1,79 +1,79 @@ -# # -*- coding: utf-8 -*- -# Copyright 2019 Red Hat +# Copyright 2023 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + ############################################# # WARNING # ############################################# # -# This file is auto generated by the resource -# module builder playbook. -# -# Do not edit this file manually. +# This file is auto generated by the +# ansible.content_builder. # -# Changes to this file will be over written -# by the resource module builder. +# Manually editing this file is not advised. # -# Changes should be made in the model used to -# generate this file or in the resource module -# builder template. +# To update the argspec make the desired changes +# in the documentation in the module file and re-run +# ansible.content_builder commenting out +# the path to external 'docstring' in build.yaml. # -############################################# +############################################## + """ The arg spec for the nxos_static_routes module """ -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type class Static_routesArgs(object): # pylint: disable=R0903 """The arg spec for the nxos_static_routes module""" argument_spec = { + "running_config": {"type": "str"}, "config": { + "type": "list", "elements": "dict", "options": { + "vrf": {"type": "str"}, "address_families": { + "type": "list", "elements": "dict", "options": { "afi": { + "type": "str", "choices": ["ipv4", "ipv6"], "required": True, - "type": "str", }, "routes": { "elements": "dict", + "type": "list", "options": { - "dest": {"required": True, "type": "str"}, + "dest": {"type": "str", "required": True}, "next_hops": { + "type": "list", "elements": "dict", "options": { - "admin_distance": {"type": "int"}, - "dest_vrf": {"type": "str"}, "forward_router_address": {"type": "str"}, "interface": {"type": "str"}, + "admin_distance": {"type": "int"}, "route_name": {"type": "str"}, "tag": {"type": "int"}, "track": {"type": "int"}, + "dest_vrf": {"type": "str"}, }, - "type": "list", }, }, - "type": "list", }, }, - "type": "list", }, - "vrf": {"type": "str"}, }, - "type": "list", }, - "running_config": {"type": "str"}, "state": { + "type": "str", "choices": [ "deleted", "merged", @@ -84,6 +84,5 @@ class Static_routesArgs(object): # pylint: disable=R0903 "parsed", ], "default": "merged", - "type": "str", }, } # pylint: disable=C0301 diff --git a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py index 721ff82c1..3b554cea5 100644 --- a/plugins/module_utils/network/nxos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/config/static_routes/static_routes.py @@ -1,71 +1,50 @@ # # -*- coding: utf-8 -*- -# Copyright 2019 Red Hat +# Copyright 2023 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -""" -The nxos_static_routes class -It is in this file where the current configuration (as dict) -is compared to the provided configuration (as dict) and the command set -necessary to bring the current configuration to it's desired end-state is -created -""" +# + from __future__ import absolute_import, division, print_function __metaclass__ = type -from copy import deepcopy +""" +The nxos_static_routes config file. +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to its desired end-state is +created. +""" -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( - ConfigBase, + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( + ResourceModule, ) from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_empties, - to_list, + dict_merge, ) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( - normalize_interface, - search_obj_in_list, +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.static_routes import ( + Static_routesTemplate, ) -class Static_routes(ConfigBase): +class Static_routes(ResourceModule): """ - The nxos_xstatic_routes class + The nxos_static_routes config class """ - gather_subset = ["!all", "!min"] - - gather_network_resources = ["static_routes"] - def __init__(self, module): - super(Static_routes, self).__init__(module) - - def get_static_routes_facts(self, data=None): - """Get the 'facts' (the current configuration) - - :rtype: A dictionary - :returns: The current configuration as a dictionary - """ - facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, - self.gather_network_resources, - data=data, + super(Static_routes, self).__init__( + empty_fact_val={}, + facts_module=Facts(module), + module=module, + resource="static_routes", + tmplt=Static_routesTemplate(), ) - static_routes_facts = facts["ansible_network_resources"].get("static_routes") - if not static_routes_facts: - return [] - - return static_routes_facts - - def edit_config(self, commands): - """Wrapper method for `_connection.edit_config()` - This exists solely to allow the unit test framework to mock device connection calls. - """ - return self._connection.edit_config(commands) def execute_module(self): """Execute the module @@ -73,495 +52,145 @@ def execute_module(self): :rtype: A dictionary :returns: The result from module execution """ - result = {"changed": False} - warnings = list() - commands = list() - state = self._module.params["state"] - action_states = ["merged", "replaced", "deleted", "overridden"] - - if state == "gathered": - result["gathered"] = self.get_static_routes_facts() - elif state == "rendered": - result["rendered"] = self.set_config({}) - # no need to fetch facts for rendered - elif state == "parsed": - result["parsed"] = self.set_config({}) - # no need to fetch facts for parsed - else: - existing_static_routes_facts = self.get_static_routes_facts() - commands.extend(self.set_config(existing_static_routes_facts)) - if commands and state in action_states: - if not self._module.check_mode: - self._connection.edit_config(commands) - result["changed"] = True - result["before"] = existing_static_routes_facts - result["commands"] = commands - - changed_static_routes_facts = self.get_static_routes_facts() - if result["changed"]: - result["after"] = changed_static_routes_facts - result["warnings"] = warnings - return result - - def set_config(self, existing_static_routes_facts): - """Collect the configuration from the args passed to the module, - collect the current configuration (as a dict from facts) - - :rtype: A list - :returns: the commands necessary to migrate the current configuration - to the desired configuration - """ - config = self._module.params["config"] - want = [] - if config: - for w in config: - want.append(remove_empties(w)) - have = existing_static_routes_facts - want = self.add_default_vrf(deepcopy(want)) - have = self.add_default_vrf(deepcopy(have)) - resp = self.set_state(want, have) - return to_list(resp) - - def set_state(self, want, have): - """Select the appropriate function based on the state provided - - :param want: the desired configuration as a dictionary - :param have: the current configuration as a dictionary - :rtype: A list - :returns: the commands necessary to migrate the current configuration - to the desired configuration - """ - state = self._module.params["state"] - commands = [] - if state == "overridden": - commands = self._state_overridden(want, have) - elif state == "deleted": - commands = self._state_deleted(want, have) - elif state == "rendered": - commands = self._state_rendered(want, have=[]) - elif state == "parsed": - want = self._module.params["running_config"] - commands = self._state_parsed(want) - else: - for w in want: - if state == "merged": - commands.extend(self._state_merged(w, have)) - elif state == "replaced": - commands.extend(self._state_replaced(w, have)) - return commands - - def _state_parsed(self, want): - return self.get_static_routes_facts(want) - - def _state_rendered(self, want, have): - commands = [] - for w in want: - commands.extend(self.set_commands(w, {})) - return commands - - def _state_replaced(self, want, have): - """The command generator when state is replaced - - :rtype: A list - :returns: the commands necessary to migrate the current configuration - to the desired configuration - """ - commands = [] - delete_commands = [] - state = self._module.params["state"] - merged_commands = [] - obj_in_have = search_obj_in_list(want["vrf"], have, "vrf") - # in replaced, we check if whatever in have is in want, unlike merged. This is because we need to apply deleted on have config - if obj_in_have and obj_in_have != {"vrf": "default"}: - want_afi_list = [] - if "address_families" in want.keys(): - want_afi_list = [w["afi"] for w in want["address_families"]] - if len(want_afi_list) > 0: - for h in obj_in_have["address_families"]: - if h["afi"] in want_afi_list: - want_afi = search_obj_in_list(h["afi"], want["address_families"], "afi") - want_dest_list = [] - if "routes" in want_afi.keys(): - want_dest_list = [w["dest"] for w in want_afi["routes"]] - if len(want_dest_list) > 0: - for ro in h["routes"]: - if ro["dest"] in want_dest_list: - want_dest = search_obj_in_list( - ro["dest"], - want_afi["routes"], - "dest", - ) - want_next_hops = [] - if "next_hops" in want_dest.keys(): - want_next_hops = list(want_dest["next_hops"]) - if len(want_next_hops) > 0: - for next_hop in ro["next_hops"]: - if next_hop not in want_next_hops: - # have's next hop not in want, so delete it - delete_dict = { - "vrf": obj_in_have["vrf"], - "address_families": [ - { - "afi": h["afi"], - "routes": [ - { - "dest": ro["dest"], - "next_hops": [next_hop], - }, - ], - }, - ], - } - delete_commands.extend( - self.del_commands([delete_dict]), - ) - else: - # want has no next_hops, so delete all next_hops under that dest - if state == "overridden": - delete_dict = { - "vrf": obj_in_have["vrf"], - "address_families": [ - { - "afi": h["afi"], - "routes": [ - { - "dest": ro["dest"], - "next_hops": ro["next_hops"], - }, - ], - }, - ], - } - delete_commands.extend(self.del_commands([delete_dict])) - else: - if state == "overridden": - delete_dict = { - "vrf": obj_in_have["vrf"], - "address_families": [ - { - "afi": h["afi"], - "routes": [ - { - "dest": ro["dest"], - "next_hops": ro["next_hops"], - }, - ], - }, - ], - } - delete_commands.extend(self.del_commands([delete_dict])) - - else: - if ( - state == "overridden" - ): # want has no 'routes' key, so delete all routes under that afi - if "routes" in h.keys(): - delete_dict = { - "vrf": obj_in_have["vrf"], - "address_families": [ - { - "afi": h["afi"], - "routes": h["routes"], - }, - ], - } - delete_commands.extend(self.del_commands([delete_dict])) - else: - if ( - state == "overridden" - ): # want has 'vrf' key only. So delete all address families in it - delete_commands.extend( - self.del_commands( - [ - { - "address_families": list(obj_in_have["address_families"]), - "vrf": obj_in_have["vrf"], - }, - ], - ), - ) - final_delete_commands = [] - for d in delete_commands: - if d not in final_delete_commands: - final_delete_commands.append(d) - # if there are two afis, 'vrf context..' is added twice fom del_commands. The above code removes the redundant 'vrf context ..' - merged_commands = self.set_commands(want, have) - if merged_commands: - cmds = set(final_delete_commands).intersection(set(merged_commands)) - for c in cmds: - merged_commands.remove(c) - - # set_commands adds a 'vrf context..' line. The above code removes the redundant 'vrf context ..' - commands.extend(final_delete_commands) - commands.extend(merged_commands) - return commands - - def _state_overridden(self, want, have): - """The command generator when state is overridden - - :rtype: A list - :returns: the commands necessary to migrate the current configuration - to the desired configuration - """ - commands = [] - want_vrfs = [w["vrf"] for w in want] - for h in have: - if h["vrf"] not in want_vrfs and h["vrf"] != "management": - commands.extend(self._state_deleted([h], have)) - for w in want: - commands.extend(self._state_replaced(w, have)) - return commands - - def _state_merged(self, want, have): - """The command generator when state is merged - - :rtype: A list - :returns: the commands necessary to merge the provided into - the current configuration - """ - return self.set_commands(want, have) - - def _state_deleted(self, want, have): - """The command generator when state is deleted - - :rtype: A list - :returns: the commands necessary to remove the current configuration - of the provided objects + if self.state not in ["parsed", "gathered"]: + self.generate_commands() + self.run_commands() + return self.result + + def generate_commands(self): + """Generate configuration commands to send based on + want, have and desired state. """ - commands = [] - if want: - for w in want: - delete_dict = {} - obj_in_have = search_obj_in_list(w["vrf"], have, "vrf") - if obj_in_have: - if "address_families" in w.keys(): - o1 = obj_in_have["address_families"] - afi_list = [o["afi"] for o in o1] # have's afi list - for w1 in w["address_families"]: - if w1["afi"] in afi_list: - o2 = search_obj_in_list(w1["afi"], o1, "afi") - state = self._module.params["state"] - if state != "deleted": - # Deleted scope is till afi only. Part below is for use by overridden state. - if "routes" in w1.keys(): - for w2 in w1["routes"]: - o3 = search_obj_in_list( - w2["dest"], - o2["routes"], - "dest", - ) - hops = [] - if "next_hops" in w2.keys(): - for nh in w2["next_hops"]: - if nh in o3["next_hops"]: - hops.append(nh) - else: - # if next hops not given - hops = o3["next_hops"] - - delete_dict = { - "vrf": obj_in_have["vrf"], - "address_families": [ - { - "afi": w1["afi"], - "routes": [ - { - "dest": w2["dest"], - "next_hops": hops, - }, - ], - }, - ], - } - commands.extend(self.del_commands([delete_dict])) - else: - # case when only afi given for delete - delete_dict = { - "vrf": obj_in_have["vrf"], - "address_families": [ - { - "afi": o2["afi"], - "routes": o2["routes"], - }, - ], - } - commands.extend(self.del_commands([delete_dict])) - else: - commands.extend( - self.del_commands( - [ - { - "vrf": obj_in_have["vrf"], - "address_families": [o2], - }, - ], - ), - ) - else: - # only vrf given to delete - commands.extend(self.del_commands([obj_in_have])) - else: - if have: - # delete everything - del_have = [] - for h in have: - if h["vrf"] != "management": # protect management vrf - del_have.append(h) - commands = self.del_commands(del_have) - - final_delete_commands = [] - # del_commands might add 'vrf context..' twice for two routes in the same vrf. This removes it - for c in commands: - if c not in final_delete_commands: - final_delete_commands.append(c) - return final_delete_commands - - def del_commands(self, have): - commands = [] - for h in have: - if h != {"vrf": "default"}: - vrf = h["vrf"] - if "default" not in vrf: - commands.append("vrf context " + vrf) + wantd, delete_spcl = self.list_to_dict(self.want, "want") + haved, n_req = self.list_to_dict(self.have, "have") + + if delete_spcl and haved and self.state == "deleted": + for pk, to_rem in delete_spcl.items(): + if pk in ["ipv4", "ipv6"]: + _afis = haved.get("(_afis_)") + for k, v in _afis.get(pk, {}).items(): + for each_dest in to_rem: + if k.split("_")[0] == each_dest: + self.addcmd({pk: v}, pk, True) else: - # Default static routes are configured in global context. - # "vrf context default" command throws error 9.X release onwards. - # Changing the context to global is achieved by "configure terminal" - commands.append("configure terminal") - for af in h["address_families"]: - for route in af["routes"]: - for next_hop in route["next_hops"]: - command = self.del_next_hop(af, route, next_hop) - commands.append(command.strip()) - return commands - - def del_next_hop(self, af, route, next_hop): - command = "" - if af["afi"] == "ipv4": - command = "no ip route " + route["dest"] + " " + self.add_commands(next_hop) - else: - command = "no ipv6 route " + route["dest"] + " " + self.add_commands(next_hop) - return command - - def add_commands(self, want): - command = "" - params = want.keys() - pref = vrf = ip = intf = name = tag = track = "" - if "admin_distance" in params: - pref = str(want["admin_distance"]) + " " - if "track" in params: - track = "track " + str(want["track"]) + " " - if "dest_vrf" in params: - vrf = "vrf " + str(want["dest_vrf"]) + " " - if "forward_router_address" in params: - ip = want["forward_router_address"] + " " - if "interface" in params: - intf = normalize_interface(want["interface"]) + " " - if "null0" in intf: - ip = "" - intf = "null0 " - if "route_name" in params: - name = "name " + str(want["route_name"]) + " " - if "tag" in params: - tag = "tag " + str(want["tag"]) + " " - command = intf + ip + vrf + name + tag + track + pref - if intf != "Null0 " and ip == "": - self._module.fail_json(msg="forward_router_address error") - return command.strip() + sp_begin = len(self.commands) + _vrfs = haved.get(pk) + for ak, v in _vrfs.items(): + for k, srts in v.items(): + for each_dest in to_rem.get(ak): + if k.split("_")[0] == each_dest: + self.addcmd({ak: srts}, ak, True) + if len(self.commands) != sp_begin: + self.commands.insert( + sp_begin, + self._tmplt.render({"namevrf": pk}, "vrf", False), + ) - def set_commands(self, want, have): - commands = [] - h1 = h2 = h3 = {} - want = remove_empties(want) - vrf_list = [] - if have: - vrf_list = [h["vrf"] for h in have] - if want["vrf"] in vrf_list and have != [{"vrf": "default"}]: - for x in have: - if x["vrf"] == want["vrf"]: - h1 = x # this has the 'have' dict with same vrf as want - if "address_families" in h1.keys(): - afi_list = [h["afi"] for h in h1["address_families"]] - if "address_families" in want.keys(): - for af in want["address_families"]: - if af["afi"] in afi_list: - for x in h1["address_families"]: - if x["afi"] == af["afi"]: - h2 = x # this has the have dict with same vrf and afi as want - dest_list = [h["dest"] for h in h2["routes"]] - if "routes" in af.keys(): - for ro in af["routes"]: - if ro["dest"] in dest_list: - for x in h2["routes"]: - if x["dest"] == ro["dest"]: - h3 = x # this has the have dict with same vrf, afi and dest as want - next_hop_list = list(h3["next_hops"]) - if "next_hops" in ro.keys(): - for nh in ro["next_hops"]: - if "interface" in nh.keys(): - nh["interface"] = normalize_interface( - nh["interface"], - ) - if nh not in next_hop_list: - # no match for next hop in have - commands = self.set_next_hop( - want, - h2, - nh, - ro, - commands, - ) - vrf_list.append(want["vrf"]) - else: - # no match for dest - if "next_hops" in ro.keys(): - for nh in ro["next_hops"]: - commands = self.set_next_hop( - want, - h2, - nh, - ro, - commands, - ) - else: - # no match for afi - if "routes" in af.keys(): - for ro in af["routes"]: - for nh in ro["next_hops"]: - commands = self.set_next_hop(want, af, nh, ro, commands) else: - # no match for vrf - vrf_list.append(want["vrf"]) - for af in want["address_families"]: - for ro in af["routes"]: - for nh in ro["next_hops"]: - commands = self.set_next_hop(want, af, nh, ro, commands) - return commands - - def set_next_hop(self, want, h2, nh, ro, commands): - vrf = want["vrf"] - if h2["afi"] == "ipv4": - com = "ip route " + ro["dest"] + " " + self.add_commands(nh) - else: - com = "ipv6 route " + ro["dest"] + " " + self.add_commands(nh) - commands.append(com.strip()) - if "default" not in vrf: - string = "vrf context " + str(vrf) - else: - # Default static routes are configured in global context. - # "vrf context default" command throws error 9.X release onwards. - # Changing the context to global is achieved by "configure terminal" - string = "configure terminal" - if string not in commands: - commands.insert(0, string) - return commands - - def add_default_vrf(self, dictionary): - """ - This method is used to add 'default' vrf to the facts collected as global/default vrf - is not shown in facts. vrf key exists for all vrfs except global. - """ - for d in dictionary: - if "vrf" not in d.keys(): - d.update({"vrf": "default"}) - return dictionary + # if state is merged, merge want onto have and then compare + if self.state == "merged": + wantd = dict_merge(haved, wantd) + + for k, want in wantd.items(): + self._compare_top_level_keys(want=want, have=haved.pop(k, {}), vrf_name=k) + + if (self.state == "deleted" and not wantd) or self.state in ["overridden"]: + for k, have in haved.items(): + self._compare_top_level_keys(want={}, have=have, vrf_name=k) + + def _compare_top_level_keys(self, want, have, vrf_name): + begin = len(self.commands) + + # if state is deleted, empty out wantd and set haved to wantd + if self.state == "deleted" and have: + _have = {} + for addf in ["ipv4", "ipv6"]: + _temp_sr = {} + for k, ha in have.get(addf, {}).items(): + if k in want.get(addf, {}): # or not want.get(addf) + _temp_sr[k] = ha + if _temp_sr: + _have[addf] = _temp_sr + if _have: + have = _have + want = {} + + if self.state != "deleted": + for _afi, routes in want.items(): + self._compare(s_want=routes, s_have=have.pop(_afi, {}), afi=_afi) + + if self.state in ["overridden", "deleted"]: + for _afi, routes in have.items(): + self._compare(s_want={}, s_have=routes, afi=_afi) + + if len(self.commands) != begin: + if vrf_name == "(_afis_)": + afi_cmds = [] + for cmds in range(begin, len(self.commands)): + self.commands.insert(0, self.commands.pop()) + # afi_cmds.append(self.commands.pop()) + # self.commands = afi_cmds + self.commands + else: + self.commands.insert(begin, self._tmplt.render({"namevrf": vrf_name}, "vrf", False)) + + def _compare(self, s_want, s_have, afi): + for name, w_srs in s_want.items(): + have_srs = s_have.pop(name, {}) + self.compare(parsers=afi, want={afi: w_srs}, have={afi: have_srs}) + + # remove remaining items in have for replaced state + for name, h_srs in s_have.items(): + self.compare(parsers=afi, want={}, have={afi: h_srs}) + + def list_to_dict(self, param, operation): + _static_rts = {} + _delete_spc = {} + if param: + for srs in param: + _vrf = srs.get("vrf") + _srts = {} + for adfs in srs.get("address_families", []): + _afi = adfs.get("afi") + _routes = {} + for rts in adfs.get("routes", []): + _dest = rts.get("dest", "") + + # below if specific to special delete + if ( + self.state == "deleted" + and operation == "want" + and not rts.get("next_hops") + ): + if _vrf: + if not _delete_spc.get(_vrf): + _delete_spc[_vrf] = {} + if not _delete_spc[_vrf].get(_afi): + _delete_spc[_vrf][_afi] = [] + _delete_spc[_vrf][_afi].append(_dest) + else: + if not _delete_spc.get(_afi): + _delete_spc[_afi] = [] + _delete_spc[_afi].append(_dest) + + for nxh in rts.get("next_hops", []): + _forw_rtr_add = nxh.get("forward_router_address", "").upper() + _intf = nxh.get("interface", "") + _key = _dest + "_" + _forw_rtr_add + _intf + + dummy_sr = { + "afi": _afi, + "dest": _dest, + } + + if _vrf: + dummy_sr["vrf"] = _vrf + if _intf: + dummy_sr["interface"] = _intf + if _forw_rtr_add: + dummy_sr["forward_router_address"] = _forw_rtr_add + dummy_sr.update(nxh) + + _routes[_key] = dummy_sr + _srts[_afi] = _routes + _static_rts[_vrf if _vrf else "(_afis_)"] = _srts + return _static_rts, _delete_spc diff --git a/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py b/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py index b62d25805..991b552ff 100644 --- a/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py +++ b/plugins/module_utils/network/nxos/facts/static_routes/static_routes.py @@ -15,15 +15,14 @@ __metaclass__ = type -import re - -from copy import deepcopy - from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.static_routes.static_routes import ( Static_routesArgs, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.static_routes import ( + Static_routesTemplate, +) class Static_routesFacts(object): @@ -32,199 +31,113 @@ class Static_routesFacts(object): def __init__(self, module, subspec="config", options="options"): self._module = module self.argument_spec = Static_routesArgs.argument_spec - spec = deepcopy(self.argument_spec) - if subspec: - if options: - facts_argument_spec = spec[subspec][options] - else: - facts_argument_spec = spec[subspec] - else: - facts_argument_spec = spec - - self.generated_spec = utils.generate_dict(facts_argument_spec) - def get_device_data(self, connection, data): - vrf_data = [] - non_vrf_data = [] - if not data: - non_vrf_data = connection.get("show running-config | include '^ip(v6)* route'") - vrf_data = connection.get("show running-config | section '^vrf context'") - if non_vrf_data: - non_vrf_data = non_vrf_data.split("\n") + def get_static_routes_data(self, connection): + non_vrf_data = connection.get("show running-config | include '^ip(v6)* route'") + vrf_data = connection.get("show running-config | section '^vrf context'") + if vrf_data: + non_vrf_data += "\n" + vrf_data + return non_vrf_data + + def process_static_routes(self, objs): + strout = {} + for k, obj in objs.items(): + _routes = {"next_hops": []} + _nx_hop = [] + is_vrf = False + + for routes in obj: + grp_vrf = routes.pop("_vrf", None) + if grp_vrf: + is_vrf = True + _afi = routes.pop("_afi") + + _routes["dest"] = routes.pop("_dest") + _nx_hop.append(routes) + + _routes["next_hops"].extend(_nx_hop) + + if is_vrf: + if strout.get(grp_vrf) and strout[grp_vrf].get(_afi): + strout[grp_vrf][_afi].append(_routes) + else: + if strout.get(grp_vrf): + _tma = {_afi: [_routes]} + strout[grp_vrf].update(_tma) + else: + _tm = {grp_vrf: {_afi: [_routes]}} + strout.update(_tm) else: - non_vrf_data = [] - vrf_data = vrf_data.split("\nvrf context") - # as we split based on 'vrf context', it is stripped from the data except the first element - else: - # used for parsed state where data is from the 'running-config' key - data = data.split("\n") - i = 0 - while i <= (len(data) - 1): - if "vrf context " in data[i]: - vrf_conf = data[i] - j = i + 1 - while j < len(data) and "vrf context " not in data[j]: - vrf_conf += "\n" + data[j] - j += 1 - i = j - vrf_data.append(vrf_conf) + if strout.get(_afi): + strout[_afi].append(_routes) else: - non_vrf_data.append(data[i]) - i += 1 + _tma = {_afi: [_routes]} + strout.update(_tma) + return strout + + def structure_static_routes(self, strout): + _static_route_facts = [] + afi_v4 = strout.pop("ipv4", None) + afi_v6 = strout.pop("ipv6", None) + + if afi_v4 or afi_v6: + _triv_static_route = {"address_families": []} - new_vrf_data = [] - for v in vrf_data: - if re.search(r"\n\s*ip(v6)? route", v): - new_vrf_data.append(v) - # dont consider vrf if it does not have routes - for i in range(len(new_vrf_data)): - if not re.search("^vrf context", new_vrf_data[i]): - new_vrf_data[i] = "vrf context" + new_vrf_data[i] + if afi_v4: + _triv_static_route["address_families"].append({"afi": "ipv4", "routes": afi_v4}) + if afi_v6: + _triv_static_route["address_families"].append({"afi": "ipv6", "routes": afi_v6}) - resources = non_vrf_data + new_vrf_data - return resources + _static_route_facts.append(_triv_static_route) + + for k, v in strout.items(): + afi_v4 = v.pop("ipv4", None) + afi_v6 = v.pop("ipv6", None) + + _vrf_static_route = { + "vrf": k, + "address_families": [], + } + + if afi_v4: + _vrf_static_route["address_families"].append({"afi": "ipv4", "routes": afi_v4}) + if afi_v6: + _vrf_static_route["address_families"].append({"afi": "ipv6", "routes": afi_v6}) + + _static_route_facts.append(_vrf_static_route) + return _static_route_facts def populate_facts(self, connection, ansible_facts, data=None): - """Populate the facts for static_routes + """Populate the facts for Static_routes network resource + :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf + :rtype: dictionary :returns: facts """ + + facts = {} objs = [] - resources = self.get_device_data(connection, data) - objs = self.render_config(self.generated_spec, resources) + + if not data: + data = self.get_static_routes_data(connection) + + # parse native config using the Static_routes template + static_routes_parser = Static_routesTemplate(lines=data.splitlines(), module=self._module) + objs = static_routes_parser.parse() + + strout = self.process_static_routes(objs) + objs = self.structure_static_routes(strout) + ansible_facts["ansible_network_resources"].pop("static_routes", None) - facts = {} - if objs: - params = utils.validate_config(self.argument_spec, {"config": objs}) - params = utils.remove_empties(params) - for c in params["config"]: - if c == {"vrf": "default"}: - params["config"].remove(c) - facts["static_routes"] = params["config"] - ansible_facts["ansible_network_resources"].update(facts) - return ansible_facts - def get_inner_dict(self, conf, inner_dict): - """ - This method parses the command to create the innermost dictionary of the config - """ - conf = re.sub(r"\s*ip(v6)? route", "", conf) - # strip 'ip route' - inner_dict["dest"] = re.match(r"^\s*(\S+\/\d+) .*", conf).group(1) - - # ethernet1/2/23 - iface = re.match(r".* (Ethernet|loopback|mgmt|port\-channel)(\S*) .*", conf) - i = ["Ethernet", "loopback", "mgmt", "port-channel"] - if iface and iface.group(1) in i: - inner_dict["interface"] = (iface.group(1)) + (iface.group(2)) - conf = re.sub(inner_dict["interface"], "", conf) - - if "." in inner_dict["dest"]: - conf = re.sub(inner_dict["dest"], "", conf) - inner_dict["afi"] = "ipv4" - ipv4 = re.match(r".* (\d+\.\d+\.\d+\.\d+\/?\d*).*", conf) # gets next hop ip - if ipv4: - inner_dict["forward_router_address"] = ipv4.group(1) - conf = re.sub(inner_dict["forward_router_address"], "", conf) - else: - inner_dict["afi"] = "ipv6" - conf = re.sub(inner_dict["dest"], "", conf) - ipv6 = re.match(r".* (\S*:\S*:\S*\/?\d*).*", conf) - if ipv6: - inner_dict["forward_router_address"] = ipv6.group(1) - conf = re.sub(inner_dict["forward_router_address"], "", conf) - - nullif = re.search(r"null0", conf, re.IGNORECASE) - if nullif: - inner_dict["interface"] = "Null0" - inner_dict["forward_router_address"] = None - return inner_dict # dest IP not needed for null if - - keywords = ["vrf", "name", "tag", "track"] - for key in keywords: - pattern = re.match(r".* (?:%s) (\S+).*" % key, conf) - if pattern: - if key == "vrf": - key = "dest_vrf" - elif key == "name": - key = "route_name" - inner_dict[key] = pattern.group(1).strip() - conf = re.sub(key + " " + inner_dict[key], "", conf) - - pref = re.match(r"(?:.*) (\d+)$", conf) - if pref: - # if something is left at the end without any key, it is the pref - inner_dict["admin_distance"] = pref.group(1) - return inner_dict - - def get_command(self, conf, afi_list, dest_list, af): - inner_dict = {} - inner_dict = self.get_inner_dict(conf, inner_dict) - if inner_dict["afi"] not in afi_list: - af.append({"afi": inner_dict["afi"], "routes": []}) - afi_list.append(inner_dict["afi"]) - - next_hop = {} - params = [ - "forward_router_address", - "interface", - "admin_distance", - "route_name", - "tag", - "track", - "dest_vrf", - ] - for p in params: - if p in inner_dict.keys(): - next_hop.update({p: inner_dict[p]}) - - if inner_dict["dest"] not in dest_list: - dest_list.append(inner_dict["dest"]) - af[-1]["routes"].append({"dest": inner_dict["dest"], "next_hops": []}) - # if 'dest' is new, create new list under 'routes' - af[-1]["routes"][-1]["next_hops"].append(next_hop) - else: - af[-1]["routes"][-1]["next_hops"].append(next_hop) - # just append if dest already exists - return af - - def render_config(self, spec, con): - """ - Render config as dictionary structure and delete keys - from spec for null values + params = utils.remove_empties( + static_routes_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), + ) - :param spec: The facts tree, generated from the argspec - :param conf: The configuration - :rtype: dictionary - :returns: The generated config - """ - # config=deepcopy(spec) - config = [] - global_afi_list = [] - global_af = [] - global_dest_list = [] - if con: - for conf in con: - if conf.startswith("vrf context"): - svrf = re.match(r"vrf context (\S+)\n", conf).group(1) - afi_list = [] - af = [] - dest_list = [] - config_dict = {"vrf": svrf, "address_families": []} - conf = conf.split("\n") - # considering from the second line as first line is 'vrf context..' - conf = conf[1:] - for c in conf: - if ("ip route" in c or "ipv6 route" in c) and "bfd" not in c: - self.get_command(c, afi_list, dest_list, af) - config_dict["address_families"] = af - config.append(config_dict) - else: - if ("ip route" in conf or "ipv6 route" in conf) and "bfd" not in conf: - self.get_command(conf, global_afi_list, global_dest_list, global_af) - if global_af: - config.append(utils.remove_empties({"address_families": global_af})) - return config + facts["static_routes"] = params.get("config") + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts diff --git a/plugins/module_utils/network/nxos/rm_templates/static_routes.py b/plugins/module_utils/network/nxos/rm_templates/static_routes.py new file mode 100644 index 000000000..a70bc4130 --- /dev/null +++ b/plugins/module_utils/network/nxos/rm_templates/static_routes.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The Static_routes parser templates file. This contains +a list of parser definitions and associated functions that +facilitates both facts gathering and native command generation for +the given network resource. +""" + +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( + NetworkTemplate, +) + + +class Static_routesTemplate(NetworkTemplate): + def __init__(self, lines=None, module=None): + super(Static_routesTemplate, self).__init__(lines=lines, tmplt=self, module=module) + + # fmt: off + PARSERS = [ + # this parser shared the vrf context names with routes + { + 'name': 'vrf', + 'getval': re.compile( + r''' + ^vrf\scontext\s(?P\S+)$ + ''', re.VERBOSE, + ), + 'setval': 'vrf context {{ namevrf }}', + 'result': {}, + 'shared': True, + }, + { + "name": "ipv4", + "getval": re.compile( + r""" + (^|\s+)ip\sroute + (\s(?P\S+)) + (\s(?P(Ethernet|loopback|mgmt|Null|port-channel)\S+))? + (\s(?P\S+))? + (\svrf\s(?P\S+))? + (\sname\s(?P\S+))? + (\stag\s(?P\d+))? + (\strack\s(?P\d+))? + (\s(?P\d+))? + $""", re.VERBOSE, + ), + "setval": "ip route" + "{{ (' ' + ipv4.dest) if ipv4.dest is defined else '' }}" + "{{ (' ' + ipv4.interface) if ipv4.interface is defined else '' }}" + "{{ (' ' + ipv4.forward_router_address) if ipv4.forward_router_address is defined else '' }}" + "{{ (' vrf ' + ipv4.dest_vrf) if ipv4.dest_vrf is defined else '' }}" + "{{ (' name ' + ipv4.route_name) if ipv4.route_name is defined else '' }}" + "{{ (' tag ' + ipv4.tag|string) if ipv4.tag is defined else '' }}" + "{{ (' track ' + ipv4.track|string) if ipv4.track is defined else '' }}" + "{{ (' ' + ipv4.admin_distance|string) if ipv4.admin_distance is defined else '' }}", + "result": { + "{{ dest }}_{{ namevrf|d() }}_ipv4": [ + { + "_vrf": "{{ namevrf }}", + "_afi": "ipv4", + "_dest": "{{ dest }}", + "interface": "{{ interface }}", + "forward_router_address": "{{ forward_router_address }}", + "admin_distance": "{{ admin_distance }}", + "dest_vrf": "{{ dest_vrf }}", + "tag": "{{ tag }}", + "route_name": "{{ route_name }}", + "track": "{{ track }}", + }, + ], + }, + }, + { + "name": "ipv6", + "getval": re.compile( + r""" + (^|\s+)ipv6\sroute + (\s(?P\S+)) + (\s(?P(Ethernet|loopback|mgmt|Null|port-channel)\S+))? + (\s(?P\S+))? + (\svrf\s(?P\S+))? + (\sname\s(?P\S+))? + (\stag\s(?P\d+))? + (\strack\s(?P\d+))? + (\s(?P\d+))? + $""", re.VERBOSE, + ), + "setval": "ipv6 route" + "{{ (' ' + ipv6.dest) if ipv6.dest is defined else '' }}" + "{{ (' ' + ipv6.interface) if ipv6.interface is defined else '' }}" + "{{ (' ' + ipv6.forward_router_address) if ipv6.forward_router_address is defined else '' }}" + "{{ (' vrf ' + ipv6.dest_vrf) if ipv6.dest_vrf is defined else '' }}" + "{{ (' name ' + ipv6.route_name) if ipv6.route_name is defined else '' }}" + "{{ (' tag ' + ipv6.tag|string) if ipv6.tag is defined else '' }}" + "{{ (' track ' + ipv6.track|string) if ipv6.track is defined else '' }}" + "{{ (' ' + ipv6.admin_distance|string) if ipv6.admin_distance is defined else '' }}", + "result": { + "{{ dest }}_{{ namevrf|d() }}_ipv6": [ + { + "_vrf": "{{ namevrf }}", + "_afi": "ipv6", + "_dest": "{{ dest }}", + "interface": "{{ interface }}", + "forward_router_address": "{{ forward_router_address }}", + "admin_distance": "{{ admin_distance }}", + "dest_vrf": "{{ dest_vrf }}", + "tag": "{{ tag }}", + "route_name": "{{ route_name }}", + "track": "{{ track }}", + }, + ], + }, + }, + ] + # fmt: on diff --git a/plugins/modules/nxos_static_routes.py b/plugins/modules/nxos_static_routes.py index f8042aede..a7fdf6713 100644 --- a/plugins/modules/nxos_static_routes.py +++ b/plugins/modules/nxos_static_routes.py @@ -1,26 +1,9 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2019 Red Hat +# Copyright 2023 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -############################################# -# WARNING # -############################################# -# -# This file is auto generated by the resource -# module builder playbook. -# -# Do not edit this file manually. -# -# Changes to this file will be over written -# by the resource module builder. -# -# Changes should be made in the model used to -# generate this file or in the resource module -# builder template. -# -############################################# """ The module file for nxos_static_routes """ @@ -30,16 +13,17 @@ __metaclass__ = type - DOCUMENTATION = """ module: nxos_static_routes short_description: Static routes resource module description: This module configures and manages the attributes of static routes on Cisco NX-OS platforms. version_added: 1.0.0 -author: Adharsh Srivats Rangarajan (@adharshsrivatsr) +author: + - Adharsh Srivats Rangarajan (@adharshsrivatsr) + - Sagar Paul (@KB-perByte) notes: -- Tested against NX-OS 7.3.(0)D1(1) on VIRL +- Tested against Nexus 9300v running NX-OS 9.3.6 on CML. - Unsupported for Cisco MDS - When a route is configured for a non-existent VRF, the VRF is created and the route is added to it. @@ -141,16 +125,18 @@ - rendered - parsed default: merged - """ + EXAMPLES = """ -# Using deleted: +# Using deleted - delete all # Before state: # ------------- # +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.32/28 192.0.2.12 name new_route # ip route 192.0.2.26/24 192.0.2.13 tag 12 +# switch# show running-config | section '^vrf context' - name: Delete all routes cisco.nxos.nxos_static_routes: @@ -158,6 +144,7 @@ # Task Output # ----------- +# # before: # - address_families: # - afi: ipv4 @@ -171,20 +158,24 @@ # - forward_router_address: 192.0.2.12 # route_name: new_route # commands: -# - configure terminal # - no ip route 192.0.2.0/24 192.0.2.13 tag 12 # - no ip route 192.0.2.32/28 192.0.2.12 name new_route # after: [] + # After state: # ------------ -# +# switch# show running-config | include '^ip(v6)* route' +# switch# show running-config | section '^vrf context' +# Using deleted - vrf based # Before state: # ------------ # +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 +# switch# show running-config | section '^vrf context' # 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 @@ -198,6 +189,7 @@ # Task Output # ----------- +# # before: # - address_families: # - afi: ipv4 @@ -248,16 +240,22 @@ # After state: # ----------- +# +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 +# switch# show running-config | section '^vrf context' # vrf context trial_vrf +# Using deleted - afi based # Before state: # ------------ # +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 +# switch# show running-config | section '^vrf context' # 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 @@ -273,6 +271,7 @@ # Task Output # ----------- +# # before: # - address_families: # - afi: ipv4 @@ -331,8 +330,11 @@ # After state: # ----------- +# +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 +# switch# show running-config | section '^vrf context' # vrf context trial_vrf # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5 @@ -340,7 +342,8 @@ # Before state: # ------------- -# +# switch# show running-config | include '^ip(v6)* route' +# switch# show running-config | section '^vrf context' - name: Merge new static route configuration cisco.nxos.nxos_static_routes: @@ -354,7 +357,6 @@ - forward_router_address: 192.0.2.22 tag: 4 admin_distance: 2 - - address_families: - afi: ipv4 routes: @@ -372,11 +374,11 @@ # Task Output # ----------- +# # before:[] # commands: # - vrf context trial_vrf # - ip route 192.0.2.64/24 192.0.2.22 tag 4 2 -# - configure terminal # - ip route 192.0.2.16/24 192.0.2.24 name new_route # - ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 # after: @@ -389,7 +391,6 @@ # - forward_router_address: 192.0.2.22 # tag: 4 # admin_distance: 2 -# # - address_families: # - afi: ipv4 # routes: @@ -407,24 +408,27 @@ # After state: # ------------ # +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/24 192.0.2.24 name new_route # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 +# switch# show running-config | section '^vrf context' # vrf context trial_vrf # ip route 192.0.2.0/24 192.0.2.22 tag 4 2 - -# Using overridden: +# Using overridden # Before state: # ------------- # +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 +# switch# show running-config | section '^vrf context' # 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 -- name: Overriden existing static route configuration with new configuration +- name: Overridden existing static route configuration with new configuration cisco.nxos.nxos_static_routes: config: - vrf: trial_vrf @@ -436,7 +440,6 @@ - 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 @@ -445,6 +448,7 @@ # Task Output # ----------- +# # before: # - address_families: # - afi: ipv4 @@ -469,7 +473,6 @@ # - forward_router_address: 192.0.2.26 # tag: 12 # commands: -# - configure terminal # - no ip route 192.0.2.16/28 192.0.2.24 name new_route # - no ip route 192.0.2.80/28 192.0.2.26 tag 12 # - vrf context trial_vrf @@ -495,17 +498,21 @@ # After state: # ------------ # +# switch# show running-config | include '^ip(v6)* route' +# switch# show running-config | section '^vrf context' # vrf context trial_vrf # ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2 - -# Using replaced: +# Using replaced # Before state: # ------------ +# +# switch# show running-config | include '^ip(v6)* route' # ip route 192.0.2.16/28 192.0.2.24 name new_route # ip route 192.0.2.80/28 192.0.2.26 tag 12 +# switch# show running-config | section '^vrf context' # 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 @@ -521,7 +528,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 @@ -530,6 +536,7 @@ # Task Output # ----------- +# # before: # - address_families: # - afi: ipv4 @@ -554,7 +561,6 @@ # - forward_router_address: 192.0.2.26 # tag: 12 # commands: -# - configure terminal # - no ip route 192.0.2.16/28 192.0.2.24 name new_route # - 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 @@ -588,29 +594,37 @@ # tag: 12 # After state: -# ----------- +# ------------ +# +# switch# show running-config | include '^ip(v6)* route' # 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 +# switch# show running-config | section '^vrf context' # 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 -# Using gathered: +# Using gathered # Before state: # ------------- +# +# switch# show running-config | include '^ip(v6)* route' # ipv6 route 2001:db8:12::/32 2001:db8::12 +# switch# show running-config | section '^vrf context' # 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 -- name: Gather the exisitng condiguration +- name: Gather the existing configuration cisco.nxos.nxos_static_routes: state: gathered -# returns: +# Task Output +# ----------- +# # gathered: # - vrf: Test # address_families: @@ -631,7 +645,7 @@ # - forward_router_address: 2001:db8::12 -# Using rendered: +# Using rendered - name: Render required configuration to be pushed to the device cisco.nxos.nxos_static_routes: @@ -642,7 +656,6 @@ - dest: 192.0.2.48/28 next_hops: - forward_router_address: 192.0.2.13 - - afi: ipv6 routes: - dest: 2001:db8::/64 @@ -651,24 +664,28 @@ forward_router_address: 2001:db8::12 state: rendered -# returns +# Task Output +# ----------- +# # rendered: # vrf context default # ip route 192.0.2.48/28 192.0.2.13 # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12 - # Using parsed - name: Parse the config to structured data cisco.nxos.nxos_static_routes: + state: parsed running_config: | ipv6 route 2002:db8:12::/32 2002:db8:12::1 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 -# returns: +# Task Output +# ----------- +# # parsed: # - vrf: Test # address_families: @@ -677,42 +694,64 @@ # - dest: 192.0.2.48/28 # next_hops: # - forward_router_address: 192.0.2.13 -# # - forward_router_address: 192.0.2.14 # admin_distance: 5 -# # - address_families: # - afi: ipv6 # routes: # - dest: 2002:db8:12::/32 # next_hops: # - forward_router_address: 2002:db8:12::1 - - """ + RETURN = """ before: - description: The configuration prior to the model invocation. - returned: always + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: > - The configuration returned will always be in the same format - of the parameters above. + This output will always be in the same format as the + module argspec. after: - description: The resulting configuration model invocation. + description: The resulting configuration after module execution. returned: when changed type: list sample: > - The configuration returned will always be in the same format - of the parameters above. + This output will always be in the same format as the + module argspec. commands: description: The set of commands pushed to the remote device. - returned: always + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - ip route 192.0.2.16/28 192.0.2.24 name new_route + - vrf context trial_vrf + - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) type: list - sample: ['ip route 192.0.2.48/28 192.0.2.12 Ethernet1/2 name sample_route', - 'ipv6 route 2001:db8:3000::/36 2001:db8:200:2::2', 'vrf context test','ip route 192.0.2.48/28 192.0.2.121'] + sample: + - ip route 192.0.2.16/28 192.0.2.24 name new_route + - vrf context trial_vrf + - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ + from ansible.module_utils.basic import AnsibleModule from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.static_routes.static_routes import ( @@ -729,7 +768,19 @@ def main(): :returns: the result form module invocation """ - module = AnsibleModule(argument_spec=Static_routesArgs.argument_spec, supports_check_mode=True) + + module = AnsibleModule( + argument_spec=Static_routesArgs.argument_spec, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, + ) result = Static_routes(module).execute_module() module.exit_json(**result) diff --git a/tests/integration/targets/nxos_static_routes/tasks/main.yaml b/tests/integration/targets/nxos_static_routes/tasks/main.yaml index 159ffa2b9..10be7ff19 100644 --- a/tests/integration/targets/nxos_static_routes/tasks/main.yaml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml b/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml index 67c89cc33..fbf316b41 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/deleted.yml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/merged.yml b/tests/integration/targets/nxos_static_routes/tests/common/merged.yml index 6ba0a1b6a..11b748793 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/merged.yml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml b/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml index ae03e947f..e90c3cfbb 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/overridden.yml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml b/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml index 32cd5bd83..8590c4e3f 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/parsed.yml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml b/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml index 2348a64b6..99581bb11 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/rendered.yml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml b/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml index 73c122198..ca61c48e5 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/replaced.yml +++ b/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/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml b/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml index 1ee36a936..24b9fe9cf 100644 --- a/tests/integration/targets/nxos_static_routes/tests/common/rtt.yml +++ b/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/tests/integration/targets/nxos_static_routes/vars/main.yml b/tests/integration/targets/nxos_static_routes/vars/main.yml index 958773252..82b180899 100644 --- a/tests/integration/targets/nxos_static_routes/vars/main.yml +++ b/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/tests/unit/modules/network/nxos/test_nxos_static_routes.py b/tests/unit/modules/network/nxos/test_nxos_static_routes.py index 69f5f74bd..76ed4a3a9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_static_routes.py +++ b/tests/unit/modules/network/nxos/test_nxos_static_routes.py @@ -8,11 +8,15 @@ __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 @@ def test_nxos_static_routes_deletedafi(self): ), ) 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 @@ def test_nxos_static_routes_rendered(self): next_hops=[ dict( forward_router_address="2048:ae12::/64", - interface="Eth1/4", + interface="Ethernet1/4", admin_distance=5, ), ], @@ -387,128 +891,386 @@ def test_nxos_static_routes_rendered(self): "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", }, ], }, From e713bebdd73a47b1eb598763f9ebc8dc3c024c0c Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Wed, 28 Jun 2023 16:32:15 +0530 Subject: [PATCH 105/166] Enable release via GitHub Actions (#692) * Enable release via GitHub Actions * fixed something * revert req changes * remove token refresh * remove pre-commit entry * add yaml lint exception * fix the galaxy.yml start --------- Co-authored-by: Nilashish Chakraborty --- .config/ansible-lint.yml | 3 -- .github/release-drafter.yml | 3 ++ .github/workflows/ack.yml | 15 ++++++++ .github/workflows/codecoverage.yml | 2 +- .github/workflows/push.yml | 37 +++++++++++++++++++ .github/workflows/release.yml | 14 +++++++ .pre-commit-config.yaml | 26 +++---------- galaxy.yml | 3 +- test-requirements.txt | 13 ++++--- .../modules/network/nxos/test_nxos_ping.py | 2 +- 10 files changed, 85 insertions(+), 33 deletions(-) delete mode 100644 .config/ansible-lint.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/ack.yml create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/release.yml diff --git a/.config/ansible-lint.yml b/.config/ansible-lint.yml deleted file mode 100644 index a401eae2a..000000000 --- a/.config/ansible-lint.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -skip_list: - - galaxy[version-incorrect] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 000000000..e3e5966e4 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,3 @@ +--- +# see https://github.com/ansible-community/devtools +_extends: ansible-community/devtools diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml new file mode 100644 index 000000000..fda595dc5 --- /dev/null +++ b/.github/workflows/ack.yml @@ -0,0 +1,15 @@ +--- +# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml +name: ack + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + ack: + uses: ansible/devtools/.github/workflows/ack.yml@main diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml index 3ed9832a7..b425edcc2 100644 --- a/.github/workflows/codecoverage.yml +++ b/.github/workflows/codecoverage.yml @@ -1,7 +1,7 @@ --- name: Code Coverage -on: +on: # yamllint disable-line rule:truthy push: pull_request: branches: [ main ] diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 000000000..11081c642 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,37 @@ +--- +# push workflow is shared and expected to perform actions after a merge happens +# on a maintenance branch (default or release). For example updating the +# draft release-notes. +# based on great work from +# https://github.com/T-Systems-MMS/ansible-collection-icinga-director +name: push + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + push: + # branches to consider in the event; optional, defaults to all + branches: + - main + - 'releases/**' + - 'stable/**' + # Prevent a 2nd run after the changelog is updated + paths-ignore: + - CHANGELOG.rst + - changelogs/changelog.yaml + workflow_dispatch: + +env: + NAMESPACE: cisco + COLLECTION_NAME: nxos + ANSIBLE_COLLECTIONS_PATHS: ./ + +jobs: + update_release_draft: + uses: ansible/devtools/.github/workflows/push_network.yml@main + with: + repo: ansible-collections/cisco.nxos + secrets: + BOT_PAT: ${{ secrets.BOT_PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..eb04259d1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,14 @@ +--- +name: release +on: # yamllint disable-line rule:truthy + release: + types: [published] + +jobs: + release: + uses: ansible/devtools/.github/workflows/release_collection.yml@main + with: + environment: release + secrets: + ah_token: ${{ secrets.AH_TOKEN }} + ansible_galaxy_api_key: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7edab1a11..0f119dce2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,10 @@ --- repos: + - repo: https://github.com/ansible-network/collection_prep + rev: 1.1.1 + hooks: + - id: update-docs + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -20,20 +25,6 @@ repos: rev: "v3.0.0-alpha.9-for-vscode" hooks: - id: prettier - # Original hook implementation is flaky due to *several* bugs described - # in https://github.com/prettier/prettier/issues/12364 - # a) CI=1 needed to avoid incomplete output - # b) two executions are needed because --list-different works correctly - # only when run with --check as with --write the output will also - # include other entries and logging level cannot be used to keep only - # modified files listed (any file is listed using the log level, regardless if - # is modified or not). - # c) We avoid letting pre-commit pass each filename in order to avoid - # running multiple instances in parallel. This also ensures that running - # prettier from the command line behaves identically with the pre-commit - # one. No real performance downsides. - # d) exit with the return code from list-different (0=none, 1=some) - # rather than the write (0=successfully rewrote files). pre-commit.ci entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" pass_filenames: false args: [] @@ -46,14 +37,9 @@ repos: hooks: - id: isort name: Sort import statements using isort + args: ["--filter-files"] - repo: https://github.com/psf/black rev: 23.3.0 hooks: - id: black - - - repo: https://github.com/ansible-network/collection_prep - rev: 1.1.1 - hooks: - - id: update-docs - - id: autoversion diff --git a/galaxy.yml b/galaxy.yml index 71bf73130..ebcd5d499 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,4 +1,3 @@ ---- authors: - Ansible Network Community (ansible-network) dependencies: @@ -13,4 +12,4 @@ issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] # NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: 5.0.0-dev +version: 5.0.0 diff --git a/test-requirements.txt b/test-requirements.txt index fa48b68f8..94ff7c9e3 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,9 @@ -black==22.3.0 ; python_version > '3.5' +# For ansible-tox-linters +black==23.3.0 ; python_version >= '3.7' flake8 -git+https://github.com/ansible-community/pytest-ansible-units.git -mock ; python_version < '3.5' -pexpect -pytest-xdist yamllint -coverage==4.5.4 + +# Unit test runner +pytest-ansible ; python_version >= '3.9' +git+https://github.com/ansible-community/pytest-ansible-units.git ; python_version < '3.9' +pytest-xdist diff --git a/tests/unit/modules/network/nxos/test_nxos_ping.py b/tests/unit/modules/network/nxos/test_nxos_ping.py index 73535f89e..bdaabe881 100644 --- a/tests/unit/modules/network/nxos/test_nxos_ping.py +++ b/tests/unit/modules/network/nxos/test_nxos_ping.py @@ -32,7 +32,7 @@ class TestNxosPingModule(TestNxosModule): - """Class used for Unit Tests agains ios_ping module""" + """Class used for Unit Tests against nxos_ping module""" module = nxos_ping From 32016dcb101edc9a03b854719a5e557974c22542 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 3 Jul 2023 15:12:14 +0530 Subject: [PATCH 106/166] Prepare for v5.0.0 (#703) * Prepare for v5.0.0 Signed-off-by: NilashishC * Update changelogs/changelog.yaml Co-authored-by: Sagar Paul --------- Signed-off-by: NilashishC Co-authored-by: Sagar Paul --- CHANGELOG.rst | 28 +++++++++++++++++++ changelogs/changelog.yaml | 24 ++++++++++++++++ changelogs/fragments/drop.yaml | 8 ------ changelogs/fragments/nxos_user.yml | 3 -- changelogs/fragments/overridden.yaml | 3 -- changelogs/fragments/templates.yaml | 3 -- changelogs/fragments/update_static_routes.yml | 5 ---- 7 files changed, 52 insertions(+), 22 deletions(-) delete mode 100644 changelogs/fragments/drop.yaml delete mode 100644 changelogs/fragments/nxos_user.yml delete mode 100644 changelogs/fragments/overridden.yaml delete mode 100644 changelogs/fragments/templates.yaml delete mode 100644 changelogs/fragments/update_static_routes.yml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 34a945461..2eb2b3295 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,34 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v5.0.0 +====== + +Major Changes +------------- + +- This release removes four of the previously deprecated modules from this collection. Refer to **Removed Features** section for details. + +Minor Changes +------------- + +- Add nxos_bgp_templates module. +- nxos_user - Added dev-ops role to BUILTINS (https://github.com/ansible-collections/cisco.nxos/issues/690) + +Removed Features (previously deprecated) +---------------------------------------- + +- The nxos_bgp module has been removed with this release. +- The nxos_bgp_af module has been removed with this release. +- The nxos_bgp_neighbor module has been removed with this release. +- The nxos_bgp_neighbor_af module has been removed with this release. + +Bugfixes +-------- + +- nxos_static_routes - Prevent action states to generate terminal configuration command. +- nxos_static_routes - Update the delete operation of static routes to be similar to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666) + v4.4.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 0ae1adf75..04b1d7f79 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1010,3 +1010,27 @@ releases: - tests.yaml - update_inft_docs.yaml release_date: "2023-05-29" + 5.0.0: + changes: + bugfixes: + - "nxos_static_routes - Prevent action states to generate terminal configuration command." + - "nxos_static_routes - Update the delete operation of static routes to be similar + to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666)" + major_changes: + - This release removes four of the previously deprecated modules from this collection. + - Refer to **Removed Features** section for details. + minor_changes: + - Add nxos_bgp_templates module. + - nxos_user - Added dev-ops role to BUILTINS (https://github.com/ansible-collections/cisco.nxos/issues/690) + removed_features: + - The nxos_bgp module has been removed with this release. + - The nxos_bgp_af module has been removed with this release. + - The nxos_bgp_neighbor module has been removed with this release. + - The nxos_bgp_neighbor_af module has been removed with this release. + fragments: + - drop.yaml + - nxos_user.yml + - overridden.yaml + - templates.yaml + - update_static_routes.yml + release_date: "2023-07-05" diff --git a/changelogs/fragments/drop.yaml b/changelogs/fragments/drop.yaml deleted file mode 100644 index e0071b198..000000000 --- a/changelogs/fragments/drop.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -removed_features: - - The nxos_bgp module has been removed with this release. - - The nxos_bgp_af module has been removed with this release. - - The nxos_bgp_neighbor module has been removed with this release. - - The nxos_bgp_neighbor_af module has been removed with this release. -major_changes: - - This release removes four of the previously deprecated modules from this collection. Refer to **Removed Features** section for details. diff --git a/changelogs/fragments/nxos_user.yml b/changelogs/fragments/nxos_user.yml deleted file mode 100644 index 2e31198d6..000000000 --- a/changelogs/fragments/nxos_user.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "nxos_user - Added dev-ops role to BUILTINS (https://github.com/ansible-collections/cisco.nxos/issues/690)" diff --git a/changelogs/fragments/overridden.yaml b/changelogs/fragments/overridden.yaml deleted file mode 100644 index 3aedb1933..000000000 --- a/changelogs/fragments/overridden.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Add support for overridden wherever valid and is missing. diff --git a/changelogs/fragments/templates.yaml b/changelogs/fragments/templates.yaml deleted file mode 100644 index 3115b98bc..000000000 --- a/changelogs/fragments/templates.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - Add nxos_bgp_templates module. diff --git a/changelogs/fragments/update_static_routes.yml b/changelogs/fragments/update_static_routes.yml deleted file mode 100644 index 6c8cf8aa9..000000000 --- a/changelogs/fragments/update_static_routes.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -bugfixes: - - nxos_static_routes - Update the delete operation of static routes to be similar to other platforms. - (https://github.com/ansible-collections/cisco.nxos/issues/666) - - nxos_static_routes - Prevent action states to generate terminal configuration command. From 73aed160bc2eae05cfc50a17ff2c651ce0464d1a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:02:18 +0530 Subject: [PATCH 107/166] [pre-commit.ci] pre-commit autoupdate (#705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/asottile/add-trailing-comma: v2.5.1 → v3.0.0](https://github.com/asottile/add-trailing-comma/compare/v2.5.1...v3.0.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- plugins/modules/nxos_snmp_host.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f119dce2..ba0b838bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v2.5.1 + rev: v3.0.0 hooks: - id: add-trailing-comma diff --git a/plugins/modules/nxos_snmp_host.py b/plugins/modules/nxos_snmp_host.py index 3c23374c8..5899472e2 100644 --- a/plugins/modules/nxos_snmp_host.py +++ b/plugins/modules/nxos_snmp_host.py @@ -264,21 +264,27 @@ def remove_snmp_host(host, udp, existing): existing["version"] = "3" command = "no snmp-server host {0} {snmp_type} version \ {version} {v3} {community} udp-port {1}".format( - host, udp, **existing + host, + udp, + **existing, ) elif existing["version"] == "v2c": existing["version"] = "2c" command = "no snmp-server host {0} {snmp_type} version \ {version} {community} udp-port {1}".format( - host, udp, **existing + host, + udp, + **existing, ) elif existing["version"] == "v1": existing["version"] = "1" command = "no snmp-server host {0} {snmp_type} version \ {version} {community} udp-port {1}".format( - host, udp, **existing + host, + udp, + **existing, ) if command: From 7cca8a8d9f577673c466bc86dd55fa803ea46110 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Wed, 5 Jul 2023 22:04:10 +0530 Subject: [PATCH 108/166] [facts] [hardware] add cpu utilization to facts (#669) * add cpu utilization to facts * add changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update plugins/module_utils/network/nxos/facts/legacy/base.py Co-authored-by: Nilashish Chakraborty * update change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update test --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/cpu_utilization.yml | 3 +++ .../network/nxos/facts/legacy/base.py | 20 +++++++++++++++++++ .../nxos_facts/tests/common/all_facts.yaml | 1 + 3 files changed, 24 insertions(+) create mode 100644 changelogs/fragments/cpu_utilization.yml diff --git a/changelogs/fragments/cpu_utilization.yml b/changelogs/fragments/cpu_utilization.yml new file mode 100644 index 000000000..9683a03e5 --- /dev/null +++ b/changelogs/fragments/cpu_utilization.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - nxos_facts - add cpu utilization data to facts. diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index b8cfbf475..16540a435 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -162,6 +162,26 @@ def populate(self): self.facts["memtotal_mb"] = self.parse_memtotal_mb(data) self.facts["memfree_mb"] = self.parse_memfree_mb(data) + data = None + data = self.run("show processes cpu | json") + + if data: + self.facts["cpu_utilization"] = self.parse_cpu_utilization(data) + + def parse_cpu_utilization(self, data): + return { + "core": { + "five_minutes": int(data.get("fivemin_percent", 0)), + "five_seconds": int( + data.get("fivesec_percent", 0), + ), + "five_seconds_interrupt": int( + data.get("fivesec_intr_percent", 0), + ), + "one_minute": int(data.get("onemin_percent", 0)), + }, + } + def parse_filesystems(self, data): return re.findall(r"^Usage for (\S+)//", data, re.M) diff --git a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index 9ace4ebff..7aece91d1 100644 --- a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/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 From 42af395914e299f248b260cfb9fb57f9edbc1132 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Wed, 5 Jul 2023 22:39:50 +0530 Subject: [PATCH 109/166] Prep release 5.1.0 (#709) --- CHANGELOG.rst | 11 ++++++++++- changelogs/changelog.yaml | 7 +++++++ changelogs/fragments/cpu_utilization.yml | 3 --- 3 files changed, 17 insertions(+), 4 deletions(-) delete mode 100644 changelogs/fragments/cpu_utilization.yml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2eb2b3295..29a132412 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,13 +5,22 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v5.1.0 +====== + +Minor Changes +------------- + +- nxos_facts - add cpu utilization data to facts. + v5.0.0 ====== Major Changes ------------- -- This release removes four of the previously deprecated modules from this collection. Refer to **Removed Features** section for details. +- Refer to **Removed Features** section for details. +- This release removes four of the previously deprecated modules from this collection. Minor Changes ------------- diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 04b1d7f79..cfac676bc 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1034,3 +1034,10 @@ releases: - templates.yaml - update_static_routes.yml release_date: "2023-07-05" + 5.1.0: + changes: + minor_changes: + - nxos_facts - add cpu utilization data to facts. + fragments: + - cpu_utilization.yml + release_date: "2023-07-05" diff --git a/changelogs/fragments/cpu_utilization.yml b/changelogs/fragments/cpu_utilization.yml deleted file mode 100644 index 9683a03e5..000000000 --- a/changelogs/fragments/cpu_utilization.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - nxos_facts - add cpu utilization data to facts. From 966f75a2f47bc4ebb773b61bd6f23fffdeaf012f Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Wed, 5 Jul 2023 23:14:21 +0530 Subject: [PATCH 110/166] Release prep 5.1.0 (#711) * Release prep 5.1.0 * comment not needed * revert changelog entry for 2.0.0 --- changelogs/changelog.yaml | 26 ++++++++++++++------------ galaxy.yml | 4 +--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index cfac676bc..404de0b8e 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -470,12 +470,12 @@ releases: - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family resource module. major_changes: - - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` - and `ansible_network_import_modules`. - "Please refer to ansible.netcommon `changelog `_ for more details." + - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` + and `ansible_network_import_modules`. minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). - Add hello_interval_ms option in nxos_pim_interface module to support sub-second @@ -721,9 +721,9 @@ releases: - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." release_summary: - "The v2.8.1 of the cisco.nxos collection is not available on + The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains - an additional bug fix." + an additional bug fix. fragments: - ignore.yaml - nxos_ntp.yaml @@ -888,7 +888,8 @@ releases: or netconf. - "This release drops support for `connection: local` and provider dictionary." removed_features: - - This release removes the following deprecated plugins that have reached their end-of-life. + - This release removes the following deprecated plugins that have reached their + end-of-life. - nxos_acl - nxos_acl_interface - nxos_interface @@ -924,8 +925,7 @@ releases: bugfixes: - "`nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623)." - "`nxos_file_copy` - stop prepending redundant bootflash: to remote file names" - - nxos_acls - Detect duplicate ACE error message from CLI and fail - (https://github.com/ansible-collections/cisco.nxos/issues/611). + - nxos_acls - Detect duplicate ACE error message from CLI and fail (https://github.com/ansible-collections/cisco.nxos/issues/611). - nxos_command - Run & evaluate commands at least once even when retries is set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). minor_changes: @@ -989,7 +989,8 @@ releases: - ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670). - nxos_banner - Add support for a custom multiline delimiter - nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440). - - "terminal - attempt privilege escalation only when prompt does not end with #" + - "terminal - attempt privilege escalation only when prompt does not end with + #" doc_changes: - Fix docs of static-routes resource module. - nxos_interfaces - Fixed module documentation and examples. @@ -1013,12 +1014,13 @@ releases: 5.0.0: changes: bugfixes: - - "nxos_static_routes - Prevent action states to generate terminal configuration command." - - "nxos_static_routes - Update the delete operation of static routes to be similar - to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666)" + - nxos_static_routes - Prevent action states to generate terminal configuration + command. + - nxos_static_routes - Update the delete operation of static routes to be similar + to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666) major_changes: - - This release removes four of the previously deprecated modules from this collection. - Refer to **Removed Features** section for details. + - This release removes four of the previously deprecated modules from this collection. minor_changes: - Add nxos_bgp_templates module. - nxos_user - Added dev-ops role to BUILTINS (https://github.com/ansible-collections/cisco.nxos/issues/690) diff --git a/galaxy.yml b/galaxy.yml index ebcd5d499..9d1c6b596 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,6 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -# NOTE(pabelanger): We create 0.0.0 version key to keep ansible-galaxy -# happy. We dynamically inject version info based on git information. -version: 5.0.0 +version: 5.1.0 From 3a21cacf628c2c8a35f182796ea38d653733f965 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Jul 2023 18:33:44 +0530 Subject: [PATCH 111/166] [pre-commit.ci] pre-commit autoupdate (#714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode → v3.0.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.9-for-vscode...v3.0.0) - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba0b838bc..2a8fe9643 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.9-for-vscode" + rev: "v3.0.0" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black From cb9d1f71b1d368d87dd24ed89cf2f581f8b316bc Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 28 Jul 2023 14:50:37 +0530 Subject: [PATCH 112/166] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f38212efe..7c02182da 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,4 +46,4 @@ jobs: '${{ needs.sanity.result }}', '${{ needs.unit-galaxy.result }}', '${{ needs.unit-source.result }}' - ]) == {'success'}" + ]) == {'success', 'skipped'}" From c5dbe4c2c8c86dd2b98ad9a4e43252b3fa96b826 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 28 Jul 2023 18:36:15 +0530 Subject: [PATCH 113/166] Fix var-naming[no-reserved] lint errors (#717) Signed-off-by: NilashishC --- .github/workflows/codecoverage.yml | 2 +- a.txt | 0 tests/integration/targets/nxos_aaa_server/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_aaa_server/tasks/nxapi.yaml | 3 +-- .../targets/nxos_aaa_server_host/tasks/cli.yaml | 3 +-- .../targets/nxos_aaa_server_host/tasks/nxapi.yaml | 3 +-- .../targets/nxos_acl_interfaces/tasks/cli.yaml | 3 +-- .../targets/nxos_acl_interfaces/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_acls/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_acls/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_banner/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_banner/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_bfd_global/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_bfd_global/tasks/nxapi.yaml | 3 +-- .../targets/nxos_bfd_interfaces/tasks/cli.yaml | 3 +-- .../targets/nxos_bfd_interfaces/tasks/nxapi.yaml | 2 +- .../targets/nxos_bgp_address_family/tasks/cli.yaml | 2 +- .../targets/nxos_bgp_address_family/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_bgp_global/tasks/cli.yaml | 2 +- .../integration/targets/nxos_bgp_global/tasks/nxapi.yaml | 2 +- .../nxos_bgp_neighbor_address_family/tasks/cli.yaml | 2 +- .../nxos_bgp_neighbor_address_family/tasks/nxapi.yaml | 2 +- .../integration/targets/nxos_bgp_templates/tasks/cli.yaml | 2 +- .../targets/nxos_bgp_templates/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_command/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_command/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_config/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_config/tasks/cli_config.yaml | 2 +- tests/integration/targets/nxos_config/tasks/nxapi.yaml | 3 +-- .../targets/nxos_config/tasks/redirection.yaml | 2 +- tests/integration/targets/nxos_devicealias/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_evpn_global/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_evpn_global/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_facts/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_facts/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_feature/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_feature/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_file_copy/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_gir/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_gir/tasks/nxapi.yaml | 3 +-- .../targets/nxos_gir_profile_management/tasks/cli.yaml | 3 +-- .../targets/nxos_gir_profile_management/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_hostname/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_hostname/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_hsrp/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml | 3 +-- .../targets/nxos_hsrp_interfaces/tasks/cli.yaml | 3 +-- .../targets/nxos_hsrp_interfaces/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_igmp/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_igmp/tasks/nxapi.yaml | 3 +-- .../targets/nxos_igmp_interface/tasks/cli.yaml | 3 +-- .../targets/nxos_igmp_interface/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_igmp_snooping/tasks/cli.yaml | 3 +-- .../targets/nxos_igmp_snooping/tasks/nxapi.yaml | 3 +-- .../targets/nxos_install_os/tasks/httpapi.yaml | 3 +-- .../targets/nxos_install_os/tasks/network_cli.yaml | 3 +-- tests/integration/targets/nxos_interfaces/tasks/cli.yaml | 2 +- .../integration/targets/nxos_interfaces/tasks/nxapi.yaml | 2 +- .../integration/targets/nxos_l2_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_l2_interfaces/tasks/nxapi.yaml | 2 +- .../integration/targets/nxos_l3_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_l3_interfaces/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_lacp/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_lacp/tasks/nxapi.yaml | 2 +- .../targets/nxos_lacp_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_lacp_interfaces/tasks/nxapi.yaml | 2 +- .../targets/nxos_lag_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_lag_interfaces/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_lldp_global/tasks/cli.yaml | 2 +- .../integration/targets/nxos_lldp_global/tasks/nxapi.yaml | 2 +- .../targets/nxos_lldp_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_lldp_interfaces/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_logging/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_logging/tasks/nxapi.yaml | 3 +-- .../targets/nxos_logging_global/tasks/cli.yaml | 2 +- .../targets/nxos_logging_global/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_ntp/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_ntp/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_ntp_global/tasks/cli.yaml | 2 +- .../integration/targets/nxos_ntp_global/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_ntp_options/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_ntp_options/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_nxapi/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml | 8 +++----- .../targets/nxos_ospf_interfaces/tasks/cli.yaml | 2 +- .../targets/nxos_ospf_interfaces/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_ospfv2/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_ospfv3/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml | 2 +- .../targets/nxos_overlay_global/tasks/cli.yaml | 3 +-- .../targets/nxos_overlay_global/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_pim/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_pim/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_pim_interface/tasks/cli.yaml | 3 +-- .../targets/nxos_pim_interface/tasks/nxapi.yaml | 3 +-- .../targets/nxos_pim_rp_address/tasks/cli.yaml | 3 +-- .../targets/nxos_pim_rp_address/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_prefix_lists/tasks/cli.yaml | 2 +- .../targets/nxos_prefix_lists/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_reboot/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_reboot/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_rollback/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_rollback/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_route_maps/tasks/cli.yaml | 2 +- .../integration/targets/nxos_route_maps/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_rpm/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_rpm/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_smoke/tasks/cli.yaml | 6 ++---- tests/integration/targets/nxos_smoke/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_snapshot/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml | 3 +-- .../targets/nxos_snmp_community/tasks/cli.yaml | 3 +-- .../targets/nxos_snmp_community/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_snmp_contact/tasks/cli.yaml | 3 +-- .../targets/nxos_snmp_contact/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_snmp_host/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_snmp_location/tasks/cli.yaml | 3 +-- .../targets/nxos_snmp_location/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_snmp_server/tasks/cli.yaml | 2 +- .../integration/targets/nxos_snmp_server/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_snmp_traps/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_snmp_user/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_static_routes/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_system/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_system/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_telemetry/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml | 2 +- tests/integration/targets/nxos_udld/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_udld/tasks/nxapi.yaml | 3 +-- .../targets/nxos_udld_interface/tasks/cli.yaml | 3 +-- .../targets/nxos_udld_interface/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_user/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_user/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vlans/tasks/cli.yaml | 2 +- tests/integration/targets/nxos_vlans/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vpc/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_vpc/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_vpc_interface/tasks/cli.yaml | 3 +-- .../targets/nxos_vpc_interface/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vrf/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_vrf/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vrf_af/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_vrf_interface/tasks/cli.yaml | 3 +-- .../targets/nxos_vrf_interface/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vrrp/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vsan/tasks/cli.yaml | 3 +-- tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_vtp_domain/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_vtp_password/tasks/cli.yaml | 3 +-- .../targets/nxos_vtp_password/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vtp_version/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_vtp_version/tasks/nxapi.yaml | 3 +-- tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml | 3 +-- .../integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml | 3 +-- .../targets/nxos_vxlan_vtep_vni/tasks/cli.yaml | 3 +-- .../targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml | 3 +-- .../integration/targets/nxos_zone_zoneset/tasks/cli.yaml | 3 +-- 168 files changed, 170 insertions(+), 284 deletions(-) create mode 100644 a.txt diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml index b425edcc2..be2018590 100644 --- a/.github/workflows/codecoverage.yml +++ b/.github/workflows/codecoverage.yml @@ -4,7 +4,7 @@ name: Code Coverage on: # yamllint disable-line rule:truthy push: pull_request: - branches: [ main ] + branches: [main] jobs: codecoverage: diff --git a/a.txt b/a.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml b/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml b/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml b/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_aaa_server_host/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml index f41fb7360..3e5e72a07 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml index 86c82adda..59a0777c5 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_acls/tasks/cli.yaml b/tests/integration/targets/nxos_acls/tasks/cli.yaml index c34726ef5..3e5e72a07 100644 --- a/tests/integration/targets/nxos_acls/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_acls/tasks/nxapi.yaml b/tests/integration/targets/nxos_acls/tasks/nxapi.yaml index e0ebc3f54..59a0777c5 100644 --- a/tests/integration/targets/nxos_acls/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_banner/tasks/cli.yaml b/tests/integration/targets/nxos_banner/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_banner/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_banner/tasks/nxapi.yaml b/tests/integration/targets/nxos_banner/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_banner/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml b/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_bfd_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_bfd_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml index 9aa0d8690..e3e64747b 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_bgp_address_family/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_bgp_neighbor_address_family/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml b/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_bgp_templates/tasks/cli.yaml +++ b/tests/integration/targets/nxos_bgp_templates/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/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml b/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_bgp_templates/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_bgp_templates/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/tests/integration/targets/nxos_command/tasks/cli.yaml b/tests/integration/targets/nxos_command/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_command/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_command/tasks/nxapi.yaml b/tests/integration/targets/nxos_command/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_command/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_config/tasks/cli.yaml b/tests/integration/targets/nxos_config/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_config/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_config/tasks/cli_config.yaml b/tests/integration/targets/nxos_config/tasks/cli_config.yaml index 4c960185d..79b7f90ab 100644 --- a/tests/integration/targets/nxos_config/tasks/cli_config.yaml +++ b/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/tests/integration/targets/nxos_config/tasks/nxapi.yaml b/tests/integration/targets/nxos_config/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_config/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_config/tasks/redirection.yaml b/tests/integration/targets/nxos_config/tasks/redirection.yaml index 0ef757aef..dde1662ea 100644 --- a/tests/integration/targets/nxos_config/tasks/redirection.yaml +++ b/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/tests/integration/targets/nxos_devicealias/tasks/cli.yaml b/tests/integration/targets/nxos_devicealias/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_devicealias/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml b/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_evpn_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_evpn_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml b/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_evpn_vni/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml b/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_facts/tasks/cli.yaml b/tests/integration/targets/nxos_facts/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_facts/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_facts/tasks/nxapi.yaml b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_feature/tasks/cli.yaml b/tests/integration/targets/nxos_feature/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_feature/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_feature/tasks/nxapi.yaml b/tests/integration/targets/nxos_feature/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_feature/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_file_copy/tasks/cli.yaml b/tests/integration/targets/nxos_file_copy/tasks/cli.yaml index 311e39414..d3d521f2a 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml b/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_gir/tasks/cli.yaml b/tests/integration/targets/nxos_gir/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_gir/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_gir/tasks/nxapi.yaml b/tests/integration/targets/nxos_gir/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_gir/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml b/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_gir_profile_management/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml b/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_gir_profile_management/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_hostname/tasks/cli.yaml b/tests/integration/targets/nxos_hostname/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_hostname/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml b/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_hostname/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_hsrp/tasks/cli.yaml b/tests/integration/targets/nxos_hsrp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_hsrp/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml b/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_hsrp/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml index 9aa0d8690..e3e64747b 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_hsrp_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_igmp/tasks/cli.yaml b/tests/integration/targets/nxos_igmp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_igmp/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml b/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_igmp/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml b/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_igmp_interface/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml b/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_igmp_snooping/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml b/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml b/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml index 555aa8358..acefd4a4c 100644 --- a/tests/integration/targets/nxos_install_os/tasks/httpapi.yaml +++ b/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/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml b/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml index 476745353..df97b28bc 100644 --- a/tests/integration/targets/nxos_install_os/tasks/network_cli.yaml +++ b/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/tests/integration/targets/nxos_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_lacp/tasks/cli.yaml b/tests/integration/targets/nxos_lacp/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_lacp/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml b/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_lacp/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/tests/integration/targets/nxos_lacp_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml b/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml index 3bff52013..bb0e65506 100644 --- a/tests/integration/targets/nxos_lldp_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml index e0ebc3f54..59a0777c5 100644 --- a/tests/integration/targets/nxos_lldp_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml index c34726ef5..3e5e72a07 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml index e0ebc3f54..59a0777c5 100644 --- a/tests/integration/targets/nxos_lldp_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_logging/tasks/cli.yaml b/tests/integration/targets/nxos_logging/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_logging/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_logging/tasks/nxapi.yaml b/tests/integration/targets/nxos_logging/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_logging/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_logging_global/tasks/cli.yaml b/tests/integration/targets/nxos_logging_global/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_logging_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_logging_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ntp/tasks/cli.yaml b/tests/integration/targets/nxos_ntp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_ntp/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_ntp/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml b/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_ntp_auth/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml b/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_ntp_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_ntp_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml b/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_ntp_options/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml b/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_ntp_options/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_nxapi/tasks/cli.yaml b/tests/integration/targets/nxos_nxapi/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_nxapi/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml b/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml index 25cdd4904..0b2e4f778 100644 --- a/tests/integration/targets/nxos_nxapi/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml b/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_ospf_interfaces/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml b/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_ospfv2/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_ospfv2/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml b/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_ospfv3/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml b/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_ospfv3/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml b/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml b/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_overlay_global/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_pim/tasks/cli.yaml b/tests/integration/targets/nxos_pim/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_pim/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_pim/tasks/nxapi.yaml b/tests/integration/targets/nxos_pim/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_pim/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml b/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_pim_interface/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_pim_interface/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml b/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_pim_rp_address/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml b/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_pim_rp_address/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml b/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_prefix_lists/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml b/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_prefix_lists/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_reboot/tasks/cli.yaml b/tests/integration/targets/nxos_reboot/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_reboot/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml b/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml index 57e91e216..cdee9a584 100644 --- a/tests/integration/targets/nxos_reboot/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_rollback/tasks/cli.yaml b/tests/integration/targets/nxos_rollback/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_rollback/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml b/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/tests/integration/targets/nxos_rollback/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_route_maps/tasks/cli.yaml b/tests/integration/targets/nxos_route_maps/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_route_maps/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml b/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_route_maps/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_rpm/tasks/cli.yaml b/tests/integration/targets/nxos_rpm/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_rpm/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml b/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/tests/integration/targets/nxos_rpm/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_smoke/tasks/cli.yaml b/tests/integration/targets/nxos_smoke/tasks/cli.yaml index 1fa8d4e11..b335e711c 100644 --- a/tests/integration/targets/nxos_smoke/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml b/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml index f3a565f93..52aa1a100 100644 --- a/tests/integration/targets/nxos_smoke/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snapshot/tasks/cli.yaml b/tests/integration/targets/nxos_snapshot/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snapshot/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml b/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snapshot/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snmp_community/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snmp_community/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snmp_contact/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snmp_contact/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snmp_host/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snmp_host/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snmp_location/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snmp_location/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml index 5cb76e671..4ae68868c 100644 --- a/tests/integration/targets/nxos_snmp_server/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snmp_traps/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snmp_traps/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml b/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_snmp_user/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml b/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_snmp_user/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_static_routes/tasks/cli.yaml b/tests/integration/targets/nxos_static_routes/tasks/cli.yaml index e22d5c622..fd8d12e79 100644 --- a/tests/integration/targets/nxos_static_routes/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_system/tasks/cli.yaml b/tests/integration/targets/nxos_system/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_system/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_system/tasks/nxapi.yaml b/tests/integration/targets/nxos_system/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_system/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_telemetry/tasks/cli.yaml b/tests/integration/targets/nxos_telemetry/tasks/cli.yaml index 311e39414..d3d521f2a 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml b/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml index 18bf1b6ef..5fec0f43b 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_udld/tasks/cli.yaml b/tests/integration/targets/nxos_udld/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_udld/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_udld/tasks/nxapi.yaml b/tests/integration/targets/nxos_udld/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_udld/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml b/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_udld_interface/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_udld_interface/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_user/tasks/cli.yaml b/tests/integration/targets/nxos_user/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_user/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_user/tasks/nxapi.yaml b/tests/integration/targets/nxos_user/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_user/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vlans/tasks/cli.yaml b/tests/integration/targets/nxos_vlans/tasks/cli.yaml index 9e4fb34bc..e3e64747b 100644 --- a/tests/integration/targets/nxos_vlans/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml b/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vlans/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vpc/tasks/cli.yaml b/tests/integration/targets/nxos_vpc/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vpc/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml b/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vpc/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml b/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml index f6096901f..988ef2894 100644 --- a/tests/integration/targets/nxos_vpc_interface/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vrf/tasks/cli.yaml b/tests/integration/targets/nxos_vrf/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vrf/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vrf/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml b/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml index f6096901f..988ef2894 100644 --- a/tests/integration/targets/nxos_vrf_af/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vrf_af/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml b/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vrf_interface/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vrrp/tasks/cli.yaml b/tests/integration/targets/nxos_vrrp/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vrrp/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml b/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vrrp/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vsan/tasks/cli.yaml b/tests/integration/targets/nxos_vsan/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vsan/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml b/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vtp_domain/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml b/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/tests/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml b/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vtp_password/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml b/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml index b4ed55204..5fec0f43b 100644 --- a/tests/integration/targets/nxos_vtp_password/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml b/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vtp_version/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml b/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/tests/integration/targets/nxos_vtp_version/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml b/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml index b4ed55204..74961c395 100644 --- a/tests/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/cli.yaml +++ b/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/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml b/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml index b4ed55204..6a7129481 100644 --- a/tests/integration/targets/nxos_vxlan_vtep_vni/tasks/nxapi.yaml +++ b/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/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml b/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml index f6096901f..d3d521f2a 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tasks/cli.yaml +++ b/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 }}" From ca43fe67c1584a1aea09430f5f2a7cb4e50041d1 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Sat, 29 Jul 2023 09:24:38 +0530 Subject: [PATCH 114/166] Fix fqcn[deep] warnings (#719) * Fix fqcn[deep] warnings Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/nxos.yaml | 3 + plugins/modules/nxos_devicealias.py | 551 ++++++++++- plugins/modules/nxos_vsan.py | 355 ++++++- plugins/modules/nxos_zone_zoneset.py | 889 +++++++++++++++++- plugins/modules/storage/__init__.py | 0 plugins/modules/storage/nxos_devicealias.py | 550 ----------- plugins/modules/storage/nxos_vsan.py | 354 ------- plugins/modules/storage/nxos_zone_zoneset.py | 888 ----------------- .../modules/network/nxos/storage/__init__.py | 0 .../{storage => }/test_nxos_devicealias.py | 6 +- .../nxos/{storage => }/test_nxos_vsan.py | 6 +- .../{storage => }/test_nxos_zone_zoneset.py | 106 ++- 12 files changed, 1883 insertions(+), 1825 deletions(-) create mode 100644 changelogs/fragments/nxos.yaml mode change 120000 => 100644 plugins/modules/nxos_devicealias.py mode change 120000 => 100644 plugins/modules/nxos_vsan.py mode change 120000 => 100644 plugins/modules/nxos_zone_zoneset.py delete mode 100644 plugins/modules/storage/__init__.py delete mode 100644 plugins/modules/storage/nxos_devicealias.py delete mode 100644 plugins/modules/storage/nxos_vsan.py delete mode 100644 plugins/modules/storage/nxos_zone_zoneset.py delete mode 100644 tests/unit/modules/network/nxos/storage/__init__.py rename tests/unit/modules/network/nxos/{storage => }/test_nxos_devicealias.py (98%) rename tests/unit/modules/network/nxos/{storage => }/test_nxos_vsan.py (97%) rename tests/unit/modules/network/nxos/{storage => }/test_nxos_zone_zoneset.py (90%) diff --git a/changelogs/fragments/nxos.yaml b/changelogs/fragments/nxos.yaml new file mode 100644 index 000000000..53eb6356c --- /dev/null +++ b/changelogs/fragments/nxos.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Drop storage sub-directory and move MDS modules to top-level. diff --git a/plugins/modules/nxos_devicealias.py b/plugins/modules/nxos_devicealias.py deleted file mode 120000 index 94e80bde3..000000000 --- a/plugins/modules/nxos_devicealias.py +++ /dev/null @@ -1 +0,0 @@ -storage/nxos_devicealias.py \ No newline at end of file diff --git a/plugins/modules/nxos_devicealias.py b/plugins/modules/nxos_devicealias.py new file mode 100644 index 000000000..71d4ebb67 --- /dev/null +++ b/plugins/modules/nxos_devicealias.py @@ -0,0 +1,550 @@ +#!/usr/bin/python +# Copyright: Ansible Project +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +DOCUMENTATION = """ +module: nxos_devicealias +short_description: Configuration of device alias for Cisco NXOS MDS Switches. +description: +- Configuration of device alias for Cisco MDS NXOS. +version_added: 1.0.0 +author: +- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) +notes: +- Tested against Cisco MDS NX-OS 8.4(1) +options: + distribute: + description: + - Enable/Disable device-alias distribution + type: bool + mode: + description: + - Mode of devices-alias, basic or enhanced + choices: + - basic + - enhanced + type: str + da: + description: + - List of device-alias to be added or removed + type: list + elements: dict + suboptions: + name: + description: + - Name of the device-alias to be added or removed + required: true + type: str + pwwn: + description: + - pwwn to which the name needs to be associated with + type: str + remove: + description: + - Removes the device-alias if set to True + type: bool + default: false + rename: + description: + - List of device-alias to be renamed + type: list + elements: dict + suboptions: + old_name: + description: + - Old name of the device-alias that needs to be renamed + required: true + type: str + new_name: + description: + - New name of the device-alias + required: true + type: str +""" + +EXAMPLES = """ +- name: Test that device alias module works + cisco.nxos.nxos_devicealias: + da: + - name: test1_add + pwwn: 56:2:22:11:22:88:11:67 + - name: test2_add + pwwn: 65:22:22:11:22:22:11:d + - name: dev1 + remove: true + - name: dev2 + remove: true + distribute: true + mode: enhanced + rename: + - new_name: bcd + old_name: abc + - new_name: bcd1 + old_name: abc1 + + +""" + +RETURN = """ +commands: + description: commands sent to the device + returned: always + type: list + sample: + - terminal dont-ask + - device-alias database + - device-alias name somename pwwn 10:00:00:00:89:a1:01:03 + - device-alias name somename1 pwwn 10:00:00:00:89:a1:02:03 + - device-alias commit + - no terminal dont-ask +""" + +import string + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + load_config, + run_commands, +) + + +__metaclass__ = type + +VALID_DA_CHARS = ("-", "_", "$", "^") + + +class showDeviceAliasStatus(object): + """docstring for showDeviceAliasStatus""" + + def __init__(self, module): + self.module = module + self.distribute = "" + self.mode = "" + self.locked = False + self.update() + + def execute_show_cmd(self, cmd): + output = execute_show_command(cmd, self.module)[0] + return output + + def update(self): + command = "show device-alias status" + output = self.execute_show_cmd(command).split("\n") + for o in output: + if "Fabric Distribution" in o: + self.distribute = o.split(":")[1].strip().lower() + if "Mode" in o: + self.mode = o.split("Mode:")[1].strip().lower() + if "Locked" in o: + self.locked = True + + def isLocked(self): + return self.locked + + def getDistribute(self): + return self.distribute + + def getMode(self): + return self.mode + + +class showDeviceAliasDatabase(object): + """docstring for showDeviceAliasDatabase""" + + def __init__(self, module): + self.module = module + self.da_dict = {} + self.update() + + def execute_show_cmd(self, cmd): + output = execute_show_command(cmd, self.module)[0] + return output + + def update(self): + command = "show device-alias database" + # output = execute_show_command(command, self.module)[0].split("\n") + output = self.execute_show_cmd(command) + self.da_list = output.split("\n") + for eachline in self.da_list: + if "device-alias" in eachline: + sv = eachline.strip().split() + self.da_dict[sv[2]] = sv[4] + + def isNameInDaDatabase(self, name): + return name in self.da_dict.keys() + + def isPwwnInDaDatabase(self, pwwn): + newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) + return newpwwn in self.da_dict.values() + + def isNamePwwnPresentInDatabase(self, name, pwwn): + newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) + if name in self.da_dict.keys(): + if newpwwn == self.da_dict[name]: + return True + return False + + def getPwwnByName(self, name): + if name in self.da_dict.keys(): + return self.da_dict[name] + else: + return None + + def getNameByPwwn(self, pwwn): + newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) + for n, p in self.da_dict.items(): + if p == newpwwn: + return n + return None + + +def isPwwnValid(pwwn): + pwwnsplit = pwwn.split(":") + if len(pwwnsplit) != 8: + return False + for eachpwwnsplit in pwwnsplit: + if len(eachpwwnsplit) > 2 or len(eachpwwnsplit) < 1: + return False + if not all(c in string.hexdigits for c in eachpwwnsplit): + return False + return True + + +def isNameValid(name): + if not name[0].isalpha(): + # Illegal first character. Name must start with a letter + return False + if len(name) > 64: + return False + for character in name: + if not character.isalnum() and character not in VALID_DA_CHARS: + return False + return True + + +def execute_show_command(command, module, command_type="cli_show"): + output = "text" + commands = [{"command": command, "output": output}] + out = run_commands(module, commands) + return out + + +def flatten_list(command_lists): + flat_command_list = [] + for command in command_lists: + if isinstance(command, list): + flat_command_list.extend(command) + else: + flat_command_list.append(command) + return flat_command_list + + +def main(): + element_spec = dict( + name=dict(required=True, type="str"), + pwwn=dict(type="str"), + remove=dict(type="bool", default=False), + ) + + element_spec_rename = dict( + old_name=dict(required=True, type="str"), + new_name=dict(required=True, type="str"), + ) + + argument_spec = dict( + distribute=dict(type="bool"), + mode=dict(type="str", choices=["enhanced", "basic"]), + da=dict(type="list", elements="dict", options=element_spec), + rename=dict(type="list", elements="dict", options=element_spec_rename), + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + warnings = list() + messages = list() + commands_to_execute = list() + result = {"changed": False} + + distribute = module.params["distribute"] + mode = module.params["mode"] + da = module.params["da"] + rename = module.params["rename"] + + # Step 0.0: Validate syntax of name and pwwn + # Also validate syntax of rename arguments + if da is not None: + for eachdict in da: + name = eachdict["name"] + pwwn = eachdict["pwwn"] + remove = eachdict["remove"] + if pwwn is not None: + pwwn = pwwn.lower() + if not remove: + if pwwn is None: + module.fail_json( + msg="This device alias name " + + str(name) + + " which needs to be added, does not have pwwn specified. Please specify a valid pwwn", + ) + if not isNameValid(name): + module.fail_json( + msg="This pwwn name is invalid : " + + str(name) + + ". Note that name cannot be more than 64 alphanumeric chars, " + + "it must start with a letter, and can only contain these characters: " + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), + ) + if not isPwwnValid(pwwn): + module.fail_json( + msg="This pwwn is invalid : " + + str(pwwn) + + ". Please check that its a valid pwwn", + ) + if rename is not None: + for eachdict in rename: + oldname = eachdict["old_name"] + newname = eachdict["new_name"] + if not isNameValid(oldname): + module.fail_json( + msg="This pwwn name is invalid : " + + str(oldname) + + ". Note that name cannot be more than 64 alphanumeric chars, " + + "it must start with a letter, and can only contain these characters: " + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), + ) + if not isNameValid(newname): + module.fail_json( + msg="This pwwn name is invalid : " + + str(newname) + + ". Note that name cannot be more than 64 alphanumeric chars, " + + "it must start with a letter, and can only contain these characters: " + + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), + ) + + # Step 0.1: Check DA status + shDAStausObj = showDeviceAliasStatus(module) + d = shDAStausObj.getDistribute() + m = shDAStausObj.getMode() + if shDAStausObj.isLocked(): + module.fail_json(msg="device-alias has acquired lock on the switch. Hence cannot procced.") + + # Step 1: Process distribute + commands = [] + if distribute is not None: + if distribute: + # playbook has distribute as True(enabled) + if d == "disabled": + # but switch distribute is disabled(false), so set it to + # true(enabled) + commands.append("device-alias distribute") + messages.append("device-alias distribute changed from disabled to enabled") + else: + messages.append( + "device-alias distribute remains unchanged. current distribution mode is enabled", + ) + else: + # playbook has distribute as False(disabled) + if d == "enabled": + # but switch distribute is enabled(true), so set it to + # false(disabled) + commands.append("no device-alias distribute") + messages.append("device-alias distribute changed from enabled to disabled") + else: + messages.append( + "device-alias distribute remains unchanged. current distribution mode is disabled", + ) + + cmds = flatten_list(commands) + if cmds: + commands_to_execute = commands_to_execute + cmds + if module.check_mode: + # Check mode implemented at the da_add/da_remove stage + pass + else: + result["changed"] = True + load_config(module, cmds) + + # Step 2: Process mode + commands = [] + if mode is not None: + if mode == "basic": + # playbook has mode as basic + if m == "enhanced": + # but switch mode is enhanced, so set it to basic + commands.append("no device-alias mode enhanced") + messages.append("device-alias mode changed from enhanced to basic") + else: + messages.append("device-alias mode remains unchanged. current mode is basic") + + else: + # playbook has mode as enhanced + if m == "basic": + # but switch mode is basic, so set it to enhanced + commands.append("device-alias mode enhanced") + messages.append("device-alias mode changed from basic to enhanced") + else: + messages.append("device-alias mode remains unchanged. current mode is enhanced") + + if commands: + if distribute: + commands.append("device-alias commit") + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] + else: + if distribute is None and d == "enabled": + commands.append("device-alias commit") + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] + + cmds = flatten_list(commands) + + if cmds: + commands_to_execute = commands_to_execute + cmds + if module.check_mode: + # Check mode implemented at the end + pass + else: + result["changed"] = True + load_config(module, cmds) + + # Step 3: Process da + commands = [] + shDADatabaseObj = showDeviceAliasDatabase(module) + if da is not None: + da_remove_list = [] + da_add_list = [] + for eachdict in da: + name = eachdict["name"] + pwwn = eachdict["pwwn"] + remove = eachdict["remove"] + if pwwn is not None: + pwwn = pwwn.lower() + if remove: + if shDADatabaseObj.isNameInDaDatabase(name): + commands.append("no device-alias name " + name) + da_remove_list.append(name) + else: + messages.append( + name + + " - This device alias name is not in switch device-alias database, hence cannot be removed.", + ) + else: + if shDADatabaseObj.isNamePwwnPresentInDatabase(name, pwwn): + messages.append( + name + + " : " + + pwwn + + " - This device alias name,pwwn is already in switch device-alias database, hence nothing to configure", + ) + else: + if shDADatabaseObj.isNameInDaDatabase(name): + module.fail_json( + msg=name + + " - This device alias name is already present in switch device-alias database but assigned to another pwwn (" + + shDADatabaseObj.getPwwnByName(name) + + ") hence cannot be added", + ) + + elif shDADatabaseObj.isPwwnInDaDatabase(pwwn): + module.fail_json( + msg=pwwn + + " - This device alias pwwn is already present in switch device-alias database but assigned to another name (" + + shDADatabaseObj.getNameByPwwn(pwwn) + + ") hence cannot be added", + ) + + else: + commands.append("device-alias name " + name + " pwwn " + pwwn) + da_add_list.append(name) + + if len(da_add_list) != 0 or len(da_remove_list) != 0: + commands = ["device-alias database"] + commands + if distribute: + commands.append("device-alias commit") + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] + else: + if distribute is None and d == "enabled": + commands.append("device-alias commit") + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] + + cmds = flatten_list(commands) + if cmds: + commands_to_execute = commands_to_execute + cmds + if module.check_mode: + # Check mode implemented at the end + pass + else: + result["changed"] = True + load_config(module, cmds) + if len(da_remove_list) != 0: + messages.append( + "the required device-alias were removed. " + ",".join(da_remove_list), + ) + if len(da_add_list) != 0: + messages.append( + "the required device-alias were added. " + ",".join(da_add_list), + ) + + # Step 5: Process rename + commands = [] + if rename is not None: + for eachdict in rename: + oldname = eachdict["old_name"] + newname = eachdict["new_name"] + if shDADatabaseObj.isNameInDaDatabase(newname): + module.fail_json( + changed=False, + commands=cmds, + msg=newname + + " - this name is already present in the device-alias database, hence we cannot rename " + + oldname + + " with this one", + ) + if shDADatabaseObj.isNameInDaDatabase(oldname): + commands.append("device-alias rename " + oldname + " " + newname) + else: + module.fail_json( + changed=False, + commands=cmds, + msg=oldname + + " - this name is not present in the device-alias database, hence we cannot rename.", + ) + + if len(commands) != 0: + commands = ["device-alias database"] + commands + if distribute: + commands.append("device-alias commit") + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] + else: + if distribute is None and d == "enabled": + commands.append("device-alias commit") + commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] + cmds = flatten_list(commands) + if cmds: + commands_to_execute = commands_to_execute + cmds + if module.check_mode: + # Check mode implemented at the end + pass + else: + result["changed"] = True + load_config(module, cmds) + + # Step END: check for 'check' mode + if module.check_mode: + module.exit_json( + changed=False, + commands=commands_to_execute, + msg="Check Mode: No cmds issued to the hosts", + ) + + result["messages"] = messages + result["commands"] = commands_to_execute + result["warnings"] = warnings + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/nxos_vsan.py b/plugins/modules/nxos_vsan.py deleted file mode 120000 index b472802a2..000000000 --- a/plugins/modules/nxos_vsan.py +++ /dev/null @@ -1 +0,0 @@ -storage/nxos_vsan.py \ No newline at end of file diff --git a/plugins/modules/nxos_vsan.py b/plugins/modules/nxos_vsan.py new file mode 100644 index 000000000..d95d95a96 --- /dev/null +++ b/plugins/modules/nxos_vsan.py @@ -0,0 +1,354 @@ +#!/usr/bin/python +# Copyright: Ansible Project +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +DOCUMENTATION = """ +module: nxos_vsan +short_description: Configuration of vsan for Cisco NXOS MDS Switches. +description: +- Configuration of vsan for Cisco MDS NXOS. +version_added: 1.0.0 +author: +- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) +notes: +- Tested against Cisco MDS NX-OS 8.4(1) +options: + vsan: + description: + - List of vsan details to be added or removed + type: list + elements: dict + suboptions: + id: + description: + - Vsan id + required: true + type: int + name: + description: + - Name of the vsan + type: str + suspend: + description: + - suspend the vsan if True + type: bool + remove: + description: + - Removes the vsan if True + type: bool + interface: + description: + - List of vsan's interfaces to be added + type: list + elements: str +""" + +EXAMPLES = """ +- name: Test that vsan module works + cisco.nxos.nxos_vsan: + vsan: + - id: 922 + interface: + - fc1/1 + - fc1/2 + - port-channel 1 + name: vsan-SAN-A + remove: false + suspend: false + - id: 923 + interface: + - fc1/11 + - fc1/21 + - port-channel 2 + name: vsan-SAN-B + remove: false + suspend: true + - id: 1923 + name: vsan-SAN-Old + remove: true +""" + +RETURN = """ +commands: + description: commands sent to the device + returned: always + type: list + sample: + - terminal dont-ask + - vsan database + - vsan 922 interface fc1/40 + - vsan 922 interface port-channel 155 + - no terminal dont-ask +""" + +import re + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + load_config, + run_commands, +) + + +__metaclass__ = type + + +class Vsan(object): + def __init__(self, vsanid): + self.vsanid = vsanid + self.vsanname = None + self.vsanstate = None + self.vsanoperstate = None + self.vsaninterfaces = [] + + +class GetVsanInfoFromSwitch(object): + """docstring for GetVsanInfoFromSwitch""" + + def __init__(self, module): + self.module = module + self.vsaninfo = {} + self.processShowVsan() + self.processShowVsanMembership() + + def execute_show_vsan_cmd(self): + output = execute_show_command("show vsan", self.module)[0] + return output + + def execute_show_vsan_mem_cmd(self): + output = execute_show_command("show vsan membership", self.module)[0] + return output + + def processShowVsan(self): + patv = r"^vsan\s+(\d+)\s+information" + patnamestate = "name:(.*)state:(.*)" + patoperstate = "operational state:(.*)" + + output = self.execute_show_vsan_cmd().split("\n") + for o in output: + z = re.match(patv, o.strip()) + if z: + v = z.group(1).strip() + self.vsaninfo[v] = Vsan(v) + + z1 = re.match(patnamestate, o.strip()) + if z1: + n = z1.group(1).strip() + s = z1.group(2).strip() + self.vsaninfo[v].vsanname = n + self.vsaninfo[v].vsanstate = s + + z2 = re.match(patoperstate, o.strip()) + if z2: + oper = z2.group(1).strip() + self.vsaninfo[v].vsanoperstate = oper + + # 4094/4079 vsan is always present + self.vsaninfo["4079"] = Vsan("4079") + self.vsaninfo["4094"] = Vsan("4094") + + def processShowVsanMembership(self): + patv = r"^vsan\s+(\d+).*" + output = self.execute_show_vsan_mem_cmd().split("\n") + memlist = [] + v = None + for o in output: + z = re.match(patv, o.strip()) + if z: + if v is not None: + self.vsaninfo[v].vsaninterfaces = memlist + memlist = [] + v = z.group(1) + if "interfaces" not in o: + llist = o.strip().split() + memlist = memlist + llist + self.vsaninfo[v].vsaninterfaces = memlist + + def getVsanInfoObjects(self): + return self.vsaninfo + + +def execute_show_command(command, module, command_type="cli_show"): + output = "text" + commands = [{"command": command, "output": output}] + return run_commands(module, commands) + + +def flatten_list(command_lists): + flat_command_list = [] + for command in command_lists: + if isinstance(command, list): + flat_command_list.extend(command) + else: + flat_command_list.append(command) + return flat_command_list + + +def main(): + vsan_element_spec = dict( + id=dict(required=True, type="int"), + name=dict(type="str"), + remove=dict(type="bool"), + suspend=dict(type="bool"), + interface=dict(type="list", elements="str"), + ) + + argument_spec = dict(vsan=dict(type="list", elements="dict", options=vsan_element_spec)) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + warnings = list() + messages = list() + commands_executed = list() + result = {"changed": False} + + obj = GetVsanInfoFromSwitch(module) + dictSwVsanObjs = obj.getVsanInfoObjects() + + commands = [] + vsan_list = module.params["vsan"] + + for eachvsan in vsan_list: + vsanid = str(eachvsan["id"]) + vsanname = eachvsan["name"] + vsanremove = eachvsan["remove"] + vsansuspend = eachvsan["suspend"] + vsaninterface_list = eachvsan["interface"] + + if int(vsanid) < 1 or int(vsanid) >= 4095: + module.fail_json( + msg=vsanid + " - This is an invalid vsan. Supported vsan range is 1-4094", + ) + + if vsanid in dictSwVsanObjs.keys(): + sw_vsanid = vsanid + sw_vsanname = dictSwVsanObjs[vsanid].vsanname + sw_vsanstate = dictSwVsanObjs[vsanid].vsanstate + sw_vsaninterfaces = dictSwVsanObjs[vsanid].vsaninterfaces + else: + sw_vsanid = None + sw_vsanname = None + sw_vsanstate = None + sw_vsaninterfaces = [] + + if vsanremove: + # Negative case: + if vsanid == "4079" or vsanid == "4094": + messages.append(str(vsanid) + " is a reserved vsan, hence cannot be removed") + continue + if vsanid == sw_vsanid: + commands.append("no vsan " + str(vsanid)) + messages.append("deleting the vsan " + str(vsanid)) + else: + messages.append( + "There is no vsan " + + str(vsanid) + + " present in the switch. Hence there is nothing to delete", + ) + continue + else: + # Negative case: + if vsanid == "4079" or vsanid == "4094": + messages.append( + str(vsanid) + " is a reserved vsan, and always present on the switch", + ) + else: + if vsanid == sw_vsanid: + messages.append( + "There is already a vsan " + + str(vsanid) + + " present in the switch. Hence there is nothing to configure", + ) + else: + commands.append("vsan " + str(vsanid)) + messages.append("creating vsan " + str(vsanid)) + + if vsanname is not None: + # Negative case: + if vsanid == "4079" or vsanid == "4094": + messages.append(str(vsanid) + " is a reserved vsan, and cannot be renamed") + else: + if vsanname == sw_vsanname: + messages.append( + "There is already a vsan " + + str(vsanid) + + " present in the switch, which has the name " + + vsanname + + " Hence there is nothing to configure", + ) + else: + commands.append("vsan " + str(vsanid) + " name " + vsanname) + messages.append("setting vsan name to " + vsanname + " for vsan " + str(vsanid)) + + if vsansuspend: + # Negative case: + if vsanid == "4079" or vsanid == "4094": + messages.append(str(vsanid) + " is a reserved vsan, and cannot be suspended") + else: + if sw_vsanstate == "suspended": + messages.append( + "There is already a vsan " + + str(vsanid) + + " present in the switch, which is in suspended state ", + ) + else: + commands.append("vsan " + str(vsanid) + " suspend") + messages.append("suspending the vsan " + str(vsanid)) + else: + if sw_vsanstate == "active": + messages.append( + "There is already a vsan " + + str(vsanid) + + " present in the switch, which is in active state ", + ) + else: + commands.append("no vsan " + str(vsanid) + " suspend") + messages.append("no suspending the vsan " + str(vsanid)) + + if vsaninterface_list is not None: + for each_interface_name in vsaninterface_list: + # For fcip,port-channel,vfc-port-channel need to remove the + # extra space to compare + temp = re.sub(" +", "", each_interface_name) + if temp in sw_vsaninterfaces: + messages.append( + each_interface_name + + " is already present in the vsan " + + str(vsanid) + + " interface list", + ) + else: + commands.append("vsan " + str(vsanid) + " interface " + each_interface_name) + messages.append( + "adding interface " + each_interface_name + " to vsan " + str(vsanid), + ) + + if len(commands) != 0: + commands = ["terminal dont-ask"] + ["vsan database"] + commands + ["no terminal dont-ask"] + + cmds = flatten_list(commands) + commands_executed = cmds + + if commands_executed: + if module.check_mode: + module.exit_json( + changed=False, + commands=commands_executed, + msg="Check Mode: No cmds issued to the hosts", + ) + else: + result["changed"] = True + load_config(module, commands_executed) + + result["messages"] = messages + result["commands"] = commands_executed + result["warnings"] = warnings + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/nxos_zone_zoneset.py b/plugins/modules/nxos_zone_zoneset.py deleted file mode 120000 index c9c313856..000000000 --- a/plugins/modules/nxos_zone_zoneset.py +++ /dev/null @@ -1 +0,0 @@ -storage/nxos_zone_zoneset.py \ No newline at end of file diff --git a/plugins/modules/nxos_zone_zoneset.py b/plugins/modules/nxos_zone_zoneset.py new file mode 100644 index 000000000..7c9fba30a --- /dev/null +++ b/plugins/modules/nxos_zone_zoneset.py @@ -0,0 +1,888 @@ +#!/usr/bin/python +# Copyright: Ansible Project +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +DOCUMENTATION = """ +module: nxos_zone_zoneset +short_description: Configuration of zone/zoneset for Cisco NXOS MDS Switches. +description: +- Configuration of zone/zoneset for Cisco MDS NXOS. +version_added: 1.0.0 +author: +- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) +notes: +- Tested against Cisco MDS NX-OS 8.4(1) +options: + zone_zoneset_details: + description: + - List of zone/zoneset details to be added or removed + type: list + elements: dict + suboptions: + vsan: + description: + - vsan id + required: true + type: int + mode: + description: + - mode of the zone for the vsan + choices: + - enhanced + - basic + type: str + default_zone: + description: + - default zone behaviour for the vsan + choices: + - permit + - deny + type: str + smart_zoning: + description: + - Removes the vsan if True + type: bool + zone: + description: + - List of zone options for that vsan + type: list + elements: dict + suboptions: + name: + description: + - name of the zone + required: true + type: str + remove: + description: + - Deletes the zone if True + type: bool + default: false + members: + description: + - Members of the zone that needs to be removed or added + type: list + elements: dict + suboptions: + pwwn: + description: + - pwwn member of the zone, use alias 'device_alias' as option for + device_alias member + aliases: + - device_alias + required: true + type: str + remove: + description: + - Removes member from the zone if True + type: bool + default: false + devtype: + description: + - devtype of the zone member used along with Smart zoning config + choices: + - initiator + - target + - both + type: str + zoneset: + description: + - List of zoneset options for the vsan + type: list + elements: dict + suboptions: + name: + description: + - name of the zoneset + required: true + type: str + remove: + description: + - Removes zoneset if True + type: bool + default: false + action: + description: + - activates/de-activates the zoneset + choices: + - activate + - deactivate + type: str + members: + description: + - Members of the zoneset that needs to be removed or added + type: list + elements: dict + suboptions: + name: + description: + - name of the zone that needs to be added to the zoneset or removed + from the zoneset + required: true + type: str + remove: + description: + - Removes zone member from the zoneset + type: bool + default: false +""" + +EXAMPLES = """ +- name: Test that zone/zoneset module works + cisco.nxos.nxos_zone_zoneset: + zone_zoneset_details: + - mode: enhanced + vsan: 22 + zone: + - members: + - pwwn: 11:11:11:11:11:11:11:11 + - device_alias: test123 + - pwwn: 61:61:62:62:12:12:12:12 + remove: true + name: zoneA + - members: + - pwwn: 10:11:11:11:11:11:11:11 + - pwwn: 62:62:62:62:21:21:21:21 + name: zoneB + - name: zoneC + remove: true + zoneset: + - action: activate + members: + - name: zoneA + - name: zoneB + - name: zoneC + remove: true + name: zsetname1 + - action: deactivate + name: zsetTestExtra + remove: true + - mode: basic + smart_zoning: true + vsan: 21 + zone: + - members: + - devtype: both + pwwn: 11:11:11:11:11:11:11:11 + - pwwn: 62:62:62:62:12:12:12:12 + - devtype: both + pwwn: 92:62:62:62:12:12:1a:1a + remove: true + name: zone21A + - members: + - pwwn: 10:11:11:11:11:11:11:11 + - pwwn: 62:62:62:62:21:21:21:21 + name: zone21B + zoneset: + - action: activate + members: + - name: zone21A + - name: zone21B + name: zsetname212 + +""" + +RETURN = """ +commands: + description: commands sent to the device + returned: always + type: list + sample: + - terminal dont-ask + - zone name zoneA vsan 923 + - member pwwn 11:11:11:11:11:11:11:11 + - no member device-alias test123 + - zone commit vsan 923 + - no terminal dont-ask +messages: + description: debug messages + returned: always + type: list + sample: + - "zone mode is already enhanced ,no change in zone mode configuration for vsan 922" + - "zone member '11:11:11:11:11:11:11:11' is already present in zone 'zoneA' in vsan 922 hence nothing to add" + - "zone member 'test123' is already present in zone 'zoneA' in vsan 922 hence nothing to add" + - "zone member '61:61:62:62:12:12:12:12' is not present in zone 'zoneA' in vsan 922 hence nothing to remove" + - "zone member '10:11:11:11:11:11:11:11' is already present in zone 'zoneB' in vsan 922 hence nothing to add" + - "zone member '62:62:62:62:21:21:21:21' is already present in zone 'zoneB' in vsan 922 hence nothing to add" + - "zone 'zoneC' is not present in vsan 922 , so nothing to remove" +""" + + +import re + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( + load_config, + run_commands, +) + + +__metaclass__ = type + + +class ShowZonesetActive(object): + """docstring for ShowZonesetActive""" + + def __init__(self, module, vsan): + self.vsan = vsan + self.module = module + self.activeZSName = None + self.parseCmdOutput() + + def execute_show_zoneset_active_cmd(self): + command = "show zoneset active vsan " + str(self.vsan) + " | grep zoneset" + output = execute_show_command(command, self.module)[0] + return output + + def parseCmdOutput(self): + patZoneset = r"zoneset name (\S+) vsan " + str(self.vsan) + output = self.execute_show_zoneset_active_cmd().split("\n") + if len(output) == 0: + return + else: + for line in output: + line = line.strip() + mzs = re.match(patZoneset, line.strip()) + if mzs: + self.activeZSName = mzs.group(1).strip() + return + + def isZonesetActive(self, zsname): + if zsname == self.activeZSName: + return True + return False + + +class ShowZoneset(object): + """docstring for ShowZoneset""" + + def __init__(self, module, vsan): + self.vsan = vsan + self.module = module + self.zsDetails = {} + self.parseCmdOutput() + + def execute_show_zoneset_cmd(self): + command = "show zoneset vsan " + str(self.vsan) + output = execute_show_command(command, self.module)[0] + return output + + def parseCmdOutput(self): + patZoneset = r"zoneset name (\S+) vsan " + str(self.vsan) + patZone = r"zone name (\S+) vsan " + str(self.vsan) + output = self.execute_show_zoneset_cmd().split("\n") + for line in output: + line = line.strip() + mzs = re.match(patZoneset, line.strip()) + mz = re.match(patZone, line.strip()) + if mzs: + zonesetname = mzs.group(1).strip() + self.zsDetails[zonesetname] = [] + continue + elif mz: + zonename = mz.group(1).strip() + v = self.zsDetails[zonesetname] + v.append(zonename) + self.zsDetails[zonesetname] = v + + def isZonesetPresent(self, zsname): + return zsname in self.zsDetails.keys() + + def isZonePresentInZoneset(self, zsname, zname): + if zsname in self.zsDetails.keys(): + return zname in self.zsDetails[zsname] + return False + + +class ShowZone(object): + """docstring for ShowZone""" + + def __init__(self, module, vsan): + self.vsan = vsan + self.module = module + self.zDetails = {} + self.parseCmdOutput() + + def execute_show_zone_vsan_cmd(self): + command = "show zone vsan " + str(self.vsan) + output = execute_show_command(command, self.module)[0] + return output + + def parseCmdOutput(self): + patZone = r"zone name (\S+) vsan " + str(self.vsan) + output = self.execute_show_zone_vsan_cmd().split("\n") + for line in output: + line = re.sub(r"[\[].*?[\]]", "", line) + line = " ".join(line.strip().split()) + if "init" in line: + line = line.replace("init", "initiator") + m = re.match(patZone, line) + if m: + zonename = m.group(1).strip() + self.zDetails[zonename] = [] + continue + else: + # For now we support only pwwn and device-alias under zone + # Ideally should use 'supported_choices'....but maybe next + # time. + if "pwwn" in line or "device-alias" in line: + v = self.zDetails[zonename] + v.append(line) + self.zDetails[zonename] = v + + def isZonePresent(self, zname): + return zname in self.zDetails.keys() + + def isZoneMemberPresent(self, zname, cmd): + if zname in self.zDetails.keys(): + zonememlist = self.zDetails[zname] + for eachline in zonememlist: + if cmd in eachline: + return True + return False + + def get_zDetails(self): + return self.zDetails + + +class ShowZoneStatus(object): + """docstring for ShowZoneStatus""" + + def __init__(self, module, vsan): + self.vsan = vsan + self.vsanAbsent = False + self.module = module + self.default_zone = "" + self.mode = "" + self.session = "" + self.sz = "" + self.locked = False + self.update() + + def execute_show_zone_status_cmd(self): + command = "show zone status vsan " + str(self.vsan) + output = execute_show_command(command, self.module)[0] + return output + + def update(self): + output = self.execute_show_zone_status_cmd().split("\n") + + patfordefzone = "VSAN: " + str(self.vsan) + r" default-zone:\s+(\S+).*" + patformode = r".*mode:\s+(\S+).*" + patforsession = r"^session:\s+(\S+).*" + patforsz = r".*smart-zoning:\s+(\S+).*" + for line in output: + if "is not configured" in line: + self.vsanAbsent = True + break + mdefz = re.match(patfordefzone, line.strip()) + mmode = re.match(patformode, line.strip()) + msession = re.match(patforsession, line.strip()) + msz = re.match(patforsz, line.strip()) + + if mdefz: + self.default_zone = mdefz.group(1) + if mmode: + self.mode = mmode.group(1) + if msession: + self.session = msession.group(1) + if self.session != "none": + self.locked = True + if msz: + self.sz = msz.group(1) + + def isLocked(self): + return self.locked + + def getDefaultZone(self): + return self.default_zone + + def getMode(self): + return self.mode + + def getSmartZoningStatus(self): + return self.sz + + def isVsanAbsent(self): + return self.vsanAbsent + + +def execute_show_command(command, module, command_type="cli_show"): + output = "text" + commands = [{"command": command, "output": output}] + return run_commands(module, commands) + + +def flatten_list(command_lists): + flat_command_list = [] + for command in command_lists: + if isinstance(command, list): + flat_command_list.extend(command) + else: + flat_command_list.append(command) + return flat_command_list + + +def getMemType(supported_choices, allmemkeys, default="pwwn"): + for eachchoice in supported_choices: + if eachchoice in allmemkeys: + return eachchoice + return default + + +def main(): + supported_choices = ["device_alias"] + zone_member_spec = dict( + pwwn=dict(required=True, type="str", aliases=["device_alias"]), + devtype=dict(type="str", choices=["initiator", "target", "both"]), + remove=dict(type="bool", default=False), + ) + + zone_spec = dict( + name=dict(required=True, type="str"), + members=dict(type="list", elements="dict", options=zone_member_spec), + remove=dict(type="bool", default=False), + ) + + zoneset_member_spec = dict( + name=dict(required=True, type="str"), + remove=dict(type="bool", default=False), + ) + + zoneset_spec = dict( + name=dict(type="str", required=True), + members=dict(type="list", elements="dict", options=zoneset_member_spec), + remove=dict(type="bool", default=False), + action=dict(type="str", choices=["activate", "deactivate"]), + ) + + zonedetails_spec = dict( + vsan=dict(required=True, type="int"), + mode=dict(type="str", choices=["enhanced", "basic"]), + default_zone=dict(type="str", choices=["permit", "deny"]), + smart_zoning=dict(type="bool"), + zone=dict(type="list", elements="dict", options=zone_spec), + zoneset=dict(type="list", elements="dict", options=zoneset_spec), + ) + + argument_spec = dict( + zone_zoneset_details=dict(type="list", elements="dict", options=zonedetails_spec), + ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + warnings = list() + messages = list() + commands = list() + result = {"changed": False} + + commands_executed = [] + listOfZoneDetails = module.params["zone_zoneset_details"] + for eachZoneZonesetDetail in listOfZoneDetails: + vsan = eachZoneZonesetDetail["vsan"] + op_mode = eachZoneZonesetDetail["mode"] + op_default_zone = eachZoneZonesetDetail["default_zone"] + op_smart_zoning = eachZoneZonesetDetail["smart_zoning"] + op_zone = eachZoneZonesetDetail["zone"] + op_zoneset = eachZoneZonesetDetail["zoneset"] + + # Step1: execute show zone status and get + shZoneStatusObj = ShowZoneStatus(module, vsan) + sw_default_zone = shZoneStatusObj.getDefaultZone() + sw_mode = shZoneStatusObj.getMode() + sw_smart_zoning = shZoneStatusObj.getSmartZoningStatus() + + if sw_smart_zoning.lower() == "Enabled".lower(): + sw_smart_zoning_bool = True + else: + sw_smart_zoning_bool = False + + if shZoneStatusObj.isVsanAbsent(): + module.fail_json( + msg="Vsan " + str(vsan) + " is not present in the switch. Hence cannot procced.", + ) + + if shZoneStatusObj.isLocked(): + module.fail_json( + msg="zone has acquired lock on the switch for vsan " + + str(vsan) + + ". Hence cannot procced.", + ) + + # Process zone default zone options + if op_default_zone is not None: + if op_default_zone != sw_default_zone: + if op_default_zone == "permit": + commands_executed.append("zone default-zone permit vsan " + str(vsan)) + messages.append( + "default zone configuration changed from deny to permit for vsan " + + str(vsan), + ) + else: + commands_executed.append("no zone default-zone permit vsan " + str(vsan)) + messages.append( + "default zone configuration changed from permit to deny for vsan " + + str(vsan), + ) + else: + messages.append( + "default zone is already " + + op_default_zone + + " ,no change in default zone configuration for vsan " + + str(vsan), + ) + + # Process zone mode options + if op_mode is not None: + if op_mode != sw_mode: + if op_mode == "enhanced": + commands_executed.append("zone mode enhanced vsan " + str(vsan)) + messages.append( + "zone mode configuration changed from basic to enhanced for vsan " + + str(vsan), + ) + else: + commands_executed.append("no zone mode enhanced vsan " + str(vsan)) + messages.append( + "zone mode configuration changed from enhanced to basic for vsan " + + str(vsan), + ) + else: + messages.append( + "zone mode is already " + + op_mode + + " ,no change in zone mode configuration for vsan " + + str(vsan), + ) + + # Process zone smart-zone options + if op_smart_zoning is not None: + if op_smart_zoning != sw_smart_zoning_bool: + if op_smart_zoning: + commands_executed.append("zone smart-zoning enable vsan " + str(vsan)) + messages.append("smart-zoning enabled for vsan " + str(vsan)) + else: + commands_executed.append("no zone smart-zoning enable vsan " + str(vsan)) + messages.append("smart-zoning disabled for vsan " + str(vsan)) + else: + messages.append( + "smart-zoning is already set to " + + sw_smart_zoning + + " , no change in smart-zoning configuration for vsan " + + str(vsan), + ) + + # Process zone member options + # TODO: Obviously this needs to be cleaned up properly, as there are a lot of ifelse statements which is bad + # Will take it up later becoz of time constraints + if op_zone is not None: + shZoneObj = ShowZone(module, vsan) + for eachzone in op_zone: + zname = eachzone["name"] + zmembers = eachzone["members"] + removeflag = eachzone["remove"] + if removeflag: + if shZoneObj.isZonePresent(zname): + messages.append("zone '" + zname + "' is removed from vsan " + str(vsan)) + commands_executed.append("no zone name " + zname + " vsan " + str(vsan)) + else: + messages.append( + "zone '" + + zname + + "' is not present in vsan " + + str(vsan) + + " , so nothing to remove", + ) + else: + if zmembers is None: + if shZoneObj.isZonePresent(zname): + messages.append( + "zone '" + zname + "' is already present in vsan " + str(vsan), + ) + else: + commands_executed.append("zone name " + zname + " vsan " + str(vsan)) + messages.append("zone '" + zname + "' is created in vsan " + str(vsan)) + else: + cmdmemlist = [] + for eachmem in zmembers: + memtype = getMemType(supported_choices, eachmem.keys()) + cmd = memtype.replace("_", "-") + " " + eachmem[memtype] + if op_smart_zoning or sw_smart_zoning_bool: + if eachmem["devtype"] is not None: + cmd = cmd + " " + eachmem["devtype"] + if eachmem["remove"]: + if shZoneObj.isZonePresent(zname): + if shZoneObj.isZoneMemberPresent(zname, cmd): + cmd = "no member " + cmd + cmdmemlist.append(cmd) + if op_smart_zoning and eachmem["devtype"] is not None: + messages.append( + "removing zone member '" + + eachmem[memtype] + + " of device type '" + + eachmem["devtype"] + + "' from zone '" + + zname + + "' in vsan " + + str(vsan), + ) + else: + messages.append( + "removing zone member '" + + eachmem[memtype] + + "' from zone '" + + zname + + "' in vsan " + + str(vsan), + ) + else: + if op_smart_zoning and eachmem["devtype"] is not None: + messages.append( + "zone member '" + + eachmem[memtype] + + "' of device type '" + + eachmem["devtype"] + + "' is not present in zone '" + + zname + + "' in vsan " + + str(vsan) + + " hence nothing to remove", + ) + else: + messages.append( + "zone member '" + + eachmem[memtype] + + "' is not present in zone '" + + zname + + "' in vsan " + + str(vsan) + + " hence nothing to remove", + ) + else: + messages.append( + "zone '" + + zname + + "' is not present in vsan " + + str(vsan) + + " , hence cannot remove the members", + ) + + else: + if shZoneObj.isZoneMemberPresent(zname, cmd): + if op_smart_zoning and eachmem["devtype"] is not None: + messages.append( + "zone member '" + + eachmem[memtype] + + "' of device type '" + + eachmem["devtype"] + + "' is already present in zone '" + + zname + + "' in vsan " + + str(vsan) + + " hence nothing to add", + ) + else: + messages.append( + "zone member '" + + eachmem[memtype] + + "' is already present in zone '" + + zname + + "' in vsan " + + str(vsan) + + " hence nothing to add", + ) + else: + cmd = "member " + cmd + cmdmemlist.append(cmd) + if op_smart_zoning and eachmem["devtype"] is not None: + messages.append( + "adding zone member '" + + eachmem[memtype] + + "' of device type '" + + eachmem["devtype"] + + "' to zone '" + + zname + + "' in vsan " + + str(vsan), + ) + else: + messages.append( + "adding zone member '" + + eachmem[memtype] + + "' to zone '" + + zname + + "' in vsan " + + str(vsan), + ) + if len(cmdmemlist) != 0: + commands_executed.append("zone name " + zname + " vsan " + str(vsan)) + commands_executed = commands_executed + cmdmemlist + + # Process zoneset member options + if op_zoneset is not None: + dactcmd = [] + actcmd = [] + shZonesetObj = ShowZoneset(module, vsan) + shZonesetActiveObj = ShowZonesetActive(module, vsan) + for eachzoneset in op_zoneset: + zsetname = eachzoneset["name"] + zsetmembers = eachzoneset["members"] + removeflag = eachzoneset["remove"] + actionflag = eachzoneset["action"] + if removeflag: + if shZonesetObj.isZonesetPresent(zsetname): + messages.append( + "zoneset '" + zsetname + "' is removed from vsan " + str(vsan), + ) + commands_executed.append( + "no zoneset name " + zsetname + " vsan " + str(vsan), + ) + else: + messages.append( + "zoneset '" + + zsetname + + "' is not present in vsan " + + str(vsan) + + " ,hence there is nothing to remove", + ) + else: + if zsetmembers is not None: + cmdmemlist = [] + for eachzsmem in zsetmembers: + zsetmem_name = eachzsmem["name"] + zsetmem_removeflag = eachzsmem["remove"] + if zsetmem_removeflag: + if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): + cmd = "no member " + zsetmem_name + cmdmemlist.append(cmd) + messages.append( + "removing zoneset member '" + + zsetmem_name + + "' from zoneset '" + + zsetname + + "' in vsan " + + str(vsan), + ) + else: + messages.append( + "zoneset member '" + + zsetmem_name + + "' is not present in zoneset '" + + zsetname + + "' in vsan " + + str(vsan) + + " ,hence there is nothing to remove", + ) + else: + if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): + messages.append( + "zoneset member '" + + zsetmem_name + + "' is already present in zoneset '" + + zsetname + + "' in vsan " + + str(vsan) + + " ,hence there is nothing to add", + ) + else: + cmd = "member " + zsetmem_name + cmdmemlist.append(cmd) + messages.append( + "adding zoneset member '" + + zsetmem_name + + "' to zoneset '" + + zsetname + + "' in vsan " + + str(vsan), + ) + if len(cmdmemlist) != 0: + commands_executed.append( + "zoneset name " + zsetname + " vsan " + str(vsan), + ) + commands_executed = commands_executed + cmdmemlist + else: + if shZonesetObj.isZonesetPresent(zsetname): + messages.append( + "zoneset '" + + zsetname + + "' is already present in vsan " + + str(vsan), + ) + else: + commands_executed.append( + "zoneset name " + zsetname + " vsan " + str(vsan), + ) + messages.append( + "zoneset '" + zsetname + "' is created in vsan " + str(vsan), + ) + + # Process zoneset activate options + if actionflag == "deactivate": + if shZonesetActiveObj.isZonesetActive(zsetname): + messages.append( + "deactivating zoneset '" + zsetname + "' in vsan " + str(vsan), + ) + dactcmd.append( + "no zoneset activate name " + zsetname + " vsan " + str(vsan), + ) + else: + messages.append( + "zoneset '" + + zsetname + + "' in vsan " + + str(vsan) + + " is not activated, hence cannot deactivate", + ) + elif actionflag == "activate": + if commands_executed: + messages.append( + "activating zoneset '" + zsetname + "' in vsan " + str(vsan), + ) + actcmd.append("zoneset activate name " + zsetname + " vsan " + str(vsan)) + else: + messages.append( + "no changes to existing zoneset '" + + zsetname + + "' in vsan " + + str(vsan) + + " hence activate action is ignored", + ) + commands_executed = commands_executed + dactcmd + actcmd + + if commands_executed: + if op_mode == "enhanced": + commands_executed.append("zone commit vsan " + str(vsan)) + elif op_mode is None: + if sw_mode == "enhanced": + commands_executed.append("zone commit vsan " + str(vsan)) + + if commands_executed: + commands_executed = ["terminal dont-ask"] + commands_executed + ["no terminal dont-ask"] + + cmds = flatten_list(commands_executed) + if cmds: + if module.check_mode: + module.exit_json( + changed=False, + commands=cmds, + msg="Check Mode: No cmds issued to the hosts", + ) + else: + result["changed"] = True + commands = commands + cmds + load_config(module, cmds) + + result["messages"] = messages + result["commands"] = commands_executed + result["warnings"] = warnings + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/storage/__init__.py b/plugins/modules/storage/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/modules/storage/nxos_devicealias.py b/plugins/modules/storage/nxos_devicealias.py deleted file mode 100644 index 71d4ebb67..000000000 --- a/plugins/modules/storage/nxos_devicealias.py +++ /dev/null @@ -1,550 +0,0 @@ -#!/usr/bin/python -# Copyright: Ansible Project -# GNU General Public License v3.0+ (see COPYING or -# https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -DOCUMENTATION = """ -module: nxos_devicealias -short_description: Configuration of device alias for Cisco NXOS MDS Switches. -description: -- Configuration of device alias for Cisco MDS NXOS. -version_added: 1.0.0 -author: -- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) -notes: -- Tested against Cisco MDS NX-OS 8.4(1) -options: - distribute: - description: - - Enable/Disable device-alias distribution - type: bool - mode: - description: - - Mode of devices-alias, basic or enhanced - choices: - - basic - - enhanced - type: str - da: - description: - - List of device-alias to be added or removed - type: list - elements: dict - suboptions: - name: - description: - - Name of the device-alias to be added or removed - required: true - type: str - pwwn: - description: - - pwwn to which the name needs to be associated with - type: str - remove: - description: - - Removes the device-alias if set to True - type: bool - default: false - rename: - description: - - List of device-alias to be renamed - type: list - elements: dict - suboptions: - old_name: - description: - - Old name of the device-alias that needs to be renamed - required: true - type: str - new_name: - description: - - New name of the device-alias - required: true - type: str -""" - -EXAMPLES = """ -- name: Test that device alias module works - cisco.nxos.nxos_devicealias: - da: - - name: test1_add - pwwn: 56:2:22:11:22:88:11:67 - - name: test2_add - pwwn: 65:22:22:11:22:22:11:d - - name: dev1 - remove: true - - name: dev2 - remove: true - distribute: true - mode: enhanced - rename: - - new_name: bcd - old_name: abc - - new_name: bcd1 - old_name: abc1 - - -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: - - terminal dont-ask - - device-alias database - - device-alias name somename pwwn 10:00:00:00:89:a1:01:03 - - device-alias name somename1 pwwn 10:00:00:00:89:a1:02:03 - - device-alias commit - - no terminal dont-ask -""" - -import string - -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) - - -__metaclass__ = type - -VALID_DA_CHARS = ("-", "_", "$", "^") - - -class showDeviceAliasStatus(object): - """docstring for showDeviceAliasStatus""" - - def __init__(self, module): - self.module = module - self.distribute = "" - self.mode = "" - self.locked = False - self.update() - - def execute_show_cmd(self, cmd): - output = execute_show_command(cmd, self.module)[0] - return output - - def update(self): - command = "show device-alias status" - output = self.execute_show_cmd(command).split("\n") - for o in output: - if "Fabric Distribution" in o: - self.distribute = o.split(":")[1].strip().lower() - if "Mode" in o: - self.mode = o.split("Mode:")[1].strip().lower() - if "Locked" in o: - self.locked = True - - def isLocked(self): - return self.locked - - def getDistribute(self): - return self.distribute - - def getMode(self): - return self.mode - - -class showDeviceAliasDatabase(object): - """docstring for showDeviceAliasDatabase""" - - def __init__(self, module): - self.module = module - self.da_dict = {} - self.update() - - def execute_show_cmd(self, cmd): - output = execute_show_command(cmd, self.module)[0] - return output - - def update(self): - command = "show device-alias database" - # output = execute_show_command(command, self.module)[0].split("\n") - output = self.execute_show_cmd(command) - self.da_list = output.split("\n") - for eachline in self.da_list: - if "device-alias" in eachline: - sv = eachline.strip().split() - self.da_dict[sv[2]] = sv[4] - - def isNameInDaDatabase(self, name): - return name in self.da_dict.keys() - - def isPwwnInDaDatabase(self, pwwn): - newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) - return newpwwn in self.da_dict.values() - - def isNamePwwnPresentInDatabase(self, name, pwwn): - newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) - if name in self.da_dict.keys(): - if newpwwn == self.da_dict[name]: - return True - return False - - def getPwwnByName(self, name): - if name in self.da_dict.keys(): - return self.da_dict[name] - else: - return None - - def getNameByPwwn(self, pwwn): - newpwwn = ":".join(["0" + str(ep) if len(ep) == 1 else ep for ep in pwwn.split(":")]) - for n, p in self.da_dict.items(): - if p == newpwwn: - return n - return None - - -def isPwwnValid(pwwn): - pwwnsplit = pwwn.split(":") - if len(pwwnsplit) != 8: - return False - for eachpwwnsplit in pwwnsplit: - if len(eachpwwnsplit) > 2 or len(eachpwwnsplit) < 1: - return False - if not all(c in string.hexdigits for c in eachpwwnsplit): - return False - return True - - -def isNameValid(name): - if not name[0].isalpha(): - # Illegal first character. Name must start with a letter - return False - if len(name) > 64: - return False - for character in name: - if not character.isalnum() and character not in VALID_DA_CHARS: - return False - return True - - -def execute_show_command(command, module, command_type="cli_show"): - output = "text" - commands = [{"command": command, "output": output}] - out = run_commands(module, commands) - return out - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def main(): - element_spec = dict( - name=dict(required=True, type="str"), - pwwn=dict(type="str"), - remove=dict(type="bool", default=False), - ) - - element_spec_rename = dict( - old_name=dict(required=True, type="str"), - new_name=dict(required=True, type="str"), - ) - - argument_spec = dict( - distribute=dict(type="bool"), - mode=dict(type="str", choices=["enhanced", "basic"]), - da=dict(type="list", elements="dict", options=element_spec), - rename=dict(type="list", elements="dict", options=element_spec_rename), - ) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - messages = list() - commands_to_execute = list() - result = {"changed": False} - - distribute = module.params["distribute"] - mode = module.params["mode"] - da = module.params["da"] - rename = module.params["rename"] - - # Step 0.0: Validate syntax of name and pwwn - # Also validate syntax of rename arguments - if da is not None: - for eachdict in da: - name = eachdict["name"] - pwwn = eachdict["pwwn"] - remove = eachdict["remove"] - if pwwn is not None: - pwwn = pwwn.lower() - if not remove: - if pwwn is None: - module.fail_json( - msg="This device alias name " - + str(name) - + " which needs to be added, does not have pwwn specified. Please specify a valid pwwn", - ) - if not isNameValid(name): - module.fail_json( - msg="This pwwn name is invalid : " - + str(name) - + ". Note that name cannot be more than 64 alphanumeric chars, " - + "it must start with a letter, and can only contain these characters: " - + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), - ) - if not isPwwnValid(pwwn): - module.fail_json( - msg="This pwwn is invalid : " - + str(pwwn) - + ". Please check that its a valid pwwn", - ) - if rename is not None: - for eachdict in rename: - oldname = eachdict["old_name"] - newname = eachdict["new_name"] - if not isNameValid(oldname): - module.fail_json( - msg="This pwwn name is invalid : " - + str(oldname) - + ". Note that name cannot be more than 64 alphanumeric chars, " - + "it must start with a letter, and can only contain these characters: " - + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), - ) - if not isNameValid(newname): - module.fail_json( - msg="This pwwn name is invalid : " - + str(newname) - + ". Note that name cannot be more than 64 alphanumeric chars, " - + "it must start with a letter, and can only contain these characters: " - + ", ".join(["'{0}'".format(c) for c in VALID_DA_CHARS]), - ) - - # Step 0.1: Check DA status - shDAStausObj = showDeviceAliasStatus(module) - d = shDAStausObj.getDistribute() - m = shDAStausObj.getMode() - if shDAStausObj.isLocked(): - module.fail_json(msg="device-alias has acquired lock on the switch. Hence cannot procced.") - - # Step 1: Process distribute - commands = [] - if distribute is not None: - if distribute: - # playbook has distribute as True(enabled) - if d == "disabled": - # but switch distribute is disabled(false), so set it to - # true(enabled) - commands.append("device-alias distribute") - messages.append("device-alias distribute changed from disabled to enabled") - else: - messages.append( - "device-alias distribute remains unchanged. current distribution mode is enabled", - ) - else: - # playbook has distribute as False(disabled) - if d == "enabled": - # but switch distribute is enabled(true), so set it to - # false(disabled) - commands.append("no device-alias distribute") - messages.append("device-alias distribute changed from enabled to disabled") - else: - messages.append( - "device-alias distribute remains unchanged. current distribution mode is disabled", - ) - - cmds = flatten_list(commands) - if cmds: - commands_to_execute = commands_to_execute + cmds - if module.check_mode: - # Check mode implemented at the da_add/da_remove stage - pass - else: - result["changed"] = True - load_config(module, cmds) - - # Step 2: Process mode - commands = [] - if mode is not None: - if mode == "basic": - # playbook has mode as basic - if m == "enhanced": - # but switch mode is enhanced, so set it to basic - commands.append("no device-alias mode enhanced") - messages.append("device-alias mode changed from enhanced to basic") - else: - messages.append("device-alias mode remains unchanged. current mode is basic") - - else: - # playbook has mode as enhanced - if m == "basic": - # but switch mode is basic, so set it to enhanced - commands.append("device-alias mode enhanced") - messages.append("device-alias mode changed from basic to enhanced") - else: - messages.append("device-alias mode remains unchanged. current mode is enhanced") - - if commands: - if distribute: - commands.append("device-alias commit") - commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - else: - if distribute is None and d == "enabled": - commands.append("device-alias commit") - commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - - cmds = flatten_list(commands) - - if cmds: - commands_to_execute = commands_to_execute + cmds - if module.check_mode: - # Check mode implemented at the end - pass - else: - result["changed"] = True - load_config(module, cmds) - - # Step 3: Process da - commands = [] - shDADatabaseObj = showDeviceAliasDatabase(module) - if da is not None: - da_remove_list = [] - da_add_list = [] - for eachdict in da: - name = eachdict["name"] - pwwn = eachdict["pwwn"] - remove = eachdict["remove"] - if pwwn is not None: - pwwn = pwwn.lower() - if remove: - if shDADatabaseObj.isNameInDaDatabase(name): - commands.append("no device-alias name " + name) - da_remove_list.append(name) - else: - messages.append( - name - + " - This device alias name is not in switch device-alias database, hence cannot be removed.", - ) - else: - if shDADatabaseObj.isNamePwwnPresentInDatabase(name, pwwn): - messages.append( - name - + " : " - + pwwn - + " - This device alias name,pwwn is already in switch device-alias database, hence nothing to configure", - ) - else: - if shDADatabaseObj.isNameInDaDatabase(name): - module.fail_json( - msg=name - + " - This device alias name is already present in switch device-alias database but assigned to another pwwn (" - + shDADatabaseObj.getPwwnByName(name) - + ") hence cannot be added", - ) - - elif shDADatabaseObj.isPwwnInDaDatabase(pwwn): - module.fail_json( - msg=pwwn - + " - This device alias pwwn is already present in switch device-alias database but assigned to another name (" - + shDADatabaseObj.getNameByPwwn(pwwn) - + ") hence cannot be added", - ) - - else: - commands.append("device-alias name " + name + " pwwn " + pwwn) - da_add_list.append(name) - - if len(da_add_list) != 0 or len(da_remove_list) != 0: - commands = ["device-alias database"] + commands - if distribute: - commands.append("device-alias commit") - commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - else: - if distribute is None and d == "enabled": - commands.append("device-alias commit") - commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - - cmds = flatten_list(commands) - if cmds: - commands_to_execute = commands_to_execute + cmds - if module.check_mode: - # Check mode implemented at the end - pass - else: - result["changed"] = True - load_config(module, cmds) - if len(da_remove_list) != 0: - messages.append( - "the required device-alias were removed. " + ",".join(da_remove_list), - ) - if len(da_add_list) != 0: - messages.append( - "the required device-alias were added. " + ",".join(da_add_list), - ) - - # Step 5: Process rename - commands = [] - if rename is not None: - for eachdict in rename: - oldname = eachdict["old_name"] - newname = eachdict["new_name"] - if shDADatabaseObj.isNameInDaDatabase(newname): - module.fail_json( - changed=False, - commands=cmds, - msg=newname - + " - this name is already present in the device-alias database, hence we cannot rename " - + oldname - + " with this one", - ) - if shDADatabaseObj.isNameInDaDatabase(oldname): - commands.append("device-alias rename " + oldname + " " + newname) - else: - module.fail_json( - changed=False, - commands=cmds, - msg=oldname - + " - this name is not present in the device-alias database, hence we cannot rename.", - ) - - if len(commands) != 0: - commands = ["device-alias database"] + commands - if distribute: - commands.append("device-alias commit") - commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - else: - if distribute is None and d == "enabled": - commands.append("device-alias commit") - commands = ["terminal dont-ask"] + commands + ["no terminal dont-ask"] - cmds = flatten_list(commands) - if cmds: - commands_to_execute = commands_to_execute + cmds - if module.check_mode: - # Check mode implemented at the end - pass - else: - result["changed"] = True - load_config(module, cmds) - - # Step END: check for 'check' mode - if module.check_mode: - module.exit_json( - changed=False, - commands=commands_to_execute, - msg="Check Mode: No cmds issued to the hosts", - ) - - result["messages"] = messages - result["commands"] = commands_to_execute - result["warnings"] = warnings - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/storage/nxos_vsan.py b/plugins/modules/storage/nxos_vsan.py deleted file mode 100644 index d95d95a96..000000000 --- a/plugins/modules/storage/nxos_vsan.py +++ /dev/null @@ -1,354 +0,0 @@ -#!/usr/bin/python -# Copyright: Ansible Project -# GNU General Public License v3.0+ (see COPYING or -# https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -DOCUMENTATION = """ -module: nxos_vsan -short_description: Configuration of vsan for Cisco NXOS MDS Switches. -description: -- Configuration of vsan for Cisco MDS NXOS. -version_added: 1.0.0 -author: -- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) -notes: -- Tested against Cisco MDS NX-OS 8.4(1) -options: - vsan: - description: - - List of vsan details to be added or removed - type: list - elements: dict - suboptions: - id: - description: - - Vsan id - required: true - type: int - name: - description: - - Name of the vsan - type: str - suspend: - description: - - suspend the vsan if True - type: bool - remove: - description: - - Removes the vsan if True - type: bool - interface: - description: - - List of vsan's interfaces to be added - type: list - elements: str -""" - -EXAMPLES = """ -- name: Test that vsan module works - cisco.nxos.nxos_vsan: - vsan: - - id: 922 - interface: - - fc1/1 - - fc1/2 - - port-channel 1 - name: vsan-SAN-A - remove: false - suspend: false - - id: 923 - interface: - - fc1/11 - - fc1/21 - - port-channel 2 - name: vsan-SAN-B - remove: false - suspend: true - - id: 1923 - name: vsan-SAN-Old - remove: true -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: - - terminal dont-ask - - vsan database - - vsan 922 interface fc1/40 - - vsan 922 interface port-channel 155 - - no terminal dont-ask -""" - -import re - -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) - - -__metaclass__ = type - - -class Vsan(object): - def __init__(self, vsanid): - self.vsanid = vsanid - self.vsanname = None - self.vsanstate = None - self.vsanoperstate = None - self.vsaninterfaces = [] - - -class GetVsanInfoFromSwitch(object): - """docstring for GetVsanInfoFromSwitch""" - - def __init__(self, module): - self.module = module - self.vsaninfo = {} - self.processShowVsan() - self.processShowVsanMembership() - - def execute_show_vsan_cmd(self): - output = execute_show_command("show vsan", self.module)[0] - return output - - def execute_show_vsan_mem_cmd(self): - output = execute_show_command("show vsan membership", self.module)[0] - return output - - def processShowVsan(self): - patv = r"^vsan\s+(\d+)\s+information" - patnamestate = "name:(.*)state:(.*)" - patoperstate = "operational state:(.*)" - - output = self.execute_show_vsan_cmd().split("\n") - for o in output: - z = re.match(patv, o.strip()) - if z: - v = z.group(1).strip() - self.vsaninfo[v] = Vsan(v) - - z1 = re.match(patnamestate, o.strip()) - if z1: - n = z1.group(1).strip() - s = z1.group(2).strip() - self.vsaninfo[v].vsanname = n - self.vsaninfo[v].vsanstate = s - - z2 = re.match(patoperstate, o.strip()) - if z2: - oper = z2.group(1).strip() - self.vsaninfo[v].vsanoperstate = oper - - # 4094/4079 vsan is always present - self.vsaninfo["4079"] = Vsan("4079") - self.vsaninfo["4094"] = Vsan("4094") - - def processShowVsanMembership(self): - patv = r"^vsan\s+(\d+).*" - output = self.execute_show_vsan_mem_cmd().split("\n") - memlist = [] - v = None - for o in output: - z = re.match(patv, o.strip()) - if z: - if v is not None: - self.vsaninfo[v].vsaninterfaces = memlist - memlist = [] - v = z.group(1) - if "interfaces" not in o: - llist = o.strip().split() - memlist = memlist + llist - self.vsaninfo[v].vsaninterfaces = memlist - - def getVsanInfoObjects(self): - return self.vsaninfo - - -def execute_show_command(command, module, command_type="cli_show"): - output = "text" - commands = [{"command": command, "output": output}] - return run_commands(module, commands) - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def main(): - vsan_element_spec = dict( - id=dict(required=True, type="int"), - name=dict(type="str"), - remove=dict(type="bool"), - suspend=dict(type="bool"), - interface=dict(type="list", elements="str"), - ) - - argument_spec = dict(vsan=dict(type="list", elements="dict", options=vsan_element_spec)) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - warnings = list() - messages = list() - commands_executed = list() - result = {"changed": False} - - obj = GetVsanInfoFromSwitch(module) - dictSwVsanObjs = obj.getVsanInfoObjects() - - commands = [] - vsan_list = module.params["vsan"] - - for eachvsan in vsan_list: - vsanid = str(eachvsan["id"]) - vsanname = eachvsan["name"] - vsanremove = eachvsan["remove"] - vsansuspend = eachvsan["suspend"] - vsaninterface_list = eachvsan["interface"] - - if int(vsanid) < 1 or int(vsanid) >= 4095: - module.fail_json( - msg=vsanid + " - This is an invalid vsan. Supported vsan range is 1-4094", - ) - - if vsanid in dictSwVsanObjs.keys(): - sw_vsanid = vsanid - sw_vsanname = dictSwVsanObjs[vsanid].vsanname - sw_vsanstate = dictSwVsanObjs[vsanid].vsanstate - sw_vsaninterfaces = dictSwVsanObjs[vsanid].vsaninterfaces - else: - sw_vsanid = None - sw_vsanname = None - sw_vsanstate = None - sw_vsaninterfaces = [] - - if vsanremove: - # Negative case: - if vsanid == "4079" or vsanid == "4094": - messages.append(str(vsanid) + " is a reserved vsan, hence cannot be removed") - continue - if vsanid == sw_vsanid: - commands.append("no vsan " + str(vsanid)) - messages.append("deleting the vsan " + str(vsanid)) - else: - messages.append( - "There is no vsan " - + str(vsanid) - + " present in the switch. Hence there is nothing to delete", - ) - continue - else: - # Negative case: - if vsanid == "4079" or vsanid == "4094": - messages.append( - str(vsanid) + " is a reserved vsan, and always present on the switch", - ) - else: - if vsanid == sw_vsanid: - messages.append( - "There is already a vsan " - + str(vsanid) - + " present in the switch. Hence there is nothing to configure", - ) - else: - commands.append("vsan " + str(vsanid)) - messages.append("creating vsan " + str(vsanid)) - - if vsanname is not None: - # Negative case: - if vsanid == "4079" or vsanid == "4094": - messages.append(str(vsanid) + " is a reserved vsan, and cannot be renamed") - else: - if vsanname == sw_vsanname: - messages.append( - "There is already a vsan " - + str(vsanid) - + " present in the switch, which has the name " - + vsanname - + " Hence there is nothing to configure", - ) - else: - commands.append("vsan " + str(vsanid) + " name " + vsanname) - messages.append("setting vsan name to " + vsanname + " for vsan " + str(vsanid)) - - if vsansuspend: - # Negative case: - if vsanid == "4079" or vsanid == "4094": - messages.append(str(vsanid) + " is a reserved vsan, and cannot be suspended") - else: - if sw_vsanstate == "suspended": - messages.append( - "There is already a vsan " - + str(vsanid) - + " present in the switch, which is in suspended state ", - ) - else: - commands.append("vsan " + str(vsanid) + " suspend") - messages.append("suspending the vsan " + str(vsanid)) - else: - if sw_vsanstate == "active": - messages.append( - "There is already a vsan " - + str(vsanid) - + " present in the switch, which is in active state ", - ) - else: - commands.append("no vsan " + str(vsanid) + " suspend") - messages.append("no suspending the vsan " + str(vsanid)) - - if vsaninterface_list is not None: - for each_interface_name in vsaninterface_list: - # For fcip,port-channel,vfc-port-channel need to remove the - # extra space to compare - temp = re.sub(" +", "", each_interface_name) - if temp in sw_vsaninterfaces: - messages.append( - each_interface_name - + " is already present in the vsan " - + str(vsanid) - + " interface list", - ) - else: - commands.append("vsan " + str(vsanid) + " interface " + each_interface_name) - messages.append( - "adding interface " + each_interface_name + " to vsan " + str(vsanid), - ) - - if len(commands) != 0: - commands = ["terminal dont-ask"] + ["vsan database"] + commands + ["no terminal dont-ask"] - - cmds = flatten_list(commands) - commands_executed = cmds - - if commands_executed: - if module.check_mode: - module.exit_json( - changed=False, - commands=commands_executed, - msg="Check Mode: No cmds issued to the hosts", - ) - else: - result["changed"] = True - load_config(module, commands_executed) - - result["messages"] = messages - result["commands"] = commands_executed - result["warnings"] = warnings - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/storage/nxos_zone_zoneset.py b/plugins/modules/storage/nxos_zone_zoneset.py deleted file mode 100644 index 7c9fba30a..000000000 --- a/plugins/modules/storage/nxos_zone_zoneset.py +++ /dev/null @@ -1,888 +0,0 @@ -#!/usr/bin/python -# Copyright: Ansible Project -# GNU General Public License v3.0+ (see COPYING or -# https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - - -DOCUMENTATION = """ -module: nxos_zone_zoneset -short_description: Configuration of zone/zoneset for Cisco NXOS MDS Switches. -description: -- Configuration of zone/zoneset for Cisco MDS NXOS. -version_added: 1.0.0 -author: -- Suhas Bharadwaj (@srbharadwaj) (subharad@cisco.com) -notes: -- Tested against Cisco MDS NX-OS 8.4(1) -options: - zone_zoneset_details: - description: - - List of zone/zoneset details to be added or removed - type: list - elements: dict - suboptions: - vsan: - description: - - vsan id - required: true - type: int - mode: - description: - - mode of the zone for the vsan - choices: - - enhanced - - basic - type: str - default_zone: - description: - - default zone behaviour for the vsan - choices: - - permit - - deny - type: str - smart_zoning: - description: - - Removes the vsan if True - type: bool - zone: - description: - - List of zone options for that vsan - type: list - elements: dict - suboptions: - name: - description: - - name of the zone - required: true - type: str - remove: - description: - - Deletes the zone if True - type: bool - default: false - members: - description: - - Members of the zone that needs to be removed or added - type: list - elements: dict - suboptions: - pwwn: - description: - - pwwn member of the zone, use alias 'device_alias' as option for - device_alias member - aliases: - - device_alias - required: true - type: str - remove: - description: - - Removes member from the zone if True - type: bool - default: false - devtype: - description: - - devtype of the zone member used along with Smart zoning config - choices: - - initiator - - target - - both - type: str - zoneset: - description: - - List of zoneset options for the vsan - type: list - elements: dict - suboptions: - name: - description: - - name of the zoneset - required: true - type: str - remove: - description: - - Removes zoneset if True - type: bool - default: false - action: - description: - - activates/de-activates the zoneset - choices: - - activate - - deactivate - type: str - members: - description: - - Members of the zoneset that needs to be removed or added - type: list - elements: dict - suboptions: - name: - description: - - name of the zone that needs to be added to the zoneset or removed - from the zoneset - required: true - type: str - remove: - description: - - Removes zone member from the zoneset - type: bool - default: false -""" - -EXAMPLES = """ -- name: Test that zone/zoneset module works - cisco.nxos.nxos_zone_zoneset: - zone_zoneset_details: - - mode: enhanced - vsan: 22 - zone: - - members: - - pwwn: 11:11:11:11:11:11:11:11 - - device_alias: test123 - - pwwn: 61:61:62:62:12:12:12:12 - remove: true - name: zoneA - - members: - - pwwn: 10:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:21:21:21:21 - name: zoneB - - name: zoneC - remove: true - zoneset: - - action: activate - members: - - name: zoneA - - name: zoneB - - name: zoneC - remove: true - name: zsetname1 - - action: deactivate - name: zsetTestExtra - remove: true - - mode: basic - smart_zoning: true - vsan: 21 - zone: - - members: - - devtype: both - pwwn: 11:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:12:12:12:12 - - devtype: both - pwwn: 92:62:62:62:12:12:1a:1a - remove: true - name: zone21A - - members: - - pwwn: 10:11:11:11:11:11:11:11 - - pwwn: 62:62:62:62:21:21:21:21 - name: zone21B - zoneset: - - action: activate - members: - - name: zone21A - - name: zone21B - name: zsetname212 - -""" - -RETURN = """ -commands: - description: commands sent to the device - returned: always - type: list - sample: - - terminal dont-ask - - zone name zoneA vsan 923 - - member pwwn 11:11:11:11:11:11:11:11 - - no member device-alias test123 - - zone commit vsan 923 - - no terminal dont-ask -messages: - description: debug messages - returned: always - type: list - sample: - - "zone mode is already enhanced ,no change in zone mode configuration for vsan 922" - - "zone member '11:11:11:11:11:11:11:11' is already present in zone 'zoneA' in vsan 922 hence nothing to add" - - "zone member 'test123' is already present in zone 'zoneA' in vsan 922 hence nothing to add" - - "zone member '61:61:62:62:12:12:12:12' is not present in zone 'zoneA' in vsan 922 hence nothing to remove" - - "zone member '10:11:11:11:11:11:11:11' is already present in zone 'zoneB' in vsan 922 hence nothing to add" - - "zone member '62:62:62:62:21:21:21:21' is already present in zone 'zoneB' in vsan 922 hence nothing to add" - - "zone 'zoneC' is not present in vsan 922 , so nothing to remove" -""" - - -import re - -from ansible.module_utils.basic import AnsibleModule - -from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.nxos import ( - load_config, - run_commands, -) - - -__metaclass__ = type - - -class ShowZonesetActive(object): - """docstring for ShowZonesetActive""" - - def __init__(self, module, vsan): - self.vsan = vsan - self.module = module - self.activeZSName = None - self.parseCmdOutput() - - def execute_show_zoneset_active_cmd(self): - command = "show zoneset active vsan " + str(self.vsan) + " | grep zoneset" - output = execute_show_command(command, self.module)[0] - return output - - def parseCmdOutput(self): - patZoneset = r"zoneset name (\S+) vsan " + str(self.vsan) - output = self.execute_show_zoneset_active_cmd().split("\n") - if len(output) == 0: - return - else: - for line in output: - line = line.strip() - mzs = re.match(patZoneset, line.strip()) - if mzs: - self.activeZSName = mzs.group(1).strip() - return - - def isZonesetActive(self, zsname): - if zsname == self.activeZSName: - return True - return False - - -class ShowZoneset(object): - """docstring for ShowZoneset""" - - def __init__(self, module, vsan): - self.vsan = vsan - self.module = module - self.zsDetails = {} - self.parseCmdOutput() - - def execute_show_zoneset_cmd(self): - command = "show zoneset vsan " + str(self.vsan) - output = execute_show_command(command, self.module)[0] - return output - - def parseCmdOutput(self): - patZoneset = r"zoneset name (\S+) vsan " + str(self.vsan) - patZone = r"zone name (\S+) vsan " + str(self.vsan) - output = self.execute_show_zoneset_cmd().split("\n") - for line in output: - line = line.strip() - mzs = re.match(patZoneset, line.strip()) - mz = re.match(patZone, line.strip()) - if mzs: - zonesetname = mzs.group(1).strip() - self.zsDetails[zonesetname] = [] - continue - elif mz: - zonename = mz.group(1).strip() - v = self.zsDetails[zonesetname] - v.append(zonename) - self.zsDetails[zonesetname] = v - - def isZonesetPresent(self, zsname): - return zsname in self.zsDetails.keys() - - def isZonePresentInZoneset(self, zsname, zname): - if zsname in self.zsDetails.keys(): - return zname in self.zsDetails[zsname] - return False - - -class ShowZone(object): - """docstring for ShowZone""" - - def __init__(self, module, vsan): - self.vsan = vsan - self.module = module - self.zDetails = {} - self.parseCmdOutput() - - def execute_show_zone_vsan_cmd(self): - command = "show zone vsan " + str(self.vsan) - output = execute_show_command(command, self.module)[0] - return output - - def parseCmdOutput(self): - patZone = r"zone name (\S+) vsan " + str(self.vsan) - output = self.execute_show_zone_vsan_cmd().split("\n") - for line in output: - line = re.sub(r"[\[].*?[\]]", "", line) - line = " ".join(line.strip().split()) - if "init" in line: - line = line.replace("init", "initiator") - m = re.match(patZone, line) - if m: - zonename = m.group(1).strip() - self.zDetails[zonename] = [] - continue - else: - # For now we support only pwwn and device-alias under zone - # Ideally should use 'supported_choices'....but maybe next - # time. - if "pwwn" in line or "device-alias" in line: - v = self.zDetails[zonename] - v.append(line) - self.zDetails[zonename] = v - - def isZonePresent(self, zname): - return zname in self.zDetails.keys() - - def isZoneMemberPresent(self, zname, cmd): - if zname in self.zDetails.keys(): - zonememlist = self.zDetails[zname] - for eachline in zonememlist: - if cmd in eachline: - return True - return False - - def get_zDetails(self): - return self.zDetails - - -class ShowZoneStatus(object): - """docstring for ShowZoneStatus""" - - def __init__(self, module, vsan): - self.vsan = vsan - self.vsanAbsent = False - self.module = module - self.default_zone = "" - self.mode = "" - self.session = "" - self.sz = "" - self.locked = False - self.update() - - def execute_show_zone_status_cmd(self): - command = "show zone status vsan " + str(self.vsan) - output = execute_show_command(command, self.module)[0] - return output - - def update(self): - output = self.execute_show_zone_status_cmd().split("\n") - - patfordefzone = "VSAN: " + str(self.vsan) + r" default-zone:\s+(\S+).*" - patformode = r".*mode:\s+(\S+).*" - patforsession = r"^session:\s+(\S+).*" - patforsz = r".*smart-zoning:\s+(\S+).*" - for line in output: - if "is not configured" in line: - self.vsanAbsent = True - break - mdefz = re.match(patfordefzone, line.strip()) - mmode = re.match(patformode, line.strip()) - msession = re.match(patforsession, line.strip()) - msz = re.match(patforsz, line.strip()) - - if mdefz: - self.default_zone = mdefz.group(1) - if mmode: - self.mode = mmode.group(1) - if msession: - self.session = msession.group(1) - if self.session != "none": - self.locked = True - if msz: - self.sz = msz.group(1) - - def isLocked(self): - return self.locked - - def getDefaultZone(self): - return self.default_zone - - def getMode(self): - return self.mode - - def getSmartZoningStatus(self): - return self.sz - - def isVsanAbsent(self): - return self.vsanAbsent - - -def execute_show_command(command, module, command_type="cli_show"): - output = "text" - commands = [{"command": command, "output": output}] - return run_commands(module, commands) - - -def flatten_list(command_lists): - flat_command_list = [] - for command in command_lists: - if isinstance(command, list): - flat_command_list.extend(command) - else: - flat_command_list.append(command) - return flat_command_list - - -def getMemType(supported_choices, allmemkeys, default="pwwn"): - for eachchoice in supported_choices: - if eachchoice in allmemkeys: - return eachchoice - return default - - -def main(): - supported_choices = ["device_alias"] - zone_member_spec = dict( - pwwn=dict(required=True, type="str", aliases=["device_alias"]), - devtype=dict(type="str", choices=["initiator", "target", "both"]), - remove=dict(type="bool", default=False), - ) - - zone_spec = dict( - name=dict(required=True, type="str"), - members=dict(type="list", elements="dict", options=zone_member_spec), - remove=dict(type="bool", default=False), - ) - - zoneset_member_spec = dict( - name=dict(required=True, type="str"), - remove=dict(type="bool", default=False), - ) - - zoneset_spec = dict( - name=dict(type="str", required=True), - members=dict(type="list", elements="dict", options=zoneset_member_spec), - remove=dict(type="bool", default=False), - action=dict(type="str", choices=["activate", "deactivate"]), - ) - - zonedetails_spec = dict( - vsan=dict(required=True, type="int"), - mode=dict(type="str", choices=["enhanced", "basic"]), - default_zone=dict(type="str", choices=["permit", "deny"]), - smart_zoning=dict(type="bool"), - zone=dict(type="list", elements="dict", options=zone_spec), - zoneset=dict(type="list", elements="dict", options=zoneset_spec), - ) - - argument_spec = dict( - zone_zoneset_details=dict(type="list", elements="dict", options=zonedetails_spec), - ) - - module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - - warnings = list() - messages = list() - commands = list() - result = {"changed": False} - - commands_executed = [] - listOfZoneDetails = module.params["zone_zoneset_details"] - for eachZoneZonesetDetail in listOfZoneDetails: - vsan = eachZoneZonesetDetail["vsan"] - op_mode = eachZoneZonesetDetail["mode"] - op_default_zone = eachZoneZonesetDetail["default_zone"] - op_smart_zoning = eachZoneZonesetDetail["smart_zoning"] - op_zone = eachZoneZonesetDetail["zone"] - op_zoneset = eachZoneZonesetDetail["zoneset"] - - # Step1: execute show zone status and get - shZoneStatusObj = ShowZoneStatus(module, vsan) - sw_default_zone = shZoneStatusObj.getDefaultZone() - sw_mode = shZoneStatusObj.getMode() - sw_smart_zoning = shZoneStatusObj.getSmartZoningStatus() - - if sw_smart_zoning.lower() == "Enabled".lower(): - sw_smart_zoning_bool = True - else: - sw_smart_zoning_bool = False - - if shZoneStatusObj.isVsanAbsent(): - module.fail_json( - msg="Vsan " + str(vsan) + " is not present in the switch. Hence cannot procced.", - ) - - if shZoneStatusObj.isLocked(): - module.fail_json( - msg="zone has acquired lock on the switch for vsan " - + str(vsan) - + ". Hence cannot procced.", - ) - - # Process zone default zone options - if op_default_zone is not None: - if op_default_zone != sw_default_zone: - if op_default_zone == "permit": - commands_executed.append("zone default-zone permit vsan " + str(vsan)) - messages.append( - "default zone configuration changed from deny to permit for vsan " - + str(vsan), - ) - else: - commands_executed.append("no zone default-zone permit vsan " + str(vsan)) - messages.append( - "default zone configuration changed from permit to deny for vsan " - + str(vsan), - ) - else: - messages.append( - "default zone is already " - + op_default_zone - + " ,no change in default zone configuration for vsan " - + str(vsan), - ) - - # Process zone mode options - if op_mode is not None: - if op_mode != sw_mode: - if op_mode == "enhanced": - commands_executed.append("zone mode enhanced vsan " + str(vsan)) - messages.append( - "zone mode configuration changed from basic to enhanced for vsan " - + str(vsan), - ) - else: - commands_executed.append("no zone mode enhanced vsan " + str(vsan)) - messages.append( - "zone mode configuration changed from enhanced to basic for vsan " - + str(vsan), - ) - else: - messages.append( - "zone mode is already " - + op_mode - + " ,no change in zone mode configuration for vsan " - + str(vsan), - ) - - # Process zone smart-zone options - if op_smart_zoning is not None: - if op_smart_zoning != sw_smart_zoning_bool: - if op_smart_zoning: - commands_executed.append("zone smart-zoning enable vsan " + str(vsan)) - messages.append("smart-zoning enabled for vsan " + str(vsan)) - else: - commands_executed.append("no zone smart-zoning enable vsan " + str(vsan)) - messages.append("smart-zoning disabled for vsan " + str(vsan)) - else: - messages.append( - "smart-zoning is already set to " - + sw_smart_zoning - + " , no change in smart-zoning configuration for vsan " - + str(vsan), - ) - - # Process zone member options - # TODO: Obviously this needs to be cleaned up properly, as there are a lot of ifelse statements which is bad - # Will take it up later becoz of time constraints - if op_zone is not None: - shZoneObj = ShowZone(module, vsan) - for eachzone in op_zone: - zname = eachzone["name"] - zmembers = eachzone["members"] - removeflag = eachzone["remove"] - if removeflag: - if shZoneObj.isZonePresent(zname): - messages.append("zone '" + zname + "' is removed from vsan " + str(vsan)) - commands_executed.append("no zone name " + zname + " vsan " + str(vsan)) - else: - messages.append( - "zone '" - + zname - + "' is not present in vsan " - + str(vsan) - + " , so nothing to remove", - ) - else: - if zmembers is None: - if shZoneObj.isZonePresent(zname): - messages.append( - "zone '" + zname + "' is already present in vsan " + str(vsan), - ) - else: - commands_executed.append("zone name " + zname + " vsan " + str(vsan)) - messages.append("zone '" + zname + "' is created in vsan " + str(vsan)) - else: - cmdmemlist = [] - for eachmem in zmembers: - memtype = getMemType(supported_choices, eachmem.keys()) - cmd = memtype.replace("_", "-") + " " + eachmem[memtype] - if op_smart_zoning or sw_smart_zoning_bool: - if eachmem["devtype"] is not None: - cmd = cmd + " " + eachmem["devtype"] - if eachmem["remove"]: - if shZoneObj.isZonePresent(zname): - if shZoneObj.isZoneMemberPresent(zname, cmd): - cmd = "no member " + cmd - cmdmemlist.append(cmd) - if op_smart_zoning and eachmem["devtype"] is not None: - messages.append( - "removing zone member '" - + eachmem[memtype] - + " of device type '" - + eachmem["devtype"] - + "' from zone '" - + zname - + "' in vsan " - + str(vsan), - ) - else: - messages.append( - "removing zone member '" - + eachmem[memtype] - + "' from zone '" - + zname - + "' in vsan " - + str(vsan), - ) - else: - if op_smart_zoning and eachmem["devtype"] is not None: - messages.append( - "zone member '" - + eachmem[memtype] - + "' of device type '" - + eachmem["devtype"] - + "' is not present in zone '" - + zname - + "' in vsan " - + str(vsan) - + " hence nothing to remove", - ) - else: - messages.append( - "zone member '" - + eachmem[memtype] - + "' is not present in zone '" - + zname - + "' in vsan " - + str(vsan) - + " hence nothing to remove", - ) - else: - messages.append( - "zone '" - + zname - + "' is not present in vsan " - + str(vsan) - + " , hence cannot remove the members", - ) - - else: - if shZoneObj.isZoneMemberPresent(zname, cmd): - if op_smart_zoning and eachmem["devtype"] is not None: - messages.append( - "zone member '" - + eachmem[memtype] - + "' of device type '" - + eachmem["devtype"] - + "' is already present in zone '" - + zname - + "' in vsan " - + str(vsan) - + " hence nothing to add", - ) - else: - messages.append( - "zone member '" - + eachmem[memtype] - + "' is already present in zone '" - + zname - + "' in vsan " - + str(vsan) - + " hence nothing to add", - ) - else: - cmd = "member " + cmd - cmdmemlist.append(cmd) - if op_smart_zoning and eachmem["devtype"] is not None: - messages.append( - "adding zone member '" - + eachmem[memtype] - + "' of device type '" - + eachmem["devtype"] - + "' to zone '" - + zname - + "' in vsan " - + str(vsan), - ) - else: - messages.append( - "adding zone member '" - + eachmem[memtype] - + "' to zone '" - + zname - + "' in vsan " - + str(vsan), - ) - if len(cmdmemlist) != 0: - commands_executed.append("zone name " + zname + " vsan " + str(vsan)) - commands_executed = commands_executed + cmdmemlist - - # Process zoneset member options - if op_zoneset is not None: - dactcmd = [] - actcmd = [] - shZonesetObj = ShowZoneset(module, vsan) - shZonesetActiveObj = ShowZonesetActive(module, vsan) - for eachzoneset in op_zoneset: - zsetname = eachzoneset["name"] - zsetmembers = eachzoneset["members"] - removeflag = eachzoneset["remove"] - actionflag = eachzoneset["action"] - if removeflag: - if shZonesetObj.isZonesetPresent(zsetname): - messages.append( - "zoneset '" + zsetname + "' is removed from vsan " + str(vsan), - ) - commands_executed.append( - "no zoneset name " + zsetname + " vsan " + str(vsan), - ) - else: - messages.append( - "zoneset '" - + zsetname - + "' is not present in vsan " - + str(vsan) - + " ,hence there is nothing to remove", - ) - else: - if zsetmembers is not None: - cmdmemlist = [] - for eachzsmem in zsetmembers: - zsetmem_name = eachzsmem["name"] - zsetmem_removeflag = eachzsmem["remove"] - if zsetmem_removeflag: - if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): - cmd = "no member " + zsetmem_name - cmdmemlist.append(cmd) - messages.append( - "removing zoneset member '" - + zsetmem_name - + "' from zoneset '" - + zsetname - + "' in vsan " - + str(vsan), - ) - else: - messages.append( - "zoneset member '" - + zsetmem_name - + "' is not present in zoneset '" - + zsetname - + "' in vsan " - + str(vsan) - + " ,hence there is nothing to remove", - ) - else: - if shZonesetObj.isZonePresentInZoneset(zsetname, zsetmem_name): - messages.append( - "zoneset member '" - + zsetmem_name - + "' is already present in zoneset '" - + zsetname - + "' in vsan " - + str(vsan) - + " ,hence there is nothing to add", - ) - else: - cmd = "member " + zsetmem_name - cmdmemlist.append(cmd) - messages.append( - "adding zoneset member '" - + zsetmem_name - + "' to zoneset '" - + zsetname - + "' in vsan " - + str(vsan), - ) - if len(cmdmemlist) != 0: - commands_executed.append( - "zoneset name " + zsetname + " vsan " + str(vsan), - ) - commands_executed = commands_executed + cmdmemlist - else: - if shZonesetObj.isZonesetPresent(zsetname): - messages.append( - "zoneset '" - + zsetname - + "' is already present in vsan " - + str(vsan), - ) - else: - commands_executed.append( - "zoneset name " + zsetname + " vsan " + str(vsan), - ) - messages.append( - "zoneset '" + zsetname + "' is created in vsan " + str(vsan), - ) - - # Process zoneset activate options - if actionflag == "deactivate": - if shZonesetActiveObj.isZonesetActive(zsetname): - messages.append( - "deactivating zoneset '" + zsetname + "' in vsan " + str(vsan), - ) - dactcmd.append( - "no zoneset activate name " + zsetname + " vsan " + str(vsan), - ) - else: - messages.append( - "zoneset '" - + zsetname - + "' in vsan " - + str(vsan) - + " is not activated, hence cannot deactivate", - ) - elif actionflag == "activate": - if commands_executed: - messages.append( - "activating zoneset '" + zsetname + "' in vsan " + str(vsan), - ) - actcmd.append("zoneset activate name " + zsetname + " vsan " + str(vsan)) - else: - messages.append( - "no changes to existing zoneset '" - + zsetname - + "' in vsan " - + str(vsan) - + " hence activate action is ignored", - ) - commands_executed = commands_executed + dactcmd + actcmd - - if commands_executed: - if op_mode == "enhanced": - commands_executed.append("zone commit vsan " + str(vsan)) - elif op_mode is None: - if sw_mode == "enhanced": - commands_executed.append("zone commit vsan " + str(vsan)) - - if commands_executed: - commands_executed = ["terminal dont-ask"] + commands_executed + ["no terminal dont-ask"] - - cmds = flatten_list(commands_executed) - if cmds: - if module.check_mode: - module.exit_json( - changed=False, - commands=cmds, - msg="Check Mode: No cmds issued to the hosts", - ) - else: - result["changed"] = True - commands = commands + cmds - load_config(module, cmds) - - result["messages"] = messages - result["commands"] = commands_executed - result["warnings"] = warnings - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/tests/unit/modules/network/nxos/storage/__init__.py b/tests/unit/modules/network/nxos/storage/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py b/tests/unit/modules/network/nxos/test_nxos_devicealias.py similarity index 98% rename from tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py rename to tests/unit/modules/network/nxos/test_nxos_devicealias.py index a35896fbe..640bcd150 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_devicealias.py +++ b/tests/unit/modules/network/nxos/test_nxos_devicealias.py @@ -9,11 +9,11 @@ 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/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py b/tests/unit/modules/network/nxos/test_nxos_vsan.py similarity index 97% rename from tests/unit/modules/network/nxos/storage/test_nxos_vsan.py rename to tests/unit/modules/network/nxos/test_nxos_vsan.py index db79f8668..af9ee7ad3 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_vsan.py +++ b/tests/unit/modules/network/nxos/test_nxos_vsan.py @@ -9,11 +9,11 @@ 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/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py b/tests/unit/modules/network/nxos/test_nxos_zone_zoneset.py similarity index 90% rename from tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py rename to tests/unit/modules/network/nxos/test_nxos_zone_zoneset.py index b49dbf2fd..6afe78a5b 100644 --- a/tests/unit/modules/network/nxos/storage/test_nxos_zone_zoneset.py +++ b/tests/unit/modules/network/nxos/test_nxos_zone_zoneset.py @@ -8,10 +8,10 @@ __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 @@ def setUp(self): ) 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 @@ def test_zone_smart_zone_1(self): # 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 @@ def test_zone_add_rem(self): ) 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 @@ def test_zone_add_rem_2(self): "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 @@ def test_zone_add_rem_3(self): "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 @@ def test_zonemem_add_rem(self): "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 @@ def test_zonemem_add_rem_1(self): 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 @@ def test_zonemem_add_rem_2(self): 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 @@ def test_zonemem_add_rem_3(self): "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 @@ def test_zonemem_add_rem_3(self): 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 @@ def test_zonemem_add_rem_4(self): # 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 @@ def test_zoneset_add_rem(self): ) 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 @@ def test_zoneset_add_rem_1(self): ) 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 @@ def test_zoneset_mem_add_rem_2(self): # 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 @@ def test_bug_zone_remove(self): 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", From ba476d4df968f2aab8cdc2b8ac914c93a48cb9ac Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 31 Jul 2023 18:28:50 +0530 Subject: [PATCH 115/166] Fix new pep8 failures (#722) Signed-off-by: NilashishC --- tests/unit/mock/loader.py | 2 +- tests/unit/modules/network/nxos/test_nxos_pim_interface.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index ebff16f63..0fc53edcd 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -31,7 +31,7 @@ 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/tests/unit/modules/network/nxos/test_nxos_pim_interface.py b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py index 886a77940..3f0d56bb6 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py @@ -63,7 +63,7 @@ def load_from_file(*args, **kwargs): output = list() for command in commands: - if type(command) == dict: + if type(command) is dict: command = command["command"] filename = str(command).split(" | ", 1)[0].replace(" ", "_").replace("/", "_") output.append(load_fixture(module_name, filename)) From b5c911a1d0c9157ac8ec5cda3ba87016f7a3aac4 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 31 Jul 2023 19:13:28 +0530 Subject: [PATCH 116/166] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c02182da..bd2ffcc74 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main changelog: uses: ansible-network/github_actions/.github/workflows/changelog.yml@main - if: github.event_name != 'schedule' + if: github.event_name == 'pull_request' sanity: uses: ansible-network/github_actions/.github/workflows/sanity.yml@main unit-galaxy: From 4a83caf84e509c77aaadec71d28258d10449e2c0 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 1 Aug 2023 16:49:02 +0530 Subject: [PATCH 117/166] Delete a.txt --- a.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 a.txt diff --git a/a.txt b/a.txt deleted file mode 100644 index e69de29bb..000000000 From 3d169a881e6b22b0436b3dce0861e51b775b11be Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Tue, 8 Aug 2023 14:10:45 +0530 Subject: [PATCH 118/166] disable auto changelog PR on merge (#728) --- .github/workflows/push.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 11081c642..771dd857a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -11,16 +11,6 @@ concurrency: cancel-in-progress: true on: # yamllint disable-line rule:truthy - push: - # branches to consider in the event; optional, defaults to all - branches: - - main - - 'releases/**' - - 'stable/**' - # Prevent a 2nd run after the changelog is updated - paths-ignore: - - CHANGELOG.rst - - changelogs/changelog.yaml workflow_dispatch: env: From f4494724ffa7189aab392d4683457f6cc87625c3 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 10 Aug 2023 11:26:34 +0530 Subject: [PATCH 119/166] Update all_green check (#732) Signed-off-by: NilashishC --- .github/workflows/tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bd2ffcc74..3e24cbcd8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,10 +40,11 @@ jobs: runs-on: ubuntu-latest steps: - run: >- - python -c "assert set([ + python -c "assert 'failure' not in + set([ '${{ needs.ansible-lint.result }}', '${{ needs.changelog.result }}', '${{ needs.sanity.result }}', '${{ needs.unit-galaxy.result }}', '${{ needs.unit-source.result }}' - ]) == {'success', 'skipped'}" + ])" From 2eec66ad66b536acbc45b19a06b2aab08c7f3d04 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 10 Aug 2023 14:06:59 +0530 Subject: [PATCH 120/166] [acls] Fix parsing error when ACE has source port range (#731) Signed-off-by: NilashishC --- changelogs/fragments/fix_713.yaml | 3 +++ .../network/nxos/facts/acls/acls.py | 16 ++++++++----- .../modules/network/nxos/test_nxos_acls.py | 24 +++++++++++++++++-- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/fix_713.yaml diff --git a/changelogs/fragments/fix_713.yaml b/changelogs/fragments/fix_713.yaml new file mode 100644 index 000000000..b8bfdebad --- /dev/null +++ b/changelogs/fragments/fix_713.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713)." diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index 70ebfcdd8..bc3aeffb3 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -125,18 +125,20 @@ def get_endpoint(self, ace, pro): ace = re.sub(port_pro.group(1), "", ace, 1) ace = re.sub(port_pro.group(2), "", ace, 1) else: - limit = re.search(r"(range) (\w*) (\w*)", ace) + limit = re.search(r"range\s(?P\w+)\s(?P\w+)", ace) if limit: + rstart = limit.groupdict()["rstart"] + rend = limit.groupdict()["rend"] port_protocol.update( { "range": { - "start": limit.group(2), - "end": limit.group(3), + "start": rstart, + "end": rend, }, }, ) - ace = re.sub(limit.group(2), "", ace, 1) - ace = re.sub(limit.group(3), "", ace, 1) + range_substring = "range %s %s" % (rstart, rend) + ace = re.sub(range_substring, "", ace, 1) if port_protocol: ret_dict.update({"port_protocol": port_protocol}) return ace, ret_dict @@ -250,7 +252,9 @@ def render_config(self, spec, conf): acl = acl.split("\n") acl = [a.strip() for a in acl] acl = list(filter(None, acl)) - acls["name"] = re.match(r"(ip)?(v6)?\s?access-list (.*)", acl[0]).group(3) + acls["name"] = re.match(r"(ip)?(v6)?\s?access-list (.*)", acl[0]).group( + 3, + ) acls["aces"] = [] for ace in list(filter(None, acl[1:])): if re.search(r"^ip(.*)access-list.*", ace): diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index 6436e065b..631d72741 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -105,7 +105,9 @@ def test_nxos_acls_merged(self): 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 @@ def test_nxos_acls_rendered(self): "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 @@ def test_nxos_acls_parse_remark(self): """\ 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 @@ -739,6 +746,19 @@ def test_nxos_acls_parse_remark(self): "source": {"prefix": "10.0.0.0/24"}, "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", From 07b32903eeafb892ef94a2c7b2a2556b8203f136 Mon Sep 17 00:00:00 2001 From: Vinay M <63404819+roverflow@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:21:17 +0530 Subject: [PATCH 121/166] Added new codecov workflow (#733) --- changelogs/fragments/codecov_pr.yml | 3 +++ codecov.yml | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/codecov_pr.yml diff --git a/changelogs/fragments/codecov_pr.yml b/changelogs/fragments/codecov_pr.yml new file mode 100644 index 000000000..ad3c08ca7 --- /dev/null +++ b/changelogs/fragments/codecov_pr.yml @@ -0,0 +1,3 @@ +--- +trivial: + - codecov - added a new codecov workflow and changing codecov.yml for added functionality. diff --git a/codecov.yml b/codecov.yml index 816cb4409..c77c91a90 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,7 +1,12 @@ --- codecov: require_ci_to_pass: true -comment: false +comment: + layout: " diff, flags, files" + behavior: default + require_changes: false + require_base: false + require_head: true coverage: status: patch: false From a7b032417daa14e63e4952013f2e62a643d2908d Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 11 Aug 2023 15:05:53 +0530 Subject: [PATCH 122/166] [interfaces] re-apply MTU when changing mode to L2 (#734) Signed-off-by: NilashishC --- changelogs/fragments/fix_730.yaml | 3 ++ .../nxos/config/interfaces/interfaces.py | 22 +++++++-- .../network/nxos/test_nxos_interfaces.py | 46 +++++++++++++++++++ 3 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/fix_730.yaml diff --git a/changelogs/fragments/fix_730.yaml b/changelogs/fragments/fix_730.yaml new file mode 100644 index 000000000..501ad501f --- /dev/null +++ b/changelogs/fragments/fix_730.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730)." diff --git a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py index dd1e4aa32..8bd4f66e7 100644 --- a/plugins/module_utils/network/nxos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/nxos/config/interfaces/interfaces.py @@ -79,7 +79,9 @@ def get_system_defaults(self): """Wrapper method for `_connection.get()` This method exists solely to allow the unit test framework to mock device connection calls. """ - return self._connection.get("show running-config all | incl 'system default switchport'") + return self._connection.get( + "show running-config all | incl 'system default switchport'", + ) def edit_config(self, commands): """Wrapper method for `_connection.edit_config()` @@ -184,7 +186,9 @@ def set_state(self, want, have): state = self._module.params["state"] if state in ("overridden", "merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state), + msg="value of config parameter must not be empty for state {0}".format( + state, + ), ) commands = list() @@ -355,7 +359,11 @@ def default_enabled(self, want=None, have=None, action=""): or intf_def_enabled is None ): # L2-L3 is changing or this is a new virtual intf. Get new default. - intf_def_enabled = default_intf_enabled(name=name, sysdefs=sysdefs, mode=want_mode) + intf_def_enabled = default_intf_enabled( + name=name, + sysdefs=sysdefs, + mode=want_mode, + ) return intf_def_enabled def del_attribs(self, obj): @@ -426,8 +434,12 @@ def add_commands(self, d, obj_in_have=None): commands.append("shutdown") elif d["enabled"] is True and have_enabled is False: commands.append("no shutdown") - if "mtu" in d: - commands.append("mtu " + str(d["mtu"])) + if "mtu" in d or ("switchport" in commands): + # changing mode to layer2 defaults the MTU + # we need re-apply existing (non-default) MTU + mtu = d.get("mtu") or obj_in_have.get("mtu") + if mtu: + commands.append("mtu " + str(mtu)) if "ip_forward" in d: if d["ip_forward"] is True: commands.append("ip forward") diff --git a/tests/unit/modules/network/nxos/test_nxos_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_interfaces.py index 7dac77c98..fb8dae234 100644 --- a/tests/unit/modules/network/nxos/test_nxos_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_interfaces.py @@ -772,3 +772,49 @@ def test_vlan_enabled(self): 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) From 6fb13eec9328ad9e5ed1624e4f4f10391abc09df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:12:30 +0530 Subject: [PATCH 123/166] [pre-commit.ci] pre-commit autoupdate (#726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v3.0.0 → v3.0.1](https://github.com/asottile/add-trailing-comma/compare/v3.0.0...v3.0.1) - [github.com/pre-commit/mirrors-prettier: v3.0.0 → v3.0.1](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0...v3.0.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a8fe9643..1caa35198 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,12 +17,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.0 + rev: v3.0.1 hooks: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0" + rev: "v3.0.1" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" From a530022c69029cbd467cf8e9b018c3f2313e5650 Mon Sep 17 00:00:00 2001 From: Rohit Thakur Date: Thu, 17 Aug 2023 11:45:33 +0530 Subject: [PATCH 124/166] Update Docs with examples (#735) * Update Docs with examples Signed-off-by: rohitthakur2590 * update docs for bgp* resource modules Signed-off-by: rohitthakur2590 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: rohitthakur2590 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../fragments/_health_check_update_docs.yaml | 9 + ...co.nxos.nxos_bgp_address_family_module.rst | 155 +- docs/cisco.nxos.nxos_bgp_global_module.rst | 95 +- ...xos_bgp_neighbor_address_family_module.rst | 155 +- docs/cisco.nxos.nxos_bgp_templates_module.rst | 28 +- ...cisco.nxos.nxos_ospf_interfaces_module.rst | 1270 +++++++---------- docs/cisco.nxos.nxos_ospfv2_module.rst | 83 +- docs/cisco.nxos.nxos_ospfv3_module.rst | 91 +- plugins/modules/nxos_bgp_address_family.py | 84 +- plugins/modules/nxos_bgp_global.py | 66 +- .../nxos_bgp_neighbor_address_family.py | 84 +- plugins/modules/nxos_bgp_templates.py | 28 +- plugins/modules/nxos_ospf_interfaces.py | 1241 ++++++---------- plugins/modules/nxos_ospfv2.py | 54 +- plugins/modules/nxos_ospfv3.py | 62 +- 15 files changed, 1729 insertions(+), 1776 deletions(-) create mode 100644 changelogs/fragments/_health_check_update_docs.yaml diff --git a/changelogs/fragments/_health_check_update_docs.yaml b/changelogs/fragments/_health_check_update_docs.yaml new file mode 100644 index 000000000..908e0b5a7 --- /dev/null +++ b/changelogs/fragments/_health_check_update_docs.yaml @@ -0,0 +1,9 @@ +--- +doc_changes: + - Update examples for ospfv2 resource modules using yaml callback plugin. + - Update examples for ospfv3 resource modules using yaml callback plugin. + - Update examples for ospf_interfaces resource modules using yaml callback plugin. + - Update examples for bgp_global resource modules using yaml callback plugin. + - Update examples for bgp_address_family resource modules using yaml callback plugin. + - Update examples for bgp_templates resource modules using yaml callback plugin. + - Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. diff --git a/docs/cisco.nxos.nxos_bgp_address_family_module.rst b/docs/cisco.nxos.nxos_bgp_address_family_module.rst index 10444549a..8378c8439 100644 --- a/docs/cisco.nxos.nxos_bgp_address_family_module.rst +++ b/docs/cisco.nxos.nxos_bgp_address_family_module.rst @@ -1690,8 +1690,8 @@ Examples id: 101 route_map: rmap-eigrp-1 - # Task output - # ------------- + # Task output: + # ------------ # before: {} # # commands: @@ -1744,7 +1744,7 @@ Examples # route_map: rmap-eigrp-1 # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # address-family ipv4 multicast @@ -1804,8 +1804,8 @@ Examples vrf: site-1 state: replaced - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # address_family: @@ -1884,7 +1884,7 @@ Examples # route_map: rmap-eigrp-1 # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # address-family ipv4 multicast @@ -1936,8 +1936,8 @@ Examples vrf: site-1 state: overridden - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # address_family: @@ -2005,7 +2005,7 @@ Examples # # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # address-family ipv4 multicast @@ -2046,8 +2046,8 @@ Examples safi: multicast state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # address_family: @@ -2102,7 +2102,7 @@ Examples # summary_only: True # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # vrf site-1 @@ -2133,8 +2133,8 @@ Examples cisco.nxos.nxos_bgp_address_family: state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # address_family: @@ -2180,7 +2180,7 @@ Examples # as_number: "65536" # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # Nexus9000v# @@ -2224,8 +2224,8 @@ Examples route_map: rmap-eigrp-1 state: rendered - # Task Output (redacted) - # ----------------------- + # Task Output: + # ------------ # rendered: # - router bgp 65536 # - address-family ipv4 multicast @@ -2264,8 +2264,8 @@ Examples running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # parsed: # as_number: "65536" # address_family: @@ -2302,6 +2302,123 @@ Examples +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ after + +
+ dictionary +
+
when changed +
The resulting configuration after module execution.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ before + +
+ dictionary +
+
when state is merged, replaced, overridden, deleted or purged +
The configuration prior to the module execution.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ commands + +
+ list +
+
when state is merged, replaced, overridden, deleted or purged +
The set of commands pushed to the remote device.
+
+
Sample:
+
['router bgp 65536', 'address-family ipv4 multicast', 'nexthop route-map rmap2']
+
+
+ gathered + +
+ dictionary +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ dictionary +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['router bgp 65536', 'address-family ipv4 multicast', 'nexthop route-map rmap2']
+
+

+ Status ------ diff --git a/docs/cisco.nxos.nxos_bgp_global_module.rst b/docs/cisco.nxos.nxos_bgp_global_module.rst index 519faf025..c75def25f 100644 --- a/docs/cisco.nxos.nxos_bgp_global_module.rst +++ b/docs/cisco.nxos.nxos_bgp_global_module.rst @@ -4650,8 +4650,8 @@ Examples neighbor_down: fib_accelerate: True - # Task output - # ------------- + # Task output: + # ------------ # before: {} # # commands: @@ -4756,7 +4756,7 @@ Examples # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65563 # router-id 192.168.1.1 @@ -4880,8 +4880,8 @@ Examples fib_accelerate: True state: replaced - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: '65563' # bestpath: @@ -4994,7 +4994,7 @@ Examples # vrf: site-2 # # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65563 # router-id 192.168.1.1 @@ -5075,8 +5075,8 @@ Examples cisco.nxos.nxos_bgp_global: state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: '65563' @@ -5158,7 +5158,7 @@ Examples # as_number: '65563' # # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65563 # address-family ipv4 unicast @@ -5228,8 +5228,8 @@ Examples cisco.nxos.nxos_bgp_global: state: purged - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: '65563' @@ -5297,7 +5297,7 @@ Examples # after: {} # # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # Nexus9000v# @@ -5365,8 +5365,8 @@ Examples neighbor_down: fib_accelerate: True - # Task Output (redacted) - # ----------------------- + # Task output: + # ------------ # rendered: # - router bgp 65563 # - bestpath as-path multipath-relax @@ -5455,8 +5455,8 @@ Examples running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # parsed: # as_number: '65563' # bestpath: @@ -5548,8 +5548,8 @@ Examples cisco.nxos.nxos_bgp_global: state: gathered - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # gathered: # as_number: '65563' # bestpath: @@ -5622,8 +5622,8 @@ Examples key: 12090404011C03162E state: replaced - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # fatal: [Nexus9000v]: FAILED! => changed=false # msg: Neighbor 203.0.113.2 has address-family configurations. # Please use the nxos_bgp_neighbor_af module to remove those first. @@ -5670,8 +5670,8 @@ Examples fib_accelerate: True state: replaced - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # fatal: [Nexus9000v]: FAILED! => changed=false # msg: VRF site-1 has address-family configurations. # Please use the nxos_bgp_af module to remove those first. @@ -5743,6 +5743,57 @@ Common return values are documented `here ['router bgp 65563', 'maxas-limit 20', 'router-id 192.168.1.1', 'confederation peers 65020 65030 65040', 'neighbor 192.168.1.100', 'remote-as 65563', 'affinity-group 160', 'bmp-activate-server 1', 'description NBR-1', 'low-memory exempt', 'vrf site-1', 'log-neighbor-changes', 'neighbor 198.51.100.1', 'remote-as 65562', 'description site-1-nbr-1', 'password 3 13D4D3549493D2877B1DC116EE27A6BE']
+
+ gathered + +
+ dictionary +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ dictionary +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['router bgp 65563', 'maxas-limit 20', 'router-id 192.168.1.1']
+


diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst index 0473c5d76..5148c878c 100644 --- a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst +++ b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst @@ -2599,8 +2599,8 @@ Examples send_community: set: True - # Task output - # ------------- + # Task output: + # ------------ # before: {} # # commands: @@ -2668,7 +2668,7 @@ Examples # safi: unicast # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -2755,8 +2755,8 @@ Examples set: True state: replaced - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # neighbors: @@ -2847,7 +2847,7 @@ Examples # safi: unicast # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -2914,8 +2914,8 @@ Examples set: True state: overridden - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # neighbors: @@ -2993,7 +2993,7 @@ Examples # set: True # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -3049,8 +3049,8 @@ Examples safi: unicast state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # neighbors: @@ -3133,7 +3133,7 @@ Examples # set: True # # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -3182,8 +3182,8 @@ Examples cisco.nxos.nxos_bgp_neighbor_address_family: state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # as_number: "65536" # neighbors: @@ -3244,7 +3244,7 @@ Examples # as_number: "65536" # # After state: - # ------------- + # ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -3301,8 +3301,8 @@ Examples set: True state: rendered - # Task Output (redacted) - # ----------------------- + # Task output: + # ------------ # rendered: # - router bgp 65536 # - neighbor 192.0.2.32 @@ -3356,8 +3356,8 @@ Examples running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # parsed: # as_number: "65536" # neighbors: @@ -3402,6 +3402,123 @@ Examples +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ after + +
+ dictionary +
+
when changed +
The resulting configuration after module execution.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ before + +
+ dictionary +
+
when state is merged, replaced, overridden, deleted or purged +
The configuration prior to the module execution.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ commands + +
+ list +
+
when state is merged, replaced, overridden, deleted or purged +
The set of commands pushed to the remote device.
+
+
Sample:
+
['router bgp 65536', 'neighbor 192.0.2.32', 'address-family ipv4 unicast']
+
+
+ gathered + +
+ dictionary +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ dictionary +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['router bgp 65536', 'neighbor 192.0.2.32', 'address-family ipv4 unicast']
+
+

+ Status ------ diff --git a/docs/cisco.nxos.nxos_bgp_templates_module.rst b/docs/cisco.nxos.nxos_bgp_templates_module.rst index 3a2f9dc39..bae0c7318 100644 --- a/docs/cisco.nxos.nxos_bgp_templates_module.rst +++ b/docs/cisco.nxos.nxos_bgp_templates_module.rst @@ -2233,8 +2233,8 @@ Examples timers: holdtime: 100 keepalive: 45 - # Task Output - # ----------- + # Task Output: + # ------------ # before: {} # # commands: @@ -2324,7 +2324,7 @@ Examples # Using replaced # Before state: - # -------------- + # ------------- # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -2368,8 +2368,8 @@ Examples local_as: 65537 state: replaced - # Task Output - # ----------- + # Task output: + # ------------ # # before: # as_number: "65536" @@ -2453,7 +2453,7 @@ Examples # keepalive: 45 # After state: - # -------------- + # ------------ # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -2479,7 +2479,7 @@ Examples # Using overridden # # Before state: - # -------------- + # ------------- # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -2523,8 +2523,8 @@ Examples local_as: 65537 state: overridden - # Task Output - # ----------- + # Task output: + # ------------ # # before: # as_number: "65536" @@ -2591,7 +2591,7 @@ Examples # local_as: "65537" # After state: - # -------------- + # ------------ # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -2635,8 +2635,8 @@ Examples cisco.nxos.nxos_bgp_templates: state: deleted - # Task Output - # ----------- + # Task output: + # ------------ # # before: # as_number: "65536" @@ -2758,7 +2758,7 @@ Common return values are documented `here gathered
- list + dictionary
when state is gatheredwhen state is parsed
+
+ gathered + +
+ list +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ list +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['interface Ethernet1/1', 'ip router ospf multi-area 11.11.11.11', 'ip router ospf 100 area 1.1.1.1 secondaries none']
+


diff --git a/docs/cisco.nxos.nxos_ospfv2_module.rst b/docs/cisco.nxos.nxos_ospfv2_module.rst index fabb4d7e4..bc5613068 100644 --- a/docs/cisco.nxos.nxos_ospfv2_module.rst +++ b/docs/cisco.nxos.nxos_ospfv2_module.rst @@ -4484,8 +4484,8 @@ Examples unit: Gbps state: merged - # Task output - # ------------- + # Task output: + # ------------ # before: {} # # commands: @@ -4650,8 +4650,8 @@ Examples no_summary: true state: replaced - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -4810,8 +4810,8 @@ Examples shutdown: true state: overridden - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -4928,8 +4928,8 @@ Examples - process_id: 102 state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -5024,8 +5024,8 @@ Examples cisco.nxos.nxos_ospfv2: state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -5144,8 +5144,8 @@ Examples unit: Gbps state: rendered - # Task Output (redacted) - # ----------------------- + # Task output: + # ------------ # rendered: # - router ospf 100 # - router-id 203.0.113.20 @@ -5208,8 +5208,8 @@ Examples running_config: "{{ lookup('file', 'ospfv2.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # parsed: # processes: # - process_id: "100" @@ -5283,8 +5283,8 @@ Examples cisco.nxos.nxos_ospfv2: state: gathered - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # gathered: # processes: # - process_id: "102" @@ -5387,6 +5387,57 @@ Common return values are documented `here ['router ospf 102', 'router-id 198.54.100.1', 'router ospf 100', 'router-id 192.0.100.1', 'redistribute eigrp 120 route-map rmap_1', 'redistribute direct route-map ospf-direct-connect', 'area 0.0.0.100 filter-list route-map rmap_1 in', 'area 0.0.0.100 filter-list route-map rmap_2 out', 'area 0.0.0.100 range 192.0.2.0/24 not-advertise', 'area 0.0.0.100 range 192.0.3.0/24 cost 120', 'vrf zone1', 'router-id 192.0.100.2', 'summary-address 10.0.0.0/24 tag 121', 'summary-address 11.0.0.0/24', 'redistribute static route-map zone1-direct-connect', 'vrf zone2', 'auto-cost reference-bandwidth 45 Gbps', 'capability vrf-lite evpn']
+
+ gathered + +
+ dictionary +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ dictionary +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['router ospf 102', 'router-id 198.54.100.1', 'router ospf 100']
+


diff --git a/docs/cisco.nxos.nxos_ospfv3_module.rst b/docs/cisco.nxos.nxos_ospfv3_module.rst index 0fa5710ed..0c4c9efed 100644 --- a/docs/cisco.nxos.nxos_ospfv3_module.rst +++ b/docs/cisco.nxos.nxos_ospfv3_module.rst @@ -3615,8 +3615,8 @@ Examples unit: Gbps state: merged - # Task output - # ------------- + # Task output: + # ------------ # before: {} # # commands: @@ -3711,7 +3711,7 @@ Examples # Using replaced # Before state: - # ------------ + # ------------- # nxos-9k-rdo# sh running-config | section "^router ospfv3" # router ospfv3 100 # router-id 203.0.113.20 @@ -3765,8 +3765,8 @@ Examples no_summary: True state: replaced - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -3877,7 +3877,7 @@ Examples # Using overridden # Before state: - # ------------ + # ------------- # nxos-9k-rdo# sh running-config | section "^router ospfv3" # router ospfv3 100 # router-id 203.0.113.20 @@ -3909,8 +3909,8 @@ Examples shutdown: true state: overridden - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -3997,7 +3997,7 @@ Examples # Using deleted to delete a single OSPF process # Before state: - # ------------ + # ------------- # nxos-9k-rdo# sh running-config | section "^router ospf .*" # router ospfv3 100 # router-id 203.0.113.20 @@ -4025,8 +4025,8 @@ Examples - process_id: 102 state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -4090,7 +4090,7 @@ Examples # Using deleted all OSPFv3 processes from the device # Before state: - # ------------ + # ------------- # nxos-9k-rdo# sh running-config | section "^router ospfv3" # router ospfv3 100 # router-id 203.0.113.20 @@ -4115,8 +4115,8 @@ Examples cisco.nxos.nxos_ospfv3: state: deleted - # Task output - # ------------- + # Task output: + # ------------ # before: # processes: # - process_id: "100" @@ -4225,8 +4225,8 @@ Examples unit: Gbps state: rendered - # Task Output (redacted) - # ----------------------- + # Task output: + # ------------ # rendered: # - router ospfv3 100 # - router-id 203.0.113.20 @@ -4272,8 +4272,8 @@ Examples running_config: "{{ lookup('file', 'ospfv2.cfg') }}" state: parsed - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # parsed: # processes: # - process_id: "100" @@ -4323,8 +4323,8 @@ Examples cisco.nxos.nxos_ospfv3: state: gathered - # Task output (redacted) - # ----------------------- + # Task output: + # ------------ # gathered: # processes: # - process_id: "100" @@ -4439,6 +4439,57 @@ Common return values are documented `here ['router ospfv3 102', 'router-id 198.54.100.1', 'router ospfv3 100', 'router-id 192.0.100.1', 'address-family ipv6 unicast', 'redistribute eigrp 120 route-map rmap_1', 'redistribute direct route-map ospf-direct-connect', 'area 0.0.0.100 filter-list route-map rmap_1 in', 'area 0.0.0.100 filter-list route-map rmap_2 out', 'area 0.0.0.100 range 2001:db2::/32 not-advertise', 'area 0.0.0.100 range 2001:db3::/32 cost 120', 'vrf zone1', 'router-id 192.0.100.2', 'vrf zone2', 'auto-cost reference-bandwidth 45 Gbps']
+
+ gathered + +
+ dictionary +
+
when state is gathered +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ parsed + +
+ dictionary +
+
when state is parsed +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+
+
+ rendered + +
+ list +
+
when state is rendered +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['router ospfv3 102', 'router-id 198.54.100.1', 'router ospfv3 100']
+


diff --git a/plugins/modules/nxos_bgp_address_family.py b/plugins/modules/nxos_bgp_address_family.py index c838d25fa..ef6e9012c 100644 --- a/plugins/modules/nxos_bgp_address_family.py +++ b/plugins/modules/nxos_bgp_address_family.py @@ -383,8 +383,8 @@ id: 101 route_map: rmap-eigrp-1 -# Task output -# ------------- +# Task output: +# ------------ # before: {} # # commands: @@ -437,7 +437,7 @@ # route_map: rmap-eigrp-1 # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # address-family ipv4 multicast @@ -497,8 +497,8 @@ vrf: site-1 state: replaced -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # address_family: @@ -577,7 +577,7 @@ # route_map: rmap-eigrp-1 # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # address-family ipv4 multicast @@ -629,8 +629,8 @@ vrf: site-1 state: overridden -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # address_family: @@ -698,7 +698,7 @@ # # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # address-family ipv4 multicast @@ -739,8 +739,8 @@ safi: multicast state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # address_family: @@ -795,7 +795,7 @@ # summary_only: True # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # vrf site-1 @@ -826,8 +826,8 @@ cisco.nxos.nxos_bgp_address_family: state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # address_family: @@ -873,7 +873,7 @@ # as_number: "65536" # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # Nexus9000v# @@ -917,8 +917,8 @@ route_map: rmap-eigrp-1 state: rendered -# Task Output (redacted) -# ----------------------- +# Task Output: +# ------------ # rendered: # - router bgp 65536 # - address-family ipv4 multicast @@ -957,8 +957,8 @@ running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # parsed: # as_number: "65536" # address_family: @@ -993,6 +993,52 @@ # protocol: eigrp # route_map: rmap-eigrp-1 """ +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - router bgp 65536 + - address-family ipv4 multicast + - nexthop route-map rmap2 +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router bgp 65536 + - address-family ipv4 multicast + - nexthop route-map rmap2 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +""" from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/nxos_bgp_global.py b/plugins/modules/nxos_bgp_global.py index 15dcb5d16..6a34bc777 100644 --- a/plugins/modules/nxos_bgp_global.py +++ b/plugins/modules/nxos_bgp_global.py @@ -595,8 +595,8 @@ neighbor_down: fib_accelerate: True -# Task output -# ------------- +# Task output: +# ------------ # before: {} # # commands: @@ -701,7 +701,7 @@ # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65563 # router-id 192.168.1.1 @@ -825,8 +825,8 @@ fib_accelerate: True state: replaced -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: '65563' # bestpath: @@ -939,7 +939,7 @@ # vrf: site-2 # # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65563 # router-id 192.168.1.1 @@ -1020,8 +1020,8 @@ cisco.nxos.nxos_bgp_global: state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: '65563' @@ -1103,7 +1103,7 @@ # as_number: '65563' # # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65563 # address-family ipv4 unicast @@ -1173,8 +1173,8 @@ cisco.nxos.nxos_bgp_global: state: purged -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: '65563' @@ -1242,7 +1242,7 @@ # after: {} # # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # Nexus9000v# @@ -1310,8 +1310,8 @@ neighbor_down: fib_accelerate: True -# Task Output (redacted) -# ----------------------- +# Task output: +# ------------ # rendered: # - router bgp 65563 # - bestpath as-path multipath-relax @@ -1400,8 +1400,8 @@ running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # parsed: # as_number: '65563' # bestpath: @@ -1493,8 +1493,8 @@ cisco.nxos.nxos_bgp_global: state: gathered -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # gathered: # as_number: '65563' # bestpath: @@ -1567,8 +1567,8 @@ key: 12090404011C03162E state: replaced -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # fatal: [Nexus9000v]: FAILED! => changed=false # msg: Neighbor 203.0.113.2 has address-family configurations. # Please use the nxos_bgp_neighbor_af module to remove those first. @@ -1615,8 +1615,8 @@ fib_accelerate: True state: replaced -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # fatal: [Nexus9000v]: FAILED! => changed=false # msg: VRF site-1 has address-family configurations. # Please use the nxos_bgp_af module to remove those first. @@ -1658,6 +1658,28 @@ - remote-as 65562 - description site-1-nbr-1 - password 3 13D4D3549493D2877B1DC116EE27A6BE +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router bgp 65563 + - maxas-limit 20 + - router-id 192.168.1.1 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/nxos_bgp_neighbor_address_family.py b/plugins/modules/nxos_bgp_neighbor_address_family.py index 967f8ee4e..299691bb7 100644 --- a/plugins/modules/nxos_bgp_neighbor_address_family.py +++ b/plugins/modules/nxos_bgp_neighbor_address_family.py @@ -316,8 +316,8 @@ send_community: set: True -# Task output -# ------------- +# Task output: +# ------------ # before: {} # # commands: @@ -385,7 +385,7 @@ # safi: unicast # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -472,8 +472,8 @@ set: True state: replaced -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # neighbors: @@ -564,7 +564,7 @@ # safi: unicast # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -631,8 +631,8 @@ set: True state: overridden -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # neighbors: @@ -710,7 +710,7 @@ # set: True # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -766,8 +766,8 @@ safi: unicast state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # neighbors: @@ -850,7 +850,7 @@ # set: True # # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -899,8 +899,8 @@ cisco.nxos.nxos_bgp_neighbor_address_family: state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # as_number: "65536" # neighbors: @@ -961,7 +961,7 @@ # as_number: "65536" # # After state: -# ------------- +# ------------ # Nexus9000v# show running-config | section "^router bgp" # router bgp 65536 # neighbor 192.0.2.32 @@ -1018,8 +1018,8 @@ set: True state: rendered -# Task Output (redacted) -# ----------------------- +# Task output: +# ------------ # rendered: # - router bgp 65536 # - neighbor 192.0.2.32 @@ -1073,8 +1073,8 @@ running_config: "{{ lookup('file', 'parsed.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # parsed: # as_number: "65536" # neighbors: @@ -1117,6 +1117,52 @@ # - afi: ipv6 # safi: unicast """ +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - router bgp 65536 + - neighbor 192.0.2.32 + - address-family ipv4 unicast +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router bgp 65536 + - neighbor 192.0.2.32 + - address-family ipv4 unicast +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +""" from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/nxos_bgp_templates.py b/plugins/modules/nxos_bgp_templates.py index 97ecb69bb..669c833c5 100644 --- a/plugins/modules/nxos_bgp_templates.py +++ b/plugins/modules/nxos_bgp_templates.py @@ -465,8 +465,8 @@ timers: holdtime: 100 keepalive: 45 -# Task Output -# ----------- +# Task Output: +# ------------ # before: {} # # commands: @@ -556,7 +556,7 @@ # Using replaced # Before state: -# -------------- +# ------------- # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -600,8 +600,8 @@ local_as: 65537 state: replaced -# Task Output -# ----------- +# Task output: +# ------------ # # before: # as_number: "65536" @@ -685,7 +685,7 @@ # keepalive: 45 # After state: -# -------------- +# ------------ # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -711,7 +711,7 @@ # Using overridden # # Before state: -# -------------- +# ------------- # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -755,8 +755,8 @@ local_as: 65537 state: overridden -# Task Output -# ----------- +# Task output: +# ------------ # # before: # as_number: "65536" @@ -823,7 +823,7 @@ # local_as: "65537" # After state: -# -------------- +# ------------ # # nxos9k# show running-config | section "^router bgp" # router bgp 65536 @@ -867,8 +867,8 @@ cisco.nxos.nxos_bgp_templates: state: deleted -# Task Output -# ----------- +# Task output: +# ------------ # # before: # as_number: "65536" @@ -961,14 +961,14 @@ gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) - type: list + type: dict sample: > This output will always be in the same format as the module argspec. parsed: description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. returned: when I(state) is C(parsed) - type: list + type: dict sample: > This output will always be in the same format as the module argspec. diff --git a/plugins/modules/nxos_ospf_interfaces.py b/plugins/modules/nxos_ospf_interfaces.py index c0a754c76..81c4ad45b 100644 --- a/plugins/modules/nxos_ospf_interfaces.py +++ b/plugins/modules/nxos_ospf_interfaces.py @@ -278,122 +278,77 @@ key: 12090404011C03162E state: merged -# Task output -# ------------- -# "before": [ -# { -# "name": "Ethernet1/1" -# }, -# { -# "name": "Ethernet1/2" -# }, -# { -# "name": "Ethernet1/3" -# }, -# ] +# Task output: +# ------------ +# before: +# - name: Ethernet1/1 +# - name: Ethernet1/2 +# - name: Ethernet1/3 # -# "commands": [ -# "interface Ethernet1/1", -# "ip router ospf multi-area 11.11.11.11", -# "ip router ospf 100 area 1.1.1.1 secondaries none", -# "ipv6 router ospfv3 multi-area 16.10.10.10", -# "ipv6 router ospfv3 200 area 2.2.2.2", -# "ipv6 router ospfv3 200 multi-area 21.0.0.0", -# "ipv6 router ospfv3 300 multi-area 50.50.50.50", -# "interface Ethernet1/2", -# "ip ospf authentication key-chain test-1", -# "ip ospf authentication", -# "ip ospf message-digest-key 10 md5 3 abc01d272be25d29", -# "ip ospf cost 100", -# "ospfv3 network broadcast", -# "ospfv3 shutdown", -# "interface Ethernet1/3", -# "ip ospf authentication-key 7 12090404011C03162E" -# ] +# commands: +# - interface Ethernet1/1 +# - ip router ospf multi-area 11.11.11.11 +# - ip router ospf 100 area 1.1.1.1 secondaries none +# - ipv6 router ospfv3 multi-area 16.10.10.10 +# - ipv6 router ospfv3 200 area 2.2.2.2 +# - ipv6 router ospfv3 200 multi-area 21.0.0.0 +# - ipv6 router ospfv3 300 multi-area 50.50.50.50 +# - interface Ethernet1/2 +# - ip ospf authentication key-chain test-1 +# - ip ospf authentication +# - ip ospf message-digest-key 10 md5 3 abc01d272be25d29 +# - ip ospf cost 100 +# - ospfv3 network broadcast +# - ospfv3 shutdown +# - interface Ethernet1/3 +# - ip ospf authentication-key 7 12090404011C03162E # -# "after": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.11" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "multi_areas": [ -# "16.10.10.10" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "2.2.2.2" -# }, -# "multi_areas": [ -# "21.0.0.0" -# ], -# "process_id": "200" -# }, -# { -# "multi_areas": [ -# "50.50.50.50" -# ], -# "process_id": "300" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# after: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.11 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# - afi: ipv6 +# multi_areas: +# - 16.10.10.10 +# processes: +# - area: +# area_id: 2.2.2.2 +# multi_areas: +# - 21.0.0.0 +# process_id: '200' +# - multi_areas: +# - 50.50.50.50 +# process_id: '300' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 # After state: -# ------------- +# ------------ # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -419,7 +374,7 @@ # Using replaced # Before state: -# ------------ +# ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -457,151 +412,92 @@ - name: Ethernet1/3 state: replaced -# Task output -# ------------- -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.11" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "multi_areas": [ -# "16.10.10.10" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "2.2.2.2" -# }, -# "multi_areas": [ -# "21.0.0.0" -# ], -# "process_id": "200" -# }, -# { -# "multi_areas": [ -# "50.50.50.50" -# ], -# "process_id": "300" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# Task output: +# ------------ +# before: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.11 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# - afi: ipv6 +# multi_areas: +# - 16.10.10.10 +# processes: +# - area: +# area_id: 2.2.2.2 +# multi_areas: +# - 21.0.0.0 +# process_id: '200' +# - multi_areas: +# - 50.50.50.50 +# process_id: '300' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 # -# "commands": [ -# "interface Ethernet1/1", -# "ip router ospf multi-area 11.11.11.12", -# "no ip router ospf multi-area 11.11.11.11", -# "no ipv6 router ospfv3 multi-area 16.10.10.10", -# "no ipv6 router ospfv3 200 area 2.2.2.2", -# "no ipv6 router ospfv3 200 multi-area 21.0.0.0", -# "no ipv6 router ospfv3 300 multi-area 50.50.50.50", -# "interface Ethernet1/3", -# "no ip ospf authentication-key 7 12090404011C03162E" -# ] +# commands: +# - interface Ethernet1/1 +# - ip router ospf multi-area 11.11.11.12 +# - no ip router ospf multi-area 11.11.11.11 +# - no ipv6 router ospfv3 multi-area 16.10.10.10 +# - no ipv6 router ospfv3 200 area 2.2.2.2 +# - no ipv6 router ospfv3 200 multi-area 21.0.0.0 +# - no ipv6 router ospfv3 300 multi-area 50.50.50.50 +# - interface Ethernet1/3 +# - no ip ospf authentication-key 7 12090404011C03162E # -# "after": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.12" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "name": "Ethernet1/3" -# }, +# after: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.12 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - name: Ethernet1/3 # # After state: -# ------------- +# ------------ # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -622,7 +518,7 @@ # Using overridden # Before state: -# ------------ +# ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -659,136 +555,83 @@ - 11.11.11.12 state: overridden -# Task output -# ------------- -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.11" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "multi_areas": [ -# "16.10.10.10" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "2.2.2.2" -# }, -# "multi_areas": [ -# "21.0.0.0" -# ], -# "process_id": "200" -# }, -# { -# "multi_areas": [ -# "50.50.50.50" -# ], -# "process_id": "300" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# Task output: +# ------------ +# before: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.11 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# - afi: ipv6 +# multi_areas: +# - 16.10.10.10 +# processes: +# - area: +# area_id: 2.2.2.2 +# multi_areas: +# - 21.0.0.0 +# process_id: '200' +# - multi_areas: +# - 50.50.50.50 +# process_id: '300' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 # -# "commands": [ -# "interface Ethernet1/2", -# "no ip ospf authentication key-chain test-1", -# "no ip ospf authentication", -# "no ip ospf message-digest-key 10 md5 3 abc01d272be25d29", -# "no ip ospf cost 100", -# "no ospfv3 network broadcast", -# "no ospfv3 shutdown", -# "interface Ethernet1/3", -# "no ip ospf authentication-key 7 12090404011C03162E", -# "interface Ethernet1/1", -# "ip router ospf multi-area 11.11.11.12", -# "no ip router ospf multi-area 11.11.11.11", -# "no ipv6 router ospfv3 multi-area 16.10.10.10", -# "no ipv6 router ospfv3 200 area 2.2.2.2", -# "no ipv6 router ospfv3 200 multi-area 21.0.0.0", -# "no ipv6 router ospfv3 300 multi-area 50.50.50.50" -# ] +# commands: +# - interface Ethernet1/2 +# - no ip ospf authentication key-chain test-1 +# - no ip ospf authentication +# - no ip ospf message-digest-key 10 md5 3 abc01d272be25d29 +# - no ip ospf cost 100 +# - no ospfv3 network broadcast +# - no ospfv3 shutdown +# - interface Ethernet1/3 +# - no ip ospf authentication-key 7 12090404011C03162E +# - interface Ethernet1/1 +# - ip router ospf multi-area 11.11.11.12 +# - no ip router ospf multi-area 11.11.11.11 +# - no ipv6 router ospfv3 multi-area 16.10.10.10 +# - no ipv6 router ospfv3 200 area 2.2.2.2 +# - no ipv6 router ospfv3 200 multi-area 21.0.0.0 +# - no ipv6 router ospfv3 300 multi-area 50.50.50.50 # -# "after": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.12" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "name": "Ethernet1/2" -# }, -# { -# "name": "Ethernet1/3" -# }, -# ] +# after: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.12 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# name: Ethernet1/1 +# - name: Ethernet1/2 +# - name: Ethernet1/3 # After state: # ------------- @@ -805,7 +648,7 @@ # Using deleted to delete OSPF config of a single interface # Before state: -# ------------ +# ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -833,139 +676,84 @@ - name: Ethernet1/1 state: deleted -# Task output -# ------------- -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.11" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "multi_areas": [ -# "16.10.10.10" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "2.2.2.2" -# }, -# "multi_areas": [ -# "21.0.0.0" -# ], -# "process_id": "200" -# }, -# { -# "multi_areas": [ -# "50.50.50.50" -# ], -# "process_id": "300" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# Task output: +# ------------ +# before: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.11 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# - afi: ipv6 +# multi_areas: +# - 16.10.10.10 +# processes: +# - area: +# area_id: 2.2.2.2 +# multi_areas: +# - 21.0.0.0 +# process_id: '200' +# - multi_areas: +# - 50.50.50.50 +# process_id: '300' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 # -# "commands": [ -# "interface Ethernet1/1", -# "no ip router ospf multi-area 11.11.11.11", -# "no ip router ospf 100 area 1.1.1.1 secondaries none", -# "no ipv6 router ospfv3 multi-area 16.10.10.10", -# "no ipv6 router ospfv3 200 area 2.2.2.2", -# "no ipv6 router ospfv3 200 multi-area 21.0.0.0", -# "no ipv6 router ospfv3 300 multi-area 50.50.50.50" -# ] +# commands: +# - interface Ethernet1/1 +# - no ip router ospf multi-area 11.11.11.11 +# - no ip router ospf 100 area 1.1.1.1 secondaries none +# - no ipv6 router ospfv3 multi-area 16.10.10.10 +# - no ipv6 router ospfv3 200 area 2.2.2.2 +# - no ipv6 router ospfv3 200 multi-area 21.0.0.0 +# - no ipv6 router ospfv3 300 multi-area 50.50.50.50 # -# "before": [ -# { -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# after: +# - name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 + # After state: # ------------ @@ -987,7 +775,7 @@ # Using deleted to delete OSPF config from all interfaces # Before state: -# ------------ +# ------------- # NXOS# show running-config | section ^interface # interface Ethernet1/1 # no switchport @@ -1013,119 +801,53 @@ cisco.nxos.nxos_ospf_interfaces: state: deleted -# Task output -# ------------- -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.11" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "multi_areas": [ -# "16.10.10.10" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "2.2.2.2" -# }, -# "multi_areas": [ -# "21.0.0.0" -# ], -# "process_id": "200" -# }, -# { -# "multi_areas": [ -# "50.50.50.50" -# ], -# "process_id": "300" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# Task output: +# ------------ +# before: +# - name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 # -# "commands": [ -# "interface Ethernet1/1", -# "no ip router ospf multi-area 11.11.11.11", -# "no ip router ospf 100 area 1.1.1.1 secondaries none", -# "no ipv6 router ospfv3 multi-area 16.10.10.10", -# "no ipv6 router ospfv3 200 area 2.2.2.2", -# "no ipv6 router ospfv3 200 multi-area 21.0.0.0", -# "no ipv6 router ospfv3 300 multi-area 50.50.50.50", -# "interface Ethernet1/2", -# "no ip ospf authentication key-chain test-1", -# "no ip ospf authentication", -# "no ip ospf message-digest-key 10 md5 3 abc01d272be25d29", -# "no ip ospf cost 100", -# "no ospfv3 network broadcast", -# "no ospfv3 shutdown", -# "interface Ethernet1/3", -# "no ip ospf authentication-key 7 12090404011C03162E" -# ] +# commands: +# - interface Ethernet1/1 +# - no ip router ospf multi-area 11.11.11.11 +# - no ip router ospf 100 area 1.1.1.1 secondaries none +# - no ipv6 router ospfv3 multi-area 16.10.10.10 +# - no ipv6 router ospfv3 200 area 2.2.2.2 +# - no ipv6 router ospfv3 200 multi-area 21.0.0.0 +# - no ipv6 router ospfv3 300 multi-area 50.50.50.50 +# - interface Ethernet1/2 +# - no ip ospf authentication key-chain test-1 +# - no ip ospf authentication +# - no ip ospf message-digest-key 10 md5 3 abc01d272be25d29 +# - no ip ospf cost 100 +# - no ospfv3 network broadcast +# - no ospfv3 shutdown +# - interface Ethernet1/3 +# - no ip ospf authentication-key 7 12090404011C03162E # -# "after": [ -# { -# "name": "Ethernet1/1" -# }, -# { -# "name": "Ethernet1/2" -# }, -# { -# "name": "Ethernet1/3" -# }, -# ] +# after: +# - name: Ethernet1/1 +# - name: Ethernet1/2 +# - name: Ethernet1/3 # After state: # ------------ @@ -1186,26 +908,25 @@ key: 12090404011C03162E state: rendered -# Task Output (redacted) -# ----------------------- -# "rendered": [ -# "interface Ethernet1/1", -# "ip router ospf multi-area 11.11.11.11", -# "ip router ospf 100 area 1.1.1.1 secondaries none", -# "ipv6 router ospfv3 multi-area 16.10.10.10", -# "ipv6 router ospfv3 200 area 2.2.2.2", -# "ipv6 router ospfv3 200 multi-area 21.0.0.0", -# "ipv6 router ospfv3 300 multi-area 50.50.50.50", -# "interface Ethernet1/2", -# "ip ospf authentication key-chain test-1", -# "ip ospf authentication", -# "ip ospf message-digest-key 10 md5 3 abc01d272be25d29", -# "ip ospf cost 100", -# "ospfv3 network broadcast", -# "ospfv3 shutdown", -# "interface Ethernet1/3", -# "ip ospf authentication-key 7 12090404011C03162E" -# ] +# Task Output: +# ------------ +# rendered: +# - interface Ethernet1/1 +# - ip router ospf multi-area 11.11.11.11 +# - ip router ospf 100 area 1.1.1.1 secondaries none +# - ipv6 router ospfv3 multi-area 16.10.10.10 +# - ipv6 router ospfv3 200 area 2.2.2.2 +# - ipv6 router ospfv3 200 multi-area 21.0.0.0 +# - ipv6 router ospfv3 300 multi-area 50.50.50.50 +# - interface Ethernet1/2 +# - ip ospf authentication key-chain test-1 +# - ip ospf authentication +# - ip ospf message-digest-key 10 md5 3 abc01d272be25d29 +# - ip ospf cost 100 +# - ospfv3 network broadcast +# - ospfv3 shutdown +# - interface Ethernet1/3 +# - ip ospf authentication-key 7 12090404011C03162E # Using parsed @@ -1233,88 +954,51 @@ running_config: "{{ lookup('file', 'ospf_interfaces.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- -# "parsed": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.11" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "multi_areas": [ -# "16.10.10.10" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "2.2.2.2" -# }, -# "multi_areas": [ -# "21.0.0.0" -# ], -# "process_id": "200" -# }, -# { -# "multi_areas": [ -# "50.50.50.50" -# ], -# "process_id": "300" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication_key": { -# "encryption": 7, -# "key": "12090404011C03162E" -# } -# } -# ], -# "name": "Ethernet1/3" -# }, -# ] +# Task output: +# ------------ +# parsed: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.11 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# - afi: ipv6 +# multi_areas: +# - 16.10.10.10 +# processes: +# - area: +# area_id: 2.2.2.2 +# multi_areas: +# - 21.0.0.0 +# process_id: '200' +# - multi_areas: +# - 50.50.50.50 +# process_id: '300' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - address_family: +# - afi: ipv4 +# authentication_key: +# encryption: 7 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# name: Ethernet1/3 # Using gathered @@ -1336,55 +1020,34 @@ # interface Ethernet1/3 # no switchport -# Task output (redacted) -# ----------------------- -# "gathered": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "multi_areas": [ -# "11.11.11.12" -# ], -# "processes": [ -# { -# "area": { -# "area_id": "1.1.1.1", -# "secondaries": false -# }, -# "process_id": "100" -# } -# ] -# } -# ], -# "name": "Ethernet1/1" -# }, -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "enable": true, -# "key_chain": "test-1" -# }, -# "cost": 100, -# "message_digest_key": { -# "encryption": 3, -# "key": "abc01d272be25d29", -# "key_id": 10 -# } -# }, -# { -# "afi": "ipv6", -# "network": "broadcast", -# "shutdown": true -# } -# ], -# "name": "Ethernet1/2" -# }, -# { -# "name": "Ethernet1/3" -# }, +# Task output: +# ------------ +# gathered: +# - address_family: +# - afi: ipv4 +# multi_areas: +# - 11.11.11.12 +# processes: +# - area: +# area_id: 1.1.1.1 +# secondaries: false +# process_id: '100' +# name: Ethernet1/1 +# - address_family: +# - afi: ipv4 +# authentication: +# enable: true +# key_chain: test-1 +# cost: 100 +# message_digest_key: +# encryption: 3 +# key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER +# key_id: 10 +# - afi: ipv6 +# network: broadcast +# shutdown: true +# name: Ethernet1/2 +# - name: Ethernet1/3 """ RETURN = """ before: @@ -1416,6 +1079,28 @@ - interface Ethernet1/2 - no ip ospf authentication key-chain test-1 - ip ospf authentication +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - interface Ethernet1/1 + - ip router ospf multi-area 11.11.11.11 + - ip router ospf 100 area 1.1.1.1 secondaries none +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/nxos_ospfv2.py b/plugins/modules/nxos_ospfv2.py index 174640a1e..be23724d2 100644 --- a/plugins/modules/nxos_ospfv2.py +++ b/plugins/modules/nxos_ospfv2.py @@ -1070,8 +1070,8 @@ unit: Gbps state: merged -# Task output -# ------------- +# Task output: +# ------------ # before: {} # # commands: @@ -1236,8 +1236,8 @@ no_summary: true state: replaced -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1396,8 +1396,8 @@ shutdown: true state: overridden -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1514,8 +1514,8 @@ - process_id: 102 state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1610,8 +1610,8 @@ cisco.nxos.nxos_ospfv2: state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1730,8 +1730,8 @@ unit: Gbps state: rendered -# Task Output (redacted) -# ----------------------- +# Task output: +# ------------ # rendered: # - router ospf 100 # - router-id 203.0.113.20 @@ -1794,8 +1794,8 @@ running_config: "{{ lookup('file', 'ospfv2.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # parsed: # processes: # - process_id: "100" @@ -1869,8 +1869,8 @@ cisco.nxos.nxos_ospfv2: state: gathered -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # gathered: # processes: # - process_id: "102" @@ -1944,6 +1944,28 @@ - "vrf zone2" - "auto-cost reference-bandwidth 45 Gbps" - "capability vrf-lite evpn" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - "router ospf 102" + - "router-id 198.54.100.1" + - "router ospf 100" +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. """ diff --git a/plugins/modules/nxos_ospfv3.py b/plugins/modules/nxos_ospfv3.py index 27d9ff659..357afda11 100644 --- a/plugins/modules/nxos_ospfv3.py +++ b/plugins/modules/nxos_ospfv3.py @@ -871,8 +871,8 @@ unit: Gbps state: merged -# Task output -# ------------- +# Task output: +# ------------ # before: {} # # commands: @@ -967,7 +967,7 @@ # Using replaced # Before state: -# ------------ +# ------------- # nxos-9k-rdo# sh running-config | section "^router ospfv3" # router ospfv3 100 # router-id 203.0.113.20 @@ -1021,8 +1021,8 @@ no_summary: True state: replaced -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1133,7 +1133,7 @@ # Using overridden # Before state: -# ------------ +# ------------- # nxos-9k-rdo# sh running-config | section "^router ospfv3" # router ospfv3 100 # router-id 203.0.113.20 @@ -1165,8 +1165,8 @@ shutdown: true state: overridden -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1253,7 +1253,7 @@ # Using deleted to delete a single OSPF process # Before state: -# ------------ +# ------------- # nxos-9k-rdo# sh running-config | section "^router ospf .*" # router ospfv3 100 # router-id 203.0.113.20 @@ -1281,8 +1281,8 @@ - process_id: 102 state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1346,7 +1346,7 @@ # Using deleted all OSPFv3 processes from the device # Before state: -# ------------ +# ------------- # nxos-9k-rdo# sh running-config | section "^router ospfv3" # router ospfv3 100 # router-id 203.0.113.20 @@ -1371,8 +1371,8 @@ cisco.nxos.nxos_ospfv3: state: deleted -# Task output -# ------------- +# Task output: +# ------------ # before: # processes: # - process_id: "100" @@ -1481,8 +1481,8 @@ unit: Gbps state: rendered -# Task Output (redacted) -# ----------------------- +# Task output: +# ------------ # rendered: # - router ospfv3 100 # - router-id 203.0.113.20 @@ -1528,8 +1528,8 @@ running_config: "{{ lookup('file', 'ospfv2.cfg') }}" state: parsed -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # parsed: # processes: # - process_id: "100" @@ -1579,8 +1579,8 @@ cisco.nxos.nxos_ospfv3: state: gathered -# Task output (redacted) -# ----------------------- +# Task output: +# ------------ # gathered: # processes: # - process_id: "100" @@ -1663,6 +1663,28 @@ - "router-id 192.0.100.2" - "vrf zone2" - "auto-cost reference-bandwidth 45 Gbps" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - "router ospfv3 102" + - "router-id 198.54.100.1" + - "router ospfv3 100" +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule From b4b9f47f5da27a1f7509d777bf0ebff1e4c32e77 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 11:16:32 +0530 Subject: [PATCH 125/166] [pre-commit.ci] pre-commit autoupdate (#737) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.1 → v3.0.2](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.1...v3.0.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1caa35198..93e8dc7d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.1" + rev: "v3.0.2" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" From 3811d882b40e4188747adc7f30e42c0f70012a6f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:30:49 +0530 Subject: [PATCH 126/166] [pre-commit.ci] pre-commit autoupdate (#744) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v3.0.1 → v3.1.0](https://github.com/asottile/add-trailing-comma/compare/v3.0.1...v3.1.0) - [github.com/pre-commit/mirrors-prettier: v3.0.2 → v3.0.3](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.2...v3.0.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93e8dc7d9..38554bc5a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,12 +17,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.1 + rev: v3.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.2" + rev: "v3.0.3" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" From 005a400ad3c89af46b7f4ca105ff15a1da0277e7 Mon Sep 17 00:00:00 2001 From: Suhas Bharadwaj Date: Thu, 7 Sep 2023 11:22:20 +0530 Subject: [PATCH 127/166] fc_interfaces module for cisco mds (#738) * initial files for fc_interfaces * some more changes * some more unit tests * all unit testcases * added chassis_type * cleanup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * cicd changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ci fixes * Update plugins/modules/nxos_fc_interfaces.py Co-authored-by: Nilashish Chakraborty * ci changes * ci changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ci changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * examples added to doc * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * overridden changes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- README.md | 1 + changelogs/fragments/nxos_mds_fc.yaml | 3 + .../nxos/argspec/fc_interfaces/__init__.py | 0 .../argspec/fc_interfaces/fc_interfaces.py | 76 + .../nxos/config/fc_interfaces/__init__.py | 0 .../config/fc_interfaces/fc_interfaces.py | 202 ++ .../module_utils/network/nxos/facts/facts.py | 4 + .../nxos/facts/fc_interfaces/__init__.py | 0 .../nxos/facts/fc_interfaces/fc_interfaces.py | 103 + .../nxos/rm_templates/fc_interfaces.py | 194 ++ plugins/modules/nxos_fc_interfaces.py | 590 ++++++ .../network/nxos/test_nxos_fc_interfaces.py | 1744 +++++++++++++++++ 12 files changed, 2917 insertions(+) create mode 100644 changelogs/fragments/nxos_mds_fc.yaml create mode 100644 plugins/module_utils/network/nxos/argspec/fc_interfaces/__init__.py create mode 100644 plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py create mode 100644 plugins/module_utils/network/nxos/config/fc_interfaces/__init__.py create mode 100644 plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py create mode 100644 plugins/module_utils/network/nxos/facts/fc_interfaces/__init__.py create mode 100644 plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py create mode 100644 plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py create mode 100644 plugins/modules/nxos_fc_interfaces.py create mode 100644 tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py diff --git a/README.md b/README.md index c038ee93e..e8ad6e9d9 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Name | Description [cisco.nxos.nxos_evpn_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_evpn_global_module.rst)|Handles the EVPN control plane for VXLAN. [cisco.nxos.nxos_evpn_vni](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_evpn_vni_module.rst)|Manages Cisco EVPN VXLAN Network Identifier (VNI). [cisco.nxos.nxos_facts](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_facts_module.rst)|Gets facts about NX-OS switches +[cisco.nxos.nxos_fc_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_fc_interfaces_module.rst)|Fc Interfaces resource module [cisco.nxos.nxos_feature](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_feature_module.rst)|Manage features in NX-OS switches. [cisco.nxos.nxos_file_copy](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_file_copy_module.rst)|Copy a file to a remote NXOS device. [cisco.nxos.nxos_gir](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_gir_module.rst)|Trigger a graceful removal or insertion (GIR) of the switch. diff --git a/changelogs/fragments/nxos_mds_fc.yaml b/changelogs/fragments/nxos_mds_fc.yaml new file mode 100644 index 000000000..14e9485cc --- /dev/null +++ b/changelogs/fragments/nxos_mds_fc.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Added new module fc_interfaces diff --git a/plugins/module_utils/network/nxos/argspec/fc_interfaces/__init__.py b/plugins/module_utils/network/nxos/argspec/fc_interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py b/plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py new file mode 100644 index 000000000..5a58d99e0 --- /dev/null +++ b/plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the +# ansible.content_builder. +# +# Manually editing this file is not advised. +# +# To update the argspec make the desired changes +# in the documentation in the module file and re-run +# ansible.content_builder commenting out +# the path to external 'docstring' in build.yaml. +# +############################################## + +""" +The arg spec for the nxos_fc_interfaces module +""" +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + allowed_port_modes, + allowed_speed_values, +) + + +class Fc_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the nxos_fc_interfaces module""" + + argument_spec = { + "running_config": {"type": "str"}, + "config": { + "type": "list", + "elements": "dict", + "options": { + "name": {"type": "str", "required": True}, + "description": {"type": "str"}, + "enabled": {"type": "bool"}, + "speed": { + "choices": allowed_speed_values, + "type": "str", + }, + "mode": { + "choices": allowed_port_modes, + "type": "str", + }, + "trunk_mode": {"choices": ["auto", "on", "off"], "type": "str"}, + "analytics": { + "choices": ["fc-scsi", "fc-nvme", "fc-all"], + "type": "str", + }, + }, + }, + "state": { + "type": "str", + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "gathered", + "rendered", + "parsed", + ], + "default": "merged", + }, + } # pylint: disable=C0301 diff --git a/plugins/module_utils/network/nxos/config/fc_interfaces/__init__.py b/plugins/module_utils/network/nxos/config/fc_interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py b/plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py new file mode 100644 index 000000000..e08a9ce1b --- /dev/null +++ b/plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py @@ -0,0 +1,202 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The nxos_fc_interfaces config file. +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to its desired end-state is +created. +""" + + +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( + ResourceModule, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, +) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + Fc_interfacesTemplate, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + normalize_interface, +) + + +class Fc_interfaces(ResourceModule): + """ + The nxos_fc_interfaces config class + """ + + def __init__(self, module): + super(Fc_interfaces, self).__init__( + empty_fact_val={}, + facts_module=Facts(module, chassis_type="mds"), + module=module, + resource="fc_interfaces", + tmplt=Fc_interfacesTemplate(), + ) + self.parsers = ["description", "speed", "mode", "trunk_mode", "analytics"] + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + if self.state not in ["parsed", "gathered"]: + self.generate_commands() + self.run_commands() + return self.result + + def generate_commands(self): + """Generate configuration commands to send based on + want, have and desired state. + """ + + wantd = {entry["name"]: entry for entry in self.want} + haved = {entry["name"]: entry for entry in self.have} + + for each in wantd, haved: + self.normalize_interface_names(each) + + # if state is merged, merge want onto have and then compare + if self.state == "merged": + wantd = dict_merge(haved, wantd) + + # if state is deleted, empty out wantd and set haved to wantd + if self.state == "deleted": + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} + wantd = {} + + # remove superfluous config for overridden and deleted + if self.state in ["overridden", "deleted"]: + for k, have in iteritems(haved): + if k not in wantd: + self._compare(want={}, have=have) + + for k, want in iteritems(wantd): + self._compare(want=want, have=haved.pop(k, {})) + + modified_list = [ + "switchport trunk mode on" if item.startswith("no switchport trunk mode") else item + for item in self.commands + ] + self.commands = modified_list + + def _calculate_ana_config(self, want_ana, have_ana): + """ + get the cmds based on want_ana and have_ana and the state + + Args: + want_ana (str): analytics type which you want + have_ana (str): analytics type which you have + + +----------+----------+---------+ + | MERGED | + |----------+----------+---------+ + | want_ana | have_ana | outcome | + +----------+----------+---------+ + | "" | * | no op | + | fc-scsi | * | fc-scsi | + | fc-scsi | fc-all | no op | + | fc-nvme | * | fc-nvme | + | fc-nvme | fc-all | no op | + +----------+----------+---------+ + + + +----------+----------+-----------+ + | DELETED | + |----------+----------+-----------+ + | want_ana | have_ana | outcome | + +----------+----------+-----------+ + | * | fc-scsi | no fc-all | + | * | fc-nvme | no fc-all | + | * | fc-all | no fc-all | + | * | "" | no op | + +----------+----------+-----------+ + + + +----------+----------+---------------------+ + | REPLACED/OVERRIDEN | + |----------+----------+---------------------+ + | want_ana | have_ana | outcome | + +----------+----------+---------------------+ + | "" | * | no fc-all | + | fc-scsi | "" | fc-scsi | + | fc-nvme | "" | fc-nvme | + | fc-all | "" | fc-all | + | fc-scsi | * | no fc-all ; fc-scsi | + | fc-nvme | * | no fc-all ; fc-nvme | + | fc-all | * | fc-all | + +----------+----------+---------------------+ + + + """ + + if want_ana == have_ana: + return [] + val = [] + if self.state in ["overridden", "replaced"]: + if want_ana == "": + val = ["no analytics type fc-all"] + elif want_ana == "fc-all": + val = ["analytics type fc-all"] + elif have_ana == "": + val = [f"analytics type {want_ana}"] + else: + val = ["no analytics type fc-all", f"analytics type {want_ana}"] + elif self.state in ["deleted"]: + if have_ana: + val = ["no analytics type fc-all"] + elif self.state in ["merged"]: + if want_ana: + if have_ana != "fc-all": + val = [f"analytics type {want_ana}"] + return val + + def _compare(self, want, have): + """Leverages the base class `compare()` method and + populates the list of commands to be run by comparing + the `want` and `have` data with the `parsers` defined + for the Fc_interfaces network resource. + """ + + begin = len(self.commands) + self.compare(parsers=self.parsers, want=want, have=have) + if want.get("enabled") != have.get("enabled"): + if want.get("enabled"): + self.addcmd(want, "enabled", True) + else: + if want: + self.addcmd(want, "enabled", False) + elif have.get("enabled"): + # handles deleted as want be blank and only + # negates if no shutdown + self.addcmd(have, "enabled", False) + + ana_cmds = self._calculate_ana_config(want.get("analytics", ""), have.get("analytics", "")) + + self.commands.extend(ana_cmds) + + if len(self.commands) != begin: + self.commands.insert(begin, self._tmplt.render(want or have, "interface", False)) + + def normalize_interface_names(self, param): + if param: + for _k, val in iteritems(param): + val["name"] = normalize_interface(val["name"]) + return param diff --git a/plugins/module_utils/network/nxos/facts/facts.py b/plugins/module_utils/network/nxos/facts/facts.py index 4daaa6b75..a7c2ab350 100644 --- a/plugins/module_utils/network/nxos/facts/facts.py +++ b/plugins/module_utils/network/nxos/facts/facts.py @@ -37,6 +37,9 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_templates.bgp_templates import ( Bgp_templatesFacts, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.fc_interfaces.fc_interfaces import ( + Fc_interfacesFacts, +) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname import ( HostnameFacts, ) @@ -149,6 +152,7 @@ bgp_templates=Bgp_templatesFacts, ) MDS_FACT_RESOURCE_SUBSETS = dict( + fc_interfaces=Fc_interfacesFacts, logging_global=Logging_globalFacts, ntp_global=Ntp_globalFacts, snmp_server=Snmp_serverFacts, diff --git a/plugins/module_utils/network/nxos/facts/fc_interfaces/__init__.py b/plugins/module_utils/network/nxos/facts/fc_interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py b/plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py new file mode 100644 index 000000000..e9d85c086 --- /dev/null +++ b/plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +import operator +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.fc_interfaces.fc_interfaces import ( + Fc_interfacesArgs, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + Fc_interfacesTemplate, +) + + +__metaclass__ = type + +""" +The nxos fc_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + + +class Fc_interfacesFacts(object): + """The nxos fc_interfaces facts class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Fc_interfacesArgs.argument_spec + + def get_interfaces_data(self, connection): + return connection.get("show running-config interface all") + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for Fc_interfaces network resource + + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + + :rtype: dictionary + :returns: facts + """ + facts = {} + objs = [] + + if not data: + data = self.get_interfaces_data(connection) + + # parse native config using the Fc_interfaces template + fc_interfaces_parser = Fc_interfacesTemplate(lines=data.splitlines(), module=self._module) + + objs = list(fc_interfaces_parser.parse().values()) + + # - populate only fc interfaces + # - populate "analytics" value based on the presence or absense of "analytics_nvme" or "analytics_scsi" keys + # - dummy key "m" and "p" is added for sorting, which is removed after sorting + modified_objs = [] + # match only fc interface + regex = re.compile(r"^fc\d+\S+") + for parsed_data in objs: + if not re.match(regex, parsed_data["name"]): + continue + m, p = parsed_data["name"].strip("fc").split("/") + parsed_data["m"] = int(m) + parsed_data["p"] = int(p) + + if "analytics_scsi" in parsed_data: + parsed_data.pop("analytics_scsi") + if "analytics_nvme" in parsed_data: + parsed_data.pop("analytics_nvme") + parsed_data["analytics"] = "fc-all" + else: + parsed_data["analytics"] = "fc-scsi" + else: + if "analytics_nvme" in parsed_data: + parsed_data.pop("analytics_nvme") + parsed_data["analytics"] = "fc-nvme" + modified_objs.append(parsed_data) + + sorted_dict = sorted(modified_objs, key=operator.itemgetter("m", "p")) + objs = [ + {key: value for key, value in eachdict.items() if key not in ["m", "p"]} + for eachdict in sorted_dict + ] + + ansible_facts["ansible_network_resources"].pop("fc_interfaces", None) + + params = utils.remove_empties( + fc_interfaces_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), + ) + + facts["fc_interfaces"] = params.get("config", []) + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts diff --git a/plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py b/plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py new file mode 100644 index 000000000..1cc9d5973 --- /dev/null +++ b/plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The Fc_interfaces parser templates file. This contains +a list of parser definitions and associated functions that +facilitates both facts gathering and native command generation for +the given network resource. +""" + +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( + NetworkTemplate, +) + + +allowed_speed_values = [ + "auto", + "1000", + "2000", + "4000", + "8000", + "10000", + "16000", + "32000", + "64000", + "auto max 2000", + "auto max 4000", + "auto max 8000", + "auto max 16000", + "auto max 32000", + "auto max 64000", +] + +allowed_port_modes = [ + "auto", + "E", + "F", + "Fx", + "NP", + "SD", +] + +allowed_values_pattern = "|".join(re.escape(val) for val in allowed_speed_values) + + +class Fc_interfacesTemplate(NetworkTemplate): + def __init__(self, lines=None, module=None): + super(Fc_interfacesTemplate, self).__init__(lines=lines, tmplt=self, module=module) + + # fmt: off + PARSERS = [ + { + "name": "interface", + "getval": re.compile( + r""" + ^interface\s + (?P\S+)$""", re.VERBOSE, + ), + "setval": "interface {{ name }}", + "result": { + "{{ name }}": { + "name": "{{ name }}", + }, + }, + "shared": True, + }, + { + "name": "description", + "getval": re.compile( + r""" + \s+switchport\s+description\s+(?P.*) + $""", re.VERBOSE, + ), + "setval": "switchport description {{ description }}", + "remval": "switchport description", + "result": { + "{{ name }}": { + "description": "{{ description }}", + }, + }, + }, + { + "name": "enabled", + "getval": re.compile( + r""" + (?P\s+no)? + (?P\s+shutdown) + $""", re.VERBOSE, + ), + "setval": "shutdown", + "result": { + "{{ name }}": { + "enabled": "{{ False if shutdown is defined and negate is not defined else True }}", + }, + }, + }, + { + "name": "speed", + "getval": re.compile( + rf"""\s+switchport\s+speed\s+(?P{allowed_values_pattern})$""", re.VERBOSE, + ), + "setval": "switchport speed {{ speed|string }}", + "result": { + "{{ name }}": { + "speed": "{{ speed|string }}", + }, + }, + }, + { + "name": "mode", + "getval": re.compile( + r""" + \s+switchport\s+mode\s+(?P\S+) + $""", re.VERBOSE, + ), + "setval": "switchport mode {{ mode|string }}", + "result": { + "{{ name }}": { + "mode": "{{ mode }}", + }, + }, + }, + { + "name": "trunk_mode", + "getval": re.compile( + r""" + \s+switchport\s+trunk\s+mode\s+(?P\S+) + $""", re.VERBOSE, + ), + "setval": "switchport trunk mode {{ trunk_mode|string }}", + "result": { + "{{ name }}": { + "trunk_mode": "{{ trunk_mode }}", + }, + }, + }, + + { + "name": "analytics_scsi", + "getval": re.compile( + r""" + (?P\s+no)? + \s+analytics\s+type\s+(?Pfc-scsi) + $""", re.VERBOSE, + ), + "setval": "analytics type {{ analytics_scsi|string }}", + "result": { + "{{ name }}": { + "analytics_scsi": "{{ analytics_scsi }}", + }, + }, + }, + { + "name": "analytics_nvme", + "getval": re.compile( + r""" + (?P\s+no)? + \s+analytics\s+type\s+(?Pfc-nvme) + $""", re.VERBOSE, + ), + "setval": "analytics type {{ analytics_nvme|string }}", + "result": { + "{{ name }}": { + "analytics_nvme": "{{ analytics_nvme }}", + }, + }, + }, + + { + "name": "analytics", + "getval": re.compile( + r""" + \s+analytics\s+type\s+(?P\S+) + $""", re.VERBOSE, + ), + # "setval": "analytics type {{ analytics|string }}", + "setval": "", + "result": { + "{{ name }}": { + "analytics": "{{ analytics }}", + }, + }, + }, + ] + # fmt: on diff --git a/plugins/modules/nxos_fc_interfaces.py b/plugins/modules/nxos_fc_interfaces.py new file mode 100644 index 000000000..192a2b12c --- /dev/null +++ b/plugins/modules/nxos_fc_interfaces.py @@ -0,0 +1,590 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" +The module file for nxos_fc_interfaces +""" + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: nxos_fc_interfaces +short_description: Fc Interfaces resource module +description: This module manages the interface attributes of NX-OS fc interfaces. +version_added: 6.0.0 +author: Suhas Bharadwaj (@srbharadwaj) +notes: + - Tested against NXOS 9.3(2) on Cisco MDS Switches +options: + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the NX-OS + device by executing the command B(show running-config interface) + - The state I(parsed) reads the configuration from C(running_config) + option and transforms it into Ansible structured data as per the + resource module's argspec and the value is then returned in the + I(parsed) key within the result. + type: str + config: + description: A dictionary of interface options + type: list + elements: dict + suboptions: + name: + description: + - Full name of interface, e.g. fc1/1, fc18/48 + type: str + required: true + description: + description: + - Interface description. + type: str + enabled: + description: + - Administrative state of the interface. Set the value to C(true) to + administratively enable the interface or C(false) to disable it + type: bool + speed: + description: + - Interface link speed. + choices: + - 'auto' + - '1000' + - '2000' + - '4000' + - '8000' + - '10000' + - '16000' + - '32000' + - '64000' + - 'auto max 2000' + - 'auto max 4000' + - 'auto max 8000' + - 'auto max 16000' + - 'auto max 32000' + - 'auto max 64000' + type: str + mode: + description: + - Port mode of the fc interface + choices: + - 'auto' + - 'E' + - 'F' + - 'Fx' + - 'NP' + - 'SD' + type: str + trunk_mode: + description: + - Trunk mode of the fc interface + choices: + - 'auto' + - 'on' + - 'off' + type: str + analytics: + description: + - Analytics type on the fc interface + choices: + - 'fc-scsi' + - 'fc-nvme' + - 'fc-all' + type: str + state: + description: + - The state of the configuration after module completion + type: str + choices: + - merged + - replaced + - overridden + - deleted + - gathered + - rendered + - parsed + default: merged +""" +EXAMPLES = """ +# Using merged + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc18/10 +# analytics type fc-nvme +# switchport speed auto max 16000 +# switchport mode auto +# switchport description $ +# switchport trunk mode on +# shutdown + +- name: Merge provided configuration with device configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/10 + analytics: fc-scsi + state: merged + +# Task Output +# ----------- +# +# before: +# - name: fc18/10 +# speed: auto max 16000 +# mode: auto +# trunk_mode: on +# enabled: False +# description: $ +# analytics: fc-nvme +# commands: +# - interface fc18/10 +# - analytics type fc-scsi +# after: +# - name: fc18/10 +# speed: auto max 16000 +# mode: auto +# trunk_mode: on +# enabled: False +# description: $ +# analytics: fc-all + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc18/10 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 16000 +# switchport mode auto +# switchport description $ +# switchport trunk mode on +# shutdown + +# Using replaced + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown + +- name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: replaced + +# Task Output +# ----------- +# +# before: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-all +# commands: +# - interface fc18/12 +# - no analytics type fc-all +# - analytics type fc-scsi +# after: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-scsi + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown + + +# Using deleted + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown + +- name: Delete or return interface parameters to default settings + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc1/2 + state: deleted + +# Task Output +# ----------- +# +# before: +# - name: fc1/2 +# speed: 1000 +# mode: E +# trunk_mode: off +# enabled: True +# commands: +# - interface fc1/2 +# - no switchport speed 1000 +# - no switchport mode E +# - switchport trunk mode on +# - shutdown +# after: +# - name: fc1/2 +# speed: auto +# mode: auto +# trunk_mode: on +# enabled: False + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc1/2 +# switchport speed auto +# switchport mode auto +# no switchport description +# switchport trunk mode on +# shutdown + +# Using overridden + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown +# interface fc18/13 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown + +- name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: overridden + +# Task Output +# ----------- +# +# before: +# - 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 +# commands: +# - interface fc18/12 +# no analytics type fc-all +# analytics type fc-scsi +# - interface fc18/13 +# no switchport description +# no switchport speed auto max 64000 +# no switchport mode auto +# switchport trunk mode on +# shutdown +# after: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-scsi +# - name: fc18/13 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: False + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown +# interface fc18/13 +# switchport mode auto +# switchport trunk mode on +# shutdown + + + + + + + +# Using rendered + +- name: Use rendered state to convert task input to device specific commands + cisco.nxos.nxos_fc_interfaces: + config: + - 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 + state: rendered + +# Task Output +# ----------- +# +# rendered: +# interface fc1/1 +# switchport speed auto +# switchport mode auto +# switchport description This is a sample line +# switchport trunk mode on +# no shutdown +# +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown + +# Using parsed + +# parsed.cfg +# ------------ +# +# interface fc1/1 +# switchport speed auto +# switchport mode auto +# switchport description This is a sample line +# switchport trunk mode on +# no shutdown +# +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown + +- name: Use parsed state to convert externally supplied config to structured format + cisco.nxos.nxos_fc_interfaces: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed + +# Task output +# ----------- +# +# parsed: +# - 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 + +# Using gathered + +# Before state: +# ------------- +# +# switch# show running-config | section interface +# interface fc1/1 +# switchport speed auto +# switchport mode auto +# switchport description This is a sample line +# switchport trunk mode on +# no shutdown +# +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown +# +- name: Gather interfaces facts from the device using nxos_fc_interfaces + cisco.nxos.nxos_fc_interfaces: + state: gathered +# +# Task output +# ----------- +# +# - 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 + + + + +""" + +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - interface fc1/1 + - description sample description + - shutdown +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - interface fc1/1 + - description sample description + - shutdown +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.fc_interfaces.fc_interfaces import ( + Fc_interfacesArgs, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.fc_interfaces.fc_interfaces import ( + Fc_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule( + argument_spec=Fc_interfacesArgs.argument_spec, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, + ) + + result = Fc_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py new file mode 100644 index 000000000..098a5b7ff --- /dev/null +++ b/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 . + +# 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", + # ], + ) From c042b923e589a34c1e95ce71bd79facbf02cbe84 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Thu, 7 Sep 2023 13:10:07 +0530 Subject: [PATCH 128/166] [bgp_templates] Add support for safi evpn & send_community (#745) Signed-off-by: NilashishC --- changelogs/fragments/bgp_templates.yaml | 4 ++ docs/cisco.nxos.nxos_bgp_templates_module.rst | 24 +++++++ .../argspec/bgp_templates/bgp_templates.py | 6 +- .../config/bgp_templates/bgp_templates.py | 13 +++- .../nxos/facts/bgp_templates/bgp_templates.py | 11 ++++ .../nxos/rm_templates/bgp_templates.py | 42 ++++++++++++ plugins/modules/nxos_bgp_templates.py | 6 +- .../network/nxos/test_nxos_bgp_templates.py | 64 +++++++++++++++++++ 8 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/bgp_templates.yaml diff --git a/changelogs/fragments/bgp_templates.yaml b/changelogs/fragments/bgp_templates.yaml new file mode 100644 index 000000000..44ff26ece --- /dev/null +++ b/changelogs/fragments/bgp_templates.yaml @@ -0,0 +1,4 @@ +--- +minor_changes: + - "bgp_templates - Add support for send_community (https://github.com/ansible-collections/cisco.nxos/issues/740)." + - "bgp_templates - Add support for safi evpn (https://github.com/ansible-collections/cisco.nxos/issues/739)." diff --git a/docs/cisco.nxos.nxos_bgp_templates_module.rst b/docs/cisco.nxos.nxos_bgp_templates_module.rst index bae0c7318..9287d7a60 100644 --- a/docs/cisco.nxos.nxos_bgp_templates_module.rst +++ b/docs/cisco.nxos.nxos_bgp_templates_module.rst @@ -906,12 +906,36 @@ Parameters
  • unicast
  • multicast
  • mvpn
  • +
  • evpn
  • Sub Address Family indicator.
    +
    + send_community + +
    + string +
    +
    +
      Choices: +
    • standard
    • +
    • extended
    • +
    • both
    • +
    +
    +
    Send Community attribute to this neighbor.
    +
    +
    + remote_as_route_map + +
    + string +
    +
    + +
    Route-map to match prefix peer AS number.
    +
    +
    + remote_as_route_map + +
    + string +
    +
    + +
    Route-map to match prefix peer AS number.
    +
    +
    + rewrite_rt_asn + +
    + boolean +
    +
    +
      Choices: +
    • no
    • +
    • yes
    • +
    +
    +
    Auto generate RTs for EBGP neighbor.
    +
    +
    + rewrite_rt_asn + +
    + boolean +
    +
    +
      Choices: +
    • no
    • +
    • yes
    • +
    +
    +
    Auto generate RTs for EBGP neighbor.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterChoices/DefaultsComments
    +
    + config + +
    + list + / elements=dictionary +
    +
    + +
    A dictionary of interface options
    +
    +
    + analytics + +
    + string +
    +
    +
      Choices: +
    • fc-scsi
    • +
    • fc-nvme
    • +
    • fc-all
    • +
    +
    +
    Analytics type on the fc interface
    +
    +
    + description + +
    + string +
    +
    + +
    Interface description.
    +
    +
    + enabled + +
    + boolean +
    +
    +
      Choices: +
    • no
    • +
    • yes
    • +
    +
    +
    Administrative state of the interface. Set the value to true to administratively enable the interface or false to disable it
    +
    +
    + mode + +
    + string +
    +
    +
      Choices: +
    • auto
    • +
    • E
    • +
    • F
    • +
    • Fx
    • +
    • NP
    • +
    • SD
    • +
    +
    +
    Port mode of the fc interface
    +
    +
    + name + +
    + string + / required +
    +
    + +
    Full name of interface, e.g. fc1/1, fc18/48
    +
    +
    + speed + +
    + string +
    +
    +
      Choices: +
    • auto
    • +
    • 1000
    • +
    • 2000
    • +
    • 4000
    • +
    • 8000
    • +
    • 10000
    • +
    • 16000
    • +
    • 32000
    • +
    • 64000
    • +
    • auto max 2000
    • +
    • auto max 4000
    • +
    • auto max 8000
    • +
    • auto max 16000
    • +
    • auto max 32000
    • +
    • auto max 64000
    • +
    +
    +
    Interface link speed.
    +
    +
    + trunk_mode + +
    + string +
    +
    +
      Choices: +
    • auto
    • +
    • on
    • +
    • off
    • +
    +
    +
    Trunk mode of the fc interface
    +
    +
    + running_config + +
    + string +
    +
    + +
    This option is used only with state parsed.
    +
    The value of this option should be the output received from the NX-OS device by executing the command show running-config interface
    +
    The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the parsed key within the result.
    +
    +
    + state + +
    + string +
    +
    +
      Choices: +
    • merged ←
    • +
    • replaced
    • +
    • overridden
    • +
    • deleted
    • +
    • gathered
    • +
    • rendered
    • +
    • parsed
    • +
    +
    +
    The state of the configuration after module completion
    +
    +
    + + +Notes +----- + +.. note:: + - Tested against NXOS 9.3(2) on Cisco MDS Switches + + + +Examples +-------- + +.. code-block:: yaml + + # Using merged + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc18/10 + # analytics type fc-nvme + # switchport speed auto max 16000 + # switchport mode auto + # switchport description $ + # switchport trunk mode on + # shutdown + + - name: Merge provided configuration with device configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/10 + analytics: fc-scsi + state: merged + + # Task Output + # ----------- + # + # before: + # - name: fc18/10 + # speed: auto max 16000 + # mode: auto + # trunk_mode: on + # enabled: False + # description: $ + # analytics: fc-nvme + # commands: + # - interface fc18/10 + # - analytics type fc-scsi + # after: + # - name: fc18/10 + # speed: auto max 16000 + # mode: auto + # trunk_mode: on + # enabled: False + # description: $ + # analytics: fc-all + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc18/10 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 16000 + # switchport mode auto + # switchport description $ + # switchport trunk mode on + # shutdown + + # Using replaced + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + + - name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: replaced + + # Task Output + # ----------- + # + # before: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-all + # commands: + # - interface fc18/12 + # - no analytics type fc-all + # - analytics type fc-scsi + # after: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-scsi + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + + + # Using deleted + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + + - name: Delete or return interface parameters to default settings + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc1/2 + state: deleted + + # Task Output + # ----------- + # + # before: + # - name: fc1/2 + # speed: 1000 + # mode: E + # trunk_mode: off + # enabled: True + # commands: + # - interface fc1/2 + # - no switchport speed 1000 + # - no switchport mode E + # - switchport trunk mode on + # - shutdown + # after: + # - name: fc1/2 + # speed: auto + # mode: auto + # trunk_mode: on + # enabled: False + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc1/2 + # switchport speed auto + # switchport mode auto + # no switchport description + # switchport trunk mode on + # shutdown + + # Using overridden + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + # interface fc18/13 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + + - name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: overridden + + # Task Output + # ----------- + # + # before: + # - 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 + # commands: + # - interface fc18/12 + # no analytics type fc-all + # analytics type fc-scsi + # - interface fc18/13 + # no switchport description + # no switchport speed auto max 64000 + # no switchport mode auto + # switchport trunk mode on + # shutdown + # after: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-scsi + # - name: fc18/13 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: False + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + # interface fc18/13 + # switchport mode auto + # switchport trunk mode on + # shutdown + + + + + + + + # Using rendered + + - name: Use rendered state to convert task input to device specific commands + cisco.nxos.nxos_fc_interfaces: + config: + - 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 + state: rendered + + # Task Output + # ----------- + # + # rendered: + # interface fc1/1 + # switchport speed auto + # switchport mode auto + # switchport description This is a sample line + # switchport trunk mode on + # no shutdown + # + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + + # Using parsed + + # parsed.cfg + # ------------ + # + # interface fc1/1 + # switchport speed auto + # switchport mode auto + # switchport description This is a sample line + # switchport trunk mode on + # no shutdown + # + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + + - name: Use parsed state to convert externally supplied config to structured format + cisco.nxos.nxos_fc_interfaces: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed + + # Task output + # ----------- + # + # parsed: + # - 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 + + # Using gathered + + # Before state: + # ------------- + # + # switch# show running-config | section interface + # interface fc1/1 + # switchport speed auto + # switchport mode auto + # switchport description This is a sample line + # switchport trunk mode on + # no shutdown + # + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + # + - name: Gather interfaces facts from the device using nxos_fc_interfaces + cisco.nxos.nxos_fc_interfaces: + state: gathered + # + # Task output + # ----------- + # + # - 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 + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyReturnedDescription
    +
    + after + +
    + dictionary +
    +
    when changed +
    The resulting configuration after module execution.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + before + +
    + dictionary +
    +
    when state is merged, replaced, overridden, deleted or purged +
    The configuration prior to the module execution.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + commands + +
    + list +
    +
    when state is merged, replaced, overridden, deleted or purged +
    The set of commands pushed to the remote device.
    +
    +
    Sample:
    +
    ['interface fc1/1', 'description sample description', 'shutdown']
    +
    +
    + gathered + +
    + list +
    +
    when state is gathered +
    Facts about the network resource gathered from the remote device as structured data.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + parsed + +
    + list +
    +
    when state is parsed +
    The device native config provided in running_config option parsed into structured data as per module argspec.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + rendered + +
    + list +
    +
    when state is rendered +
    The provided configuration in the task rendered in device-native format (offline).
    +
    +
    Sample:
    +
    ['interface fc1/1', 'description sample description', 'shutdown']
    +
    +

    + + +Status +------ + + +Authors +~~~~~~~ + +- Suhas Bharadwaj (@srbharadwaj) diff --git a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py index bfe4e5d66..3f17ccebc 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py @@ -235,6 +235,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 ], }, "remote_as": {"type": "str"}, + "remote_as_route_map": {"type": "str"}, "remove_private_as": { "type": "dict", "options": { @@ -470,6 +471,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 ], }, "remote_as": {"type": "str"}, + "remote_as_route_map": {"type": "str"}, "remove_private_as": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 4c97d2946..397acb1f4 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -158,6 +158,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, }, "rewrite_evpn_rt_asn": {"type": "bool"}, + "rewrite_rt_asn": {"type": "bool"}, "route_map": { "type": "dict", "options": { @@ -325,6 +326,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, }, "rewrite_evpn_rt_asn": {"type": "bool"}, + "rewrite_rt_asn": {"type": "bool"}, "route_map": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py index edb6e59bb..fe738d1af 100644 --- a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py @@ -234,7 +234,7 @@ def _compare_neighbors(self, want, have, vrf=None): self.compare(parsers=nbr_parsers, want=entry, have=have_nbr) self._compare_path_attribute(entry, have_nbr) - if len(self.commands) != begin: + if len(self.commands) != begin or (entry and not have_nbr): self.commands.insert(begin, self._tmplt.render(entry, "neighbor_address", False)) # cleanup remaining neighbors diff --git a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 96902987d..0ab282a6c 100644 --- a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -65,6 +65,7 @@ def __init__(self, module): "prefix_list.inbound", "prefix_list.outbound", "rewrite_evpn_rt_asn", + "rewrite_rt_asn", "route_map.inbound", "route_map.outbound", "route_reflector_client", diff --git a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py index 621e499fd..9e149d8f6 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py @@ -29,7 +29,7 @@ class Bgp_globalFacts(object): """The nxos bgp_global facts class""" - def __init__(self, module, subspec="config", options="options"): + def __init__(self, module): self._module = module self.argument_spec = Bgp_globalArgs.argument_spec diff --git a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py index e26c1826a..625ed5082 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -28,7 +28,7 @@ class Bgp_neighbor_address_familyFacts(object): """The nxos bgp_neighbor_address_family facts class""" - def __init__(self, module, subspec="config", options="options"): + def __init__(self, module): self._module = module self.argument_spec = Bgp_neighbor_address_familyArgs.argument_spec diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py index d2ca65aad..255ba7db2 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py @@ -634,10 +634,12 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor\s(?P\S+) + (\sremote-as\sroute-map\s(?P\S+))? (\sremote-as\s(?P\S+))? $""", re.VERBOSE, ), - "setval": "neighbor {{ neighbor_address }}", + "setval": "neighbor {{ neighbor_address }}" + "{{ (' remote-as route-map ' + remote_as_route_map) if remote_as_route_map|d(None) else '' }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { @@ -645,6 +647,7 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "neighbor_address": "{{ neighbor_address }}", "remote_as": "{{ remote_as }}", + "remote_as_route_map": "{{ remote_as_route_map }}", }, }, }, @@ -808,6 +811,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor\s(?P\S+) + (\sremote-as\sroute-map\s\S+)? \sdescription\s(?P\S+) $""", re.VERBOSE, ), diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py index 26dad82af..7db4b860d 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py @@ -616,6 +616,32 @@ def __init__(self, lines=None): }, }, }, + { + "name": "rewrite_rt_asn", + "getval": re.compile( + r""" + (?Prewrite-rt-asn) + $""", + re.VERBOSE, + ), + "setval": "rewrite-rt-asn", + "result": { + "vrfs": { + "{{ 'vrf_' + vrf|d() }}": { + "vrf": "{{ vrf }}", + "neighbors": { + "{{ neighbor }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "rewrite_rt_asn": "{{ not not rewrite_rt_asn }}", + }, + }, + }, + }, + }, + }, + }, + }, { "name": "route_map.inbound", "getval": re.compile( diff --git a/plugins/modules/nxos_bgp_global.py b/plugins/modules/nxos_bgp_global.py index 6a34bc777..29e016181 100644 --- a/plugins/modules/nxos_bgp_global.py +++ b/plugins/modules/nxos_bgp_global.py @@ -357,6 +357,9 @@ remote_as: description: Specify Autonomous System Number of the neighbor. type: str + remote_as_route_map: + description: Route-map to match prefix peer AS number. + type: str remove_private_as: description: Remove private AS number from outbound updates. type: dict diff --git a/plugins/modules/nxos_bgp_neighbor_address_family.py b/plugins/modules/nxos_bgp_neighbor_address_family.py index 299691bb7..e2b72ace3 100644 --- a/plugins/modules/nxos_bgp_neighbor_address_family.py +++ b/plugins/modules/nxos_bgp_neighbor_address_family.py @@ -187,6 +187,9 @@ rewrite_evpn_rt_asn: description: Auto generate RTs for EBGP neighbor. type: bool + rewrite_rt_asn: + description: Auto generate RTs for EBGP neighbor. + type: bool route_map: description: Apply route-map to neighbor. type: dict diff --git a/plugins/modules/nxos_fc_interfaces.py b/plugins/modules/nxos_fc_interfaces.py index 192a2b12c..b0c58a5e3 100644 --- a/plugins/modules/nxos_fc_interfaces.py +++ b/plugins/modules/nxos_fc_interfaces.py @@ -18,7 +18,7 @@ module: nxos_fc_interfaces short_description: Fc Interfaces resource module description: This module manages the interface attributes of NX-OS fc interfaces. -version_added: 6.0.0 +version_added: 5.2.0 author: Suhas Bharadwaj (@srbharadwaj) notes: - Tested against NXOS 9.3(2) on Cisco MDS Switches diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index 9f2377fb6..22c9378eb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -89,6 +89,11 @@ def test_nxos_bgp_global_merged(self): 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 @@ def test_nxos_bgp_global_merged(self): key="13D4D3549493D2877B1DC116EE27A6BE", ), ), + dict( + neighbor_address="2001:4000:5000:fff1::/64", + remote_as_route_map="rmap2", + description="TEST_NBR_2", + ), ], ), dict( @@ -134,6 +144,8 @@ def test_nxos_bgp_global_merged(self): "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 @@ def test_nxos_bgp_global_merged(self): "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 @@ def test_nxos_bgp_global_merged_idempotent(self): 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 @@ def test_nxos_bgp_global_merged_idempotent(self): 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( diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 8f12a4279..b3943f370 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -2713,3 +2713,64 @@ def test_nxos_bgp_nbr_parsed_3K(self): ) 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)) From 8b522224508fe06db5b24ef324f1a985bb034b94 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Sun, 10 Sep 2023 19:00:02 +0530 Subject: [PATCH 131/166] DNM (#752) --- .github/workflows/ack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml index fda595dc5..fa4957391 100644 --- a/.github/workflows/ack.yml +++ b/.github/workflows/ack.yml @@ -12,4 +12,4 @@ on: # yamllint disable-line rule:truthy jobs: ack: - uses: ansible/devtools/.github/workflows/ack.yml@main + uses: NilashishC/devtools/.github/workflows/ack.yml@main From ffe9ee18cb3959d3d6becf05c10b0f0b968dca1e Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Sun, 10 Sep 2023 19:04:35 +0530 Subject: [PATCH 132/166] Update ack.yml --- .github/workflows/ack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml index fa4957391..fda595dc5 100644 --- a/.github/workflows/ack.yml +++ b/.github/workflows/ack.yml @@ -12,4 +12,4 @@ on: # yamllint disable-line rule:truthy jobs: ack: - uses: NilashishC/devtools/.github/workflows/ack.yml@main + uses: ansible/devtools/.github/workflows/ack.yml@main From eafc98dcd7aacfb1f12b1ae61a05abab633192c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:07:23 +0530 Subject: [PATCH 133/166] [pre-commit.ci] pre-commit autoupdate (#754) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.7.0 → 23.9.1](https://github.com/psf/black/compare/23.7.0...23.9.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38554bc5a..95637e3da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black From c79c4756075d15d0d19e14517e86b9be93820666 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 12 Sep 2023 14:44:51 +0530 Subject: [PATCH 134/166] [route_maps] support extcommunity rt option (#750) * [route_maps] support extcommunity rt option Signed-off-by: NilashishC * Use different ack Signed-off-by: NilashishC * Fix sanity Signed-off-by: NilashishC * Temporarily remove broken workflow ack Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- .github/workflows/ack.yml | 15 ---- changelogs/fragments/route_maps.yaml | 3 + docs/cisco.nxos.nxos_route_maps_module.rst | 85 +++++++++++++++++++ .../nxos/argspec/route_maps/route_maps.py | 15 ++++ .../nxos/config/route_maps/route_maps.py | 15 ++++ .../network/nxos/rm_templates/route_maps.py | 39 +++++++++ plugins/modules/nxos_route_maps.py | 17 ++++ .../network/nxos/test_nxos_route_maps.py | 78 +++++++++++++++++ 8 files changed, 252 insertions(+), 15 deletions(-) delete mode 100644 .github/workflows/ack.yml create mode 100644 changelogs/fragments/route_maps.yaml diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml deleted file mode 100644 index fda595dc5..000000000 --- a/.github/workflows/ack.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml -name: ack - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: # yamllint disable-line rule:truthy - pull_request_target: - types: [opened, labeled, unlabeled, synchronize] - -jobs: - ack: - uses: ansible/devtools/.github/workflows/ack.yml@main diff --git a/changelogs/fragments/route_maps.yaml b/changelogs/fragments/route_maps.yaml new file mode 100644 index 000000000..cbf40bbbd --- /dev/null +++ b/changelogs/fragments/route_maps.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "route_maps - support extcommunity rt option (https://github.com/ansible-collections/cisco.nxos/issues/743)." diff --git a/docs/cisco.nxos.nxos_route_maps_module.rst b/docs/cisco.nxos.nxos_route_maps_module.rst index 817967670..6ced43a16 100644 --- a/docs/cisco.nxos.nxos_route_maps_module.rst +++ b/docs/cisco.nxos.nxos_route_maps_module.rst @@ -1882,6 +1882,91 @@ Parameters
    Set BGP extcommunity list (for deletion).
    +
    + extcommunity + +
    + dictionary +
    +
    + +
    Set BGP extcommunity attribute.
    +
    +
    + rt + +
    + dictionary +
    +
    + +
    Route-Target.
    +
    +
    + additive + +
    + boolean +
    +
    +
      Choices: +
    • no
    • +
    • yes
    • +
    +
    +
    Add to existing rt extcommunity.
    +
    +
    + extcommunity_numbers + +
    + list + / elements=string +
    +
    + +
    Extcommunity number.
    +
    Supported formats are ASN2:NN, ASN4:NN, IPV4:NN.
    +
    @@ -80,9 +81,6 @@ Examples # ENSURE VTP VERSION IS 2 - cisco.nxos.nxos_vtp_version: version: 2 - host: '{{ inventory_hostname }}' - username: '{{ un }}' - password: '{{ pwd }}' diff --git a/galaxy.yml b/galaxy.yml index 1813a6727..c44dc42e7 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 5.2.0 +version: 5.2.0-dev diff --git a/plugins/modules/nxos_vtp_version.py b/plugins/modules/nxos_vtp_version.py index 8c5305a08..a98bff904 100644 --- a/plugins/modules/nxos_vtp_version.py +++ b/plugins/modules/nxos_vtp_version.py @@ -46,15 +46,13 @@ choices: - '1' - '2' + - '3' type: str """ EXAMPLES = """ # ENSURE VTP VERSION IS 2 - cisco.nxos.nxos_vtp_version: version: 2 - host: '{{ inventory_hostname }}' - username: '{{ un }}' - password: '{{ pwd }}' """ RETURN = """ @@ -163,7 +161,7 @@ def get_vtp_password(module): def main(): - argument_spec = dict(version=dict(type="str", choices=["1", "2"], required=True)) + argument_spec = dict(version=dict(type="str", choices=["1", "2", "3"], required=True)) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) From 6d1d1976b1e6595beb219fabffa8017bbd111ec7 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 20 Sep 2023 09:46:58 +0530 Subject: [PATCH 139/166] [acls] update examples and use YAML output in them for better readibility (#760) * Update documentation for nxos_acls Signed-off-by: NilashishC * Add changelog Signed-off-by: NilashishC * Some lint updates Signed-off-by: NilashishC * Lint updates Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- .ansible-lint | 5 + .ansible-lint-ignore | 1 - changelogs/fragments/acls.yaml | 3 + docs/cisco.nxos.nxos_acls_module.rst | 710 +++++++++++++++--- .../network/nxos/facts/acls/acls.py | 2 +- plugins/modules/nxos_acls.py | 684 ++++++++++++++--- tests/config.yml | 3 + 7 files changed, 1228 insertions(+), 180 deletions(-) create mode 100644 .ansible-lint delete mode 100644 .ansible-lint-ignore create mode 100644 changelogs/fragments/acls.yaml create mode 100644 tests/config.yml diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 000000000..8d9bb70b8 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,5 @@ +--- +profile: production + +exclude_paths: + - changelogs/changelog.yaml diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore deleted file mode 100644 index 4a3745083..000000000 --- a/.ansible-lint-ignore +++ /dev/null @@ -1 +0,0 @@ -changelogs/changelog.yaml yaml[line-length] diff --git a/changelogs/fragments/acls.yaml b/changelogs/fragments/acls.yaml new file mode 100644 index 000000000..d352646f3 --- /dev/null +++ b/changelogs/fragments/acls.yaml @@ -0,0 +1,3 @@ +--- +doc_changes: + - "nxos_acls - update examples and use YAML output in them for better readibility." diff --git a/docs/cisco.nxos.nxos_acls_module.rst b/docs/cisco.nxos.nxos_acls_module.rst index 1c8801e8b..ee1f56f51 100644 --- a/docs/cisco.nxos.nxos_acls_module.rst +++ b/docs/cisco.nxos.nxos_acls_module.rst @@ -3111,46 +3111,89 @@ Examples # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' - - name: Merge new ACLs configuration + - name: Merge provided ACLs configuration with device configuration cisco.nxos.nxos_acls: + state: merged config: - - afi: ipv4 - acls: - - name: ACL1v4 - aces: - - grant: deny - destination: - address: 192.0.2.64 - wildcard_bits: 0.0.0.255 - source: - any: true - port_protocol: - lt: 55 - protocol: tcp - protocol_options: - tcp: - ack: true - fin: true - sequence: 50 + - afi: ipv4 + acls: + - name: ACL1v4 + aces: + - grant: deny + destination: + address: 192.0.2.64 + wildcard_bits: 0.0.0.255 + source: + any: true + port_protocol: + lt: 55 + protocol: tcp + protocol_options: + tcp: + ack: true + fin: true + sequence: 50 + + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: 2001:db8:12::/32 + protocol: sctp + + # Task Output + # ----------- + # before: [] + # + # commands: + # - ip access-list ACL1v4 + # - 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin + # - ipv6 access-list ACL1v6 + # - 10 permit sctp any 2001:db8:12::/32 + # + # after: + # - acls: + # - aces: + # - destination: + # prefix: 2001:db8:12::/32 + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # name: ACL1v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # address: 192.0.2.64 + # wildcard_bits: 0.0.0.255 + # grant: deny + # protocol: tcp + # protocol_options: + # tcp: + # ack: true + # fin: true + # sequence: 50 + # source: + # any: true + # port_protocol: + # lt: '55' + # name: ACL1v4 + # afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp - state: merged # After state: # ------------ # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -3160,94 +3203,269 @@ Examples # Before state: # ---------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any - # ip access-list ACL1v6 + # ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL - # ip access-list ACL2v6 + # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Replace existing ACL configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - sequence: 20 - grant: permit - source: - any: true - destination: - any: true - protocol: pip - - - remark: Replaced ACE - - - name: ACL2v6 + - afi: ipv4 + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - sequence: 20 + grant: permit + source: + any: true + destination: + any: true + protocol: pim + + - remark: Replaced ACE + - name: ACL2v6 state: replaced + # Task Output + # ----------- + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - ipv6 access-list ACL1v6 + # - no 10 permit sctp any any + # - no 20 remark IPv6 ACL + # - remark Replaced ACE + # - 20 permit pim any any + # - ipv6 access-list ACL2v6 + # - no 10 deny ipv6 any 2001:db8:3000::/36 + # - no 20 permit tcp host 2001:db8:2000:2::2 host 2001:db8:2000:ab::2 + # + # after: + # - acls: + # - aces: + # - remark: Replaced ACE + # sequence: 10 + # - destination: + # any: true + # grant: permit + # protocol: pim + # sequence: 20 + # source: + # any: true + # name: ACL1v6 + # - name: ACL2v6 + # afi: ipv6 + # After state: # --------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL1v6 - # 20 permit pip any any - # 30 remark Replaced ACE + # 10 remark Replaced ACE + # 20 permit pim any any # ipv6 access-list ACL2v6 # Using overridden # Before state: # ---------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any - # ip access-list ACL1v6 + # ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL - # ip access-list ACL2v6 + # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Override existing configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - acls: - - name: NewACL - aces: - - grant: deny - source: - address: 192.0.2.0 - wildcard_bits: 0.0.255.255 - destination: - any: true - protocol: eigrp - - remark: Example for overridden state + - afi: ipv4 + acls: + - name: NewACL + aces: + - grant: deny + source: + address: 192.0.2.0 + wildcard_bits: 0.0.255.255 + destination: + any: true + protocol: eigrp + - remark: Example for overridden state state: overridden + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ipv6 access-list ACL1v6 + # - no ipv6 access-list ACL2v6 + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - ip access-list NewACL + # - deny eigrp 192.0.2.0 0.0.255.255 any + # - remark Example for overridden state + # + # after: + # - acls: + # - aces: + # - destination: + # any: true + # grant: deny + # protocol: eigrp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.255.255 + # - remark: Example for overridden state + # sequence: 20 + # name: NewACL + # afi: ipv4 + # After state: # ------------ - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list NewACL # 10 deny eigrp 192.0.2.0 0.0.255.255 any # 20 remark Example for overridden state - # Using deleted: + # Using deleted - delete all # # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -3262,17 +3480,89 @@ Examples - name: Delete all ACLs cisco.nxos.nxos_acls: - config: state: deleted + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - no ipv6 access-list ACL1v6 + # - no ipv6 access-list ACL2v6 + # + # after: [] + + # After state: # ----------- + # nxos-9k# show running-config | section '^ip(v6)* access-list' # + # Using deleted - delete AFI # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -3291,9 +3581,106 @@ Examples - afi: ipv4 state: deleted + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # + # after: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # After state: # ------------ - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL @@ -3301,11 +3688,11 @@ Examples # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - + # Using deleted - delete ACLs # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -3320,18 +3707,106 @@ Examples - name: Delete specific ACLs cisco.nxos.nxos_acls: - config: - - afi: ipv4 - acls: - - name: ACL1v4 - - name: ACL2v4 - - afi: ipv6 - acls: - - name: ACL1v6 state: deleted + config: + - afi: ipv4 + acls: + - name: ACL1v4 + - name: ACL2v4 + - afi: ipv6 + acls: + - name: ACL1v6 + + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - no ipv6 access-list ACL1v6 + # + # after: + # - acls: + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 # After state: # ------------ + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 @@ -3347,7 +3822,9 @@ Examples 10 permit sctp any any state: parsed - # returns: + # Task Output + # ------------ + # # parsed: # - afi: ipv4 # acls: @@ -3385,7 +3862,7 @@ Examples # Before state: # ------------ - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -3395,7 +3872,9 @@ Examples cisco.nxos.nxos_acls: state: gathered - # returns: + # Task Output + # ----------- + # # gathered: # - afi: ipv4 # acls: @@ -3466,7 +3945,9 @@ Examples protocol: sctp state: rendered - # returns: + # Task Output + # ----------- + # # rendered: # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin @@ -3540,6 +4021,57 @@ Common return values are documented `here ['ip access-list ACL1v4', '10 permit ip any any precedence critical log', '20 deny tcp any lt smtp host 192.0.2.64 ack fin']
    +
    + gathered + +
    + list +
    +
    when state is gathered +
    Facts about the network resource gathered from the remote device as structured data.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + parsed + +
    + list +
    +
    when state is parsed +
    The device native config provided in running_config option parsed into structured data as per module argspec.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + rendered + +
    + list +
    +
    when state is rendered +
    The provided configuration in the task rendered in device-native format (offline).
    +
    +
    Sample:
    +
    ['interface GigabitEthernet1', 'description Interface description', 'shutdown']
    +


    diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index bc3aeffb3..0425a47d9 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -46,7 +46,7 @@ def __init__(self, module, subspec="config", options="options"): self.generated_spec = utils.generate_dict(facts_argument_spec) def get_device_data(self, connection): - data = connection.get("show running-config | section 'ip(v6)* access-list'") + data = connection.get("show running-config | section '^ip(v6)* access-list'") if data == "{}": return "" return data diff --git a/plugins/modules/nxos_acls.py b/plugins/modules/nxos_acls.py index 51a665047..cf43e85c0 100644 --- a/plugins/modules/nxos_acls.py +++ b/plugins/modules/nxos_acls.py @@ -507,46 +507,89 @@ # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' -- name: Merge new ACLs configuration +- name: Merge provided ACLs configuration with device configuration cisco.nxos.nxos_acls: + state: merged config: - - afi: ipv4 - acls: - - name: ACL1v4 - aces: - - grant: deny - destination: - address: 192.0.2.64 - wildcard_bits: 0.0.0.255 - source: - any: true - port_protocol: - lt: 55 - protocol: tcp - protocol_options: - tcp: - ack: true - fin: true - sequence: 50 + - afi: ipv4 + acls: + - name: ACL1v4 + aces: + - grant: deny + destination: + address: 192.0.2.64 + wildcard_bits: 0.0.0.255 + source: + any: true + port_protocol: + lt: 55 + protocol: tcp + protocol_options: + tcp: + ack: true + fin: true + sequence: 50 + + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: 2001:db8:12::/32 + protocol: sctp + +# Task Output +# ----------- +# before: [] +# +# commands: +# - ip access-list ACL1v4 +# - 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin +# - ipv6 access-list ACL1v6 +# - 10 permit sctp any 2001:db8:12::/32 +# +# after: +# - acls: +# - aces: +# - destination: +# prefix: 2001:db8:12::/32 +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# name: ACL1v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# address: 192.0.2.64 +# wildcard_bits: 0.0.0.255 +# grant: deny +# protocol: tcp +# protocol_options: +# tcp: +# ack: true +# fin: true +# sequence: 50 +# source: +# any: true +# port_protocol: +# lt: '55' +# name: ACL1v4 +# afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp - state: merged # After state: # ------------ # +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -556,94 +599,269 @@ # Before state: # ---------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any -# ip access-list ACL1v6 +# ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL -# ip access-list ACL2v6 +# ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Replace existing ACL configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - sequence: 20 - grant: permit - source: - any: true - destination: - any: true - protocol: pip - - - remark: Replaced ACE + - afi: ipv4 + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - sequence: 20 + grant: permit + source: + any: true + destination: + any: true + protocol: pim - - name: ACL2v6 + - remark: Replaced ACE + - name: ACL2v6 state: replaced +# Task Output +# ----------- +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - ipv6 access-list ACL1v6 +# - no 10 permit sctp any any +# - no 20 remark IPv6 ACL +# - remark Replaced ACE +# - 20 permit pim any any +# - ipv6 access-list ACL2v6 +# - no 10 deny ipv6 any 2001:db8:3000::/36 +# - no 20 permit tcp host 2001:db8:2000:2::2 host 2001:db8:2000:ab::2 +# +# after: +# - acls: +# - aces: +# - remark: Replaced ACE +# sequence: 10 +# - destination: +# any: true +# grant: permit +# protocol: pim +# sequence: 20 +# source: +# any: true +# name: ACL1v6 +# - name: ACL2v6 +# afi: ipv6 + # After state: # --------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL1v6 -# 20 permit pip any any -# 30 remark Replaced ACE +# 10 remark Replaced ACE +# 20 permit pim any any # ipv6 access-list ACL2v6 # Using overridden # Before state: # ---------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any -# ip access-list ACL1v6 +# ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL -# ip access-list ACL2v6 +# ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Override existing configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - acls: - - name: NewACL - aces: - - grant: deny - source: - address: 192.0.2.0 - wildcard_bits: 0.0.255.255 - destination: - any: true - protocol: eigrp - - remark: Example for overridden state + - afi: ipv4 + acls: + - name: NewACL + aces: + - grant: deny + source: + address: 192.0.2.0 + wildcard_bits: 0.0.255.255 + destination: + any: true + protocol: eigrp + - remark: Example for overridden state state: overridden +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ipv6 access-list ACL1v6 +# - no ipv6 access-list ACL2v6 +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - ip access-list NewACL +# - deny eigrp 192.0.2.0 0.0.255.255 any +# - remark Example for overridden state +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: deny +# protocol: eigrp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.255.255 +# - remark: Example for overridden state +# sequence: 20 +# name: NewACL +# afi: ipv4 + # After state: # ------------ -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list NewACL # 10 deny eigrp 192.0.2.0 0.0.255.255 any # 20 remark Example for overridden state -# Using deleted: +# Using deleted - delete all # # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -658,17 +876,89 @@ - name: Delete all ACLs cisco.nxos.nxos_acls: - config: state: deleted +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - no ipv6 access-list ACL1v6 +# - no ipv6 access-list ACL2v6 +# +# after: [] + + # After state: # ----------- +# nxos-9k# show running-config | section '^ip(v6)* access-list' # +# Using deleted - delete AFI # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -687,9 +977,106 @@ - afi: ipv4 state: deleted +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 + # After state: # ------------ -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL @@ -697,11 +1084,11 @@ # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - +# Using deleted - delete ACLs # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -716,18 +1103,106 @@ - name: Delete specific ACLs cisco.nxos.nxos_acls: - config: - - afi: ipv4 - acls: - - name: ACL1v4 - - name: ACL2v4 - - afi: ipv6 - acls: - - name: ACL1v6 state: deleted + config: + - afi: ipv4 + acls: + - name: ACL1v4 + - name: ACL2v4 + - afi: ipv6 + acls: + - name: ACL1v6 + +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - no ipv6 access-list ACL1v6 +# +# after: +# - acls: +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 # After state: # ------------ +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 @@ -743,7 +1218,9 @@ 10 permit sctp any any state: parsed -# returns: +# Task Output +# ------------ +# # parsed: # - afi: ipv4 # acls: @@ -781,7 +1258,7 @@ # Before state: # ------------ -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -791,7 +1268,9 @@ cisco.nxos.nxos_acls: state: gathered -# returns: +# Task Output +# ----------- +# # gathered: # - afi: ipv4 # acls: @@ -862,7 +1341,9 @@ protocol: sctp state: rendered -# returns: +# Task Output +# ----------- +# # rendered: # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin @@ -888,7 +1369,32 @@ description: The set of commands pushed to the remote device. returned: always type: list - sample: ['ip access-list ACL1v4', '10 permit ip any any precedence critical log', '20 deny tcp any lt smtp host 192.0.2.64 ack fin'] + sample: + - ip access-list ACL1v4 + - 10 permit ip any any precedence critical log + - 20 deny tcp any lt smtp host 192.0.2.64 ack fin +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - interface GigabitEthernet1 + - description Interface description + - shutdown +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule diff --git a/tests/config.yml b/tests/config.yml new file mode 100644 index 000000000..41f529264 --- /dev/null +++ b/tests/config.yml @@ -0,0 +1,3 @@ +--- +modules: + python_requires: ">=3.6" From 889997896461667a51fe30347074665f4187f631 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Mon, 2 Oct 2023 11:09:43 +0530 Subject: [PATCH 140/166] [acls] fix ACE parsing error with named source/dest port range (#764) * [acls] fix ACE parsing error with named source/dest port range Signed-off-by: NilashishC * Add ignore Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- changelogs/fragments/fix_763.yaml | 3 + .../network/nxos/facts/acls/acls.py | 2 +- tests/sanity/ignore-2.17.txt | 1 + .../modules/network/nxos/test_nxos_acls.py | 87 +++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/fix_763.yaml create mode 100644 tests/sanity/ignore-2.17.txt diff --git a/changelogs/fragments/fix_763.yaml b/changelogs/fragments/fix_763.yaml new file mode 100644 index 000000000..658e5843a --- /dev/null +++ b/changelogs/fragments/fix_763.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "nxos_acls - fix parsing of ACE with named source/dest port range (https://github.com/ansible-collections/cisco.nxos/issues/763)." diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index 0425a47d9..ca086bcf9 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -125,7 +125,7 @@ def get_endpoint(self, ace, pro): ace = re.sub(port_pro.group(1), "", ace, 1) ace = re.sub(port_pro.group(2), "", ace, 1) else: - limit = re.search(r"range\s(?P\w+)\s(?P\w+)", ace) + limit = re.search(r"range\s(?P\S+)\s(?P\S+)", ace) if limit: rstart = limit.groupdict()["rstart"] rend = limit.groupdict()["rend"] diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt new file mode 100644 index 000000000..46cfbc643 --- /dev/null +++ b/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/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index 631d72741..b7c0e8663 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -873,3 +873,90 @@ def test_nxos_acls_icmpv6_1(self): ] 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) From 538dcf12700709eac9a4f53956598e1d1ca33c89 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 3 Oct 2023 13:22:27 +0530 Subject: [PATCH 141/166] trivial docs update (#767) Signed-off-by: NilashishC --- changelogs/fragments/trivial.yaml | 3 +++ docs/cisco.nxos.nxos_acls_module.rst | 2 +- plugins/modules/nxos_acls.py | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/trivial.yaml diff --git a/changelogs/fragments/trivial.yaml b/changelogs/fragments/trivial.yaml new file mode 100644 index 000000000..3f0dfde5c --- /dev/null +++ b/changelogs/fragments/trivial.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix erroneous doc updates in nxos_acls. diff --git a/docs/cisco.nxos.nxos_acls_module.rst b/docs/cisco.nxos.nxos_acls_module.rst index ee1f56f51..8a4c23f3d 100644 --- a/docs/cisco.nxos.nxos_acls_module.rst +++ b/docs/cisco.nxos.nxos_acls_module.rst @@ -4069,7 +4069,7 @@ Common return values are documented `here The provided configuration in the task rendered in device-native format (offline).
    Sample:
    -
    ['interface GigabitEthernet1', 'description Interface description', 'shutdown']
    +
    ['ip access-list ACL1v4', '10 permit ip any any precedence critical log', '20 deny tcp any lt smtp host 192.0.2.64 ack fin']
    diff --git a/plugins/modules/nxos_acls.py b/plugins/modules/nxos_acls.py index cf43e85c0..133bd3a44 100644 --- a/plugins/modules/nxos_acls.py +++ b/plugins/modules/nxos_acls.py @@ -1378,9 +1378,9 @@ returned: when I(state) is C(rendered) type: list sample: - - interface GigabitEthernet1 - - description Interface description - - shutdown + - ip access-list ACL1v4 + - 10 permit ip any any precedence critical log + - 20 deny tcp any lt smtp host 192.0.2.64 ack fin gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) From 01d7db2f2ebb819a08dd284e5ea8a788ef8e4940 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 3 Oct 2023 15:27:47 +0530 Subject: [PATCH 142/166] Prepare for release v5.2.1 (#766) Signed-off-by: NilashishC --- CHANGELOG.rst | 14 ++++++++++++++ changelogs/changelog.yaml | 12 ++++++++++++ changelogs/fragments/acls.yaml | 3 --- changelogs/fragments/fix_763.yaml | 3 --- changelogs/fragments/vtp_version.yaml | 3 --- 5 files changed, 26 insertions(+), 9 deletions(-) delete mode 100644 changelogs/fragments/acls.yaml delete mode 100644 changelogs/fragments/fix_763.yaml delete mode 100644 changelogs/fragments/vtp_version.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8778fcba8..9362e34d6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,20 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v5.2.1 +====== + +Bugfixes +-------- + +- nxos_acls - fix parsing of ACE with named source/dest port range (https://github.com/ansible-collections/cisco.nxos/issues/763). +- vtp_version - allow VTP version 3 to be configured (https://github.com/ansible-collections/cisco.nxos/issues/704). + +Documentation Changes +--------------------- + +- nxos_acls - update examples and use YAML output in them for better readibility. + v5.2.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 758e60a2c..91c728004 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1002,3 +1002,15 @@ releases: name: nxos_fc_interfaces namespace: "" release_date: "2023-09-14" + 5.2.1: + changes: + bugfixes: + - nxos_acls - fix parsing of ACE with named source/dest port range (https://github.com/ansible-collections/cisco.nxos/issues/763). + - vtp_version - allow VTP version 3 to be configured (https://github.com/ansible-collections/cisco.nxos/issues/704). + doc_changes: + - nxos_acls - update examples and use YAML output in them for better readibility. + fragments: + - acls.yaml + - fix_763.yaml + - vtp_version.yaml + release_date: "2023-10-03" diff --git a/changelogs/fragments/acls.yaml b/changelogs/fragments/acls.yaml deleted file mode 100644 index d352646f3..000000000 --- a/changelogs/fragments/acls.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -doc_changes: - - "nxos_acls - update examples and use YAML output in them for better readibility." diff --git a/changelogs/fragments/fix_763.yaml b/changelogs/fragments/fix_763.yaml deleted file mode 100644 index 658e5843a..000000000 --- a/changelogs/fragments/fix_763.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "nxos_acls - fix parsing of ACE with named source/dest port range (https://github.com/ansible-collections/cisco.nxos/issues/763)." diff --git a/changelogs/fragments/vtp_version.yaml b/changelogs/fragments/vtp_version.yaml deleted file mode 100644 index afe01f592..000000000 --- a/changelogs/fragments/vtp_version.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "vtp_version - allow VTP version 3 to be configured (https://github.com/ansible-collections/cisco.nxos/issues/704)." From 1fd405b383827716ef8f3c8c7eabe9d2e317d61d Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 3 Oct 2023 20:52:49 +0530 Subject: [PATCH 143/166] Update galaxy.yml --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index c44dc42e7..18cc93af2 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 5.2.0-dev +version: 5.2.1 From 1c24cc4e6b81195bbda4abf146c8ee47c9fc525d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:19:49 +0530 Subject: [PATCH 144/166] [pre-commit.ci] pre-commit autoupdate (#770) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95637e3da..d589116e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: update-docs - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: check-symlinks From f6abf6bcb104156e84f6f304ba5b7ab90b12f173 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:50:31 +0530 Subject: [PATCH 145/166] [pre-commit.ci] pre-commit autoupdate (#773) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.9.1 → 23.10.0](https://github.com/psf/black/compare/23.9.1...23.10.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d589116e4..afaa7617e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.0 hooks: - id: black From 6cf40f82cd94a3f09217e0d732b969d5282285e9 Mon Sep 17 00:00:00 2001 From: Ashwini Mhatre Date: Wed, 25 Oct 2023 16:38:02 +0530 Subject: [PATCH 146/166] Bugfix: Config module (#768) * Fix config module * Add uts and integration tests * Add uts and integration tests * Address review comments * Fix integration tests * Address review comments * Fix sanity * Fix tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Ashwini Mhatre Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- changelogs/fragments/fix_config_module.yaml | 3 ++ plugins/modules/nxos_config.py | 6 +-- .../nxos_config/templates/basic/acl_config.j2 | 5 +++ .../nxos_config/tests/cli/replace_block.yaml | 35 +++++++++++++++ .../modules/network/nxos/test_nxos_config.py | 43 ++++++++++++++++++- 5 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/fix_config_module.yaml create mode 100644 tests/integration/targets/nxos_config/templates/basic/acl_config.j2 create mode 100644 tests/integration/targets/nxos_config/tests/cli/replace_block.yaml diff --git a/changelogs/fragments/fix_config_module.yaml b/changelogs/fragments/fix_config_module.yaml new file mode 100644 index 000000000..d7c1c79db --- /dev/null +++ b/changelogs/fragments/fix_config_module.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "nxos_config - Relax restrictions on I(src) parameter so it can be used more like I(lines). (https://github.com/ansible-collections/cisco.nxos/issues/89)." diff --git a/plugins/modules/nxos_config.py b/plugins/modules/nxos_config.py index 8cccae68f..132a62d28 100644 --- a/plugins/modules/nxos_config.py +++ b/plugins/modules/nxos_config.py @@ -415,9 +415,9 @@ def main(): mutually_exclusive = [("lines", "src", "replace_src"), ("parents", "src")] required_if = [ - ("match", "strict", ["lines"]), - ("match", "exact", ["lines"]), - ("replace", "block", ["lines"]), + ("match", "strict", ["lines", "src"], True), + ("match", "exact", ["lines", "src"], True), + ("replace", "block", ["lines", "src"], True), ("replace", "config", ["replace_src"]), ("diff_against", "intended", ["intended_config"]), ] diff --git a/tests/integration/targets/nxos_config/templates/basic/acl_config.j2 b/tests/integration/targets/nxos_config/templates/basic/acl_config.j2 new file mode 100644 index 000000000..ec03c24a2 --- /dev/null +++ b/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/tests/integration/targets/nxos_config/tests/cli/replace_block.yaml b/tests/integration/targets/nxos_config/tests/cli/replace_block.yaml new file mode 100644 index 000000000..deb79b940 --- /dev/null +++ b/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/tests/unit/modules/network/nxos/test_nxos_config.py b/tests/unit/modules/network/nxos/test_nxos_config.py index 83e58722a..ce5c987c7 100644 --- a/tests/unit/modules/network/nxos/test_nxos_config.py +++ b/tests/unit/modules/network/nxos/test_nxos_config.py @@ -181,6 +181,47 @@ def test_nxos_config_parents(self): 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 @@ def test_nxos_config_match_strict_requires_lines(self): 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) From d7fcc2d4d5cfa1db61ba5f78b180b39fcf9b5fb9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:38:27 +0530 Subject: [PATCH 147/166] [pre-commit.ci] pre-commit autoupdate (#775) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.10.0 → 23.10.1](https://github.com/psf/black/compare/23.10.0...23.10.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index afaa7617e..60411e511 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.10.0 + rev: 23.10.1 hooks: - id: black From 077e5a10f5cac16b3ed40e3ccddd3aa78a9c0055 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Fri, 24 Nov 2023 12:54:23 +0530 Subject: [PATCH 148/166] Fix sanity failures with devel (#781) * Fix sanity failures with devel Signed-off-by: NilashishC * Update condition in workflow Signed-off-by: NilashishC * Fix typo Signed-off-by: NilashishC --------- Signed-off-by: NilashishC --- .github/workflows/tests.yml | 2 +- plugins/module_utils/network/nxos/facts/vlans/vlans.py | 2 +- tests/unit/modules/network/nxos/test_nxos_pim_interface.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e24cbcd8..e9f92a2a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: git+https://github.com/ansible-collections/ansible.utils.git git+https://github.com/ansible-collections/ansible.netcommon.git all_green: - if: ${{ always() && (github.event_name != 'schedule') }} + if: ${{ always() }} needs: - ansible-lint - changelog diff --git a/plugins/module_utils/network/nxos/facts/vlans/vlans.py b/plugins/module_utils/network/nxos/facts/vlans/vlans.py index 32968d2d1..f7ac798f1 100644 --- a/plugins/module_utils/network/nxos/facts/vlans/vlans.py +++ b/plugins/module_utils/network/nxos/facts/vlans/vlans.py @@ -166,7 +166,7 @@ def normalize_table_data(self, structured, run_cfg_output): # "vlanshowinfo-vlanmode": "ce-vlan"}} mtuinfo = structured["TABLE_mtuinfo"]["ROW_mtuinfo"] - if type(vlanbrief) is not list: + if not isinstance(vlanbrief, list): # vlanbrief is not a list when only one vlan is found. vlanbrief = [vlanbrief] mtuinfo = [mtuinfo] diff --git a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py index 3f0d56bb6..b746b8b46 100644 --- a/tests/unit/modules/network/nxos/test_nxos_pim_interface.py +++ b/tests/unit/modules/network/nxos/test_nxos_pim_interface.py @@ -63,7 +63,7 @@ def load_from_file(*args, **kwargs): output = list() for command in commands: - if type(command) is dict: + if isinstance(command, dict): command = command["command"] filename = str(command).split(" | ", 1)[0].replace(" ", "_").replace("/", "_") output.append(load_fixture(module_name, filename)) From b7ae6d5a0179cb822a8e933e6e8967cf720d1311 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:51:22 +0530 Subject: [PATCH 149/166] [pre-commit.ci] pre-commit autoupdate (#777) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v3.1.0) - [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60411e511..ac716f311 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v3.1.0" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black From c640027250e314bed4cb834ccab25691f0c1d1c4 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 29 Nov 2023 17:10:53 +0530 Subject: [PATCH 150/166] Prepare for v5.3.0 (#784) * Prepare for v5.3.0 Signed-off-by: NilashishC * update galaxy Signed-off-by: NilashishC * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: NilashishC Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.rst | 8 ++++++++ changelogs/changelog.yaml | 9 +++++++++ changelogs/fragments/fix_config_module.yaml | 3 --- changelogs/fragments/trivial.yaml | 3 --- galaxy.yml | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) delete mode 100644 changelogs/fragments/fix_config_module.yaml delete mode 100644 changelogs/fragments/trivial.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9362e34d6..a23f4bf80 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,14 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v5.3.0 +====== + +Minor Changes +------------- + +- nxos_config - Relax restrictions on I(src) parameter so it can be used more like I(lines). (https://github.com/ansible-collections/cisco.nxos/issues/89). + v5.2.1 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 91c728004..055d17154 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1014,3 +1014,12 @@ releases: - fix_763.yaml - vtp_version.yaml release_date: "2023-10-03" + 5.3.0: + changes: + minor_changes: + - nxos_config - Relax restrictions on I(src) parameter so it can be used more + like I(lines). (https://github.com/ansible-collections/cisco.nxos/issues/89). + fragments: + - fix_config_module.yaml + - trivial.yaml + release_date: "2023-11-29" diff --git a/changelogs/fragments/fix_config_module.yaml b/changelogs/fragments/fix_config_module.yaml deleted file mode 100644 index d7c1c79db..000000000 --- a/changelogs/fragments/fix_config_module.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - "nxos_config - Relax restrictions on I(src) parameter so it can be used more like I(lines). (https://github.com/ansible-collections/cisco.nxos/issues/89)." diff --git a/changelogs/fragments/trivial.yaml b/changelogs/fragments/trivial.yaml deleted file mode 100644 index 3f0dfde5c..000000000 --- a/changelogs/fragments/trivial.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix erroneous doc updates in nxos_acls. diff --git a/galaxy.yml b/galaxy.yml index 18cc93af2..da53d0068 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 5.2.1 +version: 5.3.0 From 62d6cee03b234ef1135664bd7ea25ee8f76d964b Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Thu, 30 Nov 2023 11:37:37 +0530 Subject: [PATCH 151/166] fix lint workflow, update reference (#762) * fix lint workflow, update reference * lint fix * rem comments * Add 2.17 ignore Signed-off-by: NilashishC * fix lint * New ansible-lint fixes Signed-off-by: NilashishC * pre-commit fixes Signed-off-by: NilashishC * Fixes Signed-off-by: NilashishC --------- Signed-off-by: NilashishC Co-authored-by: NilashishC --- .github/workflows/lint.yml | 13 + .github/workflows/tests.yml | 4 - README.md | 2 +- changelogs/fragments/trivial_lint.yaml | 3 + .../cisco.nxos.nxos_acl_interfaces_module.rst | 146 ++++----- docs/cisco.nxos.nxos_acls_module.rst | 76 ++--- .../cisco.nxos.nxos_bfd_interfaces_module.rst | 48 +-- ...co.nxos.nxos_bgp_address_family_module.rst | 70 ++--- docs/cisco.nxos.nxos_bgp_global_module.rst | 54 ++-- ...xos_bgp_neighbor_address_family_module.rst | 38 +-- docs/cisco.nxos.nxos_command_module.rst | 24 +- docs/cisco.nxos.nxos_config_module.rst | 20 +- docs/cisco.nxos.nxos_devicealias_module.rst | 24 +- docs/cisco.nxos.nxos_evpn_vni_module.rst | 4 +- docs/cisco.nxos.nxos_facts_module.rst | 10 +- docs/cisco.nxos.nxos_fc_interfaces_module.rst | 94 +++--- ...xos.nxos_gir_profile_management_module.rst | 4 +- ...cisco.nxos.nxos_hsrp_interfaces_module.rst | 36 +-- .../cisco.nxos.nxos_igmp_interface_module.rst | 4 +- docs/cisco.nxos.nxos_install_os_module.rst | 3 +- docs/cisco.nxos.nxos_interfaces_module.rst | 60 ++-- docs/cisco.nxos.nxos_l2_interfaces_module.rst | 54 ++-- docs/cisco.nxos.nxos_l3_interfaces_module.rst | 70 ++--- ...cisco.nxos.nxos_lacp_interfaces_module.rst | 40 +-- .../cisco.nxos.nxos_lag_interfaces_module.rst | 40 +-- ...cisco.nxos.nxos_lldp_interfaces_module.rst | 28 +- .../cisco.nxos.nxos_logging_global_module.rst | 4 +- docs/cisco.nxos.nxos_logging_module.rst | 6 +- docs/cisco.nxos.nxos_ntp_global_module.rst | 44 +-- ...cisco.nxos.nxos_ospf_interfaces_module.rst | 183 ++++++------ docs/cisco.nxos.nxos_ospfv2_module.rst | 278 +++++++++--------- docs/cisco.nxos.nxos_ospfv3_module.rst | 242 +++++++-------- docs/cisco.nxos.nxos_route_maps_module.rst | 128 ++++---- docs/cisco.nxos.nxos_snmp_server_module.rst | 90 +++--- docs/cisco.nxos.nxos_static_routes_module.rst | 126 ++++---- docs/cisco.nxos.nxos_system_module.rst | 8 +- docs/cisco.nxos.nxos_telemetry_module.rst | 82 +++--- docs/cisco.nxos.nxos_user_module.rst | 4 +- docs/cisco.nxos.nxos_vlans_module.rst | 42 +-- docs/cisco.nxos.nxos_vrf_af_module.rst | 53 ++-- docs/cisco.nxos.nxos_vrf_module.rst | 38 +-- docs/cisco.nxos.nxos_vsan_module.rst | 38 +-- docs/cisco.nxos.nxos_zone_zoneset_module.rst | 96 +++--- meta/runtime.yml | 2 +- plugins/modules/nxos_aaa_server_host.py | 5 +- plugins/modules/nxos_acl_interfaces.py | 147 +++++---- plugins/modules/nxos_acls.py | 76 ++--- plugins/modules/nxos_bfd_interfaces.py | 48 +-- plugins/modules/nxos_bgp_address_family.py | 72 ++--- plugins/modules/nxos_bgp_global.py | 56 ++-- .../nxos_bgp_neighbor_address_family.py | 44 +-- plugins/modules/nxos_command.py | 25 +- plugins/modules/nxos_config.py | 58 ++-- plugins/modules/nxos_devicealias.py | 58 ++-- plugins/modules/nxos_evpn_vni.py | 8 +- plugins/modules/nxos_facts.py | 10 +- plugins/modules/nxos_fc_interfaces.py | 98 +++--- .../modules/nxos_gir_profile_management.py | 4 +- plugins/modules/nxos_hostname.py | 1 - plugins/modules/nxos_hsrp_interfaces.py | 37 ++- plugins/modules/nxos_igmp_interface.py | 18 +- plugins/modules/nxos_install_os.py | 7 +- plugins/modules/nxos_interfaces.py | 62 ++-- plugins/modules/nxos_l2_interfaces.py | 54 ++-- plugins/modules/nxos_l3_interfaces.py | 70 ++--- plugins/modules/nxos_lacp_interfaces.py | 40 +-- plugins/modules/nxos_lag_interfaces.py | 40 +-- plugins/modules/nxos_lldp_interfaces.py | 30 +- plugins/modules/nxos_logging.py | 6 +- plugins/modules/nxos_logging_global.py | 4 +- plugins/modules/nxos_ntp_global.py | 44 +-- plugins/modules/nxos_ospf_interfaces.py | 197 +++++++------ plugins/modules/nxos_ospfv2.py | 278 +++++++++--------- plugins/modules/nxos_ospfv3.py | 278 +++++++++--------- plugins/modules/nxos_route_maps.py | 128 ++++---- plugins/modules/nxos_snmp_server.py | 90 +++--- plugins/modules/nxos_static_routes.py | 126 ++++---- plugins/modules/nxos_system.py | 8 +- plugins/modules/nxos_telemetry.py | 84 +++--- plugins/modules/nxos_user.py | 4 +- plugins/modules/nxos_vlans.py | 42 +-- plugins/modules/nxos_vrf.py | 46 +-- plugins/modules/nxos_vrf_af.py | 74 +++-- plugins/modules/nxos_vsan.py | 62 ++-- plugins/modules/nxos_zone_zoneset.py | 226 ++++++++------ tests/config.yml | 2 +- 86 files changed, 2656 insertions(+), 2544 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 changelogs/fragments/trivial_lint.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..fbac38cbf --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,13 @@ +--- +name: ansible-lint +on: # yamllint disable-line rule:truthy + pull_request: + branches: ["main"] +jobs: + build: + name: Ansible Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run ansible-lint + uses: ansible/ansible-lint@main diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e9f92a2a0..e93330f3a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,8 +14,6 @@ on: # yamllint disable-line rule:truthy jobs: - ansible-lint: - uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main changelog: uses: ansible-network/github_actions/.github/workflows/changelog.yml@main if: github.event_name == 'pull_request' @@ -32,7 +30,6 @@ jobs: all_green: if: ${{ always() }} needs: - - ansible-lint - changelog - sanity - unit-galaxy @@ -42,7 +39,6 @@ jobs: - run: >- python -c "assert 'failure' not in set([ - '${{ needs.ansible-lint.result }}', '${{ needs.changelog.result }}', '${{ needs.sanity.result }}', '${{ needs.unit-galaxy.result }}', diff --git a/README.md b/README.md index e8ad6e9d9..d7e176763 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The modules with full support for Cisco MDS are tested against NX-OS 8.4(1) on M ## Ansible version compatibility -This collection has been tested against following Ansible versions: **>=2.9.10**. +This collection has been tested against following Ansible versions: **>=2.14.0**. For collections that support Ansible 2.9, please ensure you update your `network_os` to use the fully qualified collection name (for example, `cisco.ios.ios`). diff --git a/changelogs/fragments/trivial_lint.yaml b/changelogs/fragments/trivial_lint.yaml new file mode 100644 index 000000000..744f36321 --- /dev/null +++ b/changelogs/fragments/trivial_lint.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - "Fix lint action reference." diff --git a/docs/cisco.nxos.nxos_acl_interfaces_module.rst b/docs/cisco.nxos.nxos_acl_interfaces_module.rst index 938e0cafe..a2885df02 100644 --- a/docs/cisco.nxos.nxos_acl_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_acl_interfaces_module.rst @@ -258,28 +258,28 @@ Examples - name: Merge ACL interfaces configuration cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/2 - access_groups: - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in - - - name: Eth1/5 - access_groups: - - afi: ipv4 - acls: - - name: PortACL - direction: in - port: true - - - name: ACL1v4 - direction: out - - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in + - name: Ethernet1/2 + access_groups: + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in + + - name: Eth1/5 + access_groups: + - afi: ipv4 + acls: + - name: PortACL + direction: in + port: true + + - name: ACL1v4 + direction: out + + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in state: merged # After state: @@ -305,20 +305,20 @@ Examples - name: Replace interface configuration with given configuration cisco.nxos.nxos_acl_interfaces: config: - - name: Eth1/5 - access_groups: - - afi: ipv4 - acls: - - name: NewACLv4 - direction: out - - - name: Ethernet1/3 - access_groups: - - afi: ipv6 - acls: - - name: NewACLv6 - direction: in - port: true + - name: Eth1/5 + access_groups: + - afi: ipv4 + acls: + - name: NewACLv4 + direction: out + + - name: Ethernet1/3 + access_groups: + - afi: ipv6 + acls: + - name: NewACLv6 + direction: in + port: true state: replaced # After state: @@ -344,21 +344,21 @@ Examples - name: Override interface configuration with given configuration cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/3 - access_groups: - - afi: ipv4 - acls: - - name: ACL1v4 - direction: out - - - name: PortACL - port: true - direction: in - - afi: ipv6 - acls: - - name: NewACLv6 - direction: in - port: true + - name: Ethernet1/3 + access_groups: + - afi: ipv4 + acls: + - name: ACL1v4 + direction: out + + - name: PortACL + port: true + direction: in + - afi: ipv6 + acls: + - name: NewACLv6 + direction: in + port: true state: overridden # After state: @@ -384,8 +384,8 @@ Examples - name: Delete ACL configuration on interfaces cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/5 - - name: Ethernet1/2 + - name: Ethernet1/5 + - name: Ethernet1/2 state: deleted # After state: @@ -498,28 +498,28 @@ Examples - name: Render required configuration to be pushed to the device cisco.nxos.nxos_acl_interfaces: config: - - name: Ethernet1/2 - access_groups: - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in - - - name: Ethernet1/5 - access_groups: - - afi: ipv4 - acls: - - name: PortACL - direction: in - port: true - - name: ACL1v4 - direction: out - - afi: ipv6 - acls: - - name: ACL1v6 - direction: in + - name: Ethernet1/2 + access_groups: + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in + - name: Ethernet1/5 + access_groups: + - afi: ipv4 + acls: + - name: PortACL + direction: in + port: true + - name: ACL1v4 + direction: out + - afi: ipv6 + acls: + - name: ACL1v6 + direction: in state: rendered + # returns # rendered: # interface Ethernet1/2 diff --git a/docs/cisco.nxos.nxos_acls_module.rst b/docs/cisco.nxos.nxos_acls_module.rst index 8a4c23f3d..1b806511d 100644 --- a/docs/cisco.nxos.nxos_acls_module.rst +++ b/docs/cisco.nxos.nxos_acls_module.rst @@ -3140,13 +3140,13 @@ Examples acls: - name: ACL1v6 aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: 2001:db8:12::/32 + protocol: sctp # Task Output # ----------- @@ -3578,7 +3578,7 @@ Examples - name: Delete all ACLs in given AFI cisco.nxos.nxos_acls: config: - - afi: ipv4 + - afi: ipv4 state: deleted # Task Output @@ -3913,38 +3913,38 @@ Examples - name: Render required configuration to be pushed to the device cisco.nxos.nxos_acls: config: - - afi: ipv4 - acls: - - name: ACL1v4 - aces: - - grant: deny - destination: - address: 192.0.2.64 - wildcard_bits: 0.0.0.255 - source: - any: true - port_protocol: - lt: 55 - protocol: tcp - protocol_options: - tcp: - ack: true - fin: true - sequence: 50 - - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp + - afi: ipv4 + acls: + - name: ACL1v4 + aces: + - grant: deny + destination: + address: 192.0.2.64 + wildcard_bits: 0.0.0.255 + source: + any: true + port_protocol: + lt: 55 + protocol: tcp + protocol_options: + tcp: + ack: true + fin: true + sequence: 50 + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: '2001:db8:12::/32' + protocol: sctp state: rendered + # Task Output # ----------- # diff --git a/docs/cisco.nxos.nxos_bfd_interfaces_module.rst b/docs/cisco.nxos.nxos_bfd_interfaces_module.rst index 17aac421c..975de891c 100644 --- a/docs/cisco.nxos.nxos_bfd_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_bfd_interfaces_module.rst @@ -178,12 +178,12 @@ Examples - name: Configure interfaces cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/1 - bfd: enable - echo: enable - - name: Ethernet1/2 - bfd: disable - echo: disable + - name: Ethernet1/1 + bfd: enable + echo: enable + - name: Ethernet1/2 + bfd: disable + echo: disable state: merged @@ -192,12 +192,12 @@ Examples - name: Configure interfaces cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/1 - bfd: enable - echo: enable - - name: Ethernet1/2 - bfd: disable - echo: disable + - name: Ethernet1/1 + bfd: enable + echo: enable + - name: Ethernet1/2 + bfd: disable + echo: disable state: overridden @@ -206,12 +206,12 @@ Examples - name: Configure interfaces cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/1 - bfd: enable - echo: enable - - name: Ethernet1/2 - bfd: disable - echo: disable + - name: Ethernet1/1 + bfd: enable + echo: enable + - name: Ethernet1/2 + bfd: disable + echo: disable state: replaced # Using rendered @@ -219,12 +219,12 @@ Examples - name: Use rendered state to convert task input to device specific commands cisco.nxos.nxos_bfd_interfaces: config: - - name: Ethernet1/800 - bfd: enable - echo: enable - - name: Ethernet1/801 - bfd: disable - echo: disable + - name: Ethernet1/800 + bfd: enable + echo: enable + - name: Ethernet1/801 + bfd: disable + echo: disable state: rendered # Task Output (redacted) diff --git a/docs/cisco.nxos.nxos_bgp_address_family_module.rst b/docs/cisco.nxos.nxos_bgp_address_family_module.rst index 8378c8439..d16dbee7d 100644 --- a/docs/cisco.nxos.nxos_bgp_address_family_module.rst +++ b/docs/cisco.nxos.nxos_bgp_address_family_module.rst @@ -1674,11 +1674,11 @@ Examples safi: unicast vrf: site-1 default_information: - originate: True + originate: true aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv6 safi: multicast vrf: site-1 @@ -1727,11 +1727,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -1797,8 +1797,8 @@ Examples non_critical_delay: 180 aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: unicast vrf: site-1 @@ -1824,11 +1824,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -1865,8 +1865,8 @@ Examples # non_critical_delay: 180 # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # # - afi: ipv4 # safi: unicast @@ -1929,8 +1929,8 @@ Examples route_map: rmap1 aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv4 safi: unicast vrf: site-1 @@ -1956,11 +1956,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -1997,8 +1997,8 @@ Examples # route_map: rmap1 # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv4 # safi: unicast # vrf: site-1 @@ -2066,11 +2066,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -2095,11 +2095,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # After state: # ------------ @@ -2153,11 +2153,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 @@ -2207,11 +2207,11 @@ Examples safi: unicast vrf: site-1 default_information: - originate: True + originate: true aggregate_address: - prefix: 203.0.113.0/24 - as_set: True - summary_only: True + as_set: true + summary_only: true - afi: ipv6 safi: multicast vrf: site-1 @@ -2284,11 +2284,11 @@ Examples # safi: unicast # vrf: site-1 # default_information: - # originate: True + # originate: true # aggregate_address: # - prefix: 203.0.113.0/24 - # as_set: True - # summary_only: True + # as_set: true + # summary_only: true # - afi: ipv6 # safi: multicast # vrf: site-1 diff --git a/docs/cisco.nxos.nxos_bgp_global_module.rst b/docs/cisco.nxos.nxos_bgp_global_module.rst index 1ef0c27b4..19ee2709e 100644 --- a/docs/cisco.nxos.nxos_bgp_global_module.rst +++ b/docs/cisco.nxos.nxos_bgp_global_module.rst @@ -4630,16 +4630,16 @@ Examples router_id: 192.168.1.1 bestpath: as_path: - multipath_relax: True - compare_neighborid: True - cost_community_ignore: True + multipath_relax: true + compare_neighborid: true + cost_community_ignore: true confederation: identifier: 42 peers: - 65020 - 65030 - 65040 - log_neighbor_changes: True + log_neighbor_changes: true maxas_limit: 20 neighbors: - neighbor_address: 192.168.1.100 @@ -4649,19 +4649,19 @@ Examples remote_as: 65563 description: NBR-1 low_memory: - exempt: True + exempt: true - neighbor_address: 192.168.1.101 remote_as: 65563 password: encryption: 7 key: 12090404011C03162E neighbor_down: - fib_accelerate: True + fib_accelerate: true vrfs: - vrf: site-1 allocate_index: 5000 local_as: 200 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 198.51.100.1 description: site-1-nbr-1 @@ -4674,7 +4674,7 @@ Examples description: site-1-nbr-2 - vrf: site-2 local_as: 300 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 203.0.113.2 description: site-2-nbr-1 @@ -4683,7 +4683,7 @@ Examples key: AF92F4C16A0A0EC5BDF56CF58BC030F6 remote_as: 65568 neighbor_down: - fib_accelerate: True + fib_accelerate: true # Task output: # ------------ @@ -4882,8 +4882,8 @@ Examples as_number: 65563 router_id: 192.168.1.1 bestpath: - compare_neighborid: True - cost_community_ignore: True + compare_neighborid: true + cost_community_ignore: true confederation: identifier: 42 peers: @@ -4899,20 +4899,20 @@ Examples remote_as: 65563 description: NBR-1 low_memory: - exempt: True + exempt: true neighbor_down: - fib_accelerate: True + fib_accelerate: true vrfs: - vrf: site-2 local_as: 300 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 203.0.113.2 password: encryption: 7 key: 12090404011C03162E neighbor_down: - fib_accelerate: True + fib_accelerate: true state: replaced # Task output: @@ -5345,16 +5345,16 @@ Examples router_id: 192.168.1.1 bestpath: as_path: - multipath_relax: True - compare_neighborid: True - cost_community_ignore: True + multipath_relax: true + compare_neighborid: true + cost_community_ignore: true confederation: identifier: 42 peers: - 65020 - 65030 - 65040 - log_neighbor_changes: True + log_neighbor_changes: true maxas_limit: 20 neighbors: - neighbor_address: 192.168.1.100 @@ -5364,19 +5364,19 @@ Examples remote_as: 65563 description: NBR-1 low_memory: - exempt: True + exempt: true - neighbor_address: 192.168.1.101 remote_as: 65563 password: encryption: 7 key: 12090404011C03162E neighbor_down: - fib_accelerate: True + fib_accelerate: true vrfs: - vrf: site-1 allocate_index: 5000 local_as: 200 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 198.51.100.1 description: site-1-nbr-1 @@ -5389,7 +5389,7 @@ Examples description: site-1-nbr-2 - vrf: site-2 local_as: 300 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 203.0.113.2 description: site-1-nbr-1 @@ -5398,7 +5398,7 @@ Examples key: AF92F4C16A0A0EC5BDF56CF58BC030F6 remote_as: 65568 neighbor_down: - fib_accelerate: True + fib_accelerate: true # Task output: # ------------ @@ -5648,7 +5648,7 @@ Examples as_number: 65536 router_id: 198.51.100.2 maxas_limit: 20 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 192.0.2.1 remote_as: 65537 @@ -5692,7 +5692,7 @@ Examples as_number: 65536 router_id: 198.51.100.2 maxas_limit: 20 - log_neighbor_changes: True + log_neighbor_changes: true neighbors: - neighbor_address: 192.0.2.1 remote_as: 65537 @@ -5702,7 +5702,7 @@ Examples vrfs: - vrf: site-2 neighbor_down: - fib_accelerate: True + fib_accelerate: true state: replaced # Task output: diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst index 96e3c5e53..8668a0b9f 100644 --- a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst +++ b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst @@ -2632,9 +2632,9 @@ Examples address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true - neighbor_address: 203.0.113.2 address_family: - afi: ipv6 @@ -2642,7 +2642,7 @@ Examples - afi: ipv4 safi: multicast send_community: - set: True + set: true # Task output: # ------------ @@ -2708,7 +2708,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast @@ -2797,7 +2797,7 @@ Examples - afi: ipv4 safi: multicast send_community: - set: True + set: true state: replaced # Task output: @@ -2840,7 +2840,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast # @@ -2887,7 +2887,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast @@ -2954,9 +2954,9 @@ Examples address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true state: overridden # Task output: @@ -2999,7 +2999,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast # @@ -3033,9 +3033,9 @@ Examples # address_family: # - afi: ipv4 # safi: unicast - # suppress_inactive: True + # suppress_inactive: true # next_hop_self: - # set: True + # set: true # After state: # ------------ @@ -3134,7 +3134,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast # @@ -3175,7 +3175,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # # After state: # ------------ @@ -3267,7 +3267,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast # @@ -3333,9 +3333,9 @@ Examples address_family: - afi: ipv4 safi: unicast - suppress_inactive: True + suppress_inactive: true next_hop_self: - set: True + set: true - neighbor_address: 203.0.113.2 address_family: - afi: ipv6 @@ -3343,7 +3343,7 @@ Examples - afi: ipv4 safi: multicast send_community: - set: True + set: true state: rendered # Task output: @@ -3441,7 +3441,7 @@ Examples # - afi: ipv4 # safi: multicast # send_community: - # set: True + # set: true # - afi: ipv6 # safi: unicast diff --git a/docs/cisco.nxos.nxos_command_module.rst b/docs/cisco.nxos.nxos_command_module.rst index e7fbbc048..4308a6582 100644 --- a/docs/cisco.nxos.nxos_command_module.rst +++ b/docs/cisco.nxos.nxos_command_module.rst @@ -153,31 +153,31 @@ Examples - name: run multiple commands on remote nodes cisco.nxos.nxos_command: commands: - - show version - - show interfaces + - show version + - show interfaces - name: run multiple commands and evaluate the output cisco.nxos.nxos_command: commands: - - show version - - show interfaces + - show version + - show interfaces wait_for: - - result[0] contains Cisco - - result[1] contains loopback0 + - result[0] contains Cisco + - result[1] contains loopback0 - name: run commands and specify the output format cisco.nxos.nxos_command: commands: - - command: show version - output: json + - command: show version + output: json - name: run commands that require answering a prompt cisco.nxos.nxos_command: commands: - - configure terminal - - command: no feature npv - prompt: Do you want to continue - answer: y + - configure terminal + - command: no feature npv + prompt: Do you want to continue + answer: y diff --git a/docs/cisco.nxos.nxos_config_module.rst b/docs/cisco.nxos.nxos_config_module.rst index 3d7b0cad1..3ead5ab50 100644 --- a/docs/cisco.nxos.nxos_config_module.rst +++ b/docs/cisco.nxos.nxos_config_module.rst @@ -380,21 +380,21 @@ Examples - cisco.nxos.nxos_config: lines: - - 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 - - 50 permit ip 192.0.2.5/32 any log + - 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 + - 50 permit ip 192.0.2.5/32 any log parents: ip access-list test before: no ip access-list test match: exact - cisco.nxos.nxos_config: lines: - - 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 + - 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 parents: ip access-list test before: no ip access-list test replace: block @@ -408,7 +408,7 @@ Examples cisco.nxos.nxos_config: lines: # - shut - - shutdown + - shutdown # parents: int eth1/1 parents: interface Ethernet1/1 diff --git a/docs/cisco.nxos.nxos_devicealias_module.rst b/docs/cisco.nxos.nxos_devicealias_module.rst index 9e33f93ea..081c8759f 100644 --- a/docs/cisco.nxos.nxos_devicealias_module.rst +++ b/docs/cisco.nxos.nxos_devicealias_module.rst @@ -212,21 +212,21 @@ Examples - name: Test that device alias module works cisco.nxos.nxos_devicealias: da: - - name: test1_add - pwwn: 56:2:22:11:22:88:11:67 - - name: test2_add - pwwn: 65:22:22:11:22:22:11:d - - name: dev1 - remove: true - - name: dev2 - remove: true + - name: test1_add + pwwn: 56:2:22:11:22:88:11:67 + - name: test2_add + pwwn: 65:22:22:11:22:22:11:d + - name: dev1 + remove: true + - name: dev2 + remove: true distribute: true mode: enhanced rename: - - new_name: bcd - old_name: abc - - new_name: bcd1 - old_name: abc1 + - new_name: bcd + old_name: abc + - new_name: bcd1 + old_name: abc1 diff --git a/docs/cisco.nxos.nxos_evpn_vni_module.rst b/docs/cisco.nxos.nxos_evpn_vni_module.rst index 714cd9c20..530a9ff18 100644 --- a/docs/cisco.nxos.nxos_evpn_vni_module.rst +++ b/docs/cisco.nxos.nxos_evpn_vni_module.rst @@ -162,8 +162,8 @@ Examples vni: 6000 route_distinguisher: 60:10 route_target_import: - - 5000:10 - - 4100:100 + - "5000:10" + - "4100:100" route_target_export: auto route_target_both: default diff --git a/docs/cisco.nxos.nxos_facts_module.rst b/docs/cisco.nxos.nxos_facts_module.rst index 0e344b470..3ce96abea 100644 --- a/docs/cisco.nxos.nxos_facts_module.rst +++ b/docs/cisco.nxos.nxos_facts_module.rst @@ -113,11 +113,11 @@ Examples - name: Gather only the config and default facts cisco.nxos.nxos_facts: gather_subset: - - config + - config - name: Do not gather hardware facts cisco.nxos.nxos_facts: gather_subset: - - '!hardware' + - '!hardware' - name: Gather legacy and resource facts cisco.nxos.nxos_facts: gather_subset: all @@ -125,10 +125,10 @@ Examples - name: Gather only the interfaces resource facts and no legacy facts cisco.nxos.nxos_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces + - interfaces - name: Gather interfaces resource and minimal legacy facts cisco.nxos.nxos_facts: gather_subset: min diff --git a/docs/cisco.nxos.nxos_fc_interfaces_module.rst b/docs/cisco.nxos.nxos_fc_interfaces_module.rst index eaad900f2..048ddc0f0 100644 --- a/docs/cisco.nxos.nxos_fc_interfaces_module.rst +++ b/docs/cisco.nxos.nxos_fc_interfaces_module.rst @@ -103,7 +103,7 @@ Parameters
    -
    Administrative state of the interface. Set the value to true to administratively enable the interface or false to disable it
    +
    Administrative state of the interface. Set the value to true to administratively enable the interface or true to disable it