summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>2017-06-19 06:43:22 -0500
committerDhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>2017-08-01 06:08:38 -0500
commit2710e730c698952b6803fea2af6c63bff8ff385c (patch)
treeecb573b2a5dcb20981fed21d932be8aa80a69053
parent55f132bfeb4a3d634589b71e77b8289fc652aebf (diff)
downloadphosphor-state-manager-2710e730c698952b6803fea2af6c63bff8ff385c.tar.gz
phosphor-state-manager-2710e730c698952b6803fea2af6c63bff8ff385c.zip
Implementation of OS status, boot count and boot progress
Change-Id: I1b00a932db2533b83fa0bd7bb4fbd62c0299bff7 Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
-rw-r--r--configure.ac4
-rw-r--r--host_state_manager.cpp41
-rw-r--r--host_state_manager.hpp19
3 files changed, 20 insertions, 44 deletions
diff --git a/configure.ac b/configure.ac
index 7c01962..28f51ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,10 @@ AS_IF([test "x$HOST_STATE_PERSIST_PATH" == "x"], \
AC_DEFINE_UNQUOTED([HOST_STATE_PERSIST_PATH], ["$HOST_STATE_PERSIST_PATH"], \
[Path of file for storing requested host state.])
+AC_ARG_VAR(BOOT_COUNT_MAX_ALLOWED, [The maximum allowed reboot count])
+AS_IF([test "x$BOOT_COUNT_MAX_ALLOWED" == "x"], [BOOT_COUNT_MAX_ALLOWED=3])
+AC_DEFINE_UNQUOTED([BOOT_COUNT_MAX_ALLOWED], [$BOOT_COUNT_MAX_ALLOWED], [The maximum allowed reboot count])
+
# Check for header files.
AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])])
AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])])
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_BUSNAME = "xyz.openbmc_project.ObjectMapper";
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 @@ void Host::determineInitialState()
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 @@ bool Host::stateActive(const std::string& target)
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 @@ bool Host::isAutoReboot()
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 @@ bool Host::isAutoReboot()
// 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
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index 8204931..41310d6 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -3,8 +3,12 @@
#include <string>
#include <functional>
#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
+#include <xyz/openbmc_project/Control/Boot/RebootAttempts/server.hpp>
+#include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp>
#include "xyz/openbmc_project/State/Host/server.hpp"
#include "settings.hpp"
+#include "config.h"
namespace phosphor
{
@@ -14,7 +18,11 @@ namespace manager
{
using HostInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::State::server::Host>;
+ sdbusplus::xyz::openbmc_project::State::server::Host,
+ sdbusplus::xyz::openbmc_project::State::Boot::server::Progress,
+ sdbusplus::xyz::openbmc_project::Control::Boot::server::RebootAttempts,
+ sdbusplus::xyz::openbmc_project::State::OperatingSystem::server::Status>;
+
namespace sdbusRule = sdbusplus::bus::match::rules;
/** @class Host
@@ -57,6 +65,8 @@ class Host : public HostInherit
// Will throw exception on fail
determineInitialState();
+ attemptsLeft(BOOT_COUNT_MAX_ALLOWED);
+
// We deferred this until we could get our property correct
this->emit_object_added();
}
@@ -106,13 +116,6 @@ class Host : public HostInherit
bool stateActive(const std::string& target);
/**
- * @brief Set the HOST BOOTCOUNT Sensor value
- *
- * @param[in] bootCount - new BOOTCOUNT value
- */
- void setHostbootCount(int bootCount);
-
- /**
* @brief Determine if auto reboot flag is set
*
* @return boolean corresponding to current auto_reboot setting
OpenPOWER on IntegriCloud