summaryrefslogtreecommitdiff
path: root/nova/api/openstack/wsgi.py
diff options
context:
space:
mode:
authorjichenjc <jichenjc@cn.ibm.com>2016-09-10 18:26:42 +0800
committerjichenjc <jichenjc@cn.ibm.com>2016-09-10 19:40:10 +0800
commite4c8084f91e8aa2a270def2bf7df1f50cd8912ff (patch)
tree5ac65de8381866b4d239b0ea45712edff3fb6bad /nova/api/openstack/wsgi.py
parentf62d143112a8d6f55c64dadec0e51faf5fe27ed9 (diff)
downloadnova-e4c8084f91e8aa2a270def2bf7df1f50cd8912ff.tar.gz
Remove RateLimitFault class
the last usage of this class is RateLimitingMiddleware and that was removed in a31d917af0cc5ecb55424598e7b812e02afbf28c Change-Id: Icefdd7d35b4f6b510d0ead907f486e6ea7abc3ea
Diffstat (limited to 'nova/api/openstack/wsgi.py')
-rw-r--r--nova/api/openstack/wsgi.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 55f5377417..8c476824eb 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -15,8 +15,6 @@
# under the License.
import functools
-import math
-import time
import microversion_parse
from oslo_log import log as logging
@@ -1070,46 +1068,3 @@ class Fault(webob.exc.HTTPException):
def __str__(self):
return self.wrapped_exc.__str__()
-
-
-class RateLimitFault(webob.exc.HTTPException):
- """Rate-limited request response."""
-
- def __init__(self, message, details, retry_time):
- """Initialize new `RateLimitFault` with relevant information."""
- hdrs = RateLimitFault._retry_after(retry_time)
- self.wrapped_exc = webob.exc.HTTPTooManyRequests(headers=hdrs)
- self.content = {
- "overLimit": {
- "code": self.wrapped_exc.status_int,
- "message": message,
- "details": details,
- "retryAfter": hdrs['Retry-After'],
- },
- }
-
- @staticmethod
- def _retry_after(retry_time):
- delay = int(math.ceil(retry_time - time.time()))
- retry_after = delay if delay > 0 else 0
- headers = {'Retry-After': '%d' % retry_after}
- return headers
-
- @webob.dec.wsgify(RequestClass=Request)
- def __call__(self, request):
- """Return the wrapped exception with a serialized body conforming
- to our error format.
- """
- user_locale = request.best_match_language()
-
- self.content['overLimit']['message'] = \
- i18n.translate(self.content['overLimit']['message'], user_locale)
- self.content['overLimit']['details'] = \
- i18n.translate(self.content['overLimit']['details'], user_locale)
-
- content = JSONDictSerializer().serialize(self.content)
- self.wrapped_exc.charset = 'UTF-8'
- self.wrapped_exc.content_type = "application/json"
- self.wrapped_exc.text = content
-
- return self.wrapped_exc