]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix the generalized copy_image_to_volume operation.
authorjohn-griffith <john.griffith@solidfire.com>
Fri, 1 Feb 2013 05:38:51 +0000 (22:38 -0700)
committerjohn-griffith <john.griffith@solidfire.com>
Fri, 1 Feb 2013 05:43:19 +0000 (22:43 -0700)
The Generis iSCSI copy volume<->image patch
(change: Iff097629bcce9154829a7eb5aee0ea6302338b26) did
not account for the fact that the existing volume reference
passed in to the copy method would not have the updated
provider_location and iSCSI info available.

To address this, we simply just get a new ref from the DB
after creation if a copy image is requested.

Also, the list of acceptable formats was not fully inclusive,
not only that, but there's no reason to not let the qemu-convert
handle any errors here.

Change-Id: I7b1910080d285562c7f2d8afa7f65768b1089b73

cinder/volume/api.py
cinder/volume/manager.py

index 0bba3a3360297dba6ed2d38d4b33879a75fb617f..30f6c8450f39c9cd8591db017a7797718f8983d1 100644 (file)
@@ -144,14 +144,6 @@ class API(base.Base):
             if image_size_in_gb > size:
                 msg = _('Size of specified image is larger than volume size.')
                 raise exception.InvalidInput(reason=msg)
-            #We use qemu-img to convert images to raw and so we can only
-            #support the intersection of what qemu-img and glance support
-            if (image_meta['container_format'] != 'bare' or
-                image_meta['disk_format'] not in ['raw', 'qcow2',
-                                                  'vmdk', 'vdi']):
-                msg = (_("Image format must be one of raw, qcow2, "
-                         "vmdk, or vdi."))
-                raise exception.InvalidInput(reason=msg)
 
         try:
             reservations = QUOTAS.reserve(context, volumes=1, gigabytes=size)
@@ -600,16 +592,6 @@ class API(base.Base):
         """Create a new image from the specified volume."""
         self._check_volume_availability(context, volume, force)
 
-        #We use qemu-img to convert raw images to the requested type
-        #and so we can only support the intersection of what qemu-img and
-        #glance support
-        if (metadata['container_format'] != 'bare' or
-                metadata['disk_format'] not in ['raw', 'qcow2',
-                                                'vmdk', 'vdi']):
-            msg = (_("Image format must be one of raw, qcow2, "
-                     "vmdk, or vdi."))
-            raise exception.InvalidInput(reason=msg)
-
         recv_metadata = self.image_service.create(context, metadata)
         self.update(context, volume, {'status': 'uploading'})
         self.volume_rpcapi.copy_volume_to_image(context,
index 65667b51896b1663e5bddf353a21d074d1c2b0cf..40dfafe0393184310536f22d47638092a6e4d1bc 100644 (file)
@@ -221,6 +221,10 @@ class VolumeManager(manager.SchedulerDependentManager):
         self._reset_stats()
 
         if image_id and not cloned:
+            # NOTE(jdg): Our current ref hasn't been updated since
+            # the create, need to update ref to get provider_location
+            # before trying to perform the copy operation
+            volume_ref = self.db.volume_get(context, volume_id)
             if image_meta:
                 # Copy all of the Glance image properties to the
                 # volume_glance_metadata table for future reference.