Refactor GetSubTree method
Since the GetSubTree method has been implemented in dbus_utility and
this commit is to integrate all the places where the GetSubTree
method is called, and use the method in dbus_utility uniformly.
Tested: Redfish Validator Passed
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: If3852b487d74e7cd8f123e0efffbd4affe92743c
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index c9143de..e953a9f 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -144,7 +144,8 @@
}
inline void
- getSubTree(const std::string& path, std::span<std::string> interfaces,
+ getSubTree(const std::string& path, int32_t depth,
+ std::span<const std::string_view> interfaces,
std::function<void(const boost::system::error_code&,
const MapperGetSubTreeResponse&)>&& callback)
{
@@ -154,7 +155,8 @@
const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); },
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, 0, interfaces);
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, depth,
+ interfaces);
}
inline void getSubTreePaths(
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp
index 7d48845..fd8aad4 100644
--- a/include/google/google_service_root.hpp
+++ b/include/google/google_service_root.hpp
@@ -8,6 +8,7 @@
#include "utils/hex_utils.hpp"
#include "utils/json_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <nlohmann/json.hpp>
#include <array>
@@ -98,22 +99,17 @@
const std::string& rotId,
ResolvedEntityHandler&& entityHandler)
{
-
constexpr std::array<std::string_view, 1> hothIfaces = {
"xyz.openbmc_project.Control.Hoth"};
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project", 0, hothIfaces,
[command, asyncResp, rotId,
entityHandler{std::forward<ResolvedEntityHandler>(entityHandler)}](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
hothGetSubtreeCallback(command, asyncResp, rotId, entityHandler, ec,
subtree);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project",
- /*depth=*/0, hothIfaces);
+ });
}
inline void populateRootOfTrustEntity(
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 948bc36..8dd7bb4 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -34,6 +34,7 @@
#include <boost/container/flat_map.hpp>
#include <boost/container/vector.hpp>
#include <boost/iterator/iterator_facade.hpp>
+#include <boost/system/error_code.hpp>
#include <nlohmann/json.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -1660,9 +1661,10 @@
asyncResp->res.jsonValue["status"] = "ok";
asyncResp->res.jsonValue["data"] = nlohmann::json::object();
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTree(
+ objectPath, 0, {},
[objectPath, asyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& objectNames) {
auto transaction =
std::make_shared<InProgressEnumerateData>(objectPath, asyncResp);
@@ -1684,11 +1686,7 @@
// Add the data for the path passed in to the results
// as if GetSubTree returned it, and continue on enumerating
getObjectAndEnumerate(transaction);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", objectPath, 0,
- std::array<const char*, 0>());
+ });
}
inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp
index 67cb115..31c3ea3 100644
--- a/redfish-core/include/utils/sw_utils.hpp
+++ b/redfish-core/include/utils/sw_utils.hpp
@@ -5,11 +5,14 @@
#include "generated/enums/resource.hpp"
#include "utils/dbus_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
#include <algorithm>
+#include <array>
#include <string>
+#include <string_view>
#include <vector>
namespace redfish
@@ -85,10 +88,13 @@
functionalSwIds.push_back(leaf);
}
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Software.Version"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/software", 0, interfaces,
[aResp, swVersionPurpose, activeVersionPropName,
populateLinkToImages, functionalSwIds](
- const boost::system::error_code ec2,
+ const boost::system::error_code& ec2,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec2)
{
@@ -219,12 +225,7 @@
}
});
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/software", static_cast<int32_t>(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Software.Version"});
+ });
});
}
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index e724118..51eca27 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -7,6 +7,7 @@
#include "utils/dbus_utils.hpp"
#include "utils/json_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -120,9 +121,12 @@
return;
}
BMCWEB_LOG_DEBUG << "Cable Id: " << cableId;
- auto respHandler =
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Cable"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp,
- cableId](const boost::system::error_code ec,
+ cableId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec.value() == EBADR)
{
@@ -155,15 +159,7 @@
return;
}
messages::resourceNotFound(asyncResp->res, "Cable", cableId);
- };
-
- crow::connections::systemBus->async_method_call(
- respHandler, "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0,
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.Cable"});
+ });
});
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 81f8254..5489351 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -25,6 +25,7 @@
#include "utils/dbus_utils.hpp"
#include "utils/json_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -109,9 +110,12 @@
*/
inline void getPhysicalSecurityData(std::shared_ptr<bmcweb::AsyncResp> aResp)
{
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Chassis.Intrusion"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/Intrusion", 1, interfaces,
[aResp{std::move(aResp)}](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -129,12 +133,7 @@
return;
}
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/Intrusion", 1,
- std::array<const char*, 1>{"xyz.openbmc_project.Chassis.Intrusion"});
+ });
}
inline void handleChassisCollectionGet(
@@ -219,13 +218,14 @@
{
return;
}
- const std::array<const char*, 2> interfaces = {
+ constexpr std::array<std::string_view, 2> interfaces = {
"xyz.openbmc_project.Inventory.Item.Board",
"xyz.openbmc_project.Inventory.Item.Chassis"};
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp, chassisId(std::string(chassisId))](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -454,11 +454,7 @@
// Couldn't find an object with that name. return an error
messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0, interfaces);
+ });
getPhysicalSecurityData(asyncResp);
}
@@ -499,13 +495,14 @@
"299 - \"IndicatorLED is deprecated. Use LocationIndicatorActive instead.\"");
}
- const std::array<const char*, 2> interfaces = {
+ constexpr std::array<std::string_view, 2> interfaces = {
"xyz.openbmc_project.Inventory.Item.Board",
"xyz.openbmc_project.Inventory.Item.Chassis"};
const std::string& chassisId = param;
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp, chassisId, locationIndicatorActive,
indicatorLed](const boost::system::error_code ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
@@ -581,11 +578,7 @@
}
messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0, interfaces);
+ });
}
/**
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index e8fa14b..376f70c 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -27,13 +27,16 @@
#include "utils/systemd_utils.hpp"
#include "utils/time_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
#include <algorithm>
+#include <array>
#include <cstdint>
#include <memory>
#include <sstream>
+#include <string_view>
#include <variant>
namespace redfish
@@ -1177,9 +1180,13 @@
std::shared_ptr<GetPIDValues> self = shared_from_this();
// get all configurations
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 4> interfaces = {
+ pidConfigurationIface, pidZoneConfigurationIface,
+ objectManagerIface, stepwiseConfigurationIface};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
[self](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) {
if (ec)
{
@@ -1188,18 +1195,15 @@
return;
}
self->complete.subtree = subtreeLocal;
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0,
- std::array<const char*, 4>{
- pidConfigurationIface, pidZoneConfigurationIface,
- objectManagerIface, stepwiseConfigurationIface});
+ });
// at the same time get the selected profile
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> thermalModeIfaces = {
+ thermalModeIface};
+ dbus::utility::getSubTree(
+ "/", 0, thermalModeIfaces,
[self](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) {
if (ec || subtreeLocal.empty())
{
@@ -1252,11 +1256,7 @@
self->complete.currentProfile = *current;
self->complete.supportedProfiles = *supported;
});
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0,
- std::array<const char*, 1>{thermalModeIface});
+ });
}
static void
@@ -1414,8 +1414,11 @@
"GetManagedObjects");
// at the same time get the profile information
- crow::connections::systemBus->async_method_call(
- [self](const boost::system::error_code ec,
+ constexpr std::array<std::string_view, 1> thermalModeIfaces = {
+ thermalModeIface};
+ dbus::utility::getSubTree(
+ "/", 0, thermalModeIfaces,
+ [self](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec || subtree.empty())
{
@@ -1467,11 +1470,7 @@
self->profileConnection = owner;
self->profilePath = path;
});
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0,
- std::array<const char*, 1>{thermalModeIface});
+ });
}
void pidSetDone()
{
@@ -2076,9 +2075,12 @@
});
}
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Bmc"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -2181,13 +2183,7 @@
getLocation(asyncResp, connectionName, path);
}
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.Bmc"});
+ });
});
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/")
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index 3e3360b..e55eded 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -25,6 +25,7 @@
#include "utils/hex_utils.hpp"
#include "utils/json_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <nlohmann/json.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -706,9 +707,13 @@
const std::string& dimmId)
{
BMCWEB_LOG_DEBUG << "Get available system dimm resources.";
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 2> dimmInterfaces = {
+ "xyz.openbmc_project.Inventory.Item.Dimm",
+ "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, dimmInterfaces,
[dimmId, aResp{std::move(aResp)}](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -758,14 +763,7 @@
aResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Systems/system/Memory/" + dimmId;
return;
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0,
- std::array<const char*, 2>{
- "xyz.openbmc_project.Inventory.Item.Dimm",
- "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"});
+ });
}
inline void requestRoutesMemoryCollection(App& app)
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 00324d7..d3910b3 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -25,9 +25,12 @@
#include "utils/json_utils.hpp"
#include "utils/stl_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
+#include <array>
#include <optional>
+#include <string_view>
#include <variant>
namespace redfish
@@ -320,7 +323,10 @@
// Any remaining array elements should be removed
currentNtpServers.erase(currentNtpServer, currentNtpServers.end());
- auto respHandler =
+ constexpr std::array<std::string_view, 1> ethInterfaces = {
+ "xyz.openbmc_project.Network.EthernetInterface"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project", 0, ethInterfaces,
[asyncResp, currentNtpServers](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
@@ -357,12 +363,7 @@
}
}
}
- };
-
- std::vector<std::string> interfaces = {
- "xyz.openbmc_project.Network.EthernetInterface"};
- dbus::utility::getSubTree("/xyz/openbmc_project", interfaces,
- std::move(respHandler));
+ });
}
inline void
@@ -370,7 +371,10 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& netBasePath)
{
- auto respHandler =
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.Service.Attributes"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/control/service", 0, interfaces,
[protocolEnabled, asyncResp,
netBasePath](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
@@ -411,12 +415,7 @@
dbus::utility::DbusVariantType{protocolEnabled});
}
}
- };
-
- std::vector<std::string> interfaces = {
- "xyz.openbmc_project.Control.Service.Attributes"};
- dbus::utility::getSubTree("/xyz/openbmc_project/control/service",
- interfaces, std::move(respHandler));
+ });
}
inline std::string getHostName()
diff --git a/redfish-core/lib/pcie_slots.hpp b/redfish-core/lib/pcie_slots.hpp
index d25b66b..1c4b6e9 100644
--- a/redfish-core/lib/pcie_slots.hpp
+++ b/redfish-core/lib/pcie_slots.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "app.hpp"
+#include "dbus_utility.hpp"
#include "error_messages.hpp"
#include "generated/enums/pcie_slot.hpp"
#include "pcie.hpp"
@@ -9,9 +10,13 @@
#include "utils/dbus_utils.hpp"
#include "utils/json_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
+#include <array>
+#include <string_view>
+
namespace redfish
{
@@ -259,18 +264,15 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.PCIeSlot"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp,
- chassisID](const boost::system::error_code ec,
+ chassisID](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
onMapperSubtreeDone(asyncResp, chassisID, ec, subtree);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.PCIeSlot"});
+ });
}
inline void requestRoutesPCIeSlots(App& app)
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 879c04b..1ac29ff 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -27,6 +27,7 @@
#include "utils/json_utils.hpp"
#include <boost/container/flat_map.hpp>
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/message/native_types.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -681,10 +682,20 @@
BMCWEB_LOG_DEBUG << "Get available system processor resources.";
// GetSubTree on all interfaces which provide info about a Processor
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 8> interfaces = {
+ "xyz.openbmc_project.Common.UUID",
+ "xyz.openbmc_project.Inventory.Decorator.Asset",
+ "xyz.openbmc_project.Inventory.Decorator.Revision",
+ "xyz.openbmc_project.Inventory.Item.Cpu",
+ "xyz.openbmc_project.Inventory.Decorator.LocationCode",
+ "xyz.openbmc_project.Inventory.Item.Accelerator",
+ "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
+ "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[resp, processorId, handler = std::forward<Handler>(handler)](
- boost::system::error_code ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree) mutable {
+ const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error: " << ec;
@@ -729,20 +740,7 @@
return;
}
messages::resourceNotFound(resp->res, "Processor", processorId);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0,
- std::array<const char*, 8>{
- "xyz.openbmc_project.Common.UUID",
- "xyz.openbmc_project.Inventory.Decorator.Asset",
- "xyz.openbmc_project.Inventory.Decorator.Revision",
- "xyz.openbmc_project.Inventory.Item.Cpu",
- "xyz.openbmc_project.Inventory.Decorator.LocationCode",
- "xyz.openbmc_project.Inventory.Item.Accelerator",
- "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
- "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier"});
+ });
}
inline void getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
@@ -1137,9 +1135,12 @@
}
// Ask for all objects implementing OperatingConfig so we can search
// for one with a matching name
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp, cpuName, configName, reqUrl{req.url}](
- boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -1172,13 +1173,7 @@
}
messages::resourceNotFound(asyncResp->res, "OperatingConfig",
configName);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0,
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"});
+ });
});
}
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 2bf66ba..d7a7f8c 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -20,9 +20,12 @@
#include "dbus_utility.hpp"
#include "error_messages.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
+#include <array>
#include <charconv>
+#include <string_view>
namespace redfish
{
@@ -60,9 +63,13 @@
CallbackFunc&& callback)
{
// Find managed chassis
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 2> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Board",
+ "xyz.openbmc_project.Inventory.Item.Chassis"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[callback,
- asyncResp](const boost::system::error_code ec,
+ asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -86,14 +93,7 @@
std::string chassisId = subtree[0].first.substr(idPos + 1);
BMCWEB_LOG_DEBUG << "chassisId = " << chassisId;
callback(chassisId, asyncResp);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0,
- std::array<const char*, 2>{
- "xyz.openbmc_project.Inventory.Item.Board",
- "xyz.openbmc_project.Inventory.Item.Chassis"});
+ });
}
template <typename CallbackFunc>
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 315398e..6be9e86 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -31,6 +31,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/range/algorithm/replace_copy_if.hpp>
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -354,14 +355,16 @@
{
BMCWEB_LOG_DEBUG << "getObjectsWithConnection enter";
const std::string path = "/xyz/openbmc_project/sensors";
- const std::array<std::string, 1> interfaces = {
+ constexpr std::array<std::string_view, 1> interfaces = {
"xyz.openbmc_project.Sensor.Value"};
- // Response handler for parsing objects subtree
- auto respHandler =
+ // Make call to ObjectMapper to find all sensors objects
+ dbus::utility::getSubTree(
+ path, 2, interfaces,
[callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
- sensorNames](const boost::system::error_code ec,
+ sensorNames](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ // Response handler for parsing objects subtree
BMCWEB_LOG_DEBUG << "getObjectsWithConnection resp_handler enter";
if (ec)
{
@@ -404,12 +407,7 @@
BMCWEB_LOG_DEBUG << "Found " << connections.size() << " connections";
callback(std::move(connections), std::move(objectsWithConnection));
BMCWEB_LOG_DEBUG << "getObjectsWithConnection resp_handler exit";
- };
- // Make call to ObjectMapper to find all sensors objects
- crow::connections::systemBus->async_method_call(
- std::move(respHandler), "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, 2, interfaces);
+ });
BMCWEB_LOG_DEBUG << "getObjectsWithConnection exit";
}
@@ -975,9 +973,12 @@
inline void populateFanRedundancy(
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp)
{
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.FanRedundancy"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/control", 2, interfaces,
[sensorsAsyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& resp) {
if (ec)
{
@@ -1144,13 +1145,7 @@
});
});
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/control", 2,
- std::array<const char*, 1>{
- "xyz.openbmc_project.Control.FanRedundancy"});
+ });
}
inline void
@@ -1520,18 +1515,20 @@
BMCWEB_LOG_DEBUG << "getInventoryItemsConnections enter";
const std::string path = "/xyz/openbmc_project/inventory";
- const std::array<std::string, 4> interfaces = {
+ constexpr std::array<std::string_view, 4> interfaces = {
"xyz.openbmc_project.Inventory.Item",
"xyz.openbmc_project.Inventory.Item.PowerSupply",
"xyz.openbmc_project.Inventory.Decorator.Asset",
"xyz.openbmc_project.State.Decorator.OperationalStatus"};
- // Response handler for parsing output from GetSubTree
- auto respHandler =
+ // Make call to ObjectMapper to find all inventory items
+ dbus::utility::getSubTree(
+ path, 0, interfaces,
[callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
inventoryItems](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ // Response handler for parsing output from GetSubTree
BMCWEB_LOG_DEBUG << "getInventoryItemsConnections respHandler enter";
if (ec)
{
@@ -1567,13 +1564,7 @@
callback(invConnections);
BMCWEB_LOG_DEBUG << "getInventoryItemsConnections respHandler exit";
- };
-
- // Make call to ObjectMapper to find all inventory items
- crow::connections::systemBus->async_method_call(
- std::move(respHandler), "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, 0, interfaces);
+ });
BMCWEB_LOG_DEBUG << "getInventoryItemsConnections exit";
}
@@ -1866,15 +1857,17 @@
BMCWEB_LOG_DEBUG << "getInventoryLeds enter";
const std::string path = "/xyz/openbmc_project";
- const std::array<std::string, 1> interfaces = {
+ constexpr std::array<std::string_view, 1> interfaces = {
"xyz.openbmc_project.Led.Physical"};
- // Response handler for parsing output from GetSubTree
- auto respHandler =
+ // Make call to ObjectMapper to find all inventory items
+ dbus::utility::getSubTree(
+ path, 0, interfaces,
[callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
inventoryItems](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ // Response handler for parsing output from GetSubTree
BMCWEB_LOG_DEBUG << "getInventoryLeds respHandler enter";
if (ec)
{
@@ -1910,12 +1903,7 @@
getInventoryLedData(sensorsAsyncResp, inventoryItems, ledConnections,
std::move(callback));
BMCWEB_LOG_DEBUG << "getInventoryLeds respHandler exit";
- };
- // Make call to ObjectMapper to find all inventory items
- crow::connections::systemBus->async_method_call(
- std::move(respHandler), "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, 0, interfaces);
+ });
BMCWEB_LOG_DEBUG << "getInventoryLeds exit";
}
@@ -2043,15 +2031,17 @@
return;
}
- const std::array<std::string, 1> interfaces = {
+ constexpr std::array<std::string_view, 1> interfaces = {
"xyz.openbmc_project.Control.PowerSupplyAttributes"};
- // Response handler for parsing output from GetSubTree
- auto respHandler =
+ // Make call to ObjectMapper to find the PowerSupplyAttributes service
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project", 0, interfaces,
[callback{std::forward<Callback>(callback)}, sensorsAsyncResp,
inventoryItems](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ // Response handler for parsing output from GetSubTree
BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes respHandler enter";
if (ec)
{
@@ -2097,13 +2087,7 @@
psAttributesConnections,
std::move(callback));
BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes respHandler exit";
- };
- // Make call to ObjectMapper to find the PowerSupplyAttributes service
- crow::connections::systemBus->async_method_call(
- std::move(respHandler), "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project", 0, interfaces);
+ });
BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes exit";
}
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index 1b297f3..aaed634 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -23,6 +23,7 @@
#include "registries/privilege_registry.hpp"
#include "utils/dbus_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -113,9 +114,12 @@
getStorageControllers(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::shared_ptr<HealthPopulate>& health)
{
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.StorageController"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp,
- health](const boost::system::error_code ec,
+ health](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec || subtree.empty())
{
@@ -247,13 +251,7 @@
health->children.emplace_back(subHealth);
count++;
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.StorageController"});
+ });
}
inline void requestRoutesStorage(App& app)
@@ -572,9 +570,12 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Drive"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp,
- driveId](const boost::system::error_code ec,
+ driveId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -632,13 +633,7 @@
addAllDriveInfo(asyncResp, connectionNames[0].first, path,
connectionNames[0].second);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.Drive"});
+ });
});
}
@@ -657,9 +652,13 @@
}
// mapper call lambda
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 2> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Board",
+ "xyz.openbmc_project.Inventory.Item.Chassis"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp,
- chassisId](const boost::system::error_code ec,
+ chassisId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -733,14 +732,7 @@
}); // end association lambda
} // end Iterate over all retrieved ObjectPaths
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0,
- std::array<const char*, 2>{
- "xyz.openbmc_project.Inventory.Item.Board",
- "xyz.openbmc_project.Inventory.Item.Chassis"});
+ });
}
inline void requestRoutesChassisDrive(App& app)
@@ -815,19 +807,15 @@
continue;
}
// mapper call drive
- const std::array<const char*, 1> driveInterface = {
+ constexpr std::array<std::string_view, 1> driveInterface = {
"xyz.openbmc_project.Inventory.Item.Drive"};
-
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, driveInterface,
[asyncResp, chassisId, driveName](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
buildDrive(asyncResp, chassisId, driveName, ec, subtree);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0, driveInterface);
+ });
}
}
@@ -841,14 +829,15 @@
{
return;
}
- const std::array<const char*, 2> interfaces = {
+ constexpr std::array<std::string_view, 2> interfaces = {
"xyz.openbmc_project.Inventory.Item.Board",
"xyz.openbmc_project.Inventory.Item.Chassis"};
// mapper call chassis
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[asyncResp, chassisId,
- driveName](const boost::system::error_code ec,
+ driveName](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -886,11 +875,7 @@
});
break;
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", 0, interfaces);
+ });
}
/**
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index ab5a80e..864a8d9 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -30,6 +30,7 @@
#include "utils/time_utils.hpp"
#include <boost/container/flat_map.hpp>
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -241,10 +242,17 @@
const std::shared_ptr<HealthPopulate>& systemHealth)
{
BMCWEB_LOG_DEBUG << "Get available system components.";
-
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 5> interfaces = {
+ "xyz.openbmc_project.Inventory.Decorator.Asset",
+ "xyz.openbmc_project.Inventory.Item.Cpu",
+ "xyz.openbmc_project.Inventory.Item.Dimm",
+ "xyz.openbmc_project.Inventory.Item.System",
+ "xyz.openbmc_project.Common.UUID",
+ };
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[aResp,
- systemHealth](const boost::system::error_code ec,
+ systemHealth](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -524,17 +532,6 @@
break;
}
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 5>{
- "xyz.openbmc_project.Inventory.Decorator.Asset",
- "xyz.openbmc_project.Inventory.Item.Cpu",
- "xyz.openbmc_project.Inventory.Item.Dimm",
- "xyz.openbmc_project.Inventory.Item.System",
- "xyz.openbmc_project.Common.UUID",
});
}
@@ -1271,9 +1268,11 @@
const std::shared_ptr<bmcweb::AsyncResp>& aResp)
{
BMCWEB_LOG_DEBUG << "Get TPM required to boot.";
-
- crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.TPM.Policy"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
+ [aResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -1337,11 +1336,7 @@
"Disabled";
}
});
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Control.TPM.Policy"});
+ });
}
/**
@@ -1357,10 +1352,13 @@
const std::shared_ptr<bmcweb::AsyncResp>& aResp, const bool tpmRequired)
{
BMCWEB_LOG_DEBUG << "Set TrustedModuleRequiredToBoot.";
-
- crow::connections::systemBus->async_method_call(
- [aResp, tpmRequired](const boost::system::error_code ec,
- dbus::utility::MapperGetSubTreeResponse& subtree) {
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.TPM.Policy"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
+ [aResp,
+ tpmRequired](const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error on TPM.Policy GetSubTree"
@@ -1421,11 +1419,7 @@
serv, path, "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Control.TPM.Policy", "TPMEnable",
dbus::utility::DbusVariantType(tpmRequired));
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Control.TPM.Policy"});
+ });
}
/**
@@ -1685,9 +1679,12 @@
inline void setAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
const std::string& assetTag)
{
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.System"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
[aResp,
- assetTag](const boost::system::error_code ec,
+ assetTag](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -1739,13 +1736,7 @@
service, path, "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Inventory.Decorator.AssetTag", "AssetTag",
dbus::utility::DbusVariantType(assetTag));
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.System"});
+ });
}
/**
@@ -1965,8 +1956,11 @@
BMCWEB_LOG_DEBUG << "Get power mode.";
// Get Power Mode object path:
- crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.Power.Mode"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
+ [aResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -2026,11 +2020,7 @@
BMCWEB_LOG_DEBUG << "Current power mode: " << pmode;
translatePowerMode(aResp, pmode);
});
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Control.Power.Mode"});
+ });
}
/**
@@ -2088,9 +2078,12 @@
}
// Get Power Mode object path:
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.Power.Mode"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
[aResp,
- powerMode](const boost::system::error_code ec,
+ powerMode](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -2147,11 +2140,7 @@
service, path, "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Control.Power.Mode", "PowerMode",
dbus::utility::DbusVariantType(powerMode));
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Control.Power.Mode"});
+ });
}
/**
@@ -2419,8 +2408,11 @@
BMCWEB_LOG_DEBUG << "Get idle power saver parameters";
// Get IdlePowerSaver object path:
- crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec,
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
+ [aResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -2482,12 +2474,7 @@
return;
}
});
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Control.Power.IdlePowerSaver"});
+ });
BMCWEB_LOG_DEBUG << "EXIT: Get idle power saver parameters";
}
@@ -2517,9 +2504,12 @@
BMCWEB_LOG_DEBUG << "Set idle power saver properties";
// Get IdlePowerSaver object path:
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
[aResp, ipsEnable, ipsEnterUtil, ipsEnterTime, ipsExitUtil,
- ipsExitTime](const boost::system::error_code ec,
+ ipsExitTime](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -2647,12 +2637,7 @@
"ExitDwellTime",
dbus::utility::DbusVariantType(timeMilliseconds));
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Control.Power.IdlePowerSaver"});
+ });
BMCWEB_LOG_DEBUG << "EXIT: Set idle power saver parameters";
}
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index a8f0a6c..3d29f28 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -24,6 +24,7 @@
#include "utils/dbus_utils.hpp"
#include "utils/sw_utils.hpp"
+#include <boost/system/error_code.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/bus/match.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -750,9 +751,17 @@
"/redfish/v1/UpdateService/FirmwareInventory";
asyncResp->res.jsonValue["Name"] = "Software Inventory Collection";
- crow::connections::systemBus->async_method_call(
+ // Note that only firmware levels associated with a device
+ // are stored under /xyz/openbmc_project/software therefore
+ // to ensure only real FirmwareInventory items are returned,
+ // this full object path must be used here as input to
+ // mapper
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Software.Version"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/software", 0, interfaces,
[asyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
@@ -781,17 +790,7 @@
asyncResp->res.jsonValue["Members@odata.count"] =
members.size();
}
- },
- // Note that only firmware levels associated with a device
- // are stored under /xyz/openbmc_project/software therefore
- // to ensure only real FirmwareInventory items are returned,
- // this full object path must be used here as input to
- // mapper
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/software", static_cast<int32_t>(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Software.Version"});
+ });
});
}
/* Fill related item links (i.e. bmc, bios) in for inventory */
@@ -911,9 +910,12 @@
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/UpdateService/FirmwareInventory/" + *swId;
- crow::connections::systemBus->async_method_call(
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Software.Version"};
+ dbus::utility::getSubTree(
+ "/", 0, interfaces,
[asyncResp,
- swId](const boost::system::error_code ec,
+ swId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
BMCWEB_LOG_DEBUG << "doGet callback...";
if (ec)
@@ -960,12 +962,7 @@
asyncResp->res.jsonValue["Updateable"] = false;
sw_util::getSwUpdatableStatus(asyncResp, swId);
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/",
- static_cast<int32_t>(0),
- std::array<const char*, 1>{"xyz.openbmc_project.Software.Version"});
+ });
});
}