Skip to content

Commit 4ff745d

Browse files
Alexandru BleotuAlexandru Bleotu
authored andcommitted
Added python/pyvmomi compatibility check to salt.states.pbm + removed reference to Python 2.6
1 parent e1bfe24 commit 4ff745d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

salt/states/pbm.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,34 @@
9797
from __future__ import absolute_import
9898
import logging
9999
import copy
100+
import sys
100101

101102
# Import Salt Libs
102103
from salt.exceptions import CommandExecutionError, ArgumentValueError
103104
from salt.utils.dictdiffer import recursive_diff
104105
from salt.utils.listdiffer import list_diff
105106

107+
# External libraries
108+
try:
109+
from pyVmomi import VmomiSupport
110+
HAS_PYVMOMI = True
111+
except ImportError:
112+
HAS_PYVMOMI = False
113+
106114
# Get Logging Started
107115
log = logging.getLogger(__name__)
108-
# TODO change with vcenter
109-
ALLOWED_PROXY_TYPES = ['esxcluster', 'vcenter']
110-
LOGIN_DETAILS = {}
111116

112117

113118
def __virtual__():
119+
if not HAS_PYVMOMI:
120+
return False, 'State module did not load: pyVmomi not found'
121+
122+
# We check the supported vim versions to infer the pyVmomi version
123+
if 'vim25/6.0' in VmomiSupport.versionMap and \
124+
sys.version_info > (2, 7) and sys.version_info < (2, 7, 9):
125+
126+
return False, ('State module did not load: Incompatible versions '
127+
'of Python and pyVmomi present. See Issue #29537.')
114128
return True
115129

116130

0 commit comments

Comments
 (0)