Change discrete threshold value to string
For compliance with redfish schema, trigger with discrete
thresholds should use string as a value - instead of double.
This will impact dbus method "AddTrigger" for Trigger interface.
As there are currently no known sensors with discrete values,
telemetry service will still treat the value as a double internally.
Tested:
- UT passed.
- Trigger with discrete threshold value was successfully created
using dbus call.
- local redfish-tests for trigger persistency are passing after
type modification.
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I8201ce5e2a45647206c5ccd85fc45ea8f32961af
diff --git a/src/interfaces/trigger_types.hpp b/src/interfaces/trigger_types.hpp
index 568756f..6721e68 100644
--- a/src/interfaces/trigger_types.hpp
+++ b/src/interfaces/trigger_types.hpp
@@ -39,13 +39,13 @@
return std::string(utils::enumToString(details::convDataSeverity, v));
}
-using ThresholdParam = std::tuple<std::string, std::string, uint64_t, double>;
+using ThresholdParam =
+ std::tuple<std::string, std::string, uint64_t, std::string>;
-using LabeledThresholdParam =
- utils::LabeledTuple<std::tuple<std::string, Severity, uint64_t, double>,
- utils::tstring::UserId, utils::tstring::Severity,
- utils::tstring::DwellTime,
- utils::tstring::ThresholdValue>;
+using LabeledThresholdParam = utils::LabeledTuple<
+ std::tuple<std::string, Severity, uint64_t, std::string>,
+ utils::tstring::UserId, utils::tstring::Severity, utils::tstring::DwellTime,
+ utils::tstring::ThresholdValue>;
} // namespace discrete
namespace numeric
diff --git a/src/trigger_factory.cpp b/src/trigger_factory.cpp
index b491274..6e2ad21 100644
--- a/src/trigger_factory.cpp
+++ b/src/trigger_factory.cpp
@@ -47,7 +47,7 @@
labeledThresholdParam.at_label<ts::Severity>();
std::chrono::milliseconds dwellTime = std::chrono::milliseconds(
labeledThresholdParam.at_label<ts::DwellTime>());
- double thresholdValue =
+ std::string thresholdValue =
labeledThresholdParam.at_label<ts::ThresholdValue>();
if (logToJournal)
@@ -68,7 +68,7 @@
thresholds.emplace_back(std::make_shared<DiscreteThreshold>(
bus->get_io_context(), sensors, sensorNames, std::move(actions),
- std::chrono::milliseconds(dwellTime), thresholdValue,
+ std::chrono::milliseconds(dwellTime), std::stod(thresholdValue),
thresholdName));
}
if (labeledDiscreteThresholdParams.empty())