summaryrefslogtreecommitdiffstats
path: root/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils.cpp')
-rw-r--r--utils.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/utils.cpp b/utils.cpp
index 2e6c5e7..d81bf76 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -276,6 +276,51 @@ void deleteAllDbusObjects(sdbusplus::bus::bus& bus,
}
}
+ObjectTree getAllAncestors(sdbusplus::bus::bus& bus,
+ const std::string& path,
+ InterfaceList&& interfaces)
+{
+ auto convertToString = [](InterfaceList& interfaces) -> std::string
+ {
+ std::string intfStr;
+ for (const auto& intf : interfaces)
+ {
+ intfStr += "," + intf;
+ }
+ return intfStr;
+ };
+
+ auto mapperCall = bus.new_method_call(MAPPER_BUS_NAME,
+ MAPPER_OBJ,
+ MAPPER_INTF,
+ "GetAncestors");
+ mapperCall.append(path, interfaces);
+
+ auto mapperReply = bus.call(mapperCall);
+ if (mapperReply.is_method_error())
+ {
+ log<level::ERR>("Error in mapper call",
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACES=%s",
+ convertToString(interfaces).c_str()));
+
+ elog<InternalFailure>();
+ }
+
+ ObjectTree objectTree;
+ mapperReply.read(objectTree);
+
+ if (objectTree.empty())
+ {
+ log<level::ERR>("No Object has impelmented the interface",
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACES=%s",
+ convertToString(interfaces).c_str()));
+ elog<InternalFailure>();
+ }
+
+ return objectTree;
+}
namespace method_no_args
{
OpenPOWER on IntegriCloud