Fix PSU threshold mismatch issue
When trying to change thresholds on PSU sensors, PSU service will crash.
Some PSU in entity-manager will have threshold0 to threshodl5 which
contains all labels in one D-Bus path. But in current dbus sensors,
the presist threshold function do not support labels, it only check
severity. So when change a threshold in PSU sensor, it will change some
incorrect threshold in entity-manger. This patch adds label support to
presist threshold function, so that correct theshold in entity-manager
can be changed.
Tested:
After changed PSU1 Temp1 threshold by ipmitool, check the threshold again,
the value should be changed to the value we set. Check entity-manager,
the threshold in entity-manager should also change to the value we set.
Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
Change-Id: Ib1c8bb454cd42dff170ae33c4aa768c4b515bb44
diff --git a/include/sensor.hpp b/include/sensor.hpp
index e298677..3c4706f 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -60,7 +60,9 @@
}
void
- setInitialProperties(std::shared_ptr<sdbusplus::asio::connection>& conn)
+ setInitialProperties(std::shared_ptr<sdbusplus::asio::connection>& conn,
+ const std::string label = std::string(),
+ size_t thresholdSize = 0)
{
createAssociation(association, configurationPath);
@@ -114,14 +116,17 @@
std::cout << "trying to set uninitialized interface\n";
continue;
}
+
+ size_t thresSize =
+ label.empty() ? thresholds.size() : thresholdSize;
iface->register_property(
level, threshold.value,
- [&](const double& request, double& oldValue) {
+ [&, label, thresSize](const double& request, double& oldValue) {
oldValue = request; // todo, just let the config do this?
threshold.value = request;
thresholds::persistThreshold(configurationPath, objectType,
- threshold, conn,
- thresholds.size());
+ threshold, conn, thresSize,
+ label);
// Invalidate previously remembered value,
// so new thresholds will be checked during next update,
// even if sensor reading remains unchanged.