fix nxos parse response KeyError (#28602)

* fix nxos parse response

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

* use get() method instead
pull/24722/merge
Trishna Guha 7 years ago committed by Nathaniel Case
parent 335e804c0c
commit c36c34ef7e

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

Loading…
Cancel
Save