Refactor remaining DBus EventLog route handlers
Extract lambdas into separate handler functions.
Tested: Validation for the EventLog tree with redfish-dbus-log=enabled
succeeded.
```
root@romulus:~# busctl tree xyz.openbmc_project.Logging
`- /xyz
`- /xyz/openbmc_project
`- /xyz/openbmc_project/logging
|- /xyz/openbmc_project/logging/entry
| |- /xyz/openbmc_project/logging/entry/21
| |- /xyz/openbmc_project/logging/entry/22
| |- /xyz/openbmc_project/logging/entry/23
| |- /xyz/openbmc_project/logging/entry/24
| |- /xyz/openbmc_project/logging/entry/25
| |- /xyz/openbmc_project/logging/entry/26
| |- /xyz/openbmc_project/logging/entry/27
| |- /xyz/openbmc_project/logging/entry/28
| |- /xyz/openbmc_project/logging/entry/29
| `- /xyz/openbmc_project/logging/entry/30
`- /xyz/openbmc_project/logging/internal
`- /xyz/openbmc_project/logging/internal/manager
```
Patching
```
curl -k -X PATCH
'https://'"${BMC}"':'"${BMC_WEBPORT}"'/redfish/v1/Systems/system/LogServices/EventLog/Entries/22' \
-H 'X-Auth-Token: '"$BMCWEB_SESSION_TOKEN"'' \
-H "Content-Type: application/json" -d "{"Resolved":true}"
xyz.openbmc_project.Logging.Entry interface - -
.GetEntry method - h
.AdditionalData property a{ss} 0
.EventId property s ""
.Id property u 21
.Message property s "This is mock message 1"
.Resolution property s "" emits-change writable
.Resolved property b true
```
Deleting
```
$ curl -k -X DELETE 'https://'"${BMC}"':'"${BMC_WEBPORT}"'/redfish/v1/'"$ROUTE"'' \
-H 'X-Auth-Token: '"$BMCWEB_SESSION_TOKEN"'' \
-H "Content-Type: application/json"
$ busctl tree xyz.openbmc_project.Logging
`- /xyz
`- /xyz/openbmc_project
`- /xyz/openbmc_project/logging
|- /xyz/openbmc_project/logging/entry
| |- /xyz/openbmc_project/logging/entry/21
| |- /xyz/openbmc_project/logging/entry/23
| |- /xyz/openbmc_project/logging/entry/24
| |- /xyz/openbmc_project/logging/entry/25
| |- /xyz/openbmc_project/logging/entry/26
| |- /xyz/openbmc_project/logging/entry/27
| |- /xyz/openbmc_project/logging/entry/28
| |- /xyz/openbmc_project/logging/entry/29
| `- /xyz/openbmc_project/logging/entry/30
`- /xyz/openbmc_project/logging/internal
`- /xyz/openbmc_project/logging/internal/manager
```
ClearLog action
```
$ curl -v -k POST 'https://'"${BMC}"':'"${BMC_WEBPORT}"'/redfish/v1/'"$ROUTE"'' \
-H 'X-Auth-Token: '"$BMCWEB_SESSION_TOKEN"'' \
-H "Content-Type: application/json"
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The request completed successfully.",
"MessageArgs": [],
"MessageId": "Base.1.19.Success",
"MessageSeverity": "OK",
"Resolution": "None."
}
]
$ busctl introspect xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/1
...
xyz.openbmc_project.Logging.Entry interface - -
.GetEntry method - h
.AdditionalData property a{ss} 5 "NUMBER_OF_LOGS" "9" "_CODE_FILE" "...
.EventId property s ""
.Id property u 1
.Message property s "xyz.openbmc_project.Logging.Cleared"
.Resolution property s ""
.Resolved property b false
...
```
Change-Id: I25a5484c17ed966376d85c9c3439350163d6c5ed
Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
diff --git a/redfish-core/lib/systems_logservices_dbus_eventlog.hpp b/redfish-core/lib/systems_logservices_dbus_eventlog.hpp
index c97c337..584608a 100644
--- a/redfish-core/lib/systems_logservices_dbus_eventlog.hpp
+++ b/redfish-core/lib/systems_logservices_dbus_eventlog.hpp
@@ -344,6 +344,134 @@
"xyz.openbmc_project.Logging.Entry", "GetEntry");
}
+inline void handleSystemsDBusEventLogEntryCollection(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ dBusEventLogEntryCollection(asyncResp);
+}
+
+inline void handleSystemsDBusEventLogEntryGet(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& entryId)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+
+ dBusEventLogEntryGet(asyncResp, entryId);
+}
+
+inline void handleSystemsDBusEventLogEntryPatch(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& entryId)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+
+ dBusEventLogEntryPatch(req, asyncResp, entryId);
+}
+
+inline void handleSystemsDBusEventLogEntryDelete(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& entryId)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+
+ dBusEventLogEntryDelete(asyncResp, entryId);
+}
+
+inline void handleSystemsDBusLogServiceActionsClear(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ dBusLogServiceActionsClear(asyncResp);
+}
+
inline void handleSystemsDBusEventLogEntryDownloadGet(
crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -381,29 +509,8 @@
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
- .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 constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- dBusEventLogEntryCollection(asyncResp);
- });
+ .methods(boost::beast::http::verb::get)(std::bind_front(
+ handleSystemsDBusEventLogEntryCollection, std::ref(app)));
}
inline void requestRoutesDBusEventLogEntry(App& app)
@@ -412,86 +519,21 @@
app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName, const std::string& entryId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- dBusEventLogEntryGet(asyncResp, entryId);
- });
+ std::bind_front(handleSystemsDBusEventLogEntryGet, std::ref(app)));
BMCWEB_ROUTE(
app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/")
.privileges(redfish::privileges::patchLogEntry)
- .methods(boost::beast::http::verb::patch)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName, const std::string& entryId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- dBusEventLogEntryPatch(req, asyncResp, entryId);
- });
+ .methods(boost::beast::http::verb::patch)(std::bind_front(
+ handleSystemsDBusEventLogEntryPatch, std::ref(app)));
BMCWEB_ROUTE(
app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/")
.privileges(
redfish::privileges::
deleteLogEntrySubOverComputerSystemLogServiceCollectionLogServiceLogEntryCollection)
- .methods(boost::beast::http::verb::delete_)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName, const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- dBusEventLogEntryDelete(asyncResp, param);
- });
+ .methods(boost::beast::http::verb::delete_)(std::bind_front(
+ handleSystemsDBusEventLogEntryDelete, std::ref(app)));
}
/**
@@ -510,29 +552,8 @@
"/redfish/v1/Systems/<str>/LogServices/EventLog/Actions/LogService.ClearLog/")
.privileges(redfish::privileges::
postLogServiceSubOverComputerSystemLogServiceCollection)
- .methods(boost::beast::http::verb::post)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- dBusLogServiceActionsClear(asyncResp);
- });
+ .methods(boost::beast::http::verb::post)(std::bind_front(
+ handleSystemsDBusLogServiceActionsClear, std::ref(app)));
}
inline void requestRoutesDBusEventLogEntryDownload(App& app)