Support Chassis TransitioningToOff/On state
When BMC turns on/off the host, it asserts/de-asserts the PSON to turn
on/off the power. After that, BMC takes a little bit of time to change
Chassis's state from Off/On to On/Off. During this time, BMC should show
a temporary state instead of directly jumping to On/Off state.
As defined in the PDI the "CurrentPowerState" property of "Chassis"
interface has 4 options[1]:
- On
- Off
- TransitioningToOn
- TransitioningToOff
This commit supports 2 more states: TransitioningToOn and
TransitioningToOff. 2 states are updated before PSON is asserted or
de-asserted.
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/Chassis.interface.yaml
Tested:
1. Update phosphor-state-manager recipe to add 2 services.
2. Turn on the host.
$ipmitool power on
3. Check the journalctl logs.
$journalctl | grep phosphor-chassis-state-manager
4. Chassis Power State is changed from TransitioningToOn to On.
5. Turn off the host.
$ipmitool power off
6. Check the journalctl logs.
$journalctl | grep phosphor-chassis-state-manager
7. Chassis Power State is changed from TransitioningToOff to Off.
Change-Id: I474882c87510351b5c64438b33d62072629e27e7
Signed-off-by: Thang Tran <thuutran@amperecomputing.com>
diff --git a/service_files/meson.build b/service_files/meson.build
index 8aec069..d622268 100644
--- a/service_files/meson.build
+++ b/service_files/meson.build
@@ -21,7 +21,9 @@
'phosphor-set-host-transition-to-running@.service',
'phosphor-chassis-check-power-status@.service',
'phosphor-bmc-security-check.service',
- 'phosphor-create-chassis-poweron-log@.service'
+ 'phosphor-create-chassis-poweron-log@.service',
+ 'phosphor-set-chassis-transition-to-on@.service',
+ 'phosphor-set-chassis-transition-to-off@.service'
]
fs = import('fs')
diff --git a/service_files/phosphor-set-chassis-transition-to-off@.service b/service_files/phosphor-set-chassis-transition-to-off@.service
new file mode 100644
index 0000000..5d04020
--- /dev/null
+++ b/service_files/phosphor-set-chassis-transition-to-off@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Set Chassis state to transition to off
+Before=obmc-power-stop@%i.service
+Wants=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+After=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+Conflicts=obmc-chassis-poweron@%i.target
+
+[Service]
+Restart=no
+Type=oneshot
+SyslogIdentifier=phosphor-set-chassis-transition-to-off
+ExecStart=/bin/sh -c "busctl set-property `mapper get-service /xyz/openbmc_project/state/chassis%i` /xyz/openbmc_project/state/chassis%i xyz.openbmc_project.State.Chassis CurrentPowerState s xyz.openbmc_project.State.Chassis.PowerState.TransitioningToOff"
+
+[Install]
+WantedBy=obmc-chassis-poweroff@%i.target
diff --git a/service_files/phosphor-set-chassis-transition-to-on@.service b/service_files/phosphor-set-chassis-transition-to-on@.service
new file mode 100644
index 0000000..e483ee0
--- /dev/null
+++ b/service_files/phosphor-set-chassis-transition-to-on@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Set Chassis state to transition to on
+Before=obmc-power-start@%i.service
+Wants=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+After=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+Conflicts=obmc-chassis-poweroff@%i.target
+ConditionPathExists=!/run/openbmc/chassis@%i-on
+
+[Service]
+Restart=no
+Type=oneshot
+SyslogIdentifier=phosphor-set-chassis-transition-to-on
+ExecStart=/bin/sh -c "busctl set-property `mapper get-service /xyz/openbmc_project/state/chassis%i` /xyz/openbmc_project/state/chassis%i xyz.openbmc_project.State.Chassis CurrentPowerState s xyz.openbmc_project.State.Chassis.PowerState.TransitioningToOn"
+
+[Install]
+WantedBy=obmc-chassis-poweron@%i.target