Add associations to sensors
This adds associations to all the sensors on dbus.
Tested: Mapper has lots of sensor associations now.
Change-Id: I9a1c51d6b139e45a228507d29637c29a84b302d9
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/sensor.hpp b/include/sensor.hpp
index bba2c4d..a6bf2b1 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -28,6 +28,7 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> sensorInterface;
std::shared_ptr<sdbusplus::asio::dbus_interface> thresholdInterfaceWarning;
std::shared_ptr<sdbusplus::asio::dbus_interface> thresholdInterfaceCritical;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> association;
double value = std::numeric_limits<double>::quiet_NaN();
double overriddenValue = std::numeric_limits<double>::quiet_NaN();
bool overridenState = false;
@@ -49,6 +50,17 @@
void
setInitialProperties(std::shared_ptr<sdbusplus::asio::connection>& conn)
{
+ if (association)
+ {
+ using Association =
+ std::tuple<std::string, std::string, std::string>;
+ std::vector<Association> associations;
+ associations.push_back(
+ Association("inventory", "sensors", configurationPath));
+ association->register_property("associations", associations);
+ association->initialize();
+ }
+
sensorInterface->register_property("MaxValue", maxValue);
sensorInterface->register_property("MinValue", minValue);
sensorInterface->register_property(
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 01edc13..1db036e 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -65,6 +65,9 @@
"/xyz/openbmc_project/sensors/voltage/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/voltage/" + name,
+ "org.openbmc.Associations");
setInitialProperties(conn);
setupRead();
@@ -80,6 +83,7 @@
objServer.remove_interface(thresholdInterfaceWarning);
objServer.remove_interface(thresholdInterfaceCritical);
objServer.remove_interface(sensorInterface);
+ objServer.remove_interface(association);
}
void ADCSensor::setupRead(void)
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index a6dc275..955bab4 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -61,6 +61,10 @@
"/xyz/openbmc_project/sensors/temperature/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/temperature/" + name,
+ "org.openbmc.Associations");
+
setInitialProperties(conn);
}
setupPowerMatch(conn);
@@ -77,6 +81,7 @@
objServer.remove_interface(thresholdInterfaceWarning);
objServer.remove_interface(thresholdInterfaceCritical);
objServer.remove_interface(sensorInterface);
+ objServer.remove_interface(association);
}
}
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 3649f2e..f4e59ee 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -109,6 +109,11 @@
"/xyz/openbmc_project/sensors/cfm/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/voltage/" + name,
+ "org.openbmc.Associations");
+
setInitialProperties(conn);
setupSensorMatch(
matches, *dbusConnection, "fan_tach",
@@ -132,6 +137,7 @@
objServer.remove_interface(thresholdInterfaceWarning);
objServer.remove_interface(thresholdInterfaceCritical);
objServer.remove_interface(sensorInterface);
+ objServer.remove_interface(association);
}
void CFMSensor::addTachRanges(const std::string& serviceName,
@@ -287,6 +293,9 @@
"/xyz/openbmc_project/sensors/temperature/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/temperature/" + name,
+ "org.openbmc.Associations");
setInitialProperties(conn);
setupMatches();
setupPowerMatch(conn);
@@ -297,6 +306,7 @@
objServer.remove_interface(thresholdInterfaceWarning);
objServer.remove_interface(thresholdInterfaceCritical);
objServer.remove_interface(sensorInterface);
+ objServer.remove_interface(association);
}
void ExitAirTempSensor::setupMatches(void)
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index c7855f6..8325d3d 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -62,6 +62,9 @@
"/xyz/openbmc_project/sensors/temperature/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/temperature/" + name,
+ "org.openbmc.Associations");
setInitialProperties(conn);
setupRead();
}
@@ -74,6 +77,7 @@
objServer.remove_interface(thresholdInterfaceWarning);
objServer.remove_interface(thresholdInterfaceCritical);
objServer.remove_interface(sensorInterface);
+ objServer.remove_interface(association);
}
void HwmonTempSensor::setupRead(void)
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 2870d33..b8dd220 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -79,6 +79,9 @@
"/xyz/openbmc_project/sensors/temperature/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/temperature/" + name,
+ "org.openbmc.Associations");
setupPowerMatch(conn);
}
@@ -88,6 +91,7 @@
objectServer.remove_interface(thresholdInterfaceWarning);
objectServer.remove_interface(thresholdInterfaceCritical);
objectServer.remove_interface(sensorInterface);
+ objectServer.remove_interface(association);
}
void IpmbSensor::init(void)
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index a88c248..c842464 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -63,6 +63,9 @@
"/xyz/openbmc_project/sensors/fan_tach/" + name,
"xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association = objectServer.add_interface(
+ "/xyz/openbmc_project/sensors/fan_tach/" + name,
+ "org.openbmc.Associations");
setInitialProperties(conn);
setupPowerMatch(conn);
setupRead();
@@ -76,6 +79,7 @@
objServer.remove_interface(thresholdInterfaceWarning);
objServer.remove_interface(thresholdInterfaceCritical);
objServer.remove_interface(sensorInterface);
+ objServer.remove_interface(association);
}
void TachSensor::setupRead(void)