diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-07-23 12:25:20 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-07-23 12:26:55 -0400 |
| commit | a7f307bbc2607b7aaa830574010289767f43de4a (patch) | |
| tree | 17410da572c6fdb091413036cdaf79a9d7a36742 /nova/openstack | |
| parent | e2065072ced0c288fb558e10e7d6371be7c55f16 (diff) | |
| download | nova-a7f307bbc2607b7aaa830574010289767f43de4a.tar.gz nova-a7f307bbc2607b7aaa830574010289767f43de4a.tar.xz nova-a7f307bbc2607b7aaa830574010289767f43de4a.zip | |
Update jsonutils from openstack-common.
commit 9e1bd9d9313a9f324c5b7b02232e8bd2fd12ea8a
Author: Russell Bryant <rbryant@redhat.com>
Date: Wed Jul 18 16:47:34 2012 -0400
Add missing convert_instances arg.
When calling jsonutils.to_primitive() recursively, the convert_instances
argument should be passed along. This change fixes one place where it
was not.
commit 2d6f84742a3e8ea51ebbfb82cbeacefe97e199d5
Author: Russell Bryant <rbryant@redhat.com>
Date: Wed Jul 18 16:15:52 2012 -0400
Track to_primitive() depth after iteritems().
Change jsonutils.to_primitive() to increase the recursion depth counter
when calling to_primitive() on the result of iteritems() from the
current element. Previously, the only time the counter was increased
was when converting the __dict__ from an object. The iteritems() case
risks cycles, as well.
I hit a problem with this when trying to call to_primitive on an
instance of nova.db.sqlalchemy.models.Instance. An Instance includes a
reference to InstanceInfoCache, which has a reference back to the
Instance. Without this change, to_primitive() would raise an exception
for an Instance due to excessive recursion.
Related to nova blueprint no-db-messaging.
Change-Id: Iaa49ea08b406a38840e8a0b5466d48f2d3f7e840
Diffstat (limited to 'nova/openstack')
| -rw-r--r-- | nova/openstack/common/jsonutils.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/nova/openstack/common/jsonutils.py b/nova/openstack/common/jsonutils.py index 5f6a7edab..5a90d5c5e 100644 --- a/nova/openstack/common/jsonutils.py +++ b/nova/openstack/common/jsonutils.py @@ -107,9 +107,11 @@ def to_primitive(value, convert_instances=False, level=0): elif hasattr(value, 'iteritems'): return to_primitive(dict(value.iteritems()), convert_instances=convert_instances, - level=level) + level=level + 1) elif hasattr(value, '__iter__'): - return to_primitive(list(value), level) + return to_primitive(list(value), + convert_instances=convert_instances, + level=level) elif convert_instances and hasattr(value, '__dict__'): # Likely an instance of something. Watch for cycles. # Ignore class member vars. |
