]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add support for querying the quotas usage
authorSeif Lotfy <s.lotfy@telekom.de>
Thu, 26 Sep 2013 21:21:14 +0000 (21:21 +0000)
committerSeif Lotfy <s.lotfy@telekom.de>
Sun, 29 Sep 2013 11:06:44 +0000 (11:06 +0000)
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

cinder/api/contrib/quotas.py

index 954f5fb486a67be7ec8aa518c3b860507e8b5746..c66f899bd4048e2331a8313b8af4a621326bbad4 100644 (file)
@@ -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):