Merge "Fix set-quotas for non-project scoped tokens" into stable/xena

This commit is contained in:
Zuul 2022-05-18 04:31:08 +00:00 committed by Gerrit Code Review
commit b12afbf4e9
2 changed files with 16 additions and 0 deletions

View File

@ -19,6 +19,7 @@ from oslo_log import log as logging
from designate.api.v2.controllers import rest
from designate.common import keystone
from designate import exceptions
from designate.objects.adapters import DesignateAdapter
from designate.objects import QuotaList
@ -63,6 +64,15 @@ class QuotasController(rest.RestController):
quotas = DesignateAdapter.parse('API_v2', body, QuotaList())
# The get_quotas lookup will always return the default quotas
# if the context does not have a project_id (system scoped token) and
# the all_tenants boolean is false. Let's require all_tenants for
# contexts with no project ID.
if context.project_id is None and not context.all_tenants:
raise exceptions.MissingProjectID(
"The all-projects flag must be used when using non-project "
"scoped tokens.")
for quota in quotas:
self.central_api.set_quota(context, tenant_id, quota.resource,
quota.hard_limit)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed an issue where set-quotas will always return the default quotas if
it was called with a non-project scoped token and the all-projects flag
was not set.