Use xyz.openbmc_project.State.Chassis for IPMI chassis status
Instead of directly using pgood on dbus, this change uses the
xyz.openbmc_project.State.Chassis "CurrentPowerState" property
for the IPMI chassis status command. This will allow us to
remove pgood from dbus.
Tested:
Ran IPMI chassis commands and confirmed that they behave as
expected:
ipmitool power status
Chassis Power is on
ipmitool power off
Chassis Power Control: Down/Off
ipmitool power status
Chassis Power is off
ipmitool power on
Chassis Power Control: Up/On
ipmitool power status
Chassis Power is on
Change-Id: I7836c16b76c3b309f176186f3e2453082e4cd1af
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/chassishandler.cpp b/chassishandler.cpp
index 0f2d10c..88bf84b 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -822,20 +822,22 @@
*/
std::optional<bool> getPowerStatus()
{
- constexpr const char* powerControlObj =
- "/xyz/openbmc_project/Chassis/Control/Power0";
- constexpr const char* powerControlIntf =
- "xyz.openbmc_project.Chassis.Control.Power";
bool powerGood = false;
std::shared_ptr<sdbusplus::asio::connection> busp = getSdBus();
try
{
+ constexpr const char* chassisStatePath =
+ "/xyz/openbmc_project/state/chassis0";
+ constexpr const char* chassisStateIntf =
+ "xyz.openbmc_project.State.Chassis";
auto service =
- ipmi::getService(*busp, powerControlIntf, powerControlObj);
+ ipmi::getService(*busp, chassisStateIntf, chassisStatePath);
- ipmi::Value variant = ipmi::getDbusProperty(
- *busp, service, powerControlObj, powerControlIntf, "pgood");
- powerGood = static_cast<bool>(std::get<int>(variant));
+ ipmi::Value powerState =
+ ipmi::getDbusProperty(*busp, service, chassisStatePath,
+ chassisStateIntf, "CurrentPowerState");
+ powerGood = std::get<std::string>(powerState) ==
+ "xyz.openbmc_project.State.Chassis.PowerState.On";
}
catch (const std::exception& e)
{
@@ -856,9 +858,7 @@
catch (const std::exception& e)
{
log<level::ERR>("Failed to fetch pgood property",
- entry("ERROR=%s", e.what()),
- entry("PATH=%s", powerControlObj),
- entry("INTERFACE=%s", powerControlIntf));
+ entry("ERROR=%s", e.what()));
return std::nullopt;
}
}