From 2f55841037c6632f6e49193ad2d052b4288d92f9 Mon Sep 17 00:00:00 2001 From: Alexandru Bleotu Date: Thu, 21 Sep 2017 12:13:08 -0400 Subject: [PATCH] Added python/pyvmomi compatibility check to salt.modules.vsphere --- salt/modules/vsphere.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/salt/modules/vsphere.py b/salt/modules/vsphere.py index ca3bc13b77..0d02de55fd 100644 --- a/salt/modules/vsphere.py +++ b/salt/modules/vsphere.py @@ -193,7 +193,7 @@ except ImportError: HAS_JSONSCHEMA = False try: - from pyVmomi import vim, vmodl + from pyVmomi import vim, vmodl, VmomiSupport HAS_PYVMOMI = True except ImportError: HAS_PYVMOMI = False @@ -211,6 +211,17 @@ __proxyenabled__ = ['esxi', 'esxcluster', 'esxdatacenter'] def __virtual__(): + if not HAS_JSONSCHEMA: + return False, 'Execution module did not load: jsonschema not found' + if not HAS_PYVMOMI: + return False, 'Execution module did not load: pyVmomi not found' + + # We check the supported vim versions to infer the pyVmomi version + if 'vim25/6.0' in VmomiSupport.versionMap and \ + sys.version_info > (2, 7) and sys.version_info < (2, 7, 9): + + return False, ('Execution module did not load: Incompatible versions ' + 'of Python and pyVmomi present. See Issue #29537.') return __virtualname__