Skip to content

Commit

Permalink
Catches HTTP 300 while printing responses
Browse files Browse the repository at this point in the history
If glance v1 api is not enabled, and a request is made to it,
it gives a KeyError. This patch catches the 300 error and
displays error message.

Fixes bug 1046607

Change-Id: I0009a5deca3b5dd5ccaeaea90feee21274bfe090
  • Loading branch information
isethi committed Sep 10, 2012
1 parent 61b359e commit 5acd5a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions glanceclient/common/http.py
Expand Up @@ -159,6 +159,8 @@ def _http_request(self, url, method, **kwargs):
elif resp.status in (301, 302, 305):
# Redirected. Reissue the request to the new location.
return self._http_request(resp['location'], method, **kwargs)
elif resp.status == 300:
raise exc.from_response(resp)

return resp, body_iter

Expand Down
10 changes: 10 additions & 0 deletions glanceclient/exc.py
Expand Up @@ -52,6 +52,16 @@ def __str__(self):
return "%s (HTTP %s)" % (self.__class__.__name__, self.code)


class HTTPMultipleChoices(HTTPException):
code = 300

def __str__(self):
self.details = ("Requested version of OpenStack Images API is not"
"available.")
return "%s (HTTP %s) %s" % (self.__class__.__name__, self.code,
self.details)


class BadRequest(HTTPException):
"""DEPRECATED"""
code = 400
Expand Down

0 comments on commit 5acd5a6

Please sign in to comment.