diff options
author | Dan Smith <danms@us.ibm.com> | 2013-06-24 11:05:16 -0700 |
---|---|---|
committer | Dan Smith <danms@us.ibm.com> | 2013-06-27 07:58:22 -0700 |
commit | 6d5e991d51b9e440ab4e22d67157b9492eb50599 (patch) | |
tree | 783328df9df5d08af072febd59a36a61a71574ba /nova | |
parent | 2d5e53c9df16139cafee4f9c8111e0ec9b162ff0 (diff) | |
download | nova-6d5e991d51b9e440ab4e22d67157b9492eb50599.tar.gz nova-6d5e991d51b9e440ab4e22d67157b9492eb50599.tar.xz nova-6d5e991d51b9e440ab4e22d67157b9492eb50599.zip |
Sync to_primitive() IPAddress support from Oslo
This enlightens to_primitive() that it may just call str() to
serialize netaddr.IPAddress objects.
We need this for NovaObject serialization through legacy interfaces
temporarily while we migrate things.
Related to blueprint unified-object-model
Change-Id: Ibdee90e4bbd337d541344977e2a689982e0a7d34
Diffstat (limited to 'nova')
-rw-r--r-- | nova/openstack/common/jsonutils.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/nova/openstack/common/jsonutils.py b/nova/openstack/common/jsonutils.py index 11af66daf..a260efad7 100644 --- a/nova/openstack/common/jsonutils.py +++ b/nova/openstack/common/jsonutils.py @@ -41,6 +41,7 @@ import json import types import xmlrpclib +import netaddr import six from nova.openstack.common import timeutils @@ -137,6 +138,8 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, # Likely an instance of something. Watch for cycles. # Ignore class member vars. return recursive(value.__dict__, level=level + 1) + elif isinstance(value, netaddr.IPAddress): + return six.text_type(value) else: if any(test(value) for test in _nasty_type_tests): return six.text_type(value) |