Add Serialization Support for Dump Entry Attributes
Implemented serialization of dump entry attributes using the
nlohmann::json library. Added serialization support in the Dump Entry
class, serializing attributes including originatorId, originatorType,
and startTime. These attributes are not part of the dump filename and
thus require serialization to ensure their state is preserved.
Deserialization will occur only if the serialization version matches
and the dump ID in the dump object matches the ID in the
serialized file.
Tests:
- Created BMC dumps and restarted service
- Created BMC dumps and restarted BMC
- Created 200 BMC dumps and restarted service and BMC multiple times
File:
```
{"dumpId":2,"originatorId":"","originatorType":1,"startTime":1718199238942411,"version":1}
```
Change-Id: I16ecb058bddd464c8771bd8d08a50ea1877747ed
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/dump_utils.hpp b/dump_utils.hpp
index 1b86575..ce66a00 100644
--- a/dump_utils.hpp
+++ b/dump_utils.hpp
@@ -377,5 +377,17 @@
throw std::invalid_argument{"Dump type not found"};
}
+/**
+ * @brief Extracts the dump ID and timestamp from a BMC dump file name.
+ *
+ * @param[in] file The path to the dump file.
+ *
+ * @return A std::optional containing a tuple with the dump ID, timestamp
+ * and size of the file if the extraction is successful, or std::nullopt
+ * if the file name does not match the expected format.
+ */
+std::optional<std::tuple<uint32_t, uint64_t, uint64_t>>
+ extractDumpDetails(const std::filesystem::path& file);
+
} // namespace dump
} // namespace phosphor