Fixing nxos_vlan (#5005)

* Fixing nxos_vlan

* Fixing docstring

* Fixing docstring
pull/18777/head
Gabriele 8 years ago committed by Matt Clay
parent 43632951fe
commit 67d6f2c0d6

@ -982,6 +982,15 @@ 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')
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): def get_cli_body_ssh(command, response, module):
@ -1014,6 +1023,19 @@ def execute_show(cmds, module, command_type=None):
clie = get_exception() clie = get_exception()
module.fail_json(msg='Error sending {0}'.format(command), module.fail_json(msg='Error sending {0}'.format(command),
error=str(clie)) 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 return response
@ -1069,7 +1091,6 @@ def main():
proposed_vlans_list = numerical_sort(vlan_range_to_list( proposed_vlans_list = numerical_sort(vlan_range_to_list(
vlan_id or vlan_range)) vlan_id or vlan_range))
existing_vlans_list = numerical_sort(get_list_of_vlans(module)) existing_vlans_list = numerical_sort(get_list_of_vlans(module))
commands = [] commands = []
existing = None existing = None
@ -1104,7 +1125,7 @@ def main():
end_state_vlans_list = existing_vlans_list end_state_vlans_list = existing_vlans_list
if commands: if commands:
if existing: if existing.get('mapped_vni'):
if (existing.get('mapped_vni') != proposed.get('mapped_vni') and if (existing.get('mapped_vni') != proposed.get('mapped_vni') and
existing.get('mapped_vni') != '0' and proposed.get('mapped_vni') != 'default'): existing.get('mapped_vni') != '0' and proposed.get('mapped_vni') != 'default'):
commands.insert(1, 'no vn-segment') commands.insert(1, 'no vn-segment')
@ -1115,6 +1136,8 @@ def main():
execute_config_command(commands, module) execute_config_command(commands, module)
changed = True changed = True
end_state_vlans_list = numerical_sort(get_list_of_vlans(module)) end_state_vlans_list = numerical_sort(get_list_of_vlans(module))
if 'configure' in commands:
commands.pop(0)
if vlan_id: if vlan_id:
end_state = get_vlan(vlan_id, module) end_state = get_vlan(vlan_id, module)

Loading…
Cancel
Save