From 1259395061005b70a123408b9e1cdd5bb76d9b62 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 12 Dec 2012 10:29:13 -0500 Subject: Ensure datetimes can be properly serialized. The nova-network manager was returning db models from methods invoked via rpc.call(). These db models include non-primitive types that can not be properly serialized (namely datetime objects). Use to_primitive() to ensure that the data gets serialized properly. Fix bug 1089430. Change-Id: I019504cf68b2d420437c550b596eda8a12fe6618 --- nova/network/manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index 6680634c9..2c342b706 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -65,6 +65,7 @@ from nova.network import rpcapi as network_rpcapi from nova.openstack.common import cfg from nova.openstack.common import excutils from nova.openstack.common import importutils +from nova.openstack.common import jsonutils from nova.openstack.common import lockutils from nova.openstack.common import log as logging from nova.openstack.common.notifier import api as notifier @@ -1904,7 +1905,7 @@ class NetworkManager(manager.SchedulerDependentManager): networks = self.db.network_get_all(context) except exception.NoNetworksFound: return [] - return [dict(network.iteritems()) for network in networks] + return [jsonutils.to_primitive(network) for network in networks] @wrap_check_policy def disassociate_network(self, context, network_uuid): @@ -1915,12 +1916,12 @@ class NetworkManager(manager.SchedulerDependentManager): def get_fixed_ip(self, context, id): """Return a fixed ip""" fixed = self.db.fixed_ip_get(context, id) - return dict(fixed.iteritems()) + return jsonutils.to_primitive(fixed) @wrap_check_policy def get_fixed_ip_by_address(self, context, address): fixed = self.db.fixed_ip_get_by_address(context, address) - return dict(fixed.iteritems()) + return jsonutils.to_primitive(fixed) def get_vif_by_mac_address(self, context, mac_address): """Returns the vifs record for the mac_address""" -- cgit