vmware / vmware/pyvmomi

PbmQueryAssociatedProfiles() fails if pbm.version.version11 is used

Open
#942 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs verification
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

The following code:

    self._pbm_connect()
    profileManager = self.pbmSI.RetrieveContent().profileManager
    for vm in VMs:
        VMs_by_key[vm._moId]=vm
        pbmRef = pbm.ServerObjectRef(key=vm._moId,
                                     objectType=pbm.ServerObjectRef.ObjectType('virtualMachine'))
        pbmRefs.append(pbmRef)

    results = profileManager.PbmQueryAssociatedProfiles(entities=pbmRefs)
    print(results)

def _pbm_connect(self):
    if self.pbmSI is not None:
        return

    self._pyvmomi_connect()
    VmomiSupport.GetRequestContext()["vcSessionCookie"] = self.si._stub.cookie.split('"')[1]
    hostname = self.si._stub.host.split(":")[0]
    pbmStub = SoapStubAdapter(
        host=hostname,
        version="pbm.version.version11",
        path="/pbm/sdk",
        poolSize=0,
        sslContext=ssl._create_unverified_context())
    pbmServiceInstance = pbm.ServiceInstance("ServiceInstance", pbmStub)

    self.pbmSI = pbmServiceInstance

It fails with:

...
results = profileManager.PbmQueryAssociatedProfiles(entities=pbmRefs)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/VmomiSupport.py", line 706, in
self.f(*(self.args + (obj,) + args), **kwargs)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 1388, in InvokeMethod
raise exc
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 1378, in InvokeMethod
obj = deserializer.Deserialize(fd, info.result)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 845, in Deserialize
ParseData(self.parser, response)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 525, in ParseData
reraise(ParserError, pe, tb)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 514, in ParseData
parser.ParseFile(data)
File "/builddir/build/BUILD/Python-3.7.5/Modules/pyexpat.c", line 417, in StartElement
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 692, in StartElementHandler
dynType = self.LookupWsdlType(ns, name, allowManagedObjectReference=True)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/SoapAdapter.py", line 657, in LookupWsdlType
return GuessWsdlType(name)
File "/var/tmp/hdb-tool_venv/lib64/python3.7/site-packages/pyVmomi/VmomiSupport.py", line 1192, in GuessWsdlType
raise UnknownWsdlTypeError(name)
pyVmomi.SoapAdapter.ParserError: 'xml document: <http.client.HTTPResponse object at 0x7ff02fc73710> parse error at: line:1, col:420'

However, if in _pbm_connect() I change the version string to "pbm.version.version11" then it works and returns a result:

(pbm.profile.QueryProfileResult) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
object = (pbm.ServerObjectRef) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
objectType = 'virtualMachine',
key = 'vm-1009',
serverUuid = 'ae90771a-6504-4090-b241-0c1d7543cad3'
},
profileId = (pbm.profile.ProfileId) [
(pbm.profile.ProfileId) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
uniqueId = '7c530cad-bf0c-4187-b77c-0f81b0b8f22c'
}
],
fault =
}

But then version1 breaks some other calls which require version11.
Do I need to obtain and use different pbm handle with different version used for different call?
Or should the PbmQueryAssociatedProfiles() call work with version11?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in _pbm_connect() and trace SoapStubAdapter version handling into PbmQueryAssociatedProfiles, using the supplied ParserError traceback and the contrasting pbm.version.version1 and pbm.version.version11 results. Determine whether the call should support version11 or requires separate PBM handles, then add or update coverage demonstrating the affected call versions and preserving the other calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.