summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-14 02:07:10 +0000
committerGerrit Code Review <review@openstack.org>2013-03-14 02:07:10 +0000
commit2830ef14eca5695e796e8e3104528bbc8766bafa (patch)
tree74cb0d6edd916eb0940d6de338d487254abdbda7
parentebff2030cccc6e59717fc4a689ca3ab461a08374 (diff)
parente4d52f45c65704a3c153137a3d997aa3cccd8a79 (diff)
Merge "Fix cells instance deletion"
-rw-r--r--nova/compute/cells_api.py4
-rw-r--r--nova/tests/compute/test_compute_cells.py31
2 files changed, 33 insertions, 2 deletions
diff --git a/nova/compute/cells_api.py b/nova/compute/cells_api.py
index 6f974f9c5..fe6f5dc62 100644
--- a/nova/compute/cells_api.py
+++ b/nova/compute/cells_api.py
@@ -255,9 +255,9 @@ class ComputeCellsAPI(compute_api.API):
# broadcast a message down to all cells and hope this ends
# up resolving itself... Worse case.. the instance will
# show back up again here.
- delete_type = method == 'soft_delete' and 'soft' or 'hard'
+ delete_type = method_name == 'soft_delete' and 'soft' or 'hard'
self.cells_rpcapi.instance_delete_everywhere(context,
- instance['uuid'], delete_type)
+ instance, delete_type)
@validate_cell
def restore(self, context, instance):
diff --git a/nova/tests/compute/test_compute_cells.py b/nova/tests/compute/test_compute_cells.py
index 190d75a9d..78100bcc3 100644
--- a/nova/tests/compute/test_compute_cells.py
+++ b/nova/tests/compute/test_compute_cells.py
@@ -21,6 +21,7 @@ import functools
from nova.compute import api as compute_api
from nova.compute import cells_api as compute_cells_api
from nova import db
+from nova import exception
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova import quota
@@ -192,6 +193,36 @@ class CellsComputeAPITestCase(test_compute.ComputeAPITestCase):
def test_evacuate(self):
self.skipTest("Test is incompatible with cells.")
+ def test_delete_instance_no_cell(self):
+ cells_rpcapi = self.compute_api.cells_rpcapi
+ self.mox.StubOutWithMock(cells_rpcapi,
+ 'instance_delete_everywhere')
+ self.mox.StubOutWithMock(self.compute_api,
+ '_cast_to_cells')
+ inst = self._create_fake_instance()
+ exc = exception.InstanceUnknownCell(instance_uuid=inst['uuid'])
+ self.compute_api._cast_to_cells(self.context, inst,
+ 'delete').AndRaise(exc)
+ cells_rpcapi.instance_delete_everywhere(self.context,
+ inst, 'hard')
+ self.mox.ReplayAll()
+ self.compute_api.delete(self.context, inst)
+
+ def test_soft_delete_instance_no_cell(self):
+ cells_rpcapi = self.compute_api.cells_rpcapi
+ self.mox.StubOutWithMock(cells_rpcapi,
+ 'instance_delete_everywhere')
+ self.mox.StubOutWithMock(self.compute_api,
+ '_cast_to_cells')
+ inst = self._create_fake_instance()
+ exc = exception.InstanceUnknownCell(instance_uuid=inst['uuid'])
+ self.compute_api._cast_to_cells(self.context, inst,
+ 'soft_delete').AndRaise(exc)
+ cells_rpcapi.instance_delete_everywhere(self.context,
+ inst, 'soft')
+ self.mox.ReplayAll()
+ self.compute_api.soft_delete(self.context, inst)
+
class CellsComputePolicyTestCase(test_compute.ComputePolicyTestCase):
def setUp(self):