mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add transformed json output in junos_command (#26382)
* Add transformed json output in junos_command Fixes #26363 If the display is in `xml` format for command responses add th transformed `json` output in the result. * Fix CI issue
This commit is contained in:
parent
58ade65ea6
commit
8c7a6cb8ac
1 changed files with 12 additions and 2 deletions
|
@ -157,6 +157,11 @@ stdout_lines:
|
|||
returned: always apart from low level errors (such as action plugin)
|
||||
type: list
|
||||
sample: [['...', '...'], ['...'], ['...']]
|
||||
output:
|
||||
description: The set of transformed xml to json format from the commands responses
|
||||
returned: If the I(display) is in C(xml) format.
|
||||
type: list
|
||||
sample: ['...', '...']
|
||||
failed_conditions:
|
||||
description: The list of conditionals that have failed
|
||||
returned: failed
|
||||
|
@ -348,7 +353,7 @@ def main():
|
|||
responses = rpc(module, items)
|
||||
|
||||
transformed = list()
|
||||
|
||||
output = list()
|
||||
for item, resp in zip(items, responses):
|
||||
if item['xattrs']['format'] == 'xml':
|
||||
if not HAS_JXMLEASE:
|
||||
|
@ -356,7 +361,9 @@ def main():
|
|||
'It can be installed using `pip install jxmlease`')
|
||||
|
||||
try:
|
||||
transformed.append(jxmlease.parse(resp))
|
||||
json_resp = jxmlease.parse(resp)
|
||||
transformed.append(json_resp)
|
||||
output.append(json_resp)
|
||||
except:
|
||||
raise ValueError(resp)
|
||||
else:
|
||||
|
@ -390,6 +397,9 @@ def main():
|
|||
'stdout_lines': to_lines(responses)
|
||||
}
|
||||
|
||||
if output:
|
||||
result['output'] = output
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue