From fed19822f89ce7f6542d8ea6a4a8b85cfa6065d6 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 13 Nov 2012 10:53:06 -0800 Subject: Keep flavor information in system_metadata This patch copies the instance_type information into an instance's system_metadata on creation. This provides a way for us to recall the attributes used to create the instance even after the type may have been deleted. This adds db migration 153, which generates flavor information in system_metadata for existing instances in the database, as well as brings a test to make sure that works. Change-Id: Iad9d640b44df5f3831de58f9e800bcf42bc0610e --- nova/compute/api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 06ce2e07e..ed56cecb5 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -508,6 +508,13 @@ class API(base.Base): availability_zone, forced_host = self._handle_availability_zone( availability_zone) + system_metadata = {} + instance_type_props = ['id', 'name', 'memory_mb', 'vcpus', + 'root_gb', 'ephemeral_gb', 'flavorid', + 'swap', 'rxtx_factor', 'vcpu_weight'] + for k in instance_type_props: + system_metadata["instance_type_%s" % k] = instance_type[k] + base_options = { 'reservation_id': reservation_id, 'image_ref': image_href, @@ -537,7 +544,8 @@ class API(base.Base): 'access_ip_v6': access_ip_v6, 'availability_zone': availability_zone, 'root_device_name': root_device_name, - 'progress': 0} + 'progress': 0, + 'system_metadata': system_metadata} options_from_image = self._inherit_properties_from_image( image, auto_disk_config) -- cgit