diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-08-12 10:01:09 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-08-12 10:08:47 -0700 |
| commit | ed80ed615762e0ff24235b7d57fa8b356c659e11 (patch) | |
| tree | 70183b5340c7f5331c144329dac6ff73ea0116e7 | |
| parent | d036fdbe0f8112e0345e80a08762e3c1bc7885f1 (diff) | |
Key auto_disk_config in create server off of ext.
Implements part of blueprint disable-server-extensions
Makes sure that auto_disk_config is only accepted in the create
server request if the extension is enabled. Note that the extension
alias is OS-DCF because it also adds output to the server
request.
Change-Id: I59fafe769e1e562e6bf9f6db768acc9b0f8d2b93
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 4 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/test_servers.py | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index ca446f24b..797c498b8 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -678,7 +678,9 @@ class Controller(wsgi.Controller): if min_count > max_count: min_count = max_count - auto_disk_config = server_dict.get('auto_disk_config') + auto_disk_config = False + if self.ext_mgr.is_loaded('OS-DCF'): + auto_disk_config = server_dict.get('auto_disk_config') scheduler_hints = {} if self.ext_mgr.is_loaded('os-scheduler-hints'): diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index a1db243da..8d5a36168 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -1790,6 +1790,32 @@ class ServersControllerCreateTest(test.TestCase): self.stubs.Set(nova.compute.api.API, 'create', create) self._test_create_extra(params) + def test_create_instance_with_disk_config_enabled(self): + self.ext_mgr.extensions = {'OS-DCF': 'fake'} + # NOTE(vish): the extension converts OS-DCF:disk_config into + # auto_disk_config, so we are testing with + # the_internal_value + params = {'auto_disk_config': True} + old_create = nova.compute.api.API.create + + def create(*args, **kwargs): + self.assertEqual(kwargs['auto_disk_config'], True) + return old_create(*args, **kwargs) + + self.stubs.Set(nova.compute.api.API, 'create', create) + self._test_create_extra(params) + + def test_create_instance_with_disk_config_disabled(self): + params = {'auto_disk_config': True} + old_create = nova.compute.api.API.create + + def create(*args, **kwargs): + self.assertEqual(kwargs['auto_disk_config'], False) + 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_enabled(self): self.ext_mgr.extensions = {'os-scheduler-hints': 'fake'} hints = {'a': 'b'} |
