sensor SDRs: lookup Board to set IPMI info
Looks up the board object, if there is an association, and if that board
object specifies an EntityId or EntityInstance, it will use those values
in the SDR. If the configuration of the sensor also implements one or
both of those properties, then those are used instead.
Tested: Validated if the json Board file has EntityId and
EntityInstance, those values are used in the SDR. Validated if the
configuration for the sensor has those values, then those are used
instead. Verified it works in cases where these values are not set,
etc.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I998eff9b0145ede7b386041b35f488fa6dd6714f
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index 8277bf2..2e99c6a 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -48,8 +48,6 @@
std::map<sdbusplus::message::object_path,
std::map<std::string, std::map<std::string, DbusVariant>>>;
-using SensorMap = std::map<std::string, std::map<std::string, DbusVariant>>;
-
static constexpr int sensorListUpdatePeriod = 10;
static constexpr int sensorMapUpdatePeriod = 2;
@@ -1271,8 +1269,6 @@
record.key.owner_lun = 0x0;
record.key.sensor_number = sensornumber;
- record.body.entity_id = 0x0;
- record.body.entity_instance = 0x01;
record.body.sensor_capabilities = 0x68; // auto rearm - todo hysteresis
record.body.sensor_type = getSensorTypeFromPath(path);
std::string type = getSensorTypeStringFromPath(path);
@@ -1292,6 +1288,16 @@
return ipmi::responseResponseError();
}
+ uint8_t entityId = 0;
+ uint8_t entityInstance = 0x01;
+
+ // follow the association chain to get the parent board's entityid and
+ // entityInstance
+ updateIpmiFromAssociation(path, sensorMap, entityId, entityInstance);
+
+ record.body.entity_id = entityId;
+ record.body.entity_instance = entityInstance;
+
auto maxObject = sensorObject->second.find("MaxValue");
auto minObject = sensorObject->second.find("MinValue");
double max = 128;