From cc6cdbf1d4111b0f29cc3dd37c61317a7abff58f Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Fri, 1 Sep 2017 23:06:25 +0530 Subject: GetLan: Support for get/set of ipsrc parameter Change-Id: Id9c52bb0963c5924f80f9e273b53ed5556b16a2c Signed-off-by: Ratan Gupta --- utils.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'utils.cpp') 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("Error in mapper call", + entry("PATH=%s", path.c_str()), + entry("INTERFACES=%s", + convertToString(interfaces).c_str())); + + elog(); + } + + ObjectTree objectTree; + mapperReply.read(objectTree); + + if (objectTree.empty()) + { + log("No Object has impelmented the interface", + entry("PATH=%s", path.c_str()), + entry("INTERFACES=%s", + convertToString(interfaces).c_str())); + elog(); + } + + return objectTree; +} namespace method_no_args { -- cgit v1.2.1