From d61950d48c9bdf7cf0845a074815b7569b3b90c1 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Fri, 30 Sep 2016 16:18:10 -0400 Subject: [PATCH] Fixing nxos_vpc_interface (#5032) --- .../network/nxos/nxos_vpc_interface.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/nxos/nxos_vpc_interface.py b/lib/ansible/modules/network/nxos/nxos_vpc_interface.py index 0069d0a8d6b..6e657ecd70f 100644 --- a/lib/ansible/modules/network/nxos/nxos_vpc_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vpc_interface.py @@ -777,7 +777,16 @@ def execute_config_command(commands, module): clie = get_exception() module.fail_json(msg='Error sending CLI commands', error=str(clie), commands=commands) - return output + except AttributeError: + try: + commands.insert(0, 'configure') + module.cli.add_commands(commands, output='config') + response = module.cli.run_commands() + except ShellError: + clie = get_exception() + module.fail_json(msg='Error sending CLI commands', + error=str(clie), commands=commands) + return response def get_cli_body_ssh(command, response, module): @@ -808,6 +817,19 @@ def execute_show(cmds, module, command_type=None): clie = get_exception() module.fail_json(msg='Error sending {0}'.format(cmds), 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 @@ -1062,6 +1084,8 @@ def main(): if 'error' in output.lower(): module.fail_json(msg=output.replace('\n', '')) end_state = get_portchannel_vpc_config(module, portchannel) + if 'configure' in cmds: + cmds.pop(0) results = {} results['proposed'] = proposed