Display better message on Keystone failure
Fixes #148 When there's something wrong with Keystone, Heat reported a rather cryptic message. Now it indicates that the problem is with Keystone and passes its response to the user. Change-Id: I791b5bdfa68faa1b17daa67b911253d8bf8a2bb8 Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
This commit is contained in:
parent
8cbd065bf0
commit
4da17a9b8b
@ -243,7 +243,12 @@ class KeystoneStrategy(BaseStrategy):
|
||||
elif resp.status == 404:
|
||||
raise exception.AuthUrlNotFound(url=token_url)
|
||||
else:
|
||||
raise Exception(_('Unexpected response: %s') % resp.status)
|
||||
try:
|
||||
body = json.loads(resp_body)
|
||||
msg = body['error']['message']
|
||||
except:
|
||||
msg = resp_body
|
||||
raise exception.KeystoneError(resp.status, msg)
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
|
@ -29,6 +29,15 @@ class RedirectException(Exception):
|
||||
self.url = urlparse.urlparse(url)
|
||||
|
||||
|
||||
class KeystoneError(Exception):
|
||||
def __init__(self, code, message):
|
||||
self.code = code
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
return "Code: %s, message: %s" % (self.code, self.message)
|
||||
|
||||
|
||||
def wrap_exception(notifier=None, publisher_id=None, event_type=None,
|
||||
level=None):
|
||||
"""This decorator wraps a method to catch any exceptions that may
|
||||
|
@ -45,6 +45,11 @@ def catch_error(action):
|
||||
return FAILURE
|
||||
except exception.ClientConfigurationError:
|
||||
raise
|
||||
except exception.KeystoneError, e:
|
||||
logging.error("Keystone did not finish the authentication and "
|
||||
"returned the following message:\n\n%s"
|
||||
% e.message)
|
||||
return FAILURE
|
||||
except Exception, e:
|
||||
options = arguments[0]
|
||||
if options.debug:
|
||||
|
Loading…
Reference in New Issue
Block a user