Factory Reset: Wait for env variables

A call to FactoryReset followed by an immediate reboot does not work.
Add a 3 second sleep to allow the env variables to complete.
This sleep is already in IPMI and was going to be added to
bmcweb as part of Redfish Factory Reset support, instead add here
and remove from IPMI.
https://github.com/openbmc/openpower-host-ipmi-oem/blob/61950109c770fc65f7b5539974487a5a05c54bb5/oemhandler.cpp#L355

There's still a chance 3 secs is not enough if the BMC CPU usage is
high and processes are running slow, but should be very uncommon.

Could subscribe to systemd signals but this adds more complexity and
in the past, phosphor-bmc-code-mgmt had problems with this on the
Priority value. This is probably the best solution for now.

Tested: Redfish factory reset works.
Change-Id: Ibd9c5ca87e8fcd80b558ec4e6a9486efef19421b
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 9cac8dd..9e5b173 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -15,6 +15,7 @@
 #include <queue>
 #include <set>
 #include <string>
+#include <thread>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Software/Image/error.hpp>
 
@@ -453,8 +454,13 @@
 
 void ItemUpdater::reset()
 {
+    constexpr auto setFactoryResetWait = std::chrono::seconds(3);
     helper.factoryReset();
 
+    // Need to wait for env variables to complete, otherwise an immediate reboot
+    // will not factory reset.
+    std::this_thread::sleep_for(setFactoryResetWait);
+
     log<level::INFO>("BMC factory reset will take effect upon reboot.");
 }