Implement purge on eos_vrf (#28013)

This commit is contained in:
Ricardo Carrillo Cruz 2017-08-10 19:59:32 +02:00 committed by GitHub
commit e8f1c1511c
2 changed files with 36 additions and 1 deletions

View file

@ -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