Populate Protocol property in Item.Drive interface
By populating this property, bmcweb can populate the "Protocol"
property in the Drive schema.
Tested:
$ busctl get-property xyz.openbmc_project.eStoraged \
/xyz/openbmc_project/inventory/storage/mmcblk0 \
xyz.openbmc_project.Inventory.Item.Drive Protocol
s "xyz.openbmc_project.Inventory.Item.Drive.DriveProtocol.eMMC"
Signed-off-by: John Wedig <johnwedig@google.com>
Change-Id: I2bd19190c445ce57f3d867ffbb437c1a4a370b51
diff --git a/include/estoraged.hpp b/include/estoraged.hpp
index 077b12e..57a1c26 100644
--- a/include/estoraged.hpp
+++ b/include/estoraged.hpp
@@ -47,6 +47,7 @@
* @param[in] eraseMaxGeometry - max geometry to erase if it's specified
* @param[in] eraseMinGeometry - min geometry to erase if it's specified
* @param[in] driveType - type of drive, e.g. HDD vs SSD
+ * @param[in] driveProtocol - protocol used to communicate with drive
* @param[in] cryptInterface - (optional) pointer to CryptsetupInterface
* object
* @param[in] fsInterface - (optional) pointer to FilesystemInterface
@@ -58,6 +59,7 @@
const std::string& partNumber, const std::string& serialNumber,
const std::string& locationCode, uint64_t eraseMaxGeometry,
uint64_t eraseMinGeometry, const std::string& driveType,
+ const std::string& driveProtocol,
std::unique_ptr<CryptsetupInterface> cryptInterface =
std::make_unique<Cryptsetup>(),
std::unique_ptr<FilesystemInterface> fsInterface =
diff --git a/include/util.hpp b/include/util.hpp
index 7cc778a..e1050ed 100644
--- a/include/util.hpp
+++ b/include/util.hpp
@@ -19,15 +19,17 @@
uint64_t eraseMaxGeometry;
uint64_t eraseMinGeometry;
std::string driveType;
+ std::string driveProtocol;
DeviceInfo(std::filesystem::path& deviceFile,
std::filesystem::path& sysfsDir, std::string& luksName,
std::string& locationCode, uint64_t eraseMaxGeometry,
- uint64_t eraseMinGeometry, std::string& driveType) :
+ uint64_t eraseMinGeometry, std::string& driveType,
+ std::string& driveProtocol) :
deviceFile(deviceFile),
sysfsDir(sysfsDir), luksName(luksName), locationCode(locationCode),
eraseMaxGeometry(eraseMaxGeometry), eraseMinGeometry(eraseMinGeometry),
- driveType(driveType)
+ driveType(driveType), driveProtocol(driveProtocol)
{}
};
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index d2ff1ef..88529b7 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -39,6 +39,7 @@
const std::string& serialNumber,
const std::string& locationCode, uint64_t eraseMaxGeometry,
uint64_t eraseMinGeometry, const std::string& driveType,
+ const std::string& driveProtocol,
std::unique_ptr<CryptsetupInterface> cryptInterface,
std::unique_ptr<FilesystemInterface> fsInterface) :
devPath(devPath),
@@ -90,6 +91,9 @@
driveInterface->register_property(
"Type",
"xyz.openbmc_project.Inventory.Item.Drive.DriveType." + driveType);
+ driveInterface->register_property(
+ "Protocol", "xyz.openbmc_project.Inventory.Item.Drive.DriveProtocol." +
+ driveProtocol);
/* This registers the Locked property for the Drives interface.
* Now it is the same as the volume Locked property */
driveInterface->register_property_r(
diff --git a/src/main.cpp b/src/main.cpp
index cb37791..6d92ecf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -99,12 +99,13 @@
std::string partNumber = estoraged::util::getPartNumber(sysfsDir);
std::string serialNumber =
estoraged::util::getSerialNumber(sysfsDir);
- std::string driveType = deviceInfo->driveType;
+ const std::string& driveType = deviceInfo->driveType;
+ const std::string& driveProtocol = deviceInfo->driveProtocol;
/* Create the storage object. */
storageObjects[path] = std::make_unique<estoraged::EStoraged>(
objectServer, path, deviceFile, luksName, size, lifeleft,
partNumber, serialNumber, locationCode, eraseMaxGeometry,
- eraseMinGeometry, driveType);
+ eraseMinGeometry, driveType, driveProtocol);
lg2::info("Created eStoraged object for path {PATH}", "PATH", path,
"REDFISH_MESSAGE_ID",
std::string("OpenBMC.0.1.CreateStorageObjects"));
diff --git a/src/test/estoraged_test.cpp b/src/test/estoraged_test.cpp
index 3d31112..5ad8f00 100644
--- a/src/test/estoraged_test.cpp
+++ b/src/test/estoraged_test.cpp
@@ -47,6 +47,7 @@
const std::string testSerialNumber = "ABCDEF1234";
const std::string testLocationCode = "U102020";
const std::string testDriveType = "SSD";
+ const std::string testDriveProtocol = "eMMC";
std::ofstream testFile;
std::string passwordString;
std::vector<uint8_t> password;
@@ -92,7 +93,8 @@
*objectServer, testConfigPath, testFileName, testLuksDevName,
testSize, testLifeTime, testPartNumber, testSerialNumber,
testLocationCode, ERASE_MAX_GEOMETRY, ERASE_MIN_GEOMETRY,
- testDriveType, std::move(cryptIface), std::move(fsIface));
+ testDriveType, testDriveProtocol, std::move(cryptIface),
+ std::move(fsIface));
}
void TearDown() override
diff --git a/src/test/util_test.cpp b/src/test/util_test.cpp
index 86e86e9..e2fdcc3 100644
--- a/src/test/util_test.cpp
+++ b/src/test/util_test.cpp
@@ -144,6 +144,7 @@
EXPECT_EQ(ERASE_MAX_GEOMETRY, result->eraseMaxGeometry);
EXPECT_EQ(ERASE_MIN_GEOMETRY, result->eraseMinGeometry);
EXPECT_EQ("SSD", result->driveType);
+ EXPECT_EQ("eMMC", result->driveProtocol);
/* Delete the dummy files. */
EXPECT_EQ(3U, std::filesystem::remove_all("mmcblk0"));
@@ -201,6 +202,7 @@
EXPECT_EQ(5566, result->eraseMaxGeometry);
EXPECT_EQ(1234, result->eraseMinGeometry);
EXPECT_EQ("SSD", result->driveType);
+ EXPECT_EQ("eMMC", result->driveProtocol);
/* Delete the dummy files. */
EXPECT_EQ(3U, std::filesystem::remove_all("mmcblk0"));
diff --git a/src/util.cpp b/src/util.cpp
index 7bccdb1..fc32f0e 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -203,15 +203,18 @@
}
/*
- * Determine the drive type to report for this device. Note that we only
- * support eMMC currently, so report an error for any other device types.
+ * Determine the drive type and protocol to report for this device. Note
+ * that we only support eMMC currently, so report an error for any other
+ * device types.
*/
std::string deviceType = std::get<std::string>(typeVariant);
- /* drive type to report in the Item.Drive dbus interface */
+ /* drive type and protocol to report in the Item.Drive dbus interface */
std::string driveType;
+ std::string driveProtocol;
if (deviceType.compare("EmmcDevice") == 0)
{
driveType = "SSD";
+ driveProtocol = "eMMC";
}
else
{
@@ -253,9 +256,10 @@
deviceFile /= deviceName;
std::string luksName = "luks-" + deviceName.string();
- return DeviceInfo{
- deviceFile, sysfsDir, luksName, locationCode,
- eraseMaxGeometry, eraseMinGeometry, driveType};
+ return DeviceInfo{deviceFile, sysfsDir,
+ luksName, locationCode,
+ eraseMaxGeometry, eraseMinGeometry,
+ driveType, driveProtocol};
}
}
catch (...)