def test_get_host_supporting_request_first_host_is_new( self, mock_get_service, mock_delete_allocation, mock_claim_resources): self.request_spec.requested_resources = [objects.RequestGroup()] task = self._generate_task() resources = { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } first = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host1: resources } }), allocation_request_version='1.19') alternate = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host2: resources } }), allocation_request_version='1.19') selection_list = [first, alternate] first_service = objects.Service(service_host='host1') first_service.version = 39 mock_get_service.return_value = first_service selected, alternates = task._get_host_supporting_request( selection_list) self.assertEqual(first, selected) self.assertEqual([alternate], alternates) mock_get_service.assert_called_once_with(task.context, 'host1', 'nova-compute') # The first host was good and the scheduler made allocation on that # host. So we don't expect any resource claim manipulation mock_delete_allocation.assert_not_called() mock_claim_resources.assert_not_called()
def setUp(self): super(MigrationTaskTestCase, self).setUp() self.user_id = 'fake' self.project_id = 'fake' self.context = FakeContext(self.user_id, self.project_id) self.flavor = fake_flavor.fake_flavor_obj(self.context) self.flavor.extra_specs = {'extra_specs': 'fake'} inst = fake_instance.fake_db_instance(image_ref='image_ref', instance_type=self.flavor) inst_object = objects.Instance( flavor=self.flavor, numa_topology=None, pci_requests=None, system_metadata={'image_hw_disk_bus': 'scsi'}) self.instance = objects.Instance._from_db_object( self.context, inst_object, inst, []) self.request_spec = objects.RequestSpec(image=objects.ImageMeta()) self.host_lists = [[objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1)]] self.filter_properties = {'limits': {}, 'retry': {'num_attempts': 1, 'hosts': [['host1', 'node1']]}} self.reservations = [] self.clean_shutdown = True _p = mock.patch('nova.compute.utils.heal_reqspec_is_bfv') self.heal_reqspec_is_bfv_mock = _p.start() self.addCleanup(_p.stop) _p = mock.patch('nova.objects.RequestSpec.ensure_network_metadata') self.ensure_network_metadata_mock = _p.start() self.addCleanup(_p.stop)
def test_selection_obj_to_dict_no_numa(self): """Tests that to_dict() method properly converts a Selection object to the corresponding dict when the numa_topology field is None. """ fake_limit = { "memory_mb": 1024, "disk_gb": 100, "vcpus": 2, "numa_topology": None } fake_limit_obj = objects.SchedulerLimits.from_dict(fake_limit) sel_obj = objects.Selection(service_host="fakehost", nodename="fakenode", compute_node_uuid=uuids.host, cell_uuid=uuids.cell, limits=fake_limit_obj, allocation_request="fake", allocation_request_version="99.9") expected = { "host": "fakehost", "nodename": "fakenode", "limits": { "disk_gb": 100, "memory_mb": 1024 } } result = sel_obj.to_dict() self.assertDictEqual(expected, result)
def test_is_selected_host_in_source_cell_true(self): """Tests the scenario that the host Selection from the scheduler is in the same cell as the instance. """ task = self._generate_task() selection = objects.Selection(cell_uuid=self.context.cell_uuid) self.assertTrue(task._is_selected_host_in_source_cell(selection))
def test_is_selected_host_in_source_cell_false(self): """Tests the scenario that the host Selection from the scheduler is not in the same cell as the instance. """ task = self._generate_task() selection = objects.Selection(cell_uuid=uuids.cell2, service_host='x') self.assertFalse(task._is_selected_host_in_source_cell(selection))
def _test_populate_filter_props(self, selection_obj=True, with_retry=True, force_hosts=None, force_nodes=None, no_limits=None): if force_hosts is None: force_hosts = [] if force_nodes is None: force_nodes = [] if with_retry: if ((len(force_hosts) == 1 and len(force_nodes) <= 1) or (len(force_nodes) == 1 and len(force_hosts) <= 1)): filter_properties = dict(force_hosts=force_hosts, force_nodes=force_nodes) elif len(force_hosts) > 1 or len(force_nodes) > 1: filter_properties = dict(retry=dict(hosts=[]), force_hosts=force_hosts, force_nodes=force_nodes) else: filter_properties = dict(retry=dict(hosts=[])) else: filter_properties = dict() if no_limits: fake_limits = None else: fake_limits = objects.SchedulerLimits(vcpu=1, disk_gb=2, memory_mb=3, numa_topology=None) selection = objects.Selection(service_host="fake-host", nodename="fake-node", limits=fake_limits) if not selection_obj: selection = selection.to_dict() fake_limits = fake_limits.to_dict() scheduler_utils.populate_filter_properties(filter_properties, selection) enable_retry_force_hosts = not force_hosts or len(force_hosts) > 1 enable_retry_force_nodes = not force_nodes or len(force_nodes) > 1 if with_retry or enable_retry_force_hosts or enable_retry_force_nodes: # So we can check for 2 hosts scheduler_utils.populate_filter_properties(filter_properties, selection) if force_hosts: expected_limits = None elif no_limits: expected_limits = {} else: expected_limits = fake_limits self.assertEqual(expected_limits, filter_properties.get('limits')) if (with_retry and enable_retry_force_hosts and enable_retry_force_nodes): self.assertEqual([['fake-host', 'fake-node'], ['fake-host', 'fake-node']], filter_properties['retry']['hosts']) else: self.assertNotIn('retry', filter_properties)
def test_select_destination_return_objects(self, mock_get_ac, mock_rfrs, mock_process): fake_spec = objects.RequestSpec() fake_spec.instance_uuid = uuids.instance fake_version = "9.42" mock_p_sums = mock.Mock() fake_alloc_reqs = fakes.get_fake_alloc_reqs() place_res = (fake_alloc_reqs, mock_p_sums, fake_version) mock_get_ac.return_value = place_res mock_rfrs.return_value.cpu_pinning_requested = False expected_alloc_reqs_by_rp_uuid = { cn.uuid: [fake_alloc_reqs[x]] for x, cn in enumerate(fakes.COMPUTE_NODES) } with mock.patch.object(self.manager.driver, 'select_destinations') as select_destinations: sel_obj = objects.Selection(service_host="fake_host", nodename="fake_node", compute_node_uuid=uuids.compute_node, cell_uuid=uuids.cell, limits=None) select_destinations.return_value = [[sel_obj]] # Pass True; should get the Selection object back. dests = self.manager.select_destinations( None, spec_obj=fake_spec, instance_uuids=[fake_spec.instance_uuid], return_objects=True, return_alternates=True) sel_host = dests[0][0] self.assertIsInstance(sel_host, objects.Selection) mock_process.assert_called_once_with(None, fake_spec) # Since both return_objects and return_alternates are True, the # driver should have been called with True for return_alternates. select_destinations.assert_called_once_with( None, fake_spec, [fake_spec.instance_uuid], expected_alloc_reqs_by_rp_uuid, mock_p_sums, fake_version, True) # Now pass False for return objects, but keep return_alternates as # True. Verify that the manager converted the Selection object back # to a dict. select_destinations.reset_mock() dests = self.manager.select_destinations( None, spec_obj=fake_spec, instance_uuids=[fake_spec.instance_uuid], return_objects=False, return_alternates=True) sel_host = dests[0] self.assertIsInstance(sel_host, dict) # Even though return_alternates was passed as True, since # return_objects was False, the driver should have been called with # return_alternates as False. select_destinations.assert_called_once_with( None, fake_spec, [fake_spec.instance_uuid], expected_alloc_reqs_by_rp_uuid, mock_p_sums, fake_version, False)
def test_passing_numeric_allocation_version_converts(self): json_alloc = jsonutils.dumps(fake_alloc1) dest = objects.Selection(service_host="host", compute_node_uuid=uuids.host, nodename="node", cell_uuid=uuids.cell, allocation_request=json_alloc, allocation_request_version=1.23) self.assertEqual("1.23", dest.allocation_request_version)
def test_get_host_supporting_request_no_resource_request( self, mock_get_service, mock_delete_allocation, mock_claim_resources): # no resource request so we expect the first host is simply returned self.request_spec.requested_resources = [] task = self._generate_task() resources = { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } first = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host1: resources } }), allocation_request_version='1.19') alternate = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host2: resources } }), allocation_request_version='1.19') selection_list = [first, alternate] selected, alternates = task._get_host_supporting_request( selection_list) self.assertEqual(first, selected) self.assertEqual([alternate], alternates) mock_get_service.assert_not_called() # The first host was good and the scheduler made allocation on that # host. So we don't expect any resource claim manipulation mock_delete_allocation.assert_not_called() mock_claim_resources.assert_not_called()
def test_obj_make_compatible(self): selection = objects.Selection(service_host='host1', availability_zone='zone1') primitive = selection.obj_to_primitive( target_version='1.1')['nova_object.data'] self.assertIn('availability_zone', primitive) primitive = selection.obj_to_primitive( target_version='1.0')['nova_object.data'] self.assertNotIn('availability_zone', primitive) self.assertIn('service_host', primitive)
def setUp(self): super(CrossCellMigrationTaskTestCase, self).setUp() source_context = nova_context.get_context() host_selection = objects.Selection(cell_uuid=uuids.cell_uuid) migration = objects.Migration(id=1, cross_cell_move=False) self.task = cross_cell_migrate.CrossCellMigrationTask( source_context, mock.sentinel.instance, mock.sentinel.flavor, mock.sentinel.request_spec, migration, mock.sentinel.compute_rpcapi, host_selection, mock.sentinel.alternate_hosts)
def test_post_select_populate(self): # Test addition of certain filter props after a node is selected. retry = {'hosts': [], 'num_attempts': 1} filter_properties = {'retry': retry} selection = objects.Selection(service_host="host", nodename="node", cell_uuid=uuids.cell) scheduler_utils.populate_filter_properties(filter_properties, selection) self.assertEqual(['host', 'node'], filter_properties['retry']['hosts'][0])
def setUp(self): super(CrossCellMigrationTaskTestCase, self).setUp() source_context = nova_context.get_context() host_selection = objects.Selection(service_host='target.host.com', cell_uuid=uuids.cell_uuid) migration = objects.Migration(id=1, cross_cell_move=False, source_compute='source.host.com') instance = objects.Instance() self.task = cross_cell_migrate.CrossCellMigrationTask( source_context, instance, objects.Flavor(), mock.sentinel.request_spec, migration, mock.sentinel.compute_rpcapi, host_selection, mock.sentinel.alternate_hosts)
def setUp(self): super(PrepResizeAtDestTaskTestCase, self).setUp() host_selection = objects.Selection(service_host='fake-host', nodename='fake-host', limits=objects.SchedulerLimits()) self.task = cross_cell_migrate.PrepResizeAtDestTask( nova_context.get_context(), objects.Instance(uuid=uuids.instance), objects.Flavor(), objects.Migration(), objects.RequestSpec(), compute_rpcapi=mock.Mock(), host_selection=host_selection, network_api=mock.Mock(), volume_api=mock.Mock())
def test_create_with_values(self): json_alloc = jsonutils.dumps(fake_alloc1) dest = objects.Selection(service_host="host", nodename="node", compute_node_uuid=uuids.host1, cell_uuid=uuids.cell, limits=fake_limit_obj1, allocation_request=json_alloc, allocation_request_version=fake_alloc_version) self.assertEqual("host", dest.service_host) self.assertEqual(uuids.host1, dest.compute_node_uuid) self.assertEqual("node", dest.nodename) self.assertEqual(uuids.cell, dest.cell_uuid) self.assertEqual(fake_limit_obj1, dest.limits) self.assertEqual(json_alloc, dest.allocation_request) self.assertEqual(fake_alloc_version, dest.allocation_request_version)
def test_selection_obj_to_dict(self): """Tests that to_dict() method properly converts a Selection object to the corresponding dict. """ fake_network_metadata = objects.NetworkMetadata(physnets=set( ['foo', 'bar']), tunneled=True) fake_numa_limit = objects.numa.NUMATopologyLimits( cpu_allocation_ratio=1.0, ram_allocation_ratio=1.0, network_metadata=fake_network_metadata) fake_limit = { "memory_mb": 1024, "disk_gb": 100, "vcpus": 2, "numa_topology": fake_numa_limit } fake_limit_obj = objects.SchedulerLimits.from_dict(fake_limit) sel_obj = objects.Selection(service_host="fakehost", nodename="fakenode", compute_node_uuid=uuids.host, cell_uuid=uuids.cell, limits=fake_limit_obj, allocation_request="fake", allocation_request_version="99.9") result = sel_obj.to_dict() self.assertEqual(['host', 'limits', 'nodename'], sorted(result.keys())) self.assertEqual('fakehost', result['host']) self.assertEqual('fakenode', result['nodename']) limits = result['limits'] self.assertEqual(['disk_gb', 'memory_mb', 'numa_topology'], sorted(limits.keys())) self.assertEqual(100, limits['disk_gb']) self.assertEqual(1024, limits['memory_mb']) numa_topology = limits['numa_topology']['nova_object.data'] self.assertEqual(1.0, numa_topology['cpu_allocation_ratio']) self.assertEqual(1.0, numa_topology['ram_allocation_ratio']) network_meta = numa_topology['network_metadata']['nova_object.data'] # sets are unordered so we need to convert to a list self.assertEqual(['bar', 'foo'], sorted(network_meta['physnets'])) self.assertTrue(network_meta['tunneled'])
def test_selection_obj_to_dict(self): """Tests that to_dict() method properly converts a Selection object to the corresponding dict. """ fake_numa_limit = objects.numa.NUMATopologyLimits( cpu_allocation_ratio=1.0, ram_allocation_ratio=1.0) fake_limit = { "memory_mb": 1024, "disk_gb": 100, "vcpus": 2, "numa_topology": fake_numa_limit } fake_limit_obj = objects.SchedulerLimits.from_dict(fake_limit) sel_obj = objects.Selection(service_host="fakehost", nodename="fakenode", compute_node_uuid=uuids.host, cell_uuid=uuids.cell, limits=fake_limit_obj, allocation_request="fake", allocation_request_version="99.9") expected = { 'host': 'fakehost', 'nodename': 'fakenode', 'limits': { 'disk_gb': 100, 'memory_mb': 1024, 'numa_topology': { 'nova_object.changes': ['cpu_allocation_ratio', 'ram_allocation_ratio'], 'nova_object.data': { 'cpu_allocation_ratio': 1.0, 'ram_allocation_ratio': 1.0 }, 'nova_object.name': 'NUMATopologyLimits', 'nova_object.namespace': 'nova', 'nova_object.version': '1.0' } } } result = sel_obj.to_dict() self.assertDictEqual(expected, result)
def test_execute_reschedule(self, mock_elevated, mock_claim, mock_fill_provider_mapping): report_client = report.SchedulerReportClient() # setup task for re-schedule alloc_req = { "allocations": { uuids.host1: { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } } } alternate_selection = objects.Selection( service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps(alloc_req), allocation_request_version='1.19') task = migrate.MigrationTask(self.context, self.instance, self.flavor, self.request_spec, self.clean_shutdown, compute_rpcapi.ComputeAPI(), query.SchedulerQueryClient(), report_client, host_list=[alternate_selection], network_api=self.mock_network_api) mock_claim.return_value = True actual_selection = task._reschedule() self.assertIs(alternate_selection, actual_selection) mock_claim.assert_called_once_with(mock_elevated.return_value, report_client, self.request_spec, self.instance.uuid, alloc_req, '1.19') mock_fill_provider_mapping.assert_called_once_with( self.context, report_client, self.request_spec, alternate_selection)
def test_get_host_supporting_request_first_host_is_old_no_alternates( self, mock_get_service, mock_delete_allocation, mock_claim_resources): self.request_spec.requested_resources = [objects.RequestGroup()] task = self._generate_task() resources = { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } first = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host1: resources } }), allocation_request_version='1.19') selection_list = [first] first_service = objects.Service(service_host='host1') first_service.version = 38 mock_get_service.return_value = first_service self.assertRaises(exception.MaxRetriesExceeded, task._get_host_supporting_request, selection_list) mock_get_service.assert_called_once_with(task.context, 'host1', 'nova-compute') mock_delete_allocation.assert_called_once_with(task.context, self.instance.uuid) mock_claim_resources.assert_not_called()
def test_reschedule_old_compute_skipped(self, mock_get_service, mock_claim_resources, mock_debug): self.request_spec.requested_resources = [ objects.RequestGroup(requester_id=uuids.port1) ] task = self._generate_task() resources = { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } first = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host1: resources }, "mappings": { uuids.port1: [uuids.host1] } }), allocation_request_version='1.35') second = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host2: resources }, "mappings": { uuids.port1: [uuids.host2] } }), allocation_request_version='1.35') first_service = objects.Service(service_host='host1') first_service.version = 38 second_service = objects.Service(service_host='host2') second_service.version = 39 mock_get_service.side_effect = [first_service, second_service] # set up task for re-schedule task.host_list = [first, second] selected = task._reschedule() self.assertEqual(second, selected) self.assertEqual([], task.host_list) mock_get_service.assert_has_calls([ mock.call(task.context, 'host1', 'nova-compute'), mock.call(task.context, 'host2', 'nova-compute'), ]) mock_claim_resources.assert_called_once_with( self.context.elevated(), task.reportclient, task.request_spec, self.instance.uuid, { "allocations": { uuids.host2: resources }, "mappings": { uuids.port1: [uuids.host2] } }, '1.35') mock_debug.assert_has_calls([ mock.call( 'Scheduler returned alternate host %(host)s as a possible ' 'migration target for re-schedule but that host is not ' 'new enough to support the migration with resource ' 'request %(request)s. Trying another alternate.', { 'host': 'host1', 'request': self.request_spec.requested_resources }, instance=self.instance), ])
fake_numa_limit = objects.NUMATopologyLimits(cpu_allocation_ratio=1.0, ram_allocation_ratio=1.0) fake_limit = {"memory_mb": 1024, "disk_gb": 100, "vcpus": 2, "numa_topology": fake_numa_limit} fake_limit_obj = objects.SchedulerLimits.from_dict(fake_limit) fake_alloc = {"allocations": [ {"resource_provider": {"uuid": uuids.compute_node}, "resources": {"VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100} }]} fake_alloc_version = "1.23" json_alloc = jsonutils.dumps(fake_alloc) fake_selection = objects.Selection(service_host="fake_host", nodename="fake_node", compute_node_uuid=uuids.compute_node, cell_uuid=uuids.cell, limits=fake_limit_obj, allocation_request=json_alloc, allocation_request_version=fake_alloc_version) class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): """Test case for Filter Scheduler.""" driver_cls = filter_scheduler.FilterScheduler @mock.patch('nova.scheduler.client.SchedulerClient') def setUp(self, mock_client): pc_client = mock.Mock(spec=report.SchedulerReportClient) sched_client = mock.Mock(spec=client.SchedulerClient) sched_client.reportclient = pc_client mock_client.return_value = sched_client
def test_reschedule_old_computes_no_more_alternates( self, mock_get_service, mock_claim_resources, mock_fill_mapping, mock_debug): self.request_spec.requested_resources = [objects.RequestGroup()] task = self._generate_task() resources = { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } first = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host1: resources } }), allocation_request_version='1.19') second = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host2: resources } }), allocation_request_version='1.19') first_service = objects.Service(service_host='host1') first_service.version = 38 second_service = objects.Service(service_host='host2') second_service.version = 38 mock_get_service.side_effect = [first_service, second_service] # set up task for re-schedule task.host_list = [first, second] self.assertRaises(exception.MaxRetriesExceeded, task._reschedule) self.assertEqual([], task.host_list) mock_get_service.assert_has_calls([ mock.call(task.context, 'host1', 'nova-compute'), mock.call(task.context, 'host2', 'nova-compute'), ]) mock_claim_resources.assert_not_called() mock_fill_mapping.assert_not_called() mock_debug.assert_has_calls([ mock.call( 'Scheduler returned alternate host %(host)s as a possible ' 'migration target for re-schedule but that host is not ' 'new enough to support the migration with resource ' 'request %(request)s. Trying another alternate.', { 'host': 'host1', 'request': self.request_spec.requested_resources }, instance=self.instance), mock.call( 'Scheduler returned alternate host %(host)s as a possible ' 'migration target for re-schedule but that host is not ' 'new enough to support the migration with resource ' 'request %(request)s. Trying another alternate.', { 'host': 'host2', 'request': self.request_spec.requested_resources }, instance=self.instance), ])
def test_get_host_supporting_request_both_first_and_second_too_old( self, mock_get_service, mock_delete_allocation, mock_claim_resources, mock_debug): self.request_spec.requested_resources = [objects.RequestGroup()] task = self._generate_task() resources = { "resources": { "VCPU": 1, "MEMORY_MB": 1024, "DISK_GB": 100 } } first = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host1: resources } }), allocation_request_version='1.19') second = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host2: resources } }), allocation_request_version='1.19') third = objects.Selection(service_host="host3", nodename="node3", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host3: resources } }), allocation_request_version='1.19') fourth = objects.Selection(service_host="host4", nodename="node4", cell_uuid=uuids.cell1, allocation_request=jsonutils.dumps({ "allocations": { uuids.host4: resources } }), allocation_request_version='1.19') selection_list = [first, second, third, fourth] first_service = objects.Service(service_host='host1') first_service.version = 38 second_service = objects.Service(service_host='host2') second_service.version = 38 third_service = objects.Service(service_host='host3') third_service.version = 39 mock_get_service.side_effect = [ first_service, second_service, third_service ] # not called for the first and second hosts but called for the third mock_claim_resources.side_effect = [True] selected, alternates = task._get_host_supporting_request( selection_list) self.assertEqual(third, selected) self.assertEqual([fourth], alternates) mock_get_service.assert_has_calls([ mock.call(task.context, 'host1', 'nova-compute'), mock.call(task.context, 'host2', 'nova-compute'), mock.call(task.context, 'host3', 'nova-compute'), ]) mock_delete_allocation.assert_called_once_with(task.context, self.instance.uuid) mock_claim_resources.assert_called_once_with( self.context, task.reportclient, task.request_spec, self.instance.uuid, {"allocations": { uuids.host3: resources }}, '1.19') mock_debug.assert_has_calls([ mock.call( 'Scheduler returned host %(host)s as a possible migration ' 'target but that host is not new enough to support the ' 'migration with resource request %(request)s or the compute ' 'RPC is pinned to less than 5.2. Trying alternate hosts.', { 'host': 'host1', 'request': self.request_spec.requested_resources }, instance=self.instance), mock.call( 'Scheduler returned alternate host %(host)s as a possible ' 'migration target but that host is not new enough to support ' 'the migration with resource request %(request)s or the ' 'compute RPC is pinned to less than 5.2. Trying another ' 'alternate.', { 'host': 'host2', 'request': self.request_spec.requested_resources }, instance=self.instance), ])
from nova.compute import vm_states from nova.conductor.tasks import live_migrate from nova import context as nova_context from nova import exception from nova import objects from nova.scheduler.client import query from nova.scheduler.client import report from nova.scheduler import utils as scheduler_utils from nova import servicegroup from nova import test from nova.tests.unit import fake_instance fake_limits1 = objects.SchedulerLimits() fake_selection1 = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell, limits=fake_limits1, compute_node_uuid=uuids.compute_node1) fake_limits2 = objects.SchedulerLimits() fake_selection2 = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell, limits=fake_limits2, compute_node_uuid=uuids.compute_node2) class LiveMigrationTaskTestCase(test.NoDBTestCase): def setUp(self): super(LiveMigrationTaskTestCase, self).setUp() self.context = nova_context.get_admin_context() self.instance_host = "host" self.instance_uuid = uuids.instance self.instance_image = "image_ref" db_instance = fake_instance.fake_db_instance(
from nova.compute import power_state from nova.compute import rpcapi as compute_rpcapi from nova.compute import vm_states from nova.conductor.tasks import live_migrate from nova import exception from nova.network import model as network_model from nova import objects from nova.scheduler import client as scheduler_client from nova.scheduler import utils as scheduler_utils from nova import servicegroup from nova import test from nova.tests.unit import fake_instance from nova import utils fake_selection1 = objects.Selection(service_host="host1", nodename="node1", cell_uuid=uuids.cell) fake_selection2 = objects.Selection(service_host="host2", nodename="node2", cell_uuid=uuids.cell) class LiveMigrationTaskTestCase(test.NoDBTestCase): def setUp(self): super(LiveMigrationTaskTestCase, self).setUp() self.context = "context" self.instance_host = "host" self.instance_uuid = uuids.instance self.instance_image = "image_ref" db_instance = fake_instance.fake_db_instance( host=self.instance_host,