mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-05 16:04:09 -07:00
start getting modules to use shared import error code (#51787)
This commit is contained in:
parent
0924a8cf67
commit
0f0d33a954
46 changed files with 230 additions and 108 deletions
|
@ -214,18 +214,20 @@ import select
|
|||
import socket
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, load_platform_subclass
|
||||
from ansible.module_utils.basic import AnsibleModule, load_platform_subclass, missing_required_lib
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
HAS_PSUTIL = False
|
||||
PSUTIL_IMP_ERR = None
|
||||
try:
|
||||
import psutil
|
||||
HAS_PSUTIL = True
|
||||
# just because we can import it on Linux doesn't mean we will use it
|
||||
except ImportError:
|
||||
pass
|
||||
PSUTIL_IMP_ERR = traceback.format_exc()
|
||||
|
||||
|
||||
class TCPConnectionInfo(object):
|
||||
|
@ -261,7 +263,7 @@ class TCPConnectionInfo(object):
|
|||
self.port = int(self.module.params['port'])
|
||||
self.exclude_ips = self._get_exclude_ips()
|
||||
if not HAS_PSUTIL:
|
||||
module.fail_json(msg="psutil module required for wait_for")
|
||||
module.fail_json(msg=missing_required_lib('psutil'), exception=PSUTIL_IMP_ERR)
|
||||
|
||||
def _get_exclude_ips(self):
|
||||
exclude_hosts = self.module.params['exclude_hosts']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue