mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Implement purge on eos_vrf (#28013)
This commit is contained in:
committed by
GitHub
parent
1c4e491eac
commit
e8f1c1511c
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user