From 7010a66638d4b7aeaa5dd040f8000572286d58ba Mon Sep 17 00:00:00 2001 From: GGabriele Date: Sun, 4 Sep 2016 13:20:52 +0200 Subject: [PATCH] Removed tabs --- .../modules/network/nxos/nxos_static_route.py | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_static_route.py b/lib/ansible/modules/network/nxos/nxos_static_route.py index b92a483489b..bf943043e3f 100644 --- a/lib/ansible/modules/network/nxos/nxos_static_route.py +++ b/lib/ansible/modules/network/nxos/nxos_static_route.py @@ -840,24 +840,30 @@ def get_existing(module, prefix, warnings): parents = 'vrf context {0}'.format(module.params['vrf']) prefix_to_regex = fix_prefix_to_regex(prefix) - route_regex = '.*ip\sroute\s{0}\s(?P\S+)(\sname\s(?P\S+))?(\stag\s(?P\d+))?(\s(?P\d+)).*'.format(prefix_to_regex) + route_regex = ('.*ip\sroute\s{0}\s(?P\S+)(\sname\s(?P\S+))?' + '(\stag\s(?P\d+))?(\s(?P\d+)).*'.format(prefix_to_regex)) if module.params['vrf'] == 'default': config = str(netcfg) else: config = netcfg.get_section(parents) - try: - match_route = re.match(route_regex, config, re.DOTALL) - group_route = match_route.groupdict() - - for key in key_map: - if key not in group_route.keys(): - group_route['key'] = None - group_route['prefix'] = prefix - except (AttributeError, TypeError): + + if config: + try: + match_route = re.match(route_regex, config, re.DOTALL) + group_route = match_route.groupdict() + + for key in key_map: + if key not in group_route.keys(): + group_route[key] = '' + group_route['prefix'] = prefix + group_route['vrf'] = module.params['vrf'] + except (AttributeError, TypeError): + group_route = {} + else: group_route = {} - if module.params['state'] == 'present': - msg = ("VRF {0} doesn't exist.".format(module.params['vrf'])) + msg = ("VRF {0} didn't exist.".format(module.params['vrf'])) + if msg not in warnings: warnings.append(msg) return group_route