From 0c2ce3980459526a01696b63ea5d5294987ad19b Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Tue, 28 Feb 2012 07:53:29 +0000 Subject: Handle case where instance['info_cache'] is None Fixes bug 942443 Change-Id: I77c3495d1de0a9b73acc576dd0638b430a4ce16e --- nova/api/ec2/ec2utils.py | 3 ++- nova/api/openstack/common.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py index e0f336d4c..e44ae287e 100644 --- a/nova/api/ec2/ec2utils.py +++ b/nova/api/ec2/ec2utils.py @@ -86,7 +86,8 @@ def get_ip_info_for_instance_from_nw_info(nw_info): def get_ip_info_for_instance(context, instance): """Return a dictionary of IP information for an instance""" - cached_nwinfo = instance['info_cache']['network_info'] + info_cache = instance['info_cache'] or {} + cached_nwinfo = info_cache.get('network_info') # Make sure empty response is turned into [] if not cached_nwinfo: cached_nwinfo = [] diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 12fbb509b..bc49a3948 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -305,7 +305,8 @@ def get_networks_for_instance_from_nw_info(nw_info): def get_nw_info_for_instance(context, instance): - cached_nwinfo = instance['info_cache'].get('network_info') or [] + info_cache = instance['info_cache'] or {} + cached_nwinfo = info_cache.get('network_info') or [] return network_model.NetworkInfo.hydrate(cached_nwinfo) -- cgit