From c8653e4cf64af5156d571d5e2ffe7e912ac0a78e Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 7 Jun 2023 14:20:07 +0200 Subject: [PATCH] node-proxy: catch more error in redfish_client This catches more potential exceptions in the redfish_client class. So if an error is caught we can log a more accurate and nicer message. Signed-off-by: Guillaume Abrioux --- src/cephadm/node-proxy/redfish_client.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cephadm/node-proxy/redfish_client.py b/src/cephadm/node-proxy/redfish_client.py index 52ae3c089de..3948b7444f3 100644 --- a/src/cephadm/node-proxy/redfish_client.py +++ b/src/cephadm/node-proxy/redfish_client.py @@ -1,5 +1,8 @@ -from redfish.rest.v1 import ServerDownOrUnreachableError +from redfish.rest.v1 import ServerDownOrUnreachableError, \ + SessionCreationError, \ + InvalidCredentialsError import redfish +import sys from util import logger log = logger(__name__, level=10) @@ -23,8 +26,12 @@ class RedFishClient: try: self.redfish_obj.login(auth="session") log.info(f"Logging to redfish api at {self.host} with user: {self.username}") - except ServerDownOrUnreachableError as e: - log.error(f"Server not reachable or does not support RedFish {e}", e) + return self.redfish_obj + except InvalidCredentialsError as e: + log.error(f"Invalid credentials for {self.username} at {self.host}:\n{e}") + except (SessionCreationError, ServerDownOrUnreachableError) as e: + log.error(f"Server not reachable or does not support RedFish:\n{e}") + sys.exit(1) def get_path(self, path): try: -- 2.39.5