Skip to content

Commit

Permalink
Catch ServerDownOrUnreachableError in redfish_available function, and…
Browse files Browse the repository at this point in the history
… mark redfish as unavailable.
  • Loading branch information
chanchiwai-ray committed Nov 17, 2023
1 parent 15c02a2 commit 497bba0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hw_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 497bba0

Please sign in to comment.