blob: da703ece0a555b08422d4d28b6c83dd3bb85e607 [file] [log] [blame]
#include "dump_utils.hpp"
#include "dump_types.hpp"
#include <phosphor-logging/lg2.hpp>
namespace phosphor
{
namespace dump
{
std::string getService(sdbusplus::bus_t& bus, const std::string& path,
const std::string& interface)
{
constexpr auto objectMapperName = "xyz.openbmc_project.ObjectMapper";
constexpr auto objectMapperPath = "/xyz/openbmc_project/object_mapper";
auto method = bus.new_method_call(objectMapperName, objectMapperPath,
objectMapperName, "GetObject");
method.append(path);
method.append(std::vector<std::string>({interface}));
std::vector<std::pair<std::string, std::vector<std::string>>> response;
try
{
auto reply = bus.call(method);
reply.read(response);
if (response.empty())
{
lg2::error(
"Error in mapper response for getting service name, PATH: "
"{PATH}, INTERFACE: {INTERFACE}",
"PATH", path, "INTERFACE", interface);
return std::string{};
}
}
catch (const sdbusplus::exception_t& e)
{
lg2::error("Error in mapper method call, errormsg: {ERROR}, "
"PATH: {PATH}, INTERFACE: {INTERFACE}",
"ERROR", e, "PATH", path, "INTERFACE", interface);
throw;
}
return response[0].first;
}
} // namespace dump
} // namespace phosphor