mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
fix for handling commands that return no data or error (#22086)
This patch addresses a problem in nxos_facts where certain commands are not supported or return no data, the module would raise an exception. With this patch, the nxos_facts module will now print a warning for any commands that return no data and not populate the facts. fixes #22001
This commit is contained in:
parent
d66ce40ecb
commit
8d76703a9d
2 changed files with 61 additions and 59 deletions
|
@ -255,13 +255,16 @@ class Nxapi:
|
|||
except ValueError:
|
||||
self._module.fail_json(msg='unable to parse response')
|
||||
|
||||
if check_status:
|
||||
output = response['ins_api']['outputs']['output']
|
||||
for item in to_list(output):
|
||||
if item['code'] != '200':
|
||||
self._error(output=output, **item)
|
||||
else:
|
||||
result.append(item['body'])
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue