diff options
author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2019-05-21 09:57:16 -0700 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2019-06-24 23:18:20 +0000 |
commit | 3de424cd4e55ff85ed013282b4308f9f80c77894 (patch) | |
tree | 235e473a0f132bf05b1996818dc6f95a73404e78 /chassishandler.cpp | |
parent | bc996a358719e24d2ab1108167cfc9f019d3fec9 (diff) | |
download | phosphor-host-ipmid-3de424cd4e55ff85ed013282b4308f9f80c77894.tar.gz phosphor-host-ipmid-3de424cd4e55ff85ed013282b4308f9f80c77894.zip |
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>
Diffstat (limited to 'chassishandler.cpp')
-rw-r--r-- | chassishandler.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/chassishandler.cpp b/chassishandler.cpp index 0f2d10c..88bf84b 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -822,20 +822,22 @@ std::optional<uint2_t> getPowerRestorePolicy() */ 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 @@ std::optional<bool> getPowerStatus() 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; } } |