| #include "dump_utils.hpp" |
| |
| #include <phosphor-logging/log.hpp> |
| |
| namespace phosphor |
| { |
| namespace dump |
| { |
| |
| std::string getService(sdbusplus::bus::bus& bus, const std::string& path, |
| const std::string& interface) |
| { |
| constexpr auto objectMapperName = "xyz.openbmc_project.ObjectMapper"; |
| constexpr auto objectMapperPath = "/xyz/openbmc_project/object_mapper"; |
| using namespace phosphor::logging; |
| |
| 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()) |
| { |
| log<level::ERR>("Error in mapper response for getting service name", |
| entry("PATH=%s", path.c_str()), |
| entry("INTERFACE=%s", interface.c_str())); |
| return std::string{}; |
| } |
| } |
| catch (const sdbusplus::exception::SdBusError& e) |
| { |
| log<level::ERR>("Error in mapper method call", |
| entry("ERROR=%s", e.what()), |
| entry("PATH=%s", path.c_str()), |
| entry("INTERFACE=%s", interface.c_str())); |
| return std::string{}; |
| } |
| return response[0].first; |
| } |
| |
| } // namespace dump |
| } // namespace phosphor |