PNOR: implement Software RedundancyPriority interface.
- Create override function for redundancepriority.
- Update RedundancyPriority for image that holds that
already holds the requested priority.
Resolves openbmc/openbmc#1553
Change-Id: I1a5c35826c881f6e9e21550c664b033c6f4b4bc0
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 3b28c73..9a19008 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -1,6 +1,7 @@
#include <experimental/filesystem>
#include "activation.hpp"
#include "config.h"
+#include "item_updater.hpp"
namespace openpower
{
@@ -128,7 +129,9 @@
redundancyPriority =
std::make_unique<RedundancyPriority>(
bus,
- path);
+ path,
+ *this,
+ 0);
}
activationBlocksTransition.reset(nullptr);
return softwareServer::Activation::activation(
@@ -181,6 +184,7 @@
uint8_t RedundancyPriority::priority(uint8_t value)
{
+ parent.parent.freePriority(value);
return softwareServer::RedundancyPriority::priority(value);
}
diff --git a/activation.hpp b/activation.hpp
index bedef81..39e1ea3 100755
--- a/activation.hpp
+++ b/activation.hpp
@@ -23,6 +23,10 @@
namespace sdbusRule = sdbusplus::bus::match::rules;
+class ItemUpdater;
+class Activation;
+class RedundancyPriority;
+
/** @class RedundancyPriority
* @brief OpenBMC RedundancyPriority implementation
* @details A concrete implementation for
@@ -35,14 +39,19 @@
*
* @param[in] bus - The Dbus bus object
* @param[in] path - The Dbus object path
+ * @param[in] parent - Parent object.
+ * @param[in] value - The redundancyPriority value
*/
RedundancyPriority(sdbusplus::bus::bus& bus,
- const std::string& path) :
+ const std::string& path,
+ Activation& parent,
+ uint8_t value) :
RedundancyPriorityInherit(bus,
- path.c_str(), true)
+ path.c_str(), true),
+ parent(parent)
{
// Set Property
- priority(0);
+ priority(value);
// Emit deferred signal.
emit_object_added();
}
@@ -54,6 +63,15 @@
* @return Success or exception thrown
*/
uint8_t priority(uint8_t value) override;
+
+ /** @brief Priority property get function
+ *
+ * @returns uint8_t - The Priority value
+ */
+ using RedundancyPriorityInherit::priority;
+
+ /** @brief Parent Object. */
+ Activation& parent;
};
/** @class ActivationBlocksTransition
@@ -86,11 +104,13 @@
*
* @param[in] bus - The Dbus bus object
* @param[in] path - The Dbus object path
+ * @param[in] parent - Parent object.
* @param[in] versionId - The software version id
* @param[in] extVersion - The extended version
* @param[in] activationStatus - The status of Activation
*/
Activation(sdbusplus::bus::bus& bus, const std::string& path,
+ ItemUpdater& parent,
std::string& versionId,
std::string& extVersion,
sdbusplus::xyz::openbmc_project::Software::
@@ -98,6 +118,7 @@
ActivationInherit(bus, path.c_str(), true),
bus(bus),
path(path),
+ parent(parent),
versionId(versionId),
systemdSignals(
bus,
@@ -160,6 +181,9 @@
/** @brief Persistent DBus object path */
std::string path;
+ /** @brief Parent Object. */
+ ItemUpdater& parent;
+
/** @brief Version id */
std::string versionId;
diff --git a/item_updater.cpp b/item_updater.cpp
index 3fff1a4..bf4ba38 100755
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -107,6 +107,7 @@
std::make_unique<Activation>(
bus,
path,
+ *this,
versionId,
extendedVersion,
activationState)));
@@ -207,6 +208,21 @@
return;
}
+void ItemUpdater::freePriority(uint8_t value)
+{
+ //TODO openbmc/openbmc#1896 Improve the performance of this function
+ for (const auto& intf : activations)
+ {
+ if(intf.second->redundancyPriority)
+ {
+ if (intf.second->redundancyPriority.get()->priority() == value)
+ {
+ intf.second->redundancyPriority.get()->priority(value+1);
+ }
+ }
+ }
+}
+
} // namespace updater
} // namespace software
} // namespace openpower
diff --git a/item_updater.hpp b/item_updater.hpp
index 233f022..6409698 100755
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -41,6 +41,15 @@
{
}
+ /** @brief Sets the given priority free by incrementing
+ * any existing priority with the same value by 1
+ *
+ * @param[in] value - The priority that needs to be set free.
+ *
+ * @return None
+ */
+ void freePriority(uint8_t value);
+
private:
/** @brief Callback function for Software.Version match.
* @details Creates an Activation dbus object.