diff --git a/nova/compute/manager.py b/nova/compute/manager.py index b369c59d8e70..840c178ed2cf 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2721,7 +2721,7 @@ class ComputeManager(manager.Manager): image_meta = objects.ImageMeta.from_image_ref( context, self.image_api, image_ref) else: - image_meta = objects.ImageMeta.from_dict({}) + image_meta = instance.image_meta # This instance.exists message should contain the original # image_ref, not the new one. Since the DB has been updated diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index cfc5c7c78aa0..10b9342dcd56 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -11682,11 +11682,14 @@ class EvacuateHostTestCase(BaseTestCase): self.assertRaises(exception.InstanceRecreateNotSupported, lambda: self._rebuild(on_shared_storage=True)) - def test_on_shared_storage_not_provided_host_without_shared_storage(self): + @mock.patch('nova.objects.ImageMeta.from_image_ref') + def test_on_shared_storage_not_provided_host_without_shared_storage(self, + mock_image_meta): + # 'spawn' should be called with the image_meta from the image_ref self.mox.StubOutWithMock(self.compute.driver, 'spawn') self.compute.driver.spawn(mox.IsA(self.context), mox.IsA(objects.Instance), - mox.IsA(objects.ImageMeta), + mock_image_meta.return_value, mox.IgnoreArg(), mox.IsA('newpass'), network_info=mox.IgnoreArg(), block_device_info=mox.IgnoreArg()) @@ -11697,11 +11700,15 @@ class EvacuateHostTestCase(BaseTestCase): self._rebuild(on_shared_storage=None) - def test_on_shared_storage_not_provided_host_with_shared_storage(self): + @mock.patch('nova.objects.Instance.image_meta', + new_callable=mock.PropertyMock) + def test_on_shared_storage_not_provided_host_with_shared_storage(self, + mock_image_meta): + # 'spawn' should be called with the image_meta from the instance self.mox.StubOutWithMock(self.compute.driver, 'spawn') self.compute.driver.spawn(mox.IsA(self.context), mox.IsA(objects.Instance), - mox.IsA(objects.ImageMeta), + mock_image_meta.return_value, mox.IgnoreArg(), 'newpass', network_info=mox.IgnoreArg(), block_device_info=mox.IgnoreArg())