From dc7d2582db84190da0431fb7171a028b6abe2ea0 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Mon, 4 Dec 2017 00:05:43 +0900 Subject: [PATCH] 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 --- openstack_dashboard/api/neutron.py | 7 +++++++ openstack_dashboard/usage/quotas.py | 6 ++---- .../notes/neutron-default-quotas-ddd237af2935fde3.yaml | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/neutron-default-quotas-ddd237af2935fde3.yaml diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index 7a19605345..ba007996bd 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -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) diff --git a/openstack_dashboard/usage/quotas.py b/openstack_dashboard/usage/quotas.py index b560385772..fc38e99e9b 100644 --- a/openstack_dashboard/usage/quotas.py +++ b/openstack_dashboard/usage/quotas.py @@ -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.') diff --git a/releasenotes/notes/neutron-default-quotas-ddd237af2935fde3.yaml b/releasenotes/notes/neutron-default-quotas-ddd237af2935fde3.yaml new file mode 100644 index 0000000000..1f0eb44bc6 --- /dev/null +++ b/releasenotes/notes/neutron-default-quotas-ddd237af2935fde3.yaml @@ -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.