use PDI constants for ObjectMapper
PDI already defines the constants we need here, use those instead of
duplicating.
Tested: Inspection only.
Change-Id: I86ad46a4aac757aa7b377b1e1709088a1e457102
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index 0fd14c9..a544dc1 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -19,11 +19,14 @@
#include <ipmid/utils.hpp>
#include <nlohmann/json.hpp>
#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/ObjectMapper/common.hpp>
#include <fstream>
#include <optional>
#include <unordered_set>
+using ObjectMapper = sdbusplus::common::xyz::openbmc_project::ObjectMapper;
+
#ifdef FEATURE_HYBRID_SENSORS
#include <ipmid/utils.hpp>
@@ -139,9 +142,8 @@
auto lbdUpdateSensorTree = [&dbus](const char* path,
const auto& interfaces) {
auto mapperCall = dbus->new_method_call(
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree");
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, ObjectMapper::method_names::get_sub_tree);
SensorSubTree sensorTreePartial;
mapperCall.append(path, depth, interfaces);
@@ -392,10 +394,9 @@
std::vector<std::string> interfaces;
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
- sdbusplus::message_t getObjectMessage =
- dbus->new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject");
+ sdbusplus::message_t getObjectMessage = dbus->new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, ObjectMapper::method_names::get_object);
getObjectMessage.append(path, interfaces);
try
@@ -452,9 +453,9 @@
using Paths = std::vector<std::string>;
boost::system::error_code ec;
Paths paths = ipmi::callDbusMethod<Paths>(
- *ctx, ec, "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", int32_t(0),
+ *ctx, ec, ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, ObjectMapper::method_names::get_sub_tree_paths,
+ "/", int32_t(0),
std::array<const char*, 1>{
"xyz.openbmc_project.Inventory.Decorator.Ipmi"});
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index fb7879e..c22828b 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -29,6 +29,7 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/message/types.hpp>
#include <sdbusplus/timer.hpp>
+#include <xyz/openbmc_project/ObjectMapper/common.hpp>
#include <filesystem>
#include <fstream>
@@ -37,6 +38,8 @@
#include <stdexcept>
#include <string_view>
+using ObjectMapper = sdbusplus::common::xyz::openbmc_project::ObjectMapper;
+
static constexpr bool DEBUG = false;
namespace dynamic_sensors::ipmi::sel
@@ -593,9 +596,8 @@
boost::system::error_code ec;
Paths subtreePaths = ipmi::callDbusMethod<Paths>(
- ctx, ec, "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
+ ctx, ec, ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, ObjectMapper::method_names::get_sub_tree_paths,
"/xyz/openbmc_project/inventory", 0,
std::array<const char*, 2>{
"xyz.openbmc_project.Inventory.Decorator.I2CDevice",
diff --git a/include/ipmid/utils.hpp b/include/ipmid/utils.hpp
index 4e8ca91..1bd6e37 100644
--- a/include/ipmid/utils.hpp
+++ b/include/ipmid/utils.hpp
@@ -17,10 +17,6 @@
using namespace std::literals::chrono_literals;
-constexpr auto MAPPER_BUS_NAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_OBJ = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTF = "xyz.openbmc_project.ObjectMapper";
-
constexpr auto ROOT = "/";
constexpr auto HOST_MATCH = "host0";
diff --git a/libipmid/utils.cpp b/libipmid/utils.cpp
index 02d6758..e2fb65c 100644
--- a/libipmid/utils.cpp
+++ b/libipmid/utils.cpp
@@ -13,6 +13,7 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/message/types.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/ObjectMapper/common.hpp>
#include <algorithm>
#include <chrono>
@@ -24,6 +25,8 @@
using namespace phosphor::logging;
using namespace sdbusplus::error::xyz::openbmc_project::common;
+using ObjectMapper = sdbusplus::common::xyz::openbmc_project::ObjectMapper;
+
namespace network
{
@@ -200,10 +203,9 @@
std::string getService(sdbusplus::bus_t& bus, const std::string& intf,
const std::string& path)
{
- auto mapperCall =
- bus.new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, ObjectMapper::method_names::get_object);
mapperCall.append(path);
mapperCall.append(std::vector<std::string>({intf}));
@@ -225,8 +227,9 @@
ObjectTree getSubTree(sdbusplus::bus_t& bus, const InterfaceList& interfaces,
const std::string& subtreePath, int32_t depth)
{
- auto mapperCall = bus.new_method_call(MAPPER_BUS_NAME, MAPPER_OBJ,
- MAPPER_INTF, "GetSubTree");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, ObjectMapper::method_names::get_sub_tree);
mapperCall.append(subtreePath, depth, interfaces);
@@ -283,9 +286,9 @@
boost::system::error_code ec;
std::map<std::string, std::vector<std::string>> mapperResponse =
ctx->bus->yield_method_call<decltype(mapperResponse)>(
- ctx->yield, ec, "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetObject", path,
+ ctx->yield, ec, ObjectMapper::default_service,
+ ObjectMapper::instance_path, ObjectMapper::interface,
+ ObjectMapper::method_names::get_object, path,
std::vector<std::string>({intf}));
if (!ec)
@@ -301,8 +304,10 @@
{
boost::system::error_code ec;
objectTree = ctx->bus->yield_method_call<ObjectTree>(
- ctx->yield, ec, MAPPER_BUS_NAME, MAPPER_OBJ, MAPPER_INTF, "GetSubTree",
- subtreePath, depth, interfaces);
+ ctx->yield, ec, ObjectMapper::default_service,
+ ObjectMapper::instance_path, ObjectMapper::interface,
+ ObjectMapper::method_names::get_sub_tree, subtreePath, depth,
+ interfaces);
return ec;
}
diff --git a/selutility.cpp b/selutility.cpp
index 944b21c..9efd391 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -8,6 +8,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/ObjectMapper/common.hpp>
#include <charconv>
#include <chrono>
@@ -19,6 +20,8 @@
using InternalFailure =
sdbusplus::error::xyz::openbmc_project::common::InternalFailure;
+using ObjectMapper = sdbusplus::common::xyz::openbmc_project::ObjectMapper;
+
namespace
{
@@ -374,8 +377,10 @@
auto depth = 0;
paths.clear();
- auto mapperCall = bus.new_method_call(mapperBusName, mapperObjPath,
- mapperIntf, "GetSubTreePaths");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface,
+ ObjectMapper::method_names::get_sub_tree_paths);
mapperCall.append(logBasePath);
mapperCall.append(depth);
mapperCall.append(ObjectPaths({logEntryIntf}));
diff --git a/selutility.hpp b/selutility.hpp
index ace17d8..3d50a3d 100644
--- a/selutility.hpp
+++ b/selutility.hpp
@@ -15,10 +15,6 @@
namespace sel
{
-static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
-static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper";
-static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
-
static constexpr auto logWatchPath = "/xyz/openbmc_project/logging";
static constexpr auto logBasePath = "/xyz/openbmc_project/logging/entry";
static constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry";
diff --git a/settings.cpp b/settings.cpp
index 4564fa4..cac44c6 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -5,6 +5,9 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/message/types.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/ObjectMapper/common.hpp>
+
+using ObjectMapper = sdbusplus::common::xyz::openbmc_project::ObjectMapper;
namespace settings
{
@@ -12,10 +15,6 @@
using namespace phosphor::logging;
using namespace sdbusplus::error::xyz::openbmc_project::common;
-constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
-constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
-constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
-
Objects::Objects(sdbusplus::bus_t& bus, const std::vector<Interface>& filter) :
bus(bus)
{
@@ -52,8 +51,9 @@
Service Objects::service(const Path& path, const Interface& interface) const
{
using Interfaces = std::vector<Interface>;
- auto mapperCall =
- bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetObject");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetObject");
mapperCall.append(path);
mapperCall.append(Interfaces({interface}));