catching authorization failure (x-server-management-url KeyError)
This commit is contained in:
parent
c8b3b13615
commit
1f7605cb7e
@ -141,7 +141,10 @@ class HTTPClient(httplib2.Http):
|
||||
headers['X-Auth-Project-Id'] = self.projectid
|
||||
|
||||
resp, body = self.request(self.auth_url, 'GET', headers=headers)
|
||||
self.management_url = resp['x-server-management-url']
|
||||
try:
|
||||
self.management_url = resp['x-server-management-url']
|
||||
except KeyError:
|
||||
raise exceptions.AuthorizationFailure()
|
||||
|
||||
self.auth_token = resp['x-auth-token']
|
||||
else:
|
||||
|
@ -8,6 +8,10 @@ class CommandError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class AuthorizationFailure(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ClientException(Exception):
|
||||
"""
|
||||
The base exception class for all exceptions this library raises.
|
||||
@ -29,6 +33,7 @@ class BadRequest(ClientException):
|
||||
message = "Bad request"
|
||||
|
||||
|
||||
|
||||
class Unauthorized(ClientException):
|
||||
"""
|
||||
HTTP 401 - Unauthorized: bad credentials.
|
||||
|
@ -166,6 +166,8 @@ class OpenStackComputeShell(object):
|
||||
self.cs.authenticate()
|
||||
except exc.Unauthorized:
|
||||
raise exc.CommandError("Invalid OpenStack Nova credentials.")
|
||||
except exc.AuthorizationFailure:
|
||||
raise exc.CommandError("Unable to authorize user")
|
||||
|
||||
args.func(self.cs, args)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user