|
|
@ -224,12 +224,12 @@ def map_obj_to_commands(updates, module):
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
|
purge = module.params['purge']
|
|
|
|
purge = module.params['purge']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = ('rd', 'description', 'vni')
|
|
|
|
|
|
|
|
|
|
|
|
for w in want:
|
|
|
|
for w in want:
|
|
|
|
name = w['name']
|
|
|
|
name = w['name']
|
|
|
|
description = w['description']
|
|
|
|
|
|
|
|
vni = w['vni']
|
|
|
|
|
|
|
|
rd = w['rd']
|
|
|
|
|
|
|
|
admin_state = w['admin_state']
|
|
|
|
admin_state = w['admin_state']
|
|
|
|
|
|
|
|
vni = w['vni']
|
|
|
|
interfaces = w.get('interfaces') or []
|
|
|
|
interfaces = w.get('interfaces') or []
|
|
|
|
state = w['state']
|
|
|
|
state = w['state']
|
|
|
|
del w['state']
|
|
|
|
del w['state']
|
|
|
@ -242,22 +242,17 @@ def map_obj_to_commands(updates, module):
|
|
|
|
elif state == 'present':
|
|
|
|
elif state == 'present':
|
|
|
|
if not obj_in_have:
|
|
|
|
if not obj_in_have:
|
|
|
|
commands.append('vrf context {0}'.format(name))
|
|
|
|
commands.append('vrf context {0}'.format(name))
|
|
|
|
if rd and rd != '':
|
|
|
|
for item in args:
|
|
|
|
commands.append('rd {0}'.format(rd))
|
|
|
|
candidate = w.get(item)
|
|
|
|
if description:
|
|
|
|
if candidate:
|
|
|
|
commands.append('description {0}'.format(description))
|
|
|
|
cmd = item + ' ' + str(candidate)
|
|
|
|
if vni and vni != '':
|
|
|
|
commands.append(cmd)
|
|
|
|
commands.append('vni {0}'.format(vni))
|
|
|
|
|
|
|
|
if admin_state == 'up':
|
|
|
|
if admin_state == 'up':
|
|
|
|
commands.append('no shutdown')
|
|
|
|
commands.append('no shutdown')
|
|
|
|
elif admin_state == 'down':
|
|
|
|
elif admin_state == 'down':
|
|
|
|
commands.append('shutdown')
|
|
|
|
commands.append('shutdown')
|
|
|
|
|
|
|
|
|
|
|
|
if commands:
|
|
|
|
|
|
|
|
if vni:
|
|
|
|
|
|
|
|
if have.get('vni') and have.get('vni') != '':
|
|
|
|
|
|
|
|
commands.insert(1, 'no vni {0}'.format(have['vni']))
|
|
|
|
|
|
|
|
commands.append('exit')
|
|
|
|
commands.append('exit')
|
|
|
|
|
|
|
|
|
|
|
|
if interfaces:
|
|
|
|
if interfaces:
|
|
|
|
for i in interfaces:
|
|
|
|
for i in interfaces:
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
@ -265,6 +260,26 @@ def map_obj_to_commands(updates, module):
|
|
|
|
commands.append('vrf member {0}'.format(name))
|
|
|
|
commands.append('vrf member {0}'.format(name))
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
# If vni is already configured on vrf, unconfigure it first.
|
|
|
|
|
|
|
|
if vni:
|
|
|
|
|
|
|
|
if obj_in_have.get('vni') and vni != obj_in_have.get('vni'):
|
|
|
|
|
|
|
|
commands.append('no vni {0}'.format(obj_in_have.get('vni')))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for item in args:
|
|
|
|
|
|
|
|
candidate = w.get(item)
|
|
|
|
|
|
|
|
if candidate and candidate != obj_in_have.get(item):
|
|
|
|
|
|
|
|
cmd = item + ' ' + str(candidate)
|
|
|
|
|
|
|
|
commands.append(cmd)
|
|
|
|
|
|
|
|
if admin_state and admin_state != obj_in_have.get('admin_state'):
|
|
|
|
|
|
|
|
if admin_state == 'up':
|
|
|
|
|
|
|
|
commands.append('no shutdown')
|
|
|
|
|
|
|
|
elif admin_state == 'down':
|
|
|
|
|
|
|
|
commands.append('shutdown')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if commands:
|
|
|
|
|
|
|
|
commands.insert(0, 'vrf context {0}'.format(name))
|
|
|
|
|
|
|
|
commands.append('exit')
|
|
|
|
|
|
|
|
|
|
|
|
if interfaces:
|
|
|
|
if interfaces:
|
|
|
|
if not obj_in_have['interfaces']:
|
|
|
|
if not obj_in_have['interfaces']:
|
|
|
|
for i in interfaces:
|
|
|
|
for i in interfaces:
|
|
|
|