Skip to content

Commit

Permalink
Update acl_facts to render data correctly (#521)
Browse files Browse the repository at this point in the history
* Update acl_facts to render data correctly

* add tests

* correct the idempotency

---------

Co-authored-by: Ruchi Pakhle <[email protected]>
  • Loading branch information
sean-m-sullivan and Ruchip16 authored Oct 28, 2024
1 parent 6ba5a52 commit 0a9581f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/acl_facts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- iosxr_acls facts - Fix incorrect rendering of some acl facts causing errors.
6 changes: 5 additions & 1 deletion plugins/module_utils/network/iosxr/facts/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,13 @@ def _parse_match_options(rendered_ace, ace_queue):
# In this case, we add the whole unprocessed ACE
# to a key called `line` and send it back
if len(ace_queue) > 0:
for x in split_ace[1:]:
m1 = re.match(r"\(\d", x)
m2 = re.match(r"\w+\)", x)
if m1 or m2:
split_ace.remove(x)
rendered_ace = {
"sequence": sequence,
"line": " ".join(split_ace[1:]),
}

return utils.remove_empties(rendered_ace)
13 changes: 13 additions & 0 deletions tests/integration/targets/iosxr_acls/tests/cli/replaced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
destination:
any: true
protocol: icmp

- sequence: 40
remark: "Deny MARTIANS"

- sequence: 60
grant: deny
protocol: ipv4
source:
address: 10.0.0.0
wildcard_bits: 0.255.255.255
destination:
any: true

state: replaced

- name: Assert that correct set of commands were generated
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/targets/iosxr_acls/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ replaced:
- no 10
- 11 permit igmp host 198.51.100.130 any ttl eq 100
- 12 deny icmp any any
- 40 remark Deny MARTIANS
- 60 deny ipv4 10.0.0.0 0.255.255.255 any
after:
- acls:
- aces:
Expand Down Expand Up @@ -145,6 +147,16 @@ replaced:
sequence: 12
source:
any: true
- remark: Deny MARTIANS
sequence: 40
- destination:
any: true
grant: deny
protocol: ipv4
sequence: 60
source:
address: 10.0.0.0
wildcard_bits: 0.255.255.255
name: acl_2
afi: ipv4
- acls:
Expand Down

0 comments on commit 0a9581f

Please sign in to comment.