From: Vincent Hou Date: Thu, 27 Jun 2013 07:43:00 +0000 (+0800) Subject: Save some more image attributes to volume_glance_metadata. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4ef5eabaeeb70d5090079819f4c2442742f43373;p=openstack-build%2Fcinder-build.git Save some more image attributes to volume_glance_metadata. 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 --- diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 875d62ad2..725d6b4af 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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,