Activation: Implement ActivationProgress interface
This commit implements the ActivationProgress interface, which maintains
a value representing percentage completion of the activation process.
This value is periodically updated throughout the process.
Resolves openbmc/openbmc#1554
Change-Id: I7dafb32995c4c95d86e1cc17ca42065065eee2f4
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 9a19008..428a256 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -46,6 +46,12 @@
// RW volumes have not yet been created, we need to start the
// service files for each of those actions.
+ if (!activationProgress)
+ {
+ activationProgress = std::make_unique<ActivationProgress>(bus,
+ path);
+ }
+
if (!activationBlocksTransition)
{
activationBlocksTransition =
@@ -78,6 +84,8 @@
method.append(ubimountServiceFile, "replace");
bus.call_noreply(method);
+ activationProgress->progress(10);
+
return softwareServer::Activation::activation(value);
}
else if (squashfsLoaded == true && rwVolumesCreated == true)
@@ -95,6 +103,8 @@
(fs::is_directory(PNOR_RW_PREFIX + versionId)) &&
(fs::is_directory(PNOR_RO_PREFIX + versionId)))
{
+ activationProgress->progress(90);
+
if (!fs::is_directory(PNOR_ACTIVE_PATH))
{
fs::create_directories(PNOR_ACTIVE_PATH);
@@ -133,13 +143,19 @@
*this,
0);
}
+
+ activationProgress->progress(100);
+
activationBlocksTransition.reset(nullptr);
+ activationProgress.reset(nullptr);
+
return softwareServer::Activation::activation(
softwareServer::Activation::Activations::Active);
}
else
{
activationBlocksTransition.reset(nullptr);
+ activationProgress.reset(nullptr);
return softwareServer::Activation::activation(
softwareServer::Activation::Activations::Failed);
}
@@ -155,6 +171,7 @@
else
{
activationBlocksTransition.reset(nullptr);
+ activationProgress.reset(nullptr);
return softwareServer::Activation::activation(value);
}
}
@@ -206,12 +223,14 @@
if(newStateUnit == squashfsMountServiceFile && newStateResult == "done")
{
- squashfsLoaded = true;
+ squashfsLoaded = true;
+ activationProgress->progress(activationProgress->progress() + 20);
}
if(newStateUnit == ubimountServiceFile && newStateResult == "done")
{
rwVolumesCreated = true;
+ activationProgress->progress(activationProgress->progress() + 50);
}
if(squashfsLoaded && rwVolumesCreated)
diff --git a/activation.hpp b/activation.hpp
index 39e1ea3..4ef2562 100755
--- a/activation.hpp
+++ b/activation.hpp
@@ -5,6 +5,7 @@
#include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp>
#include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp"
#include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp"
+#include "xyz/openbmc_project/Software/ActivationProgress/server.hpp"
namespace openpower
{
@@ -20,6 +21,8 @@
sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>;
using RedundancyPriorityInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>;
+using ActivationProgressInherit = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Software::server::ActivationProgress>;
namespace sdbusRule = sdbusplus::bus::match::rules;
@@ -92,6 +95,23 @@
ActivationBlocksTransitionInherit(bus, path.c_str()) {}
};
+class ActivationProgress : public ActivationProgressInherit
+{
+ public:
+ /** @brief Constructs ActivationProgress.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ */
+ ActivationProgress(sdbusplus::bus::bus& bus,
+ const std::string& path) :
+ ActivationProgressInherit(bus, path.c_str(), true)
+ {
+ progress(0);
+ emit_object_added();
+ }
+};
+
/** @class Activation
* @brief OpenBMC activation software management implementation.
* @details A concrete implementation for
@@ -190,6 +210,9 @@
/** @brief Persistent ActivationBlocksTransition dbus object */
std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
+ /** @brief Persistent ActivationProgress dbus object */
+ std::unique_ptr<ActivationProgress> activationProgress;
+
/** @brief Persistent RedundancyPriority dbus object */
std::unique_ptr<RedundancyPriority> redundancyPriority;