summaryrefslogtreecommitdiff
path: root/redfish-core/include/utils
diff options
context:
space:
mode:
authorKrzysztof Grobelny <krzysztof.grobelny@intel.com>2021-06-17 16:37:57 +0300
committerEd Tanous <ed@tanous.net>2023-05-23 02:27:07 +0300
commit479e899d5f57a67647f83b7f615d2c8565290bcf (patch)
tree37ac639250ce686746c3d748e52fcc8fb5556db3 /redfish-core/include/utils
parent2c5875a20e5f7f38fac74c1850e2283e4195ff57 (diff)
downloadbmcweb-479e899d5f57a67647f83b7f615d2c8565290bcf.tar.xz
Switched bmcweb to use new telemetry service API
Added support for multiple MetricProperties. Added support for new parameters: CollectionTimeScope, CollectionDuration. ReadingParameters was not yet changed in telemetry backend, instead temporary property ReadingParametersFutureVersion was introduced. Once bmcweb is adapted to use ReadingParametersFutureVersion this property will be renamed in backend to ReadingParameters. Then bmcweb will change to use ReadingParameters. Then ReadingParametersFutureVersion will be removed from backend and everything will be exactly like described in phosphor-dbus-interfaces without introducing breaking changes. Related change in phosphor-dbus-interfaces [1], [2]. This change needs to be bumped together with [3]. Tested: - It is possible to create MetricReportDefinitions with multiple MetricProperties. - Stub values for new parameters are correctly passed to telemetry service. - All existing telemetry service functionalities remain unchanged. [1]: https://github.com/openbmc/phosphor-dbus-interfaces/commit/4f9c09144b60edc015291d2c120fc5b33aa0bec2 [2]: https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/60750 [3]: https://gerrit.openbmc.org/c/openbmc/telemetry/+/58229 Change-Id: I2cd17069e3ea015c8f5571c29278f1d50536272a Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
Diffstat (limited to 'redfish-core/include/utils')
-rw-r--r--redfish-core/include/utils/json_utils.hpp1
-rw-r--r--redfish-core/include/utils/telemetry_utils.hpp72
2 files changed, 71 insertions, 2 deletions
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 774ab7c5eb..fa49d3fc04 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -589,6 +589,5 @@ bool readJsonAction(const crow::Request& req, crow::Response& res,
}
return readJson(jsonRequest, res, key, std::forward<UnpackTypes&&>(in)...);
}
-
} // namespace json_util
} // namespace redfish
diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
index f5f9360a14..fc045f6742 100644
--- a/redfish-core/include/utils/telemetry_utils.hpp
+++ b/redfish-core/include/utils/telemetry_utils.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "dbus_utility.hpp"
+#include "generated/enums/metric_report_definition.hpp"
#include "http/utility.hpp"
#include "logging.hpp"
#include "utility.hpp"
@@ -40,7 +41,7 @@ struct IncorrectMetricUri
};
inline std::optional<IncorrectMetricUri> getChassisSensorNode(
- const std::vector<std::string>& uris,
+ std::span<const std::string> uris,
boost::container::flat_set<std::pair<std::string, std::string>>& matched)
{
size_t uriIdx = 0;
@@ -89,5 +90,74 @@ inline std::optional<IncorrectMetricUri> getChassisSensorNode(
return std::nullopt;
}
+inline metric_report_definition::CalculationAlgorithmEnum
+ toRedfishCollectionFunction(std::string_view dbusValue)
+{
+ if (dbusValue ==
+ "xyz.openbmc_project.Telemetry.Report.OperationType.Maximum")
+ {
+ return metric_report_definition::CalculationAlgorithmEnum::Maximum;
+ }
+ if (dbusValue ==
+ "xyz.openbmc_project.Telemetry.Report.OperationType.Minimum")
+ {
+ return metric_report_definition::CalculationAlgorithmEnum::Minimum;
+ }
+ if (dbusValue ==
+ "xyz.openbmc_project.Telemetry.Report.OperationType.Average")
+ {
+ return metric_report_definition::CalculationAlgorithmEnum::Average;
+ }
+ if (dbusValue ==
+ "xyz.openbmc_project.Telemetry.Report.OperationType.Summation")
+ {
+ return metric_report_definition::CalculationAlgorithmEnum::Summation;
+ }
+ return metric_report_definition::CalculationAlgorithmEnum::Invalid;
+}
+
+inline std::string toDbusCollectionFunction(std::string_view redfishValue)
+{
+ if (redfishValue == "Maximum")
+ {
+ return "xyz.openbmc_project.Telemetry.Report.OperationType.Maximum";
+ }
+ if (redfishValue == "Minimum")
+ {
+ return "xyz.openbmc_project.Telemetry.Report.OperationType.Minimum";
+ }
+ if (redfishValue == "Average")
+ {
+ return "xyz.openbmc_project.Telemetry.Report.OperationType.Average";
+ }
+ if (redfishValue == "Summation")
+ {
+ return "xyz.openbmc_project.Telemetry.Report.OperationType.Summation";
+ }
+ return "";
+}
+
+inline std::optional<nlohmann::json::array_t>
+ toRedfishCollectionFunctions(std::span<const std::string> dbusEnums)
+{
+ nlohmann::json::array_t redfishEnums;
+ redfishEnums.reserve(dbusEnums.size());
+
+ for (const auto& dbusValue : dbusEnums)
+ {
+ metric_report_definition::CalculationAlgorithmEnum redfishValue =
+ toRedfishCollectionFunction(dbusValue);
+
+ if (redfishValue ==
+ metric_report_definition::CalculationAlgorithmEnum::Invalid)
+ {
+ return std::nullopt;
+ }
+
+ redfishEnums.emplace_back(redfishValue);
+ }
+ return redfishEnums;
+}
+
} // namespace telemetry
} // namespace redfish