diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index d3906a25..0b6a3178 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -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. diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 38334c1c..977ab04e 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -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.