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/transporthandler.cpp b/transporthandler.cpp
index 0c6e4ac..669728e 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -1,5 +1,6 @@
#include "transporthandler.hpp"
+#include <ipmid/utils.hpp>
#include <stdplus/net/addr/subnet.hpp>
#include <stdplus/raw.hpp>
@@ -83,13 +84,9 @@
}
// Enumerate all VLAN + ETHERNET interfaces
- auto req = bus.new_method_call(MAPPER_BUS_NAME, MAPPER_OBJ, MAPPER_INTF,
- "GetSubTree");
- req.append(std::string_view(PATH_ROOT), 0,
- std::vector<std::string>{INTF_VLAN, INTF_ETHERNET});
- auto reply = bus.call(req);
- ObjectTree objs;
- reply.read(objs);
+ std::vector<std::string> interfaces = {INTF_VLAN, INTF_ETHERNET};
+ ipmi::ObjectTree objs = ipmi::getSubTree(bus, interfaces,
+ std::string{PATH_ROOT});
ChannelParams params;
for (const auto& [path, impls] : objs)
@@ -481,13 +478,9 @@
void deconfigureChannel(sdbusplus::bus_t& bus, ChannelParams& params)
{
// Delete all objects associated with the interface
- auto objreq = bus.new_method_call(MAPPER_BUS_NAME, MAPPER_OBJ, MAPPER_INTF,
- "GetSubTree");
- objreq.append(std::string_view(PATH_ROOT), 0,
- std::vector<std::string>{DELETE_INTERFACE});
- auto objreply = bus.call(objreq);
- ObjectTree objs;
- objreply.read(objs);
+ ObjectTree objs =
+ ipmi::getSubTree(bus, std::vector<std::string>{DELETE_INTERFACE},
+ std::string{PATH_ROOT});
for (const auto& [path, impls] : objs)
{
if (!ifnameInPath(params.ifname, path))