diff options
author | Santosh Puranik <santosh.puranik@in.ibm.com> | 2019-07-24 12:48:32 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2019-08-02 20:59:18 +0300 |
commit | 94e1b82826762404589e61904139bba3a86964bd (patch) | |
tree | 909f2b3a05fbba3a1a508ede7f2d847c3573256a /redfish-core | |
parent | 897967def41b35ec39069bee365eeee8a1111bd9 (diff) | |
download | bmcweb-94e1b82826762404589e61904139bba3a86964bd.tar.xz |
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 <santosh.puranik@in.ibm.com>
Change-Id: Ic5ccc9bcd3b2b245ffdd714105d5b4fed3ca4ea4
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/cpudimm.hpp | 16 |
1 files 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<AsyncResp> aResp, [acclrtrId, aResp{std::move(aResp)}]( const boost::system::error_code ec, const boost::container::flat_map< - std::string, std::variant<std::string, uint32_t, uint16_t>> - &properties) { + std::string, std::variant<std::string, uint32_t, uint16_t, + bool>> &properties) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error"; @@ -176,19 +176,19 @@ void getAcceleratorDataByService(std::shared_ptr<AsyncResp> 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<std::string>(&property.second); + accFunctional = std::get_if<bool>(&property.second); } else if (property.first == "Present") { - accPresent = std::get_if<std::string>(&property.second); + accPresent = std::get_if<bool>(&property.second); } } @@ -200,11 +200,11 @@ void getAcceleratorDataByService(std::shared_ptr<AsyncResp> aResp, return; } - if ((*accPresent == "Present") && (*accFunctional == "Functional")) + if (*accPresent && *accFunctional) { state = "Enabled"; } - else if (*accPresent == "Present") + else if (*accPresent) { state = "UnavailableOffline"; } |