nxos_system parse name_servers fix (#29944)

* nxos_system parse name_servers fix

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix nxos_system tests

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
pull/29953/head
Trishna Guha 7 years ago committed by GitHub
parent 68aeaa58a8
commit 5b1c91bf19

@ -238,12 +238,14 @@ def parse_domain_search(config, vrf_config):
return objects return objects
def parse_name_servers(config, vrf_config): def parse_name_servers(config, vrf_config, vrfs):
objects = list() objects = list()
match = re.search('^ip name-server (.+)$', config, re.M) match = re.search('^ip name-server (.+)$', config, re.M)
if match: if match:
for addr in match.group(1).split(' '): for addr in match.group(1).split(' '):
if addr == 'use-vrf' or addr in vrfs:
continue
objects.append({'server': addr, 'vrf': None}) objects.append({'server': addr, 'vrf': None})
for vrf, cfg in iteritems(vrf_config): for vrf, cfg in iteritems(vrf_config):
@ -275,7 +277,7 @@ def map_config_to_obj(module):
'domain_lookup': 'no ip domain-lookup' not in config, 'domain_lookup': 'no ip domain-lookup' not in config,
'domain_name': parse_domain_name(config, vrf_config), 'domain_name': parse_domain_name(config, vrf_config),
'domain_search': parse_domain_search(config, vrf_config), 'domain_search': parse_domain_search(config, vrf_config),
'name_servers': parse_name_servers(config, vrf_config), 'name_servers': parse_name_servers(config, vrf_config, vrfs),
'system_mtu': parse_system_mtu(config) 'system_mtu': parse_system_mtu(config)
} }

@ -22,7 +22,6 @@
- assert: - assert:
that: that:
- result.changed == true - result.changed == true
- result.commands|length == 3
- "'ip name-server 1.1.1.1' in result.commands" - "'ip name-server 1.1.1.1' in result.commands"
- "'ip name-server 2.2.2.2' in result.commands" - "'ip name-server 2.2.2.2' in result.commands"
- "'ip name-server 3.3.3.3' in result.commands" - "'ip name-server 3.3.3.3' in result.commands"

@ -28,7 +28,6 @@
- assert: - assert:
that: that:
- result.changed == true - result.changed == true
- result.commands|length == 3
- "'ip name-server 1.1.1.1' in result.commands" - "'ip name-server 1.1.1.1' in result.commands"
- "'ip name-server 2.2.2.2' in result.commands" - "'ip name-server 2.2.2.2' in result.commands"
- "'ip name-server 3.3.3.3' in result.commands" - "'ip name-server 3.3.3.3' in result.commands"

Loading…
Cancel
Save