|
|
@ -132,6 +132,46 @@ from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible.module_utils.network.common.utils import remove_default_spec
|
|
|
|
from ansible.module_utils.network.common.utils import remove_default_spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def normalize_interface(name):
|
|
|
|
|
|
|
|
"""Return the normalized interface name
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not name:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_number(name):
|
|
|
|
|
|
|
|
digits = ''
|
|
|
|
|
|
|
|
for char in name:
|
|
|
|
|
|
|
|
if char.isdigit() or char in '/.':
|
|
|
|
|
|
|
|
digits += char
|
|
|
|
|
|
|
|
return digits
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if name.lower().startswith('et'):
|
|
|
|
|
|
|
|
if_type = 'Ethernet'
|
|
|
|
|
|
|
|
elif name.lower().startswith('vl'):
|
|
|
|
|
|
|
|
if_type = 'Vlan'
|
|
|
|
|
|
|
|
elif name.lower().startswith('lo'):
|
|
|
|
|
|
|
|
if_type = 'loopback'
|
|
|
|
|
|
|
|
elif name.lower().startswith('po'):
|
|
|
|
|
|
|
|
if_type = 'port-channel'
|
|
|
|
|
|
|
|
elif name.lower().startswith('nv'):
|
|
|
|
|
|
|
|
if_type = 'nve'
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if_type = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
number_list = name.split(' ')
|
|
|
|
|
|
|
|
if len(number_list) == 2:
|
|
|
|
|
|
|
|
number = number_list[-1].strip()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
number = _get_number(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if if_type:
|
|
|
|
|
|
|
|
proper_interface = if_type + number
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
proper_interface = name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return proper_interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute_show_command(command, module):
|
|
|
|
def execute_show_command(command, module):
|
|
|
|
device_info = get_capabilities(module)
|
|
|
|
device_info = get_capabilities(module)
|
|
|
|
network_api = device_info.get('network_api', 'nxapi')
|
|
|
|
network_api = device_info.get('network_api', 'nxapi')
|
|
|
@ -244,14 +284,20 @@ def map_params_to_obj(module):
|
|
|
|
d = item.copy()
|
|
|
|
d = item.copy()
|
|
|
|
d['group'] = str(d['group'])
|
|
|
|
d['group'] = str(d['group'])
|
|
|
|
d['min_links'] = str(d['min_links'])
|
|
|
|
d['min_links'] = str(d['min_links'])
|
|
|
|
|
|
|
|
if d['members']:
|
|
|
|
|
|
|
|
d['members'] = [normalize_interface(i) for i in d['members']]
|
|
|
|
|
|
|
|
|
|
|
|
obj.append(d)
|
|
|
|
obj.append(d)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
members = None
|
|
|
|
|
|
|
|
if module.params['members']:
|
|
|
|
|
|
|
|
members = [normalize_interface(i) for i in module.params['members']]
|
|
|
|
|
|
|
|
|
|
|
|
obj.append({
|
|
|
|
obj.append({
|
|
|
|
'group': str(module.params['group']),
|
|
|
|
'group': str(module.params['group']),
|
|
|
|
'mode': module.params['mode'],
|
|
|
|
'mode': module.params['mode'],
|
|
|
|
'min_links': str(module.params['min_links']),
|
|
|
|
'min_links': str(module.params['min_links']),
|
|
|
|
'members': module.params['members'],
|
|
|
|
'members': members,
|
|
|
|
'state': module.params['state']
|
|
|
|
'state': module.params['state']
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
@ -290,10 +336,10 @@ def get_members(channel):
|
|
|
|
return list()
|
|
|
|
return list()
|
|
|
|
|
|
|
|
|
|
|
|
if isinstance(interfaces, dict):
|
|
|
|
if isinstance(interfaces, dict):
|
|
|
|
members.append(interfaces.get('port'))
|
|
|
|
members.append(normalize_interface(interfaces.get('port')))
|
|
|
|
elif isinstance(interfaces, list):
|
|
|
|
elif isinstance(interfaces, list):
|
|
|
|
for i in interfaces:
|
|
|
|
for i in interfaces:
|
|
|
|
members.append(i.get('port'))
|
|
|
|
members.append(normalize_interface(i.get('port')))
|
|
|
|
|
|
|
|
|
|
|
|
return members
|
|
|
|
return members
|
|
|
|
|
|
|
|
|
|
|
|