summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Wurtz <michael.wurtz@ibm.com>2016-08-18 14:53:33 -0500
committerMatt Riedemann <mriedem@us.ibm.com>2016-09-07 17:29:09 -0400
commit15cfd039fe30456e9ff19cfb9572d981c6b991f6 (patch)
tree2b4f0a4ad399f01962c7de88fad843d8a5dafc24
parent53fffe02bbabdd71d3cd829d73fba0c19c9b9175 (diff)
downloadnova-15cfd039fe30456e9ff19cfb9572d981c6b991f6.tar.gz
Refresh info_cache after deleting floating IP
When deleting a floating IP associated with Neutron's info_cache we don't refresh the info_cache after it is deleted. This patch makes it so the info_cache is refreshed when an associated floating IP is deleted. If there is no info_cache associated with the floating IP then info_cache is not refreshed. Change-Id: I8a8ae8cdbe2d9d77e7f1ae94ebdf6e4ad46eaf00 Closes-Bug: #1614538 (cherry picked from commit cdb9b6820dc17971bca24adfc0b56f030f0ae827) (cherry picked from commit a832e6b2a019323fdf00e30302ad5c3c809baa21)
-rw-r--r--nova/network/neutronv2/api.py14
-rw-r--r--nova/tests/unit/network/test_neutronv2.py15
2 files changed, 27 insertions, 2 deletions
diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py
index 2b0298d40f..9786366e63 100644
--- a/nova/network/neutronv2/api.py
+++ b/nova/network/neutronv2/api.py
@@ -1540,8 +1540,18 @@ class API(base_api.NetworkAPI):
This api call was added to allow this to be done in one operation
if using neutron.
"""
- self._release_floating_ip(context, floating_ip['address'],
- raise_if_associated=False)
+
+ @base_api.refresh_cache
+ def _release_floating_ip_and_refresh_cache(self, context, instance,
+ floating_ip):
+ self._release_floating_ip(context, floating_ip['address'],
+ raise_if_associated=False)
+ if instance:
+ _release_floating_ip_and_refresh_cache(self, context, instance,
+ floating_ip)
+ else:
+ self._release_floating_ip(context, floating_ip['address'],
+ raise_if_associated=False)
def _release_floating_ip(self, context, address,
raise_if_associated=True):
diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py
index 25aca611ed..2cbd0775cf 100644
--- a/nova/tests/unit/network/test_neutronv2.py
+++ b/nova/tests/unit/network/test_neutronv2.py
@@ -2207,6 +2207,21 @@ class TestNeutronv2(TestNeutronv2Base):
api.disassociate_and_release_floating_ip(self.context, None,
floating_ip)
+ def test_disassociate_and_release_floating_ip_with_instance(self):
+ api = neutronapi.API()
+ address = self.fip_unassociated['floating_ip_address']
+ fip_id = self.fip_unassociated['id']
+ floating_ip = {'address': address}
+ instance = self._fake_instance_object(self.instance)
+
+ self.moxed_client.list_floatingips(floating_ip_address=address).\
+ AndReturn({'floatingips': [self.fip_unassociated]})
+ self.moxed_client.delete_floatingip(fip_id)
+ self._setup_mock_for_refresh_cache(api, [instance])
+ self.mox.ReplayAll()
+ api.disassociate_and_release_floating_ip(self.context, instance,
+ floating_ip)
+
def test_release_floating_ip_associated(self):
api = neutronapi.API()
address = self.fip_associated['floating_ip_address']