blob: 6c82cf96b0dd43cbd19cef719366b5cb0dba352b [file] [log] [blame]
Andrew Geissler36529022016-11-29 15:23:54 -06001#include <cstdlib>
2#include <iostream>
3#include <exception>
4#include <sdbusplus/bus.hpp>
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -05005#include <experimental/filesystem>
Andrew Geissler36529022016-11-29 15:23:54 -06006#include "config.h"
7#include "host_state_manager.hpp"
8
Andrew Geissler769a62f2019-12-06 13:36:08 -06009int main()
Andrew Geissler36529022016-11-29 15:23:54 -060010{
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050011 namespace fs = std::experimental::filesystem;
12
Andrew Geissler36529022016-11-29 15:23:54 -060013 auto bus = sdbusplus::bus::new_default();
14
Andrew Geissler1cb8b702016-12-13 13:33:06 -060015 // For now, we only have one instance of the host
Andrew Geisslera90a31a2016-12-13 16:16:28 -060016 auto objPathInst = std::string{HOST_OBJPATH} + '0';
Andrew Geissler1cb8b702016-12-13 13:33:06 -060017
Andrew Geissler36529022016-11-29 15:23:54 -060018 // Add sdbusplus ObjectManager.
Andrew Geissler1cb8b702016-12-13 13:33:06 -060019 sdbusplus::server::manager::manager objManager(bus, objPathInst.c_str());
Andrew Geissler36529022016-11-29 15:23:54 -060020
Andrew Geissler769a62f2019-12-06 13:36:08 -060021 phosphor::state::manager::Host manager(bus, objPathInst.c_str());
Andrew Geisslera90a31a2016-12-13 16:16:28 -060022
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050023 auto dir = fs::path(HOST_STATE_PERSIST_PATH).parent_path();
24 fs::create_directories(dir);
25
Andrew Geisslera90a31a2016-12-13 16:16:28 -060026 bus.request_name(HOST_BUSNAME);
Andrew Geissler36529022016-11-29 15:23:54 -060027
Andrew Geissler58a18012018-01-19 19:36:05 -080028 while (true)
Andrew Geissler36529022016-11-29 15:23:54 -060029 {
30 bus.process_discard();
31 bus.wait();
32 }
33 return 0;
34}