blob: 05d1f10adaa5712fd9239efc5691956d7dcb4a73 [file] [log] [blame]
#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