Refactor to call the getProperty method
Uniformly use the getProperty method of utils.hpp to obtain values
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I9eae6bba6806215b51090637a7e42c8c8d90be87
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 50505aa..ac907de 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <boost/interprocess/sync/scoped_lock.hpp>
+#include <ipmid/utils.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus/match.hpp>
#include <sdbusplus/server/object.hpp>
@@ -1331,35 +1332,6 @@
return 0;
}
-int ChannelConfig::getDbusProperty(const std::string& service,
- const std::string& objPath,
- const std::string& interface,
- const std::string& property,
- DbusVariant& value)
-{
- try
- {
- auto method = bus.new_method_call(service.c_str(), objPath.c_str(),
- "org.freedesktop.DBus.Properties",
- "Get");
-
- method.append(interface, property);
-
- auto reply = bus.call(method);
- reply.read(value);
- }
- catch (const sdbusplus::exception_t& e)
- {
- log<level::DEBUG>("get-property failed",
- entry("SERVICE=%s", service.c_str()),
- entry("OBJPATH=%s", objPath.c_str()),
- entry("INTERFACE=%s", interface.c_str()),
- entry("PROP=%s", property.c_str()));
- return -EIO;
- }
- return 0;
-}
-
int ChannelConfig::syncNetworkChannelConfig()
{
boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
@@ -1376,17 +1348,11 @@
std::string networkIntfObj =
std::string(networkIntfObjectBasePath) + "/" +
channelData[chNum].chName;
- DbusVariant variant;
- if (0 != getDbusProperty(networkIntfServiceName, networkIntfObj,
- networkChConfigIntfName,
- privilegePropertyString, variant))
- {
- log<level::DEBUG>("Network interface does not exist",
- entry("INTERFACE=%s",
- channelData[chNum].chName.c_str()));
- continue;
- }
- intfPrivStr = std::get<std::string>(variant);
+ auto propValue = ipmi::getDbusProperty(
+ bus, networkIntfServiceName, networkIntfObj,
+ networkChConfigIntfName, privilegePropertyString);
+
+ intfPrivStr = std::get<std::string>(propValue);
intfPriv =
static_cast<uint8_t>(convertToPrivLimitIndex(intfPrivStr));
}