Implement host factory reset in item_updater

This commit implements a factory reset interface for the host.
This factory reset is accomplished by clearing all read/write
PNOR partitions.

Resolves openbmc/openbmc#1574

Change-Id: Ia2c9bd9cf829520bc724abb48aa2df3163f7d78a
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 7a5629d..3f72aeb 100755
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -144,7 +144,35 @@
     }
 }
 
+void ItemUpdater::reset()
+{
+    for(const auto& it : activations)
+    {
+        auto serviceFile = "obmc-flash-bios-ubiumount-rw@" + it.first +
+                ".service";
+
+        // Remove the read-write partitions.
+        auto method = busItem.new_method_call(
+                SYSTEMD_BUSNAME,
+                SYSTEMD_PATH,
+                SYSTEMD_INTERFACE,
+                "StartUnit");
+        method.append(serviceFile, "replace");
+        busItem.call_noreply(method);
+    }
+
+    // Remove the preserved partition.
+    auto method = busItem.new_method_call(
+            SYSTEMD_BUSNAME,
+            SYSTEMD_PATH,
+            SYSTEMD_INTERFACE,
+            "StartUnit");
+    method.append("obmc-flash-bios-ubiumount-prsv.service", "replace");
+    busItem.call_noreply(method);
+
+    return;
+}
+
 } // namespace updater
 } // namespace software
 } // namespace openpower
-