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
1=== modified file 'nova/tests/xenapi/stubs.py'
2--- nova/tests/xenapi/stubs.py 2011-09-16 16:17:44 +0000
3+++ nova/tests/xenapi/stubs.py 2011-09-22 16:05:25 +0000
4@@ -298,6 +298,9 @@
5 def VM_set_name_label(self, *args):
6 pass
7
8+ def VDI_set_name_label(self, session_ref, vdi_ref, name_label):
9+ pass
10+
11
12 def stub_out_migration_methods(stubs):
13 def fake_create_snapshot(self, instance):
14
15=== modified file 'nova/virt/xenapi/vm_utils.py'
16--- nova/virt/xenapi/vm_utils.py 2011-09-16 00:22:31 +0000
17+++ nova/virt/xenapi/vm_utils.py 2011-09-22 16:05:25 +0000
18@@ -314,6 +314,11 @@
19 return vdi_ref
20
21 @classmethod
22+ def set_vdi_name_label(cls, session, vdi_uuid, name_label):
23+ vdi_ref = session.get_xenapi().VDI.get_by_uuid(vdi_uuid)
24+ session.get_xenapi().VDI.set_name_label(vdi_ref, name_label)
25+
26+ @classmethod
27 def get_vdi_for_vm_safely(cls, session, vm_ref):
28 """Retrieves the primary VDI for a VM"""
29 vbd_refs = session.get_xenapi().VM.get_VBDs(vm_ref)
30@@ -471,7 +476,7 @@
31
32 # Set the name-label to ease debugging
33 vdi_ref = session.get_xenapi().VDI.get_by_uuid(os_vdi_uuid)
34- primary_name_label = get_name_label_for_image(image)
35+ primary_name_label = instance.name
36 session.get_xenapi().VDI.set_name_label(vdi_ref, primary_name_label)
37
38 cls._check_vdi_size(context, session, instance, os_vdi_uuid)
39@@ -559,7 +564,7 @@
40 _("Kernel/Ramdisk image is too large: %(vdi_size)d bytes, "
41 "max %(max_size)d bytes") % locals())
42
43- name_label = get_name_label_for_image(image)
44+ name_label = instance.name
45 vdi_ref = cls.create_vdi(session, sr_ref, name_label, vdi_size, False)
46 # From this point we have a VDI on Xen host;
47 # If anything goes wrong, we need to remember its uuid.
48@@ -1156,11 +1161,6 @@
49 LOG.debug(_('Writing partition table %s done.'), dest)
50
51
52-def get_name_label_for_image(image):
53- # TODO(sirp): This should eventually be the URI for the Glance image
54- return _('Glance image %s') % image
55-
56-
57 def _mount_filesystem(dev_path, dir):
58 """mounts the device specified by dev_path in dir"""
59 try:
60
61=== modified file 'nova/virt/xenapi/vmops.py'
62--- nova/virt/xenapi/vmops.py 2011-09-21 20:59:40 +0000
63+++ nova/virt/xenapi/vmops.py 2011-09-22 16:05:25 +0000
64@@ -697,6 +697,11 @@
65 # Now we rescan the SR so we find the VHDs
66 VMHelper.scan_default_sr(self._session)
67
68+ # Set name-label so we can find if we need to clean up a failed
69+ # migration
70+ VMHelper.set_vdi_name_label(self._session, new_cow_uuid,
71+ instance.name)
72+
73 return new_cow_uuid
74
75 def resize_instance(self, instance, vdi_uuid):