Support for FRU name from entity manager config
Get the FRU name as published on dbus by entity manager config
if the entity manager fru decorator has a name specified.
This takes care of existing approach of picking names
from board/product name with following config, as well as
option to specify custom names.
```
"xyz.openbmc_project.Inventory.Decorator.FruDevice": {
"Bus": "$bus",
"Address": "$address",
"Name": "$PRODUCT_PRODUCT_NAME"
},
```
Change-Id: I5c772721f343e1a87d7a32bd149402aaa26e23e2
Signed-off-by: Shakeeb Pasha <shakeebbk@gmail.com>
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index f8380fd..cd7825f 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -600,6 +600,7 @@
{
return IPMI_CC_RESPONSE_ERROR;
}
+ std::string name;
#ifdef USING_ENTITY_MANAGER_DECORATORS
@@ -622,7 +623,7 @@
auto entity = std::find_if(
entities.begin(), entities.end(),
- [bus, address, &entityData](ManagedEntry& entry) {
+ [bus, address, &entityData, &name](ManagedEntry& entry) {
auto findFruDevice = entry.second.find(
"xyz.openbmc_project.Inventory.Decorator.FruDevice");
if (findFruDevice == entry.second.end())
@@ -646,6 +647,12 @@
return false;
}
+ auto fruName = findFruDevice->second.find("Name");
+ if (fruName != findFruDevice->second.end())
+ {
+ name = std::get<std::string>(fruName->second);
+ }
+
// At this point we found the device entry and should return
// true.
auto findIpmiDevice = entry.second.find(
@@ -669,18 +676,7 @@
#endif
- std::string name;
- auto findProductName = fruData->find("BOARD_PRODUCT_NAME");
- auto findBoardName = fruData->find("PRODUCT_PRODUCT_NAME");
- if (findProductName != fruData->end())
- {
- name = std::get<std::string>(findProductName->second);
- }
- else if (findBoardName != fruData->end())
- {
- name = std::get<std::string>(findBoardName->second);
- }
- else
+ if (name.empty())
{
name = "UNKNOWN";
}