diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-04-12 01:07:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-04-12 01:07:08 +0000 |
| commit | b2eb7f41dc7588e90562904d8762d9df2c3bd0ee (patch) | |
| tree | fc8eea8f186a210c3900020b9daabefdb7741355 | |
| parent | fdcc1d20aa5a14272e9966507fa9213c2ed5ae3d (diff) | |
| parent | 5f68160354d240b191bcbaabca7d3c0684758cc6 (diff) | |
| download | nova-b2eb7f41dc7588e90562904d8762d9df2c3bd0ee.tar.gz nova-b2eb7f41dc7588e90562904d8762d9df2c3bd0ee.tar.xz nova-b2eb7f41dc7588e90562904d8762d9df2c3bd0ee.zip | |
Merge "Remove unnecessary db call in scheduler driver live-migration code"
| -rw-r--r-- | nova/scheduler/driver.py | 4 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 18 |
2 files changed, 9 insertions, 13 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 3426c484c..44960a856 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -25,6 +25,7 @@ import sys from oslo.config import cfg +from nova.compute import instance_types from nova.compute import power_state from nova.compute import rpcapi as compute_rpcapi from nova.compute import utils as compute_utils @@ -256,8 +257,7 @@ 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']) + instance_type = instance_types.extract_instance_type(instance_ref) image = self.image_service.show(context, instance_ref['image_ref']) request_spec = {'instance_properties': instance_ref, 'instance_type': instance_type, diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 933b4fc20..f03b79a64 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -778,11 +778,10 @@ class SchedulerTestCase(test.TestCase): # Confirm dest is picked by scheduler if not set. self.mox.StubOutWithMock(self.driver, 'select_hosts') - self.mox.StubOutWithMock(db, 'instance_type_get') + self.mox.StubOutWithMock(instance_types, 'extract_instance_type') - instance_type = instance_types.extract_instance_type(instance) request_spec = {'instance_properties': instance, - 'instance_type': instance_type, + 'instance_type': {}, 'instance_uuids': [instance['uuid']], 'image': self.image_service.show(self.context, instance['image_ref']) @@ -790,8 +789,7 @@ class SchedulerTestCase(test.TestCase): ignore_hosts = [instance['host']] filter_properties = {'ignore_hosts': ignore_hosts} - db.instance_type_get(self.context, instance_type['id']).AndReturn( - instance_type) + instance_types.extract_instance_type(instance).AndReturn({}) self.driver.select_hosts(self.context, request_spec, filter_properties).AndReturn(['fake_host2']) @@ -804,7 +802,7 @@ class SchedulerTestCase(test.TestCase): instance = self._live_migration_instance() # Confirm scheduler picks target host if none given. - self.mox.StubOutWithMock(db, 'instance_type_get') + self.mox.StubOutWithMock(instance_types, 'extract_instance_type') 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') @@ -814,9 +812,8 @@ class SchedulerTestCase(test.TestCase): dest = None block_migration = False disk_over_commit = False - instance_type = instance_types.extract_instance_type(instance) request_spec = {'instance_properties': instance, - 'instance_type': instance_type, + 'instance_type': {}, 'instance_uuids': [instance['uuid']], 'image': self.image_service.show(self.context, instance['image_ref']) @@ -824,9 +821,8 @@ class SchedulerTestCase(test.TestCase): self.driver._live_migration_src_check(self.context, instance) - db.instance_type_get(self.context, - instance_type['id']).MultipleTimes().AndReturn( - instance_type) + instance_types.extract_instance_type( + instance).MultipleTimes().AndReturn({}) # First selected host raises exception.InvalidHypervisorType self.driver.select_hosts(self.context, request_spec, |
