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