mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Convert the network subfolder to py3/py2.4 syntax (#3690)
This commit is contained in:
parent
09066f1518
commit
c0217e14a7
20 changed files with 90 additions and 47 deletions
|
@ -147,7 +147,8 @@ def main():
|
|||
queue = set()
|
||||
for entry in (module.params['waitfor'] or list()):
|
||||
queue.add(Conditional(entry))
|
||||
except AttributeError, exc:
|
||||
except AttributeError:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
result = dict(changed=False, result=list())
|
||||
|
@ -164,7 +165,8 @@ def main():
|
|||
if cmd.endswith('json'):
|
||||
try:
|
||||
response[index] = module.from_json(response[index])
|
||||
except ValueError, exc:
|
||||
except ValueError:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg='failed to parse json response',
|
||||
exc_message=str(exc), response=response[index],
|
||||
cmd=cmd, response_dict=response)
|
||||
|
|
|
@ -66,7 +66,8 @@ def execute_show(cmds, module, command_type=None):
|
|||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(command),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
|
|
@ -89,7 +89,8 @@ feature:
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -114,9 +115,12 @@ def get_cli_body_ssh(command, response):
|
|||
|
||||
def execute_show(cmds, module, command_type=None):
|
||||
try:
|
||||
response = module.execute(cmds,
|
||||
command_type=command_type) if command_type else module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
if command_type:
|
||||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(cmds),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -267,4 +271,4 @@ from ansible.module_utils.shell import *
|
|||
from ansible.module_utils.netcfg import *
|
||||
from ansible.module_utils.nxos import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -525,7 +525,8 @@ def smart_existing(module, intf_type, normalized_interface):
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -556,7 +557,8 @@ def execute_show(cmds, module, command_type=None):
|
|||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(command),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -715,4 +717,4 @@ from ansible.module_utils.netcfg import *
|
|||
from ansible.module_utils.nxos import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -102,7 +102,8 @@ changed:
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -134,7 +135,8 @@ def execute_show(cmds, module, command_type=None):
|
|||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(cmds),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -523,4 +525,4 @@ from ansible.module_utils.shell import *
|
|||
from ansible.module_utils.netcfg import *
|
||||
from ansible.module_utils.nxos import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -150,7 +150,8 @@ def execute_show(cmds, module, command_type=None):
|
|||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(cmds),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -257,4 +258,4 @@ from ansible.module_utils.shell import *
|
|||
from ansible.module_utils.netcfg import *
|
||||
from ansible.module_utils.nxos import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -440,7 +440,8 @@ def apply_value_map(value_map, resource):
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -465,8 +466,12 @@ def get_cli_body_ssh(command, response, module):
|
|||
|
||||
def execute_show(cmds, module, command_type=None):
|
||||
try:
|
||||
response = module.execute(cmds, command_type=command_type) if command_type else module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
if command_type:
|
||||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(command),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -627,4 +632,4 @@ from ansible.module_utils.netcfg import *
|
|||
from ansible.module_utils.nxos import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -280,7 +280,8 @@ def apply_value_map(value_map, resource):
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -305,8 +306,12 @@ def get_cli_body_ssh(command, response, module):
|
|||
|
||||
def execute_show(cmds, module, command_type=None):
|
||||
try:
|
||||
response = module.execute(cmds, command_type=command_type) if command_type else module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
if command_type:
|
||||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(command),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -424,4 +429,4 @@ from ansible.module_utils.netcfg import *
|
|||
from ansible.module_utils.nxos import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -104,7 +104,8 @@ changed:
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -129,9 +130,12 @@ def get_cli_body_ssh_vrf(command, response):
|
|||
|
||||
def execute_show(cmds, module, command_type=None):
|
||||
try:
|
||||
response = module.execute(cmds,
|
||||
command_type=command_type) if command_type else module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
if command_type:
|
||||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(cmds),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -307,4 +311,4 @@ from ansible.module_utils.shell import *
|
|||
from ansible.module_utils.netcfg import *
|
||||
from ansible.module_utils.nxos import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -92,7 +92,8 @@ changed:
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -118,7 +119,8 @@ def execute_show(cmds, module, command_type=None):
|
|||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(command),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
|
|
@ -116,7 +116,8 @@ changed:
|
|||
def execute_config_command(commands, module):
|
||||
try:
|
||||
module.configure(commands)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending CLI commands',
|
||||
error=str(clie), commands=commands)
|
||||
|
||||
|
@ -149,7 +150,8 @@ def execute_show(cmds, module, command_type=None):
|
|||
response = module.execute(cmds, command_type=command_type)
|
||||
else:
|
||||
response = module.execute(cmds)
|
||||
except ShellError, clie:
|
||||
except ShellError:
|
||||
clie = get_exception()
|
||||
module.fail_json(msg='Error sending {0}'.format(command),
|
||||
error=str(clie))
|
||||
return response
|
||||
|
@ -422,4 +424,4 @@ from ansible.module_utils.shell import *
|
|||
from ansible.module_utils.netcfg import *
|
||||
from ansible.module_utils.nxos import *
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue