Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow managment of security-zone address books with only one element #450

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sboyd-m
Copy link

@sboyd-m sboyd-m commented Sep 27, 2023

SUMMARY

Allow managment of security-zone address books with only one element

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

junos.junos_security_zones

ADDITIONAL INFORMATION

This is simply following a common pattern whereby single elements returned in xml are converted to arrays, such that the code can assume it is in fact an array.

Unfortunately the resulting output is sensitive, but here is the redacted error:

The full traceback is:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py", line 135, in get_network_resources_facts
    inst.populate_facts(
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ansible_collections/junipernetworks/junos/plugins/module_utils/network/junos/facts/security_zones/security_zones.py", line 110, in populate_facts
    objs = self.render_config(self.generated_spec, xml)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ansible_collections/junipernetworks/junos/plugins/module_utils/network/junos/facts/security_zones/security_zones.py", line 231, in render_config
    temp_address_set["name"] = address_set["name"]
fatal: [host.sohonet.dcn]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "config": {
                "functional_zone_management": null,
                "zones": [
                    {
                        "address_book": {
                            "address_sets": [
                                {
                                    "address_sets": null,
                                    "addresses": [
                                        "203.0.113.0"
                                    ],
                                    "description": null,
                                    "name": "really-good-name"
                                }
                            ],
                            "addresses": null
                        },
                        "advance_policy_based_routing_profile": null,
                        "advanced_connection_tracking": null,
                        "application_tracking": null,
                        "description": null,
                        "enable_reverse_reroute": null,
                        "host_inbound_traffic": null,
                        "interfaces": null,
                        "name": "UNTRUST",
                        "screen": null,
                        "source_identity_log": null,
                        "tcp_rst": null,
                        "unidirectional_session_refreshing": null
                    }
                ]
            },
            "running_config": null,
            "state": "merged"
        }
    },
    "msg": "string indices must be integers"
}

@sboyd-m sboyd-m temporarily deployed to ack September 27, 2023 21:11 — with GitHub Actions Inactive
@sboyd-m sboyd-m temporarily deployed to ack September 27, 2023 21:24 — with GitHub Actions Inactive
@sboyd-m sboyd-m temporarily deployed to ack September 27, 2023 21:26 — with GitHub Actions Inactive
@softwarefactory-project-zuul
Copy link

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/26d5dbdae6c04b78b8f5b4252bbb2c4f

ansible-test-network-integration-junos-vsrx-netconf-python39 RETRY_LIMIT in 10m 14s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 17m 54s (non-voting)
ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 NODE_FAILURE Node request 200-0006435117 failed in 0s (non-voting)
ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 RETRY_LIMIT in 9m 39s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python39 RETRY_LIMIT in 12m 59s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 15m 56s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 RETRY_LIMIT in 3m 13s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 RETRY_LIMIT in 3m 50s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 RETRY_LIMIT in 10m 27s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 SUCCESS in 14m 59s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 16m 27s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 17m 00s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable215 SUCCESS in 1h 05m 31s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable215 SUCCESS in 16m 08s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable215 FAILURE in 22m 16s (non-voting)
ansible-test-network-integration-junos-vsrx-netconf-python39-stable214 RETRY_LIMIT in 9m 57s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable214 SUCCESS in 15m 43s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable214 RETRY_LIMIT in 9m 10s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 36s
✔️ ansible-tox-linters SUCCESS in 10m 53s
✔️ ansible-galaxy-importer SUCCESS in 4m 49s

@rohitthakur2590
Copy link
Collaborator

@sboyd-m Thank you for your valuable contribution,
Could you please add a changelog and tests.

Copy link

Label error. Requires exactly 1 of: bug, enhancement, major, minor, patch, skip-changelog. Found:

Copy link

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/7f9d4d94b1214a8c924fb06bc5dd46b8

ansible-test-network-integration-junos-vsrx-netconf-python39 RETRY_LIMIT in 9m 25s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 13m 43s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 02m 42s (non-voting)
ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 11m 48s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python39 RETRY_LIMIT in 8m 03s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 14m 38s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 15m 52s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 11m 44s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 RETRY_LIMIT in 6m 07s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 SUCCESS in 14m 13s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 12m 41s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 15m 55s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable215 SUCCESS in 1h 05m 15s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable215 SUCCESS in 15m 42s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable215 SUCCESS in 14m 38s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable214 SUCCESS in 1h 05m 02s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable214 SUCCESS in 15m 02s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable214 SUCCESS in 15m 29s (non-voting)
✔️ build-ansible-collection SUCCESS in 9m 43s
✔️ ansible-tox-linters SUCCESS in 11m 53s
✔️ ansible-galaxy-importer SUCCESS in 5m 06s

@sboyd-m
Copy link
Author

sboyd-m commented Jan 2, 2024

@rohitthakur2590 I am unable to run tests locally, and so cannot add any. I have pushed a changelog, however.

Copy link

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/c0168b9febd3493bb4c9b2e6d195d91f

ansible-test-network-integration-junos-vsrx-netconf-python39 RETRY_LIMIT in 9m 33s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 14m 53s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 02m 49s (non-voting)
ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 11m 39s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python39 RETRY_LIMIT in 6m 32s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 14m 40s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 15m 51s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 12m 00s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 RETRY_LIMIT in 7m 08s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 SUCCESS in 14m 29s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 14m 47s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 15m 44s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable215 SUCCESS in 1h 06m 55s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable215 SUCCESS in 16m 21s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable215 FAILURE in 13m 08s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable214 SUCCESS in 1h 04m 57s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable214 SUCCESS in 15m 42s (non-voting)
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable214 FAILURE in 12m 53s (non-voting)
✔️ build-ansible-collection SUCCESS in 9m 54s
✔️ ansible-tox-linters SUCCESS in 11m 48s
✔️ ansible-galaxy-importer SUCCESS in 4m 01s

@ArjenB96
Copy link

ArjenB96 commented Oct 7, 2024

@rohitthakur2590 Possible to get this added? What kind of test would it require? The affected component has a fix, as shown in this PR, that is used very often in the codebase (even in the same file). A bit silly that this has been untouched for over 9 months.

Took me some hours debugging, but I got to the same exact solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants