Use the provider_api module in limit controller

Last release we spent a bunch of time going through and updating the
code base to use the keystone/common/provider_api.py module. It
looks like the unified limit controller was missed through.

This commit updates the unified limit controller to be consistent
with the rest of the keystone in not using `self` to access other
subsystems in keystone.

Change-Id: I86fa5a6e889d24779b2451b8402d0e7bd92a64ba
This commit is contained in:
Lance Bragstad 2018-04-18 21:25:44 +00:00
parent 03c06a8125
commit 000c071379
1 changed files with 8 additions and 5 deletions

View File

@ -12,11 +12,14 @@
# under the License. # under the License.
from keystone.common import controller from keystone.common import controller
from keystone.common import provider_api
from keystone.common import validation from keystone.common import validation
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _
from keystone.limit import schema from keystone.limit import schema
PROVIDERS = provider_api.ProviderAPIs
class RegisteredLimitV3(controller.V3Controller): class RegisteredLimitV3(controller.V3Controller):
collection_name = 'registered_limits' collection_name = 'registered_limits'
@ -83,7 +86,7 @@ class LimitV3(controller.V3Controller):
validation.lazy_validate(schema.limit_create, limits) validation.lazy_validate(schema.limit_create, limits)
limits = [self._assign_unique_id(self._normalize_dict(limit)) limits = [self._assign_unique_id(self._normalize_dict(limit))
for limit in limits] for limit in limits]
refs = self.unified_limit_api.create_limits(limits) refs = PROVIDERS.unified_limit_api.create_limits(limits)
refs = LimitV3.wrap_collection(request.context_dict, refs) refs = LimitV3.wrap_collection(request.context_dict, refs)
refs.pop("links") refs.pop("links")
return refs return refs
@ -91,7 +94,7 @@ class LimitV3(controller.V3Controller):
@controller.protected() @controller.protected()
def update_limits(self, request, limits): def update_limits(self, request, limits):
validation.lazy_validate(schema.limit_update, limits) validation.lazy_validate(schema.limit_update, limits)
refs = self.unified_limit_api.update_limits( refs = PROVIDERS.unified_limit_api.update_limits(
[self._normalize_dict(limit) for limit in limits]) [self._normalize_dict(limit) for limit in limits])
refs = LimitV3.wrap_collection(request.context_dict, refs) refs = LimitV3.wrap_collection(request.context_dict, refs)
refs.pop("links") refs.pop("links")
@ -107,12 +110,12 @@ class LimitV3(controller.V3Controller):
project_id = context.project_id project_id = context.project_id
if project_id: if project_id:
hints.add_filter('project_id', project_id) hints.add_filter('project_id', project_id)
refs = self.unified_limit_api.list_limits(hints) refs = PROVIDERS.unified_limit_api.list_limits(hints)
return LimitV3.wrap_collection(request.context_dict, refs, hints=hints) return LimitV3.wrap_collection(request.context_dict, refs, hints=hints)
@controller.protected() @controller.protected()
def get_limit(self, request, limit_id): def get_limit(self, request, limit_id):
ref = self.unified_limit_api.get_limit(limit_id) ref = PROVIDERS.unified_limit_api.get_limit(limit_id)
# TODO(wxy): Add system-scope check. If the request is system-scoped, # TODO(wxy): Add system-scope check. If the request is system-scoped,
# it can get any limits. # it can get any limits.
context = request.context context = request.context
@ -127,4 +130,4 @@ class LimitV3(controller.V3Controller):
@controller.protected() @controller.protected()
def delete_limit(self, request, limit_id): def delete_limit(self, request, limit_id):
return self.unified_limit_api.delete_limit(limit_id) return PROVIDERS.unified_limit_api.delete_limit(limit_id)