From 2a91bb3f8005876267fea4703ae672873bb175a1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 7 Feb 2025 11:42:13 -0500 Subject: [PATCH] General fixup for sensor handling Fixup more sensor scenarios. Give OEM a mechanism to opt out of generic sensors. If, for example, the platform is unreasonably slow at servicing the sensors. Change-Id: Ie8668ac219fc5d90f95dd980ffecd73a09ddd0cd --- pyghmi/redfish/command.py | 7 +++++-- pyghmi/redfish/oem/generic.py | 1 + pyghmi/redfish/oem/lenovo/xcc.py | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index cc3697b0..de8b7d48 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -68,6 +68,7 @@ _healthmap = { 'Unknown': const.Health.Warning, 'Warning': const.Health.Warning, 'OK': const.Health.Ok, + None: const.Health.Ok, } @@ -123,7 +124,7 @@ class SensorReading(object): self.states = [healthinfo.get('Status', {}).get('Health', 'Unknown')] self.health = _healthmap[healthinfo['Status']['Health']] - if healthinfo['Status']['Health'].lower() == 'ok': + if self.health == const.Health.Ok: self.states = [] self.value = value self.state_ids = None @@ -692,7 +693,9 @@ class Command(object): def _mapchassissensors(self, chassis): chassisurl = chassis['@odata.id'] chassisinfo = self._do_web_request(chassisurl) - sensors = chassisinfo.get('Sensors', {}).get('@odata.id', '') + sensors = None + if self.oem.usegenericsensors: + sensors = chassisinfo.get('Sensors', {}).get('@odata.id', '') if sensors: sensorinf = self._do_web_request(sensors) for sensor in sensorinf.get('Members', []): diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index a9ace6a2..1a639666 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -184,6 +184,7 @@ class AttrDependencyHandler(object): class OEMHandler(object): hostnic = None + usegenericsensors = True def __init__(self, sysinfo, sysurl, webclient, cache, gpool=None): self._gpool = gpool diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 584c44f7..47cee4c5 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -119,6 +119,7 @@ def str_to_size(sizestr): class OEMHandler(generic.OEMHandler): + usegenericsensors = False logouturl = '/api/providers/logout' bmcname = 'XCC' ADP_URL = '/api/dataset/imm_adapters?params=pci_GetAdapters'