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
This commit is contained in:
parent
4e61f415c4
commit
07a8213437
|
@ -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']],
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue