mirror of
https://opendev.org/x/pyghmi
synced 2026-05-15 10:54:22 +00:00
Provide extensibility to sensors by OEM
OEMs frequently employ special commands for data that logically would be expected to manifest as a sensor. Provide a facility for OEMs to make up sensors and provide data in the form of a 'sensor' without requiring SDR. Change-Id: I6bce99680ff64ffe2dbc0898d193a17dde066b9c
This commit is contained in:
@@ -550,7 +550,8 @@ class Command(object):
|
||||
raise exc.IpmiException(rsp['error'], rsp['code'])
|
||||
return self._sdr.sensors[sensor].decode_sensor_reading(
|
||||
rsp['data'])
|
||||
raise Exception('Sensor not found: ' + sensorname)
|
||||
self.oem_init()
|
||||
return self._oem.get_sensor_reading(sensorname)
|
||||
|
||||
def get_sensor_data(self):
|
||||
"""Get sensor reading objects
|
||||
@@ -569,6 +570,9 @@ class Command(object):
|
||||
continue
|
||||
raise exc.IpmiException(rsp['error'], code=rsp['code'])
|
||||
yield self._sdr.sensors[sensor].decode_sensor_reading(rsp['data'])
|
||||
self.oem_init()
|
||||
for reading in self._oem.get_sensor_data():
|
||||
yield reading
|
||||
|
||||
def get_sensor_descriptions(self):
|
||||
"""Get available sensor names
|
||||
@@ -582,6 +586,9 @@ class Command(object):
|
||||
for sensor in self._sdr.get_sensor_numbers():
|
||||
yield {'name': self._sdr.sensors[sensor].name,
|
||||
'type': self._sdr.sensors[sensor].sensor_type}
|
||||
self.oem_init()
|
||||
for sensor in self._oem.get_sensor_descriptions():
|
||||
yield sensor
|
||||
|
||||
def get_network_channel(self):
|
||||
"""Get a reasonable 'default' network channel.
|
||||
|
||||
@@ -52,6 +52,33 @@ class OEMHandler(object):
|
||||
"""
|
||||
return ()
|
||||
|
||||
def get_sensor_reading(self, sensorname):
|
||||
"""Get an OEM sensor
|
||||
|
||||
If software wants to model some OEM behavior as a 'sensor' without
|
||||
doing SDR, this hook provides that ability. It should mimic
|
||||
the behavior of 'get_sensor_reading' in command.py.
|
||||
"""
|
||||
raise Exception('Sensor not found: ' + sensorname)
|
||||
|
||||
def get_sensor_descriptions(self):
|
||||
"""Get list of OEM sensor names and types
|
||||
|
||||
Iterate over dicts describing a label and type for OEM 'sensors'. This
|
||||
should mimic the behavior of the get_sensor_descriptions function
|
||||
in command.py.
|
||||
"""
|
||||
return ()
|
||||
|
||||
def get_sensor_data(self):
|
||||
"""Get OEM sensor data
|
||||
|
||||
Iterate through all OEM 'sensors' and return data as if they were
|
||||
normal sensors. This should mimic the behavior of the get_sensor_data
|
||||
function in command.py.
|
||||
"""
|
||||
return ()
|
||||
|
||||
def get_oem_inventory(self):
|
||||
"""Get tuples of component names and inventory data.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user