From a01aa6e9df1ff2d9399401ad6d1f2ce2a8fb9da0 Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Mon, 14 Aug 2017 03:04:05 -0400 Subject: [PATCH] Fix structured output not supported in nxos_pim_interface (#28125) * fixed unstructured error * fix unit tests so they accept commands in dictionary form --- .../modules/network/nxos/nxos_pim_interface.py | 13 ++++++++++--- .../modules/network/nxos/test_nxos_pim_interface.py | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_pim_interface.py b/lib/ansible/modules/network/nxos/nxos_pim_interface.py index 6be6cdb8a9..07801c64ae 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_pim_interface.py @@ -170,10 +170,17 @@ PARAM_TO_COMMAND_KEYMAP = { def execute_show_command(command, module, text=False): - if text is False: - command += ' | json' + if text: + cmds = [{ + 'command': command, + 'output': 'text' + }] + else: + cmds = [{ + 'command': command, + 'output': 'json' + }] - cmds = [command] return run_commands(module, cmds) diff --git a/test/units/modules/network/nxos/test_nxos_pim_interface.py b/test/units/modules/network/nxos/test_nxos_pim_interface.py index e3ad7b45b9..a7b5e2489a 100644 --- a/test/units/modules/network/nxos/test_nxos_pim_interface.py +++ b/test/units/modules/network/nxos/test_nxos_pim_interface.py @@ -47,6 +47,8 @@ class TestNxosIPInterfaceModule(TestNxosModule): output = list() for command in commands: + if type(command) == dict: + command = command['command'] filename = str(command).split(' | ')[0].replace(' ', '_').replace('/', '_') output.append(load_fixture(module_name, filename)) return output