Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include "xyz/openbmc_project/State/Host/server.hpp" |
| 5 | |
| 6 | namespace phosphor |
| 7 | { |
| 8 | namespace state |
| 9 | { |
| 10 | namespace manager |
| 11 | { |
| 12 | |
| 13 | /** @class Host |
| 14 | * @brief OpenBMC host state management implementation. |
| 15 | * @details A concrete implementation for xyz.openbmc_project.State.Host |
| 16 | * DBus API. |
| 17 | */ |
| 18 | class Host : public sdbusplus::server::object::object< |
| 19 | sdbusplus::xyz::openbmc_project::State::server::Host> |
| 20 | { |
| 21 | public: |
| 22 | /** @brief Constructs Host State Manager |
| 23 | * |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 24 | * @note This constructor passes 'true' to the base class in order to |
| 25 | * defer dbus object registration until we can run |
| 26 | * determineInitialState() and set our properties |
| 27 | * |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 28 | * @param[in] bus - The Dbus bus object |
| 29 | * @param[in] busName - The Dbus name to own |
| 30 | * @param[in] objPath - The Dbus object path |
| 31 | */ |
| 32 | Host(sdbusplus::bus::bus& bus, |
| 33 | const char* busName, |
| 34 | const char* objPath) : |
| 35 | sdbusplus::server::object::object< |
| 36 | sdbusplus::xyz::openbmc_project::State::server::Host>( |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 37 | bus, objPath, true), |
| 38 | bus(bus) |
| 39 | { |
| 40 | // Will throw exception on fail |
| 41 | determineInitialState(); |
| 42 | |
| 43 | // We deferred this until we could get our property correct |
| 44 | this->emit_object_added(); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @brief Determine initial host state and set internally |
| 49 | * |
| 50 | * @return Will throw exceptions on failure |
| 51 | **/ |
| 52 | void determineInitialState(); |
| 53 | |
| 54 | /** @brief Set value of HostTransition */ |
| 55 | Transition requestedHostTransition(Transition value) override; |
| 56 | |
| 57 | /** @brief Set value of CurrentHostState */ |
| 58 | HostState currentHostState(HostState value) override; |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 59 | |
| 60 | private: |
Andrew Geissler | 0cd2eaf | 2016-12-07 10:50:13 -0600 | [diff] [blame^] | 61 | /** @brief Execute the transition request |
| 62 | * |
| 63 | * This function assumes the state has been validated and the host |
| 64 | * is in an appropriate state for the transition to be started. |
| 65 | * |
| 66 | * @param[in] tranReq - Transition requested |
| 67 | */ |
| 68 | void executeTransition(Transition tranReq); |
| 69 | |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 70 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 71 | sdbusplus::bus::bus& bus; |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace manager |
| 75 | } // namespace state |
| 76 | } // namespace phosphor |