From 94e1b82826762404589e61904139bba3a86964bd Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Wed, 24 Jul 2019 04:48:32 -0500 Subject: Fixed Accelerator State This commit fixes a bug in getAcceleratorDataByService when looking up the Present and Functional properties on D-Bus. The properties are booleans, but the code was trying to read them as strings. Tested: -- Redfish validator comes out clean -- Tested various combinations of present and functional properties on the GPU inventory objects: xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0 xyz.openbmc_project.State.Decorator.OperationalStatus Functional b "false" /xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0 xyz.openbmc_project.Inventory.Item Present b "true" $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/Processors/gv100card0 { "@odata.context": "/redfish/v1/$metadata#Processor.Processor", "@odata.id": "/redfish/v1/Systems/system/Processors/gv100card0", "@odata.type": "#Processor.v1_3_1.Processor", "Id": "gv100card0", "Name": "Processor", "ProcessorType": "Accelerator", "Status": { "Health": "OK", "State": "UnavailableOffline" } Set functional but not present: $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/Processors/gv100card0 { "@odata.context": "/redfish/v1/$metadata#Processor.Processor", "@odata.id": "/redfish/v1/Systems/system/Processors/gv100card0", "@odata.type": "#Processor.v1_3_1.Processor", "Id": "gv100card0", "Name": "Processor", "ProcessorType": "Accelerator", "Status": { "Health": "OK", "State": "Absent" } Set functional and present: $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/Processors/gv100card0 { "@odata.context": "/redfish/v1/$metadata#Processor.Processor", "@odata.id": "/redfish/v1/Systems/system/Processors/gv100card0", "@odata.type": "#Processor.v1_3_1.Processor", "Id": "gv100card0", "Name": "Processor", "ProcessorType": "Accelerator", "Status": { "Health": "OK", "State": "Enabled" } Set not functional and not present: $ curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/Processors/gv100card0 { "@odata.context": "/redfish/v1/$metadata#Processor.Processor", "@odata.id": "/redfish/v1/Systems/system/Processors/gv100card0", "@odata.type": "#Processor.v1_3_1.Processor", "Id": "gv100card0", "Name": "Processor", "ProcessorType": "Accelerator", "Status": { "Health": "OK", "State": "Absent" } Signed-off-by: Santosh Puranik Change-Id: Ic5ccc9bcd3b2b245ffdd714105d5b4fed3ca4ea4 --- redfish-core/lib/cpudimm.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp index 5601325614..263ef8e696 100644 --- a/redfish-core/lib/cpudimm.hpp +++ b/redfish-core/lib/cpudimm.hpp @@ -166,8 +166,8 @@ void getAcceleratorDataByService(std::shared_ptr aResp, [acclrtrId, aResp{std::move(aResp)}]( const boost::system::error_code ec, const boost::container::flat_map< - std::string, std::variant> - &properties) { + std::string, std::variant> &properties) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -176,19 +176,19 @@ void getAcceleratorDataByService(std::shared_ptr aResp, } aResp->res.jsonValue["Id"] = acclrtrId; aResp->res.jsonValue["Name"] = "Processor"; - const std::string *accPresent = nullptr; - const std::string *accFunctional = nullptr; + const bool *accPresent = nullptr; + const bool *accFunctional = nullptr; std::string state = ""; for (const auto &property : properties) { if (property.first == "Functional") { - accFunctional = std::get_if(&property.second); + accFunctional = std::get_if(&property.second); } else if (property.first == "Present") { - accPresent = std::get_if(&property.second); + accPresent = std::get_if(&property.second); } } @@ -200,11 +200,11 @@ void getAcceleratorDataByService(std::shared_ptr aResp, return; } - if ((*accPresent == "Present") && (*accFunctional == "Functional")) + if (*accPresent && *accFunctional) { state = "Enabled"; } - else if (*accPresent == "Present") + else if (*accPresent) { state = "UnavailableOffline"; } -- cgit v1.2.3