From b91ea93fe7de39140fdb5aa743ec6626ab46fb9e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 26 Oct 2023 11:28:43 -0400 Subject: [PATCH] Have average CPU handle totally missing sensors If not even unavailable sensors are found, create a new sensor to hold the unavailable data. Change-Id: I2865ff6b407955cb69655e1ae80da22c31bb6d5a --- pyghmi/ipmi/oem/generic.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 9b41e19d..a107f863 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -14,6 +14,7 @@ import pyghmi.exceptions as exc import pyghmi.ipmi.private.constants as event_const +import pyghmi.ipmi.sdr as ipmisdr import struct class OEMHandler(object): @@ -67,16 +68,14 @@ class OEMHandler(object): if sensor.entity == 'Processor': self._processor_names.append(sensor.sensor_name) readingvalues = [] - tmplreading = None for procsensor in self._processor_names: try: reading = ipmicmd.get_sensor_reading(procsensor) except exc.IpmiException: continue - tmplreading = reading if reading.value is not None: readingvalues.append(float(reading.value)) - tmplreading.name = 'Average Processor Temperature' + tmplreading = ipmisdr.SensorReading({'name': 'Average Processor Temperature', 'type': 'Temperature'}, '°C') if readingvalues: tmplreading.value = sum(readingvalues) / len(readingvalues) else: