diff options
author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2021-05-03 20:49:59 +0300 |
---|---|---|
committer | Jason M. Bills <jason.m.bills@linux.intel.com> | 2021-05-03 21:06:56 +0300 |
commit | e370fd750e2821620ec427f26f8efab0069824ff (patch) | |
tree | 9acce8ae4bf8b88a4e71b1bbcd2e69cd3c166ea5 /meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry | |
parent | ab16ab3d0de4dc9d130ae3db366c38888f1ada5a (diff) | |
download | openbmc-e370fd750e2821620ec427f26f8efab0069824ff.tar.xz |
Update to internal 0.47
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry')
5 files changed, 393 insertions, 355 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Sync_ReadingUnit_with_Redfish_Sensor_Schema.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Sync_ReadingUnit_with_Redfish_Sensor_Schema.patch new file mode 100644 index 000000000..e3b25da90 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Sync_ReadingUnit_with_Redfish_Sensor_Schema.patch @@ -0,0 +1,227 @@ +From 4b7e67d7200c0aba1b27478968d4f71449f1406a Mon Sep 17 00:00:00 2001 +From: "Wludzik, Jozef" <jozef.wludzik@intel.com> +Date: Mon, 8 Mar 2021 14:35:54 +0000 +Subject: [PATCH] Sync ReadingUnit with Redfish Sensor Schema + +Actual attribute "ReadingUnits" does not match with Redfish Sensor +Schema. This change match "ReadingUnits" with Redfish Sensor Scheme +1.0.0 and add missing "ReadingType" attribute. This change affect all +users that depends on old units that does not match with Redfish +standard. Added toReadingType and toReadingUnit function that uses +values taken from Redfish Sensor Scheme 1.0.0. Latest version 1.2.0 of +Sensor scheme defines units same units. + +Tested: + - RedfishServiceValidator pass + +Change-Id: I0c8820eba7271022c427cd25dec321db36aa0176 +Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> +Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> +--- + redfish-core/lib/power.hpp | 4 +- + redfish-core/lib/sensors.hpp | 107 +++++++++++++++++++++++++++++------ + redfish-core/lib/thermal.hpp | 4 +- + 3 files changed, 94 insertions(+), 21 deletions(-) + +diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp +index 1c7a009..99c45ef 100644 +--- a/redfish-core/lib/power.hpp ++++ b/redfish-core/lib/power.hpp +@@ -153,7 +153,7 @@ class Power : public Node + res.jsonValue["PowerControl"] = nlohmann::json::array(); + + auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( +- res, chassisName, sensors::dbus::types.at(sensors::node::power), ++ res, chassisName, sensors::dbus::paths.at(sensors::node::power), + sensors::node::power); + + getChassisData(sensorAsyncResp); +@@ -336,7 +336,7 @@ class Power : public Node + + const std::string& chassisName = params[0]; + auto asyncResp = std::make_shared<SensorsAsyncResp>( +- res, chassisName, sensors::dbus::types.at(sensors::node::power), ++ res, chassisName, sensors::dbus::paths.at(sensors::node::power), + sensors::node::power); + + std::optional<std::vector<nlohmann::json>> voltageCollections; +diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp +index 35114bf..af030f0 100644 +--- a/redfish-core/lib/sensors.hpp ++++ b/redfish-core/lib/sensors.hpp +@@ -54,9 +54,10 @@ static constexpr std::string_view thermal = "Thermal"; + + namespace dbus + { ++ + static const boost::container::flat_map<std::string_view, + std::vector<const char*>> +- types = {{node::power, ++ paths = {{node::power, + {"/xyz/openbmc_project/sensors/voltage", + "/xyz/openbmc_project/sensors/power"}}, + {node::sensors, +@@ -67,6 +68,88 @@ static const boost::container::flat_map<std::string_view, + {"/xyz/openbmc_project/sensors/fan_tach", + "/xyz/openbmc_project/sensors/temperature", + "/xyz/openbmc_project/sensors/fan_pwm"}}}; ++} // namespace dbus ++ ++inline const char* toReadingType(const std::string& sensorType) ++{ ++ if (sensorType == "voltage") ++ { ++ return "Voltage"; ++ } ++ if (sensorType == "power") ++ { ++ return "Power"; ++ } ++ if (sensorType == "current") ++ { ++ return "Current"; ++ } ++ if (sensorType == "fan_tach") ++ { ++ return "Rotational"; ++ } ++ if (sensorType == "temperature") ++ { ++ return "Temperature"; ++ } ++ if (sensorType == "fan_pwm" || sensorType == "utilization") ++ { ++ return "Percent"; ++ } ++ if (sensorType == "altitude") ++ { ++ return "Altitude"; ++ } ++ if (sensorType == "airflow") ++ { ++ return "AirFlow"; ++ } ++ if (sensorType == "energy") ++ { ++ return "EnergyJoules"; ++ } ++ return ""; ++} ++ ++inline const char* toReadingUnits(const std::string& sensorType) ++{ ++ if (sensorType == "voltage") ++ { ++ return "V"; ++ } ++ if (sensorType == "power") ++ { ++ return "W"; ++ } ++ if (sensorType == "current") ++ { ++ return "A"; ++ } ++ if (sensorType == "fan_tach") ++ { ++ return "RPM"; ++ } ++ if (sensorType == "temperature") ++ { ++ return "Cel"; ++ } ++ if (sensorType == "fan_pwm" || sensorType == "utilization") ++ { ++ return "%"; ++ } ++ if (sensorType == "altitude") ++ { ++ return "m"; ++ } ++ if (sensorType == "airflow") ++ { ++ return "cft_i/min"; ++ } ++ if (sensorType == "energy") ++ { ++ return "J"; ++ } ++ return ""; + } + } // namespace sensors + +@@ -854,18 +937,8 @@ inline void objectInterfacesToJson( + if (sensorsAsyncResp->chassisSubNode == sensors::node::sensors) + { + sensorJson["@odata.type"] = "#Sensor.v1_0_0.Sensor"; +- if (sensorType == "power") +- { +- sensorJson["ReadingUnits"] = "Watts"; +- } +- else if (sensorType == "current") +- { +- sensorJson["ReadingUnits"] = "Amperes"; +- } +- else if (sensorType == "utilization") +- { +- sensorJson["ReadingUnits"] = "Percent"; +- } ++ sensorJson["ReadingType"] = sensors::toReadingType(sensorType); ++ sensorJson["ReadingUnits"] = sensors::toReadingUnits(sensorType); + } + else if (sensorType == "temperature") + { +@@ -2979,8 +3052,8 @@ inline void retrieveUriToDbusMap(const std::string& chassis, + const std::string& node, + SensorsAsyncResp::DataCompleteCb&& mapComplete) + { +- auto typesIt = sensors::dbus::types.find(node); +- if (typesIt == sensors::dbus::types.end()) ++ auto pathIt = sensors::dbus::paths.find(node); ++ if (pathIt == sensors::dbus::paths.end()) + { + BMCWEB_LOG_ERROR << "Wrong node provided : " << node; + mapComplete(boost::beast::http::status::bad_request, {}); +@@ -2995,7 +3068,7 @@ inline void retrieveUriToDbusMap(const std::string& chassis, + uriToDbus) { mapCompleteCb(status, uriToDbus); }; + + auto resp = std::make_shared<SensorsAsyncResp>( +- *respBuffer, chassis, typesIt->second, node, std::move(callback)); ++ *respBuffer, chassis, pathIt->second, node, std::move(callback)); + getChassisData(resp); + } + +@@ -3030,7 +3103,7 @@ class SensorCollection : public Node + const std::string& chassisId = params[0]; + std::shared_ptr<SensorsAsyncResp> asyncResp = + std::make_shared<SensorsAsyncResp>( +- res, chassisId, sensors::dbus::types.at(sensors::node::sensors), ++ res, chassisId, sensors::dbus::paths.at(sensors::node::sensors), + sensors::node::sensors); + + auto getChassisCb = +diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp +index 8e01bee..00acdf9 100644 +--- a/redfish-core/lib/thermal.hpp ++++ b/redfish-core/lib/thermal.hpp +@@ -48,7 +48,7 @@ class Thermal : public Node + } + const std::string& chassisName = params[0]; + auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( +- res, chassisName, sensors::dbus::types.at(sensors::node::thermal), ++ res, chassisName, sensors::dbus::paths.at(sensors::node::thermal), + sensors::node::thermal); + + // TODO Need to get Chassis Redundancy information. +@@ -71,7 +71,7 @@ class Thermal : public Node + allCollections; + + auto asyncResp = std::make_shared<SensorsAsyncResp>( +- res, chassisName, sensors::dbus::types.at(sensors::node::thermal), ++ res, chassisName, sensors::dbus::paths.at(sensors::node::thermal), + sensors::node::thermal); + + if (!json_util::readJson(req, asyncResp->res, "Temperatures", +-- +2.25.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch index fd7e8a445..aaf3f17c7 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Add-POST-and-DELETE-in-MetricReportDefinitions.patch @@ -1,4 +1,4 @@ -From bc1635622e122f307fb3b8eb9bbd66ea576a8f0c Mon Sep 17 00:00:00 2001 +From 03c4ece83b58b954323111a1a7b2bf2b61402d7e Mon Sep 17 00:00:00 2001 From: "Wludzik, Jozef" <jozef.wludzik@intel.com> Date: Mon, 18 May 2020 11:56:57 +0200 Subject: [PATCH 2/4] Add POST and DELETE in MetricReportDefinitions @@ -31,26 +31,39 @@ Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: I2fed96848594451e22fde686f8c066d7770cc65a --- meson.build | 1 + - redfish-core/include/utils/time_utils.hpp | 138 ++++++++++- - redfish-core/lib/metric_report_definition.hpp | 328 ++++++++++++++++++++++++++ - redfish-core/ut/time_utils_test.cpp | 63 +++++ - 4 files changed, 528 insertions(+), 2 deletions(-) + .../include/utils/telemetry_utils.hpp | 2 + + redfish-core/include/utils/time_utils.hpp | 138 +++++++- + redfish-core/lib/metric_report_definition.hpp | 328 ++++++++++++++++++ + redfish-core/ut/time_utils_test.cpp | 63 ++++ + 5 files changed, 530 insertions(+), 2 deletions(-) create mode 100644 redfish-core/ut/time_utils_test.cpp diff --git a/meson.build b/meson.build -index 7a16e91..3d65b01 100644 +index 66a066b..22a8c4a 100644 --- a/meson.build +++ b/meson.build -@@ -330,6 +330,7 @@ srcfiles_bmcweb = ['src/webserver_main.cpp','redfish-core/src/error_messages.cpp - srcfiles_unittest = ['include/ut/dbus_utility_test.cpp', +@@ -345,6 +345,7 @@ srcfiles_unittest = ['include/ut/dbus_utility_test.cpp', 'redfish-core/ut/privileges_test.cpp', 'redfish-core/ut/lock_test.cpp', + 'redfish-core/ut/configfile_test.cpp', + 'redfish-core/ut/time_utils_test.cpp', 'http/ut/utility_test.cpp'] # Gather the Configuration data +diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp +index a3a8156..0a3af5f 100644 +--- a/redfish-core/include/utils/telemetry_utils.hpp ++++ b/redfish-core/include/utils/telemetry_utils.hpp +@@ -1,5 +1,7 @@ + #pragma once + ++#include "dbus_utility.hpp" ++ + namespace redfish + { + diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp -index dd4ea75..e94801b 100644 +index 4a87ba0..9965d4d 100644 --- a/redfish-core/include/utils/time_utils.hpp +++ b/redfish-core/include/utils/time_utils.hpp @@ -1,7 +1,13 @@ @@ -212,7 +225,7 @@ index dd4ea75..e94801b 100644 /** * @brief Convert time value into duration format that is based on ISO 8601. * Example output: "P12DT1M5.5S" -@@ -36,8 +171,7 @@ std::string toDurationString(std::chrono::milliseconds ms) +@@ -36,8 +171,7 @@ inline std::string toDurationString(std::chrono::milliseconds ms) std::string fmt; fmt.reserve(sizeof("PxxxxxxxxxxxxDTxxHxxMxx.xxxxxxS")); @@ -654,5 +667,5 @@ index 0000000..70999ce + EXPECT_THAT(redfish::time_utils::toDurationString(ms), Eq(expected)); +} -- -2.16.6 +2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch index 99af0ab86..03feec633 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-MetricDefinition-scheme.patch @@ -1,4 +1,4 @@ -From 462b2e814698e12a18b4956eb3c6421c34a3a4ba Mon Sep 17 00:00:00 2001 +From b6ccf463b4cfb8df4a904f06c5f4852029a96c50 Mon Sep 17 00:00:00 2001 From: "Wludzik, Jozef" <jozef.wludzik@intel.com> Date: Tue, 15 Dec 2020 12:28:17 +0100 Subject: [PATCH 3/4] Add support for MetricDefinition scheme @@ -9,9 +9,6 @@ by Telemetry service. Metrics are grouped by following categories: temperature, power, voltage, current, fan_tach, fan_pwm, utilization. -Added generic function to fill ReadingUnits and ReadingType -in Sensor node. - Tested: - MetricDefinitions response is filled with existing sensors, it works with and without Telemetry service @@ -24,18 +21,15 @@ Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: I3086e1302e1ba2e5442d1367939fd5507a0cbc00 --- - redfish-core/include/redfish.hpp | 3 + - redfish-core/include/utils/telemetry_utils.hpp | 2 + - redfish-core/lib/metric_definition.hpp | 283 +++++++++++++++++++++++++ - redfish-core/lib/power.hpp | 4 +- - redfish-core/lib/sensors.hpp | 85 ++++++-- - redfish-core/lib/telemetry_service.hpp | 2 + - redfish-core/lib/thermal.hpp | 4 +- - 7 files changed, 361 insertions(+), 22 deletions(-) + redfish-core/include/redfish.hpp | 3 + + .../include/utils/telemetry_utils.hpp | 2 + + redfish-core/lib/metric_definition.hpp | 283 ++++++++++++++++++ + redfish-core/lib/telemetry_service.hpp | 2 + + 4 files changed, 290 insertions(+) create mode 100644 redfish-core/lib/metric_definition.hpp diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp -index e94c0f3..83f2300 100644 +index aad28ac..dfcb8cd 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -25,6 +25,7 @@ @@ -46,8 +40,8 @@ index e94c0f3..83f2300 100644 #include "../lib/metric_report.hpp" #include "../lib/metric_report_definition.hpp" #include "../lib/network_protocol.hpp" -@@ -213,6 +214,8 @@ class RedfishService - nodes.emplace_back(std::make_unique<HypervisorSystem>(app)); +@@ -215,6 +216,8 @@ class RedfishService + nodes.emplace_back(std::make_unique<HypervisorResetActionInfo>(app)); nodes.emplace_back(std::make_unique<TelemetryService>(app)); + nodes.emplace_back(std::make_unique<MetricDefinitionCollection>(app)); @@ -56,10 +50,10 @@ index e94c0f3..83f2300 100644 std::make_unique<MetricReportDefinitionCollection>(app)); nodes.emplace_back(std::make_unique<MetricReportDefinition>(app)); diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp -index a3a8156..c1b7639 100644 +index 0a3af5f..54b5133 100644 --- a/redfish-core/include/utils/telemetry_utils.hpp +++ b/redfish-core/include/utils/telemetry_utils.hpp -@@ -8,6 +8,8 @@ namespace telemetry +@@ -10,6 +10,8 @@ namespace telemetry constexpr const char* service = "xyz.openbmc_project.Telemetry"; constexpr const char* reportInterface = "xyz.openbmc_project.Telemetry.Report"; @@ -70,7 +64,7 @@ index a3a8156..c1b7639 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..4a40af5 +index 0000000..f9c7779 --- /dev/null +++ b/redfish-core/lib/metric_definition.hpp @@ -0,0 +1,283 @@ @@ -96,7 +90,7 @@ index 0000000..4a40af5 + crow::connections::systemBus->async_method_call( + [asyncResp, + callback = std::move(cb)](const boost::system::error_code ec, -+ std::vector<std::string>& chassises) { ++ std::vector<std::string>& chassis) { + if (ec) + { + messages::internalError(asyncResp->res); @@ -105,18 +99,18 @@ index 0000000..4a40af5 + } + + std::vector<std::string> chassisNames; -+ chassisNames.reserve(chassises.size()); -+ for (const std::string& chassis : chassises) ++ chassisNames.reserve(chassis.size()); ++ for (const auto& path : chassis) + { -+ sdbusplus::message::object_path path(chassis); -+ std::string name = path.filename(); ++ sdbusplus::message::object_path dbusPath = path; ++ std::string name = dbusPath.filename(); + if (name.empty()) + { + messages::internalError(asyncResp->res); -+ BMCWEB_LOG_ERROR << "Invalid chassis: " << chassis; ++ BMCWEB_LOG_ERROR << "Invalid chassis: " << dbusPath.str; + return; + } -+ chassisNames.push_back(name); ++ chassisNames.emplace_back(std::move(name)); + } + + callback(chassisNames); @@ -131,14 +125,15 @@ index 0000000..4a40af5 +namespace telemetry +{ + -+class DefinitionCollectionReduce ++class MetricDefinitionCollectionReduce +{ + public: -+ DefinitionCollectionReduce(const std::shared_ptr<AsyncResp>& asyncResp) : ++ MetricDefinitionCollectionReduce( ++ const std::shared_ptr<AsyncResp>& asyncResp) : + asyncResp{asyncResp} + {} + -+ ~DefinitionCollectionReduce() ++ ~MetricDefinitionCollectionReduce() + { + if (asyncResp->res.result() != boost::beast::http::status::ok) + { @@ -179,15 +174,15 @@ index 0000000..4a40af5 + boost::container::flat_set<std::string> dbusTypes; +}; + -+class DefinitionReduce ++class MetricDefinitionReduce +{ + public: -+ DefinitionReduce(const std::shared_ptr<AsyncResp>& asyncResp, -+ const std::string& id) : ++ MetricDefinitionReduce(const std::shared_ptr<AsyncResp>& asyncResp, ++ const std::string& id) : + id(id), + pattern{'/' + id + '/'}, asyncResp{asyncResp} + {} -+ ~DefinitionReduce() ++ ~MetricDefinitionReduce() + { + if (asyncResp->res.result() != boost::beast::http::status::ok) + { @@ -259,11 +254,10 @@ index 0000000..4a40af5 + res.jsonValue["Members@odata.count"] = 0; + + auto asyncResp = std::make_shared<AsyncResp>(res); -+ auto collectionReduce = -+ std::make_shared<telemetry::DefinitionCollectionReduce>(asyncResp); + utils::getChassisNames( -+ [asyncResp, -+ collectionReduce](const std::vector<std::string>& chassisNames) { ++ [asyncResp](const std::vector<std::string>& chassisNames) { ++ auto collectionReduce = std::make_shared< ++ telemetry::MetricDefinitionCollectionReduce>(asyncResp); + for (const std::string& chassisName : chassisNames) + { + for (const auto& [sensorNode, _] : sensors::dbus::paths) @@ -322,11 +316,11 @@ index 0000000..4a40af5 + } + + const std::string& id = params[0]; -+ auto definitionGather = -+ std::make_shared<telemetry::DefinitionReduce>(asyncResp, id); + utils::getChassisNames( -+ [asyncResp, -+ definitionGather](const std::vector<std::string>& chassisNames) { ++ [asyncResp, id](const std::vector<std::string>& chassisNames) { ++ auto definitionGather = ++ std::make_shared<telemetry::MetricDefinitionReduce>( ++ asyncResp, id); + for (const std::string& chassisName : chassisNames) + { + for (const auto& [sensorNode, dbusPaths] : @@ -357,164 +351,6 @@ index 0000000..4a40af5 +}; + +} // namespace redfish -diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp -index 1c7a009..99c45ef 100644 ---- a/redfish-core/lib/power.hpp -+++ b/redfish-core/lib/power.hpp -@@ -153,7 +153,7 @@ class Power : public Node - res.jsonValue["PowerControl"] = nlohmann::json::array(); - - auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( -- res, chassisName, sensors::dbus::types.at(sensors::node::power), -+ res, chassisName, sensors::dbus::paths.at(sensors::node::power), - sensors::node::power); - - getChassisData(sensorAsyncResp); -@@ -336,7 +336,7 @@ class Power : public Node - - const std::string& chassisName = params[0]; - auto asyncResp = std::make_shared<SensorsAsyncResp>( -- res, chassisName, sensors::dbus::types.at(sensors::node::power), -+ res, chassisName, sensors::dbus::paths.at(sensors::node::power), - sensors::node::power); - - std::optional<std::vector<nlohmann::json>> voltageCollections; -diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp -index 14c9593..5080f77 100644 ---- a/redfish-core/lib/sensors.hpp -+++ b/redfish-core/lib/sensors.hpp -@@ -54,9 +54,10 @@ static constexpr std::string_view thermal = "Thermal"; - - namespace dbus - { -+ - static const boost::container::flat_map<std::string_view, - std::vector<const char*>> -- types = {{node::power, -+ paths = {{node::power, - {"/xyz/openbmc_project/sensors/voltage", - "/xyz/openbmc_project/sensors/power"}}, - {node::sensors, -@@ -67,6 +68,64 @@ static const boost::container::flat_map<std::string_view, - {"/xyz/openbmc_project/sensors/fan_tach", - "/xyz/openbmc_project/sensors/temperature", - "/xyz/openbmc_project/sensors/fan_pwm"}}}; -+} // namespace dbus -+ -+inline const char* toReadingType(const std::string& sensorType) -+{ -+ if (sensorType == "voltage") -+ { -+ return "Voltage"; -+ } -+ if (sensorType == "power") -+ { -+ return "Power"; -+ } -+ if (sensorType == "current") -+ { -+ return "Current"; -+ } -+ if (sensorType == "fan_tach") -+ { -+ return "Rotational"; -+ } -+ if (sensorType == "temperature") -+ { -+ return "Temperature"; -+ } -+ if (sensorType == "fan_pwm" || sensorType == "utilization") -+ { -+ return "Percent"; -+ } -+ return ""; -+} -+ -+inline const char* toReadingUnits(const std::string& sensorType) -+{ -+ if (sensorType == "voltage") -+ { -+ return "V"; -+ } -+ if (sensorType == "power") -+ { -+ return "W"; -+ } -+ if (sensorType == "current") -+ { -+ return "A"; -+ } -+ if (sensorType == "fan_tach") -+ { -+ return "RPM"; -+ } -+ if (sensorType == "temperature") -+ { -+ return "Cel"; -+ } -+ if (sensorType == "fan_pwm" || sensorType == "utilization") -+ { -+ return "%"; -+ } -+ return ""; - } - } // namespace sensors - -@@ -345,11 +404,11 @@ inline void reduceSensorList( - return; - } - -- for (const char* type : sensorsAsyncResp->types) -+ for (const char* path : sensorsAsyncResp->types) - { - for (const std::string& sensor : *allSensors) - { -- if (boost::starts_with(sensor, type)) -+ if (boost::starts_with(sensor, path)) - { - activeSensors->emplace(sensor); - } -@@ -853,18 +912,8 @@ inline void objectInterfacesToJson( - if (sensorsAsyncResp->chassisSubNode == sensors::node::sensors) - { - sensorJson["@odata.type"] = "#Sensor.v1_0_0.Sensor"; -- if (sensorType == "power") -- { -- sensorJson["ReadingUnits"] = "Watts"; -- } -- else if (sensorType == "current") -- { -- sensorJson["ReadingUnits"] = "Amperes"; -- } -- else if (sensorType == "utilization") -- { -- sensorJson["ReadingUnits"] = "Percent"; -- } -+ sensorJson["ReadingType"] = sensors::toReadingType(sensorType); -+ sensorJson["ReadingUnits"] = sensors::toReadingUnits(sensorType); - } - else if (sensorType == "temperature") - { -@@ -2976,8 +3025,8 @@ inline void retrieveUriToDbusMap(const std::string& chassis, - const std::string& node, - SensorsAsyncResp::DataCompleteCb&& mapComplete) - { -- auto typesIt = sensors::dbus::types.find(node); -- if (typesIt == sensors::dbus::types.end()) -+ auto typesIt = sensors::dbus::paths.find(node); -+ if (typesIt == sensors::dbus::paths.end()) - { - BMCWEB_LOG_ERROR << "Wrong node provided : " << node; - mapComplete(boost::beast::http::status::bad_request, {}); -@@ -3027,7 +3076,7 @@ class SensorCollection : public Node - const std::string& chassisId = params[0]; - std::shared_ptr<SensorsAsyncResp> asyncResp = - std::make_shared<SensorsAsyncResp>( -- res, chassisId, sensors::dbus::types.at(sensors::node::sensors), -+ res, chassisId, sensors::dbus::paths.at(sensors::node::sensors), - sensors::node::sensors); - - auto getChassisCb = diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp index 61ca891..a8c8b03 100644 --- a/redfish-core/lib/telemetry_service.hpp @@ -528,28 +364,6 @@ index 61ca891..a8c8b03 100644 res.jsonValue["MetricReportDefinitions"]["@odata.id"] = "/redfish/v1/TelemetryService/MetricReportDefinitions"; res.jsonValue["MetricReports"]["@odata.id"] = -diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp -index 8e01bee..00acdf9 100644 ---- a/redfish-core/lib/thermal.hpp -+++ b/redfish-core/lib/thermal.hpp -@@ -48,7 +48,7 @@ class Thermal : public Node - } - const std::string& chassisName = params[0]; - auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>( -- res, chassisName, sensors::dbus::types.at(sensors::node::thermal), -+ res, chassisName, sensors::dbus::paths.at(sensors::node::thermal), - sensors::node::thermal); - - // TODO Need to get Chassis Redundancy information. -@@ -71,7 +71,7 @@ class Thermal : public Node - allCollections; - - auto asyncResp = std::make_shared<SensorsAsyncResp>( -- res, chassisName, sensors::dbus::types.at(sensors::node::thermal), -+ res, chassisName, sensors::dbus::paths.at(sensors::node::thermal), - sensors::node::thermal); - - if (!json_util::readJson(req, asyncResp->res, "Temperatures", -- -2.16.6 +2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch index 3df9fe5ae..f2ebce6e3 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch @@ -1,4 +1,4 @@ -From 14a429586fd8ccb82c72611fe3310860db2e643b Mon Sep 17 00:00:00 2001 +From efcd128a3d66fce33200fd4211ba5abf13a81375 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 4/4] Sync Telmetry service with EventService @@ -17,12 +17,12 @@ Tested: Change-Id: I2fc1841a6c9259a8bff30b34bddc0d4aabd41912 Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> --- - redfish-core/include/event_service_manager.hpp | 157 +++++++++---------------- - redfish-core/lib/metric_report.hpp | 28 +++-- - 2 files changed, 71 insertions(+), 114 deletions(-) + .../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 3db9f0c..5c5a6c1 100644 +index 148c703..27e41e3 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -14,6 +14,7 @@ @@ -33,7 +33,7 @@ index 3db9f0c..5c5a6c1 100644 #include "node.hpp" #include "registries.hpp" #include "registries/base_message_registry.hpp" -@@ -510,48 +511,29 @@ class Subscription +@@ -512,47 +513,32 @@ class Subscription } #endif @@ -62,8 +62,8 @@ index 3db9f0c..5c5a6c1 100644 - nlohmann::json metricValuesArray = nlohmann::json::array(); - for (const auto& it : readings) -+ nlohmann::json json; -+ if (!telemetry::fillReport(json, id, var)) ++ nlohmann::json msg; ++ if (!telemetry::fillReport(msg, id, var)) { - metricValuesArray.push_back({}); - nlohmann::json& entry = metricValuesArray.back(); @@ -74,9 +74,12 @@ index 3db9f0c..5c5a6c1 100644 - {"MetricProperty", property}, - {"MetricValue", std::to_string(value)}, - {"Timestamp", crow::utility::getDateTime(timestamp)}}; ++ BMCWEB_LOG_ERROR << "Failed to fill the MetricReport for DBus " ++ "Report with id " ++ << id; + return; } -- + - nlohmann::json msg = { - {"@odata.id", "/redfish/v1/TelemetryService/MetricReports/" + id}, - {"@odata.type", "#MetricReport.v1_3_0.MetricReport"}, @@ -86,43 +89,31 @@ index 3db9f0c..5c5a6c1 100644 - {"MetricReportDefinition", {{"@odata.id", metricReportDef}}}, - {"MetricValues", metricValuesArray}}; - -- this->sendEvent(msg.dump()); -+ this->sendEvent(json.dump()); + this->sendEvent( + msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace)); } - - void updateRetryConfig(const uint32_t retryAttempts, -@@ -1342,56 +1324,72 @@ class EventServiceManager +@@ -1348,75 +1334,6 @@ class EventServiceManager } #endif - - void getMetricReading(const std::string& service, - const std::string& objPath, const std::string& intf) -+ void unregisterMetricReportSignal() - { +- { - std::size_t found = objPath.find_last_of('/'); - if (found == std::string::npos) -+ if (matchTelemetryMonitor) - { +- { - BMCWEB_LOG_DEBUG << "Invalid objPath received"; - return; -+ BMCWEB_LOG_DEBUG << "Metrics report signal - Unregister"; -+ matchTelemetryMonitor.reset(); -+ matchTelemetryMonitor = nullptr; - } -+ } - +- } +- - std::string idStr = objPath.substr(found + 1); - if (idStr.empty()) -+ void registerMetricReportSignal() -+ { -+ if (!serviceEnabled || matchTelemetryMonitor) - { +- { - BMCWEB_LOG_DEBUG << "Invalid ID in objPath"; -+ BMCWEB_LOG_DEBUG << "Not registering metric report signal."; - return; - } - +- return; +- } +- - crow::connections::systemBus->async_method_call( - [idStr{std::move(idStr)}]( - const boost::system::error_code ec, @@ -130,120 +121,113 @@ index 3db9f0c..5c5a6c1 100644 - std::string, std::variant<int32_t, ReadingsObjType>>& - resp) { - if (ec) -+ BMCWEB_LOG_DEBUG << "Metrics report signal - Register"; -+ std::string matchStr = "type='signal',member='PropertiesChanged'," -+ "interface='org.freedesktop.DBus.Properties'," -+ "path_namespace=/xyz/openbmc_project/Telemetry/" -+ "Reports/TelemetryService," -+ "arg0=xyz.openbmc_project.Telemetry.Report"; -+ -+ matchTelemetryMonitor = std::make_shared<sdbusplus::bus::match::match>( -+ *crow::connections::systemBus, matchStr, -+ [this](sdbusplus::message::message& msg) { -+ if (msg.is_method_error()) - { +- { - BMCWEB_LOG_DEBUG - << "D-Bus call failed to GetAll metric readings."; -+ BMCWEB_LOG_ERROR << "TelemetryMonitor Signal error"; - return; - } - +- return; +- } +- - const int32_t* timestampPtr = - std::get_if<int32_t>(&resp["Timestamp"]); - if (!timestampPtr) -+ std::string intf; -+ std::vector<std::pair< -+ std::string, std::variant<telemetry::TimestampReadings>>> -+ props; -+ std::vector<std::string> invalidProp; -+ -+ msg.read(intf, props, invalidProp); -+ if (intf != "xyz.openbmc_project.Telemetry.Report") - { +- { - BMCWEB_LOG_DEBUG << "Failed to Get timestamp."; - return; - } - +- return; +- } +- - ReadingsObjType* readingsPtr = - std::get_if<ReadingsObjType>(&resp["Readings"]); - if (!readingsPtr) -+ const std::variant<telemetry::TimestampReadings>* varPtr = -+ nullptr; -+ for (const auto& [key, var] : props) -+ { -+ if (key == "Readings") -+ { -+ varPtr = &var; -+ break; -+ } -+ } -+ if (!varPtr) - { +- { - BMCWEB_LOG_DEBUG << "Failed to Get Readings property."; - return; - } - +- return; +- } +- - if (!readingsPtr->size()) -+ sdbusplus::message::object_path path(msg.get_path()); -+ std::string id = path.filename(); -+ if (id.empty()) - { +- { - BMCWEB_LOG_DEBUG << "No metrics report to be transferred"; -+ BMCWEB_LOG_ERROR << "Failed to get Id from path"; - return; - } - -@@ -1401,52 +1399,9 @@ class EventServiceManager - std::shared_ptr<Subscription> entry = it.second; - if (entry->eventFormatType == metricReportFormatType) - { +- return; +- } +- +- for (const auto& it : +- EventServiceManager::getInstance().subscriptionsMap) +- { +- std::shared_ptr<Subscription> entry = it.second; +- if (entry->eventFormatType == metricReportFormatType) +- { - entry->filterAndSendReports( - idStr, crow::utility::getDateTime(*timestampPtr), - *readingsPtr); -+ entry->filterAndSendReports(id, *varPtr); - } - } +- } +- } - }, - service, objPath, "org.freedesktop.DBus.Properties", "GetAll", - intf); - } - -- void unregisterMetricReportSignal() -- { -- if (matchTelemetryMonitor) -- { -- BMCWEB_LOG_DEBUG << "Metrics report signal - Unregister"; -- matchTelemetryMonitor.reset(); -- matchTelemetryMonitor = nullptr; -- } -- } -- -- void registerMetricReportSignal() -- { -- if (!serviceEnabled || matchTelemetryMonitor) -- { -- BMCWEB_LOG_DEBUG << "Not registering metric report signal."; -- return; -- } -- -- BMCWEB_LOG_DEBUG << "Metrics report signal - Register"; + void unregisterMetricReportSignal() + { + if (matchTelemetryMonitor) +@@ -1436,9 +1353,11 @@ class EventServiceManager + } + + BMCWEB_LOG_DEBUG << "Metrics report signal - Register"; - std::string matchStr( - "type='signal',member='ReportUpdate', " - "interface='xyz.openbmc_project.MonitoringService.Report'"); -- -- matchTelemetryMonitor = std::make_shared<sdbusplus::bus::match::match>( -- *crow::connections::systemBus, matchStr, -- [this](sdbusplus::message::message& msg) { -- if (msg.is_method_error()) -- { -- BMCWEB_LOG_ERROR << "TelemetryMonitor Signal error"; -- return; -- } -- ++ std::string matchStr = "type='signal',member='PropertiesChanged'," ++ "interface='org.freedesktop.DBus.Properties'," ++ "path_namespace=/xyz/openbmc_project/Telemetry/" ++ "Reports/TelemetryService," ++ "arg0=xyz.openbmc_project.Telemetry.Report"; + + matchTelemetryMonitor = std::make_shared<sdbusplus::bus::match::match>( + *crow::connections::systemBus, matchStr, +@@ -1449,10 +1368,43 @@ class EventServiceManager + return; + } + - std::string service = msg.get_sender(); - std::string objPath = msg.get_path(); - std::string intf = msg.get_interface(); - getMetricReading(service, objPath, intf); ++ sdbusplus::message::object_path path(msg.get_path()); ++ std::string id = path.filename(); ++ if (id.empty()) ++ { ++ BMCWEB_LOG_ERROR << "Failed to get Id from path"; ++ return; ++ } ++ ++ std::string intf; ++ std::vector<std::pair< ++ std::string, std::variant<telemetry::TimestampReadings>>> ++ props; ++ std::vector<std::string> invalidProps; ++ msg.read(intf, props, invalidProps); ++ ++ auto found = ++ std::find_if(props.begin(), props.end(), [](const auto& x) { ++ return x.first == "Readings"; ++ }); ++ if (found == props.end()) ++ { ++ BMCWEB_LOG_ERROR ++ << "Failed to get Readings from Report properties"; ++ return; ++ } ++ ++ std::variant<telemetry::TimestampReadings>& readings = ++ found->second; ++ for (const auto& it : ++ EventServiceManager::getInstance().subscriptionsMap) ++ { ++ Subscription& entry = *it.second.get(); ++ if (entry.eventFormatType == metricReportFormatType) ++ { ++ entry.filterAndSendReports(id, readings); ++ } ++ } }); } @@ -307,5 +291,5 @@ index 9caf4a3..e79a41c 100644 telemetry::service, reportPath, "org.freedesktop.DBus.Properties", "Get", -- -2.16.6 +2.17.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 35c6e90bc..cfb47a49b 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,11 +3,11 @@ Until change is integrated they will be manually merged here to enable feature i Current revisions: - Add POST and DELETE in MetricReportDefinitions - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/32536/58 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/32536/63 - Add support for MetricDefinition scheme - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/54 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/60 - Sync Telmetry service with EventService - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/21 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/26 |