From: Seif Lotfy Date: Thu, 26 Sep 2013 21:21:14 +0000 (+0000) Subject: Add support for querying the quotas usage X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=775ca024659f8733bf498d0e6a5cf725321bdd29;p=openstack-build%2Fcinder-build.git Add support for querying the quotas usage QuotaSetsController's _get_quotas already supports querying for the usage. This patch allows sending a parameter "usage" to the REST API when asking for quotas Change-Id: I2103f41ae7aac1ed9f071949db4fb205552694f5 --- diff --git a/cinder/api/contrib/quotas.py b/cinder/api/contrib/quotas.py index 954f5fb48..c66f899bd 100644 --- a/cinder/api/contrib/quotas.py +++ b/cinder/api/contrib/quotas.py @@ -23,6 +23,7 @@ from cinder.api import xmlutil from cinder import db from cinder.db.sqlalchemy import api as sqlalchemy_api from cinder import exception +from cinder.openstack.common import strutils from cinder import quota @@ -76,12 +77,19 @@ class QuotaSetsController(object): def show(self, req, id): context = req.environ['cinder.context'] authorize_show(context) + + params = req.params + if not hasattr(params, '__call__') and 'usage' in params: + usage = strutils.bool_from_string(params['usage']) + else: + usage = False + try: sqlalchemy_api.authorize_project_context(context, id) except exception.NotAuthorized: raise webob.exc.HTTPForbidden() - return self._format_quota_set(id, self._get_quotas(context, id)) + return self._format_quota_set(id, self._get_quotas(context, id, usage)) @wsgi.serializers(xml=QuotaTemplate) def update(self, req, id, body):