1 #include "config.h"
2 
3 #include "scheduled_host_transition.hpp"
4 
5 #include <sdbusplus/bus.hpp>
6 
7 #include <cstdlib>
8 #include <exception>
9 #include <filesystem>
10 
11 int main()
12 {
13     namespace fs = std::filesystem;
14 
15     // Get a default event loop
16     auto event = sdeventplus::Event::get_default();
17 
18     // Get a handle to system dbus
19     auto bus = sdbusplus::bus::new_default();
20 
21     // For now, we only have one instance of the host
22     auto objPathInst = std::string{HOST_OBJPATH} + '0';
23 
24     // Check SCHEDULED_HOST_TRANSITION_PERSIST_PATH
25     auto dir = fs::path(SCHEDULED_HOST_TRANSITION_PERSIST_PATH).parent_path();
26     if (!fs::exists(dir))
27     {
28         fs::create_directories(dir);
29     }
30 
31     // Add sdbusplus ObjectManager.
32     sdbusplus::server::manager::manager objManager(bus, objPathInst.c_str());
33 
34     phosphor::state::manager::ScheduledHostTransition manager(
35         bus, objPathInst.c_str(), event);
36 
37     bus.request_name(SCHEDULED_HOST_TRANSITION_BUSNAME);
38 
39     // Attach the bus to sd_event to service user requests
40     bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
41     event.loop();
42 
43     return 0;
44 }
45