Skip to content

Commit

Permalink
added examples
Browse files Browse the repository at this point in the history
  • Loading branch information
roverflow committed Nov 25, 2024
1 parent 54727ea commit f57a144
Show file tree
Hide file tree
Showing 3 changed files with 519 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Vrf_address_familyArgs(object): # pylint: disable=R0903
"parsed",
"gathered",
"deleted",
"purged",
"merged",
"replaced",
"rendered",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ def generate_commands(self):
if k not in wantd:
self._compare(want={}, have=have, vrf=k)

for k, want in iteritems(wantd):
self._compare(want=want, have=haved.pop(k, {}), vrf=k)
if self.state == "purged":
purge_list = wantd or haved
for k, item in iteritems(purge_list):
self.purge(k, item)
else:
for k, want in iteritems(wantd):
self._compare(want=want, have=haved.pop(k, {}), vrf=k)

def _compare(self, want, have, vrf):
"""Leverages the base class `compare()` method and
Expand Down Expand Up @@ -163,6 +168,15 @@ def _compare_af_lists(self, want, have):
for entry in hdict.values():
self.addcmd(entry, attrib, True)

def purge(self, vrf, item):
"""Purge the VRF configuration"""
self.commands.append(f"vrf context {vrf}")
for _, value in iteritems(item.get("address_families", {})):
self.commands.append(self._tmplt.render(
{"afi": value.get("afi"), "safi": value.get("safi")},
"address_family", True)
)

def _convert_to_dict(self, vrf_af_item: list, parser_item: str) -> dict:
"""Convert to dict based on parser name.
Expand Down
Loading

0 comments on commit f57a144

Please sign in to comment.