Persist the snmp manager configuration
This commit persist the manager configuration D-Bus objects
and restores it once service starts.
This commit also deletes the associated persistent file whenever
snmp client D-Bus object gets deleted.
Change-Id: I1526b52870ee5dfea30e6527bad3fd12d1191a13
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/snmp_conf_manager.hpp b/snmp_conf_manager.hpp
index 0f1ee4b..d9164ae 100644
--- a/snmp_conf_manager.hpp
+++ b/snmp_conf_manager.hpp
@@ -5,6 +5,7 @@
#include <xyz/openbmc_project/Network/Client/Create/server.hpp>
#include <sdbusplus/bus.hpp>
+#include <experimental/filesystem>
#include <string>
namespace phosphor
@@ -13,8 +14,10 @@
{
namespace snmp
{
+
using IPAddress = std::string;
using ClientList = std::map<IPAddress, std::unique_ptr<Client>>;
+namespace fs = std::experimental::filesystem;
namespace details
{
@@ -38,7 +41,7 @@
ConfManager& operator=(ConfManager&&) = delete;
virtual ~ConfManager() = default;
- /** @brief Constructor to put object onto bus at a dbus path.
+ /** @brief Constructor to put object onto bus at a D-Bus path.
* @param[in] bus - Bus to attach to.
* @param[in] objPath - Path to attach at.
*/
@@ -50,11 +53,19 @@
*/
void client(std::string address, uint16_t port) override;
- /* @brief delete the dbus object of the given ipaddress.
+ /* @brief delete the D-Bus object of the given ipaddress.
* @param[in] address - IP address/Hostname.
*/
void deleteSNMPClient(const std::string& address);
+ /** @brief Construct manager/client D-Bus objects from their persisted
+ * representations.
+ */
+ void restoreClients();
+
+ /** @brief location of the persisted D-Bus object.*/
+ fs::path dbusPersistentLocation;
+
protected:
/** @brief generates the id by doing hash of ipaddress, port
* @param[in] address - IP address/Hostname.