item_updater: Add Volatile Object Enable dbus object

Add an Enable dbus object to determine if the Volatile PNOR partitions
should be cleared. An Enabled value of false (default) means volatile
is disabled and the partitions should not be cleared.

This property would be set by the host via IPMI, and the BMC would
check it on the power on path.

Part of openbmc/openbmc#2397

Change-Id: Ic9362206d2b1d4fd44b3505ed53e72ec240ad60c
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.hpp b/item_updater.hpp
index 0b430fe..f09891c 100755
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -3,6 +3,7 @@
 #include <sdbusplus/server.hpp>
 #include "activation.hpp"
 #include <xyz/openbmc_project/Common/FactoryReset/server.hpp>
+#include <xyz/openbmc_project/Object/Enable/server.hpp>
 #include "version.hpp"
 #include "org/openbmc/Associations/server.hpp"
 #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
@@ -20,12 +21,15 @@
         sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
 using GardResetInherit = sdbusplus::server::object::object<
         sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>;
+using ObjectEnable = sdbusplus::server::object::object<
+        sdbusplus::xyz::openbmc_project::Object::server::Enable>;
 namespace MatchRules = sdbusplus::bus::match::rules;
 
 using AssociationList =
         std::vector<std::tuple<std::string, std::string, std::string>>;
 
 constexpr auto GARD_PATH = "/org/open_power/control/gard";
+constexpr static auto volatilePath = "/org/open_power/control/volatile";
 
 /** @class GardReset
  *  @brief OpenBMC GARD factory reset implementation.
@@ -94,6 +98,7 @@
         {
             processPNORImage();
             gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
+            volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
 
             // Emit deferred signal.
             emit_object_added();
@@ -180,6 +185,9 @@
          */
         static bool isVersionFunctional(const std::string& versionId);
 
+        /** @brief Persistent ObjectEnable D-Bus object */
+        std::unique_ptr<ObjectEnable> volatileEnable;
+
     private:
         /** @brief Callback function for Software.Version match.
          *  @details Creates an Activation D-Bus object.