Add support for LocationCode
LocationCode is needed to populate ServiceLabel by BMCWeb for Redfish
resource associated with eStorage.
LocationCode is derived from config object exported by Entity Manager
in the the following interface:
"xyz.openbmc_project.Configuration.EmmcDevice
To surface LocationCode, the "Exposes" entry in board's Entity Manager
config can add "LocationCode" property as follows:
{
"Name": "example_emmc",
"Type": "EmmcDevice",
"LocationCode": "U1000"
}
Here the LocationCode is the silk screen label.
Tested:
busctl introspect xyz.openbmc_project.eStoraged \
/xyz/openbmc_project/inventory/storage/mmcblk0 \
xyz.openbmc_project.Inventory.Decorator.LocationCode
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.LocationCode property s "U1000" emits-change
wget -qO- localhost:80/redfish/v1/Chassis/DCSCM/Drives/mmcblk0
{
"@odata.id": "/redfish/v1/Chassis/DCSCM/Drives/mmcblk0",
"@odata.type": "#Drive.v1_7_0.Drive",
"Id": "mmcblk0",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/DCSCM"
}
},
"Name": "mmcblk0",
"PhysicalLocation": {
"PartLocation": {
"LocationType": "Embedded",
"ServiceLabel": "U1000"
},
"PartLocationContext": "DC_SCM"
},
"PredictedMediaLifeLeftPercent": 100,
"Status": {
"State": "Enabled"
}
}
Change-Id: Ibf53ede5ee65787f9cef53d4bad4cb8fccba3606
Signed-off-by: Rahul Kapoor <rahulkpr@google.com>
diff --git a/src/util.cpp b/src/util.cpp
index 8aad066..2f32c02 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -144,7 +144,8 @@
bool findDevice(const StorageData& data, const std::filesystem::path& searchDir,
std::filesystem::path& deviceFile,
- std::filesystem::path& sysfsDir, std::string& luksName)
+ std::filesystem::path& sysfsDir, std::string& luksName,
+ std::string& locationCode)
{
/* Check what type of storage device this is. */
estoraged::BasicVariantType typeVariant;
@@ -160,6 +161,18 @@
return false;
}
+ /* Check if location code/ silkscreen name is provided for the drive. */
+ auto findLocationCode = data.find("LocationCode");
+ if (findLocationCode != data.end())
+ {
+ const std::string* locationCodePtr =
+ std::get_if<std::string>(&findLocationCode->second);
+ if (locationCodePtr != nullptr)
+ {
+ locationCode = *locationCodePtr;
+ }
+ }
+
/*
* Currently, we only support eMMC, so report an error for any other device
* types.