Create Interface returns the D-Bus object path

In current code when the client creates the SNNP manager D-Bus object,
snmp-conf-manager(D-Bus service) implementing the create interface
was not returning the newly created D-Bus object path, hence
client needs to make the enumerate call on the
network namespace to find the newly create D-Bus object path.

This commit fixes this problem where Create interface starts
returning the newly created D-Bus object path.

Resolves openbmc/phosphor-snmp#1

Change-Id: I26e1ee4a2b869553e511576457148bd1dd9dc224
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/snmp_conf_manager.cpp b/snmp_conf_manager.cpp
index d2d5d8f..a215ef4 100644
--- a/snmp_conf_manager.cpp
+++ b/snmp_conf_manager.cpp
@@ -29,13 +29,14 @@
 {
 }
 
-void ConfManager::client(std::string address, uint16_t port)
+std::string ConfManager::client(std::string address, uint16_t port)
 {
     auto clientEntry = this->clients.find(address);
     if (clientEntry != this->clients.end())
     {
-        // address is already there
-        return;
+        log<level::ERR>("Client already configured"),
+            entry("ADDRESS=%s", address.c_str());
+        elog<InternalFailure>();
     }
     try
     {
@@ -49,17 +50,18 @@
         elog<InvalidArgument>(Argument::ARGUMENT_NAME("Address"),
                               Argument::ARGUMENT_VALUE(address.c_str()));
     }
-    // create the D-Bus object
+
     std::experimental::filesystem::path objPath;
     objPath /= objectPath;
     objPath /= generateId(address, port);
-
+    // create the D-Bus object
     auto client = std::make_unique<phosphor::network::snmp::Client>(
         bus, objPath.string().c_str(), *this, address, port);
     // save the D-Bus object
     serialize(*client, dbusPersistentLocation);
 
     this->clients.emplace(address, std::move(client));
+    return objPath.string();
 }
 
 std::string ConfManager::generateId(const std::string& address, uint16_t port)
diff --git a/snmp_conf_manager.hpp b/snmp_conf_manager.hpp
index d9164ae..7381314 100644
--- a/snmp_conf_manager.hpp
+++ b/snmp_conf_manager.hpp
@@ -50,8 +50,9 @@
     /** @brief Function to create snmp manager details D-Bus object.
      *  @param[in] address- IP address/Hostname.
      *  @param[in] port - network port.
+     *  @returns D-Bus object path
      */
-    void client(std::string address, uint16_t port) override;
+    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.
diff --git a/xyz/openbmc_project/Network/Client/Create.interface.yaml b/xyz/openbmc_project/Network/Client/Create.interface.yaml
index ff45533..77955d5 100644
--- a/xyz/openbmc_project/Network/Client/Create.interface.yaml
+++ b/xyz/openbmc_project/Network/Client/Create.interface.yaml
@@ -14,3 +14,8 @@
               Network port.
       errors:
         - xyz.openbmc_project.Common.Error.InvalidArgument
+      returns:
+        - name: path
+          type: string
+          description: >
+              Path of the object which has been created.