diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2013-02-12 09:18:26 -0800 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2013-02-12 09:19:45 -0800 |
| commit | 7b206ad53d0ecfb9176a3c47e574552998caa0f7 (patch) | |
| tree | a65c09fad55ee4785585db41b5b965c1843c2686 /nova/openstack | |
| parent | 3e4637e8e7887567ac7dbc60e997aa780f029c1c (diff) | |
| download | nova-7b206ad53d0ecfb9176a3c47e574552998caa0f7.tar.gz nova-7b206ad53d0ecfb9176a3c47e574552998caa0f7.tar.xz nova-7b206ad53d0ecfb9176a3c47e574552998caa0f7.zip | |
Sync jsonutils from openstack-common
Pulls in new jsonutils to get the configurable max_depth in
jsonutils.to_primitive.
Change-Id: I4878a033257839ec3b2ac5223440b3a9034877cc
Diffstat (limited to 'nova/openstack')
| -rw-r--r-- | nova/openstack/common/jsonutils.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/nova/openstack/common/jsonutils.py b/nova/openstack/common/jsonutils.py index 290435450..b06055117 100644 --- a/nova/openstack/common/jsonutils.py +++ b/nova/openstack/common/jsonutils.py @@ -38,13 +38,17 @@ import functools import inspect import itertools import json +import logging import xmlrpclib +from nova.openstack.common.gettextutils import _ from nova.openstack.common import timeutils +LOG = logging.getLogger(__name__) + def to_primitive(value, convert_instances=False, convert_datetime=True, - level=0): + level=0, max_depth=3): """Convert a complex object into primitives. Handy for JSON serialization. We can optionally handle instances, @@ -80,7 +84,9 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, if getattr(value, '__module__', None) == 'mox': return 'mock' - if level > 3: + if level > max_depth: + LOG.error(_('Max serialization depth exceeded on object: %d %s'), + level, value) return '?' # The try block may not be necessary after the class check above, @@ -89,7 +95,8 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, recursive = functools.partial(to_primitive, convert_instances=convert_instances, convert_datetime=convert_datetime, - level=level) + level=level, + max_depth=max_depth) # It's not clear why xmlrpclib created their own DateTime type, but # for our purposes, make it a datetime type which is explicitly # handled |
