diff options
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/user_data.py | 27 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 11 | ||||
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 15 |
3 files changed, 34 insertions, 19 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/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 8dc16fcdc..e566a95f7 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -19,7 +19,6 @@ import webob from webob import exc from nova.api.openstack import common -from nova.api.openstack.compute import servers from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil @@ -428,13 +427,6 @@ class VolumeAttachmentController(object): return {'volumeAttachments': results} -class BootFromVolumeController(servers.Controller): - """The boot from volume API controller for the OpenStack API.""" - - def _get_block_device_mapping(self, data): - return data.get('block_device_mapping') - - def _translate_snapshot_detail_view(context, vol): """Maps keys for snapshots details view.""" @@ -597,8 +589,7 @@ class Volumes(extensions.ExtensionDescriptor): collection_name='servers')) resources.append(res) - controller = BootFromVolumeController(self.ext_mgr) - res = extensions.ResourceExtension('os-volumes_boot', controller, + res = extensions.ResourceExtension('os-volumes_boot', inherits='servers') resources.append(res) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index d70323cbf..b378d4139 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -375,13 +375,6 @@ class Controller(wsgi.Controller): raise exc.HTTPNotFound() return servers - def _get_block_device_mapping(self, data): - """Get block_device_mapping from 'server' dictionary. - - Overridden by volumes controller. - """ - return None - def _add_instance_faults(self, ctxt, instances): faults = self.compute_api.get_instance_faults(ctxt, instances) if faults is not None: @@ -649,12 +642,16 @@ 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') - block_device_mapping = self._get_block_device_mapping(server_dict) + block_device_mapping = None + if self.ext_mgr.is_loaded('os-volumes'): + block_device_mapping = server_dict.get('block_device_mapping') ret_resv_id = server_dict.get('return_reservation_id', False) |
