From 4371509084c97072cc5f2fe16fe01f09b81b1af0 Mon Sep 17 00:00:00 2001 From: Eoghan Glynn Date: Mon, 10 Dec 2012 19:18:50 +0000 Subject: Consider reserved count in os-user-limits extension Fixes bug 1088606 Previously, the reserved count was not considered in the totalUsed values returned, leading to a potentially inaccurate view of the actual headroom available when resource creation was in-flight. Now, the reserved count is optionally included, controlled by a new 'reserved' query parameter. Change-Id: If71ac6f8e428b58b7c80c67ad99124e4233102d1 --- nova/api/openstack/compute/contrib/used_limits.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/used_limits.py b/nova/api/openstack/compute/contrib/used_limits.py index 020f6d8e4..a7ac33ae9 100644 --- a/nova/api/openstack/compute/contrib/used_limits.py +++ b/nova/api/openstack/compute/contrib/used_limits.py @@ -39,6 +39,13 @@ class UsedLimitsTemplate(xmlutil.TemplateBuilder): class UsedLimitsController(wsgi.Controller): + @staticmethod + def _reserved(req): + try: + return int(req.GET['reserved']) + except (ValueError, KeyError): + return False + @wsgi.extends def index(self, req, resp_obj): resp_obj.attach(xml=UsedLimitsTemplate()) @@ -57,7 +64,9 @@ class UsedLimitsController(wsgi.Controller): used_limits = {} for display_name, quota in quota_map.iteritems(): if quota in quotas: - used_limits[display_name] = quotas[quota]['in_use'] + reserved = (quotas[quota]['reserved'] + if self._reserved(req) else 0) + used_limits[display_name] = quotas[quota]['in_use'] + reserved resp_obj.obj['limits']['absolute'].update(used_limits) -- cgit