BMC: 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.
- Create override function for RedundancyPriority.

Resolves openbmc/openbmc#1755

Change-Id: I160dc4a6cad243d58759c71bbeb218aab841cf7a
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 9c94b19..667c4b6 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -106,6 +106,7 @@
                                std::make_unique<Activation>(
                                         bus,
                                         path,
+                                        *this,
                                         versionId,
                                         activationState)));
         versions.insert(std::make_pair(
@@ -132,6 +133,7 @@
                            std::make_unique<Activation>(
                                bus,
                                path,
+                               *this,
                                id,
                                server::Activation::Activations::Active)));
     versions.insert(std::make_pair(
@@ -165,6 +167,21 @@
     }
 }
 
+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 phosphor