diff options
| author | Matt Dietz <matt.dietz@rackspace.com> | 2011-09-23 15:36:50 -0500 |
|---|---|---|
| committer | Matt Dietz <matt.dietz@rackspace.com> | 2011-09-23 15:38:36 -0500 |
| commit | 774b5aaa173fa04675be5252c5d47f67a07347ac (patch) | |
| tree | 60416f512ce6c2c873b79b7c00e95875e5c36864 /nova/virt | |
| parent | 4e94ec1a0a566b66f09b734e6ffe964b4b3b4bee (diff) | |
Adds disk config
Change-Id: If3e1765b659ead77f9cdaaa86ee8478a82bf67c0
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 20 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 11 |
2 files changed, 21 insertions, 10 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 5778ca1c2..51f102689 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -314,6 +314,11 @@ class VMHelper(HelperBase): return vdi_ref @classmethod + def set_vdi_name_label(cls, session, vdi_uuid, name_label): + vdi_ref = session.get_xenapi().VDI.get_by_uuid(vdi_uuid) + session.get_xenapi().VDI.set_name_label(vdi_ref, name_label) + + @classmethod def get_vdi_for_vm_safely(cls, session, vm_ref): """Retrieves the primary VDI for a VM""" vbd_refs = session.get_xenapi().VM.get_VBDs(vm_ref) @@ -370,7 +375,8 @@ class VMHelper(HelperBase): return os.path.join(FLAGS.xenapi_sr_base_path, sr_uuid) @classmethod - def upload_image(cls, context, session, instance, vdi_uuids, image_id): + def upload_image(cls, context, session, instance, vdi_uuids, image_id, + options=None): """ Requests that the Glance plugin bundle the specified VDIs and push them into Glance using the specified human-friendly name. """ @@ -388,7 +394,8 @@ class VMHelper(HelperBase): 'glance_port': glance_port, 'sr_path': cls.get_sr_path(session), 'os_type': os_type, - 'auth_token': getattr(context, 'auth_token', None)} + 'auth_token': getattr(context, 'auth_token', None), + 'options': options} kwargs = {'params': pickle.dumps(params)} task = session.async_call_plugin('glance', 'upload_vhd', kwargs) @@ -471,7 +478,7 @@ class VMHelper(HelperBase): # Set the name-label to ease debugging vdi_ref = session.get_xenapi().VDI.get_by_uuid(os_vdi_uuid) - primary_name_label = get_name_label_for_image(image) + primary_name_label = instance.name session.get_xenapi().VDI.set_name_label(vdi_ref, primary_name_label) cls._check_vdi_size(context, session, instance, os_vdi_uuid) @@ -559,7 +566,7 @@ class VMHelper(HelperBase): _("Kernel/Ramdisk image is too large: %(vdi_size)d bytes, " "max %(max_size)d bytes") % locals()) - name_label = get_name_label_for_image(image) + name_label = instance.name vdi_ref = cls.create_vdi(session, sr_ref, name_label, vdi_size, False) # From this point we have a VDI on Xen host; # If anything goes wrong, we need to remember its uuid. @@ -1156,11 +1163,6 @@ def _write_partition(virtual_size, dev): LOG.debug(_('Writing partition table %s done.'), dest) -def get_name_label_for_image(image): - # TODO(sirp): This should eventually be the URI for the Glance image - return _('Glance image %s') % image - - def _mount_filesystem(dev_path, dir): """mounts the device specified by dev_path in dir""" try: diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 1dfa5abd1..bf4481d69 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -549,12 +549,16 @@ class VMOps(object): """ template_vm_ref = None + options = None + if instance['managed_disk']: + options = {'managed_disk': instance['managed_disk']} try: template_vm_ref, template_vdi_uuids =\ self._create_snapshot(instance) # call plugin to ship snapshot off to glance VMHelper.upload_image(context, - self._session, instance, template_vdi_uuids, image_id) + self._session, instance, template_vdi_uuids, image_id, + options) finally: if template_vm_ref: self._destroy(instance, template_vm_ref, @@ -697,6 +701,11 @@ class VMOps(object): # Now we rescan the SR so we find the VHDs VMHelper.scan_default_sr(self._session) + # Set name-label so we can find if we need to clean up a failed + # migration + VMHelper.set_vdi_name_label(self._session, new_cow_uuid, + instance.name) + return new_cow_uuid def resize_instance(self, instance, vdi_uuid): |
