mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
Merge pull request #17422 from privateip/fix-17407
bug fix for AttributeError: 'str' object has no attribute 'get'
This commit is contained in:
commit
5730c97f9e
1 changed files with 7 additions and 3 deletions
|
@ -31,6 +31,7 @@ import re
|
||||||
from ansible.module_utils.basic import json
|
from ansible.module_utils.basic import json
|
||||||
from ansible.module_utils.network import ModuleStub, NetworkError, NetworkModule
|
from ansible.module_utils.network import ModuleStub, NetworkError, NetworkModule
|
||||||
from ansible.module_utils.network import add_argument, register_transport, to_list
|
from ansible.module_utils.network import add_argument, register_transport, to_list
|
||||||
|
from ansible.module_utils.netcli import Command
|
||||||
from ansible.module_utils.shell import CliBase
|
from ansible.module_utils.shell import CliBase
|
||||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||||
|
|
||||||
|
@ -307,9 +308,12 @@ def prepare_commands(commands):
|
||||||
:returns: list of dict objects
|
:returns: list of dict objects
|
||||||
"""
|
"""
|
||||||
jsonify = lambda x: '%s | json' % x
|
jsonify = lambda x: '%s | json' % x
|
||||||
for cmd in to_list(commands):
|
for item in to_list(commands):
|
||||||
if cmd.output == 'json':
|
if item.output == 'json':
|
||||||
cmd = jsonify(cmd)
|
cmd = jsonify(cmd)
|
||||||
|
elif item.command.endswith('| json'):
|
||||||
|
item.output = 'json'
|
||||||
|
cmd = str(item)
|
||||||
else:
|
else:
|
||||||
cmd = str(cmd)
|
cmd = str(item)
|
||||||
yield cmd
|
yield cmd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue