summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-28 14:11:29 +0000
committerGerrit Code Review <review@openstack.org>2013-05-28 14:11:29 +0000
commitff61b40f66a98327f7370756ad98e3f09ec54088 (patch)
tree601c470b55ac6f360e973ff697b041577207962e /nova/api
parentb0aa0c122c3e439b79bf245df1f85f913d9c7f47 (diff)
parentcdd998c418edc42a6a828ddef144e8408c206b7c (diff)
downloadnova-ff61b40f66a98327f7370756ad98e3f09ec54088.tar.gz
nova-ff61b40f66a98327f7370756ad98e3f09ec54088.tar.xz
nova-ff61b40f66a98327f7370756ad98e3f09ec54088.zip
Merge "Delete a quota through admin api."
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/extended_quotas.py25
-rw-r--r--nova/api/openstack/compute/contrib/quotas.py18
2 files changed, 42 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/extended_quotas.py b/nova/api/openstack/compute/contrib/extended_quotas.py
new file mode 100644
index 000000000..431b95e9b
--- /dev/null
+++ b/nova/api/openstack/compute/contrib/extended_quotas.py
@@ -0,0 +1,25 @@
+# Copyright 2013 Rackspace Hosting
+# 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.
+
+from nova.api.openstack import extensions
+
+
+class Extended_quotas(extensions.ExtensionDescriptor):
+ """Adds ability for admins to delete quota."""
+
+ name = "ExtendedQuotas"
+ alias = "os-extended-quotas"
+ namespace = "http://docs.openstack.org/compute/ext/quota-delete/api/v1.1"
+ updated = "2013-05-23T00:00:00+00:00"
diff --git a/nova/api/openstack/compute/contrib/quotas.py b/nova/api/openstack/compute/contrib/quotas.py
index c7fe87a1f..0a2453038 100644
--- a/nova/api/openstack/compute/contrib/quotas.py
+++ b/nova/api/openstack/compute/contrib/quotas.py
@@ -33,6 +33,7 @@ LOG = logging.getLogger(__name__)
authorize_update = extensions.extension_authorizer('compute', 'quotas:update')
authorize_show = extensions.extension_authorizer('compute', 'quotas:show')
+authorize_delete = extensions.extension_authorizer('compute', 'quotas:delete')
class QuotaTemplate(xmlutil.TemplateBuilder):
@@ -49,6 +50,9 @@ class QuotaTemplate(xmlutil.TemplateBuilder):
class QuotaSetsController(object):
+ def __init__(self, ext_mgr):
+ self.ext_mgr = ext_mgr
+
def _format_quota_set(self, project_id, quota_set):
"""Convert the quota object to a result dict."""
@@ -124,6 +128,18 @@ class QuotaSetsController(object):
authorize_show(context)
return self._format_quota_set(id, QUOTAS.get_defaults(context))
+ def delete(self, req, id):
+ if self.ext_mgr.is_loaded('os-extended-quotas'):
+ context = req.environ['nova.context']
+ authorize_delete(context)
+ try:
+ nova.context.authorize_project_context(context, id)
+ QUOTAS.destroy_all_by_project(context, id)
+ return webob.Response(status_int=202)
+ except exception.NotAuthorized:
+ raise webob.exc.HTTPForbidden()
+ raise webob.exc.HTTPNotFound()
+
class Quotas(extensions.ExtensionDescriptor):
"""Quotas management support."""
@@ -137,7 +153,7 @@ class Quotas(extensions.ExtensionDescriptor):
resources = []
res = extensions.ResourceExtension('os-quota-sets',
- QuotaSetsController(),
+ QuotaSetsController(self.ext_mgr),
member_actions={'defaults': 'GET'})
resources.append(res)