Browse Source

Merge "vmware: Use oslo.vmware's get_moref_value()"

changes/71/788471/3
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
370e322d73
8 changed files with 24 additions and 17 deletions
  1. +1
    -1
      lower-constraints.txt
  2. +2
    -1
      nova/virt/vmwareapi/driver.py
  3. +4
    -4
      nova/virt/vmwareapi/ds_util.py
  4. +2
    -2
      nova/virt/vmwareapi/imagecache.py
  5. +6
    -3
      nova/virt/vmwareapi/vm_util.py
  6. +7
    -4
      nova/virt/vmwareapi/vmops.py
  7. +1
    -1
      nova/virt/vmwareapi/volumeops.py
  8. +1
    -1
      test-requirements.txt

+ 1
- 1
lower-constraints.txt View File

@ -85,7 +85,7 @@ oslo.service==2.5.0
oslo.upgradecheck==1.3.0
oslo.utils==4.8.0
oslo.versionedobjects==1.35.0
oslo.vmware==2.17.0
oslo.vmware==3.6.0
oslotest==3.8.0
osprofiler==1.4.0
ovs==2.10.0


+ 2
- 1
nova/virt/vmwareapi/driver.py View File

@ -136,7 +136,8 @@ class VMwareVCDriver(driver.ComputeDriver):
"found in vCenter")
% self._cluster_name)
self._vcenter_uuid = self._get_vcenter_uuid()
self._nodename = self._create_nodename(self._cluster_ref.value)
self._nodename = \
self._create_nodename(vim_util.get_moref_value(self._cluster_ref))
self._volumeops = volumeops.VMwareVolumeOps(self._session,
self._cluster_ref)
self._vmops = vmops.VMwareVMOps(self._session,


+ 4
- 4
nova/virt/vmwareapi/ds_util.py View File

@ -470,7 +470,7 @@ def _update_datacenter_cache_from_objects(session, dcs):
if datastore_refs:
datastore_refs = datastore_refs.ManagedObjectReference
for ds in datastore_refs:
ds_refs.append(ds.value)
ds_refs.append(vutil.get_moref_value(ds))
else:
LOG.debug("Datacenter %s doesn't have any datastore "
"associated with it, ignoring it", name)
@ -481,12 +481,12 @@ def _update_datacenter_cache_from_objects(session, dcs):
def get_dc_info(session, ds_ref):
"""Get the datacenter name and the reference."""
dc_info = _DS_DC_MAPPING.get(ds_ref.value)
dc_info = _DS_DC_MAPPING.get(vutil.get_moref_value(ds_ref))
if not dc_info:
dcs = session._call_method(vim_util, "get_objects",
"Datacenter", ["name", "datastore", "vmFolder"])
_update_datacenter_cache_from_objects(session, dcs)
dc_info = _DS_DC_MAPPING.get(ds_ref.value)
dc_info = _DS_DC_MAPPING.get(vutil.get_moref_value(ds_ref))
return dc_info
@ -509,6 +509,6 @@ def get_connected_hosts(session, datastore):
connected_hosts = []
for host_mount in host_mounts.DatastoreHostMount:
connected_hosts.append(host_mount.key.value)
connected_hosts.append(vutil.get_moref_value(host_mount.key))
return connected_hosts

+ 2
- 2
nova/virt/vmwareapi/imagecache.py View File

@ -116,12 +116,12 @@ class ImageCacheManager(imagecache.ImageCacheManager):
return timeutils.parse_strtime(ts, fmt=TIMESTAMP_FORMAT)
def _get_ds_browser(self, ds_ref):
ds_browser = self._ds_browser.get(ds_ref.value)
ds_browser = self._ds_browser.get(vutil.get_moref_value(ds_ref))
if not ds_browser:
ds_browser = vutil.get_object_property(self._session.vim,
ds_ref,
"browser")
self._ds_browser[ds_ref.value] = ds_browser
self._ds_browser[vutil.get_moref_value(ds_ref)] = ds_browser
return ds_browser
def _list_datastore_images(self, ds_path, datastore):


+ 6
- 3
nova/virt/vmwareapi/vm_util.py View File

@ -1623,15 +1623,18 @@ def create_folder(session, parent_folder_ref, name):
"""
LOG.debug("Creating folder: %(name)s. Parent ref: %(parent)s.",
{'name': name, 'parent': parent_folder_ref.value})
{'name': name,
'parent': vutil.get_moref_value(parent_folder_ref)})
try:
folder = session._call_method(session.vim, "CreateFolder",
parent_folder_ref, name=name)
LOG.info("Created folder: %(name)s in parent %(parent)s.",
{'name': name, 'parent': parent_folder_ref.value})
{'name': name,
'parent': vutil.get_moref_value(parent_folder_ref)})
except vexc.DuplicateName as e:
LOG.debug("Folder already exists: %(name)s. Parent ref: %(parent)s.",
{'name': name, 'parent': parent_folder_ref.value})
{'name': name,
'parent': vutil.get_moref_value(parent_folder_ref)})
val = e.details['object']
folder = vutil.get_moref(val, 'Folder')
return folder


+ 7
- 4
nova/virt/vmwareapi/vmops.py View File

@ -1583,8 +1583,9 @@ class VMwareVMOps(object):
ds_hosts = self._session._call_method(vutil, 'get_object_property',
ds_ref, 'host')
for ds_host in ds_hosts.DatastoreHostMount:
ds_host_ref_value = vutil.get_moref_value(ds_host.key)
for cluster_host in cluster_hosts.ManagedObjectReference:
if ds_host.key.value == cluster_host.value:
if ds_host_ref_value == vutil.get_moref_value(cluster_host):
return cluster_host
def _find_datastore_for_migration(self, instance, vm_ref, cluster_ref,
@ -1604,8 +1605,9 @@ class VMwareVMOps(object):
return None
# check if the current datastore is connected to the destination
# cluster
ds_ref_value = vutil.get_moref_value(ds_ref)
for datastore in cluster_datastores.ManagedObjectReference:
if datastore.value == ds_ref.value:
if vutil.get_moref_value(datastore) == ds_ref_value:
ds = ds_obj.get_datastore_by_ref(self._session, ds_ref)
if (datastore_regex is None or
datastore_regex.match(ds.name)):
@ -1819,13 +1821,14 @@ class VMwareVMOps(object):
instance=instance)
def _get_ds_browser(self, ds_ref):
ds_browser = self._datastore_browser_mapping.get(ds_ref.value)
ds_ref_value = vutil.get_moref_value(ds_ref)
ds_browser = self._datastore_browser_mapping.get(ds_ref_value)
if not ds_browser:
ds_browser = self._session._call_method(vutil,
"get_object_property",
ds_ref,
"browser")
self._datastore_browser_mapping[ds_ref.value] = ds_browser
self._datastore_browser_mapping[ds_ref_value] = ds_browser
return ds_browser
def _create_folder_if_missing(self, ds_name, ds_ref, folder):


+ 1
- 1
nova/virt/vmwareapi/volumeops.py View File

@ -300,7 +300,7 @@ class VMwareVolumeOps(object):
'initiator': iqn,
'host': CONF.vmware.host_ip}
if vm_ref:
connector['instance'] = vm_ref.value
connector['instance'] = vutil.get_moref_value(vm_ref)
return connector
def _get_volume_ref(self, volume_ref_name):


+ 1
- 1
test-requirements.txt View File

@ -24,4 +24,4 @@ gabbi>=1.35.0 # Apache-2.0
wsgi-intercept>=1.7.0 # MIT License
# vmwareapi driver specific dependencies
oslo.vmware>=2.17.0 # Apache-2.0
oslo.vmware>=3.6.0 # Apache-2.0

Loading…
Cancel
Save