diff options
author | Ed Tanous <edtanous@google.com> | 2021-09-17 01:05:36 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-12-07 02:50:55 +0300 |
commit | 98be3e394a78f8866e731019b1828419dc66561a (patch) | |
tree | a7254f7a369a2be61de9303b32491d092cfd6e39 /redfish-core/lib/log_services.hpp | |
parent | 6a3e2913e834a4b337138ac355ca1a59b3171445 (diff) | |
download | bmcweb-98be3e394a78f8866e731019b1828419dc66561a.tar.xz |
Remove copies from log services and virtual media
Both of these entries make complete copies of the Request object.
Following the pattern in the prior commit, move these to more modern
patterns.
For log service, this simply means constructing a payload object
earlier.
For virtual media, it means doing the readJson call and parameter
validation much earlier, which generally is the pattern we should strive
for, validating and unpacking the structs in the first scope, then
dealing with them as structures. To do this, this commit also creates a
secondary struct to store the param data in to make the lambdas cleaner.
Tested:
From Ashmitha
POST https://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData -d '{"DiagnosticDataType":"Manager"}'
{
"@odata.id": "/redfish/v1/TaskService/Tasks/0",
"@odata.type": "#Task.v1_4_3.Task",
"Id": "0",
"TaskState": "Running",
"TaskStatus": "OK"
}
-----------------------------------------------------------------
On task completion:
GET https://${bmc}/redfish/v1/TaskService/Tasks/0
{
"@odata.id": "/redfish/v1/TaskService/Tasks/0",
"@odata.type": "#Task.v1_4_3.Task",
"EndTime": "2021-12-03T13:40:58+00:00",
"Id": "0",
"Messages": [
{
"@odata.type": "#Message.v1_0_0.Message",
"Message": "The task with id 0 has started.",
"MessageArgs": [
"0"
],
"MessageId": "TaskEvent.1.0.1.TaskStarted",
"Resolution": "None.",
"Severity": "OK"
},
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "Successfully Completed Request",
"MessageArgs": [],
"MessageId": "Base.1.8.1.Success",
"MessageSeverity": "OK",
"Resolution": "None"
}
],
"Name": "Task 0",
"Payload": {
"HttpHeaders": [
"Host: 9.3.29.238",
"User-Agent: curl/7.71.1",
"Accept: */*",
"Content-Length: 32",
"Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/32"
],
"HttpOperation": "POST",
"JsonBody": "{\n \"DiagnosticDataType\": \"Manager\"\n}",
"TargetUri": "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
},
"PercentComplete": 0,
"StartTime": "2021-12-03T13:38:20+00:00",
"TaskMonitor": "/redfish/v1/TaskService/Tasks/0/Monitor",
"TaskState": "Completed",
"TaskStatus": "OK"
}
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I178a3a7a7b27dfd34ec50a06398ac243a9d4ab67
Diffstat (limited to 'redfish-core/lib/log_services.hpp')
-rw-r--r-- | redfish-core/lib/log_services.hpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index f71f81b66d..cdd746f4d9 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -723,7 +723,7 @@ inline void deleteDumpEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } inline void - createDumpTaskCallback(const crow::Request& req, + createDumpTaskCallback(task::Payload&& payload, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const uint32_t& dumpId, const std::string& dumpPath, const std::string& dumpType) @@ -772,7 +772,7 @@ inline void task->startTimer(std::chrono::minutes(3)); task->populateResp(asyncResp->res); - task->payload.emplace(req); + task->payload.emplace(std::move(payload)); } inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -847,8 +847,9 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } crow::connections::systemBus->async_method_call( - [asyncResp, req, dumpPath, dumpType](const boost::system::error_code ec, - const uint32_t& dumpId) { + [asyncResp, payload(task::Payload(req)), dumpPath, + dumpType](const boost::system::error_code ec, + const uint32_t& dumpId) mutable { if (ec) { BMCWEB_LOG_ERROR << "CreateDump resp_handler got error " << ec; @@ -857,7 +858,8 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } BMCWEB_LOG_DEBUG << "Dump Created. Id: " << dumpId; - createDumpTaskCallback(req, asyncResp, dumpId, dumpPath, dumpType); + createDumpTaskCallback(std::move(payload), asyncResp, dumpId, + dumpPath, dumpType); }, "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump/" + @@ -2907,10 +2909,11 @@ inline void requestRoutesCrashdumpCollect(App& app) return; } - auto collectCrashdumpCallback = [asyncResp, req]( + auto collectCrashdumpCallback = [asyncResp, + payload(task::Payload(req))]( const boost::system::error_code ec, - const std::string&) { + const std::string&) mutable { if (ec) { if (ec.value() == @@ -2948,7 +2951,7 @@ inline void requestRoutesCrashdumpCollect(App& app) "member='PropertiesChanged',arg0namespace='com.intel.crashdump'"); task->startTimer(std::chrono::minutes(5)); task->populateResp(asyncResp->res); - task->payload.emplace(req); + task->payload.emplace(std::move(payload)); }; if (oemDiagnosticDataType == "OnDemand") |