diff options
-rw-r--r-- | nova/scheduler/driver.py | 4 | ||||
-rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index accdead2d..3426c484c 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -256,9 +256,11 @@ class Scheduler(object): # If dest is not specified, have scheduler pick one. if dest is None: + instance_type = db.instance_type_get( + context, instance_ref['instance_type_id']) image = self.image_service.show(context, instance_ref['image_ref']) request_spec = {'instance_properties': instance_ref, - 'instance_type': instance_ref['instance_type'], + 'instance_type': instance_type, 'instance_uuids': [instance_ref['uuid']], 'image': image} filter_properties = {'ignore_hosts': ignore_hosts} diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 5d0228c62..4e95061a7 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -403,6 +403,7 @@ class SchedulerTestCase(test.TestCase): 'vm_state': '', 'task_state': '', 'instance_type': {'memory_mb': 1024}, + 'instance_type_id': 1, 'image_ref': 'fake-image-ref'} def test_live_migration_basic(self): @@ -736,6 +737,7 @@ class SchedulerTestCase(test.TestCase): def test_live_migration_dest_check_auto_set_host(self): # Confirm dest is picked by scheduler if not set. self.mox.StubOutWithMock(self.driver, 'select_hosts') + self.mox.StubOutWithMock(db, 'instance_type_get') instance = self._live_migration_instance() request_spec = {'instance_properties': instance, @@ -747,6 +749,8 @@ class SchedulerTestCase(test.TestCase): ignore_hosts = [instance['host']] filter_properties = {'ignore_hosts': ignore_hosts} + db.instance_type_get(self.context, 1).AndReturn( + instance['instance_type']) self.driver.select_hosts(self.context, request_spec, filter_properties).AndReturn(['fake_host2']) @@ -757,6 +761,7 @@ class SchedulerTestCase(test.TestCase): def test_live_migration_auto_set_dest(self): # Confirm scheduler picks target host if none given. + self.mox.StubOutWithMock(db, 'instance_type_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, 'select_hosts') self.mox.StubOutWithMock(self.driver, '_live_migration_common_check') @@ -776,6 +781,9 @@ class SchedulerTestCase(test.TestCase): self.driver._live_migration_src_check(self.context, instance) + db.instance_type_get(self.context, 1).MultipleTimes().AndReturn( + instance['instance_type']) + # First selected host raises exception.InvalidHypervisorType self.driver.select_hosts(self.context, request_spec, {'ignore_hosts': [instance['host']]}).AndReturn(['fake_host2']) |