summaryrefslogtreecommitdiff
path: root/redfish-core/lib/task.hpp
AgeCommit message (Collapse)AuthorFilesLines
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-205/+152
Reduces the total number of lines and will allow for easier testing of the redfish responses. A main purpose of the node class was to set app.routeDynamic(). However now app.routeDynamic can handle the complexity that was once in critical to node. The macro app.routeDynamic() provides a shorter cleaner interface to the unerlying app.routeDyanic call. The old pattern set permissions for 6 interfaces (get, head, patch, put, delete_, and post) even if only one interface is created. That pattern creates unneeded code that can be safely removed with no effect. Unit test for the responses would have to mock the node the class in order to fully test responses. see https://github.com/openbmc/bmcweb/issues/181 The following files still need node to be extracted. virtual_media.hpp account_service.hpp redfish_sessions.hpp ethernet.hpp The files above use a pattern that is not trivial to address. Often their responses call an async lambda capturing the inherited class. ie (https://github.com/openbmc/bmcweb/blob/ffed87b5ad1797ca966d030e7f979770 28d258fa/redfish-core/lib/account_service.hpp#L1393) At a later point I plan to remove node from the files above. Tested: I ran the docker unit test with the following command. WORKSPACE=$(pwd) UNIT_TEST_PKG=bmcweb ./openbmc-build-scripts/run-unit-test-docker.sh I ran the validator and this change did not create any issues. python3 RedfishServiceValidator.py -c config.ini Signed-off-by: John Edward Broadbent <jebr@google.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I147a0289c52cb4198345b1ad9bfe6fdddf57f3df
2021-04-08Using AsyncResp everywherezhanghch051-10/+11
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
2021-02-19Fix nlohmann::json::dump callsEd Tanous1-1/+3
The nlohmann::json::dump call needs to be called with specific arguments to avoid throwing in failure cases. http connection already does this properly, but a bunch of code has snuck in (mostly in redfish) that ignores this, and calls it incorrectly. This can potentially lead to a crash if the wrong thing throws on invalid UTF8 characters. This audits the whole codebase, and replaces every dump() call with the correct dump(2, ' ', true, nlohmann::json::error_handler_t::replace) call. For correct output, the callers should expect no change, and in practice, this would require injecting non-utf8 characters into the BMC. Tested: Ran several of the endpoints/error conditions in question, including some of the error cases. Observed correct responses. I don't know of a security issue that would allow injecting invalid utf8 into the BMC, but in theory if it were possible, this would prevent a crash. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4a15b8e260e3db129bc20484ade4ed5449f75ad0
2021-01-04Implement PercentComplete for code updateGeorge Liu1-0/+2
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
2020-10-07Remove adl_serializer uses for jsonEd Tanous1-9/+6
Several pieces of code seems to be using the adl_serializer from nlohmann. This unfortunately has very undesirable behavior in some cases, and makes a lot of things really difficult to track back to the function that did the serialization, which has caused several bugs in the past with incorrect types. This patchset removes them, and opts for the inline version of the nlohmann json serialization. Tested: Booted bmcweb, and logged in. cat bmcweb_persistent_data.json showed persistent data written properly. Logged into bmc through webui-vue systemctl restart bmcweb Then refreshed webui-vue, and didn't get logged out. Change-Id: I92868629c54d08b37dd1d956f7c2e2a954f9b670
2020-10-06Fix includesEd Tanous1-1/+2
Lots of bad includes got put in recently, including big things, like boost/http and beast/core. These are lots of code to parse, and leads to files including things they didn't mean to. Tested: Code compiles Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I38de889fdfd9b23f66a2259bb30bf6584345e77f
2020-10-01Remove redundant void in taskEd Tanous1-2/+3
It is not required. Also, move the deleted destructor to a public member where it should be. Tested: Code builds. No functional changes. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I4b04ee0870e908fb8204d91e2cd8505518272c7a
2020-08-20EventService : Send event for the Task LifecycleSunitha Harish1-2/+79
The commit implements the Push style events when a Task goes through its life cycle. Tested by: (Used https://github.com/DMTF/Redfish-Event-Listener) 1. Create a subscription by passing "ResourceTypes" as ["Task"] POST -D headers.txt https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination" : "https://<host:port>, "ResourceTypes":["Task"], "Protocol":"Redfish"}' 2. Run a command which starts the Task 3. Verify if the task state changes are reported as events Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I4cea83f221e6f4f40cfbdc3da3e95cd920744316
2020-08-17Enable unused variable warnings and resolveEd Tanous1-6/+6
This commit enables the "unused variables" warning in clang. Throughout this, it did point out several issues that would've been functional bugs, so I think it was worthwhile. It also cleaned up several unused variable from old constructs that no longer exist. Tested: Built with clang. Code no longer emits warnings. Downloaded bmcweb to system and pulled up the webui, observed webui loads and logs in properly. Change-Id: I51505f4222cc147d6f2b87b14d7e2ac4a74cafa8 Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-17Enable clang warningsEd Tanous1-4/+4
This commit enables clang warnings, and fixes all warnings that were found. Most of these fall into a couple categories: Variable shadow issues were fixed by renaming variables unused parameter warnings were resolved by either checking error codes that had been ignored, or removing the name of the variable from the scope. Other various warnings were fixed in the best way I was able to come up with. Note, the redfish Node class is especially insidious, as it causes all imlementers to have variables for parameters, regardless of whether or not they are used. Deprecating the Node class is on my list of things to do, as it adds extra overhead, and in general isn't a useful abstraction. For now, I have simply fixed all the handlers. Tested: Added the current meta-clang meta layer into bblayers.conf, and added TOOLCHAIN_pn-bmcweb = "clang" to my local.conf Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
2020-08-17Remove middlewaresEd Tanous1-4/+4
Middlewares, while kinda cool from an academic standpoint, make our build times even worse than they already are. Given that we only really use 1 real middleware today (token auth) and it needs to move into the parser mode anyway (for security limiting buffer sizes), we might as well use this as an opportunity to delete some code. Some other things that happen: 1. Persistent data now moves out of the crow namespace 2. App is no longer a template 3. All request_routes implementations no longer become templates. This should be a decent (unmeasured) win on compile times. This commit was part of a commit previously called "various cleanups". This separates ONLY the middleware deletion part of that. Note, this also deletes about 400 lines of hard to understand code. Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a Signed-off-by: Ed Tanous <ed@tanous.net>
2020-07-10Codespell redfish-core spelling fixesGunnar Mills1-1/+1
These spelling errors were found using https://github.com/codespell-project/codespell Tested: Top commit (along with this) was built and ran against validator. Change-Id: Ic9dce27b1de8567eedf7753164ef564d3aedf8ca Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-06-11clang-format: update to latest from docs repoGunnar Mills1-47/+46
This is from openbmc/docs/style/cpp/.clang-format Other OpenBMC repos are doing the same. Tested: Built and validator passed. Change-Id: Ief26c755c9ce012823e16a506342b0547a53517a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-05-28FW Update: Task: Update messagesJames Feist1-21/+31
This adds reporting of percent updated and changes "staged" to paused to indicate some further action must happen to change state to Completed. Tested: validator passed "Messages": [ { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has started.", "MessageArgs": [ "2" ], "MessageId": "TaskEvent.1.0.1.TaskStarted", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 5 percent complete.", "MessageArgs": [ "2", 5 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 10 percent complete.", "MessageArgs": [ "2", 10 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 15 percent complete.", "MessageArgs": [ "2", 15 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 20 percent complete.", "MessageArgs": [ "2", 20 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 25 percent complete.", "MessageArgs": [ "2", 25 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 30 percent complete.", "MessageArgs": [ "2", 30 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 35 percent complete.", "MessageArgs": [ "2", 35 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 40 percent complete.", "MessageArgs": [ "2", 40 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 45 percent complete.", "MessageArgs": [ "2", 45 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 50 percent complete.", "MessageArgs": [ "2", 50 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 55 percent complete.", "MessageArgs": [ "2", 55 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 60 percent complete.", "MessageArgs": [ "2", 60 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 65 percent complete.", "MessageArgs": [ "2", 65 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 70 percent complete.", "MessageArgs": [ "2", 70 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 75 percent complete.", "MessageArgs": [ "2", 75 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 80 percent complete.", "MessageArgs": [ "2", 80 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 85 percent complete.", "MessageArgs": [ "2", 85 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 90 percent complete.", "MessageArgs": [ "2", 90 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 95 percent complete.", "MessageArgs": [ "2", 95 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has changed to progress 100 percent complete.", "MessageArgs": [ "2", 100 ], "MessageId": "TaskEvent.1.0.1.TaskProgressChanged", "Resolution": "None.", "Severity": "OK" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has been paused.", "MessageArgs": [ "2" ], "MessageId": "TaskEvent.1.0.1.TaskPaused", "Resolution": "None.", "Severity": "Warning" }, { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 2 has Completed.", "MessageArgs": [ "2" ], "MessageId": "TaskEvent.1.0.1.TaskCompletedOK", "Resolution": "None.", "Severity": "OK" } ], Change-Id: I32103e53486d459fe945a8b451d2092232c12e83 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-05-14Task: Use TaskEvent messagesJames Feist1-1/+4
Task registry messages make more sense to use for task events then standard registry entries when applicable. Use them. Tested: "Messages": [ { "@odata.type": "#Message.v1_0_0.Message", "Message": "The task with id 0 has started.", "MessageArgs": [ "0" ], "MessageId": "TaskEvent.1.0.1.TaskStarted", "Resolution": "None.", "Severity": "OK" } ], Validator passed Change-Id: I707492544e18def2833e8a2e2216ce803c42c775 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-05-06bmcweb: Replace deprecated boost callZhenfei Tai1-1/+3
The boost::asio::io_context::post() is deprecated and will not build when boost library is version 1.71.0. See CMakeLists.txt 271 if ("${Boost_VERSION}" STREQUAL "107100") 272 add_definitions (-DBOOST_ASIO_NO_DEPRECATED) 273 endif () Signed-off-by: Zhenfei Tai <ztai@google.com> Change-Id: Iacd657af320ba6eebb1518cd86a955f355ed5068
2020-04-16Redfish: Allow slash at the end of ResourceGunnar Mills1-4/+4
This is defined in the Redfish protocol. Easiest way to allow this is to end the Node URL with "/", which most Nodes in bmcweb already had. Before: curl -k https://${bmc}/redfish/v1/TaskService/ Not Found After both /redfish/v1/TaskService/ and /redfish/v1/TaskService return the Task Service. Tested: Validator passed. Change-Id: Ic806dc5c91f631b87642e49b486a6b6da7fdf955 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-03-17Task: Add payload supportJames Feist1-0/+57
This adds the payload values to task responses. Tested: passed validator Change-Id: I50467e28ce8142d198f916ea0c63bd413edcd524 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-03-12task: add fwupdate supportJames Feist1-9/+3
This adds firmware update task service support. It adds a match and updates the task value when the interface changes. Tested: On successful fwupdate task was created and updated correctly. On failed fwupdate the status went to failed. Change-Id: Id12cc5d5270e8e45498b665e78601c5c30775323 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-03-03task: default populate internal errorJames Feist1-0/+1
If a timeout happens, set internal error as default message. Tested: passes validator with valid message, set very short timeout on long task to verify Change-Id: I31e979df486f325d18ca2b0a94d585d38097b8e5 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-03-02Add TaskServiceJames Feist1-0/+389
This adds tasks service to Redfish and creates an example for crashdump. The TaskData object creates tasks that can be updated based on d-bus matches. It also has a configurable timeout using timers. Task Monitor uses these task objects to reply with a 202 until the async task is done, then a 204 when it is either failed or completed. Messages support will come in future commit. Tested: Validator passed, wrote script to poll monitor, verified that got 202 with location header and retry-after set correctly, then 204, then 404. Change-Id: I109e671baa1c1eeff1a11ae578e7361bf6ef9f14 Signed-off-by: James Feist <james.feist@linux.intel.com>