Added asynchronous callDbusMethod

This path added two callDbusMethod methods, one without method return
value (default return ec), and the other with method return value.

Change-Id: I16503fe24adc0f3896a861972751d532b6361ef9
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index 3d16344..e8c4223 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -26,6 +26,7 @@
 #include <ipmid/api.hpp>
 #include <ipmid/message.hpp>
 #include <ipmid/types.hpp>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/message/types.hpp>
 #include <sdbusplus/timer.hpp>
@@ -80,12 +81,8 @@
     boost::container::flat_map<sdbusplus::message::object_path, ObjectType>;
 using ManagedEntry = std::pair<sdbusplus::message::object_path, ObjectType>;
 
-constexpr static const char* selLoggerServiceName =
-    "xyz.openbmc_project.Logging.IPMI";
 constexpr static const char* fruDeviceServiceName =
     "xyz.openbmc_project.FruDevice";
-constexpr static const char* entityManagerServiceName =
-    "xyz.openbmc_project.EntityManager";
 constexpr static const size_t writeTimeoutSeconds = 10;
 constexpr static const char* chassisTypeRackMount = "23";
 constexpr static const char* chassisTypeMainServer = "17";
@@ -251,13 +248,11 @@
     cacheAddr = deviceFind->second.second;
 
     boost::system::error_code ec;
+    std::vector<uint8_t> fru = ipmi::callDbusMethod<std::vector<uint8_t>>(
+        ctx, ec, fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
+        "xyz.openbmc_project.FruDeviceManager", "GetRawFru", cacheBus,
+        cacheAddr);
 
-    std::vector<uint8_t> fru =
-        ctx->bus->yield_method_call<std::vector<uint8_t>>(
-            ctx->yield, ec, fruDeviceServiceName,
-            "/xyz/openbmc_project/FruDevice",
-            "xyz.openbmc_project.FruDeviceManager", "GetRawFru", cacheBus,
-            cacheAddr);
     if (ec)
     {
         lg2::error("Couldn't get raw fru: {ERROR}", "ERROR", ec.message());
@@ -598,9 +593,8 @@
 
     // todo: this should really use caching, this is a very inefficient lookup
     boost::system::error_code ec;
-
-    ManagedObjectType entities = ctx->bus->yield_method_call<ManagedObjectType>(
-        ctx->yield, ec, entityManagerServiceName,
+    ManagedObjectType entities = ipmi::callDbusMethod<ManagedObjectType>(
+        ctx, ec, "xyz.openbmc_project.EntityManager",
         "/xyz/openbmc_project/inventory", "org.freedesktop.DBus.ObjectManager",
         "GetManagedObjects");
 
@@ -1186,13 +1180,13 @@
     // cleared
     cancelSELReservation();
 
-    boost::system::error_code ec;
-    ctx->bus->yield_method_call<>(ctx->yield, ec, selLoggerServiceName,
-                                  "/xyz/openbmc_project/Logging/IPMI",
-                                  "xyz.openbmc_project.Logging.IPMI", "Clear");
+    boost::system::error_code ec =
+        ipmi::callDbusMethod(ctx, "xyz.openbmc_project.Logging.IPMI",
+                             "/xyz/openbmc_project/Logging/IPMI",
+                             "xyz.openbmc_project.Logging.IPMI", "Clear");
     if (ec)
     {
-        std::cerr << "error in clear SEL: " << ec << std::endl;
+        std::cerr << "error in clear SEL: " << ec.message() << std::endl;
         return ipmi::responseUnspecifiedError();
     }