Skip to content

Commit

Permalink
[Emulate legacy behavior] The return type of array of instances of Ma…
Browse files Browse the repository at this point in the history
…nagedObject should be ManagedObject[]
  • Loading branch information
ddraganov committed Jan 18, 2023
1 parent 87d4cb3 commit 797ef39
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pyVmomi/StubAdapterAccessorImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def InvokeAccessor(self, mo, info):
if replacement:
info.type = GetVmodlType(replacement)

# When the type is a list of instances of ManagedObject
# the legacy behavior was to return the base class
# e.g. The returned object type was ManagedObject[] for
# vim.Datastore[] or vim.ManagedEntity[]
if info.type.__name__.endswith("[]"):
elementTypeName = info.type.__name__[:-2]
try:
elementType = GetVmodlType(elementTypeName)
if issubclass(elementType, ManagedObject):
info.type = GetVmodlType('vmodl.ManagedObject[]')
except KeyError:
pass

info = Object(name=info.name,
type=ManagedObject,
wsdlName="Fetch",
Expand Down

0 comments on commit 797ef39

Please sign in to comment.