From 9ff6070eb85d94fdc95ef3441f35be34b00305c0 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Fri, 30 Sep 2016 16:17:21 -0400 Subject: [PATCH] Fixing nxos_vrf_interface (#5034) --- .../network/nxos/nxos_vrf_interface.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py index df273bca56..3d5daa8f6c 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py @@ -770,6 +770,15 @@ def execute_config_command(commands, module): clie = get_exception() module.fail_json(msg='Error sending CLI commands', error=str(clie), commands=commands) + except AttributeError: + try: + commands.insert(0, 'configure') + module.cli.add_commands(commands, output='config') + module.cli.run_commands() + except ShellError: + clie = get_exception() + module.fail_json(msg='Error sending CLI commands', + error=str(clie), commands=commands) def get_cli_body_ssh_vrf_interface(command, response, module): @@ -797,6 +806,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 @@ -964,6 +986,8 @@ def main(): changed = True changed_vrf = get_interface_info(interface, module) end_state = dict(interface=interface, vrf=changed_vrf) + if 'configure' in commands: + commands.pop(0) results = {} results['proposed'] = proposed