Permalink
Browse files

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
  • Loading branch information...
russellb committed Dec 12, 2012
1 parent 365c9f0 commit 1259395061005b70a123408b9e1cdd5bb76d9b62
Showing with 4 additions and 3 deletions.
  1. +4 −3 nova/network/manager.py
@@ -65,6 +65,7 @@
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 @@ def get_all_networks(self, context):
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 @@ def disassociate_network(self, context, network_uuid):
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"""

0 comments on commit 1259395

Please sign in to comment.