| From a1f9d797753e32b36e08e7d611ff88b10e9bbad2 Mon Sep 17 00:00:00 2001 |
| From: "Jason M. Bills" <jason.m.bills@linux.intel.com> |
| Date: Thu, 30 Jan 2020 16:18:33 -0800 |
| Subject: [PATCH 1/3] Add Chassis State Transition interface |
| |
| This adds the Chassis State Transition interface in preparation |
| to support the mapping defined in the design document below. |
| |
| ref: https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/22358 |
| |
| Tested: |
| Ran each IPMI chassis control command to confirm the expected |
| behavior: |
| ipmitool power on: system is powered-on |
| ipmitool power off: system is forced off |
| ipmitool power cycle: system is forced off then powered-on |
| ipmitool power reset: system is hard reset |
| ipmitool power soft: soft power-off requested from system software |
| |
| Change-Id: I6acfb795a9a33ff5227a5d6e1830774ab732ac0c |
| Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com> |
| --- |
| chassishandler.cpp | 33 +++++++++++++++++++++++++++++++++ |
| 1 file changed, 33 insertions(+) |
| |
| diff --git a/chassishandler.cpp b/chassishandler.cpp |
| index 0d318647..fdbb9fa5 100644 |
| --- a/chassishandler.cpp |
| +++ b/chassishandler.cpp |
| @@ -31,6 +31,7 @@ |
| #include <xyz/openbmc_project/Control/Boot/Mode/server.hpp> |
| #include <xyz/openbmc_project/Control/Boot/Source/server.hpp> |
| #include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp> |
| +#include <xyz/openbmc_project/State/Chassis/server.hpp> |
| #include <xyz/openbmc_project/State/Host/server.hpp> |
| #include <xyz/openbmc_project/State/PowerOnHours/server.hpp> |
| |
| @@ -865,6 +866,38 @@ int initiate_state_transition(State::Host::Transition transition) |
| return rc; |
| } |
| |
| +//------------------------------------------ |
| +// Calls into Chassis State Manager Dbus object |
| +//------------------------------------------ |
| +int initiateChassisStateTransition(State::Chassis::Transition transition) |
| +{ |
| + // OpenBMC Chassis State Manager dbus framework |
| + constexpr auto chassisStatePath = "/xyz/openbmc_project/state/chassis0"; |
| + constexpr auto chassisStateIntf = "xyz.openbmc_project.State.Chassis"; |
| + |
| + auto service = |
| + ipmi::getService(*getSdBus(), chassisStateIntf, chassisStatePath); |
| + |
| + // Convert to string equivalent of the passed in transition enum. |
| + auto request = State::convertForMessage(transition); |
| + |
| + try |
| + { |
| + ipmi::setDbusProperty(*getSdBus(), service, chassisStatePath, |
| + chassisStateIntf, "RequestedPowerTransition", |
| + request); |
| + } |
| + catch (std::exception& e) |
| + { |
| + log<level::ERR>( |
| + "Failed to initiate transition", |
| + entry("EXCEPTION=%s, REQUEST=%s", e.what(), request.c_str())); |
| + return -1; |
| + } |
| + |
| + return 0; |
| +} |
| + |
| //------------------------------------------ |
| // Set Enabled property to inform NMI source |
| // handling to trigger a NMI_OUT BSOD. |
| -- |
| 2.21.0 |
| |