Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 1 | #include <iostream> |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame^] | 2 | #include <systemd/sd-bus.h> |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 3 | #include "host_state_manager.hpp" |
| 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace state |
| 8 | { |
| 9 | namespace manager |
| 10 | { |
| 11 | |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame^] | 12 | // TODO - Will be rewritten once sdbusplus client bindings are in place |
| 13 | // and persistent storage design is in place |
| 14 | void 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 | |
| 48 | Host::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 | |
| 57 | Host::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 Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 66 | } // namespace manager |
| 67 | } // namespace state |
| 68 | } // namepsace phosphor |