blob: 865987cd1b7bc85a60f86837291dc646050ace7c [file] [log] [blame]
Andrew Geissler36529022016-11-29 15:23:54 -06001#include "config.h"
Andrew Geisslere426b582020-05-28 12:40:55 -05002
Andrew Geissler36529022016-11-29 15:23:54 -06003#include "host_state_manager.hpp"
4
Andrew Geisslere426b582020-05-28 12:40:55 -05005#include <sdbusplus/bus.hpp>
6
7#include <cstdlib>
8#include <exception>
9#include <experimental/filesystem>
10#include <iostream>
11
Andrew Geissler769a62f2019-12-06 13:36:08 -060012int main()
Andrew Geissler36529022016-11-29 15:23:54 -060013{
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050014 namespace fs = std::experimental::filesystem;
15
Andrew Geissler36529022016-11-29 15:23:54 -060016 auto bus = sdbusplus::bus::new_default();
17
Andrew Geissler1cb8b702016-12-13 13:33:06 -060018 // For now, we only have one instance of the host
Andrew Geisslera90a31a2016-12-13 16:16:28 -060019 auto objPathInst = std::string{HOST_OBJPATH} + '0';
Andrew Geissler1cb8b702016-12-13 13:33:06 -060020
Andrew Geissler36529022016-11-29 15:23:54 -060021 // Add sdbusplus ObjectManager.
Andrew Geissler1cb8b702016-12-13 13:33:06 -060022 sdbusplus::server::manager::manager objManager(bus, objPathInst.c_str());
Andrew Geissler36529022016-11-29 15:23:54 -060023
Andrew Geissler769a62f2019-12-06 13:36:08 -060024 phosphor::state::manager::Host manager(bus, objPathInst.c_str());
Andrew Geisslera90a31a2016-12-13 16:16:28 -060025
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050026 auto dir = fs::path(HOST_STATE_PERSIST_PATH).parent_path();
27 fs::create_directories(dir);
28
Andrew Geisslera90a31a2016-12-13 16:16:28 -060029 bus.request_name(HOST_BUSNAME);
Andrew Geissler36529022016-11-29 15:23:54 -060030
Andrew Geissler58a18012018-01-19 19:36:05 -080031 while (true)
Andrew Geissler36529022016-11-29 15:23:54 -060032 {
33 bus.process_discard();
34 bus.wait();
35 }
36 return 0;
37}