|
|
|
@ -175,7 +175,7 @@ from copy import deepcopy
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
from ansible.module_utils.network.nxos.nxos import load_config, run_commands
|
|
|
|
|
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec
|
|
|
|
|
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, get_interface_type
|
|
|
|
|
from ansible.module_utils.network.common.utils import remove_default_spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -262,7 +262,8 @@ def map_obj_to_commands(updates, module):
|
|
|
|
|
if interfaces and interfaces[0] != 'default':
|
|
|
|
|
for i in interfaces:
|
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
if get_interface_type(i) in ('ethernet', 'portchannel'):
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
commands.append('vrf member {0}'.format(name))
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
@ -296,7 +297,8 @@ def map_obj_to_commands(updates, module):
|
|
|
|
|
commands.append('vrf context {0}'.format(name))
|
|
|
|
|
commands.append('exit')
|
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
if get_interface_type(i) in ('ethernet', 'portchannel'):
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
commands.append('vrf member {0}'.format(name))
|
|
|
|
|
|
|
|
|
|
elif set(interfaces) != set(obj_in_have['interfaces']):
|
|
|
|
@ -305,7 +307,8 @@ def map_obj_to_commands(updates, module):
|
|
|
|
|
commands.append('vrf context {0}'.format(name))
|
|
|
|
|
commands.append('exit')
|
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
if get_interface_type(i) in ('ethernet', 'portchannel'):
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
commands.append('vrf member {0}'.format(name))
|
|
|
|
|
|
|
|
|
|
superfluous_interfaces = list(set(obj_in_have['interfaces']) - set(interfaces))
|
|
|
|
@ -313,7 +316,8 @@ def map_obj_to_commands(updates, module):
|
|
|
|
|
commands.append('vrf context {0}'.format(name))
|
|
|
|
|
commands.append('exit')
|
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
if get_interface_type(i) in ('ethernet', 'portchannel'):
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
commands.append('no vrf member {0}'.format(name))
|
|
|
|
|
elif interfaces and interfaces[0] == 'default':
|
|
|
|
|
if obj_in_have['interfaces']:
|
|
|
|
@ -321,7 +325,8 @@ def map_obj_to_commands(updates, module):
|
|
|
|
|
commands.append('vrf context {0}'.format(name))
|
|
|
|
|
commands.append('exit')
|
|
|
|
|
commands.append('interface {0}'.format(i))
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
if get_interface_type(i) in ('ethernet', 'portchannel'):
|
|
|
|
|
commands.append('no switchport')
|
|
|
|
|
commands.append('no vrf member {0}'.format(name))
|
|
|
|
|
|
|
|
|
|
if purge:
|
|
|
|
|