Add implementation for delete all BMC Dumps in one shot
Resolves openbmc/openbmc#2255
Change-Id: I8383c55f0f55ac02e509d17c47bc66d326994301
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
diff --git a/dump_manager.cpp b/dump_manager.cpp
index 6ac636d..28d3b77 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -154,6 +154,17 @@
entries.erase(entryId);
}
+void Manager::deleteAll()
+{
+ auto iter = entries.begin();
+ while (iter != entries.end())
+ {
+ auto& entry = iter->second;
+ entry->delete_();
+ ++iter;
+ }
+}
+
void Manager::watchCallback(const UserMap& fileInfo)
{
for (const auto& i : fileInfo)
diff --git a/dump_manager.hpp b/dump_manager.hpp
index ef3cd22..f12d7ff 100644
--- a/dump_manager.hpp
+++ b/dump_manager.hpp
@@ -7,6 +7,7 @@
#include <xyz/openbmc_project/Dump/Create/server.hpp>
#include "xyz/openbmc_project/Dump/Internal/Create/server.hpp"
+#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
#include "dump_entry.hpp"
#include "dump_utils.hpp"
#include "watch.hpp"
@@ -28,8 +29,9 @@
using Type =
sdbusplus::xyz::openbmc_project::Dump::Internal::server::Create::Type;
-using CreateIface = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Dump::server::Create>;
+using CreateIface = sdbusplus::server::object::object <
+ sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll,
+ sdbusplus::xyz::openbmc_project::Dump::server::Create >;
namespace fs = std::experimental::filesystem;
@@ -38,7 +40,8 @@
/** @class Manager
* @brief OpenBMC Dump manager implementation.
* @details A concrete implementation for the
- * xyz.openbmc_project.Dump.Create DBus API.
+ * xyz.openbmc_project.Dump.Create DBus API and
+ * xyz::openbmc_project::Collection::server::DeleteAll.
*/
class Manager : public CreateIface
{
@@ -114,6 +117,12 @@
*/
void erase(uint32_t entryId);
+ /** @brief Erase all BMC dump entries and Delete all Dump files
+ * from Permanent location
+ *
+ */
+ void deleteAll() override;
+
/** @brief sd_event_add_child callback
*
* @param[in] s - event source