From c494c7de697403b112857313c023bd9e83f5322e Mon Sep 17 00:00:00 2001 From: Seif Lotfy Date: Tue, 3 Sep 2013 14:46:34 +0000 Subject: [PATCH] extract 'limits.' to constant for ratelimiting logic based on the equal nova code at https://review.openstack.org/#/c/41267/ the ratelimiting logic uses a constant to parse the limits. Change-Id: I8ffb4267834c79d056716a2c412ecb2c97217635 --- cinder/api/v1/limits.py | 5 +++-- cinder/api/v2/limits.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cinder/api/v1/limits.py b/cinder/api/v1/limits.py index f108b1b15..8f11988b6 100644 --- a/cinder/api/v1/limits.py +++ b/cinder/api/v1/limits.py @@ -36,6 +36,7 @@ from cinder import quota from cinder import wsgi as base_wsgi QUOTAS = quota.QUOTAS +LIMITS_PREFIX = "limits." # Convenience constants for the limits dictionary passed to Limiter(). @@ -292,8 +293,8 @@ class Limiter(object): # Pick up any per-user limit information for key, value in kwargs.items(): - if key.startswith('limits.'): - username = key[7:] + if key.startswith(LIMITS_PREFIX): + username = key[len(LIMITS_PREFIX):] self.levels[username] = self.parse_limits(value) def get_limits(self, username=None): diff --git a/cinder/api/v2/limits.py b/cinder/api/v2/limits.py index f108b1b15..8f11988b6 100644 --- a/cinder/api/v2/limits.py +++ b/cinder/api/v2/limits.py @@ -36,6 +36,7 @@ from cinder import quota from cinder import wsgi as base_wsgi QUOTAS = quota.QUOTAS +LIMITS_PREFIX = "limits." # Convenience constants for the limits dictionary passed to Limiter(). @@ -292,8 +293,8 @@ class Limiter(object): # Pick up any per-user limit information for key, value in kwargs.items(): - if key.startswith('limits.'): - username = key[7:] + if key.startswith(LIMITS_PREFIX): + username = key[len(LIMITS_PREFIX):] self.levels[username] = self.parse_limits(value) def get_limits(self, username=None): -- 2.45.2