Check for proper response key on eos_banner map_config_to_obj (#23399)

If we run the task with 'login' banner, the 'show banner' command
will return a dict containing key 'loginBanner'.
However for motd, it will just return 'motd'.
Yay naming consistency!
This commit is contained in:
Ricardo Carrillo Cruz 2017-04-07 15:32:10 +02:00 committed by GitHub
parent ce9826d76e
commit ba7ba7adc3

View file

@ -121,8 +121,12 @@ def map_config_to_obj(module):
else:
# On EAPI we need to extract the banner text from dict key
# 'loginBanner'
if isinstance(output[0], dict) and 'loginBanner' in output[0].keys():
obj['text'] = output[0]['loginBanner'].strip('\n')
if module.params['banner'] == 'login':
banner_response_key = 'loginBanner'
else:
banner_response_key = 'motd'
if isinstance(output[0], dict) and banner_response_key in output[0].keys():
obj['text'] = output[0][banner_response_key].strip('\n')
obj['state'] = 'present'
return obj