diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch')
-rw-r--r-- | meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch deleted file mode 100644 index c6c6a8f09..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch +++ /dev/null @@ -1,171 +0,0 @@ -From d206ea5049057fe4842186777231b9eb8468ec86 Mon Sep 17 00:00:00 2001 -From: Krzysztof Grobelny <krzysztof.grobelny@intel.com> -Date: Mon, 8 Jun 2020 15:16:10 +0200 -Subject: [PATCH 08/10] Add support for "OnRequest" in MetricReportDefinition - -Added support for "OnRequest" of ReportingType property in -MetricReportDefinition node. Now user is able to create -MetricReportDefinition that is updated on every GET request -on MetricReport. - -Tested: - - Succesfully passed RedfishServiceValidator.py - - Manually tested via curl - -Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> -Change-Id: I1cdfe47e56fdc5ec9753558145d0bf3645160aaf - -%% original patch: 0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch ---- - include/dbus_utility.hpp | 30 +++++++++++++++ - redfish-core/include/utils/telemetry_utils.hpp | 8 ++-- - redfish-core/lib/metric_report.hpp | 53 +++++++++++++++++++++++++- - 3 files changed, 87 insertions(+), 4 deletions(-) - -diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp -index ef3438b..80f8bcd 100644 ---- a/include/dbus_utility.hpp -+++ b/include/dbus_utility.hpp -@@ -18,6 +18,7 @@ - #include <sdbusplus/message.hpp> - - #include <filesystem> -+#include <functional> - #include <regex> - - namespace dbus -@@ -120,5 +121,34 @@ inline void getAllProperties(Callback&& callback, const std::string& service, - interface); - } - -+template <typename T> -+static void getProperty( -+ std::function<void(const boost::system::error_code&, const T&)> callback, -+ const std::string& service, const std::string& path, -+ const std::string& interface, const std::string& property) -+{ -+ crow::connections::systemBus->async_method_call( -+ [callback](const boost::system::error_code ec, -+ const std::variant<T>& value) { -+ if (ec) -+ { -+ callback(ec, T{}); -+ return; -+ } -+ -+ if (auto v = std::get_if<T>(&value)) -+ { -+ callback(ec, *v); -+ return; -+ } -+ -+ callback(boost::system::errc::make_error_code( -+ boost::system::errc::io_error), -+ T{}); -+ }, -+ service, path, "org.freedesktop.DBus.Properties", "Get", interface, -+ property); -+} -+ - } // namespace utility - } // namespace dbus -diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp -index 05ed00f..6c4e810 100644 ---- a/redfish-core/include/utils/telemetry_utils.hpp -+++ b/redfish-core/include/utils/telemetry_utils.hpp -@@ -26,6 +26,8 @@ static constexpr const char* metricReportDefinitionUri = - "/redfish/v1/TelemetryService/MetricReportDefinitions/"; - static constexpr const char* metricReportUri = - "/redfish/v1/TelemetryService/MetricReports/"; -+static constexpr const char* monitoringService = -+ "xyz.openbmc_project.MonitoringService"; - static constexpr const char* reportInterface = - "xyz.openbmc_project.MonitoringService.Report"; - static constexpr const char* telemetryPath = -@@ -66,9 +68,9 @@ static void getReport(const std::shared_ptr<AsyncResp>& asyncResp, - const std::array<const char*, 1> interfaces = {reportInterface}; - - dbus::utility::getSubTreePaths( -- [asyncResp, id, schemaType, -- callback](const boost::system::error_code ec, -- const std::vector<std::string>& reports) { -+ [asyncResp, id, schemaType, callback = std::move(callback)]( -+ const boost::system::error_code ec, -+ const std::vector<std::string>& reports) { - if (ec == boost::system::errc::no_such_file_or_directory) - { - messages::resourceNotFound(asyncResp->res, schemaType, id); -diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp -index 4d1c4e5..768cce9 100644 ---- a/redfish-core/lib/metric_report.hpp -+++ b/redfish-core/lib/metric_report.hpp -@@ -85,7 +85,7 @@ class MetricReport : public Node - } - - const std::string& id = params[0]; -- telemetry::getReport(asyncResp, id, schemaType, getReportProperties); -+ telemetry::getReport(asyncResp, id, schemaType, updateReportIfRequired); - } - - using Readings = -@@ -143,6 +143,57 @@ class MetricReport : public Node - "xyz.openbmc_project.MonitoringService.Report"); - } - -+ template <typename Callback> -+ static void updateReport(Callback&& callback, -+ const std::shared_ptr<AsyncResp>& asyncResp, -+ const std::string& path) -+ { -+ crow::connections::systemBus->async_method_call( -+ [asyncResp, callback{std::move(callback)}]( -+ const boost::system::error_code& ec) { -+ if (ec) -+ { -+ messages::internalError(asyncResp->res); -+ return; -+ } -+ -+ callback(); -+ }, -+ telemetry::monitoringService, path, telemetry::reportInterface, -+ "Update"); -+ } -+ -+ static void -+ updateReportIfRequired(const std::shared_ptr<AsyncResp> asyncResp, -+ const std::string& reportPath, -+ const std::string& id) -+ { -+ dbus::utility::getProperty<std::string>( -+ [asyncResp, id, reportPath](const boost::system::error_code& ec, -+ const std::string& reportingType) { -+ if (ec) -+ { -+ messages::internalError(asyncResp->res); -+ return; -+ } -+ -+ if (reportingType == "OnRequest") -+ { -+ updateReport( -+ [asyncResp, reportPath, id] { -+ getReportProperties(asyncResp, reportPath, id); -+ }, -+ asyncResp, reportPath); -+ } -+ else -+ { -+ getReportProperties(asyncResp, reportPath, id); -+ } -+ }, -+ telemetry::monitoringService, reportPath, -+ telemetry::reportInterface, "ReportingType"); -+ } -+ - static constexpr const char* schemaType = - "#MetricReport.v1_3_0.MetricReport"; - }; --- -2.16.6 - |