Save persistent triggers to storage
Create json storage file for persistent triggers.
Handle persistent dbus property.
Save/remove persistent triggers on add/delete.
Cover code with UTs.
Tested:
- Passed unit tests
- Tested on QEMU
* adding new valid and invalid trigger from cli
* verifying if valid trigger is properly stored
* deleting existed trigger from storage
Change-Id: I243326e84833a8cb22075fbf565573b62b205b4a
Signed-off-by: Cezary Zwolak <cezary.zwolak@intel.com>
Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
diff --git a/src/interfaces/trigger_factory.hpp b/src/interfaces/trigger_factory.hpp
index 7d448d0..d493b4a 100644
--- a/src/interfaces/trigger_factory.hpp
+++ b/src/interfaces/trigger_factory.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "interfaces/json_storage.hpp"
#include "interfaces/trigger.hpp"
#include "interfaces/trigger_manager.hpp"
#include "interfaces/trigger_types.hpp"
@@ -26,7 +27,8 @@
std::pair<sdbusplus::message::object_path, std::string>>& sensors,
const std::vector<std::string>& reportNames,
const TriggerThresholdParams& thresholdParams,
- interfaces::TriggerManager& triggerManager) const = 0;
+ interfaces::TriggerManager& triggerManager,
+ interfaces::JsonStorage& triggerStorage) const = 0;
};
} // namespace interfaces
diff --git a/src/interfaces/trigger_types.hpp b/src/interfaces/trigger_types.hpp
index 90c673d..1833171 100644
--- a/src/interfaces/trigger_types.hpp
+++ b/src/interfaces/trigger_types.hpp
@@ -1,6 +1,8 @@
#pragma once
#include "utils/conversion.hpp"
+#include "utils/labeled_tuple.hpp"
+#include "utils/tstring.hpp"
#include <string>
#include <tuple>
@@ -38,6 +40,12 @@
}
using ThresholdParam = std::tuple<std::string, std::string, uint64_t, double>;
+
+using LabeledThresholdParam =
+ utils::LabeledTuple<std::tuple<std::string, Severity, uint64_t, double>,
+ utils::tstring::UserId, utils::tstring::Severity,
+ utils::tstring::DwellTime,
+ utils::tstring::ThresholdValue>;
} // namespace discrete
namespace numeric
@@ -95,8 +103,22 @@
}
using ThresholdParam = std::tuple<std::string, uint64_t, std::string, double>;
+
+using LabeledThresholdParam =
+ utils::LabeledTuple<std::tuple<Type, uint64_t, Direction, double>,
+ utils::tstring::Type, utils::tstring::DwellTime,
+ utils::tstring::Direction,
+ utils::tstring::ThresholdValue>;
} // namespace numeric
+using TriggerSensors =
+ std::vector<std::pair<sdbusplus::message::object_path, std::string>>;
+
+using LabeledTriggerSensor =
+ utils::LabeledTuple<std::tuple<std::string, std::string>,
+ utils::tstring::SensorPath,
+ utils::tstring::SensorMetadata>;
+
using TriggerThresholdParams =
std::variant<std::vector<numeric::ThresholdParam>,
std::vector<discrete::ThresholdParam>>;
diff --git a/src/interfaces/types.hpp b/src/interfaces/types.hpp
index a5ed0db..a3a1b1c 100644
--- a/src/interfaces/types.hpp
+++ b/src/interfaces/types.hpp
@@ -28,4 +28,4 @@
using Readings = std::tuple<
uint64_t,
- std::vector<std::tuple<std::string, std::string, double, uint64_t>>>;
+ std::vector<std::tuple<std::string, std::string, double, uint64_t>>>;
\ No newline at end of file