mapper: Add GetAssociatedSubTreePathsById and GetAssociatedSubTreeById
dbus-interface change in:
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/69999
This commit implements two new methods: GetAssociatedSubTreePathsById
and GetAssociatedSubTreeById. These methods retrieve the paths of
associated endpoints corresponding to the provided identifier, filtering
based on their association with specified endpoint interfaces.
GetAssociatedSubTreePathsById returns the D-Bus paths of associated
endpoints, while GetAssociatedSubTreeById retrieves a dictionary of
D-Bus paths of associated endpoints mapped to corresponding services
associated with the provided identifier.
Tested:
'''
busctl call -j "xyz.openbmc_project.ObjectMapper" "/xyz/openbmc_project/object_mapper" \
"xyz.openbmc_project.ObjectMapper" "GetAssociatedSubTreePathsById" ssassas \
"chassis" \
"/xyz/openbmc_project/inventory" \
1 "xyz.openbmc_project.Inventory.Item.Chassis" \
"powered_by" \
1 "xyz.openbmc_project.Inventory.Item.PowerSupply"
{
"type" : "as",
"data" : [
[
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply2",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply3"
]
]
}
'''
Another example.
```
busctl call -j xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper \
xyz.openbmc_project.ObjectMapper GetAssociatedSubTreePathsById ssassas \
disk_backplane0 \
/xyz/openbmc_project/inventory \
1 xyz.openbmc_project.Inventory.Item.FabricAdapter \
connecting \
1 xyz.openbmc_project.Inventory.Connector.Port
{
"type" : "as",
"data" : [
[
"/xyz/openbmc_project/inventory/system/chassis/motherboard/disk_backplane0/dp0_connector0",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/disk_backplane0/dp0_connector1",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/disk_backplane0/dp0_connector2",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/disk_backplane0/dp0_connector3",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/disk_backplane0/dp0_connector4",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/disk_backplane0/dp0_connector5"
]
]
}
```
Change-Id: Id55a9b41fe70f7204543d92b5396888f6914a1d4
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
diff --git a/src/handler.hpp b/src/handler.hpp
index 515c937..f6d4d94 100644
--- a/src/handler.hpp
+++ b/src/handler.hpp
@@ -68,3 +68,51 @@
const sdbusplus::message::object_path& associationPath,
const sdbusplus::message::object_path& reqPath, int32_t depth,
std::vector<std::string>& interfaces);
+
+/**
+ * @brief Get the Associated Sub Tree Paths object by id
+ *
+ * @param interfaceMap Mapper Structure storing all associations
+ * @param associationMaps Map of association between objects
+ * @param id Identifier to search for the subtree
+ * @param objectPath Base path to search for the subtree
+ * @param subtreeInterfaces Interface filter for the subtree
+ * @param association The endpoint association
+ * @param endpointInterfaces Interface filter for the endpoint association
+ *
+ * Use getAssociatedSubTree and return only the dbus objects that
+ * are associated with the provided identifier, filtering based on on their
+ * endpoint association.
+ *
+ * @return std::vector<InterfaceMapType::value_type>
+ */
+std::vector<InterfaceMapType::value_type> getAssociatedSubTreeById(
+ const InterfaceMapType& interfaceMap,
+ const AssociationMaps& associationMaps, const std::string& id,
+ const std::string& objectPath, std::vector<std::string>& subtreeInterfaces,
+ const std::string& association,
+ std::vector<std::string>& endpointInterfaces);
+
+/**
+ * @brief Get the Associated Sub Tree Paths object by id
+ *
+ * @param interfaceMap Mapper Structure storing all associations
+ * @param associationMaps Map of association between objects
+ * @param id Identifier to search for the subtree
+ * @param objectPath Base path to search for the subtree
+ * @param subtreeInterfaces Interface filter for the subtree
+ * @param association The endpoint association
+ * @param endpointInterfaces Interface filter for the endpoint association
+ *
+ * Use getAssociatedSubTreePaths and return only the dbus objects that
+ * are associated with the provided identifier, filtering based on on their
+ * endpoint association.
+ *
+ * @return std::vector<std::string>
+ */
+std::vector<std::string> getAssociatedSubTreePathsById(
+ const InterfaceMapType& interfaceMap,
+ const AssociationMaps& associationMaps, const std::string& id,
+ const std::string& objectPath, std::vector<std::string>& subtreeInterfaces,
+ const std::string& association,
+ std::vector<std::string>& endpointInterfaces);