From abed08a8165d5f3647e1075efe37693a5894357a Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Wed, 28 Aug 2024 04:56:18 -0400 Subject: [PATCH 1/4] Fixes Resource module cisco.nxos.nxos_acls is not correctly converting the ports under port_protocol range keys (#888) * bugfix/acl port protocol lookup for range start and end * Create bugfix_vrf_range_resolution.yml Create Changelog Fragment * chore: auto fixes from pre-commit.com hooks * updates * chore: auto fixes from pre-commit.com hooks * add unit test case * chore: auto fixes from pre-commit.com hooks * update test * allow non-numeric values to pass through as strings * chore: auto fixes from pre-commit.com hooks * allow non-numeric values to pass through as strings * chore: auto fixes from pre-commit.com hooks * fix test * chore: auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sagar Paul Co-authored-by: Ruchi Pakhle --- .../fragments/bugfix_vrf_range_resolution.yml | 3 ++ .../network/nxos/config/acls/acls.py | 34 ++++++++++------ .../modules/network/nxos/test_nxos_acls.py | 39 +++++++++++++++++++ 3 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 changelogs/fragments/bugfix_vrf_range_resolution.yml diff --git a/changelogs/fragments/bugfix_vrf_range_resolution.yml b/changelogs/fragments/bugfix_vrf_range_resolution.yml new file mode 100644 index 000000000..ca0106ce5 --- /dev/null +++ b/changelogs/fragments/bugfix_vrf_range_resolution.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "acls - Fix lookup of range port conversion from int to string to allow strings (https://github.com/ansible-collections/cisco.nxos/pull/888)." diff --git a/plugins/module_utils/network/nxos/config/acls/acls.py b/plugins/module_utils/network/nxos/config/acls/acls.py index a62489b28..14462f45d 100644 --- a/plugins/module_utils/network/nxos/config/acls/acls.py +++ b/plugins/module_utils/network/nxos/config/acls/acls.py @@ -242,17 +242,29 @@ def convert_values(self, want): int(val) ] else: - 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] - ) - if end in port_protocol.keys(): - ace[x]["port_protocol"]["range"]["end"] = ( - port_protocol[end] - ) + st = ace[x]["port_protocol"]["range"]["start"] + end = ace[x]["port_protocol"]["range"]["end"] + + if st.isdigit(): + if int(st) in port_protocol.keys(): + ace[x]["port_protocol"]["range"]["start"] = ( + port_protocol[int(st)] + ) + else: + if st in port_protocol.keys(): + ace[x]["port_protocol"]["range"]["start"] = ( + port_protocol[st] + ) + if end.isdigit(): + if int(end) in port_protocol.keys(): + ace[x]["port_protocol"]["range"]["end"] = ( + port_protocol[int(end)] + ) + else: + if end in port_protocol.keys(): + ace[x]["port_protocol"]["range"]["end"] = ( + port_protocol[end] + ) return want def set_state(self, want, have): diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index de3595cef..b473d82a9 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -990,3 +990,42 @@ def test_nxos_acls_ranges(self): ] result = self.execute_module(changed=False) self.assertEqual(result["gathered"], gathered) + + def test_nxos_acls_protocol_conversion(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="SIPS_Automation_Test_ACL_Create", + aces=[ + dict( + sequence=17, + grant="permit", + protocol="tcp", + source=dict(any=True), + destination=dict( + prefix="10.247.12.0/24", + port_protocol=dict( + range=dict( + start="ftp-data", + end=23, + ), + ), + ), + ), + ], + ), + ], + ), + ], + state="merged", + ), + ) + commands = [ + "ip access-list SIPS_Automation_Test_ACL_Create", + "17 permit tcp any 10.247.12.0/24 range ftp-data telnet", + ] + self.execute_module(changed=True, commands=commands) From d9f600c747194d25d63305e8f65f25d80b930c65 Mon Sep 17 00:00:00 2001 From: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:35:18 +0530 Subject: [PATCH 2/4] Add a support section in README (#891) * Add a support section in README * chore: auto fixes from pre-commit.com hooks * review changes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- README.md | 10 ++++++++++ changelogs/fragments/readme.yaml | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 changelogs/fragments/readme.yaml diff --git a/README.md b/README.md index be344d853..a11a7450d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,16 @@ The Cisco NX-OS connection plugins combined with Cisco NX-OS resource modules al This collection has been tested against Cisco N9K-C9300v chassis running NX-OS 9.3.6. The modules with full support for Cisco MDS are tested against NX-OS 8.4(1) on MDS Switches. +## Support + +As a Red Hat Ansible [Certified Content](https://catalog.redhat.com/software/search?target_platforms=Red%20Hat%20Ansible%20Automation%20Platform), this collection is entitled to [support](https://access.redhat.com/support/) through [Ansible Automation Platform](https://www.redhat.com/en/technologies/management/ansible) (AAP). + +If a support case cannot be opened with Red Hat and the collection has been obtained either from [Galaxy](https://galaxy.ansible.com/ui/) or [GitHub](https://github.com/ansible-collections/cisco.nxos), there is community support available at no charge. + +You can join us on [#network:ansible.com](https://matrix.to/#/#network:ansible.com) room or the [Ansible Forum Network Working Group](https://forum.ansible.com/g/network-wg). + +For more information you can check the communication section below. + ## Communication * Join the Ansible forum: diff --git a/changelogs/fragments/readme.yaml b/changelogs/fragments/readme.yaml new file mode 100644 index 000000000..754cf19c4 --- /dev/null +++ b/changelogs/fragments/readme.yaml @@ -0,0 +1,3 @@ +--- +doc_changes: + - "Includes a new support related section in the README." From ce0fd93667b860fb82bc3391bc4f613b31710586 Mon Sep 17 00:00:00 2001 From: Vinay M <63404819+roverflow@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:54:30 +0530 Subject: [PATCH 3/4] Handle Empty LLDP Neighbor Information in facts (#889) * Handle Empty LLDP Neighbor Information in facts * chore: auto fixes from pre-commit.com hooks * used try catch block * chore: auto fixes from pre-commit.com hooks * fix sanity * chore: auto fixes from pre-commit.com hooks * change exception type * Move the try except block closer to where the keyerror originates * chore: auto fixes from pre-commit.com hooks * fix empty spaces * narrowed down the keyError more * chore: auto fixes from pre-commit.com hooks * remove comment --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com> --- changelogs/fragments/lldp_facts.yaml | 3 +++ plugins/module_utils/network/nxos/facts/legacy/base.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/lldp_facts.yaml diff --git a/changelogs/fragments/lldp_facts.yaml b/changelogs/fragments/lldp_facts.yaml new file mode 100644 index 000000000..89d940a0f --- /dev/null +++ b/changelogs/fragments/lldp_facts.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - facts - Fixes issue where the LLDP neighbor information returns an error when empty. diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index a3a453784..aa39ea734 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -342,7 +342,12 @@ def populate_structured_ipv6_interfaces(self, data): def populate_structured_neighbors_lldp(self, data): objects = dict() - data = data["TABLE_nbor"]["ROW_nbor"] + try: + data = data["TABLE_nbor"]["ROW_nbor"] + except KeyError: + return ( + objects # No neighbors found as the TABLE_nbor key is missing and return empty dict + ) if isinstance(data, dict): data = [data] From 5f59da70bb02fbdf6397a5f69d1fec00544c4863 Mon Sep 17 00:00:00 2001 From: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:18:59 +0530 Subject: [PATCH 4/4] Prepare release v9.2.1 (#892) * Prepare release 9.2.1 * chore: auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.rst | 14 ++++++++++++++ changelogs/changelog.yaml | 14 ++++++++++++++ .../fragments/bugfix_vrf_range_resolution.yml | 3 --- changelogs/fragments/lldp_facts.yaml | 3 --- changelogs/fragments/readme.yaml | 3 --- galaxy.yml | 2 +- 6 files changed, 29 insertions(+), 10 deletions(-) delete mode 100644 changelogs/fragments/bugfix_vrf_range_resolution.yml delete mode 100644 changelogs/fragments/lldp_facts.yaml delete mode 100644 changelogs/fragments/readme.yaml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c410b7bde..dda913ca5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,20 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v9.2.1 +====== + +Bugfixes +-------- + +- acls - Fix lookup of range port conversion from int to string to allow strings (https://github.com/ansible-collections/cisco.nxos/pull/888). +- facts - Fixes issue where the LLDP neighbor information returns an error when empty. + +Documentation Changes +--------------------- + +- Includes a new support related section in the README. + v9.2.0 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index a4cf490dd..9d2e83b53 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1221,3 +1221,17 @@ releases: - fix_local_as.yaml - fix_pylint.yaml release_date: "2024-08-19" + 9.2.1: + changes: + bugfixes: + - acls - Fix lookup of range port conversion from int to string to allow strings + (https://github.com/ansible-collections/cisco.nxos/pull/888). + - facts - Fixes issue where the LLDP neighbor information returns an error when + empty. + doc_changes: + - Includes a new support related section in the README. + fragments: + - bugfix_vrf_range_resolution.yml + - lldp_facts.yaml + - readme.yaml + release_date: "2024-08-29" diff --git a/changelogs/fragments/bugfix_vrf_range_resolution.yml b/changelogs/fragments/bugfix_vrf_range_resolution.yml deleted file mode 100644 index ca0106ce5..000000000 --- a/changelogs/fragments/bugfix_vrf_range_resolution.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "acls - Fix lookup of range port conversion from int to string to allow strings (https://github.com/ansible-collections/cisco.nxos/pull/888)." diff --git a/changelogs/fragments/lldp_facts.yaml b/changelogs/fragments/lldp_facts.yaml deleted file mode 100644 index 89d940a0f..000000000 --- a/changelogs/fragments/lldp_facts.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - facts - Fixes issue where the LLDP neighbor information returns an error when empty. diff --git a/changelogs/fragments/readme.yaml b/changelogs/fragments/readme.yaml deleted file mode 100644 index 754cf19c4..000000000 --- a/changelogs/fragments/readme.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -doc_changes: - - "Includes a new support related section in the README." diff --git a/galaxy.yml b/galaxy.yml index 743f6df6f..494fdf171 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: 9.2.0 +version: 9.2.1