blob: fba3b0fe0d05b7985b74dfbcf3cac19b0d4205b9 [file] [log] [blame]
Jay Pipes3f981df2012-03-27 18:59:44 -04001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack, LLC
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Attila Fazekas55f6d8c2013-03-10 10:32:54 +010018import collections
Attila Fazekas11d2a772013-01-29 17:46:52 +010019import hashlib
Jay Pipes7f757632011-12-02 15:53:32 -050020import httplib2
Matthew Treinisha83a16e2012-12-07 13:44:02 -050021import json
Daryl Walleck8a707db2012-01-25 00:46:24 -060022import logging
Dan Smithba6cb162012-08-14 07:22:42 -070023from lxml import etree
Attila Fazekas11d2a772013-01-29 17:46:52 +010024import re
Eoghan Glynna5598972012-03-01 09:27:17 -050025import time
Jay Pipes3f981df2012-03-27 18:59:44 -040026
Daryl Wallecked8bef32011-12-05 23:02:08 -060027from tempest import exceptions
dwallecke62b9f02012-10-10 23:34:42 -050028from tempest.services.compute.xml.common import xml_to_json
Daryl Walleck1465d612011-11-02 02:22:15 -050029
Eoghan Glynna5598972012-03-01 09:27:17 -050030# redrive rate limited calls at most twice
31MAX_RECURSION_DEPTH = 2
Attila Fazekas11d2a772013-01-29 17:46:52 +010032TOKEN_CHARS_RE = re.compile('^[-A-Za-z0-9+/=]*$')
Eoghan Glynna5598972012-03-01 09:27:17 -050033
34
Daryl Walleck1465d612011-11-02 02:22:15 -050035class RestClient(object):
Dan Smithba6cb162012-08-14 07:22:42 -070036 TYPE = "json"
Attila Fazekas11d2a772013-01-29 17:46:52 +010037 LOG = logging.getLogger(__name__)
Daryl Walleck1465d612011-11-02 02:22:15 -050038
chris fattarsi5098fa22012-04-17 13:27:00 -070039 def __init__(self, config, user, password, auth_url, tenant_name=None):
Jay Pipes7f757632011-12-02 15:53:32 -050040 self.config = config
chris fattarsi5098fa22012-04-17 13:27:00 -070041 self.user = user
42 self.password = password
43 self.auth_url = auth_url
44 self.tenant_name = tenant_name
45
46 self.service = None
47 self.token = None
48 self.base_url = None
Attila Fazekascadcb1f2013-01-21 23:10:53 +010049 self.region = {'compute': self.config.identity.region}
chris fattarsi5098fa22012-04-17 13:27:00 -070050 self.endpoint_url = 'publicURL'
51 self.strategy = self.config.identity.strategy
Dan Smithba6cb162012-08-14 07:22:42 -070052 self.headers = {'Content-Type': 'application/%s' % self.TYPE,
53 'Accept': 'application/%s' % self.TYPE}
David Kranz6aceb4a2012-06-05 14:05:45 -040054 self.build_interval = config.compute.build_interval
55 self.build_timeout = config.compute.build_timeout
Attila Fazekas72c7a5f2012-12-03 17:17:23 +010056 self.general_header_lc = set(('cache-control', 'connection',
57 'date', 'pragma', 'trailer',
58 'transfer-encoding', 'via',
59 'warning'))
60 self.response_header_lc = set(('accept-ranges', 'age', 'etag',
61 'location', 'proxy-authenticate',
62 'retry-after', 'server',
63 'vary', 'www-authenticate'))
Attila Fazekas55f6d8c2013-03-10 10:32:54 +010064 dscv = self.config.identity.disable_ssl_certificate_validation
65 self.http_obj = httplib2.Http(disable_ssl_certificate_validation=dscv)
chris fattarsi5098fa22012-04-17 13:27:00 -070066
67 def _set_auth(self):
68 """
69 Sets the token and base_url used in requests based on the strategy type
70 """
71
72 if self.strategy == 'keystone':
73 self.token, self.base_url = self.keystone_auth(self.user,
74 self.password,
75 self.auth_url,
76 self.service,
77 self.tenant_name)
Daryl Walleck1465d612011-11-02 02:22:15 -050078 else:
chris fattarsi5098fa22012-04-17 13:27:00 -070079 self.token, self.base_url = self.basic_auth(self.user,
80 self.password,
81 self.auth_url)
82
83 def clear_auth(self):
84 """
85 Can be called to clear the token and base_url so that the next request
Attila Fazekasb2902af2013-02-16 16:22:44 +010086 will fetch a new token and base_url.
chris fattarsi5098fa22012-04-17 13:27:00 -070087 """
88
89 self.token = None
90 self.base_url = None
Daryl Walleck1465d612011-11-02 02:22:15 -050091
Rohit Karajgi6b1e1542012-05-14 05:55:54 -070092 def get_auth(self):
93 """Returns the token of the current request or sets the token if
Attila Fazekasb2902af2013-02-16 16:22:44 +010094 none.
95 """
Rohit Karajgi6b1e1542012-05-14 05:55:54 -070096
97 if not self.token:
98 self._set_auth()
99
100 return self.token
101
Daryl Walleck587385b2012-03-03 13:00:26 -0600102 def basic_auth(self, user, password, auth_url):
Daryl Walleck1465d612011-11-02 02:22:15 -0500103 """
Attila Fazekasb2902af2013-02-16 16:22:44 +0100104 Provides authentication for the target API.
Daryl Walleck1465d612011-11-02 02:22:15 -0500105 """
106
107 params = {}
108 params['headers'] = {'User-Agent': 'Test-Client', 'X-Auth-User': user,
Daryl Walleck587385b2012-03-03 13:00:26 -0600109 'X-Auth-Key': password}
Daryl Walleck1465d612011-11-02 02:22:15 -0500110
Daryl Walleck1465d612011-11-02 02:22:15 -0500111 resp, body = self.http_obj.request(auth_url, 'GET', **params)
112 try:
113 return resp['x-auth-token'], resp['x-server-management-url']
Matthew Treinish05d9fb92012-12-07 16:14:05 -0500114 except Exception:
Daryl Walleck1465d612011-11-02 02:22:15 -0500115 raise
116
Daryl Walleck587385b2012-03-03 13:00:26 -0600117 def keystone_auth(self, user, password, auth_url, service, tenant_name):
Daryl Walleck1465d612011-11-02 02:22:15 -0500118 """
Attila Fazekasb2902af2013-02-16 16:22:44 +0100119 Provides authentication via Keystone.
Daryl Walleck1465d612011-11-02 02:22:15 -0500120 """
121
Jay Pipes7c88eb22013-01-16 21:32:43 -0500122 # Normalize URI to ensure /tokens is in it.
123 if 'tokens' not in auth_url:
124 auth_url = auth_url.rstrip('/') + '/tokens'
125
Zhongyue Luo30a563f2012-09-30 23:43:50 +0900126 creds = {
127 'auth': {
Daryl Walleck1465d612011-11-02 02:22:15 -0500128 'passwordCredentials': {
129 'username': user,
Daryl Walleck587385b2012-03-03 13:00:26 -0600130 'password': password,
Daryl Walleck1465d612011-11-02 02:22:15 -0500131 },
Zhongyue Luo30a563f2012-09-30 23:43:50 +0900132 'tenantName': tenant_name,
Daryl Walleck1465d612011-11-02 02:22:15 -0500133 }
134 }
135
Daryl Walleck1465d612011-11-02 02:22:15 -0500136 headers = {'Content-Type': 'application/json'}
137 body = json.dumps(creds)
Pavel Sedláke267eba2013-04-03 15:56:36 +0200138 self._log_request('POST', auth_url, headers, body)
139 resp, resp_body = self.http_obj.request(auth_url, 'POST',
140 headers=headers, body=body)
141 self._log_response(resp, resp_body)
Daryl Walleck1465d612011-11-02 02:22:15 -0500142
Jay Pipes7f757632011-12-02 15:53:32 -0500143 if resp.status == 200:
144 try:
Pavel Sedláke267eba2013-04-03 15:56:36 +0200145 auth_data = json.loads(resp_body)['access']
Jay Pipes7f757632011-12-02 15:53:32 -0500146 token = auth_data['token']['id']
Jay Pipes7f757632011-12-02 15:53:32 -0500147 except Exception, e:
Adam Gandelmane2d46b42012-01-03 17:40:44 -0800148 print "Failed to obtain token for user: %s" % e
Jay Pipes7f757632011-12-02 15:53:32 -0500149 raise
Adam Gandelmane2d46b42012-01-03 17:40:44 -0800150
151 mgmt_url = None
152 for ep in auth_data['serviceCatalog']:
Dan Prince8527c8a2012-12-14 14:00:31 -0500153 if ep["type"] == service:
K Jonathan Harkerd6ba4b42012-12-18 13:50:47 -0800154 for _ep in ep['endpoints']:
155 if service in self.region and \
156 _ep['region'] == self.region[service]:
157 mgmt_url = _ep[self.endpoint_url]
158 if not mgmt_url:
159 mgmt_url = ep['endpoints'][0][self.endpoint_url]
Adam Gandelmane2d46b42012-01-03 17:40:44 -0800160 break
161
Zhongyue Luoe471d6e2012-09-17 17:02:43 +0800162 if mgmt_url is None:
Adam Gandelmane2d46b42012-01-03 17:40:44 -0800163 raise exceptions.EndpointNotFound(service)
164
Rohit Karajgid2a28af2012-05-23 03:44:59 -0700165 return token, mgmt_url
166
Jay Pipes7f757632011-12-02 15:53:32 -0500167 elif resp.status == 401:
Daryl Wallecka22f57b2012-03-20 16:52:07 -0500168 raise exceptions.AuthenticationFailure(user=user,
169 password=password)
Pavel Sedláke267eba2013-04-03 15:56:36 +0200170 raise exceptions.IdentityError('Unexpected status code {0}'.format(
171 resp.status))
Daryl Walleck1465d612011-11-02 02:22:15 -0500172
173 def post(self, url, body, headers):
174 return self.request('POST', url, headers, body)
175
Attila Fazekasb8aa7592013-01-26 01:25:45 +0100176 def get(self, url, headers=None):
177 return self.request('GET', url, headers)
Daryl Walleck1465d612011-11-02 02:22:15 -0500178
Dan Smithba6cb162012-08-14 07:22:42 -0700179 def delete(self, url, headers=None):
180 return self.request('DELETE', url, headers)
Daryl Walleck1465d612011-11-02 02:22:15 -0500181
rajalakshmi-ganesanab426722013-02-08 15:49:15 +0530182 def patch(self, url, body, headers):
183 return self.request('PATCH', url, headers, body)
184
Daryl Walleck1465d612011-11-02 02:22:15 -0500185 def put(self, url, body, headers):
186 return self.request('PUT', url, headers, body)
187
dwalleck5d734432012-10-04 01:11:47 -0500188 def head(self, url, headers=None):
Larisa Ustalov6c3c7802012-11-05 12:25:19 +0200189 return self.request('HEAD', url, headers)
190
191 def copy(self, url, headers=None):
192 return self.request('COPY', url, headers)
dwalleck5d734432012-10-04 01:11:47 -0500193
Matthew Treinishc0f768f2013-03-11 14:24:16 -0400194 def get_versions(self):
195 resp, body = self.get('')
196 body = self._parse_resp(body)
197 body = body['versions']
198 versions = map(lambda x: x['id'], body)
199 return resp, versions
200
Attila Fazekas11d2a772013-01-29 17:46:52 +0100201 def _log_request(self, method, req_url, headers, body):
202 self.LOG.info('Request: ' + method + ' ' + req_url)
203 if headers:
204 print_headers = headers
205 if 'X-Auth-Token' in headers and headers['X-Auth-Token']:
206 token = headers['X-Auth-Token']
207 if len(token) > 64 and TOKEN_CHARS_RE.match(token):
208 print_headers = headers.copy()
209 print_headers['X-Auth-Token'] = "<Token omitted>"
210 self.LOG.debug('Request Headers: ' + str(print_headers))
211 if body:
212 str_body = str(body)
213 length = len(str_body)
214 self.LOG.debug('Request Body: ' + str_body[:2048])
215 if length >= 2048:
216 self.LOG.debug("Large body (%d) md5 summary: %s", length,
217 hashlib.md5(str_body).hexdigest())
218
219 def _log_response(self, resp, resp_body):
220 status = resp['status']
221 self.LOG.info("Response Status: " + status)
222 headers = resp.copy()
223 del headers['status']
224 if len(headers):
225 self.LOG.debug('Response Headers: ' + str(headers))
226 if resp_body:
227 str_body = str(resp_body)
228 length = len(str_body)
229 self.LOG.debug('Response Body: ' + str_body[:2048])
230 if length >= 2048:
231 self.LOG.debug("Large body (%d) md5 summary: %s", length,
232 hashlib.md5(str_body).hexdigest())
Daryl Walleck8a707db2012-01-25 00:46:24 -0600233
Dan Smithba6cb162012-08-14 07:22:42 -0700234 def _parse_resp(self, body):
235 return json.loads(body)
236
Attila Fazekas836e4782013-01-29 15:40:13 +0100237 def response_checker(self, method, url, headers, body, resp, resp_body):
238 if (resp.status in set((204, 205, 304)) or resp.status < 200 or
Pavel Sedláke267eba2013-04-03 15:56:36 +0200239 method.upper() == 'HEAD') and resp_body:
Attila Fazekas836e4782013-01-29 15:40:13 +0100240 raise exceptions.ResponseWithNonEmptyBody(status=resp.status)
241 #NOTE(afazekas):
242 # If the HTTP Status Code is 205
243 # 'The response MUST NOT include an entity.'
244 # A HTTP entity has an entity-body and an 'entity-header'.
245 # In the HTTP response specification (Section 6) the 'entity-header'
246 # 'generic-header' and 'response-header' are in OR relation.
247 # All headers not in the above two group are considered as entity
248 # header in every interpretation.
249
250 if (resp.status == 205 and
251 0 != len(set(resp.keys()) - set(('status',)) -
252 self.response_header_lc - self.general_header_lc)):
253 raise exceptions.ResponseWithEntity()
254 #NOTE(afazekas)
255 # Now the swift sometimes (delete not empty container)
256 # returns with non json error response, we can create new rest class
257 # for swift.
258 # Usually RFC2616 says error responses SHOULD contain an explanation.
259 # The warning is normal for SHOULD/SHOULD NOT case
260
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100261 # Likely it will cause an error
262 if not resp_body and resp.status >= 400:
Attila Fazekas11d2a772013-01-29 17:46:52 +0100263 self.LOG.warning("status >= 400 response with empty body")
Attila Fazekas836e4782013-01-29 15:40:13 +0100264
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100265 def _request(self, method, url,
266 headers=None, body=None):
Daryl Wallecke5b83d42011-11-10 14:39:02 -0600267 """A simple HTTP request interface."""
Daryl Walleck1465d612011-11-02 02:22:15 -0500268
Daryl Walleck1465d612011-11-02 02:22:15 -0500269 req_url = "%s/%s" % (self.base_url, url)
Attila Fazekas11d2a772013-01-29 17:46:52 +0100270 self._log_request(method, req_url, headers, body)
Daryl Walleck8a707db2012-01-25 00:46:24 -0600271 resp, resp_body = self.http_obj.request(req_url, method,
Zhongyue Luo79d8d362012-09-25 13:49:27 +0800272 headers=headers, body=body)
Attila Fazekas11d2a772013-01-29 17:46:52 +0100273 self._log_response(resp, resp_body)
Attila Fazekas836e4782013-01-29 15:40:13 +0100274 self.response_checker(method, url, headers, body, resp, resp_body)
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100275
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100276 return resp, resp_body
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500277
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100278 def request(self, method, url,
279 headers=None, body=None):
280 retry = 0
281 if (self.token is None) or (self.base_url is None):
282 self._set_auth()
283
284 if headers is None:
285 headers = {}
286 headers['X-Auth-Token'] = self.token
287
288 resp, resp_body = self._request(method, url,
289 headers=headers, body=body)
290
291 while (resp.status == 413 and
292 'retry-after' in resp and
293 not self.is_absolute_limit(
294 resp, self._parse_resp(resp_body)) and
295 retry < MAX_RECURSION_DEPTH):
296 retry += 1
297 delay = int(resp['retry-after'])
298 time.sleep(delay)
299 resp, resp_body = self._request(method, url,
300 headers=headers, body=body)
301 self._error_checker(method, url, headers, body,
302 resp, resp_body)
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500303 return resp, resp_body
304
305 def _error_checker(self, method, url,
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100306 headers, body, resp, resp_body):
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500307
308 # NOTE(mtreinish): Check for httplib response from glance_http. The
309 # object can't be used here because importing httplib breaks httplib2.
310 # If another object from a class not imported were passed here as
311 # resp this could possibly fail
312 if str(type(resp)) == "<type 'instance'>":
313 ctype = resp.getheader('content-type')
314 else:
315 try:
316 ctype = resp['content-type']
317 # NOTE(mtreinish): Keystone delete user responses doesn't have a
318 # content-type header. (They don't have a body) So just pretend it
319 # is set.
320 except KeyError:
321 ctype = 'application/json'
322
Attila Fazekase72b7cd2013-03-26 18:34:21 +0100323 # It is not an error response
324 if resp.status < 400:
325 return
326
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500327 JSON_ENC = ['application/json; charset=UTF-8', 'application/json',
328 'application/json; charset=utf-8']
329 # NOTE(mtreinish): This is for compatibility with Glance and swift
330 # APIs. These are the return content types that Glance api v1
331 # (and occasionally swift) are using.
332 TXT_ENC = ['text/plain; charset=UTF-8', 'text/html; charset=UTF-8',
333 'text/plain; charset=utf-8']
334 XML_ENC = ['application/xml', 'application/xml; charset=UTF-8']
335
336 if ctype in JSON_ENC or ctype in XML_ENC:
337 parse_resp = True
338 elif ctype in TXT_ENC:
339 parse_resp = False
340 else:
341 raise exceptions.RestClientException(str(resp.status))
342
Rohit Karajgi6b1e1542012-05-14 05:55:54 -0700343 if resp.status == 401 or resp.status == 403:
Daryl Walleckced8eb82012-03-19 13:52:37 -0500344 raise exceptions.Unauthorized()
Jay Pipes5135bfc2012-01-05 15:46:49 -0500345
346 if resp.status == 404:
Daryl Walleck8a707db2012-01-25 00:46:24 -0600347 raise exceptions.NotFound(resp_body)
Jay Pipes5135bfc2012-01-05 15:46:49 -0500348
Daryl Walleckadea1fa2011-11-15 18:36:39 -0600349 if resp.status == 400:
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500350 if parse_resp:
351 resp_body = self._parse_resp(resp_body)
David Kranz28e35c52012-07-10 10:14:38 -0400352 raise exceptions.BadRequest(resp_body)
Daryl Walleckadea1fa2011-11-15 18:36:39 -0600353
David Kranz5a23d862012-02-14 09:48:55 -0500354 if resp.status == 409:
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500355 if parse_resp:
356 resp_body = self._parse_resp(resp_body)
David Kranz5a23d862012-02-14 09:48:55 -0500357 raise exceptions.Duplicate(resp_body)
358
Daryl Wallecked8bef32011-12-05 23:02:08 -0600359 if resp.status == 413:
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500360 if parse_resp:
361 resp_body = self._parse_resp(resp_body)
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100362 if self.is_absolute_limit(resp, resp_body):
363 raise exceptions.OverLimit(resp_body)
364 else:
365 raise exceptions.RateLimitExceeded(resp_body)
Brian Lamar12d9b292011-12-08 12:41:21 -0500366
Wangpana9b54c62013-02-28 11:04:32 +0800367 if resp.status == 422:
368 if parse_resp:
369 resp_body = self._parse_resp(resp_body)
370 raise exceptions.UnprocessableEntity(resp_body)
371
Daryl Wallecked8bef32011-12-05 23:02:08 -0600372 if resp.status in (500, 501):
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500373 message = resp_body
374 if parse_resp:
375 resp_body = self._parse_resp(resp_body)
376 #I'm seeing both computeFault and cloudServersFault come back.
377 #Will file a bug to fix, but leave as is for now.
378 if 'cloudServersFault' in resp_body:
379 message = resp_body['cloudServersFault']['message']
380 elif 'computeFault' in resp_body:
381 message = resp_body['computeFault']['message']
382 elif 'error' in resp_body: # Keystone errors
383 message = resp_body['error']['message']
384 raise exceptions.IdentityError(message)
385 elif 'message' in resp_body:
386 message = resp_body['message']
Dan Princea4b709c2012-10-10 12:27:59 -0400387
Daryl Walleckf0087032011-12-18 13:37:05 -0600388 raise exceptions.ComputeFault(message)
Daryl Wallecked8bef32011-12-05 23:02:08 -0600389
David Kranz5a23d862012-02-14 09:48:55 -0500390 if resp.status >= 400:
Matthew Treinish7e5a3ec2013-02-08 13:53:58 -0500391 if parse_resp:
392 resp_body = self._parse_resp(resp_body)
Attila Fazekas96524032013-01-29 19:52:49 +0100393 raise exceptions.RestClientException(str(resp.status))
David Kranz5a23d862012-02-14 09:48:55 -0500394
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100395 def is_absolute_limit(self, resp, resp_body):
396 if (not isinstance(resp_body, collections.Mapping) or
Pavel Sedláke267eba2013-04-03 15:56:36 +0200397 'retry-after' not in resp):
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100398 return True
399 over_limit = resp_body.get('overLimit', None)
400 if not over_limit:
401 return True
402 return 'exceed' in over_limit.get('message', 'blabla')
rajalakshmi-ganesan0275a0d2013-01-11 18:26:05 +0530403
David Kranz6aceb4a2012-06-05 14:05:45 -0400404 def wait_for_resource_deletion(self, id):
Sean Daguef237ccb2013-01-04 15:19:14 -0500405 """Waits for a resource to be deleted."""
David Kranz6aceb4a2012-06-05 14:05:45 -0400406 start_time = int(time.time())
407 while True:
408 if self.is_resource_deleted(id):
409 return
410 if int(time.time()) - start_time >= self.build_timeout:
411 raise exceptions.TimeoutException
412 time.sleep(self.build_interval)
413
414 def is_resource_deleted(self, id):
415 """
416 Subclasses override with specific deletion detection.
417 """
Attila Fazekasd236b4e2013-01-26 00:44:12 +0100418 message = ('"%s" does not implement is_resource_deleted'
419 % self.__class__.__name__)
420 raise NotImplementedError(message)
Dan Smithba6cb162012-08-14 07:22:42 -0700421
422
423class RestClientXML(RestClient):
424 TYPE = "xml"
425
426 def _parse_resp(self, body):
427 return xml_to_json(etree.fromstring(body))
rajalakshmi-ganesan0275a0d2013-01-11 18:26:05 +0530428
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100429 def is_absolute_limit(self, resp, resp_body):
430 if (not isinstance(resp_body, collections.Mapping) or
Pavel Sedláke267eba2013-04-03 15:56:36 +0200431 'retry-after' not in resp):
Attila Fazekas55f6d8c2013-03-10 10:32:54 +0100432 return True
433 return 'exceed' in resp_body.get('message', 'blabla')