PEL: Reset host transmission state on restart

When the Repository class starts up, if it finds any existing PELs with
a host transmission state of 'sent', set it back to 'new' so that it
will get sent again, as the BMC restarted or the daemon crashed before
the host could ack it.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ieeca2c1a92eabc0a22051be6b87cecbe0b1d519d
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index 5414458..b15fd38 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -58,6 +58,23 @@
             PEL pel{data};
             if (pel.valid())
             {
+                // If the host hasn't acked it, reset the host state so
+                // it will get sent up again.
+                if (pel.hostTransmissionState() == TransmissionState::sent)
+                {
+                    pel.setHostTransmissionState(TransmissionState::newPEL);
+                    try
+                    {
+                        write(pel, dirEntry.path());
+                    }
+                    catch (std::exception& e)
+                    {
+                        log<level::ERR>(
+                            "Failed to save PEL after updating host state",
+                            entry("PELID=0x%X", pel.id()));
+                    }
+                }
+
                 PELAttributes attributes{
                     dirEntry.path(), pel.userHeader().actionFlags(),
                     pel.hostTransmissionState(), pel.hmcTransmissionState()};