Skip to content

Commit

Permalink
Fix Purged and Overridden Operations
Browse files Browse the repository at this point in the history
Signed-off-by: rohitthakur2590 <[email protected]>
  • Loading branch information
rohitthakur2590 committed Dec 11, 2024
1 parent c56f7a6 commit 0ae155e
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 101 deletions.
7 changes: 7 additions & 0 deletions changelogs/fragments/fix_purge_and_overridden_operations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- bugfixes:
- Fix purged state operation to enable users to completely remove VLAN configurations.
- Fix overridden state operations to ensure excluded VLANs in the provided configuration are removed, thus overriding the VLAN configuration.
- Improve documentation to provide clarity on the "shutdown" variable.
- Improve unit tests to align with the changes made.

10 changes: 7 additions & 3 deletions plugins/module_utils/network/ios/config/vlans/vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ def generate_commands(self, conf_want, conf_have, resource=None):
if self.state == "merged":
wantd = dict_merge(haved, wantd)

# if state is deleted, empty out wantd and set haved to wantd
if self.state == "deleted":
# if state is overridden, remove excluded vlans
if self.state == "overridden":
excluded_vlans = {k: v for k, v in iteritems(haved) if k not in wantd or not wantd}
haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd}
wantd = {}
for k, have in iteritems(excluded_vlans):
self.purge(have, resource)

# if state is deleted, empty out wantd and set haved to wantd
if self.state in ["deleted", "purged"]:
Expand Down Expand Up @@ -165,3 +167,5 @@ def purge(self, have, resource):
"""Handle operation for purged state"""
if resource == "vlan_configuration":
self.commands.append(self._tmplt.render(have, resource, True))
elif resource == "vlans":
self.commands.append(self._tmplt.render(have, resource, True))
Loading

0 comments on commit 0ae155e

Please sign in to comment.