Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 3 | #include "config.h" |
| 4 | |
| 5 | #include "settings.hpp" |
| 6 | #include "xyz/openbmc_project/State/Host/server.hpp" |
| 7 | |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 8 | #include <cereal/access.hpp> |
Vishwanatha Subbanna | 0a83873 | 2017-10-05 12:43:19 +0530 | [diff] [blame] | 9 | #include <cereal/cereal.hpp> |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 10 | #include <phosphor-logging/lg2.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 11 | #include <sdbusplus/bus.hpp> |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 12 | #include <xyz/openbmc_project/Control/Boot/RebootAttempts/server.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 13 | #include <xyz/openbmc_project/State/Boot/Progress/server.hpp> |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 14 | #include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 15 | |
Patrick Williams | 6ed41ea | 2022-04-05 15:50:21 -0500 | [diff] [blame] | 16 | #include <filesystem> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 17 | #include <string> |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 18 | |
| 19 | namespace phosphor |
| 20 | { |
| 21 | namespace state |
| 22 | { |
| 23 | namespace manager |
| 24 | { |
| 25 | |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 26 | using HostInherit = sdbusplus::server::object_t< |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 27 | sdbusplus::xyz::openbmc_project::State::server::Host, |
| 28 | sdbusplus::xyz::openbmc_project::State::Boot::server::Progress, |
| 29 | sdbusplus::xyz::openbmc_project::Control::Boot::server::RebootAttempts, |
| 30 | sdbusplus::xyz::openbmc_project::State::OperatingSystem::server::Status>; |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 31 | |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 32 | PHOSPHOR_LOG2_USING; |
Andrew Geissler | 7b90a62 | 2017-08-08 11:41:08 -0500 | [diff] [blame] | 33 | |
Patrick Williams | d22706f | 2017-05-04 05:42:49 -0500 | [diff] [blame] | 34 | namespace sdbusRule = sdbusplus::bus::match::rules; |
Patrick Williams | 6ed41ea | 2022-04-05 15:50:21 -0500 | [diff] [blame] | 35 | namespace fs = std::filesystem; |
Patrick Williams | d22706f | 2017-05-04 05:42:49 -0500 | [diff] [blame] | 36 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 37 | /** @class Host |
| 38 | * @brief OpenBMC host state management implementation. |
| 39 | * @details A concrete implementation for xyz.openbmc_project.State.Host |
| 40 | * DBus API. |
| 41 | */ |
Patrick Williams | d22706f | 2017-05-04 05:42:49 -0500 | [diff] [blame] | 42 | class Host : public HostInherit |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 43 | { |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 44 | public: |
| 45 | /** @brief Constructs Host State Manager |
| 46 | * |
| 47 | * @note This constructor passes 'true' to the base class in order to |
| 48 | * defer dbus object registration until we can run |
| 49 | * determineInitialState() and set our properties |
| 50 | * |
| 51 | * @param[in] bus - The Dbus bus object |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 52 | * @param[in] objPath - The Dbus object path |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 53 | * @param[in] id - The Host id |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 54 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 55 | Host(sdbusplus::bus_t& bus, const char* objPath, size_t id) : |
Patrick Williams | 7607074 | 2022-04-05 15:20:12 -0500 | [diff] [blame] | 56 | HostInherit(bus, objPath, HostInherit::action::defer_emit), bus(bus), |
Andrew Geissler | e4039a8 | 2020-02-11 15:51:59 -0600 | [diff] [blame] | 57 | systemdSignalJobRemoved( |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 58 | bus, |
| 59 | sdbusRule::type::signal() + sdbusRule::member("JobRemoved") + |
| 60 | sdbusRule::path("/org/freedesktop/systemd1") + |
| 61 | sdbusRule::interface("org.freedesktop.systemd1.Manager"), |
William A. Kennington III | bd28f02 | 2022-11-22 17:11:49 -0800 | [diff] [blame] | 62 | [this](sdbusplus::message_t& m) { sysStateChangeJobRemoved(m); }), |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 63 | systemdSignalJobNew( |
| 64 | bus, |
| 65 | sdbusRule::type::signal() + sdbusRule::member("JobNew") + |
| 66 | sdbusRule::path("/org/freedesktop/systemd1") + |
| 67 | sdbusRule::interface("org.freedesktop.systemd1.Manager"), |
William A. Kennington III | bd28f02 | 2022-11-22 17:11:49 -0800 | [diff] [blame] | 68 | [this](sdbusplus::message_t& m) { sysStateChangeJobNew(m); }), |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 69 | settings(bus, id), id(id) |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 70 | { |
| 71 | // Enable systemd signals |
| 72 | subscribeToSystemdSignals(); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 73 | |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 74 | // create map of target name base on host id |
| 75 | createSystemdTargetMaps(); |
| 76 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 77 | // Will throw exception on fail |
| 78 | determineInitialState(); |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 79 | |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 80 | // Sets auto-reboot attempts to max-allowed |
| 81 | attemptsLeft(sdbusplus::xyz::openbmc_project::Control::Boot::server:: |
| 82 | RebootAttempts::retryAttempts()); |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 83 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 84 | // We deferred this until we could get our property correct |
| 85 | this->emit_object_added(); |
| 86 | } |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 87 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 88 | /** @brief Set value of HostTransition */ |
| 89 | Transition requestedHostTransition(Transition value) override; |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 90 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 91 | /** @brief Set Value for boot progress */ |
| 92 | ProgressStages bootProgress(ProgressStages value) override; |
Dhruvaraj Subhashchandran | 4e6534f | 2017-09-19 06:13:20 -0500 | [diff] [blame] | 93 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 94 | /** @brief Set Value for Operating System Status */ |
| 95 | OSStatus operatingSystemState(OSStatus value) override; |
Dhruvaraj Subhashchandran | 4e6534f | 2017-09-19 06:13:20 -0500 | [diff] [blame] | 96 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 97 | /** @brief Set value of CurrentHostState */ |
| 98 | HostState currentHostState(HostState value) override; |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 99 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 100 | /** |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 101 | * @brief Set value for allowable auto-reboot count |
| 102 | * |
| 103 | * This override is responsible for ensuring that when external users |
| 104 | * set the number of automatic retry attempts that the number of |
| 105 | * automatic reboot attempts left will update accordingly. |
| 106 | * |
| 107 | * @param[in] value - desired Reboot count value |
| 108 | * |
| 109 | * @return number of reboot attempts allowed. |
| 110 | */ |
| 111 | uint32_t retryAttempts(uint32_t value) override |
| 112 | { |
| 113 | if (sdbusplus::xyz::openbmc_project::Control::Boot::server:: |
| 114 | RebootAttempts::attemptsLeft() != value) |
| 115 | { |
| 116 | info("Automatic reboot retry attempts set to: {VALUE} ", "VALUE", |
| 117 | value); |
| 118 | sdbusplus::xyz::openbmc_project::Control::Boot::server:: |
| 119 | RebootAttempts::attemptsLeft(value); |
| 120 | } |
| 121 | |
| 122 | return (sdbusplus::xyz::openbmc_project::Control::Boot::server:: |
| 123 | RebootAttempts::retryAttempts(value)); |
| 124 | } |
| 125 | |
| 126 | /** |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 127 | * @brief Set host reboot count to default |
| 128 | * |
| 129 | * OpenBMC software controls the number of allowed reboot attempts so |
| 130 | * any external set request of this property will be overridden by |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 131 | * this function and set to the number of the allowed auto-reboot |
| 132 | * retry attempts found on the system. |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 133 | * |
| 134 | * The only code responsible for decrementing the boot count resides |
| 135 | * within this process and that will use the sub class interface |
| 136 | * directly |
| 137 | * |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 138 | * @param[in] value - Reboot count value |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 139 | * |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 140 | * @return number of reboot attempts left(allowed by retry attempts |
| 141 | * property) |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 142 | */ |
| 143 | uint32_t attemptsLeft(uint32_t value) override |
| 144 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 145 | debug("External request to reset reboot count"); |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 146 | auto retryAttempts = sdbusplus::xyz::openbmc_project::Control::Boot:: |
| 147 | server::RebootAttempts::retryAttempts(); |
| 148 | return ( |
| 149 | sdbusplus::xyz::openbmc_project::Control::Boot::server:: |
| 150 | RebootAttempts::attemptsLeft(std::min(value, retryAttempts))); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 151 | } |
Andrew Geissler | 7b90a62 | 2017-08-08 11:41:08 -0500 | [diff] [blame] | 152 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 153 | private: |
| 154 | /** |
| 155 | * @brief subscribe to the systemd signals |
| 156 | * |
| 157 | * This object needs to capture when it's systemd targets complete |
| 158 | * so it can keep it's state updated |
| 159 | * |
| 160 | **/ |
| 161 | void subscribeToSystemdSignals(); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 162 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 163 | /** |
| 164 | * @brief Determine initial host state and set internally |
| 165 | * |
| 166 | * @return Will throw exceptions on failure |
| 167 | **/ |
| 168 | void determineInitialState(); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 169 | |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 170 | /** |
| 171 | * create systemd target instance names and mapping table |
| 172 | **/ |
| 173 | void createSystemdTargetMaps(); |
| 174 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 175 | /** @brief Execute the transition request |
| 176 | * |
| 177 | * This function assumes the state has been validated and the host |
| 178 | * is in an appropriate state for the transition to be started. |
| 179 | * |
| 180 | * @param[in] tranReq - Transition requested |
| 181 | */ |
| 182 | void executeTransition(Transition tranReq); |
Andrew Geissler | 0cd2eaf | 2016-12-07 10:50:13 -0600 | [diff] [blame] | 183 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 184 | /** |
| 185 | * @brief Determine if target is active |
| 186 | * |
| 187 | * This function determines if the target is active and |
| 188 | * helps prevent misleading log recorded states. |
| 189 | * |
| 190 | * @param[in] target - Target string to check on |
| 191 | * |
| 192 | * @return boolean corresponding to state active |
| 193 | **/ |
| 194 | bool stateActive(const std::string& target); |
Josh D. King | 929ef70 | 2017-03-02 10:58:11 -0600 | [diff] [blame] | 195 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 196 | /** |
| 197 | * @brief Determine if auto reboot flag is set |
| 198 | * |
| 199 | * @return boolean corresponding to current auto_reboot setting |
| 200 | **/ |
| 201 | bool isAutoReboot(); |
Michael Tritz | 206a833 | 2017-02-06 16:01:23 -0600 | [diff] [blame] | 202 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 203 | /** @brief Check if systemd state change is relevant to this object |
| 204 | * |
| 205 | * Instance specific interface to handle the detected systemd state |
| 206 | * change |
| 207 | * |
| 208 | * @param[in] msg - Data associated with subscribed signal |
| 209 | * |
| 210 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 211 | void sysStateChangeJobRemoved(sdbusplus::message_t& msg); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 212 | |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 213 | /** @brief Check if JobNew systemd signal is relevant to this object |
| 214 | * |
| 215 | * In certain instances phosphor-state-manager needs to monitor for the |
| 216 | * entry into a systemd target. This function will be used for these cases. |
| 217 | * |
| 218 | * Instance specific interface to handle the detected systemd state |
| 219 | * change |
| 220 | * |
| 221 | * @param[in] msg - Data associated with subscribed signal |
| 222 | * |
| 223 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 224 | void sysStateChangeJobNew(sdbusplus::message_t& msg); |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 225 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 226 | /** @brief Decrement reboot count |
| 227 | * |
| 228 | * This is used internally to this application to decrement the boot |
| 229 | * count on each boot attempt. The host will use the external |
| 230 | * attemptsLeft() interface to reset the count when a boot is successful |
| 231 | * |
| 232 | * @return number of reboot count attempts left |
| 233 | */ |
| 234 | uint32_t decrementRebootCount(); |
Andrew Geissler | 7b90a62 | 2017-08-08 11:41:08 -0500 | [diff] [blame] | 235 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 236 | // Allow cereal class access to allow these next two function to be |
| 237 | // private |
| 238 | friend class cereal::access; |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 239 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 240 | /** @brief Function required by Cereal to perform serialization. |
| 241 | * |
| 242 | * @tparam Archive - Cereal archive type (binary in our case). |
| 243 | * @param[in] archive - reference to Cereal archive. |
| 244 | * @param[in] version - Class version that enables handling |
| 245 | * a serialized data across code levels |
| 246 | */ |
| 247 | template <class Archive> |
| 248 | void save(Archive& archive, const std::uint32_t version) const |
| 249 | { |
Andrew Geissler | 769a62f | 2019-12-06 13:36:08 -0600 | [diff] [blame] | 250 | // version is not used currently |
| 251 | (void)(version); |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 252 | archive(sdbusplus::xyz::openbmc_project::Control::Boot::server:: |
| 253 | RebootAttempts::retryAttempts(), |
| 254 | convertForMessage(sdbusplus::xyz::openbmc_project::State:: |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 255 | server::Host::requestedHostTransition()), |
| 256 | convertForMessage(sdbusplus::xyz::openbmc_project::State::Boot:: |
| 257 | server::Progress::bootProgress()), |
| 258 | convertForMessage( |
| 259 | sdbusplus::xyz::openbmc_project::State::OperatingSystem:: |
| 260 | server::Status::operatingSystemState())); |
| 261 | } |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 262 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 263 | /** @brief Function required by Cereal to perform deserialization. |
| 264 | * |
| 265 | * @tparam Archive - Cereal archive type (binary in our case). |
| 266 | * @param[in] archive - reference to Cereal archive. |
| 267 | * @param[in] version - Class version that enables handling |
| 268 | * a serialized data across code levels |
| 269 | */ |
| 270 | template <class Archive> |
| 271 | void load(Archive& archive, const std::uint32_t version) |
| 272 | { |
| 273 | std::string reqTranState; |
| 274 | std::string bootProgress; |
| 275 | std::string osState; |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 276 | // Older cereal archive without RetryAttempt may be implemented |
| 277 | // just set to (BOOT_COUNT_MAX_ALLOWED) |
| 278 | uint32_t retryAttempts = BOOT_COUNT_MAX_ALLOWED; |
| 279 | switch (version) |
| 280 | { |
| 281 | case 2: |
| 282 | archive(retryAttempts); |
| 283 | [[fallthrough]]; |
| 284 | case 1: |
| 285 | archive(reqTranState, bootProgress, osState); |
| 286 | break; |
| 287 | } |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 288 | auto reqTran = Host::convertTransitionFromString(reqTranState); |
| 289 | // When restoring, set the requested state with persistent value |
| 290 | // but don't call the override which would execute it |
| 291 | sdbusplus::xyz::openbmc_project::State::server::Host:: |
| 292 | requestedHostTransition(reqTran); |
| 293 | sdbusplus::xyz::openbmc_project::State::Boot::server::Progress:: |
| 294 | bootProgress(Host::convertProgressStagesFromString(bootProgress)); |
| 295 | sdbusplus::xyz::openbmc_project::State::OperatingSystem::server:: |
| 296 | Status::operatingSystemState( |
| 297 | Host::convertOSStatusFromString(osState)); |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 298 | sdbusplus::xyz::openbmc_project::Control::Boot::server::RebootAttempts:: |
| 299 | retryAttempts(retryAttempts); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 300 | } |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 301 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 302 | /** @brief Serialize and persist requested host state |
| 303 | * |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 304 | * @return fs::path - pathname of persisted requested host state. |
| 305 | */ |
Allen.Wang | ba182f0 | 2022-03-23 19:01:53 +0800 | [diff] [blame] | 306 | fs::path serialize(); |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 307 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 308 | /** @brief Deserialze a persisted requested host state. |
| 309 | * |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 310 | * @return bool - true if the deserialization was successful, false |
| 311 | * otherwise. |
| 312 | */ |
Allen.Wang | ba182f0 | 2022-03-23 19:01:53 +0800 | [diff] [blame] | 313 | bool deserialize(); |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 314 | |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 315 | /** |
| 316 | * @brief Get target name of a HostState |
| 317 | * |
| 318 | * @param[in] state - The state of the host |
| 319 | * |
| 320 | * @return string - systemd target name of the state |
| 321 | */ |
| 322 | const std::string& getTarget(HostState state); |
| 323 | |
| 324 | /** |
| 325 | * @brief Get target name of a TransitionRequest |
| 326 | * |
| 327 | * @param[in] tranReq - Transition requested |
| 328 | * |
| 329 | * @return string - systemd target name of Requested transition |
| 330 | */ |
| 331 | const std::string& getTarget(Transition tranReq); |
| 332 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 333 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 334 | sdbusplus::bus_t& bus; |
Andrew Geissler | ef62116 | 2016-12-08 12:56:21 -0600 | [diff] [blame] | 335 | |
Andrew Geissler | e4039a8 | 2020-02-11 15:51:59 -0600 | [diff] [blame] | 336 | /** @brief Used to subscribe to dbus systemd JobRemoved signal **/ |
| 337 | sdbusplus::bus::match_t systemdSignalJobRemoved; |
Deepak Kodihalli | 3dd08a5 | 2017-07-25 07:34:44 -0500 | [diff] [blame] | 338 | |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 339 | /** @brief Used to subscribe to dbus systemd JobNew signal **/ |
| 340 | sdbusplus::bus::match_t systemdSignalJobNew; |
| 341 | |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 342 | // Settings host objects of interest |
| 343 | settings::HostObjects settings; |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 344 | |
| 345 | /** @brief Host id. **/ |
| 346 | const size_t id = 0; |
| 347 | |
| 348 | /** @brief HostState to systemd target mapping table. **/ |
| 349 | std::map<HostState, std::string> stateTargetTable; |
| 350 | |
| 351 | /** @brief Requested Transition to systemd target mapping table. **/ |
| 352 | std::map<Transition, std::string> transitionTargetTable; |
Andrew Geissler | 128ea8e | 2022-06-22 12:28:15 -0400 | [diff] [blame] | 353 | |
| 354 | /** @brief Target called when a host crash occurs **/ |
| 355 | std::string hostCrashTarget; |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | } // namespace manager |
| 359 | } // namespace state |
| 360 | } // namespace phosphor |