Power restore from last state after AC Loss
In situations where the power restore policy was set to Restore from
the last known state (Restore) and the requested host transition was
not denoted as "On" would lead to the host never powering back on.
For example, this occurs during a fresh boot of a system or after
completing a system update where other RequestedHostTransition
properties may be set such as 'GracefulWarmReboot'. This lead to the
old logic in discover system state to never power the host back on
which means there was a potential that users would have to manually
power back on the host. This change inverts the logic, essentially
checking to ensure the 'RequestedHostTransition' was not set to off
and therefore indicating that power should be restored in all other
cases (per the interface documentation).
Tested:
- All testing was with PowerRestorePolicy as 'Restore'
The corresponding gui option is 'LastState'.
- Applied changes and ensured that power was restored to
the host with 'GracefulWarmReboot' set as the desired
host transition property.
- Set 'RequestedHostTransition' property to "Reboot",
"GraceFulWarmReboot", "ForcedWarmReboot" and verified
that chassis power state was restored to 'On' after
a power cycle.
- Confirmed that with any of the transition properties
listed above set that the 'RequestedHostTransition'
state switched to on after reboot.
- Verified that power state remained off when the
'RequestedHostTransition' property was set to 'Off'.
Also that this property remained 'Off' after reboot.
Signed-off-by: Corey Hardesty <corey.hardesty@icloud.com>
Change-Id: Ie582bf16b51a4cbc0c3c8b3016e3ed9e5f59cb80
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index 28399bd..0e56144 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -156,7 +156,8 @@
// Read last requested state and re-request it to execute it
auto hostReqState = phosphor::state::manager::utils::getProperty(
bus, hostPath, HOST_BUSNAME, "RequestedHostTransition");
- if (hostReqState == convertForMessage(server::Host::Transition::On))
+ if (hostReqState !=
+ convertForMessage(server::Host::Transition::Off))
{
phosphor::state::manager::utils::setProperty(
bus, hostPath, HOST_BUSNAME, "RequestedHostTransition",
@@ -170,7 +171,10 @@
// Read last requested state and re-request it to execute it
auto hostReqState = phosphor::state::manager::utils::getProperty(
bus, hostPath, HOST_BUSNAME, "RequestedHostTransition");
- if (hostReqState == convertForMessage(server::Host::Transition::On))
+
+ // As long as the host transition is not 'Off' power on host state.
+ if (hostReqState !=
+ convertForMessage(server::Host::Transition::Off))
{
phosphor::state::manager::utils::setProperty(
bus, hostPath, HOST_BUSNAME, "RestartCause",
@@ -178,7 +182,7 @@
server::Host::RestartCause::PowerPolicyPreviousState));
phosphor::state::manager::utils::setProperty(
bus, hostPath, HOST_BUSNAME, "RequestedHostTransition",
- hostReqState);
+ convertForMessage(server::Host::Transition::On));
}
}
}