Use proper dbus path when possible.
Following methods and properties were updated to use full dbus path,
instead of internal telemetry id:
- TriggerManager.AddTrigger() - 'reportIds' arg
- Trigger.ReportIds - renamed to 'Reports'
- Report.TriggerIds - renamed to 'Triggers'
Testing done:
- UTs were updated and are passing.
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I78d812d38289fac575d25b48503cc8b9c6f736fe
diff --git a/src/trigger.cpp b/src/trigger.cpp
index ab48281..c0935c3 100644
--- a/src/trigger.cpp
+++ b/src/trigger.cpp
@@ -7,6 +7,7 @@
#include "types/trigger_types.hpp"
#include "utils/contains.hpp"
#include "utils/conversion_trigger.hpp"
+#include "utils/dbus_path_utils.hpp"
#include "utils/transform.hpp"
#include <phosphor-logging/log.hpp>
@@ -22,9 +23,9 @@
interfaces::JsonStorage& triggerStorageIn,
const interfaces::TriggerFactory& triggerFactory, Sensors sensorsIn) :
id(std::move(idIn)),
+ path(utils::pathAppend(utils::constants::triggerDirPath, *id)),
name(nameIn), triggerActions(std::move(triggerActionsIn)),
- path(triggerDir + *id), reportIds(std::move(reportIdsIn)),
- thresholds(std::move(thresholdsIn)),
+ reportIds(std::move(reportIdsIn)), thresholds(std::move(thresholdsIn)),
fileName(std::to_string(std::hash<std::string>{}(*id))),
triggerStorage(triggerStorageIn), sensors(std::move(sensorsIn)),
messanger(ioc)
@@ -104,17 +105,27 @@
});
dbusIface.register_property_rw(
- "ReportNames", *reportIds,
+ "Reports", std::vector<sdbusplus::message::object_path>(),
sdbusplus::vtable::property_::emits_change,
[this](auto newVal, auto& oldVal) {
- TriggerManager::verifyReportIds(newVal);
- *reportIds = newVal;
+ auto newReportIds = utils::transform<std::vector>(
+ newVal, [](const auto& path) {
+ return utils::reportPathToId(path);
+ });
+ TriggerManager::verifyReportIds(newReportIds);
+ *reportIds = newReportIds;
messanger.send(messages::TriggerPresenceChangedInd{
messages::Presence::Exist, *id, *reportIds});
oldVal = std::move(newVal);
return 1;
},
- [this](const auto&) { return *reportIds; });
+ [this](const auto&) {
+ return utils::transform<std::vector>(
+ *reportIds, [](const auto& id) {
+ return utils::pathAppend(
+ utils::constants::reportDirPath, id);
+ });
+ });
dbusIface.register_property_r(
"Discrete", isDiscreate(), sdbusplus::vtable::property_::const_,