2013-12-13 17:02:41 -05:00
|
|
|
# VMware vSphere Python SDK
|
2015-01-10 18:49:03 -06:00
|
|
|
# Copyright (c) 2008-2015 VMware, Inc. All Rights Reserved.
|
2013-12-13 17:02:41 -05:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2014-07-24 13:21:50 -04:00
|
|
|
from __future__ import absolute_import
|
2013-12-13 17:02:41 -05:00
|
|
|
# In VmomiSupport, to support dynamic type loading, all the data types are
|
|
|
|
# wrapped around using a meta type which can intercept attribute access and
|
|
|
|
# load the necessary nested classes. This can be implemented only in python 2.5
|
|
|
|
# version or more.
|
|
|
|
import sys
|
|
|
|
if sys.version_info < (2,5):
|
|
|
|
sys.stderr.write("You need Python 2.5 or later to import pyVmomi module\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.VmomiSupport
|
|
|
|
import pyVmomi.CoreTypes
|
2015-10-05 13:54:29 -07:00
|
|
|
import pyVmomi.QueryTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
try:
|
|
|
|
import ReflectTypes
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.ServerObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.InternalServerObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Import all the known product-specific types
|
|
|
|
# XXX: Make this search the package for types?
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.DrObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.DrextObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.HbrReplicaTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.HmsObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.HostdObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.VpxObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.VorbTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.DodoTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.VmwauthproxyTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.DmsTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.OmsTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.HmoTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.CimsfccTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.TaskupdaterTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.ImgFactTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.VpxapiTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.CsiObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.HostdTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.TaggingObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.NfcTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.SmsObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.SpsObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.DataserviceObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Start of update manager specific types
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.IntegrityObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.SysimageObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
# End of update manager specific types
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.RbdTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Import Profile based management specific VMODL
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.PbmObjects
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.CisLicenseTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.TestTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.SsoTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.CisCmTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
2014-07-24 13:21:50 -04:00
|
|
|
import pyVmomi.DataserviceTypes
|
2013-12-13 17:02:41 -05:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2016-11-14 23:38:27 -08:00
|
|
|
try:
|
|
|
|
import pyVmomi.EamObjects
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2013-12-13 17:02:41 -05:00
|
|
|
|
|
|
|
# All data object types and fault types have DynamicData as an ancestor
|
|
|
|
# As well load it proactively.
|
|
|
|
# Note: This should be done before importing SoapAdapter as it uses
|
|
|
|
# some fault types
|
2014-07-24 13:21:50 -04:00
|
|
|
pyVmomi.VmomiSupport.GetVmodlType("vmodl.DynamicData")
|
2013-12-13 17:02:41 -05:00
|
|
|
|
2014-07-24 13:21:50 -04:00
|
|
|
from pyVmomi.SoapAdapter import SoapStubAdapter, StubAdapterBase, SoapCmdStubAdapter, \
|
2015-11-09 10:31:48 -08:00
|
|
|
SessionOrientedStub, ThumbprintMismatchException
|
2013-12-13 17:02:41 -05:00
|
|
|
|
2014-07-24 13:21:50 -04:00
|
|
|
types = pyVmomi.VmomiSupport.types
|
2013-12-13 17:02:41 -05:00
|
|
|
|
|
|
|
# This will allow files to use Create** functions
|
|
|
|
# directly from pyVmomi
|
2014-07-24 13:21:50 -04:00
|
|
|
CreateEnumType = pyVmomi.VmomiSupport.CreateEnumType
|
|
|
|
CreateDataType = pyVmomi.VmomiSupport.CreateDataType
|
|
|
|
CreateManagedType = pyVmomi.VmomiSupport.CreateManagedType
|
2013-12-13 17:02:41 -05:00
|
|
|
|
|
|
|
# For all the top level names, creating a LazyModule object
|
|
|
|
# in the global namespace of pyVmomi. Files can just import the
|
|
|
|
# top level namespace and we will figure out what to load and when
|
|
|
|
# Examples:
|
|
|
|
# ALLOWED: from pyVmomi import vim
|
|
|
|
# NOT ALLOWED: from pyVmomi import vim.host
|
|
|
|
_globals = globals()
|
2014-07-24 13:21:50 -04:00
|
|
|
for name in pyVmomi.VmomiSupport._topLevelNames:
|
|
|
|
upperCaseName = pyVmomi.VmomiSupport.Capitalize(name)
|
|
|
|
obj = pyVmomi.VmomiSupport.LazyModule(name)
|
2013-12-13 17:02:41 -05:00
|
|
|
_globals[name] = obj
|
2014-07-24 13:21:50 -04:00
|
|
|
if pyVmomi.VmomiSupport._allowCapitalizedNames:
|
2013-12-13 17:02:41 -05:00
|
|
|
_globals[upperCaseName] = obj
|
2014-07-24 13:21:50 -04:00
|
|
|
if not hasattr(pyVmomi.VmomiSupport.types, name):
|
|
|
|
setattr(pyVmomi.VmomiSupport.types, name, obj)
|
|
|
|
if pyVmomi.VmomiSupport._allowCapitalizedNames:
|
|
|
|
setattr(pyVmomi.VmomiSupport.types, upperCaseName, obj)
|
2013-12-13 17:02:41 -05:00
|
|
|
del _globals
|