Call update u-boot env once when a priority is changed

The recursive nature of calling the free priority function
would trigger setting the u-boot env multiple times.
Make a change so that the priorities are sorted and
updated once.

- Create a non-overriden priority setter function to be called
by the free priority function and by the function that creates
the dbus objects after a bmc reboot. There's no need to call
to free the priorities after reboot since the priorities are
preserved on the bmc, and if they're not they default to 0 or 255.
- When a dbus request is made to update the priority, update
the value, then call the free priority function, which will
sort the versions by priority and bump the priority of any
duplicate ones.

Resolves openbmc/openbmc#2535

Change-Id: Ib92cc0ca6c4d5f6e986f3cde7156d63b53844b46
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.hpp b/item_updater.hpp
index 7b65b80..ea88c4b 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -114,12 +114,21 @@
          */
         bool isLowestPriority(uint8_t value);
 
-    /**
-     * @brief Updates the uboot variables to point to BMC version with lowest
-     *        priority, so that the system boots from this version on the
-     *        next boot.
-     */
-    void resetUbootEnvVars();
+        /**
+         * @brief Updates the U-Boot variables to point to the requested
+         *        versionId, so that the systems boots from this version on
+         *        the next reboot.
+         *
+         * @param[in] versionId - The version to point the system to boot from.
+         */
+        void updateUbootEnvVars(const std::string& versionId);
+
+        /**
+         * @brief Updates the uboot variables to point to BMC version with lowest
+         *        priority, so that the system boots from this version on the
+         *        next boot.
+         */
+        void resetUbootEnvVars();
 
     private:
         /** @brief Callback function for Software.Version match.