Skip to content

Commit

Permalink
Added 67u3 bindings and the supporting code for it (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumahesh authored and pgbidkar committed Sep 5, 2019
1 parent fb2720c commit a603efb
Show file tree
Hide file tree
Showing 9 changed files with 455 additions and 180 deletions.
2 changes: 1 addition & 1 deletion pyVmomi/EamObjects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ******* WARNING - AUTO GENERATED CODE - DO NOT EDIT *******
from pyVmomi.VmomiSupport import CreateDataType, CreateManagedType, CreateEnumType, AddVersion, AddVersionParent, F_LINK, F_LINKABLE, F_OPTIONAL, F_SECRET
from pyVmomi.VmomiSupport import newestVersions, currentVersions, stableVersions, matureVersions, publicVersions, oldestVersions
from pyVmomi.VmomiSupport import newestVersions, stableVersions, publicVersions, oldestVersions

AddVersion("vmodl.query.version.version1", "", "", 0, "vim25")
AddVersion("vmodl.query.version.version2", "", "", 0, "vim25")
Expand Down
142 changes: 95 additions & 47 deletions pyVmomi/PbmObjects.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyVmomi/QueryTypes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ******* WARNING - AUTO GENERATED CODE - DO NOT EDIT *******
from __future__ import absolute_import
from pyVmomi.VmomiSupport import CreateDataType, CreateManagedType, CreateEnumType, AddVersion, AddVersionParent, F_LINK, F_LINKABLE, F_OPTIONAL, F_SECRET
from pyVmomi.VmomiSupport import CreateDataType, CreateManagedType, CreateEnumType
from pyVmomi.VmomiSupport import AddVersion, AddVersionParent
from pyVmomi.VmomiSupport import F_OPTIONAL
from pyVmomi.VmomiSupport import newestVersions, stableVersions, publicVersions, oldestVersions

AddVersion("vmodl.query.version.version1", "", "", 0, "vim25")
Expand Down
125 changes: 80 additions & 45 deletions pyVmomi/ServerObjects.py

Large diffs are not rendered by default.

177 changes: 128 additions & 49 deletions pyVmomi/SmsObjects.py

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion pyVmomi/SoapAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,11 @@ def __init__(self, version):
#
# @param ns the namespace
def ComputeVersionInfo(self, version):
# Make sure we do NOT fallback to an older version
if hasattr(self, 'version') and IsChildVersion(self.version, version):
# print("WARNING: stub degrading: " + self.version + " -> " + version)
return

versionNS = GetVersionNamespace(version)
if versionNS.find("/") >= 0:
self.versionId = '"urn:{0}"'.format(versionNS)
Expand Down Expand Up @@ -1336,6 +1341,7 @@ def InvokeMethod(self, mo, info, args, outerStub=None):
format(PYTHON_VERSION, OS_NAME, OS_VERSION, OS_ARCH)}
if self._acceptCompressedResponses:
headers['Accept-Encoding'] = 'gzip, deflate'

req = self.SerializeRequest(mo, info, args)
for modifier in self.requestModifierList:
req = modifier(req)
Expand Down Expand Up @@ -1495,7 +1501,7 @@ def ParseHttpResponse(httpResponse):
headerEnd = httpResponse.find(HEADER_SECTION_END)
if headerEnd == -1:
return ('', '')
headerEnd += len(HEADER_SECTION_END);
headerEnd += len(HEADER_SECTION_END)
headerText = httpResponse[:headerEnd]
bodyText = httpResponse[headerEnd:]
return (headerText, bodyText)
Expand Down
8 changes: 4 additions & 4 deletions pyVmomi/Version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

## Add an API version
def AddVersion(version, ns, versionId='', isLegacy=0, serviceNs=''):
if not ns:
ns = serviceNs
if not (version in parentMap):
if not ns:
ns = serviceNs
if version not in parentMap:
nsMap[version] = ns
if len(versionId) > 0:
versionMap[ns + '/' + versionId] = version
Expand All @@ -29,7 +29,7 @@ def AddVersion(version, ns, versionId='', isLegacy=0, serviceNs=''):
if not serviceNs:
serviceNs = ns
serviceNsMap[version] = serviceNs
parentMap[version] = {}
parentMap[version] = set()

## Check if a version is a child of another
def IsChildVersion(child, parent):
Expand Down
166 changes: 136 additions & 30 deletions pyVmomi/VmomiSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,20 @@ def UncapitalizeVmodlName(str):

## Add a parent version
def AddVersionParent(version, parent):
parentMap[version][parent] = True
parentMap[version].add(parent)

def GetVersionProps(version):
"""Get version properties
This function is a fixed version of GetVersion().
"""

ns = nsMap[version]
versionId = versionIdMap[version]
isLegacy = versionMap.get(ns) == version
serviceNs = serviceNsMap[version]
return ns, versionId, isLegacy, serviceNs


## Get version namespace from version
def GetVersionNamespace(version):
Expand All @@ -1268,6 +1281,10 @@ def GetWsdlNamespace(version):
""" Get wsdl namespace from version """
return "urn:" + serviceNsMap[version]

## Get an iterable with all version parents
def GetVersionParents(version):
return parentMap[version]

## Get all the versions for the service with specified namespace (partially) ordered
## by compatibility (i.e. any version in the list that is compatible with some version
## v in the list will preceed v)
Expand Down Expand Up @@ -1403,28 +1420,10 @@ def GetCompatibleType(type, version):
def InverseMap(map):
return dict([ (v, k) for (k, v) in iteritems(map) ])

## Support for build-time versions
class _BuildVersions:
def __init__(self):
self._verMap = {}
self._nsMap = {}

def Add(self, version):
assert '.version.' in version, 'Invalid version %s' % version

vmodlNs = version.split(".version.", 1)[0].split(".")
for idx in [1, len(vmodlNs)]:
subVmodlNs = ".".join(vmodlNs[:idx])
if not (subVmodlNs in self._verMap):
self._verMap[subVmodlNs] = version
if not (subVmodlNs in self._nsMap):
self._nsMap[subVmodlNs] = GetVersionNamespace(version)

def Get(self, vmodlNs):
return self._verMap[vmodlNs]

def GetNamespace(self, vmodlNs):
return self._nsMap[vmodlNs]
def GetVmodlNs(version):
versionParts = version.split('.version.')
assert len(versionParts) == 2, 'Unsupported version format: %s' % version
return versionParts[0]

types = Object()
nsMap = {}
Expand All @@ -1433,14 +1432,107 @@ def GetNamespace(self, vmodlNs):
serviceNsMap = { BASE_VERSION : XMLNS_VMODL_BASE.split(":")[-1] }
parentMap = {}

newestVersions = _BuildVersions()
currentVersions = _BuildVersions()
stableVersions = _BuildVersions()
matureVersions = _BuildVersions()
publicVersions = _BuildVersions()
oldestVersions = _BuildVersions()
class _MaturitySet:
"""
Registry for versions from all namespaces defining a given maturity.
The registration is automatic (relevant code is generated by emitters),
while for the query one may use either the VMODL namespace id (e.g. 'vim'),
or the wire namespace id (e.g. 'vim25').
"""
def __init__(self):
self._verNameMap = {} # e.g. 'vim' -> 'vim.version.version12'
self._verNameMapW = {} # e.g. 'vim25' -> 'vim.version.version12'
self._wireIdMap = {} # e.g. 'vim' -> 'vim25/6.7'
self._wireIdMapW = {} # e.g. 'vim25' -> 'vim25/6.7'

from pyVmomi.Version import AddVersion, IsChildVersion
def Add(self, version):
"""
Register the version at corresponding maturity for a given VMODL
namespace. The 'version' parameter is in the VMODL name format
e.g. 'vim.version.version12'. This method is typically used by
auto-generated code.
"""
vmodlNs = GetVmodlNs(version)

# TODO fix the VSAN-related part of vcenter-all to enable the assert
# assert not (vmodlNs in self._verNameMap), 'Re-definition: %s' % vmodlNs

wireId = GetVersionNamespace(version)
wireNs = wireId.split('/')[0]
self._verNameMap[vmodlNs] = version
self._verNameMapW[wireNs] = version
self._wireIdMap[vmodlNs] = wireId
self._wireIdMapW[wireNs] = wireId
return wireId, wireNs

def GetName(self, vmodlNs):
"""
VMODL namespace to registered version name mapping, e.g.
'vim' -> 'vim.version.version12'
"""
return self._verNameMap[vmodlNs]

def GetNameW(self, wireNs):
"""
Wire namespace to registered version name mapping, e.g.
'vim25' -> 'vim.version.version12'
"""
return self._verNameMapW[wireNs]

def GetWireId(self, vmodlNs):
"""
VMODL namespace to registered version wire-id mapping, e.g.
'vim' -> 'vim25/6.7'
"""
return self._wireIdMap[vmodlNs]

def GetWireIdW(self, wireNs):
"""
Wire namespace to registered version wire-id mapping, e.g.
'vim25' -> 'vim25/6.7'
"""
return self._wireIdMapW[wireNs]

def EnumerateVmodlNs(self):
"""
Returns an iterable with registered VMODL namespace, e.g.
['vim', 'vpx', ... ]
"""
return self._verNameMap.keys()

def EnumerateWireNs(self):
"""
Returns an iterable with registered wire namespace, e.g.
['vim25', 'vpxd3', ... ]
"""
return self._verNameMapW.keys()

def EnumerateVersions(self):
"""
Returns an iterable with registered VMODL versions, e.g.
['vim.version.version12', 'vpx.version.version12', ... ]
"""
return self._verNameMap.values()

def EnumerateWireIds(self):
"""
Returns an iterable with registered versions wire-ids, e.g.
e.g. ['vim25/6.7', 'vpxd3/6.7', ... ]
"""
return self._wireIdMap.values()

# Backward compatibility aliases
_MaturitySet.Get = _MaturitySet.GetName
_MaturitySet.GetNamespace = _MaturitySet.GetWireId


newestVersions = _MaturitySet()
stableVersions = _MaturitySet()
publicVersions = _MaturitySet()
dottedVersions = _MaturitySet()
oldestVersions = _MaturitySet()

from .Version import AddVersion, IsChildVersion

if not isinstance(bool, type): # bool not a type in python <= 2.2
bool = type("bool", (int,),
Expand Down Expand Up @@ -1850,3 +1942,17 @@ def ResolveLinks(keys, obj):
return None
linkResolver = LinkResolver(obj)
return linkResolver.ResolveLinks(keys)


# Dictionary of type { 'branch' : { 'namespace' : count } }
# used by Vmodl Vcdb B2B code.

_breakingChanges = {}


def AddBreakingChangesInfo(branchName, vmodlNamespace, count):
_breakingChanges.setdefault(branchName, {})[vmodlNamespace] = count


def GetBreakingChanges():
return _breakingChanges
2 changes: 1 addition & 1 deletion tests/files/test_json_host_explode.expect

Large diffs are not rendered by default.

0 comments on commit a603efb

Please sign in to comment.