From c47fd4b3e97e7519e7af8746951fde8bbbfafbf6 Mon Sep 17 00:00:00 2001 From: GGabriele Date: Mon, 19 Sep 2016 18:50:05 +0200 Subject: [PATCH] Add feature mappings --- .../modules/network/nxos/nxos_feature.py | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_feature.py b/lib/ansible/modules/network/nxos/nxos_feature.py index bcf03003644..9752e10fe47 100644 --- a/lib/ansible/modules/network/nxos/nxos_feature.py +++ b/lib/ansible/modules/network/nxos/nxos_feature.py @@ -774,6 +774,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(command, response, module): @@ -890,11 +899,30 @@ def validate_feature(module, mode='show'): feature_to_be_mapped = { 'show': { 'nv overlay': 'nve', - 'vn-segment-vlan-based': 'vnseg_vlan'}, + 'vn-segment-vlan-based': 'vnseg_vlan', + 'hsrp': 'hsrp_engine', + 'fabric multicast': 'fabric_mcast', + 'scp-server': 'scpServer', + 'sftp-server': 'sftpServer', + 'sla responder': 'sla_responder', + 'sla sender': 'sla_sender', + 'ssh': 'sshServer', + 'tacacs+': 'tacacs', + 'telnet': 'telnetServer'}, 'config': { 'nve': 'nv overlay', - 'vnseg_vlan': 'vn-segment-vlan-based'} + 'vnseg_vlan': 'vn-segment-vlan-based', + 'hsrp_engine': 'hsrp', + 'fabric_mcast': 'fabric multicast', + 'scpServer': 'scp-server', + 'sftpServer': 'sftp-server', + 'sla_sender': 'sla sender', + 'sla_responder': 'sla responder', + 'sshServer': 'ssh', + 'tacacs': 'tacacs+', + 'telnetServer': 'telnet', + } } if feature in feature_to_be_mapped[mode]: @@ -941,6 +969,8 @@ def main(): updated_features = get_available_features(feature, module) existstate = updated_features[feature] end_state = dict(state=existstate) + if 'configure' in cmds: + cmds.pop(0) results = {} results['proposed'] = proposed