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_manager.cpp b/src/trigger_manager.cpp
index 81a0398..da4797f 100644
--- a/src/trigger_manager.cpp
+++ b/src/trigger_manager.cpp
@@ -21,8 +21,8 @@
iface.register_method(
"AddTrigger",
[this](boost::asio::yield_context& yield,
- const std::string& name, bool isDiscrete,
- bool logToJournal, bool logToRedfish, bool updateReport,
+ const std::string& name,
+ const std::vector<std::string>& triggerActions,
const SensorsInfo& sensors,
const std::vector<std::string>& reportNames,
const TriggerThresholdParamsExt& thresholds) {
@@ -34,9 +34,8 @@
std::vector<LabeledSensorInfo> labeledSensorsInfo =
triggerFactory->getLabeledSensorsInfo(yield, sensors);
- return addTrigger(name, isDiscrete, logToJournal,
- logToRedfish, updateReport,
- labeledSensorsInfo, reportNames,
+ return addTrigger(name, triggerActions, labeledSensorsInfo,
+ reportNames,
labeledTriggerThresholdParams)
.getPath();
});
@@ -51,9 +50,7 @@
triggers.end());
}
-void TriggerManager::verifyAddTrigger(
- const std::string& triggerName, bool isDiscrete,
- const LabeledTriggerThresholdParams& thresholdParams)
+void TriggerManager::verifyAddTrigger(const std::string& triggerName)
{
if (triggers.size() >= maxTriggers)
{
@@ -73,18 +70,17 @@
}
interfaces::Trigger& TriggerManager::addTrigger(
- const std::string& triggerName, bool isDiscrete, bool logToJournal,
- bool logToRedfish, bool updateReport,
+ const std::string& triggerName,
+ const std::vector<std::string>& triggerActions,
const std::vector<LabeledSensorInfo>& labeledSensorsInfo,
const std::vector<std::string>& reportNames,
const LabeledTriggerThresholdParams& labeledThresholdParams)
{
- verifyAddTrigger(triggerName, isDiscrete, labeledThresholdParams);
+ verifyAddTrigger(triggerName);
triggers.emplace_back(triggerFactory->make(
- triggerName, isDiscrete, logToJournal, logToRedfish, updateReport,
- reportNames, *this, *triggerStorage, labeledThresholdParams,
- labeledSensorsInfo));
+ triggerName, triggerActions, reportNames, *this, *triggerStorage,
+ labeledThresholdParams, labeledSensorsInfo));
return *triggers.back();
}
@@ -111,10 +107,8 @@
const std::string& name = data->at("Name").get_ref<std::string&>();
int thresholdParamsDiscriminator =
data->at("ThresholdParamsDiscriminator").get<int>();
- bool isDiscrete = data->at("IsDiscrete").get<bool>();
- bool logToJournal = data->at("LogToJournal").get<bool>();
- bool logToRedfish = data->at("LogToRedfish").get<bool>();
- bool updateReport = data->at("UpdateReport").get<bool>();
+ const std::vector<std::string> triggerActions =
+ data->at("TriggerActions").get<std::vector<std::string>>();
LabeledTriggerThresholdParams labeledThresholdParams;
if (0 == thresholdParamsDiscriminator)
@@ -136,8 +130,7 @@
auto labeledSensorsInfo =
data->at("Sensors").get<std::vector<LabeledSensorInfo>>();
- addTrigger(name, isDiscrete, logToJournal, logToRedfish,
- updateReport, labeledSensorsInfo, reportNames,
+ addTrigger(name, triggerActions, labeledSensorsInfo, reportNames,
labeledThresholdParams);
}
catch (const std::exception& e)