diff options
author | Ratan Gupta <ratagupt@linux.vnet.ibm.com> | 2019-05-03 19:20:28 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2019-05-24 00:27:16 +0300 |
commit | 22c33710fed78a5c47446ee91ececf8b8ab104db (patch) | |
tree | 3b71d3986558acd3f244741777585b91296e4d03 /include/dbus_utility.hpp | |
parent | 8a07d286c0af4a6e17b2a41492a46e25c036d2b9 (diff) | |
download | bmcweb-22c33710fed78a5c47446ee91ececf8b8ab104db.tar.xz |
Redfish: Move checkDbusPathExist function to dbus utility
This function is a utility function which would be needed
by other files.
TestedBy: ran the redfish validator: PASS
Change-Id: I2a0d07f264952f47a724da11f72b15ca5e019d62
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Diffstat (limited to 'include/dbus_utility.hpp')
-rw-r--r-- | include/dbus_utility.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp index bb2bd650ab..2dd3d97003 100644 --- a/include/dbus_utility.hpp +++ b/include/dbus_utility.hpp @@ -89,5 +89,22 @@ inline bool getNthStringFromPath(const std::string& path, int index, return true; } +template <typename Callback> +inline void checkDbusPathExists(const std::string& path, Callback&& callback) +{ + using GetObjectType = + std::vector<std::pair<std::string, std::vector<std::string>>>; + + crow::connections::systemBus->async_method_call( + [callback{std::move(callback)}](const boost::system::error_code ec, + const GetObjectType& object_names) { + callback(!ec && object_names.size() != 0); + }, + "xyz.openbmc_project.ObjectMapper", + "/xyz/openbmc_project/object_mapper", + "xyz.openbmc_project.ObjectMapper", "GetObject", path, + std::array<std::string, 0>()); +} + } // namespace utility } // namespace dbus |