This change adds the quota-delete operation to cinder.
It is adding the api and the tests, using the methods already
implemented in the db to destroy all the quotas for a specific
project.
Implements blueprint quota-delete
DocImpact
Change-Id: Ia040a20abb831c311eb13624ddecbbf0f12fdd9f
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):
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."""
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):
"volume_extension:hosts": [["rule:admin_api"]],
"volume_extension:quotas:show": [],
"volume_extension:quotas:update": [],
+ "volume_extension:quotas:delete": [],
"volume_extension:quota_classes": [],
"limits_extension:used_limits": [],