summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch489
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch9
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch2
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch21
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch22
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch93
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README8
7 files changed, 338 insertions, 306 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch
index c19691cdc..f5226fe6e 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch
@@ -1,4 +1,4 @@
-From 80608f0d72da62426bb00e03a42fbf5daed931c9 Mon Sep 17 00:00:00 2001
+From 32e557279450226ed9c06312649d90b802f3d4c5 Mon Sep 17 00:00:00 2001
From: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Date: Tue, 13 Apr 2021 13:00:18 +0000
Subject: [PATCH] Add support for MetricDefinition scheme
@@ -11,10 +11,11 @@ MetricDefinitions contains all physical sensors supported by redfish,
algorithm iterates through all chassis and collects results for each
node available in that chassis (Power, Thermal, Sensors).
-When https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/40169 will
-be merge it will be possible to optimize this algorithm to only get
-sensors from Sensors node. Currently Sensors node doesn't contain all
-available sensors.
+When BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM will be enabled by
+default (meson option redfish-new-powersubsystem-thermalsubsystem) it
+will be possible to optimize this algorithm to only get sensors from
+Sensors node. Currently Sensors node doesn't contain all available
+sensors.
Tested:
- MetricDefinitions response is filled with existing sensors, it works
@@ -30,47 +31,54 @@ GET /redfish/v1/TelemetryService/MetricDefinitions
"@odata.type": "#MetricDefinitionCollection.MetricDefinitionCollection",
"Members": [
{
- "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Rotational"
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Pwm"
},
{
- "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Percent"
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach"
},
{
- "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Temperature"
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostCpuUtilization"
},
{
- "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Power"
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostMemoryBandwidthUtilization"
},
{
- "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/AirFlow"
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostPciBandwidthUtilization"
+ },
+ {
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Inlet_BRD_Temp"
+ },
+ {
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Left_Rear_Board_Temp"
}
],
- "Members@odata.count": 5,
+ "Members@odata.count": 7,
"Name": "Metric Definition Collection"
}
-GET /redfish/v1/TelemetryService/MetricDefinitions/Rotational
+GET /redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach
{
- "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Rotational",
+ "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach",
"@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition",
- "Id": "Rotational",
- "Implementation": "PhysicalSensor",
+ "Id": "Fan_Tach",
"IsLinear": true,
+ "MaxReadingRange": 25000.0,
"MetricDataType": "Decimal",
"MetricProperties": [
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/0/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/1/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/2/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/3/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/4/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/5/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/6/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/7/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/8/Reading",
- "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/9/Reading"
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/0/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/1/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/2/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/3/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/4/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/5/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/6/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/7/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/8/Reading",
+ "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/9/Reading"
],
- "MetricType": "Numeric",
- "Name": "Rotational",
+ "MetricType": "Gauge",
+ "MinReadingRange": 0.0,
+ "Name": "Fan_Tach",
"Units": "RPM"
}
@@ -109,16 +117,16 @@ Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I3086e1302e1ba2e5442d1367939fd5507a0cbc00
---
redfish-core/include/redfish.hpp | 3 +
- .../include/utils/get_chassis_names.hpp | 58 ++++
+ .../include/utils/get_chassis_names.hpp | 58 +++
.../include/utils/telemetry_utils.hpp | 2 +
- redfish-core/lib/metric_definition.hpp | 258 ++++++++++++++++++
- redfish-core/lib/telemetry_service.hpp | 2 +
- 5 files changed, 323 insertions(+)
+ redfish-core/lib/metric_definition.hpp | 368 ++++++++++++++++++
+ redfish-core/lib/telemetry_service.hpp | 3 +-
+ 5 files changed, 433 insertions(+), 1 deletion(-)
create mode 100644 redfish-core/include/utils/get_chassis_names.hpp
create mode 100644 redfish-core/lib/metric_definition.hpp
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
-index 1c7b695..9983b88 100644
+index 0a97150..67c5af2 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -26,6 +26,7 @@
@@ -129,7 +137,7 @@ index 1c7b695..9983b88 100644
#include "../lib/metric_report.hpp"
#include "../lib/metric_report_definition.hpp"
#include "../lib/network_protocol.hpp"
-@@ -199,6 +200,8 @@ class RedfishService
+@@ -200,6 +201,8 @@ class RedfishService
requestRoutesMetricReportDefinition(app);
requestRoutesMetricReportCollection(app);
requestRoutesMetricReport(app);
@@ -217,10 +225,10 @@ index 5872350..1b4f75d 100644
constexpr const char* metricReportUri =
diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp
new file mode 100644
-index 0000000..019168b
+index 0000000..347c297
--- /dev/null
+++ b/redfish-core/lib/metric_definition.hpp
-@@ -0,0 +1,258 @@
+@@ -0,0 +1,368 @@
+#pragma once
+
+#include "async_resp.hpp"
@@ -236,55 +244,160 @@ index 0000000..019168b
+namespace telemetry
+{
+
-+bool containsOdata(const nlohmann::json& json, const std::string& odataId)
++struct ValueVisitor
+{
-+ const auto it = std::find_if(
-+ json.begin(), json.end(), [&odataId](const nlohmann::json& item) {
-+ auto kt = item.find("@odata.id");
-+ if (kt == item.end())
++ ValueVisitor(boost::system::error_code& ec) : ec(ec)
++ {}
++
++ template <class T>
++ double operator()(T value) const
++ {
++ return static_cast<double>(value);
++ }
++
++ double operator()(std::monostate) const
++ {
++ ec = boost::system::errc::make_error_code(
++ boost::system::errc::invalid_argument);
++ return double{};
++ }
++
++ boost::system::error_code& ec;
++};
++
++inline void getReadingRange(
++ const std::string& service, const std::string& path,
++ const std::string& property,
++ std::function<void(boost::system::error_code, double)> callback)
++{
++ crow::connections::systemBus->async_method_call(
++ [callback = std::move(callback)](
++ boost::system::error_code ec,
++ const std::variant<std::monostate, double, uint64_t, int64_t,
++ uint32_t, int32_t, uint16_t, int16_t>&
++ valueVariant) {
++ if (ec)
+ {
-+ return false;
++ callback(ec, double{});
++ return;
+ }
-+ const std::string* value = kt->get_ptr<const std::string*>();
-+ if (!value)
++
++ const double value = std::visit(ValueVisitor(ec), valueVariant);
++
++ callback(ec, value);
++ },
++ service, path, "org.freedesktop.DBus.Properties", "Get",
++ "xyz.openbmc_project.Sensor.Value", property);
++}
++
++inline void
++ fillMinMaxReadingRange(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
++ const std::string& serviceName,
++ const std::string& sensorPath)
++{
++ asyncResp->res.jsonValue["MetricType"] = "Numeric";
++
++ telemetry::getReadingRange(
++ serviceName, sensorPath, "MinValue",
++ [asyncResp](boost::system::error_code ec, double readingRange) {
++ if (ec)
+ {
-+ return false;
++ messages::internalError(asyncResp->res);
++ return;
++ }
++
++ if (std::isfinite(readingRange))
++ {
++ asyncResp->res.jsonValue["MetricType"] = "Gauge";
++
++ asyncResp->res.jsonValue["MinReadingRange"] = readingRange;
+ }
-+ return *value == odataId;
+ });
+
-+ return it != json.end();
++ telemetry::getReadingRange(
++ serviceName, sensorPath, "MaxValue",
++ [asyncResp](boost::system::error_code ec, double readingRange) {
++ if (ec)
++ {
++ messages::internalError(asyncResp->res);
++ return;
++ }
++
++ if (std::isfinite(readingRange))
++ {
++ asyncResp->res.jsonValue["MetricType"] = "Gauge";
++
++ asyncResp->res.jsonValue["MaxReadingRange"] = readingRange;
++ }
++ });
+}
+
-+void addMembers(crow::Response& res,
-+ const boost::container::flat_map<std::string, std::string>& el)
++inline void getSensorService(
++ const std::string& sensorPath,
++ std::function<void(boost::system::error_code, const std::string&)> callback)
+{
-+ for (const auto& [_, dbusSensor] : el)
-+ {
-+ sdbusplus::message::object_path path(dbusSensor);
-+ sdbusplus::message::object_path parentPath = path.parent_path();
-+ const std::string type = parentPath.filename();
++ using ResultType = std::pair<
++ std::string,
++ std::vector<std::pair<std::string, std::vector<std::string>>>>;
+
-+ if (type.empty())
-+ {
-+ BMCWEB_LOG_ERROR << "Received invalid DBus Sensor Path = "
-+ << dbusSensor;
-+ continue;
-+ }
++ crow::connections::systemBus->async_method_call(
++ [sensorPath, callback = std::move(callback)](
++ boost::system::error_code ec,
++ const std::vector<ResultType>& result) {
++ if (ec)
++ {
++ callback(ec, std::string{});
++ return;
++ }
++
++ for (const auto& [path, serviceToInterfaces] : result)
++ {
++ if (path == sensorPath)
++ {
++ for (const auto& [service, interfaces] :
++ serviceToInterfaces)
++ {
++ callback(boost::system::errc::make_error_code(
++ boost::system::errc::success),
++ service);
++ return;
++ }
++ }
++ }
+
-+ nlohmann::json& members = res.jsonValue["Members"];
++ callback(boost::system::errc::make_error_code(
++ boost::system::errc::no_such_file_or_directory),
++ std::string{});
++ },
++ "xyz.openbmc_project.ObjectMapper",
++ "/xyz/openbmc_project/object_mapper",
++ "xyz.openbmc_project.ObjectMapper", "GetSubTree",
++ "/xyz/openbmc_project/sensors", 2,
++ std::array{"xyz.openbmc_project.Sensor.Value"});
++}
+
-+ const std::string odataId =
-+ std::string(telemetry::metricDefinitionUri) +
-+ sensors::toReadingType(type);
++constexpr auto metricDefinitionMapping = std::array{
++ std::pair{"fan_pwm", "Fan_Pwm"}, std::pair{"fan_tach", "Fan_Tach"}};
+
-+ if (!containsOdata(members, odataId))
-+ {
-+ members.push_back({{"@odata.id", odataId}});
-+ }
++std::string mapSensorToMetricDefinition(const std::string& sensorPath)
++{
++ sdbusplus::message::object_path sensorObjectPath{sensorPath};
++
++ const auto it = std::find_if(
++ metricDefinitionMapping.begin(), metricDefinitionMapping.end(),
++ [&sensorObjectPath](const auto& item) {
++ return item.first == sensorObjectPath.parent_path().filename();
++ });
++
++ const char* metricDefinitionPath =
++ "/redfish/v1/TelemetryService/MetricDefinitions/";
+
-+ res.jsonValue["Members@odata.count"] = members.size();
++ if (it != metricDefinitionMapping.end())
++ {
++ return std::string{metricDefinitionPath} + it->second;
+ }
++
++ return metricDefinitionPath + sensorObjectPath.filename();
+}
+
+template <class Callback>
@@ -300,8 +413,11 @@ index 0000000..019168b
+ return;
+ }
+
++ auto counter = std::make_shared<std::pair<
++ boost::container::flat_map<std::string, std::string>, size_t>>();
++
+ auto handleRetrieveUriToDbusMap =
-+ [callback = std::move(callback)](
++ [counter, callback = std::move(callback)](
+ const boost::beast::http::status status,
+ const boost::container::flat_map<std::string, std::string>&
+ uriToDbus) {
@@ -310,21 +426,31 @@ index 0000000..019168b
+ BMCWEB_LOG_ERROR << "Failed to retrieve URI to dbus "
+ "sensors map with err "
+ << static_cast<unsigned>(status);
++ counter->second = 0u;
+ callback(boost::system::errc::make_error_code(
+ boost::system::errc::io_error),
+ {});
+ return;
+ }
+
-+ callback(boost::system::errc::make_error_code(
-+ boost::system::errc::success),
-+ uriToDbus);
++ for (const auto& [key, value] : uriToDbus)
++ {
++ counter->first[key] = value;
++ }
++
++ if (--counter->second == 0u)
++ {
++ callback(boost::system::errc::make_error_code(
++ boost::system::errc::success),
++ counter->first);
++ }
+ };
+
+ for (const std::string& chassisName : chassisNames)
+ {
+ for (const auto& [sensorNode, dbusPaths] : sensors::dbus::paths)
+ {
++ ++counter->second;
+ retrieveUriToDbusMap(chassisName, sensorNode.data(),
+ handleRetrieveUriToDbusMap);
+ }
@@ -354,7 +480,23 @@ index 0000000..019168b
+ return;
+ }
+
-+ telemetry::addMembers(asyncResp->res, uriToDbus);
++ std::set<std::string> members;
++
++ for (const auto& [uri, dbusPath] : uriToDbus)
++ {
++ members.insert(
++ telemetry::mapSensorToMetricDefinition(
++ dbusPath));
++ }
++
++ for (const std::string& odataId : members)
++ {
++ asyncResp->res.jsonValue["Members"].push_back(
++ {{"@odata.id", odataId}});
++ }
++
++ asyncResp->res.jsonValue["Members@odata.count"] =
++ asyncResp->res.jsonValue["Members"].size();
+ });
+
+ asyncResp->res.jsonValue["@odata.type"] =
@@ -369,128 +511,109 @@ index 0000000..019168b
+ });
+}
+
-+namespace telemetry
-+{
-+
-+bool isSensorIdSupported(std::string_view readingType)
-+{
-+ 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(
-+ sdbusplus::message::object_path(supportedPath).filename()))
-+ {
-+ return true;
-+ }
-+ }
-+ }
-+ return false;
-+}
-+
-+void addMetricProperty(
-+ bmcweb::AsyncResp& asyncResp, const std::string& readingType,
-+ const boost::container::flat_map<std::string, std::string>& el)
-+{
-+ nlohmann::json& metricProperties =
-+ asyncResp.res.jsonValue["MetricProperties"];
-+
-+ for (const auto& [redfishSensor, dbusSensor] : el)
-+ {
-+ std::string sensorId;
-+ if (dbus::utility::getNthStringFromPath(dbusSensor, 3, sensorId))
-+ {
-+ if (sensors::toReadingType(sensorId) == readingType)
-+ {
-+ metricProperties.push_back(redfishSensor);
-+ }
-+ }
-+ }
-+}
-+
-+inline const char* readingTypeToReadingUnits(const std::string& readingType)
-+{
-+ for (const auto& [node, paths] : sensors::dbus::paths)
-+ {
-+ for (const char* path : paths)
-+ {
-+ const sdbusplus::message::object_path sensorPath =
-+ sdbusplus::message::object_path(path);
-+ if (sensors::toReadingType(sensorPath.filename()) == readingType)
-+ {
-+ return sensors::toReadingUnits(sensorPath.filename());
-+ }
-+ }
-+ }
-+ return "";
-+}
-+
-+} // namespace telemetry
-+
+inline void requestRoutesMetricDefinition(App& app)
+{
+ BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricDefinitions/<str>/")
+ .privileges(privileges::getTelemetryService)
-+ .methods(boost::beast::http::verb::get)(
-+ [](const crow::Request&,
-+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
-+ const std::string& readingType) {
-+ if (!telemetry::isSensorIdSupported(readingType))
-+ {
-+ messages::resourceNotFound(asyncResp->res,
-+ "MetricDefinition", readingType);
-+ return;
-+ }
-+
-+ telemetry::mapRedfishUriToDbusPath(
-+ [asyncResp,
-+ readingType](boost::system::error_code ec,
-+ const boost::container::flat_map<
-+ std::string, std::string>& uriToDbus) {
-+ if (ec)
++ .methods(
++ boost::beast::http::verb::get)([](const crow::Request&,
++ const std::shared_ptr<
++ bmcweb::AsyncResp>& asyncResp,
++ const std::string& name) {
++ telemetry::mapRedfishUriToDbusPath(
++ [asyncResp, name](
++ boost::system::error_code ec,
++ const boost::container::flat_map<std::string, std::string>&
++ uriToDbus) {
++ if (ec)
++ {
++ messages::internalError(asyncResp->res);
++ BMCWEB_LOG_ERROR << "mapRedfishUriToDbusPath error: "
++ << ec.value();
++ return;
++ }
++
++ std::string odataId = telemetry::metricDefinitionUri + name;
++ boost::container::flat_map<std::string, std::string>
++ matchingUris;
++
++ for (const auto& [uri, dbusPath] : uriToDbus)
++ {
++ if (telemetry::mapSensorToMetricDefinition(dbusPath) ==
++ odataId)
+ {
-+ messages::internalError(asyncResp->res);
-+ BMCWEB_LOG_ERROR
-+ << "mapRedfishUriToDbusPath error: "
-+ << ec.value();
-+ return;
++ matchingUris.emplace(uri, dbusPath);
+ }
-+
-+ asyncResp->res.jsonValue["Id"] = readingType;
-+ asyncResp->res.jsonValue["Name"] = readingType;
-+ asyncResp->res.jsonValue["@odata.id"] =
-+ telemetry::metricDefinitionUri + readingType;
-+ 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"] =
-+ telemetry::readingTypeToReadingUnits(readingType);
-+
-+ telemetry::addMetricProperty(*asyncResp, readingType,
-+ uriToDbus);
-+ });
-+ });
++ }
++
++ if (matchingUris.empty())
++ {
++ messages::resourceNotFound(asyncResp->res,
++ "MetricDefinition", name);
++ return;
++ }
++
++ std::string sensorPath = matchingUris.begin()->second;
++
++ telemetry::getSensorService(
++ sensorPath,
++ [asyncResp, name, odataId = std::move(odataId),
++ sensorPath, matchingUris = std::move(matchingUris)](
++ boost::system::error_code ec,
++ const std::string& serviceName) {
++ if (ec)
++ {
++ messages::internalError(asyncResp->res);
++ BMCWEB_LOG_ERROR << "getServiceSensorFailed: "
++ << ec.value();
++ return;
++ }
++
++ asyncResp->res.jsonValue["Id"] = name;
++ asyncResp->res.jsonValue["Name"] = name;
++ asyncResp->res.jsonValue["@odata.id"] = odataId;
++ asyncResp->res.jsonValue["@odata.type"] =
++ "#MetricDefinition.v1_0_3.MetricDefinition";
++ asyncResp->res.jsonValue["MetricDataType"] =
++ "Decimal";
++ asyncResp->res.jsonValue["IsLinear"] = true;
++ asyncResp->res.jsonValue["Units"] =
++ sensors::toReadingUnits(
++ sdbusplus::message::object_path{sensorPath}
++ .parent_path()
++ .filename());
++
++ for (const auto& [uri, dbusPath] : matchingUris)
++ {
++ asyncResp->res.jsonValue["MetricProperties"]
++ .push_back(uri);
++ }
++
++ telemetry::fillMinMaxReadingRange(
++ asyncResp, serviceName, sensorPath);
++ });
++ });
++ });
+}
+
+} // namespace redfish
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
-index ad86d5c..c4962e9 100644
+index 8ecc591..027b51b 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
-@@ -29,6 +29,8 @@ inline void requestRoutesTelemetryService(App& app)
- "/redfish/v1/TelemetryService/MetricReportDefinitions";
- asyncResp->res.jsonValue["MetricReports"]["@odata.id"] =
- "/redfish/v1/TelemetryService/MetricReports";
-+ asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] =
-+ "/redfish/v1/TelemetryService/MetricDefinitions";
+@@ -18,11 +18,12 @@ inline void handleTelemetryServiceGet(
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TelemetryService";
+ asyncResp->res.jsonValue["Id"] = "TelemetryService";
+ asyncResp->res.jsonValue["Name"] = "Telemetry Service";
+-
+ asyncResp->res.jsonValue["MetricReportDefinitions"]["@odata.id"] =
+ "/redfish/v1/TelemetryService/MetricReportDefinitions";
+ asyncResp->res.jsonValue["MetricReports"]["@odata.id"] =
+ "/redfish/v1/TelemetryService/MetricReports";
++ asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] =
++ "/redfish/v1/TelemetryService/MetricDefinitions";
- crow::connections::systemBus->async_method_call(
- [asyncResp](
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
--
2.25.1
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch
index d32c85356..3088a7f9d 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch
@@ -1,4 +1,4 @@
-From 77e8a0b5037a555b1520823b667595ac8780c675 Mon Sep 17 00:00:00 2001
+From 541353a4e4b06de42b6a9a400629f5a5fba04e86 Mon Sep 17 00:00:00 2001
From: "Wludzik, Jozef" <jozef.wludzik@intel.com>
Date: Tue, 15 Dec 2020 12:30:31 +0100
Subject: [PATCH] Sync Telmetry service with EventService
@@ -16,13 +16,14 @@ Tested:
Change-Id: I2fc1841a6c9259a8bff30b34bddc0d4aabd41912
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
+Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
---
.../include/event_service_manager.hpp | 156 ++++++------------
redfish-core/lib/metric_report.hpp | 28 ++--
2 files changed, 69 insertions(+), 115 deletions(-)
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
-index d89b789..4faaddd 100644
+index 3f398d7..cf9f658 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -14,6 +14,7 @@
@@ -212,12 +213,12 @@ index d89b789..4faaddd 100644
+ });
+ if (found == props.end())
+ {
-+ BMCWEB_LOG_ERROR
++ BMCWEB_LOG_INFO
+ << "Failed to get Readings from Report properties";
+ return;
+ }
+
-+ std::variant<telemetry::TimestampReadings>& readings =
++ const std::variant<telemetry::TimestampReadings>& readings =
+ found->second;
+ for (const auto& it :
+ EventServiceManager::getInstance().subscriptionsMap)
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch
index 20bcbabfa..5dd2f51bc 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch
@@ -1,4 +1,4 @@
-From fca6f5b951a363916a83a25f6578f95a6cf32a3e Mon Sep 17 00:00:00 2001
+From 8ba1bcc3503cafb33b1a06356d4f8f92ae23e39a Mon Sep 17 00:00:00 2001
From: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Date: Thu, 17 Jun 2021 13:37:57 +0000
Subject: [PATCH] Switched bmcweb to use new telemetry service API
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch
index 3d60ae293..bf5a09d9d 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch
@@ -1,6 +1,6 @@
-From 79b3d35b864a2b545b4c9b2ac9390ea5dec169f5 Mon Sep 17 00:00:00 2001
-From: Szymon Dompke <szymon.dompke@intel.com>
-Date: Mon, 28 Jun 2021 11:10:23 +0200
+From dab3c96f9e39a89d7c359e22655650c7c16952ec Mon Sep 17 00:00:00 2001
+From: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
+Date: Tue, 12 Oct 2021 08:06:13 +0000
Subject: [PATCH] Add support for MetricDefinition property in MetricReport
Added MetricDefinition as part of MetricValues array returned by
@@ -73,19 +73,19 @@ Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
4 files changed, 95 insertions(+), 15 deletions(-)
diff --git a/meson.build b/meson.build
-index f6a66f1..6b5d9af 100644
+index 6b6a8ab..218ea49 100644
--- a/meson.build
+++ b/meson.build
-@@ -355,6 +355,8 @@ srcfiles_unittest = ['include/ut/dbus_utility_test.cpp',
- 'redfish-core/ut/time_utils_test.cpp',
- 'http/ut/utility_test.cpp']
+@@ -377,6 +377,8 @@ srcfiles_unittest = [
+ 'http/ut/utility_test.cpp'
+ ]
-+srcfiles_unittest_dependencies = ['redfish-core/src/error_messages.cpp']
++srcfiles_unittest_dependencies = ['redfish-core/src/error_messages.cpp', 'src/boost_url.cpp']
+
# Gather the Configuration data
conf_data = configuration_data()
-@@ -412,7 +414,7 @@ executable('bmcweb',srcfiles_bmcweb,
+@@ -434,7 +436,7 @@ executable('bmcweb',srcfiles_bmcweb,
if(get_option('tests').enabled())
foreach src_test : srcfiles_unittest
testname = src_test.split('/')[-1].split('.')[0]
@@ -251,7 +251,7 @@ index 7fe281d..13bf792 100644
}
} // namespace telemetry
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
-index cb7ea15..44c2129 100644
+index 7405e5a..9850b24 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -21,6 +21,8 @@
@@ -265,3 +265,4 @@ index cb7ea15..44c2129 100644
--
2.25.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch
index 987a43b4c..a80ac61c7 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch
@@ -1,6 +1,6 @@
-From 472ac5f15a19917042852b243e8b668b3ab49e32 Mon Sep 17 00:00:00 2001
+From da575aaf0bdcb15be261d58314cf7bbbcd92dd74 Mon Sep 17 00:00:00 2001
From: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
-Date: Tue, 22 Jun 2021 13:59:48 +0000
+Date: Tue, 12 Oct 2021 08:08:06 +0000
Subject: [PATCH] Revert "Remove LogService from TelemetryService"
This reverts commit 2b3da45876aac57a36d3093379a992d699e7e396.
@@ -9,18 +9,18 @@ This reverts commit 2b3da45876aac57a36d3093379a992d699e7e396.
1 file changed, 2 insertions(+)
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
-index 37221c3..f3a1efb 100644
+index 027b51b..49471fe 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
-@@ -30,6 +30,8 @@ inline void requestRoutesTelemetryService(App& app)
- "/redfish/v1/TelemetryService/MetricReports";
- asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] =
- "/redfish/v1/TelemetryService/MetricDefinitions";
-+ asyncResp->res.jsonValue["LogService"]["@odata.id"] =
-+ "/redfish/v1/Managers/bmc/LogServices/Journal";
+@@ -24,6 +24,8 @@ inline void handleTelemetryServiceGet(
+ "/redfish/v1/TelemetryService/MetricReports";
+ asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] =
+ "/redfish/v1/TelemetryService/MetricDefinitions";
++ asyncResp->res.jsonValue["LogService"]["@odata.id"] =
++ "/redfish/v1/Managers/bmc/LogServices/Journal";
- crow::connections::systemBus->async_method_call(
- [asyncResp](
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
--
2.25.1
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch
deleted file mode 100644
index bd6e64346..000000000
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From d9baec3ccdff5ed4d1620f374a252c769de5b45b Mon Sep 17 00:00:00 2001
-From: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
-Date: Thu, 19 Aug 2021 10:55:38 +0000
-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 | 25 ++++++++++++++++++-------
- 1 file changed, 18 insertions(+), 7 deletions(-)
-
-diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp
-index 019168b..df29b65 100644
---- a/redfish-core/lib/metric_definition.hpp
-+++ b/redfish-core/lib/metric_definition.hpp
-@@ -33,6 +33,18 @@ bool containsOdata(const nlohmann::json& json, const std::string& odataId)
- return it != json.end();
- }
-
-+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)
- {
-@@ -52,8 +64,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);
-
- if (!containsOdata(members, odataId))
- {
-@@ -149,15 +160,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;
-@@ -168,7 +179,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 =
-@@ -179,7 +190,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);
- }
---
-2.25.1
-
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README
index fd88e9e18..90916ecec 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README
@@ -3,16 +3,16 @@ Until change is integrated they will be manually merged here to enable feature i
Current revisions:
- Add support for MetricDefinition scheme
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/93
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/102
- Sync Telmetry service with EventService
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/40
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/53
- Switched bmcweb to use new telemetry service API
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44270/5
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44270/19
- Add support for MetricDefinition property in MetricReport
- https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44512/9
+ https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44512/24
- Add GET method for TriggerCollection
file://telemetry/0005-Add-GET-method-for-TriggerCollection.patch