Merge "Remove dead HostAPI.service_delete code"

This commit is contained in:
Zuul
2019-11-13 23:43:46 +00:00
committed by Gerrit Code Review
2 changed files with 0 additions and 56 deletions

View File

@@ -5426,20 +5426,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.'