pyvmomi
pyvmomi copied to clipboard
PbmQueryAssociatedProfiles() fails if pbm.version.version11 is used
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
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 =
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?