blob: 162ebd0c8b9c56accf3556a187be9adeee4df4e2 [file] [log] [blame]
Andrew Geissler36529022016-11-29 15:23:54 -06001#include <iostream>
Andrew Geissleref3c1842016-12-01 12:33:09 -06002#include <systemd/sd-bus.h>
Andrew Geissler36529022016-11-29 15:23:54 -06003#include "host_state_manager.hpp"
4
5namespace phosphor
6{
7namespace state
8{
9namespace manager
10{
11
Andrew Geissleref3c1842016-12-01 12:33:09 -060012// TODO - Will be rewritten once sdbusplus client bindings are in place
13// and persistent storage design is in place
14void Host::determineInitialState()
15{
16 std::string sysState;
17
18 auto method = this->bus.new_method_call("org.openbmc.managers.System",
19 "/org/openbmc/managers/System",
20 "org.openbmc.managers.System",
21 "getSystemState");
22
23 auto reply = this->bus.call(method);
24
25 reply.read(sysState);
26
27 if(sysState == "HOST_BOOTED")
28 {
29 std::cout << "HOST is BOOTED " << sysState << std::endl;
30 sdbusplus::xyz::openbmc_project::State::server::Host::
31 currentHostState(HostState::Running);
32 }
33 else
34 {
35 std::cout << "HOST is not BOOTED " << sysState << std::endl;
36 sdbusplus::xyz::openbmc_project::State::server::Host::
37 currentHostState(HostState::Off);
38 }
39
40 // Set transition initially to Off
41 // TODO - Eventually need to restore this from persistent storage
42 sdbusplus::xyz::openbmc_project::State::server::Host::
43 requestedHostTransition(Transition::Off);
44
45 return;
46}
47
48Host::Transition Host::requestedHostTransition(Transition value)
49{
50 std::cout << "Someone is setting the RequestedHostTransition field" <<
51 std::endl;
52 return sdbusplus::xyz::openbmc_project::State::server::Host::
53 requestedHostTransition(value);
54}
55
56
57Host::HostState Host::currentHostState(HostState value)
58{
59 std::cout << "Someone is being bad and trying to set the HostState field" <<
60 std::endl;
61
62 return sdbusplus::xyz::openbmc_project::State::server::Host::
63 currentHostState();
64}
65
Andrew Geissler36529022016-11-29 15:23:54 -060066} // namespace manager
67} // namespace state
68} // namepsace phosphor