common: utils: Add get ancestors mapper function

Add get ancestors mapper function. A use case is getting an inventory
item's parent path for its board or chassis.

Change-Id: I7a25c8e11f7662fd07147b7da3b8db9fbff5e00e
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/common/utils.cpp b/common/utils.cpp
index 6f39321..a5792f5 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -279,6 +279,21 @@
     return paths;
 }
 
+GetAncestorsResponse
+    DBusHandler::getAncestors(const std::string& searchPath,
+                              const std::vector<std::string>& ifaceList) const
+{
+    auto& bus = pldm::utils::DBusHandler::getBus();
+    auto method = bus.new_method_call(ObjectMapper::default_service,
+                                      ObjectMapper::instance_path,
+                                      ObjectMapper::interface, "GetAncestors");
+    method.append(searchPath, ifaceList);
+    auto reply = bus.call(method, dbusTimeout);
+    GetAncestorsResponse response;
+    reply.read(response);
+    return response;
+}
+
 void reportError(const char* errorMsg)
 {
     auto& bus = pldm::utils::DBusHandler::getBus();