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)