-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbmc_dump_entry.cpp
More file actions
70 lines (59 loc) · 1.74 KB
/
bmc_dump_entry.cpp
File metadata and controls
70 lines (59 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "bmc_dump_entry.hpp"
#include "dump_manager.hpp"
#include "dump_offload.hpp"
#include "dump_utils.hpp"
#include <phosphor-logging/lg2.hpp>
namespace phosphor
{
namespace dump
{
namespace bmc
{
void Entry::delete_()
{
// Delete Dump file from Permanent location
try
{
std::filesystem::remove_all(file.parent_path());
}
catch (const std::filesystem::filesystem_error& e)
{
// Log Error message and continue
lg2::error("Failed to delete dump file, errormsg: {ERROR}", "ERROR", e);
}
// Remove Dump entry D-bus object
phosphor::dump::Entry::delete_();
}
void Entry::initiateOffload(std::string uri)
{
phosphor::dump::offload::requestOffload(file, id, uri);
offloaded(true);
}
void Entry::updateFromFile(const std::filesystem::path& dumpPath)
{
// Extract dump details from the file name
auto dumpDetails = phosphor::dump::extractDumpDetails(dumpPath);
if (!dumpDetails)
{
lg2::error("Failed to extract dump details from file name: {PATH}",
"PATH", dumpPath);
throw std::logic_error("Invalid dump file name format");
}
auto [extractedId, extractedTimestamp, extractedSize] = *dumpDetails;
if (id != extractedId)
{
lg2::error("Id({ID}) is not matching with id on filename"
"({ID_FILENAME})",
"ID", id, "ID_FILENAME", extractedId);
throw std::logic_error("Invalid dump id in filename");
}
// Update the entry with extracted details
startTime(extractedTimestamp);
elapsed(extractedTimestamp);
completedTime(extractedTimestamp);
size(extractedSize);
status(OperationStatus::Completed);
}
} // namespace bmc
} // namespace dump
} // namespace phosphor