blob: 302fd43e02c37e90973e385def33c0b01dbfc7f6 [file] [log] [blame]
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06001#include "bmc_dump_entry.hpp"
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06002#include "dump_manager.hpp"
Dhruvaraj Subhashchandran580d91d2020-04-22 12:29:18 -05003#include "dump_offload.hpp"
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06004
George Liu858fbb22021-07-01 12:25:44 +08005#include <fmt/core.h>
6
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06007#include <phosphor-logging/log.hpp>
8
9namespace phosphor
10{
11namespace dump
12{
Dhruvaraj Subhashchandran860b8a32021-05-05 13:01:49 -050013namespace bmc_stored
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060014{
15using namespace phosphor::logging;
16
17void Entry::delete_()
18{
19 // Delete Dump file from Permanent location
20 try
21 {
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060022 std::filesystem::remove_all(
23 std::filesystem::path(path()).parent_path());
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060024 }
Patrick Williams9d2d7222021-10-06 12:44:44 -050025 catch (const std::filesystem::filesystem_error& e)
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060026 {
27 // Log Error message and continue
George Liu858fbb22021-07-01 12:25:44 +080028 log<level::ERR>(
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060029 fmt::format("Failed to delete dump file({}), errormsg({})", path(),
30 e.what())
George Liu858fbb22021-07-01 12:25:44 +080031 .c_str());
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060032 }
33
34 // Remove Dump entry D-bus object
35 phosphor::dump::Entry::delete_();
36}
37
Dhruvaraj Subhashchandran580d91d2020-04-22 12:29:18 -050038void Entry::initiateOffload(std::string uri)
39{
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060040 phosphor::dump::offload::requestOffload(path(), id, uri);
Dhruvaraj Subhashchandran580d91d2020-04-22 12:29:18 -050041 offloaded(true);
42}
43
Dhruvaraj Subhashchandran860b8a32021-05-05 13:01:49 -050044} // namespace bmc_stored
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060045} // namespace dump
46} // namespace phosphor