Add lifetime property for drives interface
This will set the lifetime property when the eStoraged object is
created. This change does not expect the lifetime to change.
Tested:
busctl introspect xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/inventory/storage/mmcblk0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.Peer interface - - -
.GetMachineId method - s -
.Ping method - - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
xyz.openbmc_project.Inventory.Item.Drive interface - - -
.Capacity property t (top secret) emits-change
.PredictedMediaLifeLeftPercent property y 100 emits-change
xyz.openbmc_project.Inventory.Item.Volume interface - - -
.ChangePassword method ayay - -
.Erase method s - -
.FormatLuks method ays - -
.Lock method - - -
.Unlock method ay - -
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: Ifbbed7d81c55e3edbe519c2b1048b5d1731fbb0e
diff --git a/src/main.cpp b/src/main.cpp
index aea7904..ed360fb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,15 +23,20 @@
" -b <blockDevice> The phyical encrypted device\n"
" If omitted, default is /dev/mmcblk0.\n"
" -c <containerName> The LUKS container name to be created\n"
- " If omitted, default is luks-<devName>";
+ " If omitted, default is luks-<devName>"
+ " -s <sysfsDevice> The interface to kernel data\n"
+ " structures dealing with this drive.\n"
+ " If omitted, default is\n"
+ " /sys/block/mmcblk0/device/\n";
}
int main(int argc, char** argv)
{
std::string physicalBlockDev = "/dev/mmcblk0";
+ std::string sysfsDev = "/sys/block/mmcblk0/device";
std::string containerBlockDev;
int opt = 0;
- while ((opt = getopt(argc, argv, "b:c:")) != -1)
+ while ((opt = getopt(argc, argv, "b:c:s:")) != -1)
{
switch (opt)
{
@@ -41,6 +46,9 @@
case 'c':
containerBlockDev = optarg;
break;
+ case 's':
+ sysfsDev = optarg;
+ break;
default:
usage(*argv);
exit(EXIT_FAILURE);
@@ -68,7 +76,8 @@
estoraged::EStoraged esObject{
server, physicalBlockDev, containerBlockDev,
- estoraged::util::Util::findSizeOfBlockDevice(physicalBlockDev)};
+ estoraged::util::findSizeOfBlockDevice(physicalBlockDev),
+ estoraged::util::findPredictedMediaLifeLeftPercent(sysfsDev)};
lg2::info("Storage management service is running", "REDFISH_MESSAGE_ID",
std::string("OpenBMC.1.0.ServiceStarted"));