Make lifetime property read/write
This commit makes the property PredictedMediaLifeLeftPercent
read-writable. This property is exposed through Redfish, so by making
this property read-writable, we can better test other things that
consume this property through Redfish.
Tested:
```
$ busctl get-property xyz.openbmc_project.eStoraged \
/xyz/openbmc_project/inventory/storage/mmcblk0 \
xyz.openbmc_project.Inventory.Item.Drive PredictedMediaLifeLeftPercent
y 100
$ busctl set-property xyz.openbmc_project.eStoraged \
/xyz/openbmc_project/inventory/storage/mmcblk0 \
xyz.openbmc_project.Inventory.Item.Drive PredictedMediaLifeLeftPercent y 90
$ curl localhost:80/redfish/v1/Chassis/dcscm/Drives/mmcblk0
{
...
"PredictedMediaLifeLeftPercent": 90,
...
}
```
Change-Id: I93bde64e76ee45640f85b00222df6e4a8a98ff4c
Signed-off-by: John Wedig <johnwedig@google.com>
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index e03fc4d..28290c4 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -27,6 +27,7 @@
{
using Association = std::tuple<std::string, std::string, std::string>;
+using sdbusplus::asio::PropertyPermission;
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
using sdbusplus::xyz::openbmc_project::Common::Error::UnsupportedRequest;
using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Drive;
@@ -85,8 +86,9 @@
driveInterface = objectServer.add_interface(
objectPath, "xyz.openbmc_project.Inventory.Item.Drive");
driveInterface->register_property("Capacity", size);
- driveInterface->register_property("PredictedMediaLifeLeftPercent",
- lifeTime);
+ /* The lifetime property is read/write only for testing purposes. */
+ driveInterface->register_property("PredictedMediaLifeLeftPercent", lifeTime,
+ PropertyPermission::readWrite);
driveInterface->register_property(
"Type",
"xyz.openbmc_project.Inventory.Item.Drive.DriveType." + driveType);