oem-ibm: Adding entity path correction function
This commit introduces enhancements to rectify entity paths over DBus.
Formerly, the conventional DBus path involved appending an instance
number, such as 'system' becoming 'system1', 'motherboard' becoming
'motherboard1', and 'chassis' becoming 'chassis1'. This function is
designed to align with IBM's specific use case, ensuring the numbering
system adheres appropriately.
Testing:
Unit tests passed
Change-Id: I671f8486078054b44110ffa2cbf169c63d164cf1
Signed-off-by: Kamalkumar Patel <kamalkumar.patel@ibm.com>
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 13d83a1..f6a1a04 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -631,7 +631,7 @@
if (!nextRecordHandle)
{
updateEntityAssociation(entityAssociations, entityTree, objPathMap,
- entityMaps);
+ entityMaps, oemPlatformHandler);
/*received last record*/
this->parseStateSensorPDRs(stateSensorPDRs);
diff --git a/host-bmc/test/utils_test.cpp b/host-bmc/test/utils_test.cpp
index 373274f..8caa68d 100644
--- a/host-bmc/test/utils_test.cpp
+++ b/host-bmc/test/utils_test.cpp
@@ -89,7 +89,8 @@
ObjectPathMaps objPathMap;
EntityMaps entityMaps = parseEntityMap("./entitymap_test.json");
- updateEntityAssociation(entityAssociations, tree, objPathMap, entityMaps);
+ updateEntityAssociation(entityAssociations, tree, objPathMap, entityMaps,
+ nullptr);
EXPECT_EQ(objPathMap.size(), retObjectMaps.size());
diff --git a/host-bmc/utils.cpp b/host-bmc/utils.cpp
index a178d48..6c1b818 100644
--- a/host-bmc/utils.cpp
+++ b/host-bmc/utils.cpp
@@ -56,11 +56,10 @@
return parents;
}
-void addObjectPathEntityAssociations(const EntityAssociations& entityAssoc,
- pldm_entity_node* entity,
- const fs::path& path,
- ObjectPathMaps& objPathMap,
- EntityMaps entityMaps)
+void addObjectPathEntityAssociations(
+ const EntityAssociations& entityAssoc, pldm_entity_node* entity,
+ const fs::path& path, ObjectPathMaps& objPathMap, EntityMaps entityMaps,
+ pldm::responder::oem_platform::Handler* oemPlatformHandler)
{
if (entity == nullptr)
{
@@ -98,6 +97,10 @@
std::to_string(
node_entity.entity_instance_num)};
std::string entity_path = p.string();
+ if (oemPlatformHandler)
+ {
+ oemPlatformHandler->updateOemDbusPaths(entity_path);
+ }
// If the entity obtained from the remote PLDM terminal is not in
// the MAP, or there is no auxiliary name PDR, add it directly.
// Otherwise, check whether the DBus service of entity_path exists,
@@ -122,7 +125,8 @@
for (size_t i = 1; i < ev.size(); i++)
{
addObjectPathEntityAssociations(entityAssoc, ev[i], p,
- objPathMap, entityMaps);
+ objPathMap, entityMaps,
+ oemPlatformHandler);
}
found = true;
}
@@ -133,6 +137,10 @@
std::string dbusPath =
path / fs::path{entityName +
std::to_string(node_entity.entity_instance_num)};
+ if (oemPlatformHandler)
+ {
+ oemPlatformHandler->updateOemDbusPaths(dbusPath);
+ }
try
{
pldm::utils::DBusHandler().getService(dbusPath.c_str(), nullptr);
@@ -144,9 +152,11 @@
}
}
-void updateEntityAssociation(const EntityAssociations& entityAssoc,
- pldm_entity_association_tree* entityTree,
- ObjectPathMaps& objPathMap, EntityMaps entityMaps)
+void updateEntityAssociation(
+ const EntityAssociations& entityAssoc,
+ pldm_entity_association_tree* entityTree, ObjectPathMaps& objPathMap,
+ EntityMaps entityMaps,
+ pldm::responder::oem_platform::Handler* oemPlatformHandler)
{
std::vector<pldm_entity_node*> parentsEntity =
getParentEntites(entityAssoc);
@@ -202,7 +212,7 @@
}
addObjectPathEntityAssociations(entityAssoc, entity, path, objPathMap,
- entityMaps);
+ entityMaps, oemPlatformHandler);
}
}
diff --git a/host-bmc/utils.hpp b/host-bmc/utils.hpp
index 2b0e2a7..6a3629e 100644
--- a/host-bmc/utils.hpp
+++ b/host-bmc/utils.hpp
@@ -35,9 +35,11 @@
* BMC's entity association tree
* @return
*/
-void updateEntityAssociation(const EntityAssociations& entityAssoc,
- pldm_entity_association_tree* entityTree,
- ObjectPathMaps& objPathMap, EntityMaps entityMaps);
+void updateEntityAssociation(
+ const EntityAssociations& entityAssoc,
+ pldm_entity_association_tree* entityTree, ObjectPathMaps& objPathMap,
+ EntityMaps entityMaps,
+ pldm::responder::oem_platform::Handler* oemPlatformHandler);
/** @brief Parsing entity to DBus string mapping from json file
*