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 | |
Andrew Geissler | 769a62f | 2019-12-06 13:36:08 -0600 | [diff] [blame] | 9 | int main() |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 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 | 769a62f | 2019-12-06 13:36:08 -0600 | [diff] [blame] | 21 | phosphor::state::manager::Host manager(bus, objPathInst.c_str()); |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 22 | |
Dhruvaraj Subhashchandran | 3f47524 | 2017-07-12 00:44:27 -0500 | [diff] [blame] | 23 | auto dir = fs::path(HOST_STATE_PERSIST_PATH).parent_path(); |
| 24 | fs::create_directories(dir); |
| 25 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 26 | bus.request_name(HOST_BUSNAME); |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 27 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 28 | while (true) |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 29 | { |
| 30 | bus.process_discard(); |
| 31 | bus.wait(); |
| 32 | } |
| 33 | return 0; |
| 34 | } |