Modify Trigger dbus api
'AddTrigger' method is now using array of strings for actions instead
of boolean flags. The action names are following:
- 'UpdateReport' (same as old flag)
- 'LogToLogService' (old 'LogToJournal' flag)
- 'RedfishEvent' (old 'LogToRedfish' flag)
Additionally, isDiscrete flag was removed from 'AddTrigger' call, as
this value can be extracted depending on threshold.
As a result new 'AddTrigger" signature is: "sasa{os}asv"
Example call parameters:
- TestTrigger 1 UpdateReport 0 0 "a(stsd)" 1 LowerWarning 1000
Either 42.7'
- TestTrigger 2 UpdateReport RedfishEvent 0 0 "a(ssts)" 1 userId_1
Warning 10 15.2'
'Trigger' properties were also modified. Instead of action bool
properties (same as mentioned above), new property was introduced
'TriggerActions' - which has same values as those used in 'AddTrigger'
method. This also affects persistence: store/load functionality was
modified accordingly.
As a side change - isDiscrete is no longer stored, as this can be easily
recreated in the runtime.
Tested:
- Trigger was successfully created using dbus.
- busctl introspect was called on test trigger and properties are
modified and working as intended.
- persistency mechanic is working propetly.
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: Icd64d4032fd6d446d9b6ad248e28e9031af1fed7
diff --git a/src/trigger.cpp b/src/trigger.cpp
index d6ee3be..92e1472 100644
--- a/src/trigger.cpp
+++ b/src/trigger.cpp
@@ -10,19 +10,16 @@
Trigger::Trigger(
boost::asio::io_context& ioc,
const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
- const std::string& nameIn, const bool isDiscreteIn,
- const bool logToJournalIn, const bool logToRedfishIn,
- const bool updateReportIn, const std::vector<std::string>& reportNamesIn,
+ const std::string& nameIn, const std::vector<std::string>& triggerActionsIn,
+ const std::vector<std::string>& reportNamesIn,
const std::vector<LabeledSensorInfo>& LabeledSensorsInfoIn,
const LabeledTriggerThresholdParams& labeledThresholdParamsIn,
std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholdsIn,
interfaces::TriggerManager& triggerManager,
interfaces::JsonStorage& triggerStorageIn) :
name(nameIn),
- isDiscrete(isDiscreteIn), logToJournal(logToJournalIn),
- logToRedfish(logToRedfishIn), updateReport(updateReportIn),
- path(triggerDir + name), reportNames(reportNamesIn),
- labeledSensorsInfo(LabeledSensorsInfoIn),
+ triggerActions(std::move(triggerActionsIn)), path(triggerDir + name),
+ reportNames(reportNamesIn), labeledSensorsInfo(LabeledSensorsInfoIn),
labeledThresholdParams(labeledThresholdParamsIn),
thresholds(std::move(thresholdsIn)),
fileName(std::to_string(std::hash<std::string>{}(name))),
@@ -42,9 +39,7 @@
});
triggerIface = objServer->add_unique_interface(
- path, triggerIfaceName,
- [this, isDiscreteIn, logToJournalIn, logToRedfishIn,
- updateReportIn](auto& dbusIface) {
+ path, triggerIfaceName, [this](auto& dbusIface) {
persistent = storeConfiguration();
dbusIface.register_property_rw(
"Persistent", persistent,
@@ -84,22 +79,19 @@
});
dbusIface.register_property_r(
-
"ReportNames", reportNames,
sdbusplus::vtable::property_::emits_change,
[](const auto& x) { return x; });
- dbusIface.register_property_r("Discrete", isDiscrete,
+
+ dbusIface.register_property_r(
+ "Discrete", false, sdbusplus::vtable::property_::const_,
+ [this](const auto& x) {
+ return isTriggerThresholdDiscrete(labeledThresholdParams);
+ });
+
+ dbusIface.register_property_r("TriggerActions", triggerActions,
sdbusplus::vtable::property_::const_,
- [](const auto& x) { return x; });
- dbusIface.register_property_r("LogToJournal", logToJournal,
- sdbusplus::vtable::property_::const_,
- [](const auto& x) { return x; });
- dbusIface.register_property_r("LogToRedfish", logToRedfish,
- sdbusplus::vtable::property_::const_,
- [](const auto& x) { return x; });
- dbusIface.register_property_r("UpdateReport", updateReport,
- sdbusplus::vtable::property_::const_,
- [](const auto& x) { return x; });
+ [this](const auto& x) { return x; });
});
for (const auto& threshold : thresholds)
@@ -117,10 +109,7 @@
data["Version"] = triggerVersion;
data["Name"] = name;
data["ThresholdParamsDiscriminator"] = labeledThresholdParams.index();
- data["IsDiscrete"] = labeledThresholdParams.index() == 1;
- data["LogToJournal"] = logToJournal;
- data["LogToRedfish"] = logToRedfish;
- data["UpdateReport"] = updateReport;
+ data["TriggerActions"] = triggerActions;
data["ThresholdParams"] =
utils::labeledThresholdParamsToJson(labeledThresholdParams);
data["ReportNames"] = reportNames;