diff options
| author | Sean Dague <sdague@linux.vnet.ibm.com> | 2012-08-08 17:27:38 -0400 |
|---|---|---|
| committer | Sean Dague <sdague@linux.vnet.ibm.com> | 2012-08-09 21:56:02 -0400 |
| commit | f54a91603933a9a67ee3ed7bb0010017bcc1193e (patch) | |
| tree | a620b42a11a6a136b29145c44082ed6cff30f828 | |
| parent | 2640f81754126c9d3ecd668eb99fb006f68b709b (diff) | |
| download | nova-f54a91603933a9a67ee3ed7bb0010017bcc1193e.tar.gz nova-f54a91603933a9a67ee3ed7bb0010017bcc1193e.tar.xz nova-f54a91603933a9a67ee3ed7bb0010017bcc1193e.zip | |
Don't accept scheduler_hints if not enabled
partially implements blueprint disable-server-extensions
moves the filling out of the code behind a conditional to
ensure this data is only passed if the extension is actually
enabled
Change-Id: If866eb87c9e6189b6948cb37f0cb8f5e26c8cced
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 5 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/test_servers.py | 25 |
2 files changed, 29 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 6756338d8..1a6881f27 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -664,7 +664,10 @@ class Controller(wsgi.Controller): min_count = max_count auto_disk_config = server_dict.get('auto_disk_config') - scheduler_hints = server_dict.get('scheduler_hints', {}) + + scheduler_hints = {} + if self.ext_mgr.is_loaded('os-scheduler-hints'): + scheduler_hints = server_dict.get('scheduler_hints', {}) try: _get_inst_type = instance_types.get_instance_type_by_flavor_id diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index edd53446a..83443c206 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -1787,6 +1787,31 @@ class ServersControllerCreateTest(test.TestCase): self.stubs.Set(nova.compute.api.API, 'create', create) self._test_create_extra(params) + def test_create_instance_with_scheduler_hints_enabled(self): + self.ext_mgr.extensions = {'os-scheduler-hints': 'fake'} + hints = {'a': 'b'} + params = {'scheduler_hints': hints} + old_create = nova.compute.api.API.create + + def create(*args, **kwargs): + self.assertEqual(kwargs['scheduler_hints'], hints) + return old_create(*args, **kwargs) + + self.stubs.Set(nova.compute.api.API, 'create', create) + self._test_create_extra(params) + + def test_create_instance_with_scheduler_hints_disabled(self): + hints = {'a': 'b'} + params = {'scheduler_hints': hints} + old_create = nova.compute.api.API.create + + def create(*args, **kwargs): + self.assertEqual(kwargs['scheduler_hints'], {}) + return old_create(*args, **kwargs) + + self.stubs.Set(nova.compute.api.API, 'create', create) + self._test_create_extra(params) + def test_create_instance_with_volumes_enabled(self): self.ext_mgr.extensions = {'os-volumes': 'fake'} bdm = [{'device_name': 'foo'}] |
