]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
extract 'limits.' to constant for ratelimiting logic
authorSeif Lotfy <s.lotfy@telekom.de>
Tue, 3 Sep 2013 14:46:34 +0000 (14:46 +0000)
committerSeif Lotfy <s.lotfy@telekom.de>
Tue, 3 Sep 2013 14:46:34 +0000 (14:46 +0000)
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
cinder/api/v2/limits.py

index f108b1b1599166be3a374d091537cabf014697bf..8f11988b6dcbac5146212e6600d31e746d6a52c5 100644 (file)
@@ -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):
index f108b1b1599166be3a374d091537cabf014697bf..8f11988b6dcbac5146212e6600d31e746d6a52c5 100644 (file)
@@ -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):