Skip to content

Instantly share code, notes, and snippets.

@kahou82
Created November 19, 2014 22:22
Show Gist options
  • Save kahou82/ff664724542feb2b160f to your computer and use it in GitHub Desktop.
Save kahou82/ff664724542feb2b160f to your computer and use it in GitHub Desktop.
diff --git a/nova/api/openstack/compute/limits.py b/nova/api/openstack/compute/limits.py
index 07e7913..481cf14 100644
--- a/nova/api/openstack/compute/limits.py
+++ b/nova/api/openstack/compute/limits.py
@@ -79,14 +79,38 @@ class LimitsController(object):
@wsgi.serializers(xml=LimitsTemplate)
def index(self, req):
+ from nova.openstack.common import log as logging
+ LOG = logging.getLogger(__name__)
"""Return all global and rate limit information."""
context = req.environ['nova.context']
- quotas = QUOTAS.get_project_quotas(context, context.project_id,
+
+ if 'QUERY_STRING' in req.environ:
+ qry = req.environ['QUERY_STRING']
+ qry = qry.split("=")
+ tenant_id = qry[1]
+ LOG.error(qry)
+ else:
+ tenant_id = context.project_id
+
+
+ #LOG.error(type(req))
+ #LOG.error(req.environ)
+ #LOG.error("get Project quotas")
+ #LOG.error(type(QUOTAS))
+ #LOG.error(tenant_id)
+ quotas = QUOTAS.get_project_quotas(context, tenant_id,
usages=False)
+
+ #LOG.error("Hi I am here----------------------------------")
+ #LOG.error(quotas)
+ #LOG.error(context.project_id)
+ #print "Hi I am here"
+
abs_limits = dict((k, v['limit']) for k, v in quotas.items())
rate_limits = req.environ.get("nova.limits", [])
builder = self._get_view_builder(req)
+ LOG.error("done!")
return builder.build(rate_limits, abs_limits)
def create(self, req, body):
diff --git a/nova/api/openstack/compute/contrib/used_limits.py b/nova/api/openstack/compute/contrib/used_limits.py
index df40fe9..94f3932 100644
--- a/nova/api/openstack/compute/contrib/used_limits.py
+++ b/nova/api/openstack/compute/contrib/used_limits.py
@@ -50,7 +50,17 @@ class UsedLimitsController(wsgi.Controller):
def index(self, req, resp_obj):
resp_obj.attach(xml=UsedLimitsTemplate())
context = req.environ['nova.context']
- quotas = QUOTAS.get_project_quotas(context, context.project_id,
+
+ LOG.error("here")
+ if 'QUERY_STRING' in req.environ:
+ qry = req.environ['QUERY_STRING']
+ qry = qry.split("=")
+ tenant_id = qry[1]
+ LOG.error(qry)
+ else:
+ tenant_id = context.project_id
+
+ quotas = QUOTAS.get_project_quotas(context, tenant_id,
usages=True)
quota_map = {
'totalRAMUsed': 'ram',
@@ -67,6 +77,9 @@ class UsedLimitsController(wsgi.Controller):
used_limits[display_name] = quotas[quota]['in_use'] + reserved
resp_obj.obj['limits']['absolute'].update(used_limits)
+ f = open("/vagrant/abc.txt", "w")
+ f.write(str(req.environ))
+ f.close()
class Used_limits(extensions.ExtensionDescriptor):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment