PEL: Clear deconfig flag after callout replaced

Making use of the previous commit's framework to call a function when a
fan or power supply becomes present, add code to the Manager class to
register a callback that will clear the deconfig flag for all PELs
created with the power-thermal or fan component ID that have the
location code of the replaced fan/PS as a callout.

This way, the degraded mode reporting code will no longer pick up those
PELs in its report as since the hardware was replaced those PELs are no
longer relevant.

This is necessary only for fans or power supplies because they're the
only N+1 hardware that can be hot plugged at runtime.  And also because
this is what the IBM service team wants.

Tested:
Simulated missing hardware (changed present D-Bus property for fans,
toggled PSU presence GPIO in the simulator for PSs).  Saw errors get
created for it, then simulated replacing it and saw those errors have
their deconfig flag cleared, verifying before and after with peltool:

```
// Remove and replace fan
phosphor-fan-monitor: Fan /system/chassis/motherboard/fan0 presence state change to false
phosphor-log-manager: Created PEL 0x50000002 (BMC ID 2) with SRC 110076F1
phosphor-fan-monitor: Fan /system/chassis/motherboard/fan0 presence state change to true
phosphor-log-manager: Detected FRU /xyz/openbmc_project/inventory/system/chassis/motherboard/fan0 (U78DB.ND0.1234567-A0) present
phosphor-log-manager: Clearing deconfig flag in PEL 0x50000002 with SRC 110076F1 because U78DB.ND0.1234567-A0 was replaced

// Remove and replace PS
phosphor-log-manager: Created PEL 0x50000003 (BMC ID 3) with SRC 110015F6
...
phosphor-psu-monitor: Updating inventory present property. present:true invpath:/system/chassis/motherboard/powersupply0 name:powersupply0
phosphor-log-manager: Detected FRU /xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0 (U78DB.ND0.1234567-E0) present
phosphor-log-manager: Clearing deconfig flag in PEL 0x50000003 with SRC 110015F6 because U78DB.ND0.1234567-E0 was replaced
```

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iee05b4a612ca8f438f8c89f37b4e7b529a131a9f
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index 8f439a5..ca7f12e 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -70,6 +70,10 @@
             std::bind(&Manager::updateResolution, this, std::placeholders::_1));
 
         setupPELDeleteWatch();
+
+        _dataIface->subscribeToFruPresent(
+            "Manager",
+            std::bind(&Manager::hardwarePresent, this, std::placeholders::_1));
     }
 
     /**
@@ -479,6 +483,30 @@
     void deleteObmcLog(sdeventplus::source::EventBase&, uint32_t obmcLogID);
 
     /**
+     * @brief Clears the deconfig flag in the PEL if necessary.
+     *
+     * If the passed in location code is in a callout and it's a PEL with
+     * the BMC power/thermal or fans component ID, clear the deconfig flag.
+     *
+     * @param[in] locationCode - The location code to look for
+     * @param[inout] pel - The PEL to check and modify.
+     * @return bool - true if the flag was cleared for this PEL
+     */
+    static bool clearPowerThermalDeconfigFlag(const std::string& locationCode,
+                                              openpower::pels::PEL& pel);
+
+    /**
+     * @brief Called by DataInterface when the presence of hotpluggable
+     *        hardware is detected.
+     *
+     * Clears the 'Deconfig' flag in any PEL that has the location code
+     * of the hardware in a callout.
+     *
+     * @param[in] locationCode - The location code of the hardware.
+     */
+    void hardwarePresent(const std::string& locationCode);
+
+    /**
      * @brief Reference to phosphor-logging's Manager class
      */
     phosphor::logging::internal::Manager& _logManager;