2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-28 16:20:54 +00:00

Stop redfish sensor health from raising on a missing Health

SensorReading computed health and states with .get() and then
overwrote both with a strict lookup, so a sensor whose Status lacks
Health, or carries a value outside the health map, raised KeyError
and aborted the whole sensor listing. Keep the tolerant lookup, and
drop the states of a reading that is OK, as the copy in command.py
already does.
This commit is contained in:
Markus Hilger
2026-09-24 18:24:55 +02:00
parent 5aecc483e0
commit 5050580bb8
@@ -111,6 +111,7 @@ def natural_sort(iterable):
class SensorReading(object):
def __init__(self, healthinfo, sensor=None, value=None, units=None,
unavailable=False):
self.states = []
if sensor:
self.name = sensor['name']
else:
@@ -119,8 +120,8 @@ class SensorReading(object):
'Status', {}).get('Health', None), const.Health.Warning)
self.states = [healthinfo.get('Status', {}).get('Health',
'Unknown')]
self.health = _healthmap[healthinfo['Status']['Health']]
self.states = [healthinfo['Status']['Health']]
if self.health == const.Health.Ok:
self.states = []
self.value = value
self.state_ids = None
self.imprecision = None