From 30f78ab40cdb58d4b151b201c68d04ab75da5d6c Mon Sep 17 00:00:00 2001 From: Parth Gala Date: Wed, 2 Jul 2014 17:41:43 -0700 Subject: [PATCH] Fix SessionOrientedStub and StubAdapterAccessor --- pyVmomi/SoapAdapter.py | 2 +- pyVmomi/StubAdapterAccessorImpl.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyVmomi/SoapAdapter.py b/pyVmomi/SoapAdapter.py index e265564..398f76c 100644 --- a/pyVmomi/SoapAdapter.py +++ b/pyVmomi/SoapAdapter.py @@ -1441,10 +1441,10 @@ class SessionOrientedStub(StubAdapterBase): ''' assert callable(loginMethod) assert retryCount >= 0 + StubAdapterBase.__init__(self, version=soapStub.version) self.lock = threading.Lock() self.soapStub = soapStub - self.version = soapStub.version self.state = self.STATE_UNAUTHENTICATED self.loginMethod = loginMethod diff --git a/pyVmomi/StubAdapterAccessorImpl.py b/pyVmomi/StubAdapterAccessorImpl.py index a34bc8c..d61c23c 100644 --- a/pyVmomi/StubAdapterAccessorImpl.py +++ b/pyVmomi/StubAdapterAccessorImpl.py @@ -1,5 +1,5 @@ # VMware vSphere Python SDK -# Copyright (c) 2008-2013 VMware, Inc. All Rights Reserved. +# Copyright (c) 2008-2014 VMware, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -38,4 +38,11 @@ class StubAdapterAccessorMixin: if not self._pc: si = self._siType("ServiceInstance", self) self._pc = si.RetrieveContent().propertyCollector - return self._pc.RetrieveContents([filterSpec])[0].propSet[0].val + result = self._pc.RetrievePropertiesEx(specSet=[filterSpec], + options=self._pcType.RetrieveOptions(maxObjects=1)) + objectContent = result.objects[0] + if len(objectContent.propSet) > 0: + return objectContent.propSet[0].val + if len(objectContent.missingSet) > 0 and objectContent.missingSet[0].fault: + raise objectContent.missingSet[0].fault + return None