summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-01-19 16:42:49 -0600
committerMatthew Barth <msbarth@us.ibm.com>2018-03-06 13:45:15 -0600
commiteca94df80661480e703b43e4adfb90363c415e66 (patch)
tree44454a3b022d73e11c9b5ed35fe5917b207fb1bd
parente3d1c4a9f155cdd05660eb1cf5c334972a5b0aea (diff)
downloadphosphor-fan-presence-eca94df80661480e703b43e4adfb90363c415e66.tar.gz
phosphor-fan-presence-eca94df80661480e703b43e4adfb90363c415e66.zip
Add GetSubTree method for single interface
Perform a GetSubTree mapper call and return the mapper response structure as is for a single interface over a given path subtree depth. Tested: Returned subtree structure matches mapper structure for an interface Returned subtree data matches mapper data for an interface Change-Id: If6b66433a331ac20633ac99c458eb5edb653bff2 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r--sdbusplus.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 1efe54d..3fc9b9e 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -128,6 +128,44 @@ class SDBusPlus
std::forward<Args>(args)...);
}
+ /** @brief Get subtree from the mapper. */
+ static auto getSubTree(
+ sdbusplus::bus::bus& bus,
+ const std::string& path,
+ const std::string& interface,
+ int32_t depth)
+ {
+ using namespace std::literals::string_literals;
+
+ using Path = std::string;
+ using Intf = std::string;
+ using Serv = std::string;
+ using Intfs = std::vector<Intf>;
+ using Objects = std::map<Path, std::map<Serv, Intfs>>;
+ Intfs intfs = {interface};
+
+ auto mapperResp = callMethodAndRead<Objects>(
+ bus,
+ "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s,
+ "GetSubTree"s,
+ path,
+ depth,
+ intfs);
+
+ if (mapperResp.empty())
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Empty response from mapper GetSubTree",
+ phosphor::logging::entry("SUBTREE=%s", path.c_str()),
+ phosphor::logging::entry(
+ "INTERFACE=%s", interface.c_str()),
+ phosphor::logging::entry("DEPTH=%u", depth));
+ phosphor::logging::elog<detail::errors::InternalFailure>();
+ }
+ return mapperResp;
+ }
/** @brief Get service from the mapper. */
static auto getService(
OpenPOWER on IntegriCloud