From b6c07bc9e9ade341e11c354a4bcb7d45ddc27666 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Sat, 1 Oct 2016 20:34:21 -0400 Subject: [PATCH] Fixing nxos_hsrp (#5009) * Fixing nxos_hsrp * Adding space after = --- lib/ansible/modules/network/nxos/nxos_hsrp.py | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_hsrp.py b/lib/ansible/modules/network/nxos/nxos_hsrp.py index 7967aac7b2c..1387bab42e2 100644 --- a/lib/ansible/modules/network/nxos/nxos_hsrp.py +++ b/lib/ansible/modules/network/nxos/nxos_hsrp.py @@ -798,11 +798,21 @@ def load_config(module, candidate): def execute_config_command(commands, module): try: - body = module.configure(commands) - except ShellError, clie: + output = module.configure(commands) + except ShellError: + clie = get_exception() module.fail_json(msg='Error sending CLI commands', error=str(clie), commands=commands) - return body + except AttributeError: + try: + commands.insert(0, 'configure') + module.cli.add_commands(commands, output='config') + output = module.cli.run_commands() + except ShellError: + clie = get_exception() + module.fail_json(msg='Error sending CLI commands', + error=str(clie), commands=commands) + return output def get_cli_body_ssh(command, response, module): @@ -837,6 +847,19 @@ def execute_show(cmds, module, command_type=None): clie = get_exception() module.fail_json(msg='Error sending {0}'.format(command), error=str(clie)) + except AttributeError: + try: + if command_type: + command_type = command_type_map.get(command_type) + module.cli.add_commands(cmds, output=command_type) + response = module.cli.run_commands() + else: + module.cli.add_commands(cmds, raw=True) + response = module.cli.run_commands() + except ShellError: + clie = get_exception() + module.fail_json(msg='Error sending {0}'.format(cmds), + error=str(clie)) return response @@ -1174,6 +1197,8 @@ def main(): validate_config(body, vip, module) changed = True end_state = get_hsrp_group(group, interface, module) + if 'configure' in commands: + commands.pop(0) results = {} results['proposed'] = proposed