Change the logic of generating the D-Bus object identifier

Presently D-Bus object identifier is generated with the hash of
D-Bus properties, as a result of this if the value of D-Bus property
gets change the D-Bus object identifier will get change.

This commit fixes this problem by keeping the last identifier
value in the manager object so whenever user creates new snmp
manager object it is incremented by 1, hence the object path
becomes unique.

This commit also takes care of that if at any point of time
if snmp manager app restart it gets the same D-Bus identifier
as it was before the restart.

Change-Id: I456c11f7824ff678ae470bc6641f0e0cc7c1f6bc
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
diff --git a/snmp_conf_manager.hpp b/snmp_conf_manager.hpp
index 7381314..f477b31 100644
--- a/snmp_conf_manager.hpp
+++ b/snmp_conf_manager.hpp
@@ -15,8 +15,7 @@
 namespace snmp
 {
 
-using IPAddress = std::string;
-using ClientList = std::map<IPAddress, std::unique_ptr<Client>>;
+using ClientList = std::map<Id, std::unique_ptr<Client>>;
 namespace fs = std::experimental::filesystem;
 
 namespace details
@@ -54,10 +53,10 @@
      */
     std::string client(std::string address, uint16_t port) override;
 
-    /* @brief delete the D-Bus object of the given ipaddress.
-     * @param[in] address - IP address/Hostname.
+    /* @brief delete the D-Bus object of the given ID.
+     * @param[in] id - client identifier.
      */
-    void deleteSNMPClient(const std::string& address);
+    void deleteSNMPClient(Id id);
 
     /** @brief Construct manager/client D-Bus objects from their persisted
      *         representations.
@@ -67,14 +66,6 @@
     /** @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.
-     *  @param[in] port - network port.
-     *  @return hash string.
-     */
-    static std::string generateId(const std::string& address, uint16_t port);
-
   private:
     /** @brief sdbusplus DBus bus object. */
     sdbusplus::bus::bus& bus;
@@ -82,9 +73,12 @@
     /** @brief Path of Object. */
     std::string objectPath;
 
-    /** @brief map of IPAddress dbus objects and their names */
+    /** @brief map of SNMP Client dbus objects and their ID */
     ClientList clients;
 
+    /** @brief Id of the last SNMP manager entry */
+    Id lastClientId = 0;
+
     friend class TestSNMPConfManager;
 };