diff options
| author | Eoghan Glynn <eglynn@redhat.com> | 2012-12-10 19:18:50 +0000 |
|---|---|---|
| committer | Eoghan Glynn <eglynn@redhat.com> | 2012-12-10 22:01:52 +0000 |
| commit | 4371509084c97072cc5f2fe16fe01f09b81b1af0 (patch) | |
| tree | 0f26615d5a445ffc70b56fb461f207660c1a59f4 /nova/api | |
| parent | debd702d90b7e39f02b438979365dd09f730f878 (diff) | |
Consider reserved count in os-user-limits extension
Fixes bug 1088606
Previously, the reserved count was not considered in the
total<Resource>Used 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
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/used_limits.py | 11 |
1 files changed, 10 insertions, 1 deletions
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) |
