diff --git a/nova/compute/api.py b/nova/compute/api.py index cdd8bb7934ed..ac0e0ec05496 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -2883,7 +2883,9 @@ class API(base.Base): self._check_auto_disk_config(image=image, **kwargs) flavor = instance.get_flavor() - root_bdm = compute_utils.get_root_bdm(context, instance) + bdms = objects.BlockDeviceMappingList.get_by_instance_uuid( + context, instance.uuid) + root_bdm = compute_utils.get_root_bdm(context, instance, bdms) self._checks_for_create_and_rebuild(context, image_id, image, flavor, metadata, files_to_inject, root_bdm) @@ -2935,9 +2937,6 @@ class API(base.Base): # system metadata... and copy in the properties for the new image. orig_sys_metadata = _reset_image_metadata() - bdms = objects.BlockDeviceMappingList.get_by_instance_uuid( - context, instance.uuid) - self._record_action_start(context, instance, instance_actions.REBUILD) # NOTE(sbauza): The migration script we provided in Newton should make diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index 521e8ce0f7d2..c8bf5847db93 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -3157,6 +3157,8 @@ class _ComputeAPIUnitTestMixIn(object): _checks_for_create_and_rebuild.assert_called_once_with(self.context, None, image, flavor, {}, [], None) self.assertNotEqual(orig_system_metadata, instance.system_metadata) + bdm_get_by_instance_uuid.assert_called_once_with( + self.context, instance.uuid) @mock.patch.object(objects.RequestSpec, 'get_by_instance_uuid') @mock.patch.object(objects.Instance, 'save')