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>
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):
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
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: