Skip to content

Commit

Permalink
[cml] fix integration tests (#839)
Browse files Browse the repository at this point in the history
* dnm

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* dnm

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

* cleanup loopback interface

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

---------

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
  • Loading branch information
NilashishC committed Mar 28, 2024
1 parent 31d8e06 commit d6d55e5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
necessary to bring the current configuration to it's desired end-state is
created
"""

from __future__ import absolute_import, division, print_function


Expand Down Expand Up @@ -120,7 +121,7 @@ def set_config(self, existing_acl_interfaces_facts):
for w in config:
if get_interface_type(w["name"]) == "loopback":
self._module.fail_json(
msg="This module works with ethernet, management or port-channe",
msg="This module works with ethernet, management or port-channel.",
)
w.update({"name": normalize_interface(w["name"])})
want.append(remove_empties(w))
Expand All @@ -139,7 +140,9 @@ def set_state(self, want, have):
"""
if self.state in ("overridden", "merged", "replaced", "rendered") and not want:
self._module.fail_json(
msg="value of config parameter must not be empty for state {0}".format(self.state),
msg="value of config parameter must not be empty for state {0}".format(
self.state,
),
)

commands = []
Expand Down Expand Up @@ -185,7 +188,11 @@ def _state_replaced(self, want, have):
for ag in obj_in_have["access_groups"]:
want_afi = []
if want.get("access_groups"):
want_afi = search_obj_in_list(ag["afi"], want["access_groups"], "afi")
want_afi = search_obj_in_list(
ag["afi"],
want["access_groups"],
"afi",
)
if not want_afi:
# whatever in have is not in want
del_dict["access_groups"].append(ag)
Expand Down Expand Up @@ -241,7 +248,11 @@ def set_commands(self, want, have, deleted=False):
ip = "ipv6"
if w_afi["afi"] == "ipv4":
ip = "ip"
have_afi = search_obj_in_list(w_afi["afi"], have_name["access_groups"], "afi")
have_afi = search_obj_in_list(
w_afi["afi"],
have_name["access_groups"],
"afi",
)
if have_afi:
new_acls = []
if deleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- name: Remove configuration - 3
cisco.nxos.nxos_config:
lines:
- no switchport
- no ip access-group ACL1v4 out
parents: interface Ethernet1/3
ignore_errors: true
Expand All @@ -41,3 +42,8 @@
- no ip port access-group PortACL in
parents: interface Ethernet1/6
ignore_errors: true

- name: Remove configuration - 6
cisco.nxos.nxos_config:
lines: no interface loopback1
ignore_errors: true
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
- "'no ip port access-group PortACL in' in result.commands"
- "'ipv6 port traffic-filter NewACLv6 in' in result.commands"

- ansible.builtin.debug:
msg: "{{ ansible_facts['network_resources']['acl_interfaces'] }}"

- name: Revert back to base configuration using facts round trip
register: result
cisco.nxos.nxos_acl_interfaces:
Expand Down

0 comments on commit d6d55e5

Please sign in to comment.