Handle login exception.
This is a first implementation that needs more elaborate error msg.
This commit is contained in:
parent
a3755a1071
commit
d3506f6a2e
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import config
|
||||
|
||||
class RedfishException(Exception):
|
||||
"""Base class for redfish exceptions"""
|
||||
@ -8,9 +9,13 @@ class RedfishException(Exception):
|
||||
self.message = message
|
||||
|
||||
|
||||
|
||||
class AuthenticationFailureException(RedfishException):
|
||||
pass
|
||||
|
||||
def __init__(self, message=None, **kwargs):
|
||||
super(AuthenticationFailureException, self).__init__(message=None, **kwargs)
|
||||
config.logger.error(message)
|
||||
# TODO
|
||||
# Give a bit more details about the failure (check login etc...)
|
||||
sys.exit(1)
|
||||
|
||||
class LogoutFailureException(RedfishException):
|
||||
pass
|
||||
pass
|
||||
|
@ -313,7 +313,7 @@ class RedfishConnection(object):
|
||||
# TODO : Manage exception with a class.
|
||||
# =======================================================================
|
||||
if auth.status_code != 201:
|
||||
pass
|
||||
raise exception.AuthenticationFailureException("Login request return an invalid status code")
|
||||
#sysraise "Error getting token", auth.status_code
|
||||
|
||||
self.connection_parameters.auth_token = auth.headers.get("x-auth-token")
|
||||
|
Loading…
x
Reference in New Issue
Block a user