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

ios_acls: Fix module failure when ARP ACLs are present on device #1131

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/fix_acl_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ios_acls - Fix get_acl_data attribute to resolve parsing errors caused by ARP ACL presence.
2 changes: 1 addition & 1 deletion plugins/module_utils/network/ios/facts/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, module):
def get_acl_data(self, connection):
# Removed the show access-list
# Removed the show running-config | include ip(v6)* access-list|remark
return connection.get("show running-config | section access-list")
return connection.get("show running-config | section 'ip[v6]* access-list'")

def get_acl_names(self, connection):
# this information is required to scoop out the access lists which has no aces
Expand Down
56 changes: 56 additions & 0 deletions tests/unit/modules/network/ios/test_ios_acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2303,3 +2303,59 @@ def test_ios_acls_overridden_remarks_complex(self):
"no ip access-list extended test_acl",
]
self.assertEqual(sorted(result["commands"]), sorted(commands))

def test_ios_acls_with_arp_acl(self):
self.execute_show_command.return_value = dedent(
"""\
ip access-list standard 10
10 permit 192.168.1.0 0.0.0.255
arp access-list arp-test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we please add a integration test where we add a prepare test to add arp access-list and then gather facts so that we are sure with an appliance too that the facts are handled correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure will do it thanks

permit ip any mac any
ip access-list extended ext_acl
10 permit ip 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255
""",
)
self.execute_show_command_name.return_value = dedent(
"""\
Standard IP access list 10
Extended IP access list ext_acl
""",
)

set_module_args(
dict(
config=[
dict(
afi="ipv4",
acls=[
dict(
name="test_ext_acl",
acl_type="extended",
aces=[
dict(
grant="permit",
protocol="ip",
source=dict(
address="192.0.2.0",
wildcard_bits="0.0.0.255",
),
destination=dict(
address="192.0.3.0",
wildcard_bits="0.0.0.255",
),
),
],
),
],
),
],
state="merged",
),
)

result = self.execute_module(changed=True)
commands = [
"ip access-list extended test_ext_acl",
"permit ip 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255",
]
self.assertEqual(sorted(result["commands"]), sorted(commands))
Loading