blob: be48a5b05e3a91ea2a5b3af8bf4babaf16980403 [file] [log] [blame]
James Feist46229572020-02-19 15:11:58 -08001/*
2// Copyright (c) 2020 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#pragma once
17
John Edward Broadbent7e860f12021-04-08 15:57:16 -070018#include <app.hpp>
Ed Tanousd43cd0c2020-09-30 20:46:53 -070019#include <boost/asio/post.hpp>
20#include <boost/asio/steady_timer.hpp>
Ed Tanousb9d36b42022-02-26 21:42:46 -080021#include <dbus_utility.hpp>
Ed Tanous45ca1b82022-03-25 13:07:27 -070022#include <query.hpp>
Ed Tanoused398212021-06-09 17:05:54 -070023#include <registries/privilege_registry.hpp>
James Feiste5d50062020-05-11 17:29:00 -070024#include <task_messages.hpp>
Gunnar Mills1214b7e2020-06-04 10:11:30 -050025
26#include <chrono>
James Feist46229572020-02-19 15:11:58 -080027#include <variant>
28
29namespace redfish
30{
31
32namespace task
33{
34constexpr size_t maxTaskCount = 100; // arbitrary limit
35
36static std::deque<std::shared_ptr<struct TaskData>> tasks;
37
James Feist32898ce2020-03-10 16:16:52 -070038constexpr bool completed = true;
39
James Feistfe306722020-03-12 16:32:08 -070040struct Payload
41{
Ed Tanous4e23a442022-06-06 09:57:26 -070042 explicit Payload(const crow::Request& req) :
James Feistfe306722020-03-12 16:32:08 -070043 targetUri(req.url), httpOperation(req.methodString()),
44 httpHeaders(nlohmann::json::array())
45
46 {
47 using field_ns = boost::beast::http::field;
48 constexpr const std::array<boost::beast::http::field, 7>
49 headerWhitelist = {field_ns::accept, field_ns::accept_encoding,
50 field_ns::user_agent, field_ns::host,
51 field_ns::connection, field_ns::content_length,
52 field_ns::upgrade};
53
54 jsonBody = nlohmann::json::parse(req.body, nullptr, false);
55 if (jsonBody.is_discarded())
56 {
57 jsonBody = nullptr;
58 }
59
Gunnar Mills1214b7e2020-06-04 10:11:30 -050060 for (const auto& field : req.fields)
James Feistfe306722020-03-12 16:32:08 -070061 {
62 if (std::find(headerWhitelist.begin(), headerWhitelist.end(),
63 field.name()) == headerWhitelist.end())
64 {
65 continue;
66 }
67 std::string header;
68 header.reserve(field.name_string().size() + 2 +
69 field.value().size());
70 header += field.name_string();
71 header += ": ";
72 header += field.value();
73 httpHeaders.emplace_back(std::move(header));
74 }
75 }
76 Payload() = delete;
77
78 std::string targetUri;
79 std::string httpOperation;
80 nlohmann::json httpHeaders;
81 nlohmann::json jsonBody;
82};
83
James Feist46229572020-02-19 15:11:58 -080084struct TaskData : std::enable_shared_from_this<TaskData>
85{
86 private:
Patrick Williams59d494e2022-07-22 19:26:55 -050087 TaskData(
88 std::function<bool(boost::system::error_code, sdbusplus::message_t&,
89 const std::shared_ptr<TaskData>&)>&& handler,
90 const std::string& matchIn, size_t idx) :
James Feist46229572020-02-19 15:11:58 -080091 callback(std::move(handler)),
Ed Tanous23a21a12020-07-25 04:45:05 +000092 matchStr(matchIn), index(idx),
James Feist46229572020-02-19 15:11:58 -080093 startTime(std::chrono::system_clock::to_time_t(
94 std::chrono::system_clock::now())),
95 status("OK"), state("Running"), messages(nlohmann::json::array()),
96 timer(crow::connections::systemBus->get_io_context())
97
Gunnar Mills1214b7e2020-06-04 10:11:30 -050098 {}
James Feist46229572020-02-19 15:11:58 -080099
100 public:
Ed Tanousd609fd62020-09-28 19:08:03 -0700101 TaskData() = delete;
102
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500103 static std::shared_ptr<TaskData>& createTask(
Patrick Williams59d494e2022-07-22 19:26:55 -0500104 std::function<bool(boost::system::error_code, sdbusplus::message_t&,
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500105 const std::shared_ptr<TaskData>&)>&& handler,
106 const std::string& match)
James Feist46229572020-02-19 15:11:58 -0800107 {
108 static size_t lastTask = 0;
109 struct MakeSharedHelper : public TaskData
110 {
111 MakeSharedHelper(
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500112 std::function<bool(boost::system::error_code,
Patrick Williams59d494e2022-07-22 19:26:55 -0500113 sdbusplus::message_t&,
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500114 const std::shared_ptr<TaskData>&)>&& handler,
Ed Tanous23a21a12020-07-25 04:45:05 +0000115 const std::string& match2, size_t idx) :
116 TaskData(std::move(handler), match2, idx)
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500117 {}
James Feist46229572020-02-19 15:11:58 -0800118 };
119
120 if (tasks.size() >= maxTaskCount)
121 {
Ed Tanous02cad962022-06-30 16:50:15 -0700122 const auto& last = tasks.front();
James Feist46229572020-02-19 15:11:58 -0800123
124 // destroy all references
125 last->timer.cancel();
126 last->match.reset();
127 tasks.pop_front();
128 }
129
130 return tasks.emplace_back(std::make_shared<MakeSharedHelper>(
131 std::move(handler), match, lastTask++));
132 }
133
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500134 void populateResp(crow::Response& res, size_t retryAfterSeconds = 30)
James Feist46229572020-02-19 15:11:58 -0800135 {
136 if (!endTime)
137 {
138 res.result(boost::beast::http::status::accepted);
139 std::string strIdx = std::to_string(index);
140 std::string uri = "/redfish/v1/TaskService/Tasks/" + strIdx;
Ed Tanous14766872022-03-15 10:44:42 -0700141
142 res.jsonValue["@odata.id"] = uri;
143 res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
144 res.jsonValue["Id"] = strIdx;
145 res.jsonValue["TaskState"] = state;
146 res.jsonValue["TaskStatus"] = status;
147
James Feist46229572020-02-19 15:11:58 -0800148 res.addHeader(boost::beast::http::field::location,
149 uri + "/Monitor");
150 res.addHeader(boost::beast::http::field::retry_after,
151 std::to_string(retryAfterSeconds));
152 }
153 else if (!gave204)
154 {
155 res.result(boost::beast::http::status::no_content);
156 gave204 = true;
157 }
158 }
159
Ed Tanousd609fd62020-09-28 19:08:03 -0700160 void finishTask()
James Feist46229572020-02-19 15:11:58 -0800161 {
162 endTime = std::chrono::system_clock::to_time_t(
163 std::chrono::system_clock::now());
164 }
165
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500166 void extendTimer(const std::chrono::seconds& timeout)
James Feist46229572020-02-19 15:11:58 -0800167 {
James Feist46229572020-02-19 15:11:58 -0800168 timer.expires_after(timeout);
169 timer.async_wait(
170 [self = shared_from_this()](boost::system::error_code ec) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700171 if (ec == boost::asio::error::operation_aborted)
172 {
173 return; // completed successfully
174 }
175 if (!ec)
176 {
177 // change ec to error as timer expired
178 ec = boost::asio::error::operation_aborted;
179 }
180 self->match.reset();
Patrick Williams59d494e2022-07-22 19:26:55 -0500181 sdbusplus::message_t msg;
Ed Tanous002d39b2022-05-31 08:59:27 -0700182 self->finishTask();
183 self->state = "Cancelled";
184 self->status = "Warning";
185 self->messages.emplace_back(
186 messages::taskAborted(std::to_string(self->index)));
187 // Send event :TaskAborted
188 self->sendTaskEvent(self->state, self->index);
189 self->callback(ec, msg, self);
190 });
James Feistfd9ab9e2020-05-19 13:48:07 -0700191 }
192
Ed Tanous56d23962022-02-14 20:42:02 -0800193 static void sendTaskEvent(const std::string_view state, size_t index)
Sunitha Harishe7686572020-07-15 02:32:44 -0500194 {
195 std::string origin =
196 "/redfish/v1/TaskService/Tasks/" + std::to_string(index);
197 std::string resType = "Task";
198 // TaskState enums which should send out an event are:
199 // "Starting" = taskResumed
200 // "Running" = taskStarted
201 // "Suspended" = taskPaused
202 // "Interrupted" = taskPaused
203 // "Pending" = taskPaused
204 // "Stopping" = taskAborted
205 // "Completed" = taskCompletedOK
206 // "Killed" = taskRemoved
207 // "Exception" = taskCompletedWarning
208 // "Cancelled" = taskCancelled
209 if (state == "Starting")
210 {
211 redfish::EventServiceManager::getInstance().sendEvent(
212 redfish::messages::taskResumed(std::to_string(index)), origin,
213 resType);
214 }
215 else if (state == "Running")
216 {
217 redfish::EventServiceManager::getInstance().sendEvent(
218 redfish::messages::taskStarted(std::to_string(index)), origin,
219 resType);
220 }
221 else if ((state == "Suspended") || (state == "Interrupted") ||
222 (state == "Pending"))
223 {
224 redfish::EventServiceManager::getInstance().sendEvent(
225 redfish::messages::taskPaused(std::to_string(index)), origin,
226 resType);
227 }
228 else if (state == "Stopping")
229 {
230 redfish::EventServiceManager::getInstance().sendEvent(
231 redfish::messages::taskAborted(std::to_string(index)), origin,
232 resType);
233 }
234 else if (state == "Completed")
235 {
236 redfish::EventServiceManager::getInstance().sendEvent(
237 redfish::messages::taskCompletedOK(std::to_string(index)),
238 origin, resType);
239 }
240 else if (state == "Killed")
241 {
242 redfish::EventServiceManager::getInstance().sendEvent(
243 redfish::messages::taskRemoved(std::to_string(index)), origin,
244 resType);
245 }
246 else if (state == "Exception")
247 {
248 redfish::EventServiceManager::getInstance().sendEvent(
249 redfish::messages::taskCompletedWarning(std::to_string(index)),
250 origin, resType);
251 }
252 else if (state == "Cancelled")
253 {
254 redfish::EventServiceManager::getInstance().sendEvent(
255 redfish::messages::taskCancelled(std::to_string(index)), origin,
256 resType);
257 }
258 else
259 {
260 BMCWEB_LOG_INFO << "sendTaskEvent: No events to send";
261 }
262 }
263
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500264 void startTimer(const std::chrono::seconds& timeout)
James Feistfd9ab9e2020-05-19 13:48:07 -0700265 {
266 if (match)
267 {
268 return;
269 }
Patrick Williams59d494e2022-07-22 19:26:55 -0500270 match = std::make_unique<sdbusplus::bus::match_t>(
271 static_cast<sdbusplus::bus_t&>(*crow::connections::systemBus),
James Feistfd9ab9e2020-05-19 13:48:07 -0700272 matchStr,
Patrick Williams59d494e2022-07-22 19:26:55 -0500273 [self = shared_from_this()](sdbusplus::message_t& message) {
Ed Tanous002d39b2022-05-31 08:59:27 -0700274 boost::system::error_code ec;
James Feistfd9ab9e2020-05-19 13:48:07 -0700275
Ed Tanous002d39b2022-05-31 08:59:27 -0700276 // callback to return True if callback is done, callback needs
277 // to update status itself if needed
278 if (self->callback(ec, message, self) == task::completed)
279 {
280 self->timer.cancel();
281 self->finishTask();
James Feistfd9ab9e2020-05-19 13:48:07 -0700282
Ed Tanous002d39b2022-05-31 08:59:27 -0700283 // Send event
284 self->sendTaskEvent(self->state, self->index);
Sunitha Harishe7686572020-07-15 02:32:44 -0500285
Ed Tanous002d39b2022-05-31 08:59:27 -0700286 // reset the match after the callback was successful
287 boost::asio::post(
288 crow::connections::systemBus->get_io_context(),
289 [self] { self->match.reset(); });
290 return;
291 }
James Feistfd9ab9e2020-05-19 13:48:07 -0700292 });
293
294 extendTimer(timeout);
James Feiste5d50062020-05-11 17:29:00 -0700295 messages.emplace_back(messages::taskStarted(std::to_string(index)));
Sunitha Harishe7686572020-07-15 02:32:44 -0500296 // Send event : TaskStarted
297 sendTaskEvent(state, index);
James Feist46229572020-02-19 15:11:58 -0800298 }
299
Patrick Williams59d494e2022-07-22 19:26:55 -0500300 std::function<bool(boost::system::error_code, sdbusplus::message_t&,
Gunnar Mills1214b7e2020-06-04 10:11:30 -0500301 const std::shared_ptr<TaskData>&)>
James Feist46229572020-02-19 15:11:58 -0800302 callback;
303 std::string matchStr;
304 size_t index;
305 time_t startTime;
306 std::string status;
307 std::string state;
308 nlohmann::json messages;
309 boost::asio::steady_timer timer;
Patrick Williams59d494e2022-07-22 19:26:55 -0500310 std::unique_ptr<sdbusplus::bus::match_t> match;
James Feist46229572020-02-19 15:11:58 -0800311 std::optional<time_t> endTime;
James Feistfe306722020-03-12 16:32:08 -0700312 std::optional<Payload> payload;
James Feist46229572020-02-19 15:11:58 -0800313 bool gave204 = false;
George Liu6868ff52021-01-02 11:37:41 +0800314 int percentComplete = 0;
James Feist46229572020-02-19 15:11:58 -0800315};
316
317} // namespace task
318
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700319inline void requestRoutesTaskMonitor(App& app)
James Feist46229572020-02-19 15:11:58 -0800320{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700321 BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/<str>/Monitor/")
Ed Tanoused398212021-06-09 17:05:54 -0700322 .privileges(redfish::privileges::getTask)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700323 .methods(boost::beast::http::verb::get)(
Ed Tanous45ca1b82022-03-25 13:07:27 -0700324 [&app](const crow::Request& req,
325 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
326 const std::string& strParam) {
Carson Labrado3ba00072022-06-06 19:40:56 +0000327 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Ed Tanous002d39b2022-05-31 08:59:27 -0700328 {
329 return;
330 }
331 auto find = std::find_if(
332 task::tasks.begin(), task::tasks.end(),
333 [&strParam](const std::shared_ptr<task::TaskData>& task) {
334 if (!task)
335 {
336 return false;
337 }
James Feist46229572020-02-19 15:11:58 -0800338
Ed Tanous002d39b2022-05-31 08:59:27 -0700339 // we compare against the string version as on failure
340 // strtoul returns 0
341 return std::to_string(task->index) == strParam;
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700342 });
Ed Tanous002d39b2022-05-31 08:59:27 -0700343
344 if (find == task::tasks.end())
345 {
346 messages::resourceNotFound(asyncResp->res, "Monitor", strParam);
347 return;
348 }
349 std::shared_ptr<task::TaskData>& ptr = *find;
350 // monitor expires after 204
351 if (ptr->gave204)
352 {
353 messages::resourceNotFound(asyncResp->res, "Monitor", strParam);
354 return;
355 }
356 ptr->populateResp(asyncResp->res);
357 });
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700358}
359
360inline void requestRoutesTask(App& app)
361{
362 BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/<str>/")
Ed Tanoused398212021-06-09 17:05:54 -0700363 .privileges(redfish::privileges::getTask)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700364 .methods(boost::beast::http::verb::get)(
Ed Tanous45ca1b82022-03-25 13:07:27 -0700365 [&app](const crow::Request& req,
366 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
367 const std::string& strParam) {
Carson Labrado3ba00072022-06-06 19:40:56 +0000368 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Ed Tanous002d39b2022-05-31 08:59:27 -0700369 {
370 return;
371 }
372 auto find = std::find_if(
373 task::tasks.begin(), task::tasks.end(),
374 [&strParam](const std::shared_ptr<task::TaskData>& task) {
375 if (!task)
376 {
377 return false;
378 }
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700379
Ed Tanous002d39b2022-05-31 08:59:27 -0700380 // we compare against the string version as on failure
381 // strtoul returns 0
382 return std::to_string(task->index) == strParam;
James Feist46229572020-02-19 15:11:58 -0800383 });
Ed Tanous002d39b2022-05-31 08:59:27 -0700384
385 if (find == task::tasks.end())
386 {
387 messages::resourceNotFound(asyncResp->res, "Tasks", strParam);
388 return;
389 }
390
Ed Tanous02cad962022-06-30 16:50:15 -0700391 const std::shared_ptr<task::TaskData>& ptr = *find;
Ed Tanous002d39b2022-05-31 08:59:27 -0700392
393 asyncResp->res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
394 asyncResp->res.jsonValue["Id"] = strParam;
395 asyncResp->res.jsonValue["Name"] = "Task " + strParam;
396 asyncResp->res.jsonValue["TaskState"] = ptr->state;
397 asyncResp->res.jsonValue["StartTime"] =
Ed Tanous2b829372022-08-03 14:22:34 -0700398 redfish::time_utils::getDateTimeStdtime(ptr->startTime);
Ed Tanous002d39b2022-05-31 08:59:27 -0700399 if (ptr->endTime)
400 {
401 asyncResp->res.jsonValue["EndTime"] =
Ed Tanous2b829372022-08-03 14:22:34 -0700402 redfish::time_utils::getDateTimeStdtime(*(ptr->endTime));
Ed Tanous002d39b2022-05-31 08:59:27 -0700403 }
404 asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
405 asyncResp->res.jsonValue["Messages"] = ptr->messages;
406 asyncResp->res.jsonValue["@odata.id"] =
407 "/redfish/v1/TaskService/Tasks/" + strParam;
408 if (!ptr->gave204)
409 {
410 asyncResp->res.jsonValue["TaskMonitor"] =
411 "/redfish/v1/TaskService/Tasks/" + strParam + "/Monitor";
412 }
413 if (ptr->payload)
414 {
415 const task::Payload& p = *(ptr->payload);
416 asyncResp->res.jsonValue["Payload"]["TargetUri"] = p.targetUri;
417 asyncResp->res.jsonValue["Payload"]["HttpOperation"] =
418 p.httpOperation;
419 asyncResp->res.jsonValue["Payload"]["HttpHeaders"] = p.httpHeaders;
420 asyncResp->res.jsonValue["Payload"]["JsonBody"] = p.jsonBody.dump(
421 2, ' ', true, nlohmann::json::error_handler_t::replace);
422 }
423 asyncResp->res.jsonValue["PercentComplete"] = ptr->percentComplete;
424 });
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700425}
James Feist46229572020-02-19 15:11:58 -0800426
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700427inline void requestRoutesTaskCollection(App& app)
James Feist46229572020-02-19 15:11:58 -0800428{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700429 BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/")
Ed Tanoused398212021-06-09 17:05:54 -0700430 .privileges(redfish::privileges::getTaskCollection)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700431 .methods(boost::beast::http::verb::get)(
Ed Tanous45ca1b82022-03-25 13:07:27 -0700432 [&app](const crow::Request& req,
433 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
Carson Labrado3ba00072022-06-06 19:40:56 +0000434 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Ed Tanous002d39b2022-05-31 08:59:27 -0700435 {
436 return;
437 }
438 asyncResp->res.jsonValue["@odata.type"] =
439 "#TaskCollection.TaskCollection";
440 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService/Tasks";
441 asyncResp->res.jsonValue["Name"] = "Task Collection";
442 asyncResp->res.jsonValue["Members@odata.count"] = task::tasks.size();
443 nlohmann::json& members = asyncResp->res.jsonValue["Members"];
444 members = nlohmann::json::array();
James Feist46229572020-02-19 15:11:58 -0800445
Ed Tanous002d39b2022-05-31 08:59:27 -0700446 for (const std::shared_ptr<task::TaskData>& task : task::tasks)
447 {
448 if (task == nullptr)
449 {
450 continue; // shouldn't be possible
451 }
452 members.emplace_back(
453 nlohmann::json{{"@odata.id", "/redfish/v1/TaskService/Tasks/" +
454 std::to_string(task->index)}});
455 }
456 });
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700457}
zhanghch058d1b46d2021-04-01 11:18:24 +0800458
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700459inline void requestRoutesTaskService(App& app)
James Feist46229572020-02-19 15:11:58 -0800460{
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700461 BMCWEB_ROUTE(app, "/redfish/v1/TaskService/")
Ed Tanoused398212021-06-09 17:05:54 -0700462 .privileges(redfish::privileges::getTaskService)
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700463 .methods(boost::beast::http::verb::get)(
Ed Tanous45ca1b82022-03-25 13:07:27 -0700464 [&app](const crow::Request& req,
465 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
Carson Labrado3ba00072022-06-06 19:40:56 +0000466 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Ed Tanous002d39b2022-05-31 08:59:27 -0700467 {
468 return;
469 }
470 asyncResp->res.jsonValue["@odata.type"] =
471 "#TaskService.v1_1_4.TaskService";
472 asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService";
473 asyncResp->res.jsonValue["Name"] = "Task Service";
474 asyncResp->res.jsonValue["Id"] = "TaskService";
475 asyncResp->res.jsonValue["DateTime"] =
Ed Tanous2b829372022-08-03 14:22:34 -0700476 redfish::time_utils::getDateTimeOffsetNow().first;
Ed Tanous002d39b2022-05-31 08:59:27 -0700477 asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] = "Oldest";
James Feist46229572020-02-19 15:11:58 -0800478
Ed Tanous002d39b2022-05-31 08:59:27 -0700479 asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] = true;
James Feist46229572020-02-19 15:11:58 -0800480
Ed Tanous002d39b2022-05-31 08:59:27 -0700481 auto health = std::make_shared<HealthPopulate>(asyncResp);
482 health->populate();
483 asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
484 asyncResp->res.jsonValue["ServiceEnabled"] = true;
485 asyncResp->res.jsonValue["Tasks"]["@odata.id"] =
486 "/redfish/v1/TaskService/Tasks";
487 });
John Edward Broadbent7e860f12021-04-08 15:57:16 -0700488}
James Feist46229572020-02-19 15:11:58 -0800489
490} // namespace redfish