From 07a8213437e41311335fe59c433c690475a34e6b Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Wed, 8 May 2013 21:06:41 +0100 Subject: Pass None to image if booted from volume in live migration The destination check in live migration will fetch the image information from glance and it will throw ImageNotFound if the instance is booted from volume since there is no image id on the instance Fix bug 1170596 Change-Id: Ie683a3ca5d6430c52ead77b41f98fbcb4114ea1e --- nova/tests/scheduler/test_scheduler.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 60d45fed4..f4f607647 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -808,6 +808,31 @@ class SchedulerTestCase(test.TestCase): None, ignore_hosts) self.assertEqual('fake_host2', result) + def test_live_migration_dest_check_no_image(self): + instance = self._live_migration_instance() + instance['image_ref'] = '' + + # Confirm dest is picked by scheduler if not set. + self.mox.StubOutWithMock(self.driver, 'select_hosts') + self.mox.StubOutWithMock(flavors, 'extract_instance_type') + + request_spec = {'instance_properties': instance, + 'instance_type': {}, + 'instance_uuids': [instance['uuid']], + 'image': None + } + ignore_hosts = [instance['host']] + filter_properties = {'ignore_hosts': ignore_hosts} + + flavors.extract_instance_type(instance).AndReturn({}) + self.driver.select_hosts(self.context, request_spec, + filter_properties).AndReturn(['fake_host2']) + + self.mox.ReplayAll() + result = self.driver._live_migration_dest_check(self.context, instance, + None, ignore_hosts) + self.assertEqual('fake_host2', result) + def test_live_migration_auto_set_dest(self): instance = self._live_migration_instance() -- cgit