Dynamic EventLogService handler
In order to reuse the handler for the EventLogService under Managers,
extract the logic from the handler and put it into a separate function
in the eventlog util. Add an additional argument that specifies
the redfish resource, so we can handle Systems and Managers resource
with the same handler.
Tested: Code compiles. Redfish validation succeeds.
Additionally the curl output with and without the changes has been
diffed. No differences observed.
Change-Id: I48825b55b41afeafa02283dc91cf4cb1cd4cd7c3
Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 015360c..982f74e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -24,6 +24,7 @@
#include "task_messages.hpp"
#include "utils/dbus_utils.hpp"
#include "utils/etag_utils.hpp"
+#include "utils/eventlog_utils.hpp"
#include "utils/json_utils.hpp"
#include "utils/log_services_utils.hpp"
#include "utils/time_utils.hpp"
@@ -1010,56 +1011,27 @@
});
}
-inline void requestRoutesEventLogService(App& app)
+inline void requestRoutesSystemsEventLogService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/")
.privileges(redfish::privileges::getLogService)
- .methods(
- boost::beast::http::verb::
- get)([&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/EventLog",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_2_0.LogService";
- asyncResp->res.jsonValue["Name"] = "Event Log Service";
- asyncResp->res.jsonValue["Description"] =
- "System Event Log Service";
- asyncResp->res.jsonValue["Id"] = "EventLog";
- asyncResp->res.jsonValue["OverWritePolicy"] =
- log_service::OverWritePolicy::WrapsWhenFull;
-
- std::pair<std::string, std::string> redfishDateTimeOffset =
- redfish::time_utils::getDateTimeOffsetNow();
-
- asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
-
- asyncResp->res.jsonValue["Entries"]["@odata.id"] = std::format(
- "/redfish/v1/Systems/{}/LogServices/EventLog/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res
- .jsonValue["Actions"]["#LogService.ClearLog"]["target"]
-
- = std::format(
- "/redfish/v1/Systems/{}/LogServices/EventLog/Actions/LogService.ClearLog",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
-
- etag_utils::setEtagOmitDateTimeHandler(asyncResp);
- });
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ eventlog_utils::handleSystemsAndManagersEventLogServiceGet(
+ asyncResp, eventlog_utils::LogServiceParent::Systems);
+ });
}
inline void handleBMCLogServicesCollectionGet(