From 5bce6f5fbe804cd24d8bf1c2e36680876bc044cd Mon Sep 17 00:00:00 2001 From: SandyWalsh Date: Wed, 4 Jul 2012 22:47:06 -0300 Subject: Ensure system metadata is sent on new image creation. System metadata is useful for billing and notification purposes. Sadly, this data was getting lost on new instances created from snapshots of old instances. This patch ensures the system metadata of the old instance is stored in the snapshot for use with creating new instances. Additionally, it strips the "image_" prefix from any system metadata keys (as required). Change-Id: I9fff55c0e9f106afcded1865c7a47bc96ba507a7 --- nova/virt/xenapi/vm_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 61cf74f91..241b0da68 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -454,7 +454,13 @@ def upload_image(context, session, instance, vdi_uuids, image_id): glance_host, glance_port = glance.pick_glance_api_server() + sys_meta = db.instance_system_metadata_get(context, instance['uuid']) properties = {} + prefix = 'image_' + for key, value in sys_meta.iteritems(): + if key.startswith(prefix): + key = key[len(prefix):] + properties[key] = value properties['auto_disk_config'] = instance.auto_disk_config properties['os_type'] = instance.os_type or FLAGS.default_os_type -- cgit