summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Edward Broadbent <jebr@google.com>2022-05-07 00:42:35 +0300
committerEd Tanous <ed@tanous.net>2022-09-02 03:54:20 +0300
commit3fe4d5cca464ff7696236fe42acf64637e9126d9 (patch)
tree9387b4c9b29c94497db1c6ae6307d4e42ad53e2b
parentc1343bf6a51b22b85a0521050948ad6026027fc8 (diff)
downloadbmcweb-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.hpp18
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;
+ }
+ }
}
});
}