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/selutility.cpp b/selutility.cpp
index b3bfa3e..c43a660 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -317,22 +317,13 @@
"xyz.openbmc_project.Association.Definitions";
static constexpr auto assocProp = "Associations";
- auto service = ipmi::getService(bus, assocIntf, objPath);
-
- // Read the Associations interface.
- auto methodCall = bus.new_method_call(service.c_str(), objPath.c_str(),
- propIntf, "Get");
- methodCall.append(assocIntf);
- methodCall.append(assocProp);
-
- using AssociationList =
- std::vector<std::tuple<std::string, std::string, std::string>>;
-
- std::variant<AssociationList> list;
+ std::vector<ipmi::Association> assocs;
try
{
- auto reply = bus.call(methodCall);
- reply.read(list);
+ auto service = ipmi::getService(bus, assocIntf, objPath);
+ auto propValue = ipmi::getDbusProperty(bus, service, objPath, assocIntf,
+ assocProp);
+ assocs = std::get<std::vector<ipmi::Association>>(propValue);
}
catch (const std::exception& e)
{
@@ -341,8 +332,6 @@
elog<InternalFailure>();
}
- auto& assocs = std::get<AssociationList>(list);
-
/*
* Check if the log entry has any callout associations, if there is a
* callout association try to match the inventory path to the corresponding
@@ -377,21 +366,15 @@
{
sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()};
- auto service = ipmi::getService(bus, logEntryIntf, objPath);
+ static constexpr auto propTimeStamp = "Timestamp";
- using namespace std::string_literals;
- static const auto propTimeStamp = "Timestamp"s;
-
- auto methodCall = bus.new_method_call(service.c_str(), objPath.c_str(),
- propIntf, "Get");
- methodCall.append(logEntryIntf);
- methodCall.append(propTimeStamp);
-
- std::variant<uint64_t> timeStamp;
+ uint64_t timeStamp;
try
{
- auto reply = bus.call(methodCall);
- reply.read(timeStamp);
+ auto service = ipmi::getService(bus, logEntryIntf, objPath);
+ auto propValue = ipmi::getDbusProperty(bus, service, objPath,
+ logEntryIntf, propTimeStamp);
+ timeStamp = std::get<uint64_t>(propValue);
}
catch (const std::exception& e)
{
@@ -400,7 +383,7 @@
elog<InternalFailure>();
}
- std::chrono::milliseconds chronoTimeStamp(std::get<uint64_t>(timeStamp));
+ std::chrono::milliseconds chronoTimeStamp(timeStamp);
return std::chrono::duration_cast<std::chrono::seconds>(chronoTimeStamp);
}