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