Implement Notify method
This commit implements notify method for notifying the
creation of a new dump.
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: Ieb4fa29965b3a93b3dafa2251f354c44ca12db46
diff --git a/dump_manager.cpp b/dump_manager.cpp
index accd0da..a42fce2 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -4,6 +4,7 @@
#include "bmc_dump_entry.hpp"
#include "dump_internal.hpp"
+#include "system_dump_entry.hpp"
#include "xyz/openbmc_project/Common/error.hpp"
#include "xyz/openbmc_project/Dump/Create/error.hpp"
@@ -240,5 +241,21 @@
return size;
}
+void Manager::notify(NewDump::DumpType dumpType, uint32_t dumpId, uint64_t size)
+{
+ // Get the timestamp
+ auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch())
+ .count();
+ // Get the id
+ auto id = lastEntryId + 1;
+ auto idString = std::to_string(id);
+ auto objPath = fs::path(OBJ_ENTRY) / idString;
+ entries.insert(std::make_pair(
+ id, std::make_unique<system::Entry>(bus, objPath.c_str(), id, ms, size,
+ dumpId, *this)));
+ lastEntryId++;
+}
+
} // namespace dump
} // namespace phosphor
diff --git a/dump_manager.hpp b/dump_manager.hpp
index 694cf7b..4b5005d 100644
--- a/dump_manager.hpp
+++ b/dump_manager.hpp
@@ -7,6 +7,7 @@
#include "watch.hpp"
#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
#include "xyz/openbmc_project/Dump/Internal/Create/server.hpp"
+#include "xyz/openbmc_project/Dump/NewDump/server.hpp"
#include <experimental/filesystem>
#include <sdbusplus/bus.hpp>
@@ -31,7 +32,8 @@
using CreateIface = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll,
- sdbusplus::xyz::openbmc_project::Dump::server::Create>;
+ sdbusplus::xyz::openbmc_project::Dump::server::Create,
+ sdbusplus::xyz::openbmc_project::Dump::server::NewDump>;
namespace fs = std::experimental::filesystem;
@@ -96,6 +98,13 @@
*/
void restore();
+ /** @brief Notify the dump manager about creation of a new dump.
+ * @param[in] dumpType - Type of the Dump.
+ * @param[in] dumpId - Id from the source of the dump.
+ * @param[in] size - Size of the dump.
+ */
+ void notify(NewDump::DumpType dumpType, uint32_t dumpId, uint64_t size);
+
private:
/** @brief Create Dump entry d-bus object
* @param[in] fullPath - Full path of the Dump file name