mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Remove deprecated get_exception API
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
committed by
Brian Coca
parent
caefe31125
commit
6bd0fbb63c
@@ -81,7 +81,7 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.netconf import exec_rpc
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_param
|
||||
from ansible.module_utils.network.junos.junos import get_configuration, get_connection
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
|
||||
@@ -263,9 +263,8 @@ class Facts(FactsBase):
|
||||
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
|
||||
|
||||
@@ -286,6 +285,7 @@ class Facts(FactsBase):
|
||||
|
||||
return facts
|
||||
|
||||
|
||||
FACT_SUBSETS = dict(
|
||||
default=Default,
|
||||
hardware=Hardware,
|
||||
|
||||
@@ -103,7 +103,7 @@ EXAMPLES = """
|
||||
"""
|
||||
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
|
||||
@@ -134,9 +134,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(msg='unable to connect to %s: %s' % (host, str(exc)))
|
||||
except ConnectError as exc:
|
||||
module.fail_json(msg='unable to connect to %s: %s' % (host, to_native(exc)))
|
||||
|
||||
return device
|
||||
|
||||
|
||||
Reference in New Issue
Block a user