]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
node-proxy: catch more error in redfish_client
authorGuillaume Abrioux <gabrioux@ibm.com>
Wed, 7 Jun 2023 12:20:07 +0000 (14:20 +0200)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 25 Jan 2024 14:43:29 +0000 (14:43 +0000)
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 <gabrioux@ibm.com>
src/cephadm/node-proxy/redfish_client.py

index 52ae3c089def852dc463db4978949a84e60ffdce..3948b7444f37df85a16ce771b0cb5d52d993ad22 100644 (file)
@@ -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: