mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
nxos_smu: fix Structured output unsupported error in nxapi (#27976)
* fixed structured output unsupported error
This commit is contained in:
parent
e8f1c1511c
commit
d0485779e8
1 changed files with 27 additions and 18 deletions
|
@ -88,18 +88,18 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
import time
|
import time
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
import re
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def execute_show_command(command, module, command_type='cli_show'):
|
def execute_show_command(command, module, command_type='cli_show'):
|
||||||
if module.params['transport'] == 'cli':
|
if command_type == 'cli_show_ascii':
|
||||||
|
cmds = [{
|
||||||
|
'command': command,
|
||||||
|
'output': 'text',
|
||||||
|
}]
|
||||||
|
else:
|
||||||
cmds = [command]
|
cmds = [command]
|
||||||
body = run_commands(module, cmds)
|
|
||||||
elif module.params['transport'] == 'nxapi':
|
|
||||||
cmds = [command]
|
|
||||||
body = run_commands(module, cmds)
|
|
||||||
|
|
||||||
return body
|
return run_commands(module, cmds)
|
||||||
|
|
||||||
|
|
||||||
def remote_file_exists(module, dst, file_system='bootflash:'):
|
def remote_file_exists(module, dst, file_system='bootflash:'):
|
||||||
|
@ -122,11 +122,18 @@ def get_commands(module, pkg, file_system):
|
||||||
fixed_pkg = '.'.join(splitted_pkg[0:-1])
|
fixed_pkg = '.'.join(splitted_pkg[0:-1])
|
||||||
|
|
||||||
command = 'show install inactive'
|
command = 'show install inactive'
|
||||||
inactive_body = execute_show_command(command, module,
|
inactive_body = execute_show_command(
|
||||||
command_type='cli_show_ascii')
|
command,
|
||||||
|
module,
|
||||||
|
command_type='cli_show_ascii'
|
||||||
|
)
|
||||||
|
|
||||||
command = 'show install active'
|
command = 'show install active'
|
||||||
active_body = execute_show_command(command, module,
|
active_body = execute_show_command(
|
||||||
command_type='cli_show_ascii')
|
command,
|
||||||
|
module,
|
||||||
|
command_type='cli_show_ascii'
|
||||||
|
)
|
||||||
|
|
||||||
if fixed_pkg not in inactive_body[0] and fixed_pkg not in active_body[0]:
|
if fixed_pkg not in inactive_body[0] and fixed_pkg not in active_body[0]:
|
||||||
commands.append('install add {0}{1}'.format(file_system, pkg))
|
commands.append('install add {0}{1}'.format(file_system, pkg))
|
||||||
|
@ -167,8 +174,9 @@ def main():
|
||||||
remote_exists = remote_file_exists(module, pkg, file_system=file_system)
|
remote_exists = remote_file_exists(module, pkg, file_system=file_system)
|
||||||
|
|
||||||
if not remote_exists:
|
if not remote_exists:
|
||||||
module.fail_json(msg="The requested package doesn't exist "
|
module.fail_json(
|
||||||
"on the device")
|
msg="The requested package doesn't exist on the device"
|
||||||
|
)
|
||||||
|
|
||||||
commands = get_commands(module, pkg, file_system)
|
commands = get_commands(module, pkg, file_system)
|
||||||
if not module.check_mode and commands:
|
if not module.check_mode and commands:
|
||||||
|
@ -178,12 +186,13 @@ def main():
|
||||||
if 'configure' in commands:
|
if 'configure' in commands:
|
||||||
commands.pop(0)
|
commands.pop(0)
|
||||||
|
|
||||||
module.exit_json(changed=changed,
|
module.exit_json(
|
||||||
pkg=pkg,
|
changed=changed,
|
||||||
file_system=file_system,
|
pkg=pkg,
|
||||||
updates=commands)
|
file_system=file_system,
|
||||||
|
updates=commands
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue