Fix Task Monitor URI
Fixes #272
The TaskMonitor urls we create aren't correct per Redfish. Per DSP0266
section 12.2, our TaskMonitor URIs should take the form
/redfish/v1/TaskService/TaskMonitors/<id>
Note that even though this appears to be a collection, it is not, and
does not "exist" in the Redfish schema, hence why it is called out
explicitly.
Tested:
Started dump collection task with
POST
```
/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
```
GET /redfish/v1/Tasks/0
Returned TaskMonitor = /redfish/v1/Tasks/TaskMonitors/0
GET /redfish/v1/Tasks/TaskMonitors/0 returned 200
Change-Id: I9fb1d62090f7787d7649c077b748b51ac3202f8a
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 8d81a29..ec92aca 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -144,7 +144,8 @@
{
res.result(boost::beast::http::status::accepted);
std::string strIdx = std::to_string(index);
- std::string uri = "/redfish/v1/TaskService/Tasks/" + strIdx;
+ boost::urls::url uri =
+ boost::urls::format("/redfish/v1/TaskService/Tasks/{}", strIdx);
res.jsonValue["@odata.id"] = uri;
res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
@@ -152,8 +153,11 @@
res.jsonValue["TaskState"] = state;
res.jsonValue["TaskStatus"] = status;
+ boost::urls::url taskMonitor = boost::urls::format(
+ "/redfish/v1/TaskService/TaskMonitors/{}", strIdx);
+
res.addHeader(boost::beast::http::field::location,
- uri + "/Monitor");
+ taskMonitor.buffer());
res.addHeader(boost::beast::http::field::retry_after,
std::to_string(retryAfterSeconds));
}
@@ -313,7 +317,7 @@
inline void requestRoutesTaskMonitor(App& app)
{
- BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/<str>/Monitor/")
+ BMCWEB_ROUTE(app, "/redfish/v1/TaskService/TaskMonitors/<str>/")
.privileges(redfish::privileges::getTask)
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
@@ -402,8 +406,8 @@
boost::urls::format("/redfish/v1/TaskService/Tasks/{}", strParam);
if (!ptr->gave204)
{
- asyncResp->res.jsonValue["TaskMonitor"] =
- "/redfish/v1/TaskService/Tasks/" + strParam + "/Monitor";
+ asyncResp->res.jsonValue["TaskMonitor"] = boost::urls::format(
+ "/redfish/v1/TaskService/TaskMonitors/{}", strParam);
}
asyncResp->res.jsonValue["HidePayload"] = !ptr->payload;