Fixing nxos_portchannel

This commit is contained in:
GGabriele 2016-09-19 14:27:00 +02:00
parent 8886afd145
commit 5174e3f31f

View file

@ -18,7 +18,6 @@
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: nxos_portchannel module: nxos_portchannel
version_added: "2.2" version_added: "2.2"
short_description: Manages port-channel interfaces. short_description: Manages port-channel interfaces.
@ -107,14 +106,14 @@ end_state:
"Ethernet2/5": {"mode": "on", "status": "D"}, "Ethernet2/5": {"mode": "on", "status": "D"},
"Ethernet2/6": {"mode": "on", "status": "D"}}, "Ethernet2/6": {"mode": "on", "status": "D"}},
"min_links": null, "mode": "on"} "min_links": null, "mode": "on"}
commands: updates:
description: command string sent to the device description: command sent to the device
returned: always returned: always
type: string type: list
sample: "interface Ethernet2/6 ; no channel-group 12 ; sample: ["interface Ethernet2/6", "no channel-group 12",
interface Ethernet2/5 ; no channel-group 12 ; "interface Ethernet2/5", "no channel-group 12",
interface Ethernet2/6 ; channel-group 12 mode on ; "interface Ethernet2/6", "channel-group 12 mode on",
interface Ethernet2/5 ; channel-group 12 mode on ;" "interface Ethernet2/5", "channel-group 12 mode on"
changed: changed:
description: check to see if a change was made on the device description: check to see if a change was made on the device
returned: always returned: always
@ -330,12 +329,24 @@ def execute_config_command(commands, module):
clie = get_exception() clie = get_exception()
module.fail_json(msg='Error sending CLI commands', module.fail_json(msg='Error sending CLI commands',
error=str(clie), commands=commands) error=str(clie), commands=commands)
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 return output
def get_cli_body_ssh(command, response, module): def get_cli_body_ssh(command, response, module):
try: try:
if isinstance(response[0], str):
body = [json.loads(response[0])] body = [json.loads(response[0])]
else:
body = response
except ValueError: except ValueError:
module.fail_json(msg='Command does not support JSON output', module.fail_json(msg='Command does not support JSON output',
command=command) command=command)
@ -714,12 +725,13 @@ def main():
output = execute_config_command(cmds, module) output = execute_config_command(cmds, module)
changed = True changed = True
end_state, interface_exist = get_existing(module, args) end_state, interface_exist = get_existing(module, args)
if 'configure' in cmds:
cmds.pop(0)
results = {} results = {}
results['proposed'] = proposed results['proposed'] = proposed
results['existing'] = existing results['existing'] = existing
results['end_state'] = end_state results['end_state'] = end_state
results['state'] = state
results['updates'] = cmds results['updates'] = cmds
results['changed'] = changed results['changed'] = changed