Task: Fix missing properties in task monitor
Task monitor URI when the task is running contains partial information.
Properties like progress percent, message is missing. Same issue is
present when task is created and response is returned.
This patch fixes missing properties in task creation response and task
monitor URI.
Tested:
- Task creation with fwupdate response shows all properties
- Task monitor URI provides complete information when running
- Verified task creation and monitor response for log service
Change-Id: I77c6d9b9302d13b8480cf5a3419b8c6754e5049d
Signed-off-by: Chinmay Shripad Hegde <hosmanechinmay@gmail.com>
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 4972c7d..0e29cae 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -190,6 +190,27 @@
taskMonitor.buffer());
res.addHeader(boost::beast::http::field::retry_after,
std::to_string(retryAfterSeconds));
+ res.jsonValue["Name"] = "Task " + strIdx;
+ res.jsonValue["StartTime"] =
+ redfish::time_utils::getDateTimeStdtime(startTime);
+ res.jsonValue["Messages"] = messages;
+ res.jsonValue["TaskMonitor"] = taskMonitor;
+ res.jsonValue["HidePayload"] = !payload;
+ if (payload)
+ {
+ const task::Payload& p = *payload;
+ nlohmann::json::object_t payloadObj;
+ payloadObj["TargetUri"] = p.targetUri;
+ payloadObj["HttpOperation"] = p.httpOperation;
+ payloadObj["HttpHeaders"] = p.httpHeaders;
+ if (p.jsonBody.is_object())
+ {
+ payloadObj["JsonBody"] = p.jsonBody.dump(
+ 2, ' ', true, nlohmann::json::error_handler_t::replace);
+ }
+ res.jsonValue["Payload"] = std::move(payloadObj);
+ }
+ res.jsonValue["PercentComplete"] = percentComplete;
}
else if (!gave204)
{