]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix hardware status parsing for health
authorAfreen Misbah <afreen@ibm.com>
Thu, 25 Jun 2026 18:58:06 +0000 (00:28 +0530)
committerAfreen Misbah <afreen@ibm.com>
Wed, 15 Jul 2026 11:24:46 +0000 (16:54 +0530)
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 <afreen@ibm.com>
src/pybind/mgr/dashboard/services/hardware.py

index 2aa89f422a38eef35c5faaccfb98ad29e306d084..34c8c2cc3fafa275d1e244afb5b75e4653c99633 100644 (file)
@@ -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