blob: 66087130ef7405cb4e635dff8e83991e9d66964a [file] [log] [blame]
Claire Weinan919f71c2022-03-01 19:02:07 -08001#pragma once
2
3#include "dump_manager.hpp"
4
Claire Weinan919f71c2022-03-01 19:02:07 -08005#include <phosphor-logging/elog-errors.hpp>
6#include <phosphor-logging/elog.hpp>
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -05007#include <phosphor-logging/lg2.hpp>
Claire Weinan919f71c2022-03-01 19:02:07 -08008#include <sdbusplus/bus.hpp>
9#include <sdbusplus/server/object.hpp>
10#include <xyz/openbmc_project/Dump/Create/server.hpp>
11
12namespace phosphor
13{
14namespace dump
15{
16namespace faultlog
17{
18
Patrick Williams9b18bf22022-07-22 19:26:55 -050019using CreateIface = sdbusplus::server::object_t<
Claire Weinan919f71c2022-03-01 19:02:07 -080020 sdbusplus::xyz::openbmc_project::Dump::server::Create>;
21
22/** @class Manager
23 * @brief FaultLog Dump manager implementation.
24 */
25class 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 Williams9b18bf22022-07-22 19:26:55 -050043 Manager(sdbusplus::bus_t& bus, const char* path,
Claire Weinan919f71c2022-03-01 19:02:07 -080044 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 Subhashchandrand1f670f2023-06-05 22:19:25 -050054 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 Weinan919f71c2022-03-01 19:02:07 -080060 }
61 }
62
63 void restore() override
64 {
65 // TODO phosphor-debug-collector/issues/21: Restore fault log entries
66 // after service restart
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050067 lg2::info("dump_manager_faultlog restore not implemented");
Claire Weinan919f71c2022-03-01 19:02:07 -080068 }
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