Merge "Remove legacy RequestSpec compat code from live migrate task"
This commit is contained in:
commit
86da9c72c1
@ -25,7 +25,6 @@ from nova import network
|
|||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.objects import fields as obj_fields
|
from nova.objects import fields as obj_fields
|
||||||
from nova.scheduler import utils as scheduler_utils
|
from nova.scheduler import utils as scheduler_utils
|
||||||
from nova import utils
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CONF = nova.conf.CONF
|
CONF = nova.conf.CONF
|
||||||
@ -340,25 +339,11 @@ class LiveMigrationTask(base.TaskBase):
|
|||||||
This is generally at least seeded with the source host.
|
This is generally at least seeded with the source host.
|
||||||
:returns: nova.objects.RequestSpec object
|
:returns: nova.objects.RequestSpec object
|
||||||
"""
|
"""
|
||||||
if not self.request_spec:
|
request_spec = self.request_spec
|
||||||
# NOTE(sbauza): We were unable to find an original RequestSpec
|
# NOTE(sbauza): Force_hosts/nodes needs to be reset
|
||||||
# object - probably because the instance is old.
|
# if we want to make sure that the next destination
|
||||||
# We need to mock that the old way
|
# is not forced to be the original host
|
||||||
image = utils.get_image_from_system_metadata(
|
request_spec.reset_forced_destinations()
|
||||||
self.instance.system_metadata)
|
|
||||||
filter_properties = {'ignore_hosts': attempted_hosts}
|
|
||||||
request_spec = objects.RequestSpec.from_components(
|
|
||||||
self.context, self.instance.uuid, image,
|
|
||||||
self.instance.flavor, self.instance.numa_topology,
|
|
||||||
self.instance.pci_requests,
|
|
||||||
filter_properties, None, self.instance.availability_zone
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
request_spec = self.request_spec
|
|
||||||
# NOTE(sbauza): Force_hosts/nodes needs to be reset
|
|
||||||
# if we want to make sure that the next destination
|
|
||||||
# is not forced to be the original host
|
|
||||||
request_spec.reset_forced_destinations()
|
|
||||||
scheduler_utils.setup_instance_group(self.context, request_spec)
|
scheduler_utils.setup_instance_group(self.context, request_spec)
|
||||||
|
|
||||||
# We currently only support live migrating to hosts in the same
|
# We currently only support live migrating to hosts in the same
|
||||||
|
@ -28,7 +28,6 @@ from nova.scheduler import utils as scheduler_utils
|
|||||||
from nova import servicegroup
|
from nova import servicegroup
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests.unit import fake_instance
|
from nova.tests.unit import fake_instance
|
||||||
from nova import utils
|
|
||||||
|
|
||||||
|
|
||||||
fake_selection1 = objects.Selection(service_host="host1", nodename="node1",
|
fake_selection1 = objects.Selection(service_host="host1", nodename="node1",
|
||||||
@ -400,47 +399,6 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
|||||||
mock_check.assert_called_once_with('host1')
|
mock_check.assert_called_once_with('host1')
|
||||||
mock_call.assert_called_once_with('host1')
|
mock_call.assert_called_once_with('host1')
|
||||||
|
|
||||||
def test_find_destination_works_with_no_request_spec(self):
|
|
||||||
task = live_migrate.LiveMigrationTask(
|
|
||||||
self.context, self.instance, self.destination,
|
|
||||||
self.block_migration, self.disk_over_commit, self.migration,
|
|
||||||
compute_rpcapi.ComputeAPI(), servicegroup.API(),
|
|
||||||
scheduler_client.SchedulerClient(), request_spec=None)
|
|
||||||
another_spec = objects.RequestSpec()
|
|
||||||
self.instance.flavor = objects.Flavor()
|
|
||||||
self.instance.numa_topology = None
|
|
||||||
self.instance.pci_requests = None
|
|
||||||
|
|
||||||
@mock.patch.object(task, '_call_livem_checks_on_host')
|
|
||||||
@mock.patch.object(task, '_check_compatible_with_source_hypervisor')
|
|
||||||
@mock.patch.object(task.scheduler_client, 'select_destinations')
|
|
||||||
@mock.patch.object(objects.RequestSpec, 'from_components')
|
|
||||||
@mock.patch.object(scheduler_utils, 'setup_instance_group')
|
|
||||||
@mock.patch.object(utils, 'get_image_from_system_metadata')
|
|
||||||
def do_test(get_image, setup_ig, from_components, select_dest,
|
|
||||||
check_compat, call_livem_checks):
|
|
||||||
get_image.return_value = "image"
|
|
||||||
from_components.return_value = another_spec
|
|
||||||
select_dest.return_value = [[fake_selection1]]
|
|
||||||
|
|
||||||
self.assertEqual(("host1", "node1"), task._find_destination())
|
|
||||||
|
|
||||||
get_image.assert_called_once_with(self.instance.system_metadata)
|
|
||||||
setup_ig.assert_called_once_with(self.context, another_spec)
|
|
||||||
self.ensure_network_metadata_mock.assert_called_once_with(
|
|
||||||
self.instance)
|
|
||||||
self.heal_reqspec_is_bfv_mock.assert_called_once_with(
|
|
||||||
self.context, another_spec, self.instance)
|
|
||||||
select_dest.assert_called_once_with(self.context, another_spec,
|
|
||||||
[self.instance.uuid], return_objects=True,
|
|
||||||
return_alternates=False)
|
|
||||||
# Make sure the request_spec was updated to include the cell
|
|
||||||
# mapping.
|
|
||||||
self.assertIsNotNone(another_spec.requested_destination.cell)
|
|
||||||
check_compat.assert_called_once_with("host1")
|
|
||||||
call_livem_checks.assert_called_once_with("host1")
|
|
||||||
do_test()
|
|
||||||
|
|
||||||
@mock.patch.object(live_migrate.LiveMigrationTask,
|
@mock.patch.object(live_migrate.LiveMigrationTask,
|
||||||
'_call_livem_checks_on_host')
|
'_call_livem_checks_on_host')
|
||||||
@mock.patch.object(live_migrate.LiveMigrationTask,
|
@mock.patch.object(live_migrate.LiveMigrationTask,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user