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/thresholds.hpp b/thresholds.hpp
index 2e42938..63e1884 100644
--- a/thresholds.hpp
+++ b/thresholds.hpp
@@ -53,14 +53,32 @@
{
static constexpr auto name = "Warning";
using WarningObject::WarningObject;
+ /** @brief sdbusplus bus client connection. */
+ sdbusplus::bus::bus& bus;
+ std::string objPath;
+
+ /** @brief Virtual sensor path/interface in entityManagerDbus.
+ * This 3 value is used to set thresholds
+ */
+ std::string entityPath;
+ std::string entityInterfaceHigh;
+ std::string entityInterfaceLow;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ */
+ Threshold(sdbusplus::bus::bus& bus, const char* path) :
+ WarningObject(bus, path), bus(bus), objPath(std::string(path))
+ {}
auto high()
{
- return warningHigh();
+ return WarningObject::warningHigh();
}
auto low()
{
- return warningLow();
+ return WarningObject::warningLow();
}
template <typename... Args>
@@ -98,21 +116,82 @@
{
return warningLowAlarmDeasserted(std::forward<Args>(args)...);
}
+
+ /** @brief Set value of WarningHigh */
+ virtual double warningHigh(double value)
+ {
+ // persistThreshold
+ setDbusProperty(bus, entityManagerBusName, entityPath,
+ entityInterfaceHigh, "Value", value);
+ return WarningObject::warningHigh(value);
+ }
+
+ /** @brief Set value of WarningLow */
+ virtual double warningLow(double value)
+ {
+ // persistThreshold
+ setDbusProperty(bus, entityManagerBusName, entityPath,
+ entityInterfaceLow, "Value", value);
+ return WarningObject::warningLow(value);
+ }
+
+ /** @brief Set the entitymanager interface corresponding to virtualsensor
+ * warningLow
+ */
+ void setEntityInterfaceLow(const std::string& interfaceLow)
+ {
+ entityInterfaceLow = interfaceLow;
+ }
+
+ /** @brief Set the entitymanager interface corresponding to virtualsensor
+ * warningHigh
+ */
+ void setEntityInterfaceHigh(const std::string& interfaceHigh)
+ {
+ entityInterfaceHigh = interfaceHigh;
+ }
+
+ /** @brief Set the entitymanager path corresponding to virtualsensor warning
+ */
+ void setEntityPath(const std::string& path)
+ {
+ entityPath = path;
+ }
};
template <>
struct Threshold<CriticalObject> : public CriticalObject, public Hysteresis
{
static constexpr auto name = "Critical";
+
+ /** @brief sdbusplus bus client connection. */
+ sdbusplus::bus::bus& bus;
+ std::string objPath;
+
+ /** @brief Virtual sensor path/interface in entityManagerDbus.
+ * This 3 value is used to set thresholds
+ */
+ std::string entityPath;
+ std::string entityInterfaceHigh;
+ std::string entityInterfaceLow;
+
using CriticalObject::CriticalObject;
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ */
+ Threshold(sdbusplus::bus::bus& bus, const char* path) :
+ CriticalObject(bus, path), bus(bus), objPath(std::string(path))
+ {}
+
auto high()
{
- return criticalHigh();
+ return CriticalObject::criticalHigh();
}
auto low()
{
- return criticalLow();
+ return CriticalObject::criticalLow();
}
template <typename... Args>
@@ -150,6 +229,46 @@
{
return criticalLowAlarmDeasserted(std::forward<Args>(args)...);
}
+
+ /** @brief Set value of CriticalHigh */
+ virtual double criticalHigh(double value)
+ {
+ // persistThreshold
+ setDbusProperty(bus, entityManagerBusName, entityPath,
+ entityInterfaceHigh, "Value", value);
+ return CriticalObject::criticalHigh(value);
+ }
+
+ /** @brief Set value of CriticalLow */
+ virtual double criticalLow(double value)
+ {
+ setDbusProperty(bus, entityManagerBusName, entityPath,
+ entityInterfaceLow, "Value", value);
+ return CriticalObject::criticalLow(value);
+ }
+
+ /** @brief Set the entitymanager interface corresponding to virtualsensor
+ * criticalLow
+ */
+ void setEntityInterfaceLow(const std::string& interfaceLow)
+ {
+ entityInterfaceLow = interfaceLow;
+ }
+
+ /** @brief Set the entitymanager interface corresponding to virtualsensor
+ * criticalLow
+ */
+ void setEntityInterfaceHigh(const std::string& interfaceHigh)
+ {
+ entityInterfaceHigh = interfaceHigh;
+ }
+
+ /** @brief Set the entitymanager path corresponding to virtualsensor warning
+ */
+ void setEntityPath(const std::string& path)
+ {
+ entityPath = path;
+ }
};
template <>