From 8b5da30eacd209b539f25a27aaa785af88691295 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 7 Nov 2019 15:11:33 -0500 Subject: [PATCH] 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 --- nova/compute/api.py | 14 -------- nova/tests/unit/compute/test_host_api.py | 42 ------------------------ 2 files changed, 56 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 8821680f105..2e0f0e7c46a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -5351,20 +5351,6 @@ def service_update_by_host_and_binary(self, context, host_name, binary, 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.""" diff --git a/nova/tests/unit/compute/test_host_api.py b/nova/tests/unit/compute/test_host_api.py index e986790b130..108667c06b4 100644 --- a/nova/tests/unit/compute/test_host_api.py +++ b/nova/tests/unit/compute/test_host_api.py @@ -463,48 +463,6 @@ def _fake_set_target_cell(ctxt, cell_mapping): [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.'