From 382d64759b0848f18bad9e0d85a8291529ced0e9 Mon Sep 17 00:00:00 2001 From: Ali Ahmed Date: Fri, 3 Sep 2021 16:53:53 -0500 Subject: Move nested dbus calls in getComputerSystem Dbus calls to dbus objects 'xyz.openbmc_project.Inventory.Item' and and 'xyz.openbmc_project.State.Decorator.OperationalStatus' are nested under a call for 'xyz.openbmc_project.Inventory.Item.Cpu' properties. This change seperates these calls for clarity and to minimize variables Testing: 1. Redfish Validator Testing passed 2. Curl testing: curl -k -H "X-Auth-Token: $tok" https://$bmc/redfish/v1/Systems/system ... "ProcessorSummary": { "CoreCount": 0, "Count": 2, "Model": "", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" } }, ... Signed-off-by: Ali Ahmed Change-Id: Id4657836607a2261a188db8d565aaa2b1a414c5a Signed-off-by: Shantappa Teekappanavar --- redfish-core/lib/systems.hpp | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 230598b809..76fcd59caa 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -126,46 +126,14 @@ inline void } } -inline void - getProcessorProperties(const std::shared_ptr& aResp, - const std::string& service, const std::string& path, - const dbus::utility::DBusPropertiesMap& properties) +inline void getProcessorProperties( + const std::shared_ptr& aResp, + const std::vector>& + properties) { BMCWEB_LOG_DEBUG << "Got " << properties.size() << " Cpu properties."; - auto getCpuPresenceState = [aResp](const boost::system::error_code ec3, - const bool cpuPresenceCheck) { - if (ec3) - { - BMCWEB_LOG_ERROR << "DBUS response error " << ec3; - return; - } - modifyCpuPresenceState(aResp, cpuPresenceCheck); - }; - - auto getCpuFunctionalState = [aResp](const boost::system::error_code ec3, - const bool cpuFunctionalCheck) { - if (ec3) - { - BMCWEB_LOG_ERROR << "DBUS response error " << ec3; - return; - } - modifyCpuFunctionalState(aResp, cpuFunctionalCheck); - }; - - // Get the Presence of CPU - sdbusplus::asio::getProperty( - *crow::connections::systemBus, service, path, - "xyz.openbmc_project.Inventory.Item", "Present", - std::move(getCpuPresenceState)); - - // Get the Functional State - sdbusplus::asio::getProperty( - *crow::connections::systemBus, service, path, - "xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional", - std::move(getCpuFunctionalState)); - // TODO: Get Model const uint16_t* coreCount = nullptr; @@ -210,6 +178,38 @@ inline void getProcessorSummary(const std::shared_ptr& aResp, const std::string& path) { + auto getCpuPresenceState = [aResp](const boost::system::error_code ec3, + const bool cpuPresenceCheck) { + if (ec3) + { + BMCWEB_LOG_ERROR << "DBUS response error " << ec3; + return; + } + modifyCpuPresenceState(aResp, cpuPresenceCheck); + }; + + auto getCpuFunctionalState = [aResp](const boost::system::error_code ec3, + const bool cpuFunctionalCheck) { + if (ec3) + { + BMCWEB_LOG_ERROR << "DBUS response error " << ec3; + return; + } + modifyCpuFunctionalState(aResp, cpuFunctionalCheck); + }; + + // Get the Presence of CPU + sdbusplus::asio::getProperty( + *crow::connections::systemBus, service, path, + "xyz.openbmc_project.Inventory.Item", "Present", + std::move(getCpuPresenceState)); + + // Get the Functional State + sdbusplus::asio::getProperty( + *crow::connections::systemBus, service, path, + "xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional", + std::move(getCpuFunctionalState)); + sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, path, "xyz.openbmc_project.Inventory.Item.Cpu", @@ -222,7 +222,7 @@ inline void getProcessorSummary(const std::shared_ptr& aResp, messages::internalError(aResp->res); return; } - getProcessorProperties(aResp, service, path, properties); + getProcessorProperties(aResp, properties); }); } -- cgit v1.2.3