From 22984074fa0ec13967fe95b93282de2294411c6b Mon Sep 17 00:00:00 2001 From: James Feist Date: Mon, 21 Oct 2019 16:10:49 -0700 Subject: Add Rebuilding to Drives When the xyz.openbmc_project.Drive.State has rebuilding set true, make the state Updating. Tested: { "@odata.context": "/redfish/v1/$metadata#Drive.Drive", "@odata.id": "/redfish/v1/Systems/system/Storage/1/Drive/Drive_1", "@odata.type": "#Drive.v1_2_0.Drive", "Id": "Drive_1", "Manufacturer": "INTEL", "Model": "P4800X", "Name": "Drive_1", "PartNumber": "INTEL SSDPE21K375GA", "SerialNumber": "PHKE722600NL375AGN", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Updating" } } Change-Id: I401e5a8c416d969831cebde8b5b0723f41c3e1c7 Signed-off-by: James Feist --- redfish-core/lib/storage.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'redfish-core/lib/storage.hpp') diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp index 3c4fe4c543..5554839c37 100644 --- a/redfish-core/lib/storage.hpp +++ b/redfish-core/lib/storage.hpp @@ -274,6 +274,35 @@ class Drive : public Node }, connectionName, path, "org.freedesktop.DBus.Properties", "Get", "xyz.openbmc_project.Inventory.Item", "Present"); + + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec, + const std::variant rebuilding) { + // this interface isn't necessary, only check it if we + // get a good return + if (ec) + { + return; + } + const bool *updating = std::get_if(&rebuilding); + if (updating == nullptr) + { + BMCWEB_LOG_DEBUG << "Illegal property present"; + messages::internalError(asyncResp->res); + return; + } + + // updating and disabled in the backend shouldn't be + // able to be set at the same time, so we don't need to + // check for the race condition of these two calls + if ((*updating)) + { + asyncResp->res.jsonValue["Status"]["State"] = + "Updating"; + } + }, + connectionName, path, "org.freedesktop.DBus.Properties", + "Get", "xyz.openbmc_project.State.Drive", "Rebuilding"); }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", -- cgit v1.2.3