Use urn map for attribute resolution from top-level names

pyvmomi objects can be resolved by the vmodl name, e.g. "vim.vm.RelocateSpec"
or by the wsdl name, e.g. "vim.VirtualMachineRelocateSpec".
The wsdl name resolution uses "vim" as a hard-coded name, and doesn't
resolve more wsdl namespaces like "sms" and "pbm"
This commit is contained in:
Arnon Yaari 2014-09-14 17:31:02 +03:00
parent 841ad99118
commit f5bfaccce5
1 changed files with 5 additions and 2 deletions

View File

@ -78,6 +78,9 @@ _wsdlDefMap = {}
# if a.b.c and a.b.d are the nested classes of a.b, then _dependencyMap[a.b] = {c,d}
_dependencyMap = {}
# Map top level names to xml namespaces
_urnMap = {"vim": XMLNS_VMODL_BASE, "sms": "urn:sms", "pbm": "urn:pbm"}
## Update the dependency map
# Note: Must be holding the _lazyLock
#
@ -250,9 +253,9 @@ class LazyModule(object):
else:
if _CheckForDependency(self.name, attr):
typeObj = LazyModule(name)
elif self.name == "vim":
elif self.name in _urnMap:
try:
typeObj = GetWsdlType(XMLNS_VMODL_BASE, attr)
typeObj = GetWsdlType(_urnMap[self.name], attr)
except:
raise AttributeError(attr)
else: