Merge "Quota delete operation in cinder"

This commit is contained in:
Jenkins 2014-03-05 14:47:52 +00:00 committed by Gerrit Code Review
commit 800ead31a9
3 changed files with 32 additions and 0 deletions

View File

@ -32,6 +32,7 @@ NON_QUOTA_KEYS = ['tenant_id', 'id']
authorize_update = extensions.extension_authorizer('volume', 'quotas:update')
authorize_show = extensions.extension_authorizer('volume', 'quotas:show')
authorize_delete = extensions.extension_authorizer('volume', 'quotas:delete')
class QuotaTemplate(xmlutil.TemplateBuilder):
@ -134,6 +135,17 @@ class QuotaSetsController(wsgi.Controller):
authorize_show(context)
return self._format_quota_set(id, QUOTAS.get_defaults(context))
@wsgi.serializers(xml=QuotaTemplate)
def delete(self, req, id):
context = req.environ['cinder.context']
authorize_delete(context)
try:
db.quota_destroy_all_by_project(context, id)
except exception.AdminRequired:
raise webob.exc.HTTPForbidden()
class Quotas(extensions.ExtensionDescriptor):
"""Quota management support."""

View File

@ -110,6 +110,25 @@ class QuotaSetsControllerTest(test.TestCase):
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
self.req, 'foo', body)
def test_delete(self):
result_show = self.controller.show(self.req, 'foo')
self.assertDictMatch(result_show, make_body())
body = make_body(gigabytes=2000, snapshots=15,
volumes=5, tenant_id=None)
result_update = self.controller.update(self.req, 'foo', body)
self.assertDictMatch(result_update, body)
self.controller.delete(self.req, 'foo')
result_show_after = self.controller.show(self.req, 'foo')
self.assertDictMatch(result_show, result_show_after)
def test_delete_no_admin(self):
self.req.environ['cinder.context'].is_admin = False
self.assertRaises(webob.exc.HTTPForbidden, self.controller.delete,
self.req, 'test')
class QuotaSerializerTest(test.TestCase):

View File

@ -56,6 +56,7 @@
"volume_extension:hosts": [["rule:admin_api"]],
"volume_extension:quotas:show": [],
"volume_extension:quotas:update": [],
"volume_extension:quotas:delete": [],
"volume_extension:quota_classes": [],
"volume_extension:volume_manage": [["rule:admin_api"]],
"volume_extension:volume_unmanage": [["rule:admin_api"]],