Update threshold to entity-manager
Save path&interface when creating thresholds,and then set DBUS value
corresponding to path&interface when setting thresholds;
I have a requirement to set the threshold to restart without losing. In
addition, I can see that the threshold can be saved in the file in the
entity-manager, which can meet my requirements.
Data flow:
Old version: IPMI set threshold -> virtualsensors (DBUS) What
I want to achieve: IPMI set threshold -> virtualsensors (DBUS) ->
filesystem
I found that it can be implemented as follows: IPMI set
threshold -> virtual-sensors (DBUS) -> entitymanager -> filesystem
Because the threshold setting in dbus-sensors is: IPMI set threshold ->
dbus-sensors (DBUS) -> entitymanager -> filesystem
Tested:
The following print result shows this process:
IPMI set threshold -> virtual sensors (DBUS) -> entitymanager
root@NULL:~# busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/nvme/NVMe_MAX/NVMe_MAX_Temp xyz.openbmc_project.Configuration.ModifiedMedian.Thresholds0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Delete method - - -
.Direction property s "greater than" emits-change writable
.Name property s "upper critical" emits-change writable
.Severity property d 1 emits-change writable
.Value property d 116 emits-change writable
root@NULL:~# ipmitool sensor list | grep NVM
NVMe_MAX_Temp | na | degrees C | na | na | 1.000 | 6.000 | 111.000 | 116.000 | na
root@NULL:~# ipmitool sensor thresh NVMe_MAX_Temp ucr 119
Locating sensor record 'NVMe_MAX_Temp'...
Setting sensor "NVMe_MAX_Temp" Upper Critical threshold to 119.000
root@NULL:~# ipmitool sensor list | grep NVM
NVMe_MAX_Temp | na | degrees C | na | na | 1.000 | 6.000 | 111.000 | 119.000 | na
root@NULL:~# busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/nvme/NVMe_MAX/NVMe_MAX_Temp xyz.openbmc_project.Configuration.ModifiedMedian.Thresholds0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Delete method - - -
.Direction property s "greater than" emits-change writable
.Name property s "upper critical" emits-change writable
.Severity property d 1 emits-change writable
.Value property d 119 emits-change writable
root@NULL:~# busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/nvme/NVMe_MAX/NVMe_MAX_Temp xyz.openbmc_project.Configuration.ModifiedMedian.Thresholds0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Delete method - - -
.Direction property s "greater than" emits-change writable
.Name property s "upper critical" emits-change writable
.Severity property d 1 emits-change writable
.Value property d 119 emits-change writable
root@NULL:~#
Signed-off-by: Tao Lin <lintao.lc@inspur.com>
Change-Id: I0f5eeb06d0b3aaf4f5806bfa68672dedcb087f26
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index 5e4ca5f..063fb0f 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -188,7 +188,8 @@
return severity;
}
-void parseThresholds(Json& thresholds, const PropertyMap& propertyMap)
+void parseThresholds(Json& thresholds, const PropertyMap& propertyMap,
+ const std::string& entityInterface = "")
{
std::string direction;
@@ -210,6 +211,11 @@
{
thresholds[threshold + "Hysteresis"] = hysteresis;
}
+
+ if (!entityInterface.empty())
+ {
+ thresholds[threshold + "Direction"] = entityInterface;
+ }
}
void VirtualSensor::parseConfigInterface(const PropertyMap& propertyMap,
@@ -415,7 +421,7 @@
* eg xyz.openbmc_project.Configuration.ModifiedMedian.Thresholds1 */
if (interface.find(vsThresholdsIntf) != std::string::npos)
{
- parseThresholds(thresholds, propertyMap);
+ parseThresholds(thresholds, propertyMap, interface);
}
else if (interface == calculationIface)
{
@@ -568,6 +574,34 @@
threshold.value("CriticalHighHysteresis", defaultHysteresis));
criticalIface->setLowHysteresis(
threshold.value("CriticalLowHysteresis", defaultHysteresis));
+
+ if (threshold.contains("CriticalHigh"))
+ {
+ criticalIface->setEntityInterfaceHigh(
+ threshold.value("CriticalHighDirection", ""));
+ if (DEBUG)
+ {
+ debug("Sensor Threshold:{NAME} = intf:{INTF}", "NAME", objPath,
+ "INTF", threshold.value("CriticalHighDirection", ""));
+ }
+ }
+ if (threshold.contains("CriticalLow"))
+ {
+ criticalIface->setEntityInterfaceLow(
+ threshold.value("CriticalLowDirection", ""));
+ if (DEBUG)
+ {
+ debug("Sensor Threshold:{NAME} = intf:{INTF}", "NAME", objPath,
+ "INTF", threshold.value("CriticalLowDirection", ""));
+ }
+ }
+
+ criticalIface->setEntityPath(entityPath);
+ if (DEBUG)
+ {
+ debug("Sensor Threshold:{NAME} = path:{PATH}", "NAME", objPath,
+ "PATH", entityPath);
+ }
}
if (threshold.contains("WarningHigh") || threshold.contains("WarningLow"))
@@ -583,6 +617,34 @@
threshold.value("WarningHighHysteresis", defaultHysteresis));
warningIface->setLowHysteresis(
threshold.value("WarningLowHysteresis", defaultHysteresis));
+
+ if (threshold.contains("WarningHigh"))
+ {
+ warningIface->setEntityInterfaceHigh(
+ threshold.value("WarningHighDirection", ""));
+ if (DEBUG)
+ {
+ debug("Sensor Threshold:{NAME} = intf:{INTF}", "NAME", objPath,
+ "INTF", threshold.value("WarningHighDirection", ""));
+ }
+ }
+ if (threshold.contains("WarningLow"))
+ {
+ warningIface->setEntityInterfaceLow(
+ threshold.value("WarningLowDirection", ""));
+ if (DEBUG)
+ {
+ debug("Sensor Threshold:{NAME} = intf:{INTF}", "NAME", objPath,
+ "INTF", threshold.value("WarningLowDirection", ""));
+ }
+ }
+
+ warningIface->setEntityPath(entityPath);
+ if (DEBUG)
+ {
+ debug("Sensor Threshold:{NAME} = path:{PATH}", "NAME", objPath,
+ "PATH", entityPath);
+ }
}
if (threshold.contains("HardShutdownHigh") ||