EventService: Move subscription persistent data

This commit resolves https://github.com/openbmc/bmcweb/issues/168
Current store mechanism makes it very difficult to keep in sync with
the existing files, and has caused several bugs because the path it
uses different than the existing bmcweb_persistent_data.json, and it's
missing several error checks.

If there has old config in /var/lib/bmcweb/eventservice_config.json.
Restart bmcweb will move old config to bmcweb_presistent_data.json and
delete the old config.


Tested:
 - Create new Subscription via POST
https://${bmc}/redfish/v1/EventService/Subscriptions/

The subscription is successfully created and GET succussfully.
Restart bmcweb or reboot.
The subscription will restore.

 - Delete the Subscription via DELETE
https://${bmc}/redfish/v1/EventService/Subscriptions/${subscription_id}

The subscription is successfully delete.
bmcweb_persistent_data.json will delete subscription content.

 - Modify EventService config via PATCH
https://{{bmc}}/redfish/v1/EventService

GET https://{{bmc}}/redfish/v1/EventService and the changes applied.
bmcweb_persistent_data.json will apply modification after PATCH.
Restart bmcweb or reboot
The config maintains the changed.

Signed-off-by: JunLin Chen <Jun-Lin.Chen@quantatw.com>
Change-Id: Ic29385ea8231ba976bbf415af2803df2d30cb10a
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 98c67c6..f1d6f50 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -58,16 +58,18 @@
                                    "EventService.SubmitTestEvent"}}}}},
                     {"@odata.id", "/redfish/v1/EventService"}};
 
-                const auto& [enabled, retryAttempts, retryTimeoutInterval] =
-                    EventServiceManager::getInstance().getEventServiceConfig();
+                const persistent_data::EventServiceConfig eventServiceConfig =
+                    persistent_data::EventServiceStore::getInstance()
+                        .getEventServiceConfig();
 
                 asyncResp->res.jsonValue["Status"]["State"] =
-                    (enabled ? "Enabled" : "Disabled");
-                asyncResp->res.jsonValue["ServiceEnabled"] = enabled;
+                    (eventServiceConfig.enabled ? "Enabled" : "Disabled");
+                asyncResp->res.jsonValue["ServiceEnabled"] =
+                    eventServiceConfig.enabled;
                 asyncResp->res.jsonValue["DeliveryRetryAttempts"] =
-                    retryAttempts;
+                    eventServiceConfig.retryAttempts;
                 asyncResp->res.jsonValue["DeliveryRetryIntervalSeconds"] =
-                    retryTimeoutInterval;
+                    eventServiceConfig.retryTimeoutInterval;
                 asyncResp->res.jsonValue["EventFormatTypes"] =
                     supportedEvtFormatTypes;
                 asyncResp->res.jsonValue["RegistryPrefixes"] =
@@ -103,12 +105,13 @@
                     return;
                 }
 
-                auto [enabled, retryCount, retryTimeoutInterval] =
-                    EventServiceManager::getInstance().getEventServiceConfig();
+                persistent_data::EventServiceConfig eventServiceConfig =
+                    persistent_data::EventServiceStore::getInstance()
+                        .getEventServiceConfig();
 
                 if (serviceEnabled)
                 {
-                    enabled = *serviceEnabled;
+                    eventServiceConfig.enabled = *serviceEnabled;
                 }
 
                 if (retryAttemps)
@@ -122,7 +125,7 @@
                     }
                     else
                     {
-                        retryCount = *retryAttemps;
+                        eventServiceConfig.retryAttempts = *retryAttemps;
                     }
                 }
 
@@ -137,12 +140,13 @@
                     }
                     else
                     {
-                        retryTimeoutInterval = *retryInterval;
+                        eventServiceConfig.retryTimeoutInterval =
+                            *retryInterval;
                     }
                 }
 
                 EventServiceManager::getInstance().setEventServiceConfig(
-                    std::make_tuple(enabled, retryCount, retryTimeoutInterval));
+                    eventServiceConfig);
             });
 }