Skip to content

Commit 8b5da30

Browse files
committed
Remove dead HostAPI.service_delete code
Ie1aa45a508fbba16e969f216398dee15b37a9569 stopped using this in the API but at the time there was still some complexity with the Cells v1 API code. Since that Cells v1 code is gone now nothing is using this so we can remove it. Change-Id: I6681734783f7649cedb34e2ea533c00f645e3360
1 parent f28839b commit 8b5da30

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

nova/compute/api.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5351,20 +5351,6 @@ def service_update_by_host_and_binary(self, context, host_name, binary,
53515351
service.update(params_to_update)
53525352
return self.service_update(context, service)
53535353

5354-
def _service_delete(self, context, service_id):
5355-
"""Performs the actual Service deletion operation."""
5356-
try:
5357-
service = _find_service_in_cell(context, service_id=service_id)
5358-
except exception.NotFound:
5359-
raise exception.ServiceNotFound(service_id=service_id)
5360-
service.destroy()
5361-
5362-
# TODO(mriedem): Nothing outside of tests is using this now so we should
5363-
# be able to remove it.
5364-
def service_delete(self, context, service_id):
5365-
"""Deletes the specified service found via id or uuid."""
5366-
self._service_delete(context, service_id)
5367-
53685354
@target_host_cell
53695355
def instance_get_all_by_host(self, context, host_name):
53705356
"""Return all instances on the given host."""

nova/tests/unit/compute/test_host_api.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -463,48 +463,6 @@ def _fake_set_target_cell(ctxt, cell_mapping):
463463
[mock.call(ctxt, uuids.service_uuid)] * 2)
464464
self.assertEqual('db://fake2', ctxt.db_connection)
465465

466-
@mock.patch('nova.context.set_target_cell')
467-
@mock.patch('nova.compute.api.load_cells')
468-
@mock.patch('nova.objects.Service.get_by_id')
469-
def test_service_delete(self, get_by_id, load_cells, set_target):
470-
compute.CELLS = [
471-
objects.CellMapping(),
472-
objects.CellMapping(),
473-
objects.CellMapping(),
474-
]
475-
476-
service = mock.MagicMock()
477-
get_by_id.side_effect = [exception.ServiceNotFound(service_id=1),
478-
service,
479-
exception.ServiceNotFound(service_id=1)]
480-
self.host_api.service_delete(self.ctxt, 1)
481-
get_by_id.assert_has_calls([mock.call(self.ctxt, 1),
482-
mock.call(self.ctxt, 1),
483-
mock.call(self.ctxt, 1)])
484-
service.destroy.assert_called_once_with()
485-
set_target.assert_called_once_with(self.ctxt, compute.CELLS[1])
486-
487-
@mock.patch('nova.context.set_target_cell')
488-
@mock.patch('nova.compute.api.load_cells')
489-
@mock.patch('nova.objects.Service.get_by_id')
490-
def test_service_delete_ambiguous(self, get_by_id, load_cells, set_target):
491-
compute.CELLS = [
492-
objects.CellMapping(),
493-
objects.CellMapping(),
494-
objects.CellMapping(),
495-
]
496-
497-
service1 = mock.MagicMock()
498-
service2 = mock.MagicMock()
499-
get_by_id.side_effect = [exception.ServiceNotFound(service_id=1),
500-
service1,
501-
service2]
502-
self.assertRaises(exception.ServiceNotUnique,
503-
self.host_api.service_delete, self.ctxt, 1)
504-
self.assertFalse(service1.destroy.called)
505-
self.assertFalse(service2.destroy.called)
506-
self.assertFalse(set_target.called)
507-
508466
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
509467
'aggregate_remove_host')
510468
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'

0 commit comments

Comments
 (0)