reduce dbus string constants
There are a large number of dbus constants scattered throughout the
code that could/should be obtained from phosphor-dbus-interface values.
Perform minor refactoring to greatly reduce the number of string
constants.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie8700bc90611d21eee7160f4686bc978fe0a0eb4
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 3818210..bfa8ff8 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -10,12 +10,14 @@
#include <fmt/printf.h>
#include <cereal/archives/json.hpp>
+#include <org/freedesktop/UPower/Device/client.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/exception.hpp>
+#include <xyz/openbmc_project/ObjectMapper/client.hpp>
#include <xyz/openbmc_project/State/Chassis/error.hpp>
#include <xyz/openbmc_project/State/Decorator/PowerSystemInputs/server.hpp>
@@ -36,6 +38,9 @@
namespace decoratorServer =
sdbusplus::server::xyz::openbmc_project::state::decorator;
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
+using UPowerDevice = sdbusplus::client::org::freedesktop::u_power::Device<>;
+
using namespace phosphor::logging;
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
using sdbusplus::xyz::openbmc_project::State::Shutdown::Power::Error::Blackout;
@@ -65,12 +70,6 @@
constexpr auto SYSTEMD_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
constexpr auto SYSTEMD_INTERFACE_UNIT = "org.freedesktop.systemd1.Unit";
-constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-constexpr auto UPOWER_INTERFACE = "org.freedesktop.UPower.Device";
-constexpr auto POWERSYSINPUTS_INTERFACE =
- "xyz.openbmc_project.State.Decorator.PowerSystemInputs";
constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
void Chassis::createSystemdTargetTable()
@@ -92,7 +91,7 @@
uPowerPropChangeSignal = std::make_unique<sdbusplus::bus::match_t>(
bus,
sdbusplus::bus::match::rules::propertiesChangedNamespace(
- "/org/freedesktop/UPower", UPOWER_INTERFACE),
+ "/org/freedesktop/UPower", UPowerDevice::interface),
[this](auto& msg) { this->uPowerChangeEvent(msg); });
// Monitor for any properties changed signals on PowerSystemInputs
@@ -101,7 +100,7 @@
sdbusplus::bus::match::rules::propertiesChangedNamespace(
fmt::format(
"/xyz/openbmc_project/power/power_supplies/chassis{}/psus", id),
- POWERSYSINPUTS_INTERFACE),
+ decoratorServer::PowerSystemInputs::interface),
[this](auto& msg) { this->powerSysInputsChangeEvent(msg); });
determineStatusOfPower();
@@ -231,10 +230,11 @@
bool Chassis::determineStatusOfUPSPower()
{
// Find all implementations of the UPower interface
- auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
- MAPPER_INTERFACE, "GetSubTree");
+ auto mapper = bus.new_method_call(ObjectMapper::default_service,
+ ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetSubTree");
- mapper.append("/", 0, std::vector<std::string>({UPOWER_INTERFACE}));
+ mapper.append("/", 0, std::vector<std::string>({UPowerDevice::interface}));
std::map<std::string, std::map<std::string, std::vector<std::string>>>
mapperResponse;
@@ -266,7 +266,7 @@
{
auto method = bus.new_method_call(service.c_str(), path.c_str(),
PROPERTY_INTERFACE, "GetAll");
- method.append(UPOWER_INTERFACE);
+ method.append(UPowerDevice::interface);
auto response = bus.call(method);
using Property = std::string;
@@ -337,10 +337,13 @@
bool Chassis::determineStatusOfPSUPower()
{
// Find all implementations of the PowerSystemInputs interface
- auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
- MAPPER_INTERFACE, "GetSubTree");
+ auto mapper = bus.new_method_call(ObjectMapper::default_service,
+ ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetSubTree");
- mapper.append("/", 0, std::vector<std::string>({POWERSYSINPUTS_INTERFACE}));
+ mapper.append("/", 0,
+ std::vector<std::string>(
+ {decoratorServer::PowerSystemInputs::interface}));
std::map<std::string, std::map<std::string, std::vector<std::string>>>
mapperResponse;
@@ -367,7 +370,7 @@
{
auto method = bus.new_method_call(service.c_str(), path.c_str(),
PROPERTY_INTERFACE, "GetAll");
- method.append(POWERSYSINPUTS_INTERFACE);
+ method.append(decoratorServer::PowerSystemInputs::interface);
auto response = bus.call(method);
using Property = std::string;
diff --git a/chassis_state_manager.hpp b/chassis_state_manager.hpp
index 3f44c1e..d79464d 100644
--- a/chassis_state_manager.hpp
+++ b/chassis_state_manager.hpp
@@ -3,14 +3,14 @@
#include "config.h"
#include "utils.hpp"
-#include "xyz/openbmc_project/State/Chassis/server.hpp"
-#include "xyz/openbmc_project/State/PowerOnHours/server.hpp"
#include <cereal/cereal.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
+#include <xyz/openbmc_project/State/Chassis/server.hpp>
+#include <xyz/openbmc_project/State/PowerOnHours/server.hpp>
#include <chrono>
#include <filesystem>
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index 0a9c728..92d0e76 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -15,6 +15,8 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/exception.hpp>
#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/State/BMC/client.hpp>
+#include <xyz/openbmc_project/State/Host/client.hpp>
#include <filesystem>
#include <iostream>
@@ -44,7 +46,6 @@
using namespace phosphor::logging;
size_t hostId = 0;
- std::string hostPath = "/xyz/openbmc_project/state/host0";
int arg;
int optIndex = 0;
@@ -57,14 +58,17 @@
{
case 'h':
hostId = std::stoul(optarg);
- hostPath = std::string("/xyz/openbmc_project/state/host") +
- optarg;
break;
default:
break;
}
}
+ using Host = sdbusplus::client::xyz::openbmc_project::state::Host<>;
+ std::string hostPath = std::string(Host::namespace_path::value) + "/" +
+ std::string(Host::namespace_path::host) +
+ std::to_string(hostId);
+
auto bus = sdbusplus::bus::new_default();
using namespace settings;
@@ -77,17 +81,22 @@
// If the BMC was rebooted due to a user initiated pinhole reset, do not
// implement any power restore policies
- auto bmcRebootCause = phosphor::state::manager::utils::getProperty(
- bus, "/xyz/openbmc_project/state/bmc0", BMC_BUSNAME, "LastRebootCause");
- if (bmcRebootCause ==
- "xyz.openbmc_project.State.BMC.RebootCause.PinholeReset")
+ using BMC = sdbusplus::client::xyz::openbmc_project::state::BMC<>;
+ auto bmcPath = sdbusplus::message::object_path(BMC::namespace_path::value) /
+ BMC::namespace_path::bmc;
+
+ auto bmcRebootCause =
+ sdbusplus::message::convert_from_string<BMC::RebootCause>(
+ phosphor::state::manager::utils::getProperty(
+ bus, bmcPath.str.c_str(), BMC_BUSNAME, "LastRebootCause"));
+
+ if (bmcRebootCause == BMC::RebootCause::PinholeReset)
{
info(
"BMC was reset due to pinhole reset, no power restore policy will be run");
return 0;
}
- else if (bmcRebootCause ==
- "xyz.openbmc_project.State.BMC.RebootCause.Watchdog")
+ else if (bmcRebootCause == BMC::RebootCause::Watchdog)
{
info(
"BMC was reset due to cold reset, no power restore policy will be run");
diff --git a/host_check.cpp b/host_check.cpp
index ec0f3f4..37a6689 100644
--- a/host_check.cpp
+++ b/host_check.cpp
@@ -8,8 +8,9 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
-#include <xyz/openbmc_project/Condition/HostFirmware/server.hpp>
-#include <xyz/openbmc_project/State/Chassis/server.hpp>
+#include <xyz/openbmc_project/Condition/HostFirmware/client.hpp>
+#include <xyz/openbmc_project/ObjectMapper/client.hpp>
+#include <xyz/openbmc_project/State/Chassis/client.hpp>
#include <cstdio>
#include <cstdlib>
@@ -28,32 +29,29 @@
PHOSPHOR_LOG2_USING;
using namespace std::literals;
-using namespace sdbusplus::server::xyz::openbmc_project::condition;
+
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
+using Chassis = sdbusplus::client::xyz::openbmc_project::state::Chassis<>;
+using HostFirmware =
+ sdbusplus::client::xyz::openbmc_project::condition::HostFirmware<>;
// Required strings for sending the msg to check on host
-constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-constexpr auto CONDITION_HOST_INTERFACE =
- "xyz.openbmc_project.Condition.HostFirmware";
constexpr auto CONDITION_HOST_PROPERTY = "CurrentFirmwareCondition";
constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
constexpr auto CHASSIS_STATE_SVC = "xyz.openbmc_project.State.Chassis";
-constexpr auto CHASSIS_STATE_PATH = "/xyz/openbmc_project/state/chassis";
-constexpr auto CHASSIS_STATE_INTF = "xyz.openbmc_project.State.Chassis";
constexpr auto CHASSIS_STATE_POWER_PROP = "CurrentPowerState";
// Find all implementations of Condition interface and check if host is
// running over it
bool checkFirmwareConditionRunning(sdbusplus::bus_t& bus)
{
- using FirmwareCondition = HostFirmware::FirmwareCondition;
// Find all implementations of host firmware condition interface
- auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
- MAPPER_INTERFACE, "GetSubTree");
+ auto mapper = bus.new_method_call(ObjectMapper::default_service,
+ ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetSubTree");
- mapper.append("/", 0, std::vector<std::string>({CONDITION_HOST_INTERFACE}));
+ mapper.append("/", 0, std::vector<std::string>({HostFirmware::interface}));
std::map<std::string, std::map<std::string, std::vector<std::string>>>
mapperResponse;
@@ -97,21 +95,20 @@
{
auto method = bus.new_method_call(service.c_str(), path.c_str(),
PROPERTY_INTERFACE, "Get");
- method.append(CONDITION_HOST_INTERFACE,
- CONDITION_HOST_PROPERTY);
+ method.append(HostFirmware::interface, CONDITION_HOST_PROPERTY);
auto response = bus.call(method);
- std::variant<FirmwareCondition> currentFwCondV;
+ std::variant<HostFirmware::FirmwareCondition> currentFwCondV;
response.read(currentFwCondV);
auto currentFwCond =
- std::get<FirmwareCondition>(currentFwCondV);
+ std::get<HostFirmware::FirmwareCondition>(currentFwCondV);
info(
"Read host fw condition {COND_VALUE} from {COND_SERVICE}, {COND_PATH}",
"COND_VALUE", currentFwCond, "COND_SERVICE", service,
"COND_PATH", path);
- if (currentFwCond == FirmwareCondition::Running)
+ if (currentFwCond == HostFirmware::FirmwareCondition::Running)
{
return true;
}
@@ -132,23 +129,24 @@
bool isChassiPowerOn(sdbusplus::bus_t& bus, size_t id)
{
auto svcname = std::string{CHASSIS_STATE_SVC} + std::to_string(id);
- auto objpath = std::string{CHASSIS_STATE_PATH} + std::to_string(id);
+ auto objpath = std::string{Chassis::namespace_path::value} + "/" +
+ std::string{Chassis::namespace_path::chassis} +
+ std::to_string(id);
try
{
- using PowerState =
- sdbusplus::server::xyz::openbmc_project::state::Chassis::PowerState;
auto method = bus.new_method_call(svcname.c_str(), objpath.c_str(),
PROPERTY_INTERFACE, "Get");
- method.append(CHASSIS_STATE_INTF, CHASSIS_STATE_POWER_PROP);
+ method.append(Chassis::interface, CHASSIS_STATE_POWER_PROP);
auto response = bus.call(method);
- std::variant<PowerState> currentPowerStateV;
+ std::variant<Chassis::PowerState> currentPowerStateV;
response.read(currentPowerStateV);
- auto currentPowerState = std::get<PowerState>(currentPowerStateV);
+ auto currentPowerState =
+ std::get<Chassis::PowerState>(currentPowerStateV);
- if (currentPowerState == PowerState::On)
+ if (currentPowerState == Chassis::PowerState::On)
{
return true;
}
diff --git a/host_reset_recovery.cpp b/host_reset_recovery.cpp
index 9579f30..a8d3842 100644
--- a/host_reset_recovery.cpp
+++ b/host_reset_recovery.cpp
@@ -6,9 +6,9 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
-#include <xyz/openbmc_project/Logging/Create/server.hpp>
-#include <xyz/openbmc_project/Logging/Entry/server.hpp>
-#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
+#include <xyz/openbmc_project/Logging/Create/client.hpp>
+#include <xyz/openbmc_project/Logging/Entry/client.hpp>
+#include <xyz/openbmc_project/State/Boot/Progress/client.hpp>
#include <cstdlib>
#include <fstream>
@@ -23,16 +23,17 @@
PHOSPHOR_LOG2_USING;
+using BootProgress =
+ sdbusplus::client::xyz::openbmc_project::state::boot::Progress<>;
+using LoggingCreate =
+ sdbusplus::client::xyz::openbmc_project::logging::Create<>;
+using LoggingEntry = sdbusplus::client::xyz::openbmc_project::logging::Entry<>;
+
constexpr auto HOST_STATE_SVC = "xyz.openbmc_project.State.Host";
constexpr auto HOST_STATE_PATH = "/xyz/openbmc_project/state/host0";
constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
-constexpr auto BOOT_STATE_INTF = "xyz.openbmc_project.State.Boot.Progress";
constexpr auto BOOT_PROGRESS_PROP = "BootProgress";
-constexpr auto LOGGING_SVC = "xyz.openbmc_project.Logging";
-constexpr auto LOGGING_PATH = "/xyz/openbmc_project/logging";
-constexpr auto LOGGING_CREATE_INTF = "xyz.openbmc_project.Logging.Create";
-
constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
@@ -42,12 +43,11 @@
{
try
{
- using ProgressStages = sdbusplus::xyz::openbmc_project::State::Boot::
- server::Progress::ProgressStages;
+ using ProgressStages = BootProgress::ProgressStages;
auto method = bus.new_method_call(HOST_STATE_SVC, HOST_STATE_PATH,
PROPERTY_INTERFACE, "Get");
- method.append(BOOT_STATE_INTF, BOOT_PROGRESS_PROP);
+ method.append(BootProgress::interface, BOOT_PROGRESS_PROP);
auto response = bus.call(method);
@@ -86,12 +86,10 @@
static constexpr auto errorMessage =
"xyz.openbmc_project.State.Error.HostNotRunning";
- auto method = bus.new_method_call(LOGGING_SVC, LOGGING_PATH,
- LOGGING_CREATE_INTF, "Create");
- method.append(errorMessage,
- sdbusplus::server::xyz::openbmc_project::logging::Entry::
- Level::Error,
- additionalData);
+ auto method = bus.new_method_call(LoggingCreate::default_service,
+ LoggingCreate::instance_path,
+ LoggingCreate::interface, "Create");
+ method.append(errorMessage, LoggingEntry::Level::Error, additionalData);
auto resp = bus.call(method);
}
catch (const sdbusplus::exception_t& e)
@@ -99,8 +97,8 @@
error(
"sdbusplus D-Bus call exception, error {ERROR}, objpath {OBJPATH}, "
"interface {INTERFACE}",
- "ERROR", e, "OBJPATH", LOGGING_PATH, "INTERFACE",
- LOGGING_CREATE_INTF);
+ "ERROR", e, "OBJPATH", LoggingCreate::instance_path, "INTERFACE",
+ LoggingCreate::interface);
throw std::runtime_error(
"Error in invoking D-Bus logging create interface");
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index c8fb24f..8227a06 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -4,7 +4,6 @@
#include "settings.hpp"
#include "utils.hpp"
-#include "xyz/openbmc_project/State/Host/server.hpp"
#include <cereal/access.hpp>
#include <cereal/cereal.hpp>
@@ -12,6 +11,7 @@
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Control/Boot/RebootAttempts/server.hpp>
#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
+#include <xyz/openbmc_project/State/Host/server.hpp>
#include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp>
#include <filesystem>
diff --git a/hypervisor_state_manager.hpp b/hypervisor_state_manager.hpp
index 3c7d896..88ea57c 100644
--- a/hypervisor_state_manager.hpp
+++ b/hypervisor_state_manager.hpp
@@ -3,9 +3,10 @@
#include "config.h"
#include "settings.hpp"
-#include "xyz/openbmc_project/State/Host/server.hpp"
#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/State/Boot/Progress/client.hpp>
+#include <xyz/openbmc_project/State/Host/server.hpp>
namespace phosphor
{
@@ -16,6 +17,8 @@
using HypervisorInherit = sdbusplus::server::object_t<
sdbusplus::server::xyz::openbmc_project::state::Host>;
+using BootProgress =
+ sdbusplus::client::xyz::openbmc_project::state::boot::Progress<>;
namespace server = sdbusplus::server::xyz::openbmc_project::state;
namespace sdbusRule = sdbusplus::bus::match::rules;
@@ -46,9 +49,8 @@
bus(bus),
bootProgressChangeSignal(
bus,
- sdbusRule::propertiesChanged(
- "/xyz/openbmc_project/state/host0",
- "xyz.openbmc_project.State.Boot.Progress"),
+ sdbusRule::propertiesChanged("/xyz/openbmc_project/state/host0",
+ BootProgress::interface),
[this](sdbusplus::message_t& m) { bootProgressChangeEvent(m); })
{}
diff --git a/scheduled_host_transition.cpp b/scheduled_host_transition.cpp
index c827807..28541f5 100644
--- a/scheduled_host_transition.cpp
+++ b/scheduled_host_transition.cpp
@@ -11,6 +11,7 @@
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/ScheduledTime/error.hpp>
+#include <xyz/openbmc_project/State/Host/error.hpp>
#include <chrono>
#include <filesystem>
@@ -208,12 +209,12 @@
}
catch (const sdbusplus::exception_t& e)
{
+ using BMCNotReady = sdbusplus::error::xyz::openbmc_project::state::
+ host::BMCNotReady;
// If error indicates BMC is not at Ready error then reschedule for
// 60s later
if ((e.name() != nullptr) &&
- (e.name() ==
- std::string_view(
- "xyz.openbmc_project.State.Host.Error.BMCNotReady")))
+ (e.name() == std::string_view(BMCNotReady::errName)))
{
warning(
"BMC is not at ready, reschedule transition request for 60s");
diff --git a/secure_boot_check.cpp b/secure_boot_check.cpp
index c5f6dd8..ce3dfe0 100644
--- a/secure_boot_check.cpp
+++ b/secure_boot_check.cpp
@@ -3,6 +3,7 @@
#include "utils.hpp"
#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Logging/Settings/client.hpp>
#include <filesystem>
#include <fstream>
@@ -11,6 +12,8 @@
PHOSPHOR_LOG2_USING;
constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
+using LoggingSettings =
+ sdbusplus::client::xyz::openbmc_project::logging::Settings<>;
// Check if the TPM measurement file exists and has a valid value.
// If the TPM measurement is invalid, it logs an error message.
@@ -68,7 +71,7 @@
{
auto bus = sdbusplus::bus::new_default();
std::string path = "/xyz/openbmc_project/logging/settings";
- std::string interface = "xyz.openbmc_project.Logging.Settings";
+ std::string interface = LoggingSettings::interface;
std::string propertyName = "QuiesceOnHwError";
std::variant<bool> mfgModeEnabled;
diff --git a/settings.cpp b/settings.cpp
index 2e2e70a..a334a84 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -5,6 +5,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/exception.hpp>
+#include <xyz/openbmc_project/ObjectMapper/client.hpp>
namespace settings
{
@@ -14,17 +15,16 @@
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
-constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
-constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
Objects::Objects(sdbusplus::bus_t& bus, const Path& root) : bus(bus)
{
std::vector<std::string> settingsIntfs = {autoRebootIntf, powerRestoreIntf};
auto depth = 0;
- auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf,
- "GetSubTree");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetSubTree");
mapperCall.append(root);
mapperCall.append(depth);
mapperCall.append(settingsIntfs);
@@ -100,8 +100,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}));
diff --git a/settings.hpp b/settings.hpp
index 8f2dcda..a4ec5cc 100644
--- a/settings.hpp
+++ b/settings.hpp
@@ -1,6 +1,8 @@
#pragma once
#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Control/Boot/RebootPolicy/client.hpp>
+#include <xyz/openbmc_project/Control/Power/RestorePolicy/client.hpp>
#include <string>
@@ -12,9 +14,10 @@
using Interface = std::string;
constexpr auto defaultRoot = "/";
-constexpr auto autoRebootIntf = "xyz.openbmc_project.Control.Boot.RebootPolicy";
-constexpr auto powerRestoreIntf =
- "xyz.openbmc_project.Control.Power.RestorePolicy";
+constexpr auto autoRebootIntf = sdbusplus::client::xyz::openbmc_project::
+ control::boot::RebootPolicy<>::interface;
+constexpr auto powerRestoreIntf = sdbusplus::client::xyz::openbmc_project::
+ control::power::RestorePolicy<>::interface;
/** @class Objects
* @brief Fetch paths of settings d-bus objects of interest, upon construction
diff --git a/systemd_target_signal.cpp b/systemd_target_signal.cpp
index 8c76b97..2014045 100644
--- a/systemd_target_signal.cpp
+++ b/systemd_target_signal.cpp
@@ -8,6 +8,8 @@
#include <sdbusplus/server/manager.hpp>
#include <sdeventplus/event.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Logging/Create/client.hpp>
+#include <xyz/openbmc_project/Logging/Entry/client.hpp>
namespace phosphor
{
@@ -21,6 +23,10 @@
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
+using LoggingCreate =
+ sdbusplus::client::xyz::openbmc_project::logging::Create<>;
+using LoggingEntry = sdbusplus::client::xyz::openbmc_project::logging::Entry<>;
+
void SystemdTargetLogging::startBmcQuiesceTarget()
{
auto method = this->bus.new_method_call(
@@ -49,15 +55,15 @@
const std::string& result,
const std::string& unit)
{
- auto method = this->bus.new_method_call(
- "xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
- "xyz.openbmc_project.Logging.Create", "Create");
+ auto method = this->bus.new_method_call(LoggingCreate::default_service,
+ LoggingCreate::instance_path,
+ LoggingCreate::interface, "Create");
// Signature is ssa{ss}
- method.append(errorLog);
- method.append("xyz.openbmc_project.Logging.Entry.Level.Critical");
- method.append(std::array<std::pair<std::string, std::string>, 2>(
- {std::pair<std::string, std::string>({"SYSTEMD_RESULT", result}),
- std::pair<std::string, std::string>({"SYSTEMD_UNIT", unit})}));
+ method.append(
+ errorLog, LoggingEntry::Level::Critical,
+ std::array<std::pair<std::string, std::string>, 2>(
+ {std::pair<std::string, std::string>({"SYSTEMD_RESULT", result}),
+ std::pair<std::string, std::string>({"SYSTEMD_UNIT", unit})}));
try
{
this->bus.call_noreply(method);
diff --git a/utils.cpp b/utils.cpp
index 95760cb..332ddc0 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -7,6 +7,10 @@
#include <gpiod.h>
#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Dump/Create/client.hpp>
+#include <xyz/openbmc_project/Logging/Create/client.hpp>
+#include <xyz/openbmc_project/ObjectMapper/client.hpp>
+#include <xyz/openbmc_project/State/BMC/client.hpp>
#include <chrono>
#include <filesystem>
@@ -27,12 +31,10 @@
constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
-
-constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
+
void subscribeToSystemdSignals(sdbusplus::bus_t& bus)
{
auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
@@ -58,8 +60,9 @@
std::string getService(sdbusplus::bus_t& bus, std::string path,
std::string interface)
{
- auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
- MAPPER_INTERFACE, "GetObject");
+ auto mapper = bus.new_method_call(ObjectMapper::default_service,
+ ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetObject");
mapper.append(path, std::vector<std::string>({interface}));
@@ -174,9 +177,12 @@
// Always add the _PID on for some extra logging debug
additionalData.emplace("_PID", std::to_string(getpid()));
- auto method = bus.new_method_call(
- "xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
- "xyz.openbmc_project.Logging.Create", "Create");
+ using LoggingCreate =
+ sdbusplus::client::xyz::openbmc_project::logging::Create<>;
+
+ auto method = bus.new_method_call(LoggingCreate::default_service,
+ LoggingCreate::instance_path,
+ LoggingCreate::interface, "Create");
method.append(errorMsg, errLevel, additionalData);
auto resp = bus.call(method);
@@ -199,9 +205,14 @@
void createBmcDump(sdbusplus::bus_t& bus)
{
- auto method = bus.new_method_call(
- "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump/bmc",
- "xyz.openbmc_project.Dump.Create", "CreateDump");
+ using DumpCreate = sdbusplus::client::xyz::openbmc_project::dump::Create<>;
+ auto dumpPath =
+ sdbusplus::message::object_path(DumpCreate::namespace_path::value) /
+ DumpCreate::namespace_path::bmc;
+
+ auto method = bus.new_method_call(DumpCreate::default_service,
+ dumpPath.str.c_str(),
+ DumpCreate::interface, "CreateDump");
method.append(
std::vector<
std::pair<std::string, std::variant<std::string, uint64_t>>>());
@@ -233,10 +244,15 @@
bool isBmcReady(sdbusplus::bus_t& bus)
{
- auto bmcState = getProperty(bus, "/xyz/openbmc_project/state/bmc0",
- "xyz.openbmc_project.State.BMC",
+ using BMC = sdbusplus::client::xyz::openbmc_project::state::BMC<>;
+ auto bmcPath = sdbusplus::message::object_path(BMC::namespace_path::value) /
+ BMC::namespace_path::bmc;
+
+ auto bmcState = getProperty(bus, bmcPath.str.c_str(), BMC::interface,
"CurrentBMCState");
- if (bmcState != "xyz.openbmc_project.State.BMC.BMCState.Ready")
+
+ if (sdbusplus::message::convert_from_string<BMC::BMCState>(bmcState) !=
+ BMC::BMCState::Ready)
{
debug("BMC State is {BMC_STATE}", "BMC_STATE", bmcState);
return false;