Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 25, 2024
1 parent 87cda46 commit 32f2bc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
41 changes: 15 additions & 26 deletions plugins/module_utils/network/ios/config/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
dict_merge,
)

from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import (
Facts,
)
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import Facts
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.rm_templates.acls import (
AclsTemplate,
)
Expand Down Expand Up @@ -85,9 +83,7 @@ def generate_commands(self):
wplists = wvalue.get("acls", {})
hplists = hvalue.get("acls", {})
hvalue["acls"] = {
k: v
for k, v in iteritems(hplists)
if k in wplists or not wplists
k: v for k, v in iteritems(hplists) if k in wplists or not wplists
}

# remove superfluous config for overridden and deleted
Expand Down Expand Up @@ -122,9 +118,7 @@ def rearrange_cmds(aces):
hplists = have.get("acls", {})
for wname, wentry in iteritems(wplists):
hentry = hplists.pop(wname, {})
acl_type = (
wentry["acl_type"] if wentry.get("acl_type") else hentry.get("acl_type")
)
acl_type = wentry["acl_type"] if wentry.get("acl_type") else hentry.get("acl_type")
# If ACLs type is different between existing and wanted ACL, we need first remove it
if acl_type != hentry.get("acl_type", acl_type):
self.commands.append(
Expand Down Expand Up @@ -247,7 +241,7 @@ def pop_remark(r_entry, afi):
# add ace if not in have
if hentry != wentry:
if len(wentry) == 1 and wentry.get(
"sequence"
"sequence",
): # if the ace entry just has sequence then do nothing
continue
else: # add normal ace entries from want
Expand Down Expand Up @@ -326,25 +320,20 @@ def list_to_dict(self, param):
.get("range")
):
for k, v in (
ace.get("destination", {})
.get("port_protocol", {})
.items()
ace.get("destination", {}).get("port_protocol", {}).items()
):
ace["destination"]["port_protocol"][k] = (
self.port_protocl_no_to_protocol(v)
)
ace["destination"]["port_protocol"][
k
] = self.port_protocl_no_to_protocol(v)
if acl.get("acl_type") == "standard":
for ks in list(ace.keys()):
if (
ks
not in [
"sequence",
"grant",
"source",
"remarks",
"log",
]
): # failing for mutually exclusive standard acl key
if ks not in [
"sequence",
"grant",
"source",
"remarks",
"log",
]: # failing for mutually exclusive standard acl key
self._module.fail_json(
"Unsupported attribute for standard ACL - {0}.".format(
ks,
Expand Down
14 changes: 5 additions & 9 deletions tests/unit/modules/network/ios/test_ios_acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def setUp(self):
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base."
"get_resource_connection",
)
self.get_resource_connection_facts = (
self.mock_get_resource_connection_facts.start()
)
self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()

self.mock_execute_show_command = patch(
"ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.acls.acls."
Expand All @@ -40,9 +38,7 @@ def setUp(self):
"ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.acls.acls."
"AclsFacts.get_acl_names",
)
self.execute_show_command_name = (
self.mock_execute_show_command_name_specific.start()
)
self.execute_show_command_name = self.mock_execute_show_command_name_specific.start()

def tearDown(self):
super(TestIosAclsModule, self).tearDown()
Expand Down Expand Up @@ -2238,12 +2234,12 @@ def test_ios_acls_overridden_remarks_complex(self):
"Remark not specific to sequence",
"============",
"End Remarks 1",
]
],
},
],
}
},
],
}
},
],
state="overridden",
),
Expand Down

0 comments on commit 32f2bc7

Please sign in to comment.