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