Merge "Pass bdms to versioned notifications during finish_revert_resize"

This commit is contained in:
Zuul 2017-12-21 13:05:54 +00:00 committed by Gerrit Code Review
commit 3563d00530
3 changed files with 10 additions and 6 deletions

View File

@ -3862,11 +3862,13 @@ class ComputeManager(manager.Manager):
"""
with self._error_out_instance_on_exception(context, instance):
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
self._notify_about_instance_usage(
context, instance, "resize.revert.start")
compute_utils.notify_about_instance_action(context, instance,
self.host, action=fields.NotificationAction.RESIZE_REVERT,
phase=fields.NotificationPhase.START)
phase=fields.NotificationPhase.START, bdms=bdms)
# NOTE(mriedem): delete stashed old_vm_state information; we
# default to ACTIVE for backwards compatibility if old_vm_state
@ -3906,8 +3908,6 @@ class ComputeManager(manager.Manager):
# _get_instance_block_device_info below with refresh_conn_info=True
# and then the volumes can be re-connected via the driver on this
# host.
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
self._update_volume_attachments(context, instance, bdms)
block_device_info = self._get_instance_block_device_info(
@ -3942,7 +3942,7 @@ class ComputeManager(manager.Manager):
context, instance, "resize.revert.end")
compute_utils.notify_about_instance_action(context, instance,
self.host, action=fields.NotificationAction.RESIZE_REVERT,
phase=fields.NotificationPhase.END)
phase=fields.NotificationPhase.END, bdms=bdms)
def _revert_allocation(self, context, instance, migration):
"""Revert an allocation that is held by migration to our instance."""

View File

@ -5778,9 +5778,11 @@ class ComputeTestCase(BaseTestCase,
instance=instance, reservations=[])
mock_notify.assert_has_calls([
mock.call(self.context, instance, 'fake-mini',
action='resize_revert', phase='start'),
action='resize_revert', phase='start',
bdms=test.MatchType(objects.BlockDeviceMappingList)),
mock.call(self.context, instance, 'fake-mini',
action='resize_revert', phase='end')])
action='resize_revert', phase='end',
bdms=test.MatchType(objects.BlockDeviceMappingList))])
self.assertIsNone(instance.task_state)

View File

@ -6056,6 +6056,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
return_value=22)
@mock.patch('nova.objects.ComputeNode.get_by_host_and_nodename')
@mock.patch.object(self.compute, "_notify_about_instance_usage")
@mock.patch.object(compute_utils, 'notify_about_instance_action')
@mock.patch.object(self.compute, "_set_instance_info")
@mock.patch.object(self.instance, 'save')
@mock.patch.object(self.migration, 'save')
@ -6085,6 +6086,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
mock_mig_save,
mock_inst_save,
mock_set,
mock_notify_about_instance_action,
mock_notify,
mock_get_cn,
mock_version):