diff options
author | Jonathan Doman <jonathan.doman@intel.com> | 2021-06-11 19:36:17 +0300 |
---|---|---|
committer | Krzysztof Grobelny <krzysztof.grobelny@intel.com> | 2021-12-28 15:23:02 +0300 |
commit | 1e1e598df6d1d9530dde6e92d8f74f8143f60e50 (patch) | |
tree | b71aee4a4c50c79332e14d6e74094693888855a6 /redfish-core/include | |
parent | 168e20c1306e3e689907ba43e14ea679e2328611 (diff) | |
download | bmcweb-1e1e598df6d1d9530dde6e92d8f74f8143f60e50.tar.xz |
Using sdbusplus::asio::getProperty
It simplifies a lot of code and after changing sdbusplus implementation
slightly reduces binary size if used together with:
https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/49467
* Uncompressed size: 3033148 -> 3012164, -20984 B
* gzip compressed size: 1220586 -> 1214625, -5961 B
Tested:
- Redfish validator output is the same before and after the change
Change-Id: Ibe3227d3f4230de2363ba3d9396e51130c8240a5
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Diffstat (limited to 'redfish-core/include')
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 13 | ||||
-rw-r--r-- | redfish-core/include/utils/fw_utils.hpp | 52 |
2 files changed, 31 insertions, 34 deletions
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index 16af1be2a8..9349cd84b0 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -501,7 +501,7 @@ class Subscription : public persistent_data::UserSubscription #endif void filterAndSendReports(const std::string& id, - const dbus::utility::DbusVariantType& var) + const telemetry::TimestampReadings& var) { std::string mrdUri = telemetry::metricReportDefinitionUri + ("/" + id); @@ -1328,14 +1328,21 @@ class EventServiceManager return; } - const dbus::utility::DbusVariantType& readings = found->second; + const telemetry::TimestampReadings* readings = + std::get_if<telemetry::TimestampReadings>(&found->second); + if (!readings) + { + BMCWEB_LOG_INFO << "Failed to get Readings from Report properties"; + return; + } + for (const auto& it : EventServiceManager::getInstance().subscriptionsMap) { Subscription& entry = *it.second.get(); if (entry.eventFormatType == metricReportFormatType) { - entry.filterAndSendReports(id, readings); + entry.filterAndSendReports(id, *readings); } } } diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp index 658ca4d6d7..5477575bc7 100644 --- a/redfish-core/include/utils/fw_utils.hpp +++ b/redfish-core/include/utils/fw_utils.hpp @@ -1,6 +1,7 @@ #pragma once #include <async_resp.hpp> #include <dbus_utility.hpp> +#include <sdbusplus/asio/property.hpp> #include <algorithm> #include <string> @@ -38,10 +39,13 @@ inline void const bool populateLinkToImages) { // Used later to determine running (known on Redfish as active) FW images - crow::connections::systemBus->async_method_call( + sdbusplus::asio::getProperty<std::vector<std::string>>( + *crow::connections::systemBus, "xyz.openbmc_project.ObjectMapper", + "/xyz/openbmc_project/software/functional", + "xyz.openbmc_project.Association", "endpoints", [aResp, fwVersionPurpose, activeVersionPropName, populateLinkToImages](const boost::system::error_code ec, - const dbus::utility::DbusVariantType& resp) { + const std::vector<std::string>& functionalFw) { BMCWEB_LOG_DEBUG << "populateFirmwareInformation enter"; if (ec) { @@ -51,9 +55,7 @@ inline void return; } - const std::vector<std::string>* functionalFw = - std::get_if<std::vector<std::string>>(&resp); - if ((functionalFw == nullptr) || (functionalFw->size() == 0)) + if (functionalFw.size() == 0) { // Could keep going and try to populate SoftwareImages but // something is seriously wrong, so just fail @@ -66,7 +68,7 @@ inline void // example functionalFw: // v as 2 "/xyz/openbmc_project/software/ace821ef" // "/xyz/openbmc_project/software/230fb078" - for (auto& fw : *functionalFw) + for (auto& fw : functionalFw) { sdbusplus::message::object_path path(fw); std::string leaf = path.filename(); @@ -250,11 +252,7 @@ inline void "/xyz/openbmc_project/software", static_cast<int32_t>(0), std::array<const char*, 1>{ "xyz.openbmc_project.Software.Version"}); - }, - "xyz.openbmc_project.ObjectMapper", - "/xyz/openbmc_project/software/functional", - "org.freedesktop.DBus.Properties", "Get", - "xyz.openbmc_project.Association", "endpoints"); + }); return; } @@ -384,9 +382,12 @@ inline void getFwUpdateableStatus(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::shared_ptr<std::string>& fwId) { - crow::connections::systemBus->async_method_call( + sdbusplus::asio::getProperty<std::vector<std::string>>( + *crow::connections::systemBus, "xyz.openbmc_project.ObjectMapper", + "/xyz/openbmc_project/software/updateable", + "xyz.openbmc_project.Association", "endpoints", [asyncResp, fwId](const boost::system::error_code ec, - dbus::utility::DbusVariantType& resp) { + const std::vector<std::string>& objPaths) { if (ec) { BMCWEB_LOG_DEBUG << " error_code = " << ec @@ -395,26 +396,15 @@ inline void // so don't throw error here. return; } - const std::vector<std::string>* objPaths = - std::get_if<std::vector<std::string>>(&resp); - if (objPaths) - { - std::string reqFwObjPath = - "/xyz/openbmc_project/software/" + *fwId; + std::string reqFwObjPath = "/xyz/openbmc_project/software/" + *fwId; - if (std::find((*objPaths).begin(), (*objPaths).end(), - reqFwObjPath) != (*objPaths).end()) - { - asyncResp->res.jsonValue["Updateable"] = true; - return; - } + if (std::find(objPaths.begin(), objPaths.end(), reqFwObjPath) != + objPaths.end()) + { + asyncResp->res.jsonValue["Updateable"] = true; + return; } - return; - }, - "xyz.openbmc_project.ObjectMapper", - "/xyz/openbmc_project/software/updateable", - "org.freedesktop.DBus.Properties", "Get", - "xyz.openbmc_project.Association", "endpoints"); + }); return; } |