quota: Use neutron default quota (read-only) API

Neutron provides an API to retrieve default quotas since newton.
Unfortunately there is no corresponding neutron API extension
is not defined, so there is no way to detect it via API.
The API exists since newton, so this commit just switches to
the default quota API.

Closes-Bug: #1337473
blueprint make-quotas-great-again
Change-Id: Ia826b67f4cec7d95335c62ef98c3040feaa06117
This commit is contained in:
Akihiro Motoki 2017-12-04 00:05:43 +09:00
parent 794fec40f9
commit dc7d2582db
3 changed files with 18 additions and 4 deletions

View File

@ -1454,6 +1454,13 @@ def tenant_quota_detail_get(request, tenant_id=None):
return response['quota']
@profiler.trace
def default_quota_get(request, tenant_id=None):
tenant_id = tenant_id or request.user.tenant_id
response = neutronclient(request).show_quota_default(tenant_id)
return base.QuotaSet(response['quota'])
@profiler.trace
def agent_list(request, **params):
agents = neutronclient(request).list_agents(**params)

View File

@ -183,11 +183,9 @@ def get_default_quota_data(request, disabled_quotas=None, tenant_id=None):
exceptions.handle(request, msg)
if NEUTRON_QUOTA_FIELDS - disabled_quotas:
# TODO(jpichon): There is no API to access the Neutron default quotas
# (LP#1204956). For now, use the values from the current project.
try:
quotasets.append(neutron.tenant_quota_get(request,
tenant_id=tenant_id))
quotasets.append(neutron.default_quota_get(request,
tenant_id=tenant_id))
except Exception:
disabled_quotas.update(NEUTRON_QUOTA_FIELDS)
msg = _('Unable to retrieve Neutron quota information.')

View File

@ -0,0 +1,9 @@
---
fixes:
- |
[:bug:`1337473`] The default quotas of neutron resource for a new project
are no longer got from the quotas of the current project.
Neutron did not provide a way to retrieve the default quotas and horizon
used the quotas of the current project as the default quotas for a new
project as a workaround. Neutron implemented an API to retrieve default
quotas since newton and horizon now consumes it.