1*d31be2ccSJayanth Othayoth #include "dump_utils.hpp" 2*d31be2ccSJayanth Othayoth 3*d31be2ccSJayanth Othayoth #include <phosphor-logging/log.hpp> 4*d31be2ccSJayanth Othayoth 5*d31be2ccSJayanth Othayoth namespace phosphor 6*d31be2ccSJayanth Othayoth { 7*d31be2ccSJayanth Othayoth namespace dump 8*d31be2ccSJayanth Othayoth { 9*d31be2ccSJayanth Othayoth 10*d31be2ccSJayanth Othayoth std::string getService(sdbusplus::bus::bus& bus, const std::string& path, 11*d31be2ccSJayanth Othayoth const std::string& interface) 12*d31be2ccSJayanth Othayoth { 13*d31be2ccSJayanth Othayoth constexpr auto objectMapperName = "xyz.openbmc_project.ObjectMapper"; 14*d31be2ccSJayanth Othayoth constexpr auto objectMapperPath = "/xyz/openbmc_project/object_mapper"; 15*d31be2ccSJayanth Othayoth using namespace phosphor::logging; 16*d31be2ccSJayanth Othayoth 17*d31be2ccSJayanth Othayoth auto method = bus.new_method_call(objectMapperName, objectMapperPath, 18*d31be2ccSJayanth Othayoth objectMapperName, "GetObject"); 19*d31be2ccSJayanth Othayoth 20*d31be2ccSJayanth Othayoth method.append(path); 21*d31be2ccSJayanth Othayoth method.append(std::vector<std::string>({interface})); 22*d31be2ccSJayanth Othayoth 23*d31be2ccSJayanth Othayoth std::vector<std::pair<std::string, std::vector<std::string>>> response; 24*d31be2ccSJayanth Othayoth 25*d31be2ccSJayanth Othayoth try 26*d31be2ccSJayanth Othayoth { 27*d31be2ccSJayanth Othayoth auto reply = bus.call(method); 28*d31be2ccSJayanth Othayoth reply.read(response); 29*d31be2ccSJayanth Othayoth if (response.empty()) 30*d31be2ccSJayanth Othayoth { 31*d31be2ccSJayanth Othayoth log<level::ERR>("Error in mapper response for getting service name", 32*d31be2ccSJayanth Othayoth entry("PATH=%s", path.c_str()), 33*d31be2ccSJayanth Othayoth entry("INTERFACE=%s", interface.c_str())); 34*d31be2ccSJayanth Othayoth return std::string{}; 35*d31be2ccSJayanth Othayoth } 36*d31be2ccSJayanth Othayoth } 37*d31be2ccSJayanth Othayoth catch (const sdbusplus::exception::SdBusError& e) 38*d31be2ccSJayanth Othayoth { 39*d31be2ccSJayanth Othayoth log<level::ERR>("Error in mapper method call", 40*d31be2ccSJayanth Othayoth entry("ERROR=%s", e.what()), 41*d31be2ccSJayanth Othayoth entry("PATH=%s", path.c_str()), 42*d31be2ccSJayanth Othayoth entry("INTERFACE=%s", interface.c_str())); 43*d31be2ccSJayanth Othayoth return std::string{}; 44*d31be2ccSJayanth Othayoth } 45*d31be2ccSJayanth Othayoth return response[0].first; 46*d31be2ccSJayanth Othayoth } 47*d31be2ccSJayanth Othayoth 48*d31be2ccSJayanth Othayoth } // namespace dump 49*d31be2ccSJayanth Othayoth } // namespace phosphor 50