summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2012-07-20 20:25:16 +0000
committerRick Harris <rconradharris@gmail.com>2012-07-20 20:27:11 +0000
commit4cee1e5b156d735468bcbd3fc51384d53ea28f76 (patch)
tree090773dd9871a1b16dd1efb562aa351aa131abb8
parent075cd488472ee8dd241629007460942ffb53ba5e (diff)
downloadnova-4cee1e5b156d735468bcbd3fc51384d53ea28f76.tar.gz
nova-4cee1e5b156d735468bcbd3fc51384d53ea28f76.tar.xz
nova-4cee1e5b156d735468bcbd3fc51384d53ea28f76.zip
Improve VDI chain logging.
Currently we're logging the parent's OpaqueRef which is rather useless. This patches uses the much more useful UUID. Some small cleanups are included as well. Change-Id: I6a9dd712dbac1d1b1aaba65da2b7c399b606e934
-rw-r--r--nova/virt/xenapi/vm_utils.py39
1 files changed, 11 insertions, 28 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index c17f53ee8..d028379cf 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1501,48 +1501,31 @@ def _get_all_vdis_in_sr(session, sr_ref):
continue
-#TODO(sirp): This code comes from XS5.6 pluginlib.py, we should refactor to
-# use that implmenetation
-def _get_vhd_parent(session, vdi_rec):
- """
- Returns the VHD parent of the given VDI record, as a (ref, rec) pair.
- Returns None if we're at the root of the tree.
- """
- if 'vhd-parent' in vdi_rec['sm_config']:
- parent_uuid = vdi_rec['sm_config']['vhd-parent']
- parent_ref = session.call_xenapi("VDI.get_by_uuid", parent_uuid)
- parent_rec = session.call_xenapi("VDI.get_record", parent_ref)
- vdi_uuid = vdi_rec['uuid']
- LOG.debug(_("VHD %(vdi_uuid)s has parent %(parent_ref)s") % locals())
- return parent_ref, parent_rec
- else:
- return None
-
-
def _get_vhd_parent_uuid(session, vdi_ref):
vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
- ret = _get_vhd_parent(session, vdi_rec)
- if ret:
- _parent_ref, parent_rec = ret
- return parent_rec["uuid"]
- else:
+
+ if 'vhd-parent' not in vdi_rec['sm_config']:
return None
+ parent_uuid = vdi_rec['sm_config']['vhd-parent']
+ vdi_uuid = vdi_rec['uuid']
+ LOG.debug(_("VHD %(vdi_uuid)s has parent %(parent_uuid)s") % locals())
+ return parent_uuid
+
def _walk_vdi_chain(session, vdi_uuid):
"""Yield vdi_recs for each element in a VDI chain"""
- # TODO(jk0): perhaps make _get_vhd_parent use this
while True:
vdi_ref = session.call_xenapi("VDI.get_by_uuid", vdi_uuid)
vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
yield vdi_rec
- parent_uuid = vdi_rec['sm_config'].get('vhd-parent')
- if parent_uuid:
- vdi_uuid = parent_uuid
- else:
+ parent_uuid = _get_vhd_parent_uuid(session, vdi_ref)
+ if not parent_uuid:
break
+ vdi_uuid = parent_uuid
+
def _wait_for_vhd_coalesce(session, instance, sr_ref, vdi_ref,
original_parent_uuid):