mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
Final round of moving modules to new import error msg (#51852)
* Final round of moving modules to new import error msg * readd URL to jenkins install guide * fix unit tests
This commit is contained in:
parent
ffbc9d99de
commit
a39c4ad464
42 changed files with 292 additions and 150 deletions
|
@ -11,25 +11,30 @@ import os
|
|||
import re
|
||||
import ssl
|
||||
import time
|
||||
import traceback
|
||||
from random import randint
|
||||
|
||||
REQUESTS_IMP_ERR = None
|
||||
try:
|
||||
# requests is required for exception handling of the ConnectionError
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError:
|
||||
REQUESTS_IMP_ERR = traceback.format_exc()
|
||||
HAS_REQUESTS = False
|
||||
|
||||
PYVMOMI_IMP_ERR = None
|
||||
try:
|
||||
from pyVim import connect
|
||||
from pyVmomi import vim, vmodl
|
||||
HAS_PYVMOMI = True
|
||||
except ImportError:
|
||||
PYVMOMI_IMP_ERR = traceback.format_exc()
|
||||
HAS_PYVMOMI = False
|
||||
|
||||
from ansible.module_utils._text import to_text, to_native
|
||||
from ansible.module_utils.six import integer_types, iteritems, string_types, raise_from
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.basic import env_fallback, missing_required_lib
|
||||
|
||||
|
||||
class TaskError(Exception):
|
||||
|
@ -776,11 +781,12 @@ class PyVmomi(object):
|
|||
Constructor
|
||||
"""
|
||||
if not HAS_REQUESTS:
|
||||
module.fail_json(msg="Unable to find 'requests' Python library which is required."
|
||||
" Please install using 'pip install requests'")
|
||||
module.fail_json(msg=missing_required_lib('requests'),
|
||||
exception=REQUESTS_IMP_ERR)
|
||||
|
||||
if not HAS_PYVMOMI:
|
||||
module.fail_json(msg='PyVmomi Python module required. Install using "pip install PyVmomi"')
|
||||
module.fail_json(msg=missing_required_lib('PyVmomi'),
|
||||
exception=PYVMOMI_IMP_ERR)
|
||||
|
||||
self.module = module
|
||||
self.params = module.params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue