From: Afreen Misbah Date: Thu, 25 Jun 2026 18:58:06 +0000 (+0530) Subject: mgr/dashboard: fix hardware status parsing for health X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b269dc7e147eed559b0e7c9036f4e6f634b888b9;p=ceph.git mgr/dashboard: fix hardware status parsing for health Atollon return status as a plain string ("OK") instead of the dict format ({"health": "OK", "state": "Enabled"}) used by other BMCs. This caused KeyError/AttributeError. Added _get_health() helper that handles both formats: - dict with nested health key - plain string status - missing or non-dict components Signed-off-by: Afreen Misbah --- diff --git a/src/pybind/mgr/dashboard/services/hardware.py b/src/pybind/mgr/dashboard/services/hardware.py index 2aa89f422a3..34c8c2cc3fa 100644 --- a/src/pybind/mgr/dashboard/services/hardware.py +++ b/src/pybind/mgr/dashboard/services/hardware.py @@ -23,9 +23,19 @@ class HardwareService(object): } } + def _get_health(component: Any) -> str: + if not isinstance(component, dict): + return 'Unknown' + status_val = component.get("status", {}) + if isinstance(status_val, dict): + return status_val.get("health", "Unknown") + if isinstance(status_val, str): + return status_val + return 'Unknown' + def count_ok(data: dict) -> int: return sum( - component.get("status", {}).get("health") == "OK" + _get_health(component) == "OK" for node in data.values() for system in node.values() for component in system.values() @@ -53,7 +63,8 @@ class HardwareService(object): output['host'].setdefault(host, {'flawed': False}) if not output['host'][host]['flawed']: for system in systems.values(): - if any(dimm['status']['health'] != 'OK' for dimm in system.values()): + if any(_get_health(comp) != 'OK' + for comp in system.values()): output['host'][host]['flawed'] = True break