summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-08-07 14:08:21 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2012-08-09 08:01:07 -0700
commit0bfbce95c8bb867d8e8d27cb7c7429465cc88f15 (patch)
tree7a2884e79c58e1d905baffed7499bfbc47b19fc8 /nova/api
parent2640f81754126c9d3ecd668eb99fb006f68b709b (diff)
downloadnova-0bfbce95c8bb867d8e8d27cb7c7429465cc88f15.tar.gz
nova-0bfbce95c8bb867d8e8d27cb7c7429465cc88f15.tar.xz
nova-0bfbce95c8bb867d8e8d27cb7c7429465cc88f15.zip
Key user_data in create server off of extension
Implements part of blueprint disable-server-extensions Adds a new extension descriptor for user_data and makes sure that user_data is only accepted in the create server request if the extension is enabled. Change-Id: I7aef0ebe569da841adbf380d5695c9029fb3b002
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/user_data.py27
-rw-r--r--nova/api/openstack/compute/servers.py4
2 files changed, 30 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/user_data.py b/nova/api/openstack/compute/contrib/user_data.py
new file mode 100644
index 000000000..debd1176e
--- /dev/null
+++ b/nova/api/openstack/compute/contrib/user_data.py
@@ -0,0 +1,27 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License
+
+from nova.api.openstack import extensions
+
+
+class User_data(extensions.ExtensionDescriptor):
+ """Add user_data to the Create Server v1.1 API"""
+
+ name = "UserData"
+ alias = "os-user-data"
+ namespace = ("http://docs.openstack.org/compute/ext/"
+ "userdata/api/v1.1")
+ updated = "2012-08-07T00:00:00+00:00"
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 6756338d8..b378d4139 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -642,7 +642,9 @@ class Controller(wsgi.Controller):
# optional openstack extensions:
key_name = server_dict.get('key_name')
- user_data = server_dict.get('user_data')
+ user_data = None
+ if self.ext_mgr.is_loaded('os-user-data'):
+ user_data = server_dict.get('user_data')
self._validate_user_data(user_data)
availability_zone = server_dict.get('availability_zone')