diff options
author | John Edward Broadbent <jebr@google.com> | 2022-05-07 00:42:35 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-09-02 03:54:20 +0300 |
commit | 3fe4d5cca464ff7696236fe42acf64637e9126d9 (patch) | |
tree | 9387b4c9b29c94497db1c6ae6307d4e42ad53e2b | |
parent | c1343bf6a51b22b85a0521050948ad6026027fc8 (diff) | |
download | bmcweb-3fe4d5cca464ff7696236fe42acf64637e9126d9.tar.xz |
redfish: Add the percent lifeleft to drive
The property known as "PredictedMediaLifeLeftPercent" was not
implemented in bmcweb. This change adds that property to bmcweb, and
exposes the value of PredictedMediaLifeLeftPercent to redfish clients.
More information about the interface can be found at the link below, or
in yaml/xyz/openbmc_project/Inventory/Item/Drive.interface.yaml.
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/47657/10/yaml/xyz/openbmc_project/Inventory/Item/Drive.interface.yaml#31
Tested:
Redfish Validator did not show any errors from this change.
$ wget -qO- http://localhost:80/redfish/v1/Chassis/DC_SCM/Drives/mmcblk0
{
"@odata.context": "/redfish/v1/$metadata#Drive.Drive",
"@odata.id": "/redfish/v1/Chassis/Drives/mmcblk0",
"@odata.type": "#Drive.v1_7_0.Drive",
"CapacityBytes": 15634268160,
"EncryptionStatus": "Unencrypted",
"Id": "mmcblk0",
"Links": {
"Chassis": "Enabled"
},
"Name": "mmcblk0",
"PredictedMediaLifeLeftPercent": 100,
"Status": {
"State": "Enabled"
}
}
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I360ce393707ba7a876810fc80f8a2d6fb484759c
-rw-r--r-- | redfish-core/lib/storage.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp index 51635ce10f..30b679deea 100644 --- a/redfish-core/lib/storage.hpp +++ b/redfish-core/lib/storage.hpp @@ -467,6 +467,24 @@ inline void } asyncResp->res.jsonValue["Protocol"] = *proto; } + else if (propertyName == "PredictedMediaLifeLeftPercent") + { + const uint8_t* lifeLeft = + std::get_if<uint8_t>(&property.second); + if (lifeLeft == nullptr) + { + BMCWEB_LOG_ERROR + << "Illegal property: PredictedMediaLifeLeftPercent"; + messages::internalError(asyncResp->res); + return; + } + // 255 means reading the value is not supported + if (*lifeLeft != 255) + { + asyncResp->res.jsonValue["PredictedMediaLifeLeftPercent"] = + *lifeLeft; + } + } } }); } |