PNOR: Implement Software RedundancyPriority.interface
- Create Redundancy Priority interface after a successful
PNOR update and set the priority.
- Remove Redundancy Priority interface once the activation
state changes from being Active
Change-Id: If4fdb466d3e0319b57a381c80e25457d689b8785
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 81aa5e7..58819c0 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -15,6 +15,12 @@
auto Activation::activation(Activations value) ->
Activations
{
+
+ if (value != softwareServer::Activation::Activations::Active)
+ {
+ redundancyPriority.reset(nullptr);
+ }
+
if (value == softwareServer::Activation::Activations::Activating)
{
softwareServer::Activation::activation(value);
@@ -77,6 +83,15 @@
fs::create_directory_symlink(PNOR_PRSV, PNOR_PRSV_ACTIVE_PATH);
}
+ // Set Redundancy Priority before setting to Active
+ if (!redundancyPriority)
+ {
+ redundancyPriority =
+ std::make_unique<RedundancyPriority>(
+ bus,
+ path);
+ }
+
return softwareServer::Activation::activation(
softwareServer::Activation::Activations::Active);
}
diff --git a/activation.hpp b/activation.hpp
index 4aff3e5..8835ca6 100755
--- a/activation.hpp
+++ b/activation.hpp
@@ -4,6 +4,7 @@
#include <xyz/openbmc_project/Software/Activation/server.hpp>
#include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp>
#include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp"
+#include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp"
namespace openpower
{
@@ -17,6 +18,33 @@
sdbusplus::xyz::openbmc_project::Software::server::Activation>;
using ActivationBlocksTransitionInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>;
+using RedundancyPriorityInherit = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>;
+
+/** @class RedundancyPriority
+ * @brief OpenBMC RedundancyPriority implementation
+ * @details A concrete implementation for
+ * xyz.openbmc_project.Software.RedundancyPriority DBus API.
+ */
+class RedundancyPriority : public RedundancyPriorityInherit
+{
+ public:
+ /** @brief Constructs RedundancyPriority.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ */
+ RedundancyPriority(sdbusplus::bus::bus& bus,
+ const std::string& path) :
+ RedundancyPriorityInherit(bus,
+ path.c_str(), true)
+ {
+ // Set Property
+ priority(0);
+ // Emit deferred signal.
+ emit_object_added();
+ }
+};
/** @class ActivationBlocksTransition
* @brief OpenBMC ActivationBlocksTransition implementation.
@@ -97,6 +125,9 @@
/** @brief Persistent ActivationBlocksTransition dbus object */
std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
+
+ /** @brief Persistent RedundancyPriority dbus object */
+ std::unique_ptr<RedundancyPriority> redundancyPriority;
};
} // namespace updater