|
|
@ -94,6 +94,23 @@ from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_arg
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute_show_command(module, command):
|
|
|
|
|
|
|
|
format = 'json'
|
|
|
|
|
|
|
|
cmds = [{
|
|
|
|
|
|
|
|
'command': command,
|
|
|
|
|
|
|
|
'output': format,
|
|
|
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
output = run_commands(module, cmds, False)
|
|
|
|
|
|
|
|
if len(output) == 0 or len(output[0]) == 0:
|
|
|
|
|
|
|
|
# If we get here the platform does not
|
|
|
|
|
|
|
|
# support structured output. Resend as
|
|
|
|
|
|
|
|
# text.
|
|
|
|
|
|
|
|
cmds[0]['output'] = 'text'
|
|
|
|
|
|
|
|
output = run_commands(module, cmds, False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def map_obj_to_commands(want, have, module):
|
|
|
|
def map_obj_to_commands(want, have, module):
|
|
|
|
commands = list()
|
|
|
|
commands = list()
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
@ -111,7 +128,8 @@ def map_obj_to_commands(want, have, module):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def map_config_to_obj(module):
|
|
|
|
def map_config_to_obj(module):
|
|
|
|
output = run_commands(module, ['show banner %s' % module.params['banner']], False)[0]
|
|
|
|
command = 'show banner %s' % module.params['banner']
|
|
|
|
|
|
|
|
output = execute_show_command(module, command)[0]
|
|
|
|
|
|
|
|
|
|
|
|
if "Invalid command" in output:
|
|
|
|
if "Invalid command" in output:
|
|
|
|
module.fail_json(msg="banner: exec may not be supported on this platform. Possible values are : exec | motd")
|
|
|
|
module.fail_json(msg="banner: exec may not be supported on this platform. Possible values are : exec | motd")
|
|
|
@ -128,6 +146,8 @@ def map_config_to_obj(module):
|
|
|
|
output = output[0]
|
|
|
|
output = output[0]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
output = ''
|
|
|
|
output = ''
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
output = output.rstrip()
|
|
|
|
|
|
|
|
|
|
|
|
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
|
|
|
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
|
|
|
if output:
|
|
|
|
if output:
|
|
|
|