diff options
| author | Dongdong Zhou <dzhou121@gmail.com> | 2013-05-08 21:06:41 +0100 |
|---|---|---|
| committer | Dongdong Zhou <dzhou121@gmail.com> | 2013-05-08 21:06:41 +0100 |
| commit | 07a8213437e41311335fe59c433c690475a34e6b (patch) | |
| tree | 95f0541f96d0e316e05c705d80a7116358e09642 | |
| parent | 4e61f415c4cbddcffefc05008acce1f96b51a6b1 (diff) | |
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
| -rw-r--r-- | nova/scheduler/driver.py | 6 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 25 |
2 files changed, 30 insertions, 1 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 506c77cff..4ad6b8513 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -258,7 +258,11 @@ class Scheduler(object): # If dest is not specified, have scheduler pick one. if dest is None: instance_type = flavors.extract_instance_type(instance_ref) - image = self.image_service.show(context, instance_ref['image_ref']) + if not instance_ref['image_ref']: + image = None + else: + image = self.image_service.show(context, + instance_ref['image_ref']) request_spec = {'instance_properties': instance_ref, 'instance_type': instance_type, 'instance_uuids': [instance_ref['uuid']], 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() |
