Skip to content

Commit

Permalink
Merge "Remove dead HostAPI.service_delete code"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Nov 13, 2019
2 parents 207bb41 + 8b5da30 commit 292a678
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
14 changes: 0 additions & 14 deletions nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5426,20 +5426,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."""
Expand Down
42 changes: 0 additions & 42 deletions nova/tests/unit/compute/test_host_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down

0 comments on commit 292a678

Please sign in to comment.