1*919f71c6SClaire Weinan #pragma once 2*919f71c6SClaire Weinan 3*919f71c6SClaire Weinan #include "dump_manager.hpp" 4*919f71c6SClaire Weinan 5*919f71c6SClaire Weinan #include <fmt/core.h> 6*919f71c6SClaire Weinan 7*919f71c6SClaire Weinan #include <phosphor-logging/elog-errors.hpp> 8*919f71c6SClaire Weinan #include <phosphor-logging/elog.hpp> 9*919f71c6SClaire Weinan #include <sdbusplus/bus.hpp> 10*919f71c6SClaire Weinan #include <sdbusplus/server/object.hpp> 11*919f71c6SClaire Weinan #include <xyz/openbmc_project/Dump/Create/server.hpp> 12*919f71c6SClaire Weinan 13*919f71c6SClaire Weinan namespace phosphor 14*919f71c6SClaire Weinan { 15*919f71c6SClaire Weinan namespace dump 16*919f71c6SClaire Weinan { 17*919f71c6SClaire Weinan namespace faultlog 18*919f71c6SClaire Weinan { 19*919f71c6SClaire Weinan 20*919f71c6SClaire Weinan using namespace phosphor::logging; 21*919f71c6SClaire Weinan 22*919f71c6SClaire Weinan using CreateIface = sdbusplus::server::object::object< 23*919f71c6SClaire Weinan sdbusplus::xyz::openbmc_project::Dump::server::Create>; 24*919f71c6SClaire Weinan 25*919f71c6SClaire Weinan /** @class Manager 26*919f71c6SClaire Weinan * @brief FaultLog Dump manager implementation. 27*919f71c6SClaire Weinan */ 28*919f71c6SClaire Weinan class Manager : 29*919f71c6SClaire Weinan virtual public CreateIface, 30*919f71c6SClaire Weinan virtual public phosphor::dump::Manager 31*919f71c6SClaire Weinan { 32*919f71c6SClaire Weinan public: 33*919f71c6SClaire Weinan Manager() = delete; 34*919f71c6SClaire Weinan Manager(const Manager&) = default; 35*919f71c6SClaire Weinan Manager& operator=(const Manager&) = delete; 36*919f71c6SClaire Weinan Manager(Manager&&) = delete; 37*919f71c6SClaire Weinan Manager& operator=(Manager&&) = delete; 38*919f71c6SClaire Weinan virtual ~Manager() = default; 39*919f71c6SClaire Weinan 40*919f71c6SClaire Weinan /** @brief Constructor to put object onto bus at a dbus path. 41*919f71c6SClaire Weinan * @param[in] bus - Bus to attach to. 42*919f71c6SClaire Weinan * @param[in] path - Path to attach at. 43*919f71c6SClaire Weinan * @param[in] baseEntryPath - Base path for dump entry. 44*919f71c6SClaire Weinan * @param[in] filePath - Path where the dumps are stored. 45*919f71c6SClaire Weinan */ 46*919f71c6SClaire Weinan Manager(sdbusplus::bus::bus& bus, const char* path, 47*919f71c6SClaire Weinan const std::string& baseEntryPath, const char* filePath) : 48*919f71c6SClaire Weinan CreateIface(bus, path), 49*919f71c6SClaire Weinan phosphor::dump::Manager(bus, path, baseEntryPath), dumpDir(filePath) 50*919f71c6SClaire Weinan { 51*919f71c6SClaire Weinan std::error_code ec; 52*919f71c6SClaire Weinan 53*919f71c6SClaire Weinan std::filesystem::create_directory(FAULTLOG_DUMP_PATH, ec); 54*919f71c6SClaire Weinan 55*919f71c6SClaire Weinan if (ec) 56*919f71c6SClaire Weinan { 57*919f71c6SClaire Weinan log<level::ERR>(fmt::format("dump_manager_faultlog directory {} " 58*919f71c6SClaire Weinan "not created. error_code = {} ({})", 59*919f71c6SClaire Weinan FAULTLOG_DUMP_PATH, ec.value(), 60*919f71c6SClaire Weinan ec.message()) 61*919f71c6SClaire Weinan .c_str()); 62*919f71c6SClaire Weinan } 63*919f71c6SClaire Weinan } 64*919f71c6SClaire Weinan 65*919f71c6SClaire Weinan void restore() override 66*919f71c6SClaire Weinan { 67*919f71c6SClaire Weinan // TODO phosphor-debug-collector/issues/21: Restore fault log entries 68*919f71c6SClaire Weinan // after service restart 69*919f71c6SClaire Weinan log<level::INFO>("dump_manager_faultlog restore not implemented"); 70*919f71c6SClaire Weinan } 71*919f71c6SClaire Weinan 72*919f71c6SClaire Weinan /** @brief Method to create a new fault log dump entry 73*919f71c6SClaire Weinan * @param[in] params - Key-value pair input parameters 74*919f71c6SClaire Weinan * 75*919f71c6SClaire Weinan * @return object_path - The path to the new dump entry. 76*919f71c6SClaire Weinan */ 77*919f71c6SClaire Weinan sdbusplus::message::object_path 78*919f71c6SClaire Weinan createDump(phosphor::dump::DumpCreateParams params) override; 79*919f71c6SClaire Weinan 80*919f71c6SClaire Weinan private: 81*919f71c6SClaire Weinan /** @brief Path to the dump file*/ 82*919f71c6SClaire Weinan std::string dumpDir; 83*919f71c6SClaire Weinan }; 84*919f71c6SClaire Weinan 85*919f71c6SClaire Weinan } // namespace faultlog 86*919f71c6SClaire Weinan } // namespace dump 87*919f71c6SClaire Weinan } // namespace phosphor 88