1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix nxos parse response KeyError (#28602)

* fix nxos parse response

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* use get() method instead
This commit is contained in:
Trishna Guha 2017-08-28 16:15:20 -04:00 committed by Nathaniel Case
parent 335e804c0c
commit c36c34ef7e

View file

@ -288,18 +288,19 @@ class Nxapi:
except ValueError: except ValueError:
self._module.fail_json(msg='unable to parse response') self._module.fail_json(msg='unable to parse response')
output = response['ins_api']['outputs']['output'] if response['ins_api'].get('outputs'):
for item in to_list(output): output = response['ins_api']['outputs']['output']
if check_status and item['code'] != '200': for item in to_list(output):
self._error(output=output, **item) if check_status and item['code'] != '200':
elif 'body' in item: self._error(output=output, **item)
result.append(item['body']) elif 'body' in item:
# else: result.append(item['body'])
# error in command but since check_status is disabled # else:
# silently drop it. # error in command but since check_status is disabled
# result.append(item['msg']) # silently drop it.
# result.append(item['msg'])
return result return result
def get_config(self, flags=[]): def get_config(self, flags=[]):
"""Retrieves the current config from the device or cache """Retrieves the current config from the device or cache