Merge "Move live_migration.pre.start to the start of the method"
This commit is contained in:
commit
3688eae4fe
|
@ -6133,6 +6133,15 @@ class ComputeManager(manager.Manager):
|
|||
migrate_data.old_vol_attachment_ids = {}
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, "live_migration.pre.start",
|
||||
network_info=network_info)
|
||||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.LIVE_MIGRATION_PRE,
|
||||
phase=fields.NotificationPhase.START, bdms=bdms)
|
||||
|
||||
try:
|
||||
connector = self.driver.get_volume_connector(instance)
|
||||
for bdm in bdms:
|
||||
|
@ -6177,15 +6186,6 @@ class ComputeManager(manager.Manager):
|
|||
context, instance, refresh_conn_info=True,
|
||||
bdms=bdms)
|
||||
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, "live_migration.pre.start",
|
||||
network_info=network_info)
|
||||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.LIVE_MIGRATION_PRE,
|
||||
phase=fields.NotificationPhase.START)
|
||||
|
||||
# The driver pre_live_migration will plug vifs on the host.
|
||||
# We call plug_vifs before calling ensure_filtering_rules_for_instance,
|
||||
# to ensure bridge is set up.
|
||||
|
@ -6230,7 +6230,7 @@ class ComputeManager(manager.Manager):
|
|||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.LIVE_MIGRATION_PRE,
|
||||
phase=fields.NotificationPhase.END)
|
||||
phase=fields.NotificationPhase.END, bdms=bdms)
|
||||
|
||||
LOG.debug('pre_live_migration result data is %s', migrate_data)
|
||||
return migrate_data
|
||||
|
|
|
@ -6101,7 +6101,10 @@ class ComputeTestCase(BaseTestCase,
|
|||
@mock.patch.object(fake.FakeDriver, 'ensure_filtering_rules_for_instance')
|
||||
@mock.patch.object(fake.FakeDriver, 'pre_live_migration')
|
||||
@mock.patch('nova.compute.utils.notify_about_instance_action')
|
||||
def test_pre_live_migration_works_correctly(self, mock_notify,
|
||||
@mock.patch('nova.objects.BlockDeviceMappingList.get_by_instance_uuid',
|
||||
return_value=objects.BlockDeviceMappingList())
|
||||
def test_pre_live_migration_works_correctly(self, mock_get_bdms,
|
||||
mock_notify,
|
||||
mock_pre, mock_ensure):
|
||||
# Confirm setup_compute_volume is called when volume is mounted.
|
||||
def stupid(*args, **kwargs):
|
||||
|
@ -6140,9 +6143,11 @@ class ComputeTestCase(BaseTestCase,
|
|||
|
||||
mock_notify.assert_has_calls([
|
||||
mock.call(c, instance, 'fake-mini',
|
||||
action='live_migration_pre', phase='start'),
|
||||
action='live_migration_pre', phase='start',
|
||||
bdms=mock_get_bdms.return_value),
|
||||
mock.call(c, instance, 'fake-mini',
|
||||
action='live_migration_pre', phase='end')])
|
||||
action='live_migration_pre', phase='end',
|
||||
bdms=mock_get_bdms.return_value)])
|
||||
|
||||
mock_pre.assert_called_once_with(
|
||||
test.MatchType(nova.context.RequestContext),
|
||||
|
|
|
@ -7392,9 +7392,11 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
|
||||
mock_notify_about_inst.assert_has_calls([
|
||||
mock.call(self.context, instance, 'fake-mini',
|
||||
action='live_migration_pre', phase='start'),
|
||||
action='live_migration_pre', phase='start',
|
||||
bdms=mock_get_bdms.return_value),
|
||||
mock.call(self.context, instance, 'fake-mini',
|
||||
action='live_migration_pre', phase='end')])
|
||||
action='live_migration_pre', phase='end',
|
||||
bdms=mock_get_bdms.return_value)])
|
||||
self.assertIsInstance(r, migrate_data_obj.LiveMigrateData)
|
||||
self.assertIsInstance(mock_plm.call_args_list[0][0][5],
|
||||
migrate_data_obj.LiveMigrateData)
|
||||
|
@ -7444,6 +7446,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(compute_utils, 'add_instance_fault_from_exc')
|
||||
@mock.patch.object(vol1_bdm, 'save')
|
||||
@mock.patch.object(compute, '_notify_about_instance_usage')
|
||||
@mock.patch('nova.compute.utils.notify_about_instance_action')
|
||||
@mock.patch.object(compute, 'network_api')
|
||||
@mock.patch.object(compute.driver, 'pre_live_migration')
|
||||
@mock.patch.object(compute, '_get_instance_block_device_info')
|
||||
|
@ -7453,8 +7456,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(compute.volume_api, 'attachment_delete')
|
||||
@mock.patch.object(compute.volume_api, 'attachment_create')
|
||||
def _test(mock_attach_create, mock_attach_delete, mock_get_bdms,
|
||||
mock_ivbi, mock_gibdi, mock_plm, mock_nwapi, mock_notify,
|
||||
mock_bdm_save, mock_exception):
|
||||
mock_ivbi, mock_gibdi, mock_plm, mock_nwapi, mock_ver_notify,
|
||||
mock_notify, mock_bdm_save, mock_exception):
|
||||
new_attachment_id = uuids.attachment3
|
||||
mock_attach_create.side_effect = [{'id': new_attachment_id},
|
||||
test.TestingException]
|
||||
|
|
Loading…
Reference in New Issue