diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2012-07-25 15:31:11 -0500 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2012-07-25 15:31:34 -0500 |
| commit | 82afe7ad5eac668aaefc79e16bbf2226eddde97d (patch) | |
| tree | 2f6fbe30e9e5e1b1246c64027be1a4b0415cb6c7 /nova/utils.py | |
| parent | 9a40e9e9a4538f6ba87451137bf0d6d2598f2319 (diff) | |
| download | nova-82afe7ad5eac668aaefc79e16bbf2226eddde97d.tar.gz nova-82afe7ad5eac668aaefc79e16bbf2226eddde97d.tar.xz nova-82afe7ad5eac668aaefc79e16bbf2226eddde97d.zip | |
Inject instance metadata into xenstore
When using Xenserver, inject instance metadata into the xenstore, for
the use of the instance. Implements blueprint xenstore-metadata.
Change-Id: I88a59f1b783eaaaef6ba5efd8bd448aece2f869c
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py index 9cfb6d06d..adb1cf45c 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -861,6 +861,24 @@ def subset_dict(dict_, keys): return subset +def diff_dict(orig, new): + """ + Return a dict describing how to change orig to new. The keys + correspond to values that have changed; the value will be a list + of one or two elements. The first element of the list will be + either '+' or '-', indicating whether the key was updated or + deleted; if the key was updated, the list will contain a second + element, giving the updated value. + """ + # Figure out what keys went away + result = dict((k, ['-']) for k in set(orig.keys()) - set(new.keys())) + # Compute the updates + for key, value in new.items(): + if key not in orig or value != orig[key]: + result[key] = ['+', value] + return result + + def check_isinstance(obj, cls): """Checks that obj is of type cls, and lets PyLint infer types.""" if isinstance(obj, cls): |
