From f407b79ae2677ca5ce877e7353000d5bf42a5c74 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Thu, 5 Sep 2013 16:37:22 -0700 Subject: [PATCH] Clean up duplicated change-building code in objects Almost every object thus far has done this: changes = {} for key in self.obj_what_changed(): changes[key] = self[key] to get a dict of updates to apply to the database. This patch adds that as part of the base object and makes every place that does the above to just use that. Change-Id: I847f5d35181b0305668b107f86faa164e71c3375 --- nova/objects/aggregate.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nova/objects/aggregate.py b/nova/objects/aggregate.py index 6b6f97998..302a2d644 100644 --- a/nova/objects/aggregate.py +++ b/nova/objects/aggregate.py @@ -55,9 +55,7 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject): @base.remotable def create(self, context): self._assert_no_hosts('create') - updates = {} - for key in self.obj_what_changed(): - updates[key] = self[key] + updates = self.obj_get_changes() payload = dict(updates) if 'metadata' in updates: # NOTE(danms): For some reason the notification format is weird @@ -76,9 +74,7 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject): @base.remotable def save(self, context): self._assert_no_hosts('save') - updates = {} - for key in self.obj_what_changed(): - updates[key] = self[key] + updates = self.obj_get_changes() payload = {'aggregate_id': self.id} if 'metadata' in updates: