Implement PercentComplete for code update
In order to implement full task support for code update,
the PercentComplete property is added to the task service.
Testd: Validator passes.
curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/TaskService/Tasks/0
{
"@odata.id": "/redfish/v1/TaskService/Tasks/0",
"@odata.type": "#Task.v1_4_3.Task",
... ...
"PercentComplete": 100,
"TaskMonitor": "/redfish/v1/TaskService/Tasks/0/Monitor",
"TaskState": "Completed",
"TaskStatus": "OK"
}
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I030bf0bbff098dec2f45158642f149711554285d
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 19973d9..b6ca010 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -309,6 +309,7 @@
std::optional<time_t> endTime;
std::optional<Payload> payload;
bool gave204 = false;
+ int percentComplete = 0;
};
} // namespace task
@@ -447,6 +448,7 @@
{"HttpHeaders", p.httpHeaders},
{"JsonBody", p.jsonBody.dump()}};
}
+ asyncResp->res.jsonValue["PercentComplete"] = ptr->percentComplete;
}
};
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 87933fa..9e382ce 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -215,6 +215,8 @@
messages::internalError());
return task::completed;
}
+ taskData->percentComplete =
+ static_cast<int>(*progress);
taskData->messages.emplace_back(
messages::taskProgressChanged(
index, static_cast<size_t>(