Handle exceptions when there are connection errors
Changes:
- Added try except handling in a key location to
suppress noisy traceback python dumping on the
console.
- Add code to mask password in the console log
Tested:
- When failed to connect to the server when it is not
responsive.
- Wrong password causing the connection to fail.
- Wrong HTTPS port to cause connection failure
Change-Id: I27bb4e2fe4489ad742b7d9ebacd09a8f7ced4fa0
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish_utils.py b/lib/bmc_redfish_utils.py
index dbd5da7..099345a 100644
--- a/lib/bmc_redfish_utils.py
+++ b/lib/bmc_redfish_utils.py
@@ -23,7 +23,14 @@
"""
# Obtain a reference to the global redfish object.
self.__inited__ = False
- self._redfish_ = BuiltIn().get_library_instance("redfish")
+ try:
+ self._redfish_ = BuiltIn().get_library_instance("redfish")
+ except RuntimeError as e:
+ BuiltIn().log_to_console(
+ "get_library_instance: No active redfish instance found."
+ )
+ # Handling init exception at worse to raise on error.
+ raise e
if MTLS_ENABLED == "True":
self.__inited__ = True