dbus_utility: Support new ObjectMapper methods
The new ObjectMapper methods are added as part of
https://gerrit.openbmc.org/c/openbmc/phosphor-objmgr/+/70699
- GetAssociatedSubTreeById
- GetAssociatedSubTreePathsById
The two methods are meant to be used to replace places where two dbus
calls are used to get associated objects
Change-Id: Ia6dc198ea3c63b9d5a49ba09f1fa999381de8a7c
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index 11163de..5a53140 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -225,6 +225,44 @@
associatedPath, path, depth, interfaces);
}
+inline void getAssociatedSubTreeById(
+ const std::string& id, const std::string& path,
+ std::span<const std::string_view> subtreeInterfaces,
+ std::string_view association,
+ std::span<const std::string_view> endpointInterfaces,
+ std::function<void(const boost::system::error_code&,
+ const MapperGetSubTreeResponse&)>&& callback)
+{
+ crow::connections::systemBus->async_method_call(
+ [callback{std::move(callback)}](
+ const boost::system::error_code& ec,
+ const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTreeById", id,
+ path, subtreeInterfaces, association, endpointInterfaces);
+}
+
+inline void getAssociatedSubTreePathsById(
+ const std::string& id, const std::string& path,
+ std::span<const std::string_view> subtreeInterfaces,
+ std::string_view association,
+ std::span<const std::string_view> endpointInterfaces,
+ std::function<void(const boost::system::error_code&,
+ const MapperGetSubTreePathsResponse&)>&& callback)
+{
+ crow::connections::systemBus->async_method_call(
+ [callback{std::move(callback)}](
+ const boost::system::error_code& ec,
+ const MapperGetSubTreePathsResponse& subtreePaths) {
+ callback(ec, subtreePaths);
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTreePathsById", id,
+ path, subtreeInterfaces, association, endpointInterfaces);
+}
+
inline void getDbusObject(
const std::string& path, std::span<const std::string_view> interfaces,
std::function<void(const boost::system::error_code&,