mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-08 17:34:01 -07:00
Fixes ios_l2_interface and ios_vlan not working on certain interface types issue (#43819)
* Fixes #43654 and #43582 * Remove q statement * Fix shippable errors * Fix more shippable errors * Fix unittest
This commit is contained in:
parent
e188073629
commit
b14f256d41
3 changed files with 51 additions and 3 deletions
|
@ -145,3 +145,51 @@ def load_config(module, commands):
|
|||
return resp.get('response')
|
||||
except ConnectionError as exc:
|
||||
module.fail_json(msg=to_text(exc))
|
||||
|
||||
|
||||
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('gi'):
|
||||
if_type = 'GigabitEthernet'
|
||||
elif name.lower().startswith('te'):
|
||||
if_type = 'TenGigabitEthernet'
|
||||
elif name.lower().startswith('fa'):
|
||||
if_type = 'FastEthernet'
|
||||
elif name.lower().startswith('fo'):
|
||||
if_type = 'FortyGigabitEthernet'
|
||||
elif 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:
|
||||
if_number = number_list[-1].strip()
|
||||
else:
|
||||
if_number = _get_number(name)
|
||||
|
||||
if if_type:
|
||||
proper_interface = if_type + if_number
|
||||
else:
|
||||
proper_interface = name
|
||||
|
||||
return proper_interface
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue