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 | { |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 8 | namespace details |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 9 | { |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 10 | void commit(const char* name) |
| 11 | { |
| 12 | using phosphor::logging::log; |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 13 | constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; |
Leonel Gonzalez | 3064a19 | 2017-03-16 13:47:40 -0500 | [diff] [blame] | 14 | constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 15 | constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; |
| 16 | |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 17 | constexpr auto IFACE_INTERNAL("xyz.openbmc_project.Logging.Internal.Manager"); |
| 18 | |
| 19 | // Transaction id is located at the end of the string separated by a period. |
| 20 | |
| 21 | auto b = sdbusplus::bus::new_default(); |
| 22 | auto mapper = b.new_method_call( |
| 23 | MAPPER_BUSNAME, |
| 24 | MAPPER_PATH, |
| 25 | MAPPER_INTERFACE, |
| 26 | "GetObject"); |
| 27 | mapper.append(OBJ_INTERNAL, std::vector<std::string>({IFACE_INTERNAL})); |
| 28 | |
| 29 | auto mapperResponseMsg = b.call(mapper); |
| 30 | if (mapperResponseMsg.is_method_error()) |
| 31 | { |
| 32 | log<level::ERR>("Error in mapper call"); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | std::map<std::string, std::vector<std::string>> mapperResponse; |
| 37 | mapperResponseMsg.read(mapperResponse); |
| 38 | if (mapperResponse.empty()) |
| 39 | { |
| 40 | log<level::ERR>("Error reading mapper response"); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | const auto& host = mapperResponse.cbegin()->first; |
| 45 | auto m = b.new_method_call( |
| 46 | host.c_str(), |
| 47 | OBJ_INTERNAL, |
| 48 | IFACE_INTERNAL, |
| 49 | "Commit"); |
| 50 | uint64_t id = sdbusplus::server::transaction::get_id(); |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 51 | m.append(id, name); |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 52 | b.call_noreply(m); |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 53 | } |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 54 | } // namespace details |
| 55 | |
| 56 | void commit(std::string&& name) |
| 57 | { |
| 58 | log<level::ERR>("method is deprecated, use commit() with exception type"); |
| 59 | phosphor::logging::details::commit(name.c_str()); |
| 60 | } |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 61 | |
| 62 | } // namespace logging |
| 63 | } // namespace phosphor |
| 64 | |