summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2011-12-22 18:53:59 +0000
committerGerrit Code Review <review@openstack.org>2011-12-22 18:53:59 +0000
commit460dee919eb1be42de147e9cd8279d7fa61394ba (patch)
tree33f2ac72542922a5ab0e92f6cb14c79fa1baedde /nova/api
parentc83a672d691ec72b3ce832d57e37864f86d0e627 (diff)
parent74390d4920e692e7c85462232a6256774c6eabae (diff)
downloadnova-460dee919eb1be42de147e9cd8279d7fa61394ba.tar.gz
nova-460dee919eb1be42de147e9cd8279d7fa61394ba.tar.xz
nova-460dee919eb1be42de147e9cd8279d7fa61394ba.zip
Merge "Move 'actions' subresource into extension"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/v2/__init__.py7
-rw-r--r--nova/api/openstack/v2/contrib/server_action_list.py61
-rw-r--r--nova/api/openstack/v2/servers.py15
3 files changed, 62 insertions, 21 deletions
diff --git a/nova/api/openstack/v2/__init__.py b/nova/api/openstack/v2/__init__.py
index 8a574ffa5..82a8764a0 100644
--- a/nova/api/openstack/v2/__init__.py
+++ b/nova/api/openstack/v2/__init__.py
@@ -105,7 +105,6 @@ class APIRouter(base_wsgi.Router):
if ext_mgr is None:
ext_mgr = extensions.ExtensionManager()
- self.server_members = {}
mapper = ProjectMapper()
self._setup_routes(mapper)
self._setup_ext_routes(mapper, ext_mgr)
@@ -133,13 +132,9 @@ class APIRouter(base_wsgi.Router):
mapper.resource(resource.collection, resource.collection, **kargs)
def _setup_routes(self, mapper):
- server_members = self.server_members
- server_members['action'] = 'POST'
if FLAGS.allow_admin_api:
LOG.debug(_("Including admin operations in API."))
- server_members['actions'] = 'GET'
-
mapper.resource("user", "users",
controller=users.create_resource(),
collection={'detail': 'GET'})
@@ -168,7 +163,7 @@ class APIRouter(base_wsgi.Router):
mapper.resource("server", "servers",
controller=servers.create_resource(),
collection={'detail': 'GET'},
- member=self.server_members)
+ member={'action': 'POST'})
mapper.resource("ip", "ips", controller=ips.create_resource(),
parent_resource=dict(member_name='server',
diff --git a/nova/api/openstack/v2/contrib/server_action_list.py b/nova/api/openstack/v2/contrib/server_action_list.py
new file mode 100644
index 000000000..62f21dbbf
--- /dev/null
+++ b/nova/api/openstack/v2/contrib/server_action_list.py
@@ -0,0 +1,61 @@
+# Copyright 2011 OpenStack LLC.
+# All Rights Reserved.
+#
+# 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.
+
+import webob.exc
+
+from nova.api.openstack.v2 import extensions
+from nova import compute
+from nova import exception
+
+
+class ServerActionListController(object):
+
+ def index(self, req, server_id):
+ context = req.environ["nova.context"]
+ compute_api = compute.API()
+
+ try:
+ instance = compute_api.get(context, server_id)
+ except exception.NotFound:
+ raise webob.exc.HTTPNotFound(_("Instance not found"))
+
+ items = compute_api.get_actions(context, instance)
+
+ def _format_item(item):
+ return {
+ 'created_at': str(item['created_at']),
+ 'action': item['action'],
+ 'error': item['error'],
+ }
+
+ return {'actions': [_format_item(item) for item in items]}
+
+
+class Server_action_list(extensions.ExtensionDescriptor):
+ """Allow Admins to view pending server actions"""
+
+ name = "ServerActionList"
+ alias = "os-server-action-list"
+ namespace = "http://docs.openstack.org/ext/server-actions-list/api/v1.1"
+ updated = "2011-12-21T00:00:00+00:00"
+ admin_only = True
+
+ def get_resources(self):
+ parent_def = {'member_name': 'server', 'collection_name': 'servers'}
+ #NOTE(bcwaldon): This should be prefixed with 'os-'
+ ext = extensions.ResourceExtension('actions',
+ ServerActionListController(),
+ parent=parent_def)
+ return [ext]
diff --git a/nova/api/openstack/v2/servers.py b/nova/api/openstack/v2/servers.py
index 57ae5306f..5c62a7f82 100644
--- a/nova/api/openstack/v2/servers.py
+++ b/nova/api/openstack/v2/servers.py
@@ -559,21 +559,6 @@ class Controller(wsgi.Controller):
raise exc.HTTPUnprocessableEntity()
return webob.Response(status_int=202)
- def actions(self, req, id):
- """Permit Admins to retrieve server actions."""
- ctxt = req.environ["nova.context"]
- instance = self._get_server(ctxt, id)
- items = self.compute_api.get_actions(ctxt, instance)
- actions = []
- # TODO(jk0): Do not do pre-serialization here once the default
- # serializer is updated
- for item in items:
- actions.append(dict(
- created_at=str(item.created_at),
- action=item.action,
- error=item.error))
- return dict(actions=actions)
-
def _resize(self, req, instance_id, flavor_id):
"""Begin the resize process with given instance/flavor."""
context = req.environ["nova.context"]