#include "config.h" #include "bios_handler.hpp" #include "constants.hpp" #include "event_logger.hpp" #include "exceptions.hpp" #include "logger.hpp" #include "manager.hpp" #include "types.hpp" #include #include #include /** * @brief Main function for VPD parser application. */ int main(int, char**) { try { auto io_con = std::make_shared(); auto connection = std::make_shared(*io_con); auto server = sdbusplus::asio::object_server(connection); std::shared_ptr interface = server.add_interface(OBJPATH, IFACE); std::shared_ptr progressInf = server.add_interface(OBJPATH, vpd::constants::vpdCollectionInterface); auto vpdManager = std::make_shared( io_con, interface, progressInf, connection); try { // TODO: Take this under conditional compilation for IBM auto biosHandler = std::make_shared>( connection, vpdManager); biosHandler->checkAndListenPldmService(); } catch (const std::exception& l_ex) { // Cathcing exception here explicitly to let VPD-Manager service // continue even when bios handler fails. const std::string& l_errMsg = "Instantiation of BIOS Handler failed. { " + std::string(l_ex.what()) + std::string(" }"); vpd::EventLogger::createSyncPel( vpd::types::ErrorType::FirmwareError, vpd::types::SeverityType::Warning, __FILE__, __FUNCTION__, 0, l_errMsg, std::nullopt, std::nullopt, std::nullopt, std::nullopt); } interface->initialize(); progressInf->initialize(); vpd::logging::logMessage("Start VPD-Manager event loop"); // Grab the bus name connection->request_name(BUSNAME); // Start event loop. io_con->run(); exit(EXIT_SUCCESS); } catch (const std::exception& l_ex) { vpd::logging::logMessage("VPD-Manager service failed to start."); vpd::EventLogger::createSyncPel( vpd::EventLogger::getErrorType(l_ex), vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0, vpd::EventLogger::getErrorMsg(l_ex), std::nullopt, std::nullopt, std::nullopt, std::nullopt); } exit(EXIT_FAILURE); }