summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-05-12 19:07:05 +0000
committerGerrit Code Review <review@openstack.org>2016-05-12 19:07:07 +0000
commitcb5e5714bb32abfd78d66dc3f9ab9204ee077390 (patch)
tree11f864e9af8cde007046a638889f3a70d9395305
parent61896dbf7f697cde319372254fe57ba39fc3c02e (diff)
parent45fad7807f9b66fd0e29acfc95145902b6454326 (diff)
downloadnova-cb5e5714bb32abfd78d66dc3f9ab9204ee077390.tar.gz
Merge "compute: Retain instance metadata for 'evacuate' on shared storage" into stable/liberty
-rw-r--r--nova/compute/manager.py3
-rw-r--r--nova/tests/unit/compute/test_compute.py17
2 files changed, 13 insertions, 7 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 69841d2431..faa6602db1 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -2784,7 +2784,8 @@ class ComputeManager(manager.Manager):
if image_ref:
image_meta = self.image_api.get(context, image_ref)
else:
- image_meta = {}
+ image_meta = utils.get_image_from_system_metadata(
+ instance.system_metadata)
# 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 4b86b8de63..bf08f1b33b 100644
--- a/nova/tests/unit/compute/test_compute.py
+++ b/nova/tests/unit/compute/test_compute.py
@@ -11387,12 +11387,14 @@ class EvacuateHostTestCase(BaseTestCase):
for bdm in bdms:
db.block_device_mapping_destroy(self.context, bdm['id'])
- def test_rebuild_on_host_with_shared_storage(self):
+ @mock.patch('nova.utils.get_image_from_system_metadata')
+ def test_rebuild_on_host_with_shared_storage(self, mock_image_meta):
"""Confirm evacuate scenario on shared storage."""
self.mox.StubOutWithMock(self.compute.driver, 'spawn')
+ mock_image_meta.return_value = {'disk_format': 'qcow2'}
self.compute.driver.spawn(mox.IsA(self.context),
- mox.IsA(objects.Instance), {}, mox.IgnoreArg(), 'newpass',
- network_info=mox.IgnoreArg(),
+ mox.IsA(objects.Instance), mock_image_meta.return_value,
+ mox.IgnoreArg(), 'newpass', network_info=mox.IgnoreArg(),
block_device_info=mox.IgnoreArg())
self.stubs.Set(self.compute.driver, 'instance_on_disk', lambda x: True)
@@ -11460,11 +11462,14 @@ class EvacuateHostTestCase(BaseTestCase):
self._rebuild(on_shared_storage=None)
- def test_on_shared_storage_not_provided_host_with_shared_storage(self):
+ @mock.patch('nova.utils.get_image_from_system_metadata')
+ def test_on_shared_storage_not_provided_host_with_shared_storage(self,
+ mock_image_meta):
self.mox.StubOutWithMock(self.compute.driver, 'spawn')
+ mock_image_meta.return_value = {'disk_format': 'qcow2'}
self.compute.driver.spawn(mox.IsA(self.context),
- mox.IsA(objects.Instance), {}, mox.IgnoreArg(), 'newpass',
- network_info=mox.IgnoreArg(),
+ mox.IsA(objects.Instance), mock_image_meta.return_value,
+ mox.IgnoreArg(), 'newpass', network_info=mox.IgnoreArg(),
block_device_info=mox.IgnoreArg())
self.stubs.Set(self.compute.driver, 'instance_on_disk', lambda x: True)