From 6d5e991d51b9e440ab4e22d67157b9492eb50599 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 24 Jun 2013 11:05:16 -0700 Subject: 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 --- nova/openstack/common/jsonutils.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nova') 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) -- cgit