Jayanth Othayoth | 5ba35c6 | 2025-06-07 03:55:11 -0500 | [diff] [blame] | 1 | #include "watchdog_common.hpp" |
| 2 | |
| 3 | #include "watchdog_logging.hpp" |
| 4 | |
Shantappa Teekappanavar | 1ac6162 | 2021-06-22 19:07:29 -0500 | [diff] [blame] | 5 | #include <phosphor-logging/log.hpp> |
| 6 | #include <sdbusplus/bus.hpp> |
Shantappa Teekappanavar | 1ac6162 | 2021-06-22 19:07:29 -0500 | [diff] [blame] | 7 | |
| 8 | #include <map> |
| 9 | |
| 10 | namespace watchdog |
| 11 | { |
| 12 | namespace dump |
| 13 | { |
| 14 | |
| 15 | using namespace phosphor::logging; |
| 16 | |
| 17 | void transitionHost(const std::string& target) |
| 18 | { |
| 19 | constexpr auto systemdService = "org.freedesktop.systemd1"; |
| 20 | constexpr auto systemdObjPath = "/org/freedesktop/systemd1"; |
| 21 | constexpr auto systemdInterface = "org.freedesktop.systemd1.Manager"; |
| 22 | |
| 23 | auto bus = sdbusplus::bus::new_system(); |
| 24 | auto method = bus.new_method_call(systemdService, systemdObjPath, |
| 25 | systemdInterface, "StartUnit"); |
| 26 | |
| 27 | method.append(target); // target unit to start |
| 28 | method.append("replace"); |
| 29 | |
| 30 | bus.call_noreply(method); // start the service |
| 31 | } |
| 32 | |
Shantappa Teekappanavar | 1ac6162 | 2021-06-22 19:07:29 -0500 | [diff] [blame] | 33 | } // namespace dump |
| 34 | } // namespace watchdog |