blob: 7e1d14f181f0b514aa4586bfeb45181ebdef70e8 [file] [log] [blame]
Ben Tynerb797b3e2020-06-29 10:12:05 -05001#include <attn/attn_handler.hpp>
2#include <attn/attn_logging.hpp>
3#include <attn/ti_handler.hpp>
Ben Tyner9ae5ca42020-02-28 13:13:50 -06004#include <sdbusplus/bus.hpp>
5
Ben Tyner9ae5ca42020-02-28 13:13:50 -06006namespace attn
7{
8
9/** @brief Start host diagnostic mode systemd unit */
Ben Tyner792f32f2020-06-02 08:50:47 -050010int tiHandler(TiDataArea* i_tiDataArea)
Ben Tyner9ae5ca42020-02-28 13:13:50 -060011{
Ben Tyner792f32f2020-06-02 08:50:47 -050012 int rc = RC_NOT_HANDLED; // assume TI not handled
Ben Tyner9ae5ca42020-02-28 13:13:50 -060013
Ben Tyner792f32f2020-06-02 08:50:47 -050014 if (0xa1 == i_tiDataArea->command)
15 {
16 // trace message
17 trace<level::INFO>("start host diagnostic mode service");
Ben Tyner9ae5ca42020-02-28 13:13:50 -060018
Ben Tyner792f32f2020-06-02 08:50:47 -050019 // 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 Tyner9ae5ca42020-02-28 13:13:50 -060025
Ben Tyner792f32f2020-06-02 08:50:47 -050026 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 Tyner9ae5ca42020-02-28 13:13:50 -060034}
35
36} // namespace attn