Clear flags when the host changes to powered off state

When the host is powered off, the OCCs will be stopped, so clear any
reset pending flags as well as any outstanding HRESET requests.

This will ensure the next boot will start clean and not react to
something that happened on prior boot.

Tested on Rainier for several error scenarios.

Change-Id: Ie4156975a844e823787f7162ee0542d7f099bd12
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_manager.cpp b/occ_manager.cpp
index ff9ff3f..699f4a8 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -66,7 +66,7 @@
                   std::placeholders::_1, std::placeholders::_2),
         std::bind(std::mem_fn(&Manager::updateOccSafeMode), this,
                   std::placeholders::_1),
-        event);
+        std::bind(std::mem_fn(&Manager::hostPoweredOff), this), event);
 #endif
 }
 
@@ -1784,5 +1784,24 @@
     }
 }
 
+// Clean up any variables since the OCC is no longer running.
+// Called when pldm receives an event indicating host is powered off.
+void Manager::hostPoweredOff()
+{
+    if (resetRequired)
+    {
+        lg2::info("hostPoweredOff: Clearing resetRequired for OCC{INST}",
+                  "INST", resetInstance);
+        resetRequired = false;
+    }
+    if (resetInProgress)
+    {
+        lg2::info("hostPoweredOff: Clearing resetInProgress for OCC{INST}",
+                  "INST", resetInstance);
+        resetInProgress = false;
+    }
+    resetInstance = 255;
+}
+
 } // namespace occ
 } // namespace open_power