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

Bug(eos_acls): improve condition to not always convert port numbers to IANA assigned names #432

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

Conversation

noredistribution
Copy link

SUMMARY

Fixes #431

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

eos_acls

ADDITIONAL INFORMATION

Example playbook:

- hosts: 10.83.13.214
  gather_facts: no
  vars:
    acls:
    - acls:
      - aces:
        - destination:
            host: 192.168.150.1
          grant: permit
          log: true
          protocol: tcp
          sequence: 15
          source:
            host: 192.168.1.1
            port_protocol:
              eq: '8082'
        name: acl-test
      afi: ipv4

  tasks:
    - name: Push acls to device
      arista.eos.eos_acls:
        state: replaced
        config: "{{ acls }}"

Before the change:

TASK [Push acls to device] ************************************************************************************
Saturday 12 August 2023  01:53:47 +0100 (0:00:00.134)       0:00:00.134 *******
fatal: [10.83.13.214]: FAILED! => changed=false
  module_stderr: 'Invalid input (at token 6: ''us-cli'')'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error

After the change:

TASK [Push acls to device] ************************************************************************************************************
Saturday 12 August 2023  02:06:29 +0100 (0:00:00.114)       0:00:00.114 *******
changed: [10.83.13.214]

PLAY RECAP ****************************************************************************************************************************
10.83.13.214               : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/0250eae185a74cbf89394cdb3dab3036

✔️ ansible-test-network-integration-eos-httpapi-python39-stable214 SUCCESS in 39m 21s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable213 SUCCESS in 35m 58s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable212 SUCCESS in 36m 47s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable211 SUCCESS in 35m 35s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 32m 48s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 FAILURE in 32m 32s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 35m 38s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 FAILURE in 33m 34s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 33m 40s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 FAILURE in 32m 14s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 32m 16s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 FAILURE in 38m 27s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 32m 39s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 FAILURE in 31m 23s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 31m 22s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 FAILURE in 32m 36s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 SUCCESS in 32m 44s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 FAILURE in 37m 41s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 SUCCESS in 30m 46s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 FAILURE in 32m 27s (non-voting)
✔️ build-ansible-collection SUCCESS in 9m 30s
ansible-tox-linters FAILURE in 11m 40s
✔️ ansible-galaxy-importer SUCCESS in 5m 01s

Comment on lines 529 to 530
for op, val in ace["source"]["port_protocol"].items():
if val.isdigit():
val = socket.getservbyport(int(val))
command = command + " " + op + " " + val.replace("_", "-")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing the translation completely, could we keep a list of EOS implemented names as a constant? If the translated name is in the list we keep it, and if not revert to the original value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good idea, I will have to check if that list has ever changed first, otherwise that would add a dependency on EOS versions, which I'm not sure if this collection deals with yet

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it looks like we had various changes along the years so it wouldn't be a trivial change to make, however if users want to use names instead of numbers they could just use names in the yaml input right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upon further investigation I've found out that we have a base list of port numbers that has been there since day 1 and added all those in a list as a constant and validate if the value is a digit and part of our base list then it can do the translation otherwise it can't, tested on 4.22.4 and 4.30.1

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (4d3dcde) 82.71% compared to head (66132f1) 82.72%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #432   +/-   ##
=======================================
  Coverage   82.71%   82.72%           
=======================================
  Files         153      154    +1     
  Lines       11950    11955    +5     
=======================================
+ Hits         9885     9890    +5     
  Misses       2065     2065           

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/90a61c6f7c844e12bbb968fa6df1266b

✔️ ansible-test-network-integration-eos-httpapi-python39-stable214 SUCCESS in 38m 16s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable213 SUCCESS in 35m 23s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable212 SUCCESS in 36m 52s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable211 SUCCESS in 37m 42s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 31m 21s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 SUCCESS in 33m 24s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 32m 33s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 SUCCESS in 33m 48s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 31m 26s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 SUCCESS in 33m 13s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 31m 37s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 SUCCESS in 32m 51s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 31m 38s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 SUCCESS in 40m 32s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 31m 27s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 SUCCESS in 42m 55s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 SUCCESS in 31m 26s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 SUCCESS in 41m 02s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 SUCCESS in 32m 19s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 SUCCESS in 40m 53s (non-voting)
✔️ build-ansible-collection SUCCESS in 9m 40s
ansible-tox-linters FAILURE in 11m 49s
✔️ ansible-galaxy-importer SUCCESS in 3m 25s

…ive hints about it in another file + add a more meaningful docstring
@noredistribution noredistribution changed the title Fix(eos_acls): remove condition to always convert port numbers to IANA assigned names Bug(eos_acls): improve condition to not always convert port numbers to IANA assigned names Aug 15, 2023
@noredistribution
Copy link
Author

can someone from the maintainers add bug as a label for the ack test to pass? looks like contributors cannot set the labels. thx!

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/492a5fbe97a4413ea8f1f6e521e8ac89

✔️ ansible-test-network-integration-eos-httpapi-python39-stable214 SUCCESS in 44m 04s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable213 SUCCESS in 39m 46s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable212 SUCCESS in 39m 35s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable211 SUCCESS in 36m 20s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 32m 57s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 SUCCESS in 38m 21s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 32m 10s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 SUCCESS in 33m 17s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 31m 15s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 SUCCESS in 39m 30s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 32m 05s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 SUCCESS in 33m 55s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 36m 40s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 SUCCESS in 39m 30s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 36m 02s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 SUCCESS in 37m 10s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 SUCCESS in 36m 44s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 SUCCESS in 38m 33s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 SUCCESS in 36m 47s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 SUCCESS in 38m 24s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 52s
ansible-tox-linters FAILURE in 10m 44s
✔️ ansible-galaxy-importer SUCCESS in 4m 35s

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/283409ed4cc94dc798cb63273b8f9b35

✔️ ansible-test-network-integration-eos-httpapi-python39-stable214 SUCCESS in 40m 20s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable213 SUCCESS in 36m 12s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable212 SUCCESS in 40m 47s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable211 SUCCESS in 36m 57s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 37m 52s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 SUCCESS in 33m 59s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 39m 01s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 SUCCESS in 40m 08s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 32m 55s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 SUCCESS in 34m 32s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 32m 18s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 SUCCESS in 39m 35s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 32m 46s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 SUCCESS in 39m 53s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 32m 22s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 SUCCESS in 41m 48s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 SUCCESS in 31m 16s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 SUCCESS in 39m 57s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 SUCCESS in 31m 32s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 SUCCESS in 39m 05s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 39s
ansible-tox-linters FAILURE in 11m 09s
✔️ ansible-galaxy-importer SUCCESS in 5m 45s

@softwarefactory-project-zuul
Copy link

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

✔️ ansible-test-network-integration-eos-httpapi-python39-stable214 SUCCESS in 39m 38s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable213 SUCCESS in 35m 01s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable212 SUCCESS in 35m 02s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable211 SUCCESS in 34m 38s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 30m 50s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 SUCCESS in 33m 52s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 31m 38s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 SUCCESS in 33m 25s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 32m 52s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 SUCCESS in 32m 59s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 31m 25s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 SUCCESS in 32m 35s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 36m 28s (non-voting)
ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 POST_FAILURE in 33m 45s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 31m 16s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 SUCCESS in 32m 58s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 SUCCESS in 36m 18s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 SUCCESS in 33m 04s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 POST_FAILURE in 31m 34s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 SUCCESS in 37m 18s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 40s
✔️ ansible-tox-linters SUCCESS in 10m 41s
✔️ ansible-galaxy-importer SUCCESS in 5m 20s

Copy link
Contributor

@rohitthakur2590 rohitthakur2590 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noredistribution Thank you for the contribution, I have added a comment, Could you please also add a changelog for this?


__metaclass__ = type

PORT_NUMBERS = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitthakur2590 rohitthakur2590 temporarily deployed to ack October 9, 2023 11:58 — with GitHub Actions Inactive
@softwarefactory-project-zuul
Copy link

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

✔️ ansible-test-network-integration-eos-httpapi-python39-stable215 SUCCESS in 46m 44s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable214 SUCCESS in 46m 11s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable213 SUCCESS in 41m 36s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable212 SUCCESS in 40m 22s
✔️ ansible-test-network-integration-eos-httpapi-python39-stable211 SUCCESS in 42m 09s
✔️ ansible-test-network-integration-eos-network_cli-python39-stable215-scenario01 SUCCESS in 37m 27s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable215-scenario02 SUCCESS in 39m 28s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable215-scenario01 SUCCESS in 37m 07s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable215-scenario02 SUCCESS in 39m 32s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario01 SUCCESS in 36m 17s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable214-scenario02 SUCCESS in 40m 42s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario01 SUCCESS in 32m 33s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable214-scenario02 SUCCESS in 39m 30s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario01 SUCCESS in 36m 11s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable213-scenario02 SUCCESS in 33m 17s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario01 SUCCESS in 36m 12s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable213-scenario02 SUCCESS in 38m 09s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario01 SUCCESS in 35m 53s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable212-scenario02 SUCCESS in 39m 59s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario01 SUCCESS in 36m 07s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable212-scenario02 SUCCESS in 33m 47s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario01 SUCCESS in 36m 41s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39-stable211-scenario02 SUCCESS in 33m 30s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario01 SUCCESS in 36m 49s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39-stable211-scenario02 SUCCESS in 33m 47s (non-voting)
✔️ build-ansible-collection SUCCESS in 8m 39s
✔️ ansible-tox-linters SUCCESS in 10m 38s
✔️ ansible-galaxy-importer SUCCESS in 5m 05s

@TheRealBecks
Copy link
Contributor

@noredistribution Looks like this merge in stuck due to the missing changelog?

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.

Bug(eos_acls): tcp/udp port name resolution breaks pushing ACL changes to EOS
5 participants