Merge "Change HostManager to allow scheduling to other cells"

This commit is contained in:
Zuul 2019-08-29 05:47:29 +00:00 committed by Gerrit Code Review
commit eb6fcb2191
2 changed files with 27 additions and 1 deletions

View File

@ -755,9 +755,12 @@ class HostManager(object):
if not self.cells:
LOG.warning("No cells were found")
# Restrict to a single cell if and only if the request spec has a
# requested cell and allow_cross_cell_move=False.
if (spec_obj and 'requested_destination' in spec_obj and
spec_obj.requested_destination and
'cell' in spec_obj.requested_destination):
'cell' in spec_obj.requested_destination and
not spec_obj.requested_destination.allow_cross_cell_move):
only_cell = spec_obj.requested_destination.cell
else:
only_cell = None

View File

@ -1319,6 +1319,29 @@ class HostManagerChangedNodesTestCase(test.NoDBTestCase):
num_hosts2 = len(list(host_states2))
self.assertEqual(0, num_hosts2)
@mock.patch('nova.scheduler.host_manager.HostManager.'
'_get_computes_for_cells',
return_value=(mock.sentinel.compute_nodes,
mock.sentinel.services))
@mock.patch('nova.scheduler.host_manager.HostManager._get_host_states')
def test_get_host_states_by_uuids_allow_cross_cell_move(
self, mock_get_host_states, mock_get_computes):
"""Tests that get_host_states_by_uuids will not restrict to a given
cell if allow_cross_cell_move=True in the request spec.
"""
ctxt = nova_context.get_admin_context()
compute_uuids = [uuids.compute_node_uuid]
spec_obj = objects.RequestSpec(
requested_destination=objects.Destination(
cell=objects.CellMapping(uuid=uuids.cell1),
allow_cross_cell_move=True))
self.host_manager.get_host_states_by_uuids(
ctxt, compute_uuids, spec_obj)
mock_get_computes.assert_called_once_with(
ctxt, self.host_manager.enabled_cells, compute_uuids=compute_uuids)
mock_get_host_states.assert_called_once_with(
ctxt, mock.sentinel.compute_nodes, mock.sentinel.services)
class HostStateTestCase(test.NoDBTestCase):
"""Test case for HostState class."""