use PDI constants for State.BMC
Tested: Inspection only.
Change-Id: I7ba48d7f5f856d5f284b68f8344b982da08c58df
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/apphandler.cpp b/apphandler.cpp
index 85334fc..014355c 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -46,8 +46,6 @@
extern sd_bus* bus;
-constexpr auto bmc_state_interface = "xyz.openbmc_project.State.BMC";
-constexpr auto bmc_state_property = "CurrentBMCState";
constexpr auto versionPurposeHostEnd = ".Host";
static constexpr auto redundancyIntf =
@@ -64,7 +62,7 @@
using Version = sdbusplus::server::xyz::openbmc_project::software::Version;
using Activation =
sdbusplus::server::xyz::openbmc_project::software::Activation;
-using BMC = sdbusplus::server::xyz::openbmc_project::state::BMC;
+using BMCState = sdbusplus::server::xyz::openbmc_project::state::BMC;
namespace fs = std::filesystem;
#ifdef ENABLE_I2C_WHITELIST_CHECK
@@ -186,14 +184,14 @@
// Get the Inventory object implementing the BMC interface
ipmi::DbusObjectInfo bmcObject =
- ipmi::getDbusObject(bus, bmc_state_interface);
- auto variant =
- ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first,
- bmc_state_interface, bmc_state_property);
+ ipmi::getDbusObject(bus, BMCState::interface);
+ auto variant = ipmi::getDbusProperty(
+ bus, bmcObject.second, bmcObject.first, BMCState::interface,
+ BMCState::property_names::current_bmc_state);
return std::holds_alternative<std::string>(variant) &&
- BMC::convertBMCStateFromString(std::get<std::string>(variant)) ==
- BMC::BMCState::Ready;
+ BMCState::convertBMCStateFromString(
+ std::get<std::string>(variant)) == BMCState::BMCState::Ready;
}
bool getCurrentBmcStateWithFallback(const bool fallbackAvailability)
diff --git a/globalhandler.cpp b/globalhandler.cpp
index 7b64d42..36cf0a4 100644
--- a/globalhandler.cpp
+++ b/globalhandler.cpp
@@ -5,12 +5,7 @@
#include <string>
-static constexpr auto bmcStateRoot = "/xyz/openbmc_project/state";
-static constexpr auto bmcStateIntf = "xyz.openbmc_project.State.BMC";
-static constexpr auto reqTransition = "RequestedBMCTransition";
-static constexpr auto match = "bmc0";
-
-using BMC = sdbusplus::server::xyz::openbmc_project::state::BMC;
+using BMCState = sdbusplus::server::xyz::openbmc_project::state::BMC;
void registerNetFnGlobalFunctions() __attribute__((constructor));
@@ -22,16 +17,19 @@
{
ipmi::DbusObjectInfo bmcStateObj;
boost::system::error_code ec = ipmi::getDbusObject(
- ctx, bmcStateIntf, bmcStateRoot, match, bmcStateObj);
+ ctx, BMCState::interface, BMCState::namespace_path::value,
+ BMCState::namespace_path::bmc, bmcStateObj);
if (!ec)
{
std::string service;
- ec = ipmi::getService(ctx, bmcStateIntf, bmcStateObj.first, service);
+ ec = ipmi::getService(ctx, BMCState::interface, bmcStateObj.first,
+ service);
if (!ec)
{
ec = ipmi::setDbusProperty(
- ctx, service, bmcStateObj.first, bmcStateIntf, reqTransition,
- convertForMessage(BMC::Transition::Reboot));
+ ctx, service, bmcStateObj.first, BMCState::interface,
+ BMCState::property_names::requested_bmc_transition,
+ convertForMessage(BMCState::Transition::Reboot));
}
}
if (ec)
diff --git a/oem/example/apphandler.cpp b/oem/example/apphandler.cpp
index 678f71a..7ded160 100644
--- a/oem/example/apphandler.cpp
+++ b/oem/example/apphandler.cpp
@@ -26,9 +26,6 @@
#include <tuple>
#include <vector>
-constexpr auto bmcStateInterface = "xyz.openbmc_project.State.BMC";
-constexpr auto bmcStateProperty = "CurrentBMCState";
-
static constexpr auto redundancyIntf =
"xyz.openbmc_project.Software.RedundancyPriority";
static constexpr auto versionIntf = "xyz.openbmc_project.Software.Version";
@@ -43,7 +40,7 @@
using Version = sdbusplus::server::xyz::openbmc_project::software::Version;
using Activation =
sdbusplus::server::xyz::openbmc_project::software::Activation;
-using BMC = sdbusplus::server::xyz::openbmc_project::state::BMC;
+using BMCState = sdbusplus::server::xyz::openbmc_project::state::BMC;
namespace fs = std::filesystem;
/**
@@ -134,19 +131,21 @@
// Get the Inventory object implementing the BMC interface
ipmi::DbusObjectInfo bmcObject{};
boost::system::error_code ec =
- ipmi::getDbusObject(ctx, bmcStateInterface, bmcObject);
+ ipmi::getDbusObject(ctx, BMCState::interface, bmcObject);
std::string bmcState{};
if (ec.value())
{
return fallbackAvailability;
}
- ec = ipmi::getDbusProperty(ctx, bmcObject.second, bmcObject.first,
- bmcStateInterface, bmcStateProperty, bmcState);
+ ec = ipmi::getDbusProperty(
+ ctx, bmcObject.second, bmcObject.first, BMCState::interface,
+ BMCState::property_names::current_bmc_state, bmcState);
if (!ec.value())
{
return fallbackAvailability;
}
- return BMC::convertBMCStateFromString(bmcState) == BMC::BMCState::Ready;
+ return BMCState::convertBMCStateFromString(bmcState) ==
+ BMCState::BMCState::Ready;
}
typedef struct