summaryrefslogtreecommitdiff
path: root/redfish-core/lib/log_services.hpp
AgeCommit message (Collapse)AuthorFilesLines
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-1961/+1555
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-05-21log_services: Fix BMC Journal Entries collection odata.idCharles Boyer1-4/+0
This commit removes odata.id assertions so the odata.id becomes Journal/Entries instead of BmcLog/Entries. Tested: - Redfish Service Validator passes - The response from `curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Managers/bmc/LogServices/Journal/Entries` contained the correct odata.id, `{ "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Journal/Entries", "@odata.type": "#LogEntryCollection.LogEntryCollection", "Description": "Collection of BMC Journal Entries", ...` Signed-off-by: Mohaimen Alsamarai <mohaimen.alsamrai@fii-na.com> Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com> Change-Id: Ie9cfa52b141d9f5d0fc12945fa3936bad871a413
2021-05-19Change AdditionalDataURI to be a child URIAbhishek Patel1-20/+16
Make the AdditionalDataURI a child relationship of the resource to better follow Hypermedia API best practices and match the AdditionalDataURI of the coming Post Code log entries. Changed the AdditionalDataURI for bmc dump, system dump, and log entry A hypermedia API gives us a search form in response and tells API what URL to use, which HTTP verb is appropriate, and what parameters to supply. URL change:- Old: "/redfish/v1/Systems/system/LogServices/EventLog/attachment/<str>" New: "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/attachment" openbmc/bmcweb#205 Tested: Validator passes. - Verified the new AdditionalDataURI was correct for /redfish/v1/Systems/system/LogServices/EventLog/Entries: $ curl -k https://w15.aus.stglabs.ibm.com/redfish/v1/Systems/system/LogServices/EventLog/Entries/1 { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", "@odata.type": "#LogEntry.v1_8_0.LogEntry", "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1/attachment", "Created": "2021-03-15T18:47:26+00:00", "EntryType": "Event", "Id": "1", "Message": "xyz.openbmc_project.Common.Error.InternalFailure", "Modified": "2021-04-30T17:26:38+00:00", "Name": "System Event Log Entry", "Resolved": true, "Severity": "Critical" } Change-Id: Ifb720ac2710ebd4a2df37a83c9deb8a6eefdffd5 Signed-off-by: Abhishek Patel <Abhishek.Patel@ibm.com>
2021-05-04Change the word TS to Time Stamp & add time unitManojkiran Eda1-2/+2
- The Message argument in the BIOSPOSTCode Message Entry uses short form wording for TS (Time Stamp) & without any time unit. - As the Message argument is directly displayed on OpenBMC GUI as it is, word "TS" would create customer confusion due to it not being a well known acronym. Also a field like this that captures a physical quantity(time) should have units. - Redfish clients should not be parsing the message argument, so changing this wording should not break them. - Also, this commit changes ":" to ";" in the Message argument to makes things look consistent. - As we changed the content of Message in the Message Entry, we had to bump up the minor version of the Message registry. Tested By: 1. Redfish Validator Passed. Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I17924c2dfdcf34563f8f8cd325011e13cb70e476
2021-04-08Using AsyncResp everywherezhanghch051-143/+146
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-04-03log_services: Remove raw PECI commandJason M. Bills1-82/+0
The raw PECI command is recommended not to include in a standard build, so removing it from the bmcweb to avoid accidental inclusion. Tested: Confirmed that the raw PECI command is gone. Change-Id: I2b52e0ede089da6df6ca3ad304194de8af27b709 Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
2021-04-02log_services: Add download of log entriesAdriana Kobylak1-0/+128
Add a GET function for endpoint /redfish/v1/Systems/system/LogServices/EventLog/attachment/<str> which would read the File Path property of the specified entry, encode it as base64, and send it off. This allows the user to offload error logs for analysis and further parsing if needed. An http header of "Accept: application/octet-stream" or the default "*/*" is expected. Tested: - Ran Redfish validator. - Verified the contents of the offloaded file were the same as the file in the BMC, after decoding it with a base64 decoder. curl -k -H "X-Auth-Token: $token" \ https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/attachment/2 - Verified the supported Accept header values, ex: "Accept: application/octet-stream;q=1" "Accept: text/plain;q=0,application/octet-stream;q=1,multipart/form-data;q=2" - Verified an unsupported Accept header returned "Bad Request", ex: curl -k -H "X-Auth-Token: $token" -H "Accept: application/*" curl -k -H "X-Auth-Token: $token" -H "Accept: foo, not/supported" - Verified 404 was returned for a not found endpoint: $ curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/attachment/foo { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type EventLogAttachment named foo was not found.", "MessageArgs": [ "EventLogAttachment", "foo" ], "MessageId": "Base.1.8.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.8.1.ResourceNotFound", "message": "The requested resource of type EventLogAttachment named foo was not found." } } Change-Id: Id9e2308ebedc70852a2ed62def107648f7e6fb7a Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
2021-04-02log_services: Add AdditionalDataURI to log entriesAdriana Kobylak1-87/+126
The File Path property was added to the DBus Event Log Entries with https://github.com/openbmc/phosphor-logging/commit/1ff95efecaf24bf296b291ed85798b6e22189d0f The Path was added to indicate the path to the Entry file and that the file could be offloaded out of the BMC. Check if the Path property exists, and if so add an AdditionalDataURI field to the EventLog redfish output and populate it with string "LogServices/EventLog/attachment/id" in the same fashion as the dump URI entry. An implementation of GET on that path is done in a subsequent commit. The new Path property is located under the xyz.openbmc_project.Common.FilePath interface. The rest of the current properties are under the xyz.openbmc_project.Logging.Entry interface. In order to read the Path property for an individual entry (endpoint Entries/<str>/), need to remove the Entry interface from the GetAll call so that all properties from all interfaces are returned. In order to get the Path property when querying all entries (endpoint Entries/), need to query the properties under the Entry and FilePath interface, then build the json response for that entry. Tested: - Ran Redfish validator - Verified the new AdditionalDataURI was correct for both LogServices/EventLog/Entries and LogServices/EventLog/Entries/<str>: $ curl -k -H "X-Auth-Token: $token" \ https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/7 { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/7", "@odata.type": "#LogEntry.v1_8_0.LogEntry", "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/attachment/7", - Verified that AdditionalDataURI is not added if the Path property doesn't exist. Change-Id: Ib82361bae19a99e74d53f4ab5c4b446d277f0937 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
2021-03-28Update Crashdump to the latest LogService and LogEntry schemasJason M. Bills1-95/+58
This updates Crashdump to the latest LogService schema which now has a "CollectDiagnosticData" Action that replaces the OEM actions. It also updates to the latest LogEntry to use the new "AdditionalDataURI" property to provide the Crashdump file URI. Tested: Confirmed that the Crashdump LogEntries are displayed and can be collected correctly. Confirmed that the schema changes pass the Redfish Service Validator. Change-Id: I34f533b78441269a66201a13e990dba18745c7ba Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
2021-03-23log-services: Error return 500(internal error)George Liu1-2/+15
- If the server returns 500(internal error) to any of these requests, the security scanner logs it as an error for followup. - Sometimes, it is not a real 500(internal error), may be is a 404 (not found) error, and we think that the 404(not found) error is a benign error, and not actually a real security threat. - We should handle the 404(not found) error correctly and return it where appropriate. - Refer to: https://github.com/openbmc/bmcweb/blob/master/COMMON_ERRORS.md#11-not-responding-to-404 Tested: curl -k -X DELETE -v https://$bmc/redfish/v1/Systems/system/LogServices/Dump/Entries/198274391874 - Before: { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request failed due to an internal service error. The service is still operational.", "MessageArgs": [], "MessageId": "Base.1.8.1.InternalError", "MessageSeverity": "Critical", "Resolution": "Resubmit the request. If the problem persists, consider resetting the service." } ], "code": "Base.1.8.1.InternalError", "message": "The request failed due to an internal service error. The service is still operational." } } - After: { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type systemDumpEntry named 198274391874 was not found.", "MessageArgs": [ "LogEntry", "198274391874" ], "MessageId": "Base.1.8.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.8.1.ResourceNotFound", "message": "The requested resource of type systemDumpEntry named 198274391874 was not found." } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I84c14f0294cf84606c9850dc4bacbda16e8cfa8e
2021-03-19Change PostCode property signatureManojkiran Eda1-7/+13
- This commit would change the backend signature of the PostCode Raw Value property. - IBM progress codes are typically around 72 bytes including a primary code (typically 8 bytes) & a secondary code that contains hex words that would provide additional details on the core problem during boot hangs. - The intent behind this commit is to change the signature of the backend Post Code Raw Value Property as per the proposed PDI change. - This commit has various dependencies across mutiple repos like phosphor-host-postd, phosphor-post-code-manager, all the dependent commit can be found in gerrit with topic name : progress codes Tested By : 1. PATCHED a witherspoon system with the new PDI library with both changes(40927,40936). 2. PACTHED the new snoopd daemon, post code manager, bmcweb & pldm with the progress code support. 3. Trigger a progress code(ASCII Value : STANDBY) using the pldm tool as shown below: ./pldmtool raw --data 0x80 0x3F 0xC 0x0A 0x00 0x00 0x00 0x00 0x00 0x07 0x00 0x00 0x00 0x48 0x00 0x00 0x00 0x02 0x00 0x00 0x01 0x00 0x00 0x00 0x48 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x53 0x54 0x41 0x4e 0x44 0x42 0x59 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 4. Now check the Raw Property : busctl call xyz.openbmc_project.State.Boot.Raw /xyz/openbmc_project/state/boot/raw0 org.freedesktop.DBus.Properties Get ss xyz.openbmc_project.State.Boot.Raw Value v (tay) 6004496007600167200 72 2 0 0 1 0 0 0 72 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 83 84 65 78 68 66 89 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 5. Check the Redfish GET on Post Code Log Service Entry { "@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries", "@odata.type": "#LogEntryCollection.LogEntryCollection", "Description": "Collection of POST Code Log Entries", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1", "@odata.type": "#LogEntry.v1_4_0.LogEntry", "Created": "2021-02-27T08:38:31+00:00", "EntryType": "Event", "Id": "B1-1", "Message": "Boot Count: 1: TS Offset: 0.0000; POST Code: 0x5354414e44425920", "MessageArgs": [ "1", "0.0000", "0x5354414e44425920" ], "MessageId": "OpenBMC.0.1.BIOSPOSTCode", "Name": "POST Code Log Entry", "Severity": "OK" } ], "Members@odata.count": 1, "Members@odata.nextLink": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries?$skip=1000", "Name": "BIOS POST Code Log Entries" } The post code Field shows 0x5354414e44425920 in Hex(In Ascii it would be STANDBY) Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I960a9a4f35ac8d7af03e9547d1f609b6adda0caa
2021-03-16Redfish: Implement new event log propety ResolvedXiaochao Ma1-2/+70
In the new Redfish specification 2020.4,the eventlog propety "resolved" is added. This attribute indicates whether the log is marked as "resolved". Tested: Validator succeeded. The "Modified" attribute value will also change accordingly. This property can be changed as the "marked as resolved" is modified on the web page, or it can be modified directly using the redfish command. Before marked the log as resolved: ~$ curl -i -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/1 { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", "@odata.type": "#LogEntry.v1_8_0.LogEntry", "Created": "1970-01-01T00:01:09+00:00", "EntryType": "Event", "Id": "1", "Message": "xyz.openbmc_project.Common.Device.Error.ReadFailure", "Modified": "1970-01-01T00:01:09+00:00", "Name": "System Event Log Entry", "Resolved": false, "Severity": "Critical" }% after marked the log as resolved on webpage OR use the redfish commond: ~$ curl -k -H "X-Auth-Token: $token" -X PATCH -d '{"Resolved": true}' https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/1 ~$ curl -i -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/1 { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", "@odata.type": "#LogEntry.v1_8_0.LogEntry", "Created": "1970-01-01T00:00:57+00:00", "EntryType": "Event", "Id": "1", "Message": "xyz.openbmc_project.Common.Device.Error.ReadFailure", "Modified": "1970-01-01T00:03:05+00:00", "Name": "System Event Log Entry", "Resolved": true, "Severity": "Critical" } Signed-off-by: Xiaochao Ma <maxiaochao@inspur.com> Change-Id: Idd0cc0ca61ad56703303f90ba2bd1a372c321d94
2021-02-25log_services: Update PostCode D-Bus namesJonathan Doman1-8/+8
PostCode D-Bus service and object names are updated to include 0 suffix, based on updated POST code design for single host systems (see docs change Ibb0389c880243bf3a7c9de12bf409eee2eac9ad7). This change does not add any support for multi-host systems. Tested: With phosphor-host-postd: I89ab5f2eef7eab59823df3a063414f3ca3b2949f phosphor-post-code-manager: I59ed514f28c2bb9b159f51367c38557bf55bf226 1. Cleared POST code history by sending (HTTP)POST to /redfish/v1/Systems/system/LogServices/PostCodes/Actions/LogService.ClearLog/, and verify it returns 200 OK. 2. Verified the Entries collection was now empty at /redfish/v1/Systems/system/LogServices/PostCodes/Entries. 3. Power cycled host and repeat step 2 to verify that new entries are added. Signed-off-by: Jonathan Doman <jonathan.doman@intel.com> Change-Id: I2fdf97b7aaf8d6471d162f8ed1b72143491ac23f
2021-02-23clang-format-11: reformatPatrick Williams1-2/+3
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I0f662e2e6d594567cc10eee34e1df2ca89614870
2021-02-19Start using sdbusplus::message::filename()Ed Tanous1-9/+8
Lots of code gets checked in that does this path checking incorrectly. So much so, that we have it documented in COMMON_ERRORS.md, yet, we persist. This patchset starts using the new object_path::filename() method that was added recently to sdbusplus. Overall, it deletes code, and makes for a much better developer experience. Tested: Pulled down several endpoints and verified that filename() method works properly, and the collections are returned as expected. curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/AccountService/Accounts Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ief1e0584394fb139678d3453265f7011bc931f3c
2021-02-11log_services: Improve error handling for DBus Log EntryAdriana Kobylak1-45/+19
Improve the error handling of the DBus Log Entry class: 1. Return internal error only if message, id, or severity are not initialized. 2. Handle Not Found error (404). 3. Escape the Entry ID used for the DBus call. Tested: A call to entries/foo returns not found: $ curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/foo { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type EventLogEntry named foo was not found.", "MessageArgs": [ "EventLogEntry", "foo" ], "MessageId": "Base.1.8.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.8.1.ResourceNotFound", "message": "The requested resource of type EventLogEntry named foo was not found." } Change-Id: Icac06b34c9d4bc570973da369eef42fd785b4bf7 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
2020-12-18Fix .clang-tidyEd Tanous1-2/+2
camelLower is not a type, camelBack is. Changes were made automatically with clang-tidy --fix-errors To be able to apply changes automatically, the only way I've found that works was to build the version of clang/clang-tidy that yocto has, and run the fix script within bitbake -c devshell bmcweb. Unfortunately, yocto has clang-tidy 11, which can apparently find a couple extra errors in tests we already had enabled. As such, a couple of those are also included. Tested: Ran clang-tidy-11 and got a clean result. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9d1080b67f0342229c2f267160849445c065ca51
2020-11-21Add SYSLOG_IDENTIFIER to the BMC journal MessageJason M. Bills1-1/+15
journalctl prints the SYSLOG_IDENTIFIER from each journal entry to help identify the application that printed the message. If it exists in the journal entry, this adds the SYSLOG_IDENTIFIER to the beginning of the Redfish Message field. Tested: Confirmed that the Journal resource entries still display correctly and include the SYSLOG_IDENTIFIER. Change-Id: I0dfb020e5de13a280d5f1a64c2cf36f1d65a60fa Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
2020-11-06log_services: Fix redundant AsyncResp objects when deleting dump entriesStanley Chu1-6/+5
In the doPost handler for clearing Dump entries, it may create redundant AsyncResp objects in deleteDumpEntry(). This will cause redundant execution of res->end() and lead to unexpected result for subsequent request within the same connection. Tested By: - pass the openbmc-test-automation with the following case. LogService Test [Documentation] Test LogService [Tags] Test_LogService Create User Initiated BMC Dump Redfish Delete All BMC Dumps Redfish.Login Signed-off-by: Stanley Chu <yschu@nuvoton.com> Change-Id: I636cdf7a4c18072898660fd0eab1380e294d263c
2020-10-27log_services: Remove odata.contextGunnar Mills1-20/+12
A series of commits 8 months ago removed odata.context. These creeped back in. Redfish made odata.context optional (1.6.0 of DSP0266, Sept 2018). Redfish has removed odata.context from example payloads in the specification (1.7.0 of DSP0266), removed it from the mockups, and Redfish recommended not using. The reason for making optional and removing from mockups/examples, "no one could figure out how to use it and it did not add value". Don't see value in it for our implementation. Tested: Was tested in a series in an earlier patch set. Change-Id: Ibee7a3839388d4bcafa16ad78b8211e8338c45dc Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-10-23Turn on ALL perf checksEd Tanous1-8/+8
1st, alphabetize the tidy-list for good housekeeping. Next, enable all the clang-tidy performance checks, and resolve all the issues. most of the issues boil down to: 1. Using std::move on const variables. This does nothing. 2. Passing big variables (like std::string) by value. 3. Using double quotes on a find call, which constructs an intermediate string, rather than using the character overload. Tested Loaded on system, logged in successfully and pulled down webui-vue. No new errors. Walked the Redfish tree a bit, and observed no new problems. Ran redfish service validator. Got no new failures (although there are a lot of log service deprecation warnings that we should look at). Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I2238958c4b22c1e554e09a0a1787c744bdbca43e
2020-10-15Lots of performance improvementsEd Tanous1-7/+7
(In the voice of the kid from sixth sense) I see string copies... Apparently there are a lot of places we make unnecessary copies. This fixes all of them. Not sure how to split this up into smaller patches, or if it even needs split up. It seems pretty easy to review to me, because basically every diff is identical. Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369 Signed-off-by: Ed Tanous <ed@tanous.net> Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
2020-10-13Change BMC and System dump codeAsmitha Karunanithi1-58/+52
This commit contains the dump code changes w.r.t the latest changes in the backend. The dump paths are being changed to /xyz/openbmc_project/dump/<bmc or system> as per the below commit: https://gerrit.openbmc-project.xyz/c/openbmc/phosphor- debug-collector/+/36276 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I57abffc59354c363236be42d2d697916bd6480a9
2020-10-09Write the clang-tidy file OpenBMC needsEd Tanous1-7/+7
Now that CI can handle clang-tidy, and a lot of the individual fixes have landed for the various static analysis checks, lets see how close we are. This includes bringing a bunch of the code up to par with the checks that require. Most of them fall into the category of extraneous else statements, const correctness problems, or extra copies. Tested: CI only. Unit tests pass. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9fbd346560a75fdd3901fa40c57932486275e912
2020-10-05Implement bugprone-branch-clone complianceEd Tanous1-22/+7
As part of getting the clang-tidy bugprone tests running, these conditionals were found to have duplicate entries, or be somewhat nonsensical. Tested: clang-tidy now passes with the branch-compliance check set. Change-Id: Ibec106f3bbd866fc471a1fc56bd8cdd5d44024e0
2020-09-29Fix naming conventionsEd Tanous1-5/+5
Lots of code has been checked in that doesn't match the naming conventions. Lets fix that. Tested: Code compiles. Variable/function renames only. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I6bd107811d0b724f1fad990016113cdf035b604b
2020-09-27Fix Task related issue when creating a bmc dumpAsmitha Karunanithi1-5/+6
This commit fixes the issue where, while creating a bmc dump, the task was not being sent back to the redfish client as the response. Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: Id3d6466c5bfc04aa44a66f53e35c4ea28f8ae25b
2020-09-27Remove OEM schemas and related code for Dump LogServicesAsmitha Karunanithi1-43/+32
In this commit, Oem schemas for Dump LogServices are removed as per the latest Redfish schemas. Also, the code is changed w.r.t the latest schema changes. Redfish Validator Passed. Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I12c8d283cd54c32e71a2b11857e7c4cce89b9f0a
2020-09-03Revert http::Request::socket() callbackEd Tanous1-70/+0
Details on why this revert is needed are here. https://lists.ozlabs.org/pipermail/openbmc/2020-August/022478.html Appu and Ravi still have not commented. It should be noted, this also causes a memory leak in http connection, where connections refuse to be freed, because of a bad usage of shared_from_this. This code wasn't very well thought through, and needs rearchitected to not break the unit testability of bmcweb, nor cause memory leaks. https://github.com/openbmc/bmcweb/blob/218bd4746130aac22366968c8c9a34a929e45a3d/http/http_connection.h#L351 Is the memory leak in question. Specifically, this reverts: The /attachment download in LogServices. This needs reimplemented properly, but is an OEM property, so it shouldn't be a big deal to revert, and shouldn't break our redfish compliance. The IpAddress property in SessionService. I have no idea why this was injected, and it's functionally incorrect. IpAddresses are not related to a session, and IP addresses can change over the course of a session, so this property is already broken as written. I suspect the author really wanted RedfishEvent type logging, but that was too complex, so they half implemented this. Redfish SSE properties. This needs to be reimplemented similar to the patchset here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/13948 Where the ownership of the HTTP connection does not leave the http framework. As written, the SSE implementation causes ownership issues, as there's no clear delineation of the ownership between HttpConnection and the SSE framework. Tested: On current master, running this command: wget -O- --no-http-keep-alive --no-check-certificate https://{bmc hostname}:18080/redfish/v1 Which should download the service root, then immediately close and destroy the connection, prints: (2020-08-28 16:55:24) [DEBUG "routing.h":1258] Matched rule '/redfish/v1/' 2 / 4 (2020-08-28 16:55:24) [DEBUG "http_response.h":130] calling completion handler (2020-08-28 16:55:24) [DEBUG "http_response.h":133] completion handler was valid (2020-08-28 16:55:24) [INFO "http_connection.h":429] Response: 0x1e1ee28 /redfish/v1 200 keepalive=0 (2020-08-28 16:55:24) [DEBUG "timer_queue.h":48] timer add inside: 0x1d3d1a8 7 (2020-08-28 16:55:24) [DEBUG "http_connection.h":751] 0x1e1ee28 timer added: 0x1d3d1a8 7 (2020-08-28 16:55:24) [DEBUG "http_connection.h":655] 0x1e1ee28 doWrite (2020-08-28 16:55:24) [DEBUG "http_connection.h":663] 0x1e1ee28 async_write 1555 bytes (2020-08-28 16:55:24) [DEBUG "http_connection.h":697] 0x1e1ee28 timer cancelled: 0x1d3d1a8 7 (2020-08-28 16:55:24) [DEBUG "http_connection.h":676] 0x1e1ee28 from write(1) Then stops. Note, that the connection was not destroyed, and has leaked. Once this patchset is added, the connection closes and destroys properly, and doesn't leak, so it prints the above, but also prints. (2020-08-28 16:27:10) [DEBUG "http_connection.h":305] 0x1d15c90 Connection closed, total 1 Ran Redfish service validator. Saw one unrelated failure due to UUID, all other things pass. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I18686037bf58f20389d31facc0d77020274d38a1
2020-08-27Fix potential null pointer dereferenceGeorge Liu1-8/+21
Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ibeedbe61fa1575af2599c63e6513ddb7d1feff58
2020-08-25Implement Modified Event log propertyGeorge Liu1-20/+35
Refer to https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/29734 and implement Modified Event log property Tested: curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/1 { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", "@odata.type": "#LogEntry.v1_6_0.LogEntry", "Created": "1970-01-01T00:01:35+00:00", "EntryType": "Event", "Id": "1", "Message": "xyz.openbmc_project.Common.Device.Error.ReadFailure", "Modified": "1970-01-01T00:01:35+00:00", "Name": "System Event Log Entry", "Severity": "Critical" } Passed the validator: VERBO - ServiceRoot -> Systems.Systems -> Members.ComputerSystem#0 -> LogServices.LogServices -> Members.LogService#0 -> Entries.Entries -> Members.LogEntry#0, LogEntry.v1_6_1, LogEntry VERBO - @odata.id PASS VERBO - @odata.type PASS VERBO - Created PASS VERBO - EntryType PASS VERBO - Id PASS VERBO - Message PASS VERBO - Modified PASS VERBO - Name PASS VERBO - Severity PASS Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I5a59a298e95e78acaad11a99558f9046675820d3
2020-08-17Deleting the deprecated format for SendRawPeciKarthick Sundarrajan1-38/+17
Crashdump.SendRawPeci redfish interface supports two input data formats. Removing the support for deprecated format. Change-Id: I86db8694d94f1dbabf2852dbde04c414c846b1d1 Signed-off-by: Karthick Sundarrajan <karthick.sundarrajan@intel.com>
2020-08-17Enable unused variable warnings and resolveEd Tanous1-59/+64
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-6/+6
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-50/+36
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-08-08Redfish: Support for DownloadLog ActionAsmitha Karunanithi1-5/+36
Supports offloading a dump to the client Tested-By: * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Managers/bmc/LogServices/ Dump/attachment/<dump-id> * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/ Dump/attachment/<dump-id> Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I99bbb50bc171408273744f89220a46bfe64ba4c4
2020-08-04Remove QueryStringJames Feist1-8/+12
QueryString is an error-prone library that was leftover from crow. Replace it with boost::url, a header only library based and written by the one of the authors of boost beast. Tested: Verified logging paging still worked as expected Change-Id: I47c225089aa7d0f7d2299142f91806294f879381 Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-08-04Minor changes in the code to use the appropriate errorsAsmitha Karunanithi1-15/+8
This commit contains changes that replaces the error messages in the response's body with the appropriate one. This change was made based on the comment in the following commit: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/32033/35/ redfish-core/lib/log_services.hpp#501 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I56a63f1cde27776b86d588695ce9505bf38d7f38
2020-08-04Removing getTimestampStr methodAsmitha Karunanithi1-28/+6
The method 'getTimestampStr' is not used elsewhere in the code, hence it is removed and replaced by 'crow::utility::getDateTime' method. Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I094fe8ca741bf36755a722e72fadd14ed8df7287
2020-07-28Redfish: Support for ClearLog ActionAsmitha Karunanithi1-28/+60
Clears the BMC dump entry collection Tested-By: * curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Managers/bmc/LogServices/ Dump/Actions/LogService.ClearLog * curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/ Dump/Actions/LogService.ClearLog Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: Iffe9b62d52bc28ccbeae3efdb34d30b2b750ab2c
2020-07-28Redfish: Creation of a BMC dumpAsmitha Karunanithi1-0/+187
This commit supports creation of a BMC dump entry. After initiation of the dump creation, a task is created that listens to "InterfaceAdded" signal over "/xyz/openbmc_project/dump" path. Once the task is completed, it returns the created BMC dump entry ID, as a part of the task's message args as well as in the task's http header. Tested-By: * curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Managers/bmc/LogServices/ Dump/Actions/Oem/OemLogService.CollectDiagnosticData -d '{"DiagnosticDataType" : "Managers", "OEMDiagnosticDataType": ""}' * curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/Systems/system/LogServices/ Dump/Actions/Oem/OemLogService.CollectDiagnosticData -d '{"DiagnosticDataType" : "OEM", "OEMDiagnosticDataType": "System"}' <Returns a Task> * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/TaskService/Tasks/<task-id> <Returns Dump ID on completion> Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: Ide44b6abda797d738851123f06696558bab05ce0
2020-07-28Redfish: BMC dump logEntry service implementationAsmitha Karunanithi1-225/+463
This commit supports adding a BMC dump entry under /redfish/ v1/Managers/bmc/LogServices/Dump * Removed the option for enabling each dump separately. Instead introduced one common option to enable dump. * Defined few methods that are common for both BMC and System dumps. * Compilation flag DBMCWEB_ENABLE_REDFISH_DUMP_LOG must be enabled. Tested-By: * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/ redfish/v1/Managers/bmc/LogServices/ * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/ redfish/v1/Managers/bmc/LogServices/Dump * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/ redfish/v1/Managers/bmc/LogServices/Dump/Entries * curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/ redfish/v1/Managers/bmc/LogServices/Dump/Entries/<dump-id> * curl -k -H "X-Auth-Token: $bmc_token" -X DELETE https://${bmc}/ redfish/v1/Managers/bmc/LogServices/Dump/Entries/<dump-id> Redfish Validator passed. Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: Iac9daa8242154e249fad66609b837cf7d2b16091
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-30Add Crashdump.Telemetry interface and triggerKenny L. Ku1-2/+78
Tested: - Sent post requests Crashdump.OnDemand & Crashdump.Telemetry and correct trigger is received in crashdump application. - Redfish validator is run successfully. Signed-off-by: Kenny K. Ku <kenny.k.ku@intel.com> Change-Id: Ie0f49d3230aeb4450e11dfa2d46e309946763a6a
2020-06-11clang-format: update to latest from docs repoGunnar Mills1-234/+235
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-06-03log_services: Fix Severity Empty string found issue when running Redfish ↵Tim Lee1-5/+7
Service Validator Symptom: When running Redfish Service Validator, we found that Severity Empty string issue except first post code in PostCodesEntry. *** /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1 Regetting resource from URI /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1 Type (#LogEntry.v1_4_0.LogEntry), GET SUCCESS (time: 0) PASS *** /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-2 Regetting resource from URI /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-2 Type (#LogEntry.v1_4_0.LogEntry), GET SUCCESS (time: 0) Severity: Empty string found - Services should omit properties if not supported Severity: Invalid Enum value '' found, expected ['OK', 'Warning', 'Critical'] FAIL... Root cause: In fillPostCodeEntry(), this statement "severity = message->severity" only be executed once. And another statement {"Severity", std::move(severity)} in the end of this function will clear severity string to null after calling std::move() standard function. Thus, only first post code Severity is 'OK', but the others are NULL. Solution: Move this statement "severity = message->severity" to for loop in fillPostCodeEntry() then all post codes will be recorded with correct severity string 'OK'. Tested: Passed the Redfish Service Validator and verified "Severity": "OK" in /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-2 { "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry", "@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-2", "@odata.type": "#LogEntry.v1_4_0.LogEntry", "Created": "2020-04-27T01:48:10+00:00", "EntryType": "Event", "Id": "B1-2", "Message": "Boot Count: 1: TS Offset: 0.0046; POST Code: 0x02", "MessageArgs": [ "1", "0.0046", "0x02" ], "MessageId": "OpenBMC.0.1.BIOSPOSTCode", "Name": "POST Code Log Entry", "Severity": "OK" } Signed-off-by: Tim Lee <timlee660101@gmail.com> Change-Id: Ibfccfa47cfe8e0f58e7f24650871edda5d248674
2020-05-29BMCWeb : Fix a warning spotted in meson scan buildManojkiran Eda1-0/+7
- This commit fixes a warning that is spotted in meson scan build which is run as a part of CI. ``` ../../../redfish-core/include/../lib/log_services.hpp:1519:9: warning: Value stored to 'ret' is never read ret = sd_journal_seek_realtime_usec(journal.get(), ts); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. ``` Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I6800ef9d908494d8328ab8e66c12778df394023c
2020-05-28Redfish: ClearLog action support for system dump log entriesraviteja-b1-2/+48
Tested By: POST https://${IP}/redfish/v1/Systems/system/LogServices/SystemDump/Actions/LogService.ClearLog Change-Id: I28af3ccc1d7bd54c521e79d93e6ccb1436eefc4f Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
2020-05-28Redfish: Download action support for system dump entryraviteja-b1-0/+31
Tested By: POST https://${IP}/redfish/v1/Systems/system/LogServices/SystemDump/Entries/<id>/Actions/Oem/OpenBmc/LogEntry.DownloadLog Change-Id: I06262cf0799920aeb065a065886320b20c04aa7c Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
2020-05-14Task: Use TaskEvent messagesJames Feist1-1/+3
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>