xref: /openbmc/openpower-hw-diags/attn/attn_common.cpp (revision bcf65a8b95ae1e2b9c9ea53fe749ceba625732ff)
1 #include <libpdbg.h>
2 
3 #include <attn/attn_common.hpp>
4 #include <sdbusplus/bus.hpp>
5 
6 #include <map>
7 
8 namespace attn
9 {
10 
11 /** @brief Transition the host state */
12 void transitionHost(const HostState i_hostState)
13 {
14     thread_stop_all(); // in libpdbg
15 
16     // We will be transitioning host by starting appropriate dbus target
17     std::string target = "obmc-host-quiesce@0.target"; // quiesce is default
18 
19     // diagnostic mode state requested
20     if (HostState::Diagnostic == i_hostState)
21     {
22         target = "obmc-host-diagnostic-mode@0.target";
23     }
24 
25     auto bus    = sdbusplus::bus::new_system();
26     auto method = bus.new_method_call(
27         "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
28         "org.freedesktop.systemd1.Manager", "StartUnit");
29 
30     method.append(target);    // target unit to start
31     method.append("replace"); // mode = replace conflicting queued jobs
32 
33     bus.call_noreply(method); // start the service
34 }
35 
36 } // namespace attn
37