public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 92ef176..5f97e70 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -304,6 +304,11 @@ def get_networks_for_instance_from_nw_info(nw_info):
return networks
+def get_nwinfo_for_instance(context, instance):
+ cached_nwinfo = instance['info_cache'].get('network_info') or []
+ return network_model.NetworkInfo.hydrate(cached_nwinfo)
+
+
def get_networks_for_instance(context, instance):
"""Returns a prepared nw_info list for passing into the view
builders
@@ -315,11 +320,7 @@ def get_networks_for_instance(context, instance):
{'addr': '172.16.2.1', 'version': 4}]},
...}
"""
-
- cached_nwinfo = instance['info_cache']['network_info']
- if not cached_nwinfo:
- return {}
- nw_info = network_model.NetworkInfo.hydrate(cached_nwinfo)
+ nw_info = get_nwinfo_for_instance(context, instance)
return get_networks_for_instance_from_nw_info(nw_info)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.