Support reboot transition request in host interface
Change-Id: Ic09ccf710f13697fd203ca1b96c3b5084a76511b
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 1d5351a..c532b9d 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -98,9 +98,25 @@
auto it = SYS_HOST_STATE_TABLE.find(newState);
if(it != SYS_HOST_STATE_TABLE.end())
{
- HostState gotoState = it->second;
+ // This is a state change we're interested in so process it
+ Host::HostState gotoState = it->second;
+ // Grab the host object instance from the userData
auto hostInst = static_cast<Host*>(usrData);
hostInst->currentHostState(gotoState);
+
+ // Check if we need to start a new transition (i.e. a Reboot)
+ if((gotoState == server::Host::HostState::Off) &&
+ (hostInst->server::Host::requestedHostTransition() ==
+ Transition::Reboot))
+ {
+ std::cout << "Reached intermediate state, going to next" <<
+ std::endl;
+ hostInst->executeTransition(server::Host::Transition::On);
+ }
+ else
+ {
+ std::cout << "Reached Final State " << newState << std::endl;
+ }
}
else
{
@@ -114,9 +130,26 @@
{
std::cout << "Someone is setting the RequestedHostTransition field"
<< std::endl;
- executeTransition(value);
- std::cout << "Transition executed with success" << std::endl;
+ Transition tranReq = value;
+ if(value == server::Host::Transition::Reboot)
+ {
+ // On reboot requests we just need to do a off if we're on and
+ // vice versa. The handleSysStateChange() code above handles the
+ // second part of the reboot
+ if(this->server::Host::currentHostState() ==
+ server::Host::HostState::Off)
+ {
+ tranReq = server::Host::Transition::On;
+ }
+ else
+ {
+ tranReq = server::Host::Transition::Off;
+ }
+ }
+
+ executeTransition(tranReq);
+ std::cout << "Transition executed with success" << std::endl;
return server::Host::requestedHostTransition(value);
}