summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn R Barker <john@johnrbarker.com>2017-04-06 16:18:58 +0100
committerGitHub <noreply@github.com>2017-04-06 16:18:58 +0100
commitc6e9039b233cb0216a4f62191945251f13631816 (patch)
treed6b823d4666803161a7fbe73d0967fc924bc8234
parent0da250c9f12d3798e82d848797690148844df9b1 (diff)
downloadansible-c6e9039b233cb0216a4f62191945251f13631816.tar.gz
fix iosxr commands to encode json (#23346) (#23355)
the command dict in the iosxr module_utils wasn't encoding the request to json. this patch will fix that problem (cherry picked from commit f0008248d4c1712c24a62d47bebe96254b815ab0)
-rw-r--r--lib/ansible/module_utils/iosxr.py1
-rw-r--r--lib/ansible/modules/network/iosxr/iosxr_command.py1
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_command.py3
3 files changed, 2 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/iosxr.py b/lib/ansible/module_utils/iosxr.py
index 53ea7db7df..9b2deacf9c 100644
--- a/lib/ansible/module_utils/iosxr.py
+++ b/lib/ansible/module_utils/iosxr.py
@@ -79,6 +79,7 @@ def run_commands(module, commands, check_rc=True):
responses = list()
commands = to_commands(module, to_list(commands))
for cmd in to_list(commands):
+ cmd = module.jsonify(cmd)
rc, out, err = exec_command(module, cmd)
if check_rc and rc != 0:
module.fail_json(msg=err, rc=rc)
diff --git a/lib/ansible/modules/network/iosxr/iosxr_command.py b/lib/ansible/modules/network/iosxr/iosxr_command.py
index 08a2272562..7239218039 100644
--- a/lib/ansible/modules/network/iosxr/iosxr_command.py
+++ b/lib/ansible/modules/network/iosxr/iosxr_command.py
@@ -163,7 +163,6 @@ def parse_commands(module, warnings):
msg='iosxr_command does not support running config mode '
'commands. Please use iosxr_config instead'
)
- commands[index] = module.jsonify(item)
return commands
def main():
diff --git a/test/units/modules/network/iosxr/test_iosxr_command.py b/test/units/modules/network/iosxr/test_iosxr_command.py
index fadee0d273..fcf1efd9d3 100644
--- a/test/units/modules/network/iosxr/test_iosxr_command.py
+++ b/test/units/modules/network/iosxr/test_iosxr_command.py
@@ -45,8 +45,7 @@ class TestIosxrCommandModule(TestIosxrModule):
for item in commands:
try:
- obj = json.loads(item)
- command = obj['command']
+ command = item['command']
except ValueError:
command = item
filename = str(command).replace(' ', '_')