From 4ef5eabaeeb70d5090079819f4c2442742f43373 Mon Sep 17 00:00:00 2001 From: Vincent Hou Date: Thu, 27 Jun 2013 15:43:00 +0800 Subject: [PATCH] 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 --- cinder/volume/manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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, -- 2.45.2