Item Updater: Implement BMC factory reset
This commit implements the generic factory reset interface for the BMC
software updater. When the reset function is called, a service file is
called which sets the environmental variable to reset the RW volume.
Change-Id: Ic69b5d145edd654ed75295a9e9aeef9f53779dad
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 667c4b6..fe9af2f 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -22,6 +22,10 @@
constexpr auto bmcImage = "image-rofs";
+constexpr auto SYSTEMD_BUSNAME = "org.freedesktop.systemd1";
+constexpr auto SYSTEMD_PATH = "/org/freedesktop/systemd1";
+constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
+
void ItemUpdater::createActivation(sdbusplus::message::message& msg)
{
@@ -182,6 +186,22 @@
}
}
+void ItemUpdater::reset()
+{
+ // Mark the read-write partition for recreation upon reboot.
+ auto method = bus.new_method_call(
+ SYSTEMD_BUSNAME,
+ SYSTEMD_PATH,
+ SYSTEMD_INTERFACE,
+ "StartUnit");
+ method.append("obmc-flash-bmc-setenv@rwreset=true.service", "replace");
+ bus.call_noreply(method);
+
+ log<level::INFO>("BMC factory reset will take effect upon reboot.");
+
+ return;
+}
+
} // namespace updater
} // namespace software
} // namespace phosphor