Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 1 | #include <cstdlib> |
| 2 | #include <iostream> |
| 3 | #include <exception> |
| 4 | #include <sdbusplus/bus.hpp> |
Dhruvaraj Subhashchandran | 3f47524 | 2017-07-12 00:44:27 -0500 | [diff] [blame] | 5 | #include <experimental/filesystem> |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 6 | #include "config.h" |
| 7 | #include "host_state_manager.hpp" |
| 8 | |
| 9 | int main(int argc, char *argv[]) |
| 10 | { |
Dhruvaraj Subhashchandran | 3f47524 | 2017-07-12 00:44:27 -0500 | [diff] [blame] | 11 | namespace fs = std::experimental::filesystem; |
| 12 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 13 | auto bus = sdbusplus::bus::new_default(); |
| 14 | |
Andrew Geissler | 1cb8b70 | 2016-12-13 13:33:06 -0600 | [diff] [blame] | 15 | // For now, we only have one instance of the host |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 16 | auto objPathInst = std::string{HOST_OBJPATH} + '0'; |
Andrew Geissler | 1cb8b70 | 2016-12-13 13:33:06 -0600 | [diff] [blame] | 17 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 18 | // Add sdbusplus ObjectManager. |
Andrew Geissler | 1cb8b70 | 2016-12-13 13:33:06 -0600 | [diff] [blame] | 19 | sdbusplus::server::manager::manager objManager(bus, objPathInst.c_str()); |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 20 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 21 | phosphor::state::manager::Host manager(bus, HOST_BUSNAME, |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 22 | objPathInst.c_str()); |
| 23 | |
Dhruvaraj Subhashchandran | 3f47524 | 2017-07-12 00:44:27 -0500 | [diff] [blame] | 24 | auto dir = fs::path(HOST_STATE_PERSIST_PATH).parent_path(); |
| 25 | fs::create_directories(dir); |
| 26 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 27 | bus.request_name(HOST_BUSNAME); |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 28 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 29 | while (true) |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 30 | { |
| 31 | bus.process_discard(); |
| 32 | bus.wait(); |
| 33 | } |
| 34 | return 0; |
| 35 | } |