diff options
author | jmbills <42755197+jmbills@users.noreply.github.com> | 2020-09-08 23:40:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 23:40:52 +0300 |
commit | c16fb8893b19075db4bcf3b5bf33c1db8c3ca2bd (patch) | |
tree | ca75379d317be9cc1757a00e0352a048b5d3200b /meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch | |
parent | d81f2708c4462a62e3b5e8d08643eb2b8895dde7 (diff) | |
parent | f99301c1a626951ee7feee081a1494e795d0e243 (diff) | |
download | openbmc-c16fb8893b19075db4bcf3b5bf33c1db8c3ca2bd.tar.xz |
Merge pull request #47 from Intel-BMC/update
Update to internal 0.74
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 | 169 |
1 files changed, 169 insertions, 0 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 new file mode 100644 index 000000000..e996ac585 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-OnRequest-in-MetricReportDefinition.patch @@ -0,0 +1,169 @@ +From 9fc7d722b3192df9940062185b40ebb0fabad518 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 4/5] 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 +--- + 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 3df88d8..029d8d8 100644 +--- a/include/dbus_utility.hpp ++++ b/include/dbus_utility.hpp +@@ -17,6 +17,7 @@ + + #include <sdbusplus/message.hpp> + ++#include <functional> + #include <regex> + + namespace dbus +@@ -130,5 +131,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 a52d680..877e7f1 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 + |