Payload meta_data is empty when remove metadata

When update metadata for a host aggregation, all of the values will
be in the variable of "updates", if remove metadata, the format would
be {"foo": None, "bar": None}; If adding metadata, the format would
be {"foo": "foo1", "bar": "bar1"}.

The current logic of update_metadata() is as following:
1) Get all metadata from variable "updates".
2) Traverse updates to see which values are new added and which needs
to be removed. For the new added values, put the metadata to
variable "to_add"; for the values which need to be removed, just
remove them from metadata.
3) Set the values of variable "to_add" as payload metadata.

The above logic will make the values which was removed from metadata
cannot be in payload, this caused the third party receiver cannot know
which metadata was removed.

The fix was always using the values from variable "updates" as the
metadata for payload as it include values removed and new added.

Change-Id: I7b78795e325f52cfb9c24eabd9ef42990666c02d
Closes-Bug: #1269684
This commit is contained in:
Jay Lau
2014-04-25 16:03:40 +08:00
committed by Jay Lau
parent 4637f62863
commit 652c8ca285
2 changed files with 11 additions and 1 deletions

View File

@@ -119,7 +119,6 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject):
to_add[key] = value
self.metadata[key] = value
db.aggregate_metadata_add(context, self.id, to_add)
payload['meta_data'] = to_add
compute_utils.notify_about_aggregate_update(context,
"updatemetadata.end",
payload)