|
|
|
@ -56,7 +56,7 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- Specifies mechanism for host reachability advertisement.
|
|
|
|
|
required: false
|
|
|
|
|
choices: ['bgp','static']
|
|
|
|
|
choices: ['bgp','static', 'default']
|
|
|
|
|
default: null
|
|
|
|
|
multicast_group:
|
|
|
|
|
description:
|
|
|
|
@ -110,6 +110,11 @@ BOOL_PARAMS = [
|
|
|
|
|
'assoc_vrf',
|
|
|
|
|
'suppress_arp',
|
|
|
|
|
]
|
|
|
|
|
PARAM_TO_DEFAULT_KEYMAP = {
|
|
|
|
|
'multicast_group': '',
|
|
|
|
|
'peer_list': [],
|
|
|
|
|
'ingress_replication': '',
|
|
|
|
|
}
|
|
|
|
|
PARAM_TO_COMMAND_KEYMAP = {
|
|
|
|
|
'assoc_vrf': 'associate-vrf',
|
|
|
|
|
'interface': 'interface',
|
|
|
|
@ -203,19 +208,33 @@ def state_present(module, existing, proposed, candidate):
|
|
|
|
|
command = 'no {0}'.format(command)
|
|
|
|
|
commands.append(command)
|
|
|
|
|
|
|
|
|
|
elif key == 'peer-ip' and value != 'default':
|
|
|
|
|
elif key == 'peer-ip' and value != []:
|
|
|
|
|
for peer in value:
|
|
|
|
|
commands.append('{0} {1}'.format(key, peer))
|
|
|
|
|
|
|
|
|
|
elif key == 'mcast-group' and value != existing_commands.get(key):
|
|
|
|
|
commands.append('no {0}'.format(key))
|
|
|
|
|
vni_command = 'member vni {0}'.format(module.params['vni'])
|
|
|
|
|
if vni_command not in commands:
|
|
|
|
|
commands.append('member vni {0}'.format(module.params['vni']))
|
|
|
|
|
if value != PARAM_TO_DEFAULT_KEYMAP.get('multicast_group', 'default'):
|
|
|
|
|
commands.append('{0} {1}'.format(key, value))
|
|
|
|
|
|
|
|
|
|
elif key == 'ingress-replication protocol' and value != existing_commands.get(key):
|
|
|
|
|
evalue = existing_commands.get(key)
|
|
|
|
|
dvalue = PARAM_TO_DEFAULT_KEYMAP.get('ingress_replication', 'default')
|
|
|
|
|
if value != dvalue:
|
|
|
|
|
if evalue != dvalue:
|
|
|
|
|
commands.append('no {0} {1}'.format(key, evalue))
|
|
|
|
|
commands.append('{0} {1}'.format(key, value))
|
|
|
|
|
else:
|
|
|
|
|
commands.append('no {0} {1}'.format(key, evalue))
|
|
|
|
|
|
|
|
|
|
elif value is True:
|
|
|
|
|
commands.append(key)
|
|
|
|
|
elif value is False:
|
|
|
|
|
commands.append('no {0}'.format(key))
|
|
|
|
|
elif value == 'default':
|
|
|
|
|
elif value == 'default' or value == []:
|
|
|
|
|
if existing_commands.get(key):
|
|
|
|
|
existing_value = existing_commands.get(key)
|
|
|
|
|
if key == 'peer-ip':
|
|
|
|
@ -232,15 +251,26 @@ def state_present(module, existing, proposed, candidate):
|
|
|
|
|
|
|
|
|
|
if commands:
|
|
|
|
|
vni_command = 'member vni {0}'.format(module.params['vni'])
|
|
|
|
|
ingress_replication_command = 'ingress-replication protocol static'
|
|
|
|
|
ingress_replications_command = 'ingress-replication protocol static'
|
|
|
|
|
ingress_replicationb_command = 'ingress-replication protocol bgp'
|
|
|
|
|
ingress_replicationns_command = 'no ingress-replication protocol static'
|
|
|
|
|
ingress_replicationnb_command = 'no ingress-replication protocol bgp'
|
|
|
|
|
interface_command = 'interface {0}'.format(module.params['interface'])
|
|
|
|
|
|
|
|
|
|
if ingress_replication_command in commands:
|
|
|
|
|
if any(c in commands for c in (ingress_replications_command, ingress_replicationb_command,
|
|
|
|
|
ingress_replicationnb_command, ingress_replicationns_command)):
|
|
|
|
|
static_level_cmds = [cmd for cmd in commands if 'peer' in cmd]
|
|
|
|
|
parents = [interface_command, vni_command, ingress_replication_command]
|
|
|
|
|
parents = [interface_command, vni_command]
|
|
|
|
|
for cmd in commands:
|
|
|
|
|
parents.append(cmd)
|
|
|
|
|
candidate.add(static_level_cmds, parents=parents)
|
|
|
|
|
commands = [cmd for cmd in commands if 'peer' not in cmd]
|
|
|
|
|
|
|
|
|
|
elif 'peer-ip' in commands[0]:
|
|
|
|
|
static_level_cmds = [cmd for cmd in commands]
|
|
|
|
|
parents = [interface_command, vni_command, ingress_replications_command]
|
|
|
|
|
candidate.add(static_level_cmds, parents=parents)
|
|
|
|
|
|
|
|
|
|
if vni_command in commands:
|
|
|
|
|
parents = [interface_command]
|
|
|
|
|
commands.remove(vni_command)
|
|
|
|
@ -288,7 +318,7 @@ def main():
|
|
|
|
|
module.fail_json(msg='assoc_vrf cannot be used with '
|
|
|
|
|
'{0} param'.format(param))
|
|
|
|
|
if module.params['peer_list']:
|
|
|
|
|
if module.params['ingress_replication'] != 'static':
|
|
|
|
|
if module.params['peer_list'][0] != 'default' and module.params['ingress_replication'] != 'static':
|
|
|
|
|
module.fail_json(msg='ingress_replication=static is required '
|
|
|
|
|
'when using peer_list param')
|
|
|
|
|
else:
|
|
|
|
@ -322,6 +352,9 @@ def main():
|
|
|
|
|
|
|
|
|
|
proposed = {}
|
|
|
|
|
for key, value in proposed_args.items():
|
|
|
|
|
if key in ['multicast_group', 'peer_list', 'ingress_replication']:
|
|
|
|
|
if str(value).lower() == 'default':
|
|
|
|
|
value = PARAM_TO_DEFAULT_KEYMAP.get(key, 'default')
|
|
|
|
|
if key != 'interface' and existing.get(key) != value:
|
|
|
|
|
proposed[key] = value
|
|
|
|
|
|
|
|
|
|