use PDI constants for State.Host
Tested: Inspection only.
Change-Id: I0be6d281b49f30814dd40309cc9af540d7d6ea86
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/chassishandler.cpp b/chassishandler.cpp
index d4bc27d..2f8cbad 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -125,6 +125,7 @@
using namespace sdbusplus::error::xyz::openbmc_project::common;
using namespace sdbusplus::server::xyz::openbmc_project::control::boot;
using Intrusion = sdbusplus::client::xyz::openbmc_project::chassis::Intrusion<>;
+using HostState = sdbusplus::common::xyz::openbmc_project::state::Host;
namespace chassis
{
@@ -821,8 +822,8 @@
State::Host::Transition transition)
{
// OpenBMC Host State Manager dbus framework
- constexpr auto hostStatePath = "/xyz/openbmc_project/state/host0";
- constexpr auto hostStateIntf = "xyz.openbmc_project.State.Host";
+ const auto hostStatePath =
+ std::format("{}/{}", HostState::namespace_path::value, "host0");
// Convert to string equivalent of the passed in transition enum.
auto request =
@@ -831,12 +832,13 @@
std::string service;
boost::system::error_code ec =
- ipmi::getService(ctx, hostStateIntf, hostStatePath, service);
+ ipmi::getService(ctx, HostState::interface, hostStatePath, service);
if (!ec)
{
- ec = ipmi::setDbusProperty(ctx, service, hostStatePath, hostStateIntf,
- "RequestedHostTransition", request);
+ ec = ipmi::setDbusProperty(
+ ctx, service, hostStatePath, HostState::interface,
+ HostState::property_names::requested_host_transition, request);
}
if (ec)
{
@@ -1342,17 +1344,16 @@
static std::optional<uint4_t> getRestartCause(ipmi::Context::ptr ctx)
{
constexpr const char* restartCausePath = "/xyz/openbmc_project/state/host0";
- constexpr const char* restartCauseIntf = "xyz.openbmc_project.State.Host";
std::string service;
boost::system::error_code ec =
- ipmi::getService(ctx, restartCauseIntf, restartCausePath, service);
+ ipmi::getService(ctx, HostState::interface, restartCausePath, service);
if (!ec)
{
std::string restartCauseStr;
ec = ipmi::getDbusProperty<std::string>(
- ctx, service, restartCausePath, restartCauseIntf, "RestartCause",
- restartCauseStr);
+ ctx, service, restartCausePath, HostState::interface,
+ HostState::property_names::restart_cause, restartCauseStr);
if (!ec)
{
auto cause =
@@ -1365,7 +1366,7 @@
lg2::error(
"Failed to fetch RestartCause property ({PATH}/{INTERFACE}): {ERROR}",
"ERROR", ec.message(), "PATH", restartCausePath, "INTERFACE",
- restartCauseIntf);
+ HostState::interface);
return std::nullopt;
}
diff --git a/host-cmd-manager.cpp b/host-cmd-manager.cpp
index 3b3304f..4bbbb55 100644
--- a/host-cmd-manager.cpp
+++ b/host-cmd-manager.cpp
@@ -14,6 +14,8 @@
#include <chrono>
+using HostState = sdbusplus::common::xyz::openbmc_project::state::Host;
+
namespace phosphor
{
namespace host
@@ -21,10 +23,6 @@
namespace command
{
-constexpr auto HOST_STATE_PATH = "/xyz/openbmc_project/state/host0";
-constexpr auto HOST_STATE_INTERFACE = "xyz.openbmc_project.State.Host";
-constexpr auto HOST_TRANS_PROP = "RequestedHostTransition";
-
// For throwing exceptions
using namespace phosphor::logging;
using InternalFailure =
@@ -36,7 +34,8 @@
bus(bus), timer(std::bind(&Manager::hostTimeout, this)),
hostTransitionMatch(
bus,
- sdbusRule::propertiesChanged(HOST_STATE_PATH, HOST_STATE_INTERFACE),
+ sdbusRule::propertiesChanged("/xyz/openbmc_project/state/host0",
+ HostState::interface),
std::bind(&Manager::clearQueueOnPowerOn, this, std::placeholders::_1))
{
// Nothing to do here.
@@ -175,13 +174,14 @@
msg.read(interface, properties);
- if (properties.find(HOST_TRANS_PROP) == properties.end())
+ if (properties.find(HostState::property_names::requested_host_transition) ==
+ properties.end())
{
return;
}
- auto& requestedState =
- std::get<std::string>(properties.at(HOST_TRANS_PROP));
+ auto& requestedState = std::get<std::string>(
+ properties.at(HostState::property_names::requested_host_transition));
if (server::Host::convertTransitionFromString(requestedState) ==
server::Host::Transition::On)