Make InfoCache.network_info be the network model

Instead of storing the DB version of network_info (which is a JSON
version of network.model.NetworkInfo) on the object, go ahead and turn
it into its native object as well.  This means that all uses of the
object don't need to worry about hydrating network_info themselves.

This adjusts all uses in the code understand the old and new ways of
life.

There's also a small issue with the get_by_instance_uuid() method that
would cause a traceback when no entry was found.  This method is not
being used yet anywhere, but this is fixed to raise a NotFound.

Related to blueprint unified-object-model

Change-Id: I882311c8a9f9df927c5650946e6398eeb33e74d0
This commit is contained in:
Chris Behrens
2013-07-11 19:07:15 +00:00
committed by Dan Smith
parent 96a5baf673
commit 5701c4e5a8
8 changed files with 93 additions and 30 deletions

View File

@@ -27,6 +27,7 @@ from nova.compute import flavors
from nova import exception
from nova.network import model as network_model
from nova import notifications
from nova.objects import instance as instance_obj
from nova.openstack.common import log
from nova.openstack.common.notifier import api as notifier_api
from nova.openstack.common import timeutils
@@ -276,9 +277,14 @@ def notify_about_aggregate_update(context, event_suffix, aggregate_payload):
def get_nw_info_for_instance(instance):
if isinstance(instance, instance_obj.Instance):
return instance.info_cache.network_info
# FIXME(comstud): Transitional while we convert to objects.
info_cache = instance['info_cache'] or {}
cached_nwinfo = info_cache.get('network_info') or []
return network_model.NetworkInfo.hydrate(cached_nwinfo)
nw_info = info_cache.get('network_info') or []
if not isinstance(nw_info, network_model.NetworkInfo):
nw_info = network_model.NetworkInfo.hydrate(nw_info)
return nw_info
def has_audit_been_run(context, conductor, host, timestamp=None):