summaryrefslogtreecommitdiff
path: root/oslo_vmware/pbm.py
diff options
context:
space:
mode:
authorJohannes Kulik <johannes.kulik@sap.com>2020-05-07 14:03:41 +0200
committerJohannes Kulik <johannes.kulik@sap.com>2020-07-09 12:16:32 +0200
commit32c8d43a20cb6a29f03324fbc2e6cad3bfb5a294 (patch)
treee72332b0ee9e39fe2fb54f845050db7959a24163 /oslo_vmware/pbm.py
parent89e1612cb22887370bce14bbea5574e34b014c3c (diff)
downloadoslo-vmware-32c8d43a20cb6a29f03324fbc2e6cad3bfb5a294.tar.gz
Add moref helper functions3.5.0
Since the attribute access on a ManagedObjectReference can differ depending on the SOAP library used in the backend, we and especially depending projects should not rely on it, because that breaks the abstraction layer oslo.vmware is supposed to provide. To help transitioning to a newer backend library, we introduce two methods for retrieving a ManagedObjectReference's value and type: get_moref_value() and get_moref_type(). We cannot handle this by just returning our own ManagedObjectReference object with uniform access, because it's hard to get control of all morefs returned by the API. In that spirit, we also change all references inside of oslo_vmware to using `get_moref_value()` and `get_moref_type()` instead of directly accessing the attributes. This is part of phase 1 of https://specs.openstack.org/openstack/oslo-specs/specs/victoria/oslo-vmware-soap-library-switch.html Change-Id: I0b0a3d37f6c7d0c750b48596bc3d79b8b2cb0cee
Diffstat (limited to 'oslo_vmware/pbm.py')
-rw-r--r--oslo_vmware/pbm.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/oslo_vmware/pbm.py b/oslo_vmware/pbm.py
index c0a92ab..84c6d3a 100644
--- a/oslo_vmware/pbm.py
+++ b/oslo_vmware/pbm.py
@@ -161,7 +161,7 @@ def convert_datastores_to_hubs(pbm_client_factory, datastores):
hubs = []
for ds in datastores:
hub = pbm_client_factory.create('ns0:PbmPlacementHub')
- hub.hubId = ds.value
+ hub.hubId = vim_util.get_moref_value(ds)
hub.hubType = 'Datastore'
hubs.append(hub)
return hubs
@@ -177,7 +177,7 @@ def filter_datastores_by_hubs(hubs, datastores):
filtered_dss = []
hub_ids = [hub.hubId for hub in hubs]
for ds in datastores:
- if ds.value in hub_ids:
+ if vim_util.get_moref_value(ds) in hub_ids:
filtered_dss.append(ds)
return filtered_dss
@@ -216,7 +216,7 @@ def get_profiles(session, vm):
profile_manager = pbm.service_content.profileManager
object_ref = pbm.client.factory.create('ns0:PbmServerObjectRef')
- object_ref.key = vm.value
+ object_ref.key = vim_util.get_moref_value(vm)
object_ref.objectType = 'virtualMachine'
return session.invoke_api(pbm, 'PbmQueryAssociatedProfile',