Correct chassis's PowerState reading condition
phosphor-dbus-interfaces defines 4 values for PowerState property under
xyz.openbmc_project.State.Chassis interface [1]. The current logic
causes all the other values except for
`xyz.openbmc_project.State.Chassis.PowerState.On` to be interpreted as
`Off` in `ipmitool power status`. This patch supports interpreting
CurrentPowerState value to adapt all states following the logic in the
Tested section below.
Tested:
`D-Bus value ends with` <=> `$ipmitool power status`
*.Off <=> Chassis Power is off
*.TransitioningToOn <=> Chassis Power is off
*.On <=> Chassis Power is on
*.TransitioningToOff <=> Chassis Power is on
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Chassis.interface.yaml
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: Ic8e9f0a10b061137126ed3e24ad71e3bf80a5a34
diff --git a/chassishandler.cpp b/chassishandler.cpp
index e48816f..fbb8561 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -971,8 +971,12 @@
ipmi::Value powerState =
ipmi::getDbusProperty(*busp, service, chassisStatePath,
chassisStateIntf, "CurrentPowerState");
- powerGood = std::get<std::string>(powerState) ==
- "xyz.openbmc_project.State.Chassis.PowerState.On";
+ std::string powerStateStr = std::get<std::string>(powerState);
+ if (powerStateStr.ends_with(".On") ||
+ powerStateStr.ends_with(".TransitioningToOff"))
+ {
+ powerGood = true;
+ }
}
catch (const std::exception& e)
{