From 5abd080ba2ce9ddc90c4c0e8ed367229770ce35f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 30 Jun 2026 13:56:34 -0400 Subject: [PATCH] Restore some sanity to redfish error handling --- confluent_server/aiohmi/redfish/command.py | 2 ++ .../aiohmi/redfish/oem/lenovo/main.py | 4 +++- .../plugins/hardwaremanagement/redfish.py | 21 +++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/confluent_server/aiohmi/redfish/command.py b/confluent_server/aiohmi/redfish/command.py index dbb4e40b..adc7288d 100644 --- a/confluent_server/aiohmi/redfish/command.py +++ b/confluent_server/aiohmi/redfish/command.py @@ -497,6 +497,8 @@ class Command(object): async def bmcinfo(self): bmcurl = await self.get_bmcurl() + if not bmcurl: + raise exc.PyghmiException('Unable to identify BMC') return await self._do_web_request(bmcurl) async def get_power(self): diff --git a/confluent_server/aiohmi/redfish/oem/lenovo/main.py b/confluent_server/aiohmi/redfish/oem/lenovo/main.py index bd2c83e7..35ba6bbf 100644 --- a/confluent_server/aiohmi/redfish/oem/lenovo/main.py +++ b/confluent_server/aiohmi/redfish/oem/lenovo/main.py @@ -17,11 +17,13 @@ from aiohmi.redfish.oem.lenovo import tsma from aiohmi.redfish.oem.lenovo import xcc from aiohmi.redfish.oem.lenovo import xcc3 from aiohmi.redfish.oem.lenovo import smm3 - +import aiohmi.exceptions as exc async def get_handler(sysinfo, sysurl, webclient, cache, cmd, rootinfo={}): if not sysinfo: # we are before establishing there is one system, and one manager... systems, status = await webclient.grab_json_response_with_status('/redfish/v1/Systems') + if status == 401: + raise exc.PyghmiException('Access Denied') if status == 200: for system in systems.get('Members', []): if system.get('@odata.id', '').endswith('/1'): diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index 26e39265..d95ff71e 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -160,18 +160,8 @@ class IpmiCommandWrapper(ipmicommand.Command): kv = util.TLSCertVerifier(cfm, node, 'pubkeys.tls_hardwaremanager', subject).verify_cert kwargs['verifycallback'] = kv - self = await super().create(**kwargs) - self.confluentbmcname = kwargs['bmc'] - self.cfm = cfm - self.node = node - self._inhealth = False - self._lasthealth = None - self._attribwatcher = cfm.watch_attributes( - (node,), ('secret.hardwaremanagementuser', 'collective.manager', - 'secret.hardwaremanagementpassword', - 'hardwaremanagement.manager'), self._attribschanged) try: - pass + self = await super().create(**kwargs) except socket.error as se: if (hasattr(se, 'errno') and se.errno in (errno.ENETUNREACH, errno.EHOSTUNREACH, errno.EADDRNOTAVAIL)): @@ -188,6 +178,15 @@ class IpmiCommandWrapper(ipmicommand.Command): if 'Redfish not ready' in str(pe): raise exc.TargetEndpointUnreachable('Redfish is not supported by this system or is not yet ready') raise + self.confluentbmcname = kwargs['bmc'] + self.cfm = cfm + self.node = node + self._inhealth = False + self._lasthealth = None + self._attribwatcher = cfm.watch_attributes( + (node,), ('secret.hardwaremanagementuser', 'collective.manager', + 'secret.hardwaremanagementpassword', + 'hardwaremanagement.manager'), self._attribschanged) return self def close_confluent(self):