add normalize_interface in module_utils and fix nxos_l3_interface module (#40598)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2018-05-23 21:42:58 +05:30 committed by GitHub
commit 0b7932db30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 85 deletions

View file

@ -90,7 +90,7 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.common.config import CustomNetworkConfig
from ansible.module_utils.network.common.utils import remove_default_spec
from ansible.module_utils.network.nxos.nxos import get_config, load_config
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, normalize_interface
def search_obj_in_list(name, lst):
@ -151,10 +151,14 @@ def map_params_to_obj(module):
if item.get(key) is None:
item[key] = module.params[key]
obj.append(item.copy())
d = item.copy()
name = d['name']
d['name'] = normalize_interface(name)
obj.append(d)
else:
obj.append({
'name': module.params['name'],
'name': normalize_interface(module.params['name']),
'ipv4': module.params['ipv4'],
'ipv6': module.params['ipv6'],
'state': module.params['state']
@ -175,7 +179,7 @@ def map_config_to_obj(want, module):
if config:
match_name = re.findall(r'interface (\S+)', config, re.M)
if match_name:
obj['name'] = match_name[0]
obj['name'] = normalize_interface(match_name[0])
match_ipv4 = re.findall(r'ip address (\S+)', config, re.M)
if match_ipv4: