ios_vrf speed fix (#43765)

pull/44257/merge
Dennis Israelsson 6 years ago committed by Nathaniel Case
parent 1fac494d8c
commit 49f692b08f

@ -405,12 +405,16 @@ def parse_rd(configobj, name):
return match.group(1) return match.group(1)
def parse_interfaces(configobj, name): def parse_interfaces(configobj):
vrf_cfg = 'vrf forwarding %s' % name vrf_cfg = 'vrf forwarding'
interfaces = list() interfaces = dict()
for intf in re.findall('^interface .+', str(configobj), re.M): for intf in set(re.findall('^interface .+', str(configobj), re.M)):
if vrf_cfg in '\n'.join(configobj[intf].children): for line in configobj[intf].children:
interfaces.append(intf.split(' ')[1]) if vrf_cfg in line:
try:
interfaces[line.split()[-1]].append(intf.split(' ')[1])
except KeyError:
interfaces[line.split()[-1]] = [intf.split(' ')[1]]
return interfaces return interfaces
@ -507,13 +511,16 @@ def map_config_to_obj(module):
return list() return list()
instances = list() instances = list()
interfaces = parse_interfaces(configobj)
for item in set(match): for item in set(match):
obj = { obj = {
'name': item, 'name': item,
'state': 'present', 'state': 'present',
'description': parse_description(configobj, item), 'description': parse_description(configobj, item),
'rd': parse_rd(configobj, item), 'rd': parse_rd(configobj, item),
'interfaces': parse_interfaces(configobj, item), 'interfaces': interfaces.get(item),
'route_import': parse_import(configobj, item), 'route_import': parse_import(configobj, item),
'route_export': parse_export(configobj, item), 'route_export': parse_export(configobj, item),
'route_both': parse_both(configobj, item), 'route_both': parse_both(configobj, item),

Loading…
Cancel
Save