1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Remove get_exception from modules

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-02-06 20:18:51 +05:30 committed by Toshio Kuratomi
parent fb2c0181c5
commit 1119709b56
3 changed files with 5 additions and 23 deletions

View file

@ -86,7 +86,7 @@ changed:
"""
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_param
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
try:
from jnpr.junos import Device
@ -117,9 +117,8 @@ def connect(module):
device = Device(host, **kwargs)
device.open()
device.timeout = get_param(module, 'timeout') or 10
except ConnectError:
exc = get_exception()
module.fail_json('unable to connect to %s: %s' % (host, str(exc)))
except ConnectError as exc:
module.fail_json('unable to connect to %s: %s' % (host, to_native(exc)))
return device
@ -158,7 +157,7 @@ def main():
if not HAS_PYEZ:
module.fail_json(
msg='junos-eznc is required but does not appear to be installed. '
'It can be installed using `pip install junos-eznc`'
'It can be installed using `pip install junos-eznc`'
)
result = dict(changed=True)
@ -170,7 +169,7 @@ def main():
transfer_files(module, device)
except Exception as ex:
module.fail_json(
msg=str(ex)
msg=to_native(ex)
)
finally:
try:

View file

@ -142,7 +142,6 @@ RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import get_exception
try:
import pan.xapi

View file

@ -7,27 +7,11 @@
get_exception=$(find . -path ./test/runner/.tox -prune \
-o -path ./lib/ansible/module_utils/pycompat24.py -prune \
-o -path ./lib/ansible/module_utils/basic.py -prune \
-o -path ./lib/ansible/modules/storage/netapp -prune \
-o -path ./lib/ansible/modules/packaging/os/apt.py -prune \
-o -path ./lib/ansible/modules/packaging/os/apt_repository.py -prune \
-o -path ./lib/ansible/modules/packaging/os/yum_repository.py -prune \
-o -path ./lib/ansible/modules/network/panos -prune \
-o -path ./lib/ansible/modules/network/junos/junos_facts.py -prune \
-o -path ./lib/ansible/modules/network/junos/junos_scp.py -prune \
-o -path ./lib/ansible/modules/network/junos/junos_package.py -prune \
-o -path ./lib/ansible/modules/network/vyos/vyos_command.py -prune \
-o -path ./lib/ansible/modules/network/fortios/fortios_address.py -prune \
-o -path ./lib/ansible/modules/network/cloudengine/ce_file_copy.py -prune \
-o -path ./lib/ansible/modules/network/aos/aos_blueprint_param.py -prune \
-o -path ./lib/ansible/modules/network/aos/aos_blueprint.py -prune \
-o -path ./lib/ansible/modules/network/aos/aos_blueprint_virtnet.py -prune \
-o -path ./lib/ansible/modules/network/eos/eos_command.py -prune \
-o -path ./lib/ansible/modules/files/xattr.py -prune \
-o -path ./lib/ansible/modules/files/acl.py -prune \
-o -path ./lib/ansible/modules/system -prune \
-o -path ./lib/ansible/modules/web_infrastructure/jenkins_plugin.py -prune \
-o -path ./lib/ansible/modules/web_infrastructure/taiga_issue.py -prune \
-o -path ./lib/ansible/modules/web_infrastructure/htpasswd.py -prune \
-o -name '*.py' -type f -exec grep -H 'get_exception' '{}' '+')
basic_failed=0