1919f71c6SClaire Weinan #pragma once 2919f71c6SClaire Weinan 3919f71c6SClaire Weinan #include "dump_manager.hpp" 4919f71c6SClaire Weinan 5919f71c6SClaire Weinan #include <phosphor-logging/elog-errors.hpp> 6919f71c6SClaire Weinan #include <phosphor-logging/elog.hpp> 7d1f670feSDhruvaraj Subhashchandran #include <phosphor-logging/lg2.hpp> 8919f71c6SClaire Weinan #include <sdbusplus/bus.hpp> 9919f71c6SClaire Weinan #include <sdbusplus/server/object.hpp> 10919f71c6SClaire Weinan #include <xyz/openbmc_project/Dump/Create/server.hpp> 11919f71c6SClaire Weinan 12919f71c6SClaire Weinan namespace phosphor 13919f71c6SClaire Weinan { 14919f71c6SClaire Weinan namespace dump 15919f71c6SClaire Weinan { 16919f71c6SClaire Weinan namespace faultlog 17919f71c6SClaire Weinan { 18919f71c6SClaire Weinan 199b18bf2dSPatrick Williams using CreateIface = sdbusplus::server::object_t< 20919f71c6SClaire Weinan sdbusplus::xyz::openbmc_project::Dump::server::Create>; 21919f71c6SClaire Weinan 22919f71c6SClaire Weinan /** @class Manager 23919f71c6SClaire Weinan * @brief FaultLog Dump manager implementation. 24919f71c6SClaire Weinan */ 25919f71c6SClaire Weinan class Manager : 26919f71c6SClaire Weinan virtual public CreateIface, 27919f71c6SClaire Weinan virtual public phosphor::dump::Manager 28919f71c6SClaire Weinan { 29919f71c6SClaire Weinan public: 30919f71c6SClaire Weinan Manager() = delete; 31*4f68fc46SJayanth Othayoth Manager(const Manager&) = delete; 32919f71c6SClaire Weinan Manager& operator=(const Manager&) = delete; 33919f71c6SClaire Weinan Manager(Manager&&) = delete; 34919f71c6SClaire Weinan Manager& operator=(Manager&&) = delete; 35919f71c6SClaire Weinan virtual ~Manager() = default; 36919f71c6SClaire Weinan 37919f71c6SClaire Weinan /** @brief Constructor to put object onto bus at a dbus path. 38919f71c6SClaire Weinan * @param[in] bus - Bus to attach to. 39919f71c6SClaire Weinan * @param[in] path - Path to attach at. 40919f71c6SClaire Weinan * @param[in] baseEntryPath - Base path for dump entry. 41919f71c6SClaire Weinan * @param[in] filePath - Path where the dumps are stored. 42919f71c6SClaire Weinan */ Manager(sdbusplus::bus_t & bus,const char * path,const std::string & baseEntryPath,const char * filePath)439b18bf2dSPatrick Williams Manager(sdbusplus::bus_t& bus, const char* path, 44919f71c6SClaire Weinan const std::string& baseEntryPath, const char* filePath) : 45919f71c6SClaire Weinan CreateIface(bus, path), 46919f71c6SClaire Weinan phosphor::dump::Manager(bus, path, baseEntryPath), dumpDir(filePath) 47919f71c6SClaire Weinan { 48919f71c6SClaire Weinan std::error_code ec; 49919f71c6SClaire Weinan 50919f71c6SClaire Weinan std::filesystem::create_directory(FAULTLOG_DUMP_PATH, ec); 51919f71c6SClaire Weinan 52919f71c6SClaire Weinan if (ec) 53919f71c6SClaire Weinan { 54d1f670feSDhruvaraj Subhashchandran auto dir = FAULTLOG_DUMP_PATH; 55d1f670feSDhruvaraj Subhashchandran lg2::error( 56d1f670feSDhruvaraj Subhashchandran "dump_manager_faultlog directory {DIRECTORY} not created. " 57d1f670feSDhruvaraj Subhashchandran "error_code = {ERRNO} ({ERROR_MESSAGE})", 58d1f670feSDhruvaraj Subhashchandran "DIRECTORY", dir, "ERRNO", ec.value(), "ERROR_MESSAGE", 59d1f670feSDhruvaraj Subhashchandran ec.message()); 60919f71c6SClaire Weinan } 61919f71c6SClaire Weinan } 62919f71c6SClaire Weinan restore()63919f71c6SClaire Weinan void restore() override 64919f71c6SClaire Weinan { 65919f71c6SClaire Weinan // TODO phosphor-debug-collector/issues/21: Restore fault log entries 66919f71c6SClaire Weinan // after service restart 67d1f670feSDhruvaraj Subhashchandran lg2::info("dump_manager_faultlog restore not implemented"); 68919f71c6SClaire Weinan } 69919f71c6SClaire Weinan 70919f71c6SClaire Weinan /** @brief Method to create a new fault log dump entry 71919f71c6SClaire Weinan * @param[in] params - Key-value pair input parameters 72919f71c6SClaire Weinan * 73919f71c6SClaire Weinan * @return object_path - The path to the new dump entry. 74919f71c6SClaire Weinan */ 75919f71c6SClaire Weinan sdbusplus::message::object_path 76919f71c6SClaire Weinan createDump(phosphor::dump::DumpCreateParams params) override; 77919f71c6SClaire Weinan 78919f71c6SClaire Weinan private: 79919f71c6SClaire Weinan /** @brief Path to the dump file*/ 80919f71c6SClaire Weinan std::string dumpDir; 81919f71c6SClaire Weinan }; 82919f71c6SClaire Weinan 83919f71c6SClaire Weinan } // namespace faultlog 84919f71c6SClaire Weinan } // namespace dump 85919f71c6SClaire Weinan } // namespace phosphor 86