]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Save some more image attributes to volume_glance_metadata.
authorVincent Hou <sbhou@cn.ibm.com>
Thu, 27 Jun 2013 07:43:00 +0000 (15:43 +0800)
committerVincent Hou <sbhou@cn.ibm.com>
Thu, 27 Jun 2013 09:58:36 +0000 (17:58 +0800)
Current issue: When copying an image to a volume, attributes like size, disk_format, container_format,
checksum, min_disk and min_ram have not been copied so far. When booting a VM from a volume, we are
not able to check these atrributes without giving the image id. Furthermore, if the original
image is deleted, we will lose all the information.

This patch saves these attributes into volume_glance_metadata. We can still check these attributes
without giving the image id when booting a VM from a volume.

Fixed Bug 1159824.

Change-Id: I42ce676026d32be6e3f4bec6fd269908e2df0a8c

cinder/volume/manager.py

index 875d62ad28b34c2e8a4ddecbc8a3bb2047af6a46..725d6b4af2d00f6899d755c66d4ad129467f5dc8 100644 (file)
@@ -323,6 +323,16 @@ class VolumeManager(manager.SchedulerDependentManager):
                 self.db.volume_glance_metadata_create(context,
                                                       volume_ref['id'],
                                                       'image_name', name)
+            # Save some more attributes into the volume metadata
+            IMAGE_ATTRIBUTES = ['size', 'disk_format',
+                                'container_format', 'checksum',
+                                'min_disk', 'min_ram']
+            for key in IMAGE_ATTRIBUTES:
+                value = image_meta.get(key, None)
+                if value is not None:
+                    self.db.volume_glance_metadata_create(context,
+                                                          volume_ref['id'],
+                                                          key, value)
             image_properties = image_meta.get('properties', {})
             for key, value in image_properties.items():
                 self.db.volume_glance_metadata_create(context,