summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2012-05-03 22:30:32 +0000
committerBrian Elliott <brian.elliott@rackspace.com>2012-08-31 16:09:33 +0000
commit04e6ad112f541df68b06c17f141be916e5e8bdb2 (patch)
tree77fec07b44b60475b1e7f8c2d923f53522f5d4be /nova/compute
parenta9e84dd614a26f093594a9ccec10740bd3ecd9e6 (diff)
Save the original base image ref for snapshots.
Save the base image ref in instance system metadata for tracking purposes. (This is modified code originally from Rick Harris.) Change-Id: I574c597c7ff2e55675ebdaa7b3213b53e61a94b7
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index dcc6a7f06..9f99e00dc 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -688,6 +688,16 @@ class API(base.Base):
new_value = str(value)[:255]
instance['system_metadata']['image_%s' % key] = new_value
+ # Keep a record of the original base image that this
+ # image's instance is derived from:
+ base_image_ref = image['properties'].get('base_image_ref')
+ if not base_image_ref:
+ # base image ref property not previously set through a snapshot.
+ # default to using the image ref as the base:
+ base_image_ref = base_options['image_ref']
+
+ instance['system_metadata']['image_base_image_ref'] = base_image_ref
+
# Use 'default' security_group if none specified.
if security_groups is None:
security_groups = ['default']
@@ -1173,6 +1183,13 @@ class API(base.Base):
'image_type': image_type,
}
+ # Persist base image ref as a Glance image property
+ system_meta = self.db.instance_system_metadata_get(
+ context, instance_uuid)
+ base_image_ref = system_meta.get('image_base_image_ref')
+ if base_image_ref:
+ properties['base_image_ref'] = base_image_ref
+
sent_meta = {'name': name, 'is_public': False}
if image_type == 'backup':