146229577SJames Feist /* 246229577SJames Feist // Copyright (c) 2020 Intel Corporation 346229577SJames Feist // 446229577SJames Feist // Licensed under the Apache License, Version 2.0 (the "License"); 546229577SJames Feist // you may not use this file except in compliance with the License. 646229577SJames Feist // You may obtain a copy of the License at 746229577SJames Feist // 846229577SJames Feist // http://www.apache.org/licenses/LICENSE-2.0 946229577SJames Feist // 1046229577SJames Feist // Unless required by applicable law or agreed to in writing, software 1146229577SJames Feist // distributed under the License is distributed on an "AS IS" BASIS, 1246229577SJames Feist // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1346229577SJames Feist // See the License for the specific language governing permissions and 1446229577SJames Feist // limitations under the License. 1546229577SJames Feist */ 1646229577SJames Feist #pragma once 1746229577SJames Feist 1846229577SJames Feist #include "node.hpp" 1946229577SJames Feist 20decde9efSZhenfei Tai #include <boost/asio.hpp> 2146229577SJames Feist #include <boost/container/flat_map.hpp> 2246229577SJames Feist #include <chrono> 23e5d5006bSJames Feist #include <task_messages.hpp> 2446229577SJames Feist #include <variant> 2546229577SJames Feist 2646229577SJames Feist namespace redfish 2746229577SJames Feist { 2846229577SJames Feist 2946229577SJames Feist namespace task 3046229577SJames Feist { 3146229577SJames Feist constexpr size_t maxTaskCount = 100; // arbitrary limit 3246229577SJames Feist 3346229577SJames Feist static std::deque<std::shared_ptr<struct TaskData>> tasks; 3446229577SJames Feist 3532898ceaSJames Feist constexpr bool completed = true; 3632898ceaSJames Feist 37fe306728SJames Feist struct Payload 38fe306728SJames Feist { 39fe306728SJames Feist Payload(const crow::Request &req) : 40fe306728SJames Feist targetUri(req.url), httpOperation(req.methodString()), 41fe306728SJames Feist httpHeaders(nlohmann::json::array()) 42fe306728SJames Feist 43fe306728SJames Feist { 44fe306728SJames Feist using field_ns = boost::beast::http::field; 45fe306728SJames Feist constexpr const std::array<boost::beast::http::field, 7> 46fe306728SJames Feist headerWhitelist = {field_ns::accept, field_ns::accept_encoding, 47fe306728SJames Feist field_ns::user_agent, field_ns::host, 48fe306728SJames Feist field_ns::connection, field_ns::content_length, 49fe306728SJames Feist field_ns::upgrade}; 50fe306728SJames Feist 51fe306728SJames Feist jsonBody = nlohmann::json::parse(req.body, nullptr, false); 52fe306728SJames Feist if (jsonBody.is_discarded()) 53fe306728SJames Feist { 54fe306728SJames Feist jsonBody = nullptr; 55fe306728SJames Feist } 56fe306728SJames Feist 57fe306728SJames Feist for (const auto &field : req.fields) 58fe306728SJames Feist { 59fe306728SJames Feist if (std::find(headerWhitelist.begin(), headerWhitelist.end(), 60fe306728SJames Feist field.name()) == headerWhitelist.end()) 61fe306728SJames Feist { 62fe306728SJames Feist continue; 63fe306728SJames Feist } 64fe306728SJames Feist std::string header; 65fe306728SJames Feist header.reserve(field.name_string().size() + 2 + 66fe306728SJames Feist field.value().size()); 67fe306728SJames Feist header += field.name_string(); 68fe306728SJames Feist header += ": "; 69fe306728SJames Feist header += field.value(); 70fe306728SJames Feist httpHeaders.emplace_back(std::move(header)); 71fe306728SJames Feist } 72fe306728SJames Feist } 73fe306728SJames Feist Payload() = delete; 74fe306728SJames Feist 75fe306728SJames Feist std::string targetUri; 76fe306728SJames Feist std::string httpOperation; 77fe306728SJames Feist nlohmann::json httpHeaders; 78fe306728SJames Feist nlohmann::json jsonBody; 79fe306728SJames Feist }; 80fe306728SJames Feist 81fe306728SJames Feist inline void to_json(nlohmann::json &j, const Payload &p) 82fe306728SJames Feist { 83fe306728SJames Feist j = {{"TargetUri", p.targetUri}, 84fe306728SJames Feist {"HttpOperation", p.httpOperation}, 85fe306728SJames Feist {"HttpHeaders", p.httpHeaders}, 86fe306728SJames Feist {"JsonBody", p.jsonBody.dump()}}; 87fe306728SJames Feist } 88fe306728SJames Feist 8946229577SJames Feist struct TaskData : std::enable_shared_from_this<TaskData> 9046229577SJames Feist { 9146229577SJames Feist private: 9246229577SJames Feist TaskData(std::function<bool(boost::system::error_code, 9346229577SJames Feist sdbusplus::message::message &, 9446229577SJames Feist const std::shared_ptr<TaskData> &)> &&handler, 9546229577SJames Feist const std::string &match, size_t idx) : 9646229577SJames Feist callback(std::move(handler)), 9746229577SJames Feist matchStr(match), index(idx), 9846229577SJames Feist startTime(std::chrono::system_clock::to_time_t( 9946229577SJames Feist std::chrono::system_clock::now())), 10046229577SJames Feist status("OK"), state("Running"), messages(nlohmann::json::array()), 10146229577SJames Feist timer(crow::connections::systemBus->get_io_context()) 10246229577SJames Feist 10346229577SJames Feist { 10446229577SJames Feist } 10546229577SJames Feist TaskData() = delete; 10646229577SJames Feist 10746229577SJames Feist public: 10846229577SJames Feist static std::shared_ptr<TaskData> &createTask( 10946229577SJames Feist std::function<bool(boost::system::error_code, 11046229577SJames Feist sdbusplus::message::message &, 11146229577SJames Feist const std::shared_ptr<TaskData> &)> &&handler, 11246229577SJames Feist const std::string &match) 11346229577SJames Feist { 11446229577SJames Feist static size_t lastTask = 0; 11546229577SJames Feist struct MakeSharedHelper : public TaskData 11646229577SJames Feist { 11746229577SJames Feist MakeSharedHelper( 11846229577SJames Feist std::function<bool( 11946229577SJames Feist boost::system::error_code, sdbusplus::message::message &, 12046229577SJames Feist const std::shared_ptr<TaskData> &)> &&handler, 12146229577SJames Feist const std::string &match, size_t idx) : 12246229577SJames Feist TaskData(std::move(handler), match, idx) 12346229577SJames Feist { 12446229577SJames Feist } 12546229577SJames Feist }; 12646229577SJames Feist 12746229577SJames Feist if (tasks.size() >= maxTaskCount) 12846229577SJames Feist { 12946229577SJames Feist auto &last = tasks.front(); 13046229577SJames Feist 13146229577SJames Feist // destroy all references 13246229577SJames Feist last->timer.cancel(); 13346229577SJames Feist last->match.reset(); 13446229577SJames Feist tasks.pop_front(); 13546229577SJames Feist } 13646229577SJames Feist 13746229577SJames Feist return tasks.emplace_back(std::make_shared<MakeSharedHelper>( 13846229577SJames Feist std::move(handler), match, lastTask++)); 13946229577SJames Feist } 14046229577SJames Feist 14146229577SJames Feist void populateResp(crow::Response &res, size_t retryAfterSeconds = 30) 14246229577SJames Feist { 14346229577SJames Feist if (!endTime) 14446229577SJames Feist { 14546229577SJames Feist res.result(boost::beast::http::status::accepted); 14646229577SJames Feist std::string strIdx = std::to_string(index); 14746229577SJames Feist std::string uri = "/redfish/v1/TaskService/Tasks/" + strIdx; 14846229577SJames Feist res.jsonValue = {{"@odata.id", uri}, 14946229577SJames Feist {"@odata.type", "#Task.v1_4_3.Task"}, 15046229577SJames Feist {"Id", strIdx}, 15146229577SJames Feist {"TaskState", state}, 15246229577SJames Feist {"TaskStatus", status}}; 15346229577SJames Feist res.addHeader(boost::beast::http::field::location, 15446229577SJames Feist uri + "/Monitor"); 15546229577SJames Feist res.addHeader(boost::beast::http::field::retry_after, 15646229577SJames Feist std::to_string(retryAfterSeconds)); 15746229577SJames Feist } 15846229577SJames Feist else if (!gave204) 15946229577SJames Feist { 16046229577SJames Feist res.result(boost::beast::http::status::no_content); 16146229577SJames Feist gave204 = true; 16246229577SJames Feist } 16346229577SJames Feist } 16446229577SJames Feist 16546229577SJames Feist void finishTask(void) 16646229577SJames Feist { 16746229577SJames Feist endTime = std::chrono::system_clock::to_time_t( 16846229577SJames Feist std::chrono::system_clock::now()); 16946229577SJames Feist } 17046229577SJames Feist 171*fd9ab9e1SJames Feist void extendTimer(const std::chrono::seconds &timeout) 17246229577SJames Feist { 17346229577SJames Feist timer.expires_after(timeout); 17446229577SJames Feist timer.async_wait( 17546229577SJames Feist [self = shared_from_this()](boost::system::error_code ec) { 17646229577SJames Feist if (ec == boost::asio::error::operation_aborted) 17746229577SJames Feist { 17846229577SJames Feist return; // completed succesfully 17946229577SJames Feist } 18046229577SJames Feist if (!ec) 18146229577SJames Feist { 18246229577SJames Feist // change ec to error as timer expired 18346229577SJames Feist ec = boost::asio::error::operation_aborted; 18446229577SJames Feist } 18546229577SJames Feist self->match.reset(); 18646229577SJames Feist sdbusplus::message::message msg; 18746229577SJames Feist self->finishTask(); 18846229577SJames Feist self->state = "Cancelled"; 18946229577SJames Feist self->status = "Warning"; 190e5d5006bSJames Feist self->messages.emplace_back( 191e5d5006bSJames Feist messages::taskAborted(std::to_string(self->index))); 19246229577SJames Feist self->callback(ec, msg, self); 19346229577SJames Feist }); 194*fd9ab9e1SJames Feist } 195*fd9ab9e1SJames Feist 196*fd9ab9e1SJames Feist void startTimer(const std::chrono::seconds &timeout) 197*fd9ab9e1SJames Feist { 198*fd9ab9e1SJames Feist if (match) 199*fd9ab9e1SJames Feist { 200*fd9ab9e1SJames Feist return; 201*fd9ab9e1SJames Feist } 202*fd9ab9e1SJames Feist match = std::make_unique<sdbusplus::bus::match::match>( 203*fd9ab9e1SJames Feist static_cast<sdbusplus::bus::bus &>(*crow::connections::systemBus), 204*fd9ab9e1SJames Feist matchStr, 205*fd9ab9e1SJames Feist [self = shared_from_this()](sdbusplus::message::message &message) { 206*fd9ab9e1SJames Feist boost::system::error_code ec; 207*fd9ab9e1SJames Feist 208*fd9ab9e1SJames Feist // callback to return True if callback is done, callback needs 209*fd9ab9e1SJames Feist // to update status itself if needed 210*fd9ab9e1SJames Feist if (self->callback(ec, message, self) == task::completed) 211*fd9ab9e1SJames Feist { 212*fd9ab9e1SJames Feist self->timer.cancel(); 213*fd9ab9e1SJames Feist self->finishTask(); 214*fd9ab9e1SJames Feist 215*fd9ab9e1SJames Feist // reset the match after the callback was successful 216*fd9ab9e1SJames Feist boost::asio::post( 217*fd9ab9e1SJames Feist crow::connections::systemBus->get_io_context(), 218*fd9ab9e1SJames Feist [self] { self->match.reset(); }); 219*fd9ab9e1SJames Feist return; 220*fd9ab9e1SJames Feist } 221*fd9ab9e1SJames Feist }); 222*fd9ab9e1SJames Feist 223*fd9ab9e1SJames Feist extendTimer(timeout); 224e5d5006bSJames Feist messages.emplace_back(messages::taskStarted(std::to_string(index))); 22546229577SJames Feist } 22646229577SJames Feist 22746229577SJames Feist std::function<bool(boost::system::error_code, sdbusplus::message::message &, 22846229577SJames Feist const std::shared_ptr<TaskData> &)> 22946229577SJames Feist callback; 23046229577SJames Feist std::string matchStr; 23146229577SJames Feist size_t index; 23246229577SJames Feist time_t startTime; 23346229577SJames Feist std::string status; 23446229577SJames Feist std::string state; 23546229577SJames Feist nlohmann::json messages; 23646229577SJames Feist boost::asio::steady_timer timer; 23746229577SJames Feist std::unique_ptr<sdbusplus::bus::match::match> match; 23846229577SJames Feist std::optional<time_t> endTime; 239fe306728SJames Feist std::optional<Payload> payload; 24046229577SJames Feist bool gave204 = false; 24146229577SJames Feist }; 24246229577SJames Feist 24346229577SJames Feist } // namespace task 24446229577SJames Feist 24546229577SJames Feist class TaskMonitor : public Node 24646229577SJames Feist { 24746229577SJames Feist public: 24846229577SJames Feist TaskMonitor(CrowApp &app) : 2497af91514SGunnar Mills Node((app), "/redfish/v1/TaskService/Tasks/<str>/Monitor/", 25046229577SJames Feist std::string()) 25146229577SJames Feist { 25246229577SJames Feist entityPrivileges = { 25346229577SJames Feist {boost::beast::http::verb::get, {{"Login"}}}, 25446229577SJames Feist {boost::beast::http::verb::head, {{"Login"}}}, 25546229577SJames Feist {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 25646229577SJames Feist {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 25746229577SJames Feist {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 25846229577SJames Feist {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 25946229577SJames Feist } 26046229577SJames Feist 26146229577SJames Feist private: 26246229577SJames Feist void doGet(crow::Response &res, const crow::Request &req, 26346229577SJames Feist const std::vector<std::string> ¶ms) override 26446229577SJames Feist { 26546229577SJames Feist auto asyncResp = std::make_shared<AsyncResp>(res); 26646229577SJames Feist if (params.size() != 1) 26746229577SJames Feist { 26846229577SJames Feist messages::internalError(asyncResp->res); 26946229577SJames Feist return; 27046229577SJames Feist } 27146229577SJames Feist 27246229577SJames Feist const std::string &strParam = params[0]; 27346229577SJames Feist auto find = std::find_if( 27446229577SJames Feist task::tasks.begin(), task::tasks.end(), 27546229577SJames Feist [&strParam](const std::shared_ptr<task::TaskData> &task) { 27646229577SJames Feist if (!task) 27746229577SJames Feist { 27846229577SJames Feist return false; 27946229577SJames Feist } 28046229577SJames Feist 28146229577SJames Feist // we compare against the string version as on failure strtoul 28246229577SJames Feist // returns 0 28346229577SJames Feist return std::to_string(task->index) == strParam; 28446229577SJames Feist }); 28546229577SJames Feist 28646229577SJames Feist if (find == task::tasks.end()) 28746229577SJames Feist { 28846229577SJames Feist messages::resourceNotFound(asyncResp->res, "Monitor", strParam); 28946229577SJames Feist return; 29046229577SJames Feist } 29146229577SJames Feist std::shared_ptr<task::TaskData> &ptr = *find; 29246229577SJames Feist // monitor expires after 204 29346229577SJames Feist if (ptr->gave204) 29446229577SJames Feist { 29546229577SJames Feist messages::resourceNotFound(asyncResp->res, "Monitor", strParam); 29646229577SJames Feist return; 29746229577SJames Feist } 29846229577SJames Feist ptr->populateResp(asyncResp->res); 29946229577SJames Feist } 30046229577SJames Feist }; 30146229577SJames Feist 30246229577SJames Feist class Task : public Node 30346229577SJames Feist { 30446229577SJames Feist public: 30546229577SJames Feist Task(CrowApp &app) : 3067af91514SGunnar Mills Node((app), "/redfish/v1/TaskService/Tasks/<str>/", std::string()) 30746229577SJames Feist { 30846229577SJames Feist entityPrivileges = { 30946229577SJames Feist {boost::beast::http::verb::get, {{"Login"}}}, 31046229577SJames Feist {boost::beast::http::verb::head, {{"Login"}}}, 31146229577SJames Feist {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 31246229577SJames Feist {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 31346229577SJames Feist {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 31446229577SJames Feist {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 31546229577SJames Feist } 31646229577SJames Feist 31746229577SJames Feist private: 31846229577SJames Feist void doGet(crow::Response &res, const crow::Request &req, 31946229577SJames Feist const std::vector<std::string> ¶ms) override 32046229577SJames Feist { 32146229577SJames Feist auto asyncResp = std::make_shared<AsyncResp>(res); 32246229577SJames Feist if (params.size() != 1) 32346229577SJames Feist { 32446229577SJames Feist messages::internalError(asyncResp->res); 32546229577SJames Feist return; 32646229577SJames Feist } 32746229577SJames Feist 32846229577SJames Feist const std::string &strParam = params[0]; 32946229577SJames Feist auto find = std::find_if( 33046229577SJames Feist task::tasks.begin(), task::tasks.end(), 33146229577SJames Feist [&strParam](const std::shared_ptr<task::TaskData> &task) { 33246229577SJames Feist if (!task) 33346229577SJames Feist { 33446229577SJames Feist return false; 33546229577SJames Feist } 33646229577SJames Feist 33746229577SJames Feist // we compare against the string version as on failure strtoul 33846229577SJames Feist // returns 0 33946229577SJames Feist return std::to_string(task->index) == strParam; 34046229577SJames Feist }); 34146229577SJames Feist 34246229577SJames Feist if (find == task::tasks.end()) 34346229577SJames Feist { 34446229577SJames Feist messages::resourceNotFound(asyncResp->res, "Tasks", strParam); 34546229577SJames Feist return; 34646229577SJames Feist } 34746229577SJames Feist 34846229577SJames Feist std::shared_ptr<task::TaskData> &ptr = *find; 34946229577SJames Feist 35046229577SJames Feist asyncResp->res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task"; 35146229577SJames Feist asyncResp->res.jsonValue["Id"] = strParam; 35246229577SJames Feist asyncResp->res.jsonValue["Name"] = "Task " + strParam; 35346229577SJames Feist asyncResp->res.jsonValue["TaskState"] = ptr->state; 35446229577SJames Feist asyncResp->res.jsonValue["StartTime"] = 35546229577SJames Feist crow::utility::getDateTime(ptr->startTime); 35646229577SJames Feist if (ptr->endTime) 35746229577SJames Feist { 35846229577SJames Feist asyncResp->res.jsonValue["EndTime"] = 35946229577SJames Feist crow::utility::getDateTime(*(ptr->endTime)); 36046229577SJames Feist } 36146229577SJames Feist asyncResp->res.jsonValue["TaskStatus"] = ptr->status; 36246229577SJames Feist asyncResp->res.jsonValue["Messages"] = ptr->messages; 36346229577SJames Feist asyncResp->res.jsonValue["@odata.id"] = 36446229577SJames Feist "/redfish/v1/TaskService/Tasks/" + strParam; 36546229577SJames Feist if (!ptr->gave204) 36646229577SJames Feist { 36746229577SJames Feist asyncResp->res.jsonValue["TaskMonitor"] = 36846229577SJames Feist "/redfish/v1/TaskService/Tasks/" + strParam + "/Monitor"; 36946229577SJames Feist } 370fe306728SJames Feist if (ptr->payload) 371fe306728SJames Feist { 372fe306728SJames Feist asyncResp->res.jsonValue["Payload"] = *(ptr->payload); 373fe306728SJames Feist } 37446229577SJames Feist } 37546229577SJames Feist }; 37646229577SJames Feist 37746229577SJames Feist class TaskCollection : public Node 37846229577SJames Feist { 37946229577SJames Feist public: 3807af91514SGunnar Mills TaskCollection(CrowApp &app) : Node(app, "/redfish/v1/TaskService/Tasks/") 38146229577SJames Feist { 38246229577SJames Feist entityPrivileges = { 38346229577SJames Feist {boost::beast::http::verb::get, {{"Login"}}}, 38446229577SJames Feist {boost::beast::http::verb::head, {{"Login"}}}, 38546229577SJames Feist {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 38646229577SJames Feist {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 38746229577SJames Feist {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 38846229577SJames Feist {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 38946229577SJames Feist } 39046229577SJames Feist 39146229577SJames Feist private: 39246229577SJames Feist void doGet(crow::Response &res, const crow::Request &req, 39346229577SJames Feist const std::vector<std::string> ¶ms) override 39446229577SJames Feist { 39546229577SJames Feist auto asyncResp = std::make_shared<AsyncResp>(res); 39646229577SJames Feist asyncResp->res.jsonValue["@odata.type"] = 39746229577SJames Feist "#TaskCollection.TaskCollection"; 39846229577SJames Feist asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService/Tasks"; 39946229577SJames Feist asyncResp->res.jsonValue["Name"] = "Task Collection"; 40046229577SJames Feist asyncResp->res.jsonValue["Members@odata.count"] = task::tasks.size(); 40146229577SJames Feist nlohmann::json &members = asyncResp->res.jsonValue["Members"]; 40246229577SJames Feist members = nlohmann::json::array(); 40346229577SJames Feist 40446229577SJames Feist for (const std::shared_ptr<task::TaskData> &task : task::tasks) 40546229577SJames Feist { 40646229577SJames Feist if (task == nullptr) 40746229577SJames Feist { 40846229577SJames Feist continue; // shouldn't be possible 40946229577SJames Feist } 41046229577SJames Feist members.emplace_back( 41146229577SJames Feist nlohmann::json{{"@odata.id", "/redfish/v1/TaskService/Tasks/" + 41246229577SJames Feist std::to_string(task->index)}}); 41346229577SJames Feist } 41446229577SJames Feist } 41546229577SJames Feist }; 41646229577SJames Feist 41746229577SJames Feist class TaskService : public Node 41846229577SJames Feist { 41946229577SJames Feist public: 4207af91514SGunnar Mills TaskService(CrowApp &app) : Node(app, "/redfish/v1/TaskService/") 42146229577SJames Feist { 42246229577SJames Feist entityPrivileges = { 42346229577SJames Feist {boost::beast::http::verb::get, {{"Login"}}}, 42446229577SJames Feist {boost::beast::http::verb::head, {{"Login"}}}, 42546229577SJames Feist {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 42646229577SJames Feist {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 42746229577SJames Feist {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 42846229577SJames Feist {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 42946229577SJames Feist } 43046229577SJames Feist 43146229577SJames Feist private: 43246229577SJames Feist void doGet(crow::Response &res, const crow::Request &req, 43346229577SJames Feist const std::vector<std::string> ¶ms) override 43446229577SJames Feist { 43546229577SJames Feist auto asyncResp = std::make_shared<AsyncResp>(res); 43646229577SJames Feist asyncResp->res.jsonValue["@odata.type"] = 43746229577SJames Feist "#TaskService.v1_1_4.TaskService"; 43846229577SJames Feist asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService"; 43946229577SJames Feist asyncResp->res.jsonValue["Name"] = "Task Service"; 44046229577SJames Feist asyncResp->res.jsonValue["Id"] = "TaskService"; 44146229577SJames Feist asyncResp->res.jsonValue["DateTime"] = crow::utility::dateTimeNow(); 44246229577SJames Feist asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] = "Oldest"; 44346229577SJames Feist 44446229577SJames Feist // todo: if we enable events, change this to true 44546229577SJames Feist asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] = false; 44646229577SJames Feist 44746229577SJames Feist auto health = std::make_shared<HealthPopulate>(asyncResp); 44846229577SJames Feist health->populate(); 44946229577SJames Feist asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; 45046229577SJames Feist asyncResp->res.jsonValue["ServiceEnabled"] = true; 45146229577SJames Feist asyncResp->res.jsonValue["Tasks"] = { 45246229577SJames Feist {"@odata.id", "/redfish/v1/TaskService/Tasks"}}; 45346229577SJames Feist } 45446229577SJames Feist }; 45546229577SJames Feist 45646229577SJames Feist } // namespace redfish 457