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
This commit is contained in:
Ricardo Carrillo Cruz 2017-03-29 22:38:15 +02:00 committed by GitHub
parent 88ce6fd273
commit 66e29f0a7c

View file

@ -113,7 +113,10 @@ def map_config_to_obj(module):
rc, out, err = exec_command(module, rc, out, err = exec_command(module,
'show running-config | begin banner %s' 'show running-config | begin banner %s'
% module.params['banner']) % 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'} obj = {'banner': module.params['banner'], 'state': 'absent'}
if output: if output:
obj['text'] = output obj['text'] = output