Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 1 | #include <attn/attn_handler.hpp> |
| 2 | #include <attn/attn_logging.hpp> |
| 3 | #include <attn/ti_handler.hpp> |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
| 5 | |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 6 | namespace attn |
| 7 | { |
| 8 | |
| 9 | /** @brief Start host diagnostic mode systemd unit */ |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 10 | int tiHandler(TiDataArea* i_tiDataArea) |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 11 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 12 | int rc = RC_NOT_HANDLED; // assume TI not handled |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 13 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 14 | if (0xa1 == i_tiDataArea->command) |
| 15 | { |
| 16 | // trace message |
| 17 | trace<level::INFO>("start host diagnostic mode service"); |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 18 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 19 | // Use the systemd service manager object interface to call the start |
| 20 | // unit method with the obmc-host-diagnostic-mode target. |
| 21 | auto bus = sdbusplus::bus::new_system(); |
| 22 | auto method = bus.new_method_call( |
| 23 | "org.freedesktop.systemd1", "/org/freedesktop/systemd1", |
| 24 | "org.freedesktop.systemd1.Manager", "StartUnit"); |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 25 | |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 26 | method.append("obmc-host-diagnostic-mode@0.target"); // unit to activate |
| 27 | method.append("replace"); // mode = replace conflicting queued jobs |
| 28 | bus.call_noreply(method); // start the service |
| 29 | |
| 30 | rc = RC_SUCCESS; |
| 31 | } |
| 32 | |
| 33 | return rc; |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | } // namespace attn |