Redfish:Support to Delete a single event log
Tested:Use redfish to delete a single event log
Before:
curl -k -H "X-Auth-Token: $bmc_token" -X DELETE https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/2 -d '{"[]"}'
Method Not Allowed
After:
curl -k -H "X-Auth-Token: $bmc_token" -X DELETE https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/2 -d '{"[]"}'
No error response,and the entry 2 is deleted.
Signed-off-by: Chicago Duan <duanzhijia01@inspur.com>
Change-Id: I31e4470d73b72012b8727d466530202e2609000d
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index cfccd61..c74bfa2 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1011,6 +1011,47 @@
"org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Logging.Entry");
}
+
+ void doDelete(crow::Response &res, const crow::Request &req,
+ const std::vector<std::string> ¶ms) override
+ {
+
+ BMCWEB_LOG_DEBUG << "Do delete single event entries.";
+
+ auto asyncResp = std::make_shared<AsyncResp>(res);
+
+ if (params.size() != 1)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ std::string entryID = params[0];
+
+ dbus::utility::escapePathForDbus(entryID);
+
+ // Process response from Logging service.
+ auto respHandler = [asyncResp](const boost::system::error_code ec) {
+ BMCWEB_LOG_DEBUG << "EventLogEntry (DBus) doDelete callback: Done";
+ if (ec)
+ {
+ // TODO Handle for specific error code
+ BMCWEB_LOG_ERROR
+ << "EventLogEntry (DBus) doDelete respHandler got error "
+ << ec;
+ asyncResp->res.result(
+ boost::beast::http::status::internal_server_error);
+ return;
+ }
+
+ asyncResp->res.result(boost::beast::http::status::ok);
+ };
+
+ // Make call to Logging service to request Delete Log
+ crow::connections::systemBus->async_method_call(
+ respHandler, "xyz.openbmc_project.Logging",
+ "/xyz/openbmc_project/logging/entry/" + entryID,
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ }
};
class BMCLogServiceCollection : public Node