Merge lp:~johannes.erdfelt/nova/lp822982 into lp:~hudson-openstack/nova/trunk

Proposed by Johannes Erdfelt
Status: Merged
Approved by: Paul Voccio
Approved revision: 1618
Merged at revision: 1617
Proposed branch: lp:~johannes.erdfelt/nova/lp822982
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 75 lines (+15/-7)
3 files modified
nova/tests/xenapi/stubs.py (+3/-0)
nova/virt/xenapi/vm_utils.py (+7/-7)
nova/virt/xenapi/vmops.py (+5/-0)
To merge this branch: bzr merge lp:~johannes.erdfelt/nova/lp822982
Reviewer Review Type Date Requested Status
Paul Voccio (community) Approve
Brian Waldon (community) Approve
Review via email: mp+76607@code.launchpad.net

Description of the change

The xenapi driver currently names VDIs in the form "Glance image %d". In cases of failures or other troubleshooting, it's difficult to differentiate VDIs from each other. This patch changes the VDI name to match the instance name.

To post a comment you must log in.
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Code looks good.

review: Approve
Revision history for this message
Paul Voccio (pvo) wrote :

Thanks Johannes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/tests/xenapi/stubs.py'
--- nova/tests/xenapi/stubs.py 2011-09-16 16:17:44 +0000
+++ nova/tests/xenapi/stubs.py 2011-09-22 16:05:25 +0000
@@ -298,6 +298,9 @@
298 def VM_set_name_label(self, *args):298 def VM_set_name_label(self, *args):
299 pass299 pass
300300
301 def VDI_set_name_label(self, session_ref, vdi_ref, name_label):
302 pass
303
301304
302def stub_out_migration_methods(stubs):305def stub_out_migration_methods(stubs):
303 def fake_create_snapshot(self, instance):306 def fake_create_snapshot(self, instance):
304307
=== modified file 'nova/virt/xenapi/vm_utils.py'
--- nova/virt/xenapi/vm_utils.py 2011-09-16 00:22:31 +0000
+++ nova/virt/xenapi/vm_utils.py 2011-09-22 16:05:25 +0000
@@ -314,6 +314,11 @@
314 return vdi_ref314 return vdi_ref
315315
316 @classmethod316 @classmethod
317 def set_vdi_name_label(cls, session, vdi_uuid, name_label):
318 vdi_ref = session.get_xenapi().VDI.get_by_uuid(vdi_uuid)
319 session.get_xenapi().VDI.set_name_label(vdi_ref, name_label)
320
321 @classmethod
317 def get_vdi_for_vm_safely(cls, session, vm_ref):322 def get_vdi_for_vm_safely(cls, session, vm_ref):
318 """Retrieves the primary VDI for a VM"""323 """Retrieves the primary VDI for a VM"""
319 vbd_refs = session.get_xenapi().VM.get_VBDs(vm_ref)324 vbd_refs = session.get_xenapi().VM.get_VBDs(vm_ref)
@@ -471,7 +476,7 @@
471476
472 # Set the name-label to ease debugging477 # Set the name-label to ease debugging
473 vdi_ref = session.get_xenapi().VDI.get_by_uuid(os_vdi_uuid)478 vdi_ref = session.get_xenapi().VDI.get_by_uuid(os_vdi_uuid)
474 primary_name_label = get_name_label_for_image(image)479 primary_name_label = instance.name
475 session.get_xenapi().VDI.set_name_label(vdi_ref, primary_name_label)480 session.get_xenapi().VDI.set_name_label(vdi_ref, primary_name_label)
476481
477 cls._check_vdi_size(context, session, instance, os_vdi_uuid)482 cls._check_vdi_size(context, session, instance, os_vdi_uuid)
@@ -559,7 +564,7 @@
559 _("Kernel/Ramdisk image is too large: %(vdi_size)d bytes, "564 _("Kernel/Ramdisk image is too large: %(vdi_size)d bytes, "
560 "max %(max_size)d bytes") % locals())565 "max %(max_size)d bytes") % locals())
561566
562 name_label = get_name_label_for_image(image)567 name_label = instance.name
563 vdi_ref = cls.create_vdi(session, sr_ref, name_label, vdi_size, False)568 vdi_ref = cls.create_vdi(session, sr_ref, name_label, vdi_size, False)
564 # From this point we have a VDI on Xen host;569 # From this point we have a VDI on Xen host;
565 # If anything goes wrong, we need to remember its uuid.570 # If anything goes wrong, we need to remember its uuid.
@@ -1156,11 +1161,6 @@
1156 LOG.debug(_('Writing partition table %s done.'), dest)1161 LOG.debug(_('Writing partition table %s done.'), dest)
11571162
11581163
1159def get_name_label_for_image(image):
1160 # TODO(sirp): This should eventually be the URI for the Glance image
1161 return _('Glance image %s') % image
1162
1163
1164def _mount_filesystem(dev_path, dir):1164def _mount_filesystem(dev_path, dir):
1165 """mounts the device specified by dev_path in dir"""1165 """mounts the device specified by dev_path in dir"""
1166 try:1166 try:
11671167
=== modified file 'nova/virt/xenapi/vmops.py'
--- nova/virt/xenapi/vmops.py 2011-09-21 20:59:40 +0000
+++ nova/virt/xenapi/vmops.py 2011-09-22 16:05:25 +0000
@@ -697,6 +697,11 @@
697 # Now we rescan the SR so we find the VHDs697 # Now we rescan the SR so we find the VHDs
698 VMHelper.scan_default_sr(self._session)698 VMHelper.scan_default_sr(self._session)
699699
700 # Set name-label so we can find if we need to clean up a failed
701 # migration
702 VMHelper.set_vdi_name_label(self._session, new_cow_uuid,
703 instance.name)
704
700 return new_cow_uuid705 return new_cow_uuid
701706
702 def resize_instance(self, instance, vdi_uuid):707 def resize_instance(self, instance, vdi_uuid):