diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0007-Generalize-ReadingType-in-MetricDefinition.patch')
-rw-r--r-- | meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0007-Generalize-ReadingType-in-MetricDefinition.patch | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0007-Generalize-ReadingType-in-MetricDefinition.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0007-Generalize-ReadingType-in-MetricDefinition.patch deleted file mode 100644 index 1cdd59d4b..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0007-Generalize-ReadingType-in-MetricDefinition.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 872a7bdb9c272944914d7c5babc751e6bb33afec Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Adrian=20Ambro=C5=BCewicz?= <adrian.ambrozewicz@intel.com> -Date: Tue, 3 Aug 2021 13:59:31 +0200 -Subject: [PATCH] Generalize ReadingType in MetricDefinition - -Recent addition of PMT required adding new type of sensor 'count', which -doesnt comply with any of Redfish-defined Sensor.ReadingType values. - -To support property of this kind MetricDefinition implementation was -altered to support sensor types not covered by Redfish types by -a 'fallback' to direct usage of sensor type. Populating 'Units' was also -modified, so it won't be shown if value does not have any units mapped. - -Testing: -- PMT counters are shown properly in MetricDefinitions/Count -- Redfish Validator passes ---- - redfish-core/lib/metric_definition.hpp | 63 ++++++++++++++++---------- - 1 file changed, 39 insertions(+), 24 deletions(-) - -diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp -index 2443996..fcab44d 100644 ---- a/redfish-core/lib/metric_definition.hpp -+++ b/redfish-core/lib/metric_definition.hpp -@@ -11,6 +11,18 @@ namespace redfish - namespace telemetry - { - -+std::string groupName(const std::string& sensorType) -+{ -+ std::string group = sensors::toReadingType(sensorType); -+ if (group.empty()) -+ { -+ // Fallback for types not covered by standard Redfish Sensor.ReadingType -+ group = sensorType; -+ group[0] = static_cast<char>(std::toupper(group[0])); -+ } -+ return group; -+} -+ - void addMembers(crow::Response& res, - const boost::container::flat_map<std::string, std::string>& el) - { -@@ -30,8 +42,7 @@ void addMembers(crow::Response& res, - nlohmann::json& members = res.jsonValue["Members"]; - - const std::string odataId = -- std::string(telemetry::metricDefinitionUri) + -- sensors::toReadingType(type); -+ std::string(telemetry::metricDefinitionUri) + groupName(type); - - const auto it = std::find_if(members.begin(), members.end(), - [&odataId](const nlohmann::json& item) { -@@ -125,15 +136,15 @@ inline void requestRoutesMetricDefinitionCollection(App& app) - namespace telemetry - { - --bool isSensorIdSupported(std::string_view readingType) -+bool isSensorIdSupported(std::string_view group) - { - for (const std::pair<std::string_view, std::vector<const char*>>& - typeToPaths : sensors::dbus::paths) - { - for (const char* supportedPath : typeToPaths.second) - { -- if (readingType == -- sensors::toReadingType( -+ if (group == -+ groupName( - sdbusplus::message::object_path(supportedPath).filename())) - { - return true; -@@ -144,7 +155,7 @@ bool isSensorIdSupported(std::string_view readingType) - } - - void addMetricProperty( -- bmcweb::AsyncResp& asyncResp, const std::string& readingType, -+ bmcweb::AsyncResp& asyncResp, const std::string& group, - const boost::container::flat_map<std::string, std::string>& el) - { - nlohmann::json& metricProperties = -@@ -155,7 +166,7 @@ void addMetricProperty( - std::string sensorId; - if (dbus::utility::getNthStringFromPath(dbusSensor, 3, sensorId)) - { -- if (sensors::toReadingType(sensorId) == readingType) -+ if (groupName(sensorId) == group) - { - metricProperties.push_back(redfishSensor); - } -@@ -172,33 +183,37 @@ inline void requestRoutesMetricDefinition(App& app) - .methods(boost::beast::http::verb::get)( - [](const crow::Request&, - const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, -- const std::string& readingType) { -- if (!telemetry::isSensorIdSupported(readingType)) -+ const std::string& group) { -+ if (!telemetry::isSensorIdSupported(group)) - { - messages::resourceNotFound(asyncResp->res, -- "MetricDefinition", readingType); -+ "MetricDefinition", group); - return; - } - - asyncResp->res.jsonValue["MetricProperties"] = - nlohmann::json::array(); -- asyncResp->res.jsonValue["Id"] = readingType; -- asyncResp->res.jsonValue["Name"] = readingType; -+ asyncResp->res.jsonValue["Id"] = group; -+ asyncResp->res.jsonValue["Name"] = group; - asyncResp->res.jsonValue["@odata.id"] = -- telemetry::metricDefinitionUri + readingType; -+ telemetry::metricDefinitionUri + group; - asyncResp->res.jsonValue["@odata.type"] = - "#MetricDefinition.v1_0_3.MetricDefinition"; - asyncResp->res.jsonValue["MetricDataType"] = "Decimal"; - asyncResp->res.jsonValue["MetricType"] = "Numeric"; - asyncResp->res.jsonValue["IsLinear"] = true; - asyncResp->res.jsonValue["Implementation"] = "PhysicalSensor"; -- asyncResp->res.jsonValue["Units"] = -- sensors::toReadingUnits(readingType); -+ -+ std::string readingUnits = sensors::toReadingUnits(group); -+ if (!readingUnits.empty()) -+ { -+ asyncResp->res.jsonValue["Units"] = readingUnits; -+ } - - utils::getChassisNames( -- [asyncResp, readingType]( -- boost::system::error_code ec, -- const std::vector<std::string>& chassisNames) { -+ [asyncResp, -+ group](boost::system::error_code ec, -+ const std::vector<std::string>& chassisNames) { - if (ec) - { - messages::internalError(asyncResp->res); -@@ -208,10 +223,10 @@ inline void requestRoutesMetricDefinition(App& app) - } - - auto handleRetrieveUriToDbusMap = -- [asyncResp, readingType]( -- const boost::beast::http::status status, -- const boost::container::flat_map< -- std::string, std::string>& uriToDbus) { -+ [asyncResp, -+ group](const boost::beast::http::status status, -+ const boost::container::flat_map< -+ std::string, std::string>& uriToDbus) { - if (status != boost::beast::http::status::ok) - { - BMCWEB_LOG_ERROR -@@ -221,8 +236,8 @@ inline void requestRoutesMetricDefinition(App& app) - messages::internalError(asyncResp->res); - return; - } -- telemetry::addMetricProperty( -- *asyncResp, readingType, uriToDbus); -+ telemetry::addMetricProperty(*asyncResp, group, -+ uriToDbus); - }; - - for (const std::string& chassisName : chassisNames) --- -2.25.1 - |