diff options
author | Chris Behrens <cbehrens@codestud.com> | 2013-06-17 19:10:10 +0000 |
---|---|---|
committer | Chris Behrens <cbehrens@codestud.com> | 2013-06-17 19:12:23 +0000 |
commit | 1b9961c4b6785d85e98223f576bd839c0212b3a7 (patch) | |
tree | 3a3495567fcccb8daf67d51fc06c4194df5fb1ca | |
parent | 328b347cd058f1c87d7e32a18d9decc0ba517266 (diff) | |
download | nova-1b9961c4b6785d85e98223f576bd839c0212b3a7.tar.gz nova-1b9961c4b6785d85e98223f576bd839c0212b3a7.tar.xz nova-1b9961c4b6785d85e98223f576bd839c0212b3a7.zip |
Fix instance obj refresh()
The refresh() method pulls a fresh copy of the instance but if any
fields changed when doing so, they are left marked as changes that
are not yet committed.
Also clarified the doc string for obj_what_changed() to state that a set
is returned, not a list.
This method is not used yet, so I didn't file a bug for this.
Change-Id: I83fbce07936fea2bc936441c5c6594f65da443a7
-rw-r--r-- | nova/objects/base.py | 2 | ||||
-rw-r--r-- | nova/objects/instance.py | 1 | ||||
-rw-r--r-- | nova/tests/objects/test_instance.py | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/nova/objects/base.py b/nova/objects/base.py index 2e0797477..ec1ada6aa 100644 --- a/nova/objects/base.py +++ b/nova/objects/base.py @@ -311,7 +311,7 @@ class NovaObject(object): raise NotImplementedError('Cannot save anything in the base class') def obj_what_changed(self): - """Returns a list of fields that have been modified.""" + """Returns a set of fields that have been modified.""" return self._changed_fields def obj_reset_changes(self, fields=None): diff --git a/nova/objects/instance.py b/nova/objects/instance.py index aec6fe968..cd08c4c4f 100644 --- a/nova/objects/instance.py +++ b/nova/objects/instance.py @@ -256,6 +256,7 @@ class Instance(base.NovaObject): if (hasattr(self, base.get_attrname(field)) and self[field] != current[field]): self[field] = current[field] + self.obj_reset_changes() def obj_load_attr(self, attrname): extra = [] diff --git a/nova/tests/objects/test_instance.py b/nova/tests/objects/test_instance.py index a9238a924..efd0bcdf9 100644 --- a/nova/tests/objects/test_instance.py +++ b/nova/tests/objects/test_instance.py @@ -163,6 +163,7 @@ class _TestInstanceObject(object): inst.refresh() self.assertEqual(inst.host, 'new-host') self.assertRemotes() + self.assertEqual(set([]), inst.obj_what_changed()) def test_save(self): ctxt = context.get_admin_context() |