|
| 1 | +From 50d80038cd6cf30245293d05271b0218f2d5e614 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Wed, 6 Sep 2017 19:15:39 +0800 |
| 4 | +Subject: [PATCH] get instance object from compute api |
| 5 | + |
| 6 | +Fix instance has no attribute 'info_cache' issue when |
| 7 | +associate/disassociate floating ip. |
| 8 | + |
| 9 | +Fix redmine #10873 |
| 10 | + |
| 11 | +Signed-off-by: blkart < [email protected]> |
| 12 | +--- |
| 13 | + nova/api/openstack/compute/contrib/floating_ips.py | 5 +++-- |
| 14 | + 1 file changed, 3 insertions(+), 2 deletions(-) |
| 15 | + |
| 16 | +diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py |
| 17 | +index 19a31ae..a23ada1 100644 |
| 18 | +--- a/nova/api/openstack/compute/contrib/floating_ips.py |
| 19 | ++++ b/nova/api/openstack/compute/contrib/floating_ips.py |
| 20 | +@@ -86,7 +86,7 @@ def get_instance_by_floating_ip_addr(self, context, address): |
| 21 | + snagiibfa = self.network_api.get_instance_id_by_floating_address |
| 22 | + instance_id = snagiibfa(context, address) |
| 23 | + if instance_id: |
| 24 | +- return self.compute_api.get(context, instance_id) |
| 25 | ++ return self.compute_api.get(context, instance_id, want_objects=True) |
| 26 | + |
| 27 | + |
| 28 | + def disassociate_floating_ip(self, context, instance, address): |
| 29 | +@@ -206,7 +206,8 @@ class FloatingIPActionController(wsgi.Controller): |
| 30 | + msg = _("Address not specified") |
| 31 | + raise webob.exc.HTTPBadRequest(explanation=msg) |
| 32 | + |
| 33 | +- instance = common.get_instance(self.compute_api, context, id) |
| 34 | ++ instance = common.get_instance(self.compute_api, context, id, |
| 35 | ++ want_objects=True) |
| 36 | + cached_nwinfo = compute_utils.get_nw_info_for_instance(instance) |
| 37 | + if not cached_nwinfo: |
| 38 | + msg = _('No nw_info cache associated with instance') |
| 39 | +-- |
| 40 | +2.1.0 |
| 41 | + |
0 commit comments