blob: ffb37b1e551d4715bcd1a8f37e7d5815e7f7860b [file] [log] [blame]
Andrew Geisslere426b582020-05-28 12:40:55 -05001#include "config.h"
2
3#include "host_state_manager.hpp"
4
Matt Spinlerbbbc0162020-11-11 14:43:50 -06005#include <fmt/format.h>
Andrew Geissler131d04a2021-03-12 11:02:41 -06006#include <stdio.h>
Andrew Geisslere426b582020-05-28 12:40:55 -05007#include <systemd/sd-bus.h>
8
9#include <cereal/archives/json.hpp>
10#include <cereal/cereal.hpp>
11#include <cereal/types/string.hpp>
12#include <cereal/types/tuple.hpp>
13#include <cereal/types/vector.hpp>
14#include <phosphor-logging/elog-errors.hpp>
15#include <phosphor-logging/log.hpp>
16#include <sdbusplus/exception.hpp>
17#include <sdbusplus/server.hpp>
18#include <xyz/openbmc_project/Common/error.hpp>
19#include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
20
Andrew Geissler131d04a2021-03-12 11:02:41 -060021#include <filesystem>
Andrew Geisslere426b582020-05-28 12:40:55 -050022#include <fstream>
Andrew Geissler36529022016-11-29 15:23:54 -060023#include <iostream>
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -060024#include <map>
25#include <string>
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050026
Vishwanatha Subbanna0a838732017-10-05 12:43:19 +053027// Register class version with Cereal
Andrew Geissler769a62f2019-12-06 13:36:08 -060028CEREAL_CLASS_VERSION(phosphor::state::manager::Host, CLASS_VERSION)
Andrew Geissler36529022016-11-29 15:23:54 -060029
30namespace phosphor
31{
32namespace state
33{
34namespace manager
35{
36
Andrew Geissler7b90a622017-08-08 11:41:08 -050037// When you see server:: or reboot:: you know we're referencing our base class
Andrew Geissler3e3b84b2016-12-02 15:46:17 -060038namespace server = sdbusplus::xyz::openbmc_project::State::server;
Andrew Geissler7b90a622017-08-08 11:41:08 -050039namespace reboot = sdbusplus::xyz::openbmc_project::Control::Boot::server;
Dhruvaraj Subhashchandrana3b8d7e2017-08-10 05:40:04 -050040namespace bootprogress = sdbusplus::xyz::openbmc_project::State::Boot::server;
41namespace osstatus =
42 sdbusplus::xyz::openbmc_project::State::OperatingSystem::server;
Andrew Geissler1e3bf942016-12-13 15:32:22 -060043using namespace phosphor::logging;
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050044namespace fs = std::experimental::filesystem;
Anthony Wilson32c532e2018-10-25 21:56:07 -050045using sdbusplus::exception::SdBusError;
Andrew Geissler2f60aae2019-09-12 13:25:21 -050046using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Andrew Geissler1e3bf942016-12-13 15:32:22 -060047
Andrew Geissler4f309e82017-05-24 15:18:01 -050048// host-shutdown notifies host of shutdown and that leads to host-stop being
49// called so initiate a host shutdown with the -shutdown target and consider the
50// host shut down when the -stop target is complete
51constexpr auto HOST_STATE_SOFT_POWEROFF_TGT = "obmc-host-shutdown@0.target";
Josh D. Kingca357922017-04-11 13:44:09 -050052constexpr auto HOST_STATE_POWEROFF_TGT = "obmc-host-stop@0.target";
53constexpr auto HOST_STATE_POWERON_TGT = "obmc-host-start@0.target";
Andrew Geissler969b2612018-03-29 10:16:51 -070054constexpr auto HOST_STATE_POWERON_MIN_TGT = "obmc-host-startmin@0.target";
Andrew Geisslera27a6e82017-07-27 16:44:43 -050055constexpr auto HOST_STATE_REBOOT_TGT = "obmc-host-reboot@0.target";
Andrew Geissler40dd6e72020-02-07 14:31:12 -060056constexpr auto HOST_STATE_WARM_REBOOT = "obmc-host-warm-reboot@0.target";
57constexpr auto HOST_STATE_FORCE_WARM_REBOOT =
58 "obmc-host-force-warm-reboot@0.target";
Andrew Geissler47b96122020-02-11 16:13:13 -060059constexpr auto HOST_STATE_DIAGNOSTIC_MODE =
60 "obmc-host-diagnostic-mode@0.target";
Andrew Geissler40dd6e72020-02-07 14:31:12 -060061
Josh D. Kingcc3fb5d2017-04-19 15:45:10 -050062constexpr auto HOST_STATE_QUIESCE_TGT = "obmc-host-quiesce@0.target";
Andrew Geissler4da7e002017-01-24 15:21:40 -060063
Josh D. King929ef702017-03-02 10:58:11 -060064constexpr auto ACTIVE_STATE = "active";
65constexpr auto ACTIVATING_STATE = "activating";
66
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -060067/* Map a transition to it's systemd target */
Andrew Geissler58a18012018-01-19 19:36:05 -080068const std::map<server::Host::Transition, std::string> SYSTEMD_TARGET_TABLE = {
69 {server::Host::Transition::Off, HOST_STATE_SOFT_POWEROFF_TGT},
70 {server::Host::Transition::On, HOST_STATE_POWERON_TGT},
Andrew Geissler40dd6e72020-02-07 14:31:12 -060071 {server::Host::Transition::Reboot, HOST_STATE_REBOOT_TGT},
Andrew Geissler7fdad602020-06-22 13:46:16 -050072// Some systems do not support a warm reboot so just map the reboot
73// requests to our normal cold reboot in that case
74#if ENABLE_WARM_REBOOT
Andrew Geissler40dd6e72020-02-07 14:31:12 -060075 {server::Host::Transition::GracefulWarmReboot, HOST_STATE_WARM_REBOOT},
76 {server::Host::Transition::ForceWarmReboot, HOST_STATE_FORCE_WARM_REBOOT}};
Andrew Geissler7fdad602020-06-22 13:46:16 -050077#else
78 {server::Host::Transition::GracefulWarmReboot, HOST_STATE_REBOOT_TGT},
79 {server::Host::Transition::ForceWarmReboot, HOST_STATE_REBOOT_TGT}};
80#endif
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -060081
Andrew Geissler58a18012018-01-19 19:36:05 -080082constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
83constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -060084constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
85
Josh D. King929ef702017-03-02 10:58:11 -060086constexpr auto SYSTEMD_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
87constexpr auto SYSTEMD_INTERFACE_UNIT = "org.freedesktop.systemd1.Unit";
88
Andrew Geissler4da7e002017-01-24 15:21:40 -060089void Host::subscribeToSystemdSignals()
90{
Andrew Geissler58a18012018-01-19 19:36:05 -080091 auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
92 SYSTEMD_INTERFACE, "Subscribe");
Andrew Geissler2f60aae2019-09-12 13:25:21 -050093 try
94 {
95 this->bus.call_noreply(method);
96 }
97 catch (const SdBusError& e)
98 {
99 log<level::ERR>("Failed to subscribe to systemd signals",
100 entry("ERR=%s", e.what()));
101 elog<InternalFailure>();
102 }
Andrew Geissler4da7e002017-01-24 15:21:40 -0600103 return;
104}
105
Andrew Geissleref3c1842016-12-01 12:33:09 -0600106void Host::determineInitialState()
107{
Andrew Geissleref3c1842016-12-01 12:33:09 -0600108
Andrew Geissler969b2612018-03-29 10:16:51 -0700109 if (stateActive(HOST_STATE_POWERON_MIN_TGT))
Andrew Geissleref3c1842016-12-01 12:33:09 -0600110 {
Andrew Geissler1e3bf942016-12-13 15:32:22 -0600111 log<level::INFO>("Initial Host State will be Running",
112 entry("CURRENT_HOST_STATE=%s",
113 convertForMessage(HostState::Running).c_str()));
Andrew Geissler97924142017-01-24 16:10:18 -0600114 server::Host::currentHostState(HostState::Running);
115 server::Host::requestedHostTransition(Transition::On);
Andrew Geissleref3c1842016-12-01 12:33:09 -0600116 }
117 else
118 {
Andrew Geissler1e3bf942016-12-13 15:32:22 -0600119 log<level::INFO>("Initial Host State will be Off",
120 entry("CURRENT_HOST_STATE=%s",
121 convertForMessage(HostState::Off).c_str()));
Andrew Geissler97924142017-01-24 16:10:18 -0600122 server::Host::currentHostState(HostState::Off);
123 server::Host::requestedHostTransition(Transition::Off);
Andrew Geissleref3c1842016-12-01 12:33:09 -0600124 }
125
Andrew Geissler033fc3b2017-08-30 15:11:44 -0500126 if (!deserialize(HOST_STATE_PERSIST_PATH))
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -0500127 {
Andrew Geissler58a18012018-01-19 19:36:05 -0800128 // set to default value.
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -0500129 server::Host::requestedHostTransition(Transition::Off);
130 }
Andrew Geissleref3c1842016-12-01 12:33:09 -0600131
132 return;
133}
134
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -0600135void Host::executeTransition(Transition tranReq)
136{
137 auto sysdUnit = SYSTEMD_TARGET_TABLE.find(tranReq)->second;
138
Andrew Geissler58a18012018-01-19 19:36:05 -0800139 auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
140 SYSTEMD_INTERFACE, "StartUnit");
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -0600141
142 method.append(sysdUnit);
143 method.append("replace");
144
Andrew Geissler4da7e002017-01-24 15:21:40 -0600145 this->bus.call_noreply(method);
Andrew Geissler0cd2eaf2016-12-07 10:50:13 -0600146
147 return;
148}
149
Josh D. King929ef702017-03-02 10:58:11 -0600150bool Host::stateActive(const std::string& target)
151{
Patrick Williams2975e262020-05-13 18:01:09 -0500152 std::variant<std::string> currentState;
Josh D. King929ef702017-03-02 10:58:11 -0600153 sdbusplus::message::object_path unitTargetPath;
154
Andrew Geissler58a18012018-01-19 19:36:05 -0800155 auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
156 SYSTEMD_INTERFACE, "GetUnit");
Josh D. King929ef702017-03-02 10:58:11 -0600157
158 method.append(target);
Josh D. King929ef702017-03-02 10:58:11 -0600159
Anthony Wilson32c532e2018-10-25 21:56:07 -0500160 try
Josh D. King929ef702017-03-02 10:58:11 -0600161 {
Anthony Wilson32c532e2018-10-25 21:56:07 -0500162 auto result = this->bus.call(method);
163 result.read(unitTargetPath);
164 }
165 catch (const SdBusError& e)
166 {
167 log<level::ERR>("Error in GetUnit call", entry("ERROR=%s", e.what()));
Josh D. King929ef702017-03-02 10:58:11 -0600168 return false;
169 }
170
Andrew Geissler58a18012018-01-19 19:36:05 -0800171 method = this->bus.new_method_call(
172 SYSTEMD_SERVICE,
173 static_cast<const std::string&>(unitTargetPath).c_str(),
174 SYSTEMD_PROPERTY_IFACE, "Get");
Josh D. King929ef702017-03-02 10:58:11 -0600175
176 method.append(SYSTEMD_INTERFACE_UNIT, "ActiveState");
Josh D. King929ef702017-03-02 10:58:11 -0600177
Anthony Wilson32c532e2018-10-25 21:56:07 -0500178 try
Josh D. King929ef702017-03-02 10:58:11 -0600179 {
Anthony Wilson32c532e2018-10-25 21:56:07 -0500180 auto result = this->bus.call(method);
181 result.read(currentState);
182 }
183 catch (const SdBusError& e)
184 {
185 log<level::ERR>("Error in ActiveState Get",
186 entry("ERROR=%s", e.what()));
Josh D. King929ef702017-03-02 10:58:11 -0600187 return false;
188 }
189
Patrick Williams37413dc2020-05-13 11:29:54 -0500190 const auto& currentStateStr = std::get<std::string>(currentState);
William A. Kennington III7a0689a2018-11-12 17:19:33 -0800191 return currentStateStr == ACTIVE_STATE ||
192 currentStateStr == ACTIVATING_STATE;
Josh D. King929ef702017-03-02 10:58:11 -0600193}
194
Michael Tritz206a8332017-02-06 16:01:23 -0600195bool Host::isAutoReboot()
196{
Deepak Kodihalli3dd08a52017-07-25 07:34:44 -0500197 using namespace settings;
Michael Tritz206a8332017-02-06 16:01:23 -0600198
Andrew Geissler7f620832020-10-23 08:25:52 -0500199 /* The logic here is to first check the one-time AutoReboot setting.
200 * If this property is true (the default) then look at the persistent
201 * user setting in the non one-time object, otherwise honor the one-time
202 * setting and do not auto reboot.
203 */
204 auto methodOneTime = bus.new_method_call(
Andrew Geissler58a18012018-01-19 19:36:05 -0800205 settings.service(settings.autoReboot, autoRebootIntf).c_str(),
Andrew Geissler7f620832020-10-23 08:25:52 -0500206 settings.autoRebootOneTime.c_str(), SYSTEMD_PROPERTY_IFACE, "Get");
207 methodOneTime.append(autoRebootIntf, "AutoReboot");
208
209 auto methodUserSetting = bus.new_method_call(
210 settings.service(settings.autoReboot, autoRebootIntf).c_str(),
211 settings.autoReboot.c_str(), SYSTEMD_PROPERTY_IFACE, "Get");
212 methodUserSetting.append(autoRebootIntf, "AutoReboot");
Michael Tritz206a8332017-02-06 16:01:23 -0600213
Anthony Wilson32c532e2018-10-25 21:56:07 -0500214 try
Michael Tritz206a8332017-02-06 16:01:23 -0600215 {
Andrew Geissler7f620832020-10-23 08:25:52 -0500216 auto reply = bus.call(methodOneTime);
Patrick Williams2975e262020-05-13 18:01:09 -0500217 std::variant<bool> result;
Anthony Wilson32c532e2018-10-25 21:56:07 -0500218 reply.read(result);
Patrick Williams37413dc2020-05-13 11:29:54 -0500219 auto autoReboot = std::get<bool>(result);
Andrew Geissler7f620832020-10-23 08:25:52 -0500220
221 if (!autoReboot)
222 {
223 log<level::INFO>("Auto reboot (one-time) disabled");
224 return false;
225 }
226 else
227 {
228 // one-time is true so read the user setting
229 reply = bus.call(methodUserSetting);
230 reply.read(result);
231 autoReboot = std::get<bool>(result);
232 }
233
Anthony Wilson32c532e2018-10-25 21:56:07 -0500234 auto rebootCounterParam = reboot::RebootAttempts::attemptsLeft();
235
236 if (autoReboot)
Saqib Khancbe08d12017-03-10 01:29:20 -0600237 {
Anthony Wilson32c532e2018-10-25 21:56:07 -0500238 if (rebootCounterParam > 0)
239 {
240 // Reduce BOOTCOUNT by 1
241 log<level::INFO>("Auto reboot enabled, rebooting");
242 return true;
243 }
244 else if (rebootCounterParam == 0)
245 {
246 // Reset reboot counter and go to quiesce state
247 log<level::INFO>("Auto reboot enabled. "
248 "HOST BOOTCOUNT already set to 0.");
249 attemptsLeft(BOOT_COUNT_MAX_ALLOWED);
250 return false;
251 }
252 else
253 {
254 log<level::INFO>("Auto reboot enabled. "
255 "HOST BOOTCOUNT has an invalid value.");
256 return false;
257 }
Saqib Khand5ac6352017-04-04 09:53:59 -0500258 }
259 else
260 {
Anthony Wilson32c532e2018-10-25 21:56:07 -0500261 log<level::INFO>("Auto reboot disabled.");
Saqib Khancbe08d12017-03-10 01:29:20 -0600262 return false;
263 }
Michael Tritz206a8332017-02-06 16:01:23 -0600264 }
Anthony Wilson32c532e2018-10-25 21:56:07 -0500265 catch (const SdBusError& e)
Saqib Khand5ac6352017-04-04 09:53:59 -0500266 {
Anthony Wilson32c532e2018-10-25 21:56:07 -0500267 log<level::ERR>("Error in AutoReboot Get", entry("ERROR=%s", e.what()));
Saqib Khand5ac6352017-04-04 09:53:59 -0500268 return false;
269 }
Michael Tritz206a8332017-02-06 16:01:23 -0600270}
271
Andrew Geisslere4039a82020-02-11 15:51:59 -0600272void Host::sysStateChangeJobRemoved(sdbusplus::message::message& msg)
Andrew Geissler4da7e002017-01-24 15:21:40 -0600273{
Andrew Geissler58a18012018-01-19 19:36:05 -0800274 uint32_t newStateID{};
Andrew Geissler4da7e002017-01-24 15:21:40 -0600275 sdbusplus::message::object_path newStateObjPath;
276 std::string newStateUnit{};
277 std::string newStateResult{};
278
Andrew Geissler58a18012018-01-19 19:36:05 -0800279 // Read the msg and populate each variable
Patrick Williamsd22706f2017-05-04 05:42:49 -0500280 msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
Andrew Geissler4da7e002017-01-24 15:21:40 -0600281
Andrew Geissler58a18012018-01-19 19:36:05 -0800282 if ((newStateUnit == HOST_STATE_POWEROFF_TGT) &&
Andrew Geissler969b2612018-03-29 10:16:51 -0700283 (newStateResult == "done") &&
284 (!stateActive(HOST_STATE_POWERON_MIN_TGT)))
Andrew Geissleref621162016-12-08 12:56:21 -0600285 {
Andrew Jeffery55b983e2017-04-19 11:11:26 +0930286 log<level::INFO>("Received signal that host is off");
Andrew Geissler4da7e002017-01-24 15:21:40 -0600287 this->currentHostState(server::Host::HostState::Off);
Dhruvaraj Subhashchandrana3b8d7e2017-08-10 05:40:04 -0500288 this->bootProgress(bootprogress::Progress::ProgressStages::Unspecified);
289 this->operatingSystemState(osstatus::Status::OSStatus::Inactive);
Andrew Geissleref621162016-12-08 12:56:21 -0600290 }
Andrew Geissler969b2612018-03-29 10:16:51 -0700291 else if ((newStateUnit == HOST_STATE_POWERON_MIN_TGT) &&
Andrew Geissler58a18012018-01-19 19:36:05 -0800292 (newStateResult == "done") &&
Andrew Geissler969b2612018-03-29 10:16:51 -0700293 (stateActive(HOST_STATE_POWERON_MIN_TGT)))
Andrew Geissler58a18012018-01-19 19:36:05 -0800294 {
295 log<level::INFO>("Received signal that host is running");
296 this->currentHostState(server::Host::HostState::Running);
Andrew Geissler131d04a2021-03-12 11:02:41 -0600297
298 // Remove temporary file which is utilized for scenarios where the
299 // BMC is rebooted while the host is still up.
300 // This file is used to indicate to host related systemd services
301 // that the host is already running and they should skip running.
302 // Once the host state is back to running we can clear this file.
303 auto size = std::snprintf(nullptr, 0, HOST_RUNNING_FILE, 0);
304 size++; // null
305 std::unique_ptr<char[]> hostFile(new char[size]);
306 std::snprintf(hostFile.get(), size, HOST_RUNNING_FILE, 0);
307 if (std::filesystem::exists(hostFile.get()))
308 {
309 std::filesystem::remove(hostFile.get());
310 }
Andrew Geissler58a18012018-01-19 19:36:05 -0800311 }
312 else if ((newStateUnit == HOST_STATE_QUIESCE_TGT) &&
Josh D. King29d025d2017-04-27 12:40:22 -0500313 (newStateResult == "done") &&
314 (stateActive(HOST_STATE_QUIESCE_TGT)))
Andrew Geissler58a18012018-01-19 19:36:05 -0800315 {
316 if (Host::isAutoReboot())
317 {
318 log<level::INFO>("Beginning reboot...");
319 Host::requestedHostTransition(server::Host::Transition::Reboot);
320 }
321 else
322 {
323 log<level::INFO>("Maintaining quiesce");
324 this->currentHostState(server::Host::HostState::Quiesced);
325 }
326 }
Andrew Geissleref621162016-12-08 12:56:21 -0600327}
328
Andrew Geissler47b96122020-02-11 16:13:13 -0600329void Host::sysStateChangeJobNew(sdbusplus::message::message& msg)
330{
331 uint32_t newStateID{};
332 sdbusplus::message::object_path newStateObjPath;
333 std::string newStateUnit{};
334
335 // Read the msg and populate each variable
336 msg.read(newStateID, newStateObjPath, newStateUnit);
337
338 if (newStateUnit == HOST_STATE_DIAGNOSTIC_MODE)
339 {
340 log<level::INFO>("Received signal that host is in diagnostice mode");
341 this->currentHostState(server::Host::HostState::DiagnosticMode);
342 }
343}
344
Andrew Geissler7b90a622017-08-08 11:41:08 -0500345uint32_t Host::decrementRebootCount()
346{
347 auto rebootCount = reboot::RebootAttempts::attemptsLeft();
Andrew Geissler58a18012018-01-19 19:36:05 -0800348 if (rebootCount > 0)
Andrew Geissler7b90a622017-08-08 11:41:08 -0500349 {
Andrew Geissler58a18012018-01-19 19:36:05 -0800350 return (reboot::RebootAttempts::attemptsLeft(rebootCount - 1));
Andrew Geissler7b90a622017-08-08 11:41:08 -0500351 }
352 return rebootCount;
353}
354
Andrew Geissler033fc3b2017-08-30 15:11:44 -0500355fs::path Host::serialize(const fs::path& dir)
356{
357 std::ofstream os(dir.c_str(), std::ios::binary);
358 cereal::JSONOutputArchive oarchive(os);
359 oarchive(*this);
360 return dir;
361}
362
363bool Host::deserialize(const fs::path& path)
364{
Jayanth Othayothe39f3792017-09-19 23:53:31 -0500365 try
Andrew Geissler033fc3b2017-08-30 15:11:44 -0500366 {
Jayanth Othayothe39f3792017-09-19 23:53:31 -0500367 if (fs::exists(path))
368 {
369 std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
370 cereal::JSONInputArchive iarchive(is);
371 iarchive(*this);
372 return true;
373 }
374 return false;
Andrew Geissler033fc3b2017-08-30 15:11:44 -0500375 }
Andrew Geissler58a18012018-01-19 19:36:05 -0800376 catch (cereal::Exception& e)
Jayanth Othayothe39f3792017-09-19 23:53:31 -0500377 {
378 log<level::ERR>(e.what());
379 fs::remove(path);
380 return false;
381 }
Andrew Geissler033fc3b2017-08-30 15:11:44 -0500382}
383
Andrew Geissleref3c1842016-12-01 12:33:09 -0600384Host::Transition Host::requestedHostTransition(Transition value)
385{
Matt Spinlerbbbc0162020-11-11 14:43:50 -0600386 log<level::INFO>(fmt::format("Host state transition request of {}",
387 convertForMessage(value))
388 .c_str());
Andrew Geissler7b90a622017-08-08 11:41:08 -0500389 // If this is not a power off request then we need to
390 // decrement the reboot counter. This code should
391 // never prevent a power on, it should just decrement
392 // the count to 0. The quiesce handling is where the
393 // check of this count will occur
Andrew Geissler58a18012018-01-19 19:36:05 -0800394 if (value != server::Host::Transition::Off)
Andrew Geissler7b90a622017-08-08 11:41:08 -0500395 {
396 decrementRebootCount();
397 }
398
Andrew Geisslera27a6e82017-07-27 16:44:43 -0500399 executeTransition(value);
Andrew Geissler7b90a622017-08-08 11:41:08 -0500400
Andrew Geissler58a18012018-01-19 19:36:05 -0800401 auto retVal = server::Host::requestedHostTransition(value);
Andrew Geissler033fc3b2017-08-30 15:11:44 -0500402 serialize();
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -0500403 return retVal;
Andrew Geissleref3c1842016-12-01 12:33:09 -0600404}
405
Dhruvaraj Subhashchandran4e6534f2017-09-19 06:13:20 -0500406Host::ProgressStages Host::bootProgress(ProgressStages value)
407{
408 auto retVal = bootprogress::Progress::bootProgress(value);
409 serialize();
410 return retVal;
411}
412
413Host::OSStatus Host::operatingSystemState(OSStatus value)
414{
415 auto retVal = osstatus::Status::operatingSystemState(value);
416 serialize();
417 return retVal;
418}
419
Andrew Geissleref3c1842016-12-01 12:33:09 -0600420Host::HostState Host::currentHostState(HostState value)
421{
Andrew Geissler58a18012018-01-19 19:36:05 -0800422 log<level::INFO>(
Matt Spinlerbbbc0162020-11-11 14:43:50 -0600423 fmt::format("Change to Host State: {}", convertForMessage(value))
424 .c_str());
Andrew Geissleref621162016-12-08 12:56:21 -0600425 return server::Host::currentHostState(value);
Andrew Geissleref3c1842016-12-01 12:33:09 -0600426}
427
Andrew Geissler36529022016-11-29 15:23:54 -0600428} // namespace manager
429} // namespace state
Andrew Geisslera965cf02018-08-31 08:37:05 -0700430} // namespace phosphor