Refactor to call the GetSubTree method
Uniformly use the getSubTree method of utils.hpp to obtain objectTree
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I20204745a01c50f053db74a5749a070bc8193d39
diff --git a/settings.cpp b/settings.cpp
index e76694f..93eb094 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -19,30 +19,19 @@
Objects::Objects(sdbusplus::bus_t& bus, const std::vector<Interface>& filter) :
bus(bus)
{
- auto depth = 0;
-
- auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf,
- "GetSubTree");
- mapperCall.append(root);
- mapperCall.append(depth);
- mapperCall.append(filter);
-
- using Interfaces = std::vector<Interface>;
- using MapperResponse = std::map<Path, std::map<Service, Interfaces>>;
- MapperResponse result;
+ ipmi::ObjectTree objectTree;
try
{
- auto response = bus.call(mapperCall);
- response.read(result);
+ objectTree = ipmi::getSubTree(bus, filter);
}
catch (const std::exception& e)
{
- log<level::ERR>("Error in mapper GetSubTree",
+ log<level::ERR>("Failed to call the getSubTree method.",
entry("ERROR=%s", e.what()));
elog<InternalFailure>();
}
- for (auto& iter : result)
+ for (auto& iter : objectTree)
{
const auto& path = iter.first;
for (auto& interface : iter.second.begin()->second)