Removed tabs

pull/18777/head
GGabriele 8 years ago committed by Matt Clay
parent 7a234fc7cc
commit 7010a66638

@ -840,24 +840,30 @@ def get_existing(module, prefix, warnings):
parents = 'vrf context {0}'.format(module.params['vrf']) parents = 'vrf context {0}'.format(module.params['vrf'])
prefix_to_regex = fix_prefix_to_regex(prefix) prefix_to_regex = fix_prefix_to_regex(prefix)
route_regex = '.*ip\sroute\s{0}\s(?P<next_hop>\S+)(\sname\s(?P<route_name>\S+))?(\stag\s(?P<tag>\d+))?(\s(?P<pref>\d+)).*'.format(prefix_to_regex) route_regex = ('.*ip\sroute\s{0}\s(?P<next_hop>\S+)(\sname\s(?P<route_name>\S+))?'
'(\stag\s(?P<tag>\d+))?(\s(?P<pref>\d+)).*'.format(prefix_to_regex))
if module.params['vrf'] == 'default': if module.params['vrf'] == 'default':
config = str(netcfg) config = str(netcfg)
else: else:
config = netcfg.get_section(parents) config = netcfg.get_section(parents)
try:
match_route = re.match(route_regex, config, re.DOTALL) if config:
group_route = match_route.groupdict() try:
match_route = re.match(route_regex, config, re.DOTALL)
for key in key_map: group_route = match_route.groupdict()
if key not in group_route.keys():
group_route['key'] = None for key in key_map:
group_route['prefix'] = prefix if key not in group_route.keys():
except (AttributeError, TypeError): group_route[key] = ''
group_route['prefix'] = prefix
group_route['vrf'] = module.params['vrf']
except (AttributeError, TypeError):
group_route = {}
else:
group_route = {} group_route = {}
if module.params['state'] == 'present': msg = ("VRF {0} didn't exist.".format(module.params['vrf']))
msg = ("VRF {0} doesn't exist.".format(module.params['vrf'])) if msg not in warnings:
warnings.append(msg) warnings.append(msg)
return group_route return group_route

Loading…
Cancel
Save