mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00: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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user