summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authormdietz <mdietz@openstack>2010-12-18 00:18:36 +0000
committermdietz <mdietz@openstack>2010-12-18 00:18:36 +0000
commitf3f5b58f395794b3933cc3489ff37ce08002de89 (patch)
tree7726a499904308a2e5e88b5191711d647a57c782 /nova/api
parent5b8362d0f56bdbeba7ee8292222863a501bad6af (diff)
parent800ecbd713c55d7410d6eb860a439cb87468e7ad (diff)
downloadnova-f3f5b58f395794b3933cc3489ff37ce08002de89.tar.gz
nova-f3f5b58f395794b3933cc3489ff37ce08002de89.tar.xz
nova-f3f5b58f395794b3933cc3489ff37ce08002de89.zip
All API tests finally pass
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/__init__.py2
-rw-r--r--nova/api/openstack/ratelimiting/__init__.py17
2 files changed, 10 insertions, 9 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index e78080012..20336d885 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -113,7 +113,7 @@ class RateLimitingMiddleware(wsgi.Middleware):
@webob.dec.wsgify
def __call__(self, req):
- return self._limiting_driver.limited_request(req)
+ return self._limiting_driver.limited_request(req, self.application)
class APIRouter(wsgi.Router):
diff --git a/nova/api/openstack/ratelimiting/__init__.py b/nova/api/openstack/ratelimiting/__init__.py
index 2dc5ec32e..3c1e6e1eb 100644
--- a/nova/api/openstack/ratelimiting/__init__.py
+++ b/nova/api/openstack/ratelimiting/__init__.py
@@ -6,6 +6,7 @@ import urllib
import webob.dec
import webob.exc
+from nova.api.openstack import faults
# Convenience constants for the limits dictionary passed to Limiter().
PER_SECOND = 1
@@ -22,16 +23,16 @@ class BasicRateLimiting(object):
#TODO(gundlach): These limits were based on limitations of Cloud
#Servers. We should revisit them in Nova.
self.limiter = Limiter(limits={
- 'DELETE': (100, ratelimiting.PER_MINUTE),
- 'PUT': (10, ratelimiting.PER_MINUTE),
- 'POST': (10, ratelimiting.PER_MINUTE),
- 'POST servers': (50, ratelimiting.PER_DAY),
- 'GET changes-since': (3, ratelimiting.PER_MINUTE),
+ 'DELETE': (100, PER_MINUTE),
+ 'PUT': (10, PER_MINUTE),
+ 'POST': (10, PER_MINUTE),
+ 'POST servers': (50, PER_DAY),
+ 'GET changes-since': (3, PER_MINUTE),
})
else:
self.limiter = WSGIAppProxy(service_host)
- def limited_request(self, req):
+ def limited_request(self, req, application):
"""Rate limit the request.
If the request should be rate limited, return a 413 status with a
@@ -40,7 +41,7 @@ class BasicRateLimiting(object):
action_name = self.get_action_name(req)
if not action_name:
# Not rate limited
- return self.application
+ return application
delay = self.get_delay(action_name,
req.environ['nova.context'].user_id)
if delay:
@@ -49,7 +50,7 @@ class BasicRateLimiting(object):
explanation='Too many requests.',
headers={'Retry-After': time.time() + delay})
raise faults.Fault(exc)
- return self.application
+ return application
def get_delay(self, action_name, username):
"""Return the delay for the given action and username, or None if