summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Sync-Telmetry-service-with-EventService.patch224
1 files changed, 104 insertions, 120 deletions
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