Deepak Kodihalli | 827b50f | 2017-02-24 00:00:08 -0600 | [diff] [blame] | 1 | #include "config.h" |
Saqib Khan | 2bb1519 | 2017-02-13 13:19:55 -0600 | [diff] [blame] | 2 | #include <phosphor-logging/elog.hpp> |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 3 | |
| 4 | namespace phosphor |
| 5 | { |
| 6 | namespace logging |
| 7 | { |
| 8 | |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 9 | void commit(std::string&& e) |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 10 | { |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 11 | constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; |
| 12 | constexpr auto MAPPER_PATH = "/xyz/openbmc_project/ObjectMapper"; |
| 13 | constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; |
| 14 | |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 15 | constexpr auto IFACE_INTERNAL("xyz.openbmc_project.Logging.Internal.Manager"); |
| 16 | |
| 17 | // Transaction id is located at the end of the string separated by a period. |
| 18 | |
| 19 | auto b = sdbusplus::bus::new_default(); |
| 20 | auto mapper = b.new_method_call( |
| 21 | MAPPER_BUSNAME, |
| 22 | MAPPER_PATH, |
| 23 | MAPPER_INTERFACE, |
| 24 | "GetObject"); |
| 25 | mapper.append(OBJ_INTERNAL, std::vector<std::string>({IFACE_INTERNAL})); |
| 26 | |
| 27 | auto mapperResponseMsg = b.call(mapper); |
| 28 | if (mapperResponseMsg.is_method_error()) |
| 29 | { |
| 30 | log<level::ERR>("Error in mapper call"); |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | std::map<std::string, std::vector<std::string>> mapperResponse; |
| 35 | mapperResponseMsg.read(mapperResponse); |
| 36 | if (mapperResponse.empty()) |
| 37 | { |
| 38 | log<level::ERR>("Error reading mapper response"); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | const auto& host = mapperResponse.cbegin()->first; |
| 43 | auto m = b.new_method_call( |
| 44 | host.c_str(), |
| 45 | OBJ_INTERNAL, |
| 46 | IFACE_INTERNAL, |
| 47 | "Commit"); |
| 48 | uint64_t id = sdbusplus::server::transaction::get_id(); |
| 49 | m.append(id, std::forward<std::string>(e)); |
| 50 | b.call_noreply(m); |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | } // namespace logging |
| 54 | } // namespace phosphor |
| 55 | |