From 497bba06ba7f58e569f0273ea0075479cfb4d785 Mon Sep 17 00:00:00 2001 From: Chi Wai Chan Date: Fri, 17 Nov 2023 17:36:23 +0800 Subject: [PATCH] Catch ServerDownOrUnreachableError in redfish_available function, and mark redfish as unavailable. --- src/hw_tools.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hw_tools.py b/src/hw_tools.py index bf5a67f6..7a47d67e 100644 --- a/src/hw_tools.py +++ b/src/hw_tools.py @@ -14,7 +14,12 @@ from charms.operator_libs_linux.v0 import apt from ops.model import ModelError, Resources from redfish import redfish_client -from redfish.rest.v1 import InvalidCredentialsError, RetriesExhaustedError, SessionCreationError +from redfish.rest.v1 import ( + InvalidCredentialsError, + RetriesExhaustedError, + ServerDownOrUnreachableError, + SessionCreationError, +) from checksum import ( PERCCLI_VERSION_INFOS, @@ -354,7 +359,8 @@ def redfish_available() -> bool: max_retry=REDFISH_MAX_RETRY, ) redfish_obj.login(auth="session") - except RetriesExhaustedError: # redfish not available + except (RetriesExhaustedError, ServerDownOrUnreachableError): + # redfish not available result = False except (SessionCreationError, InvalidCredentialsError): # redfish available, wrong credentials or not able to create a session