2
0
mirror of https://opendev.org/x/pyghmi synced 2026-04-10 03:51:28 +00:00

Move normalized CPU and power to OEM

This permits OEM extensions, and use this to provide data for
XCC3 accurately.

Change-Id: I67e31839810ddf6740a99cf118e31287ec7fa2ba
This commit is contained in:
Jarrod Johnson
2024-09-27 12:28:10 -04:00
parent 764524cb33
commit 3f16d45c1e
3 changed files with 51 additions and 27 deletions

View File

@@ -1195,35 +1195,11 @@ class Command(object):
return retval
def get_average_processor_temperature(self):
cputemps = []
for chassis in self.sysinfo.get('Links', {}).get('Chassis', []):
thermals = self._get_thermals(chassis)
for temp in thermals:
if temp.get('PhysicalContext', '') != 'CPU':
continue
if temp.get('ReadingCelsius', None) is None:
continue
cputemps.append(temp['ReadingCelsius'])
if not cputemps:
return SensorReading(
None, {'name': 'Average Processor Temperature'}, value=None, units='°C',
unavailable=True)
avgtemp = sum(cputemps) / len(cputemps)
return SensorReading(
None, {'name': 'Average Processor Temperature'}, value=avgtemp, units='°C')
return self.oem.get_average_processor_temperature(self)
def get_system_power_watts(self):
totalwatts = 0
gotpower = False
for chassis in self.sysinfo.get('Links', {}).get('Chassis', []):
envinfo = self._get_chassis_env(chassis)
currwatts = envinfo.get('watts', None)
if currwatts is not None:
gotpower = True
totalwatts += envinfo['watts']
if not gotpower:
raise exc.UnsupportedFunctionality("System does not provide Power under redfish EnvironmentMetrics")
return totalwatts
return self.oem.get_system_power_watts(self)
def get_inlet_temperature(self):
inlets = []

View File

@@ -198,6 +198,42 @@ class OEMHandler(object):
# nothing programattic to consume to know when to do or not do an expand..
return False
def get_system_power_watts(self, fishclient):
totalwatts = 0
gotpower = False
for chassis in fishclient.sysinfo.get('Links', {}).get('Chassis', []):
envinfo = fishclient._get_chassis_env(chassis)
currwatts = envinfo.get('watts', None)
if currwatts is not None:
gotpower = True
totalwatts += envinfo['watts']
if not gotpower:
raise exc.UnsupportedFunctionality("System does not provide Power under redfish EnvironmentMetrics")
return totalwatts
def _get_cpu_temps(self, fishclient):
cputemps = []
for chassis in fishclient.sysinfo.get('Links', {}).get('Chassis', []):
thermals = fishclient._get_thermals(chassis)
for temp in thermals:
if temp.get('PhysicalContext', '') != 'CPU':
continue
if temp.get('ReadingCelsius', None) is None:
continue
cputemps.append(temp)
return cputemps
def get_average_processor_temperature(self, fishclient):
cputemps = self._get_cpu_temps(fishclient)
if not cputemps:
return SensorReading(
None, {'name': 'Average Processor Temperature'}, value=None, units='°C',
unavailable=True)
cputemps = [x['ReadingCelsius'] for x in cputemps]
avgtemp = sum(cputemps) / len(cputemps)
return SensorReading(
None, {'name': 'Average Processor Temperature'}, value=avgtemp, units='°C')
def get_health(self, fishclient, verbose=True):
health = fishclient.sysinfo.get('Status', {})
health = health.get('HealthRollup', health.get('Health', 'Unknown'))

View File

@@ -10,6 +10,18 @@ class OEMHandler(generic.OEMHandler):
def supports_expand(self, url):
return True
def get_system_power_watts(self, fishclient):
powerinfo = fishclient._do_web_request('/redfish/v1/Chassis/1/Sensors/power_Sys_Power')
return powerinfo['Reading']
def _get_cpu_temps(self, fishclient):
cputemps = []
for reading in super()._get_cpu_temps(fishclient):
if 'Margin' in reading['Name']:
continue
cputemps.append(reading)
return cputemps
def get_system_configuration(self, hideadvanced=True, fishclient=None):
stgs = self._getsyscfg(fishclient)[0]
outstgs = {}