diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2012-10-04 16:23:14 -0500 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2012-10-04 16:23:14 -0500 |
| commit | 1c68e733ca0e536ea95ac982d1b4b43ed143b3e2 (patch) | |
| tree | 8b998f9dd2b3909cf24822d3050e3cd298078d86 /nova/compute | |
| parent | df22ef9c0f45fe29353d8bbc020f488cfe9314ce (diff) | |
Move snapshot image property inheritance
The xenapi snapshotting code had support for inheriting properties
from the base image of the snapshot (by way of the system metadata
set on the snapshotted instance). The problem, however, came in the
fact that some image properties were set in nova.compute.api, but
those properties were not excluded from this inheritance logic
except through a configuration option called
"non_inheritable_image_properties". I had previously updated the
default setting for this option to work around the bugs introduced
by setting image properties in two different locations, but now it
is time for the real fix.
This change moves the inheritance logic into
nova.compute.api:API._create_image. Note that two properties are
still set through the xenapi snapshotting logic: the "os_type" and
the "auto_disk_config" properties, which are presumed to be xenapi
specific. The change also alters the inheritance logic to ensure
that the work-around listing of image properties in
non_inheritable_image_properties is no longer necessary; the
default for this configuration option is updated accordingly.
(Note: It will not harm anything to have these image properties
still listed in non_inheritable_image_properties, so configurations
that override this option do not need to be altered.)
Change-Id: I3514da432cc10c75418e1de9752f60640d579136
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 2818a9eb8..20523170f 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1233,6 +1233,22 @@ class API(base.Base): sent_meta['min_disk'] = min_disk properties.update(extra_properties or {}) + + # Now inherit image properties from the base image + prefix = 'image_' + for key, value in system_meta.items(): + # Trim off the image_ prefix + if key.startswith(prefix): + key = key[len(prefix):] + + # Skip properties that are non-inheritable + if key in FLAGS.non_inheritable_image_properties: + continue + + # By using setdefault, we ensure that the properties set + # up above will not be overwritten by inherited values + properties.setdefault(key, value) + sent_meta['properties'] = properties recv_meta = self.image_service.create(context, sent_meta) |
