From 382441a9f18c583c071bf69d25cd44f5ec3555bb Mon Sep 17 00:00:00 2001 From: Lin Hua Cheng Date: Tue, 5 Feb 2013 11:17:53 -0800 Subject: [PATCH] Treat HTTP code 400 and above as error. Fixes bug 1116559. Change-Id: I4b12176599686f7e545b63c8e54cf9da6a1f963e --- keystoneclient/client.py | 2 +- keystoneclient/exceptions.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/keystoneclient/client.py b/keystoneclient/client.py index 77e8b3c92..0233aeb69 100644 --- a/keystoneclient/client.py +++ b/keystoneclient/client.py @@ -341,7 +341,7 @@ class HTTPClient(object): self.http_log_resp(resp) - if resp.status_code in (400, 401, 403, 404, 408, 409, 413, 500, 501): + if resp.status_code >= 400: _logger.debug( "Request returned failure status: %s", resp.status_code) diff --git a/keystoneclient/exceptions.py b/keystoneclient/exceptions.py index 213f0781c..2174cfbad 100644 --- a/keystoneclient/exceptions.py +++ b/keystoneclient/exceptions.py @@ -79,6 +79,14 @@ class NotFound(ClientException): message = "Not found" +class MethodNotAllowed(ClientException): + """ + HTTP 405 - Method not allowed + """ + http_status = 405 + message = "Method not allowed" + + class Conflict(ClientException): """ HTTP 409 - Conflict @@ -122,6 +130,7 @@ _code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized, Forbidden, NotFound, + MethodNotAllowed, OverLimit, HTTPNotImplemented, ServiceUnavailable])