mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Implement purge on eos_vrf (#28013)
This commit is contained in:
parent
1c4e491eac
commit
e8f1c1511c
2 changed files with 36 additions and 1 deletions
|
@ -91,6 +91,7 @@ def map_obj_to_commands(updates, module):
|
|||
commands = list()
|
||||
want, have = updates
|
||||
state = module.params['state']
|
||||
purge = module.params['purge']
|
||||
|
||||
for w in want:
|
||||
name = w['name']
|
||||
|
@ -100,7 +101,7 @@ def map_obj_to_commands(updates, module):
|
|||
obj_in_have = search_obj_in_list(name, have)
|
||||
|
||||
if state == 'absent':
|
||||
if have:
|
||||
if obj_in_have:
|
||||
commands.append('no vrf definition %s' % name)
|
||||
elif state == 'present':
|
||||
if not obj_in_have:
|
||||
|
@ -130,6 +131,12 @@ def map_obj_to_commands(updates, module):
|
|||
commands.append('interface %s' % i)
|
||||
commands.append('vrf forwarding %s' % w['name'])
|
||||
|
||||
if purge:
|
||||
for h in have:
|
||||
obj_in_want = search_obj_in_list(h['name'], want)
|
||||
if not obj_in_want:
|
||||
commands.append('no vrf definition %s' % h['name'])
|
||||
|
||||
return commands
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue