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
This commit is contained in:
Matt Riedemann
2019-11-07 15:11:33 -05:00
parent f28839b523
commit 8b5da30eac
2 changed files with 0 additions and 56 deletions

View File

@@ -5351,20 +5351,6 @@ class HostAPI(base.Base):
service.update(params_to_update)
return self.service_update(context, service)
def _service_delete(self, context, service_id):
"""Performs the actual Service deletion operation."""
try:
service = _find_service_in_cell(context, service_id=service_id)
except exception.NotFound:
raise exception.ServiceNotFound(service_id=service_id)
service.destroy()
# TODO(mriedem): Nothing outside of tests is using this now so we should
# be able to remove it.
def service_delete(self, context, service_id):
"""Deletes the specified service found via id or uuid."""
self._service_delete(context, service_id)
@target_host_cell
def instance_get_all_by_host(self, context, host_name):
"""Return all instances on the given host."""

View File

@@ -463,48 +463,6 @@ class ComputeHostAPITestCase(test.TestCase):
[mock.call(ctxt, uuids.service_uuid)] * 2)
self.assertEqual('db://fake2', ctxt.db_connection)
@mock.patch('nova.context.set_target_cell')
@mock.patch('nova.compute.api.load_cells')
@mock.patch('nova.objects.Service.get_by_id')
def test_service_delete(self, get_by_id, load_cells, set_target):
compute.CELLS = [
objects.CellMapping(),
objects.CellMapping(),
objects.CellMapping(),
]
service = mock.MagicMock()
get_by_id.side_effect = [exception.ServiceNotFound(service_id=1),
service,
exception.ServiceNotFound(service_id=1)]
self.host_api.service_delete(self.ctxt, 1)
get_by_id.assert_has_calls([mock.call(self.ctxt, 1),
mock.call(self.ctxt, 1),
mock.call(self.ctxt, 1)])
service.destroy.assert_called_once_with()
set_target.assert_called_once_with(self.ctxt, compute.CELLS[1])
@mock.patch('nova.context.set_target_cell')
@mock.patch('nova.compute.api.load_cells')
@mock.patch('nova.objects.Service.get_by_id')
def test_service_delete_ambiguous(self, get_by_id, load_cells, set_target):
compute.CELLS = [
objects.CellMapping(),
objects.CellMapping(),
objects.CellMapping(),
]
service1 = mock.MagicMock()
service2 = mock.MagicMock()
get_by_id.side_effect = [exception.ServiceNotFound(service_id=1),
service1,
service2]
self.assertRaises(exception.ServiceNotUnique,
self.host_api.service_delete, self.ctxt, 1)
self.assertFalse(service1.destroy.called)
self.assertFalse(service2.destroy.called)
self.assertFalse(set_target.called)
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'aggregate_remove_host')
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'