Implementation of OS status, boot count and boot progress
Change-Id: I1b00a932db2533b83fa0bd7bb4fbd62c0299bff7
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 6e2fd22..83f21e7 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -52,16 +52,9 @@
constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-constexpr auto REBOOTCOUNTER_SERVICE("org.openbmc.Sensors");
-constexpr auto REBOOTCOUNTER_PATH("/org/openbmc/sensors/host/BootCount");
-constexpr auto REBOOTCOUNTER_INTERFACE("org.openbmc.SensorValue");
-
constexpr auto SYSTEMD_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
constexpr auto SYSTEMD_INTERFACE_UNIT = "org.freedesktop.systemd1.Unit";
-// TODO openbmc/openbmc#1646 - boot count needs to be defined in 1 place
-constexpr auto DEFAULT_BOOTCOUNT = 3;
-
/* Map a system state to the HostState */
const std::map<std::string, server::Host::HostState> SYS_HOST_STATE_TABLE = {
{"HOST_BOOTING", server::Host::HostState::Running},
@@ -102,7 +95,7 @@
auto restore = getStateRestoreSetting();
- if ((!restore) || (!deserialize(HOST_STATE_PERSIST_PATH,*this)))
+ if ((!restore) || (!deserialize(HOST_STATE_PERSIST_PATH, *this)))
{
//set to default value.
server::Host::requestedHostTransition(Transition::Off);
@@ -213,17 +206,6 @@
return true;
}
-void Host::setHostbootCount(int bootCount)
-{
- auto method = this->bus.new_method_call(REBOOTCOUNTER_SERVICE,
- REBOOTCOUNTER_PATH,
- REBOOTCOUNTER_INTERFACE,
- "setValue");
- sdbusplus::message::variant<int> newParam = bootCount;
- method.append(newParam);
- this->bus.call_noreply(method);
-}
-
bool Host::isAutoReboot()
{
using namespace settings;
@@ -245,29 +227,16 @@
sdbusplus::message::variant<bool> result;
reply.read(result);
auto autoReboot = result.get<bool>();
-
- sdbusplus::message::variant<int> rebootCounterParam = 0;
- method = this->bus.new_method_call(REBOOTCOUNTER_SERVICE,
- REBOOTCOUNTER_PATH,
- REBOOTCOUNTER_INTERFACE,
- "getValue");
- reply = this->bus.call(method);
- if (reply.is_method_error())
- {
- log<level::ERR>("Error in BOOTCOUNT getValue");
- return false;
- }
- reply.read(rebootCounterParam);
+ auto rebootCounterParam = attemptsLeft();
if (autoReboot)
{
- if ( rebootCounterParam > 0)
+ if (rebootCounterParam > 0)
{
// Reduce BOOTCOUNT by 1
log<level::INFO>("Auto reboot enabled. "
"Reducing HOST BOOTCOUNT by 1.");
- Host::setHostbootCount((sdbusplus::message::variant_ns::
- get<int>(rebootCounterParam)) - 1);
+ attemptsLeft(rebootCounterParam - 1);
return true;
}
else if(rebootCounterParam == 0)
@@ -275,7 +244,7 @@
// Reset reboot counter and go to quiesce state
log<level::INFO>("Auto reboot enabled. "
"HOST BOOTCOUNT already set to 0.");
- Host::setHostbootCount(DEFAULT_BOOTCOUNT);
+ attemptsLeft(BOOT_COUNT_MAX_ALLOWED);
return false;
}
else