summaryrefslogtreecommitdiff
path: root/include/dbus_utility.hpp
diff options
context:
space:
mode:
authorGeorge Liu <liuxiwei@inspur.com>2023-02-11 10:49:46 +0300
committerGeorge Liu <liuxiwei@inspur.com>2023-03-03 05:17:03 +0300
commita4eb761a4537a95f445d2980c43d79e55573507b (patch)
tree63f25d79e5f92cc6b6eb4f6ffe2502d87055b639 /include/dbus_utility.hpp
parent2feeb9d05739ee5de4f10aaa1527bc077c7a46e6 (diff)
downloadbmcweb-a4eb761a4537a95f445d2980c43d79e55573507b.tar.xz
Add the getAssociationEndPoints method
There are currently many files that use the get endpoints methods[1]. Since they are general methods, they are defined in the dbus_utility.hpp file and will be further refactored in subsequent patches. Since the current endpoints of phosphor-objmgr do not support object_path and fails in romulus CI[2], so we should revert to std::string. Also, Updated the populateSoftwareInformation method of sw_utils.hpp [1] https://github.com/openbmc/docs/blob/master/architecture/object-mapper.md#associations [2] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/58924/22/include/dbus_utility.hpp#98 When an object with, for example, an object path of pathA uses the following values: ["foo", "bar", "pathB"] The mapper will create 2 new objects: pathA/foo pathB/bar Tested: Built bmcweb successuflly and Validator passes curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", ... "FirmwareVersion": "2.14.0-dev-95-gea3949e76-dirty", ... } Tested: Validator passes Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I32a2c663bf2b8c84517bd0ecb4ccba61ce87c7e2
Diffstat (limited to 'include/dbus_utility.hpp')
-rw-r--r--include/dbus_utility.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index f41c422d30..ea0610126a 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -18,6 +18,7 @@
#include "dbus_singleton.hpp"
#include <boost/system/error_code.hpp> // IWYU pragma: keep
+#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/message/native_types.hpp>
#include <array>
@@ -95,6 +96,8 @@ using MapperGetAncestorsResponse = std::vector<
using MapperGetSubTreePathsResponse = std::vector<std::string>;
+using MapperEndPoints = std::vector<std::string>;
+
inline void escapePathForDbus(std::string& path)
{
const std::regex reg("[^A-Za-z0-9_/]");
@@ -193,5 +196,15 @@ inline void
"xyz.openbmc_project.ObjectMapper", "GetObject", path, interfaces);
}
+inline void getAssociationEndPoints(
+ const std::string& path,
+ std::function<void(const boost::system::error_code&,
+ const MapperEndPoints&)>&& callback)
+{
+ sdbusplus::asio::getProperty<MapperEndPoints>(
+ *crow::connections::systemBus, "xyz.openbmc_project.ObjectMapper", path,
+ "xyz.openbmc_project.Association", "endpoints", std::move(callback));
+}
+
} // namespace utility
} // namespace dbus