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