Added openpower util file support
Created common file to keep all the common util functions.
In this commit
- added getService function to get d-bus service for given
interface.
- updated create_pel.cpp to start using common util interface.
- Moved formatting library to common build dependency for
both meson and automake.
Tested: Manually verified.
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I39a642710c0476e81fae020eb3b4216ca8ce9ad5
diff --git a/phalerror/create_pel.cpp b/phalerror/create_pel.cpp
index e3e6117..4ca8bb0 100644
--- a/phalerror/create_pel.cpp
+++ b/phalerror/create_pel.cpp
@@ -1,5 +1,7 @@
#include "create_pel.hpp"
+#include "util.hpp"
+
#include <fcntl.h>
#include <fmt/format.h>
#include <libekb.H>
@@ -23,41 +25,6 @@
{
using namespace phosphor::logging;
-namespace util
-{
-std::string getService(sdbusplus::bus::bus& bus, const std::string& objectPath,
- const std::string& interface)
-{
- constexpr auto mapperBusBame = "xyz.openbmc_project.ObjectMapper";
- constexpr auto mapperObjectPath = "/xyz/openbmc_project/object_mapper";
- constexpr auto mapperInterface = "xyz.openbmc_project.ObjectMapper";
- std::vector<std::pair<std::string, std::vector<std::string>>> response;
- auto method = bus.new_method_call(mapperBusBame, mapperObjectPath,
- mapperInterface, "GetObject");
- method.append(objectPath, std::vector<std::string>({interface}));
- try
- {
- auto reply = bus.call(method);
- reply.read(response);
- }
- catch (const sdbusplus::exception::SdBusError& e)
- {
- log<level::ERR>("D-Bus call exception",
- entry("OBJPATH=%s", mapperObjectPath),
- entry("INTERFACE=%s", mapperInterface),
- entry("EXCEPTION=%s", e.what()));
-
- throw std::runtime_error("Service name is not found");
- }
-
- if (response.empty())
- {
- throw std::runtime_error("Service name response is empty");
- }
- return response.begin()->first;
-}
-} // namespace util
-
namespace pel
{
void createBootErrorPEL(const FFDCData& ffdcData, const json& calloutData)