summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xnova/compute/manager.py2
-rw-r--r--nova/tests/compute/test_compute.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index e0b2f38e8..1a6479f7f 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1345,7 +1345,7 @@ class ComputeManager(manager.SchedulerDependentManager):
# get network info before tearing down
try:
network_info = self._get_instance_nw_info(context, instance)
- except exception.NetworkNotFound:
+ except (exception.NetworkNotFound, exception.NoMoreFixedIps):
network_info = network_model.NetworkInfo()
# NOTE(vish) get bdms before destroying the instance
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index c887041f8..7953f8b63 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1217,6 +1217,30 @@ class ComputeTestCase(BaseTestCase):
LOG.info(_("After terminating instances: %s"), instances)
self.assertEqual(len(instances), 0)
+ def test_terminate_no_fixed_ips(self):
+ # This is as reported in LP bug 1192893
+ instance = jsonutils.to_primitive(self._create_fake_instance())
+
+ self.compute.run_instance(self.context, instance=instance)
+
+ instances = db.instance_get_all(self.context)
+ LOG.info(_("Running instances: %s"), instances)
+ self.assertEqual(len(instances), 1)
+
+ self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
+ self.compute._get_instance_nw_info(
+ mox.IgnoreArg(),
+ mox.IgnoreArg()).AndRaise(
+ exception.NoMoreFixedIps()
+ )
+ self.mox.ReplayAll()
+
+ self.compute.terminate_instance(self.context, instance=instance)
+
+ instances = db.instance_get_all(self.context)
+ LOG.info(_("After terminating instances: %s"), instances)
+ self.assertEqual(len(instances), 0)
+
def test_terminate_failure_leaves_task_state(self):
"""Ensure that a failure in terminate_instance does not result
in the task state being reverted from DELETING (see LP 1046236).