Do not re.search show configuration stdout if empty (#23087)

If the banner is not set, the stdout of 'show configuration | begin banner <banner>'
returns empty string thus the re.search raises an exception.

Fixes #22216
pull/23093/head
Ricardo Carrillo Cruz 9 years ago
parent 664b27aaf0
commit 18dedd985a

@ -113,7 +113,10 @@ def map_config_to_obj(module):
rc, out, err = exec_command(module,
'show running-config | begin banner %s'
% module.params['banner'])
output = re.search('\^C(.*)\^C', out, re.S).group(1).strip()
if out:
output = re.search('\^C(.*)\^C', out, re.S).group(1).strip()
else:
output = None
obj = {'banner': module.params['banner'], 'state': 'absent'}
if output:
obj['text'] = output

Loading…
Cancel
Save