#include #include #include #include namespace open_power { namespace occ { // For throwing exceptions using namespace phosphor::logging; using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: Error::InternalFailure; std::string getService(sdbusplus::bus::bus& bus, const std::string& path, const std::string& intf) { auto mapperCall = bus.new_method_call("xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetObject"); mapperCall.append(path); mapperCall.append(std::vector({intf})); auto mapperResponseMsg = bus.call(mapperCall); if (mapperResponseMsg.is_method_error()) { log("ERROR in getting service", entry("PATH=%s",path.c_str()), entry("INTERFACE=%s",intf.c_str())); elog(); } std::map> mapperResponse; mapperResponseMsg.read(mapperResponse); if (mapperResponse.begin() == mapperResponse.end()) { log("ERROR reading mapper response", entry("PATH=%s",path.c_str()), entry("INTERFACE=%s",intf.c_str())); elog(); } return mapperResponse.begin()->first; } } // namespace occ } // namespace open_power