summaryrefslogtreecommitdiff
path: root/include/openbmc_dbus_rest.hpp
diff options
context:
space:
mode:
authorGeorge Liu <liuxiwei@inspur.com>2023-01-11 11:27:13 +0300
committerGeorge Liu <liuxiwei@inspur.com>2023-01-19 03:27:03 +0300
commit2b73119c57d054d1a0d67b376ae5651fccfae5ba (patch)
tree9e7824d11af9084d59bf700250238bf7860142cd /include/openbmc_dbus_rest.hpp
parent703f67418ae1915e49ac32d475de872da3ab2819 (diff)
downloadbmcweb-2b73119c57d054d1a0d67b376ae5651fccfae5ba.tar.xz
Add the GetObject method to dbus_utility
There are currently many files that use the GetObject method. Since they are a general method, they are defined in the dbus_utility.hpp file and refactors them. Tested: Built bmcweb successfully and Validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If2af77294389b023b611987252ee6149906fcd25
Diffstat (limited to 'include/openbmc_dbus_rest.hpp')
-rw-r--r--include/openbmc_dbus_rest.hpp55
1 files changed, 20 insertions, 35 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 61eaa6e8c7..948bc367e5 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -406,8 +406,9 @@ inline void findObjectManagerPathForEnumerate(
inline void getObjectAndEnumerate(
const std::shared_ptr<InProgressEnumerateData>& transaction)
{
- crow::connections::systemBus->async_method_call(
- [transaction](const boost::system::error_code ec,
+ dbus::utility::getDbusObject(
+ transaction->objectPath, {},
+ [transaction](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& objects) {
if (ec)
{
@@ -466,11 +467,7 @@ inline void getObjectAndEnumerate(
transaction->objectPath, connection.first, transaction);
}
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject",
- transaction->objectPath, std::array<const char*, 0>());
+ });
}
// Structure for storing data on an in progress action
@@ -1571,9 +1568,10 @@ inline void handleAction(const crow::Request& req,
transaction->path = objectPath;
transaction->methodName = methodName;
transaction->arguments = std::move(*data);
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getDbusObject(
+ objectPath, {},
[transaction](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const std::vector<std::pair<std::string, std::vector<std::string>>>&
interfaceNames) {
if (ec || interfaceNames.empty())
@@ -1593,11 +1591,7 @@ inline void handleAction(const crow::Request& req,
{
findActionOnInterface(transaction, object.first);
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject", objectPath,
- std::array<std::string, 0>());
+ });
}
inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -1605,9 +1599,10 @@ inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
{
BMCWEB_LOG_DEBUG << "handleDelete on path: " << objectPath;
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getDbusObject(
+ objectPath, {},
[asyncResp, objectPath](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const std::vector<std::pair<std::string, std::vector<std::string>>>&
interfaceNames) {
if (ec || interfaceNames.empty())
@@ -1630,11 +1625,7 @@ inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
{
findActionOnInterface(transaction, object.first);
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject", objectPath,
- std::array<const char*, 0>());
+ });
}
inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -1710,9 +1701,10 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
std::shared_ptr<std::string> path =
std::make_shared<std::string>(std::move(objectPath));
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getDbusObject(
+ *path, {},
[asyncResp, path,
- propertyName](const boost::system::error_code ec,
+ propertyName](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& objectNames) {
if (ec || objectNames.empty())
{
@@ -1801,11 +1793,7 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
});
}
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject", *path,
- std::array<std::string, 0>());
+ });
}
struct AsyncPutRequest
@@ -1878,8 +1866,9 @@ inline void handlePut(const crow::Request& req,
transaction->propertyName = destProperty;
transaction->propertyValue = propertySetValue;
- crow::connections::systemBus->async_method_call(
- [transaction](const boost::system::error_code ec2,
+ dbus::utility::getDbusObject(
+ transaction->objectPath, {},
+ [transaction](const boost::system::error_code& ec2,
const dbus::utility::MapperGetObject& objectNames) {
if (!ec2 && objectNames.empty())
{
@@ -2016,11 +2005,7 @@ inline void handlePut(const crow::Request& req,
connectionName, transaction->objectPath,
"org.freedesktop.DBus.Introspectable", "Introspect");
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject",
- transaction->objectPath, std::array<std::string, 0>());
+ });
}
inline void handleDBusUrl(const crow::Request& req,