mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-09 01:39:10 -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
|
@ -6,19 +6,26 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import traceback
|
||||
|
||||
REQUESTS_IMP_ERR = None
|
||||
try:
|
||||
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
|
||||
|
||||
VCLOUD_IMP_ERR = None
|
||||
try:
|
||||
from vmware.vapi.lib.connect import get_requests_connector
|
||||
from vmware.vapi.security.session import create_session_security_context
|
||||
|
@ -27,16 +34,19 @@ try:
|
|||
from com.vmware.vapi.std_client import DynamicID
|
||||
HAS_VCLOUD = True
|
||||
except ImportError:
|
||||
VCLOUD_IMP_ERR = traceback.format_exc()
|
||||
HAS_VCLOUD = False
|
||||
|
||||
VSPHERE_IMP_ERR = None
|
||||
try:
|
||||
from vmware.vapi.stdlib.client.factories import StubConfigurationFactory
|
||||
HAS_VSPHERE = True
|
||||
except ImportError:
|
||||
VSPHERE_IMP_ERR = traceback.format_exc()
|
||||
HAS_VSPHERE = False
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.basic import env_fallback, missing_required_lib
|
||||
|
||||
|
||||
class VmwareRestClient(object):
|
||||
|
@ -56,18 +66,21 @@ class VmwareRestClient(object):
|
|||
|
||||
"""
|
||||
if not HAS_REQUESTS:
|
||||
self.module.fail_json(msg="Unable to find 'requests' Python library which is required."
|
||||
" Please install using 'pip install requests'")
|
||||
self.module.fail_json(msg=missing_required_lib('requests'),
|
||||
exception=REQUESTS_IMP_ERR)
|
||||
if not HAS_PYVMOMI:
|
||||
self.module.fail_json(msg="PyVmomi Python module required. Install using 'pip install PyVmomi'")
|
||||
self.module.fail_json(msg=missing_required_lib('PyVmomi'),
|
||||
exception=PYVMOMI_IMP_ERR)
|
||||
if not HAS_VSPHERE:
|
||||
self.module.fail_json(msg="Unable to find 'vSphere Automation SDK' Python library which is required."
|
||||
" Please refer this URL for installation steps"
|
||||
" - https://code.vmware.com/web/sdk/65/vsphere-automation-python")
|
||||
self.module.fail_json(
|
||||
msg=missing_required_lib('vSphere Automation SDK',
|
||||
url='https://code.vmware.com/web/sdk/65/vsphere-automation-python'),
|
||||
exception=VSPHERE_IMP_ERR)
|
||||
if not HAS_VCLOUD:
|
||||
self.module.fail_json(msg="Unable to find 'vCloud Suite SDK' Python library which is required."
|
||||
" Please refer this URL for installation steps"
|
||||
" - https://code.vmware.com/web/sdk/60/vcloudsuite-python")
|
||||
self.module.fail_json(
|
||||
msg=missing_required_lib('vCloud Suite SDK',
|
||||
url='https://code.vmware.com/web/sdk/60/vcloudsuite-python'),
|
||||
exception=VCLOUD_IMP_ERR)
|
||||
|
||||
def connect_to_rest(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue