summaryrefslogtreecommitdiff
path: root/redfish-core/include
AgeCommit message (Collapse)AuthorFilesLines
2022-02-15Abstract fillMessageArgs and unit test itEd Tanous2-15/+30
EventService has a routine for taking a message registry entry and populate it with data. This ideally should be part of the message registry namespace, not EventService, as it could be useful to later patchsets. So break out the method, and write some unit tests to ensure that it can be relied upon in the future. Tested: Unit tests ran and passing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I052d9492f306b63fb72cbf78286370ed0c477430
2022-02-14Remove invalid base log messageEd Tanous1-14/+0
The redfish base registry does not include a definition of this message, which generating type-safe models has teased out. Replace the MutuallyExclusiveProperties message with two "PropertyValueConflict" messages. This seems like the closest thing, but in lieu of the things not being in the standard, this seems like the best compromise. Tested: curl --insecure -X POST --user root:0penBmc https://192.168.7.2/redfish/v1/EventService/Subscriptions -d '{"MessageIds":[""],"RegistryPrefixes":[""],"Destination":"","Protocol":""}' Returns: { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The property 'MessageIds' could not be written because its value would conflict with the value of the 'RegistryPrefixes' property.", "MessageArgs": [ "MessageIds", "RegistryPrefixes" ], "MessageId": "Base.1.8.1.PropertyValueConflict", "MessageSeverity": "Warning", "Resolution": "No resolution is required." } ], "code": "Base.1.8.1.PropertyValueConflict", "message": "The property 'MessageIds' could not be written because its value would conflict with the value of the 'RegistryPrefixes' property." } } Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1eaf4d06b6f5b85909392c48970e3f353af3a41e
2022-02-11Add readability-redundant-* checksEd Tanous1-1/+1
There's a number of redundancies in our code that clang can sanitize out. Fix the existing problems, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie63d7b7f0777b702fbf1b23a24e1bed7b4f5183b
2022-02-09Enable readability-avoid-const-params-in-declsEd Tanous4-5/+5
This check involves explicitly declaring variables const when they're declared auto, which helps in readability, and makes it more clear that the variables are const. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
2022-02-09Send push-style event only if EventService enabledsunharis_in1-5/+23
As per DMTF Redfish, if the event service is disabled, events are not expected to be posted to the existing subscribers This commit adds validation to check "ServiceEnabled" property while sending events. An additional check is made not to attempt sending events if there are no event subscribers at BMC Tested by: Using DMTF Redfish-Event-Listener script with some local modification to support the latest event subscription specifications 1. With a Push-style event subscriber setup, set "ServiceEnabled" to false PATCH /redfish/v1/EventService -d '{"ServiceEnabled":false}' 2. Generate events and check no events are posted to subscriber 2. Set "ServiceEnabled" to true. BMC should resume sending further events 3. Check if BMC attempts to send events by forming the eventRecords when there are no subscriptions made - Verified with traces that events are not sent out 4. With "ServiceEnabled" set to false, verified the SubmitTestEvent fails Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: Icbe7c25ba12bbfb73e59639c484fccdf384ebecf
2022-02-08Capture int by value in stringValueTooLongEd Tanous1-3/+2
Per the coding standard, we should be capturing this by int, not const int&. Tested: There are no uses of stringValueTooLong(), so noop change to binary. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Idfcb05c962e0a0d489db263a6f845bb1789b5842
2022-02-08Rerun parse_registries.pyEd Tanous4-1634/+1332
After the last string wrapping rule change, we never re-ran the script to regenerate, which puts all of these strings on their own line. While this is non-ideal for reading comprehension, it's the rule we have at the moment, so we should be consistent. 12778e61c281b8f8c0f976dec225fb0c30edcb47 appears to have incorrectly checked in a bad version of the privilege registry, which this commit diffs out again. I have inspected https://redfish.dmtf.org/registries/Redfish_1.2.0_PrivilegeRegistry.json by hand, and verified that those overrides are not present. Tested: Whitespace changes only Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I517a7cf13eba2dfd3211491c08ecce69ee68257f
2022-02-07Enable readability-redundant-control-flow checksEd Tanous3-9/+0
These checks are a nice addition to our static analysis, as they simplify code quite a bit, as can be seen by this diff being negative lines. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I60ede4ad23d7e5337e811d70ddcab24bf8986891
2022-02-07Enable readability-named-parameter checksEd Tanous2-25/+5
We don't have too many violations here, probably because we don't have many optional parameters. Fix the existing instances, and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4d512f0ec90b060fb60a42fe3cd6ba72fb6c6bcb
2022-01-28Enable readability-container-size-empty testsEd Tanous2-7/+7
This one is a little trivial, but it does help in readability. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa
2022-01-26Implement Cable schemaShantappa Teekappanavar1-0/+3
This commit implements Cable and Cable collection schema on bmcweb. Testing: Validator: @odata.id /redfish/v1/Cables odata Exists PASS @odata.type #CableCollection.CableCollection odata Exists PASS Members@odata.count 2 odata Exists PASS Members Array (size: 2) links: Cable Yes ... Members[0] Link: /redfish/v1/Cables/dp0_cable0 link: Cable Yes PASS Members[1] Link: /redfish/v1/Cables/dp0_cable1 link: Cable Yes PASS Description Collection of Cable Entries none Yes PASS Name Cable Collection none Yes PASS Oem - Resource.Oem No Optional Property Name Value Type Exists Result @odata.id /redfish/v1/Cables/dp0_cable0 odata Exists PASS @odata.type #Cable.v1_0_0.Cable odata Exists PASS CableType string Yes PASS LengthMeters - number No Optional Id dp0_cable0 none Yes PASS Name Cable none Yes PASS Property Name Value Type Exists Result @odata.id /redfish/v1/Cables/dp0_cable1 odata Exists PASS @odata.type #Cable.v1_0_0.Cable odata Exists PASS CableType string Yes PASS LengthMeters - number No Optional Id dp0_cable1 none Yes PASS Name Cable none Yes PASS Note: Removed some of the fields that are optional to reduce commit msg Tesing with Curl commands: $ curl -k -X GET https://{$bmc}/redfish/v1/Cables { "@odata.id": "/redfish/v1/Cables", "@odata.type": "#CableCollection.CableCollection", "Description": "Collection of Cable Entries", "Members": [ { "@odata.id": "/redfish/v1/Cables/dp0_cable0" }, { "@odata.id": "/redfish/v1/Cables/dp0_cable1" } ], "Members@odata.count": 2, "Name": "Cable Collection" } $ curl -k -X GET https://{$bmc}/redfish/v1/Cables/dp0_cable0 { "@odata.id": "/redfish/v1/Cables/dp0_cable0", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable0", "Name": "Cable" } $ curl -k -X GET https://{$bmc}/redfish/v1/Cables/dp0_cable1 { "@odata.id": "/redfish/v1/Cables/dp0_cable1", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable1", "Name": "Cable" } Set Length property to 1.5 meters using busctl, and check the properties busctl set-property xyz.openbmc_project.Inventory.Manager \ /xyz/openbmc_project/inventory/cables/dp0_cable0 \ xyz.openbmc_project.Inventory.Item.Cable Length d 1.5 $ curl -k -X GET https://{$bmc}/redfish/v1/Cables/dp0_cable0 { "@odata.id": "/redfish/v1/Cables/dp0_cable0", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable0", "LengthMeters": 1.5, "Name": "Cable" } Signed-off-by: Shantappa Teekappanavar <sbteeks@yahoo.com> Change-Id: I832ff1c1053f4d8100d04a42cc8046a61e8c1613
2022-01-19Include what you useEd Tanous4-1/+9
Do a partial update from the include what you use tool. While ideally we'd be able to do this as part of CI, there's still quite a bit of noise in the output that requires manual intervention. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iaaeb7a9199f64b5d6913c3abab4779b252768ed8
2022-01-12Enable pointer devolution checksEd Tanous1-3/+8
Enable cpp core guidelines checks for pointer deevolution. For the moment, simply ignore the uses, although ideally these should be cleaned up at some point. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9a8aae94cc7a59529eab89225a37e89628c17597
2022-01-12Enforce variable initEd Tanous2-5/+6
There were a few places we weren't initting our variables per cpp core guidelines. Fix all of them, and enable checks for this. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iba09924beb9fb26f597ff94d1cecbd6d6b1af912
2022-01-12Enable cppcoreguidelines-special-member-functions checksEd Tanous3-0/+5
Part of enforcing cpp core guidelines involves explicitly including all constructors required on a non-trivial class. We were missing quite a few. In all cases, the copy/move/and operator= methods are simply deleted. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8d6e8bf2bc311fa21a9ae48b0d61ee5c1940999
2022-01-12Enable init checkerEd Tanous1-1/+1
clang-tidy added cppcoreguidelines-init-variables as a check, which is something we already enforce to some extent, but getting CI to enforce it will help reviews move faster. Tested: Code compiles. Noop changes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7e10950de617b1d3262265572b1703f2e60b69d0
2022-01-12Enable bugprone widening checks in clangEd Tanous1-1/+2
Most of the errors we hit are simply places we need to explicitly increase the width of the integer. Luckily, these are few and far between. Tested: Code compiles, unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I617d87f3970ae773e0767bb2f20118fca2e71daa
2022-01-10Bump up privilege_registry to Redfish_1.2.0Shantappa Teekappanavar1-14/+361
Testing: - The privilege_registry.hpp was generated successfully after running the parse_registries script - bmcweb was built with newly generated privilege registry file Signed-off-by: Shantappa Teekappanavar <sbteeks@yahoo.com> Change-Id: I84b5f3eccbbb2c4f12b326b99fb41192b12d245a
2022-01-05Make code compile with clangEd Tanous1-3/+3
One minor shadowed variable that needed it's name changed, and a missing inline statement. Tested: Code now builds in clang-13 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I83b662a2818e1469dfeb29b818338346e40cb832
2021-12-28Using sdbusplus::asio::getPropertyJonathan Doman2-34/+31
It simplifies a lot of code and after changing sdbusplus implementation slightly reduces binary size if used together with: https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/49467 * Uncompressed size: 3033148 -> 3012164, -20984 B * gzip compressed size: 1220586 -> 1214625, -5961 B Tested: - Redfish validator output is the same before and after the change Change-Id: Ibe3227d3f4230de2363ba3d9396e51130c8240a5 Signed-off-by: Jonathan Doman <jonathan.doman@intel.com> Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2021-12-28Move to common variantEd Tanous2-26/+21
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
2021-12-17Add support for DELETE on Triggers schemaSzymon Dompke1-4/+10
Added DELETE method on /redfish/v1/TelemetryService/Triggers/<trigger> uri. Dbus Delete interface on trigger object is used as a backend. Tested: - Trigger was removed successfully by making DELETE call on redfish/v1/TelemetryService/Triggers/TestTrigger Signed-off-by: Szymon Dompke <szymon.dompke@intel.com> Change-Id: Ia830920dac6a539da5b289428374cb96d6492183
2021-12-17Add GET method for TriggersLukasz Kazmierczak2-0/+21
Added GET method for retrieving details of individual Trigger searched by given Trigger name, details are extracted from Telemetry service Tested: - Added single Trigger and requested result from bmcweb via /redfish/v1/TelemetryService/Triggers/<triggername> - Added multiple Triggers numeric and discrete with various parameters (empty, non-empty), and requested results from bmcweb via /redfish/v1/TelemetryService/Triggers/<triggername> - Verified uris /redfish/v1/TelemetryService/Triggers/<triggername> by using Redfish-Service-Validator (all passed) Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com> Change-Id: I1c966b2f792324cc6f6a8784ad18a683e5ce7bd9
2021-12-17Add GET method for TriggerCollectionLukasz Kazmierczak2-1/+2
Added GET method for retrieving list of Triggers from Telemetry service Tested: - Added single Trigger and requested result from bmcweb via /redfish/v1/TelemetryService/Triggers - Added multiple Triggers numeric and discrete, and requested results from bmcweb via /redfish/v1/TelemetryService/Triggers - Verified uri /redfish/v1/TelemetryService/Triggers by using Redfish-Service-Validator with no Triggers/empty Collection (passed) Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com> Change-Id: Ide00eb44901ea1b97b80fc5c5ddfd97e393d4a04
2021-12-16Remove unused headerEd Tanous1-1/+0
Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Idd1426bf5455f66ec873ebdebe96eb06e1df1fc0
2021-12-16error_messages: Use int64_t in invalidIndexJosh Lehan1-2/+2
Using int64_t instead of int, to permit 64-bit indices. This is to support ExternalStorer, a new project I am working on, which uses a 64-bit sequence number for long-term robustness. Change-Id: I00121933067030fd722f6b02c2d2dbd1854dff1c Signed-off-by: Josh Lehan <krellan@google.com>
2021-12-10Add logging to internal errorEd Tanous1-1/+3
Internal error call sites are propagated through the code, and might be triggered multiple times in the course of a request, which makes them difficult to track the source of. This commit changes the internalError() method to include a print of which invocation within bmcweb triggered the error, using c++20s std::source_location mechanism. Note: clang-13 still doesn't implement std::source_location, so this commit pulls source_location.hpp from lg2 to be able to support all compilers. Tested: Loaded in qemu, and added an internalError() call into systems.hpp for the /redfish/v1/Systems handler. Observed that [CRITICAL "error_messages.cpp":234] Internal Error ../../../../../../workspace/sources/bmcweb/redfish-core/include/../lib/systems.hpp(2820:40) `redfish::requestRoutesSystemsCollection(App&)::<lambda(const crow::Request&, const std::shared_ptr<bmcweb::AsyncResp>&)>`: Got printed to the bmcweb logs. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic1b4240422445357bc87404de814ad14f86b9edf
2021-12-10Convert IPv4-mapped IPv6 ClientIP back to IPv4Jiaqing Zhao1-0/+32
Current HTTP server creates an IPv6 acceptor to accept both IPv4 and IPv6 connections. In this way, IPv4 address will be presented as IPv6 address in IPv4-mapped format. This patch converts it back to IPv4. Tested: Verified the ClientOriginIP in Session is shown in native IPv4 format instead of IPv4-mapped IPv6 format. Change-Id: Icd51260b2d4572d52f5c670128b7f07f6b5e6912 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2021-12-10Restructure Redfish EventLog Transmit code flowP Dheeraj Srujan Kumar1-42/+50
In the current implementation: 1. When Event service is disabled and enabled back after a while, all the logs during this time span between disable to enable are dumped to the Event listener. 2. When two(or more) events occur very close (in terms of microseconds) and they trigger multiple iNotify events, the listener receives all of these events with the same Event ID. This occurs as the last log timestamp read from redfish file and previous time stamp used to generate Event ID's are not being updated continuously. This commit fixes this issue by tweaking the logic to continuously update the time stamp values (even when Event Service is disabled), and also replaces multiple string operations with file operations. i.e. Instead of looping through the entire Redfish file until last timestamp read is reached, this fix makes use of seekg to get to the last read position. Tested: - Subscribed to an event and successfully received Event Logs. - No Event Logs were received when Event Service was disabled. - No Dump of past Events after Event Service was enabled. - Redfish Validator passed Change-Id: Id8407ff7e9fc48e7810c9193ef43f707b9615c36 Signed-off-by: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com> Signed-off-by: Ankita Vilas Gawade <ankita.gawade@intel.com>
2021-12-07/s/boost::beast::span/std::spanEd Tanous1-9/+10
std::span is now available in c++ 20 builds, and should be a drop in replacement for boost::span we were using previously. This commit sed replaces it, and changes reference to cbegin and cend to begin and end respectively. Tested: Ran redfish-service-validator. No new failures, and all nodes within /redfish/v1/Registries that would be effected by this change respond with 200 and the same content as previously. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iace89473b7c20f32106eae9d872c16cfae5f17f6
2021-12-01Sync Telmetry service with EventServiceWludzik, Jozef1-91/+44
Synced the latest changes in Telemetry service with Event Service code. Now assembling MetricReport is covered in single place in code. Updated method of fetching Readings from Telemetry by Event Service. Using ReportUpdate signal is no longer supported. Now Event Service monitors for PropertiesChanged signal from /xyz/openbmc_project/Telemetry/Reports path. Tested: - Verified that EventListener received MetricReport response from Event Service in insecure http push style eventing mode Change-Id: I2fc1841a6c9259a8bff30b34bddc0d4aabd41912 Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
2021-11-18EventService: Pass httpHeaders to subscriberSunitha Harish1-6/+9
Custom http headers provided by the subscriber was not passed on to the http client request header This commit passes the http headers to the Subscriber constructor Tested by: Subscribe to events with custom headers Verify the event request packet sending the custom header to the subscriber Verified persistency of the subscription Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I9a4f59b6e9477fae96b380565885f4ac51e2a628
2021-11-16reduce error traces in priv and chassis codeAndrew Geissler1-2/+2
These are not error paths so do not log them as errors Tested: - None other then CI. Changes are very simple. Change-Id: I65b99b466ba2d59c304cd80c88c2c81b940829b9 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
2021-11-05Make telemetry use the common collection utilitiesEd Tanous1-49/+2
getReportCollection is almost a 1:1 copy of getCollectionMembers, but hardcoded for report interface. This commit moves to using the common implementation, rather than duplicating the code. In the course of writing this patchset, it looks like the definition in metric_report_definition.hpp is incorrect, as we pulling metric reports instead of pulling metric report definitions. This commit has the same behavior as the old, but will need to be looked at in the future. Tested: Basic touch testing done by Szymon Dompke. "Everything looks good to me" Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I643da1849aacc38848db1da3eeaad0c111521d34
2021-11-04Redfish: Support Host Log EntriesSpencer Ku2-0/+216
This commit is designing and implementing a new logging service in Redfish to expose host serial console logs.The goal is that clients can talk to bmc via Redfish and get a real-time console. It will improve the debuggability of BMCs. We will add three paths to redfish tree to implement the feature: 1. /redfish/v1/Systems/system/LogServices/HostLogger 2. /redfish/v1/Systems/system/LogServices/HostLogger/Entries 3. /redfish/v1/Systems/system/LogServices/HostLogger/Entries/<str> To use this feature, we expect to use phosphor-hostlogger(stream mode) + rsyslog + bmcweb. Phosphor-hostlooger in stream mode forwards the byte stream into rsyslog via the imuxsock module. The log is persisted via the omfile module as soon as collected. It makes Host Logger leverage exsisting tools (rsyslog and logrotate). Then we can expose host serial console logs via bmcweb. This feature can be enabled or disabled by setting the option "redfish-host-logger", and the default value is "enabled". If you don't want to expose host serial console logs, you need to turn the value to "disabled". Sample Output: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/HostLogger/ { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger", "@odata.type": "#LogService.v1_1_0.LogService", "Description": "Host Logger Service", "Entries": { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger/Entries" }, "Id": "HostLogger", "Name": "Host Logger Service" } curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/HostLogger/Entries { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger/Entries", "@odata.type": "#LogEntryCollection.LogEntryCollection", "Description": "Collection of HostLogger Entries", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger/Entries/0", "@odata.type": "#LogEntry.v1_4_0.LogEntry", "EntryType": "Oem", "Id": "0", "Message": "123123", "Name": "Host Logger Entry", "OemRecordFormat": "Host Logger Entry", "Severity": "OK" } ], "Members@odata.count": 1, "Name": "HostLogger Entries" } curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/HostLogger/Entries/0 { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger/Entries/0", "@odata.type": "#LogEntry.v1_4_0.LogEntry", "EntryType": "Oem", "Id": "0", "Message": "123123", "Name": "Host Logger Entry", "OemRecordFormat": "Host Logger Entry", "Severity": "OK" } Signed-off-by: Spencer Ku <Spencer.Ku@quantatw.com> Change-Id: I4ad2652a80fb1c441a25382b7d422ecd7ffc8557
2021-10-27Sort collections by human sortEd Tanous1-3/+11
Today, collections of dimms have a weird issue where they sort by lexicographical sort, not numeric sort, so systems with >10 dimms show up in the order: Dimm1 Dimm10 Dimm11 Dimm2 While these collections are supposed to be sets, and the order doesn't matter in the spec, there are a number of humans that look at these, and doing something obvious is good for people. Tested: Tested on a CI system with 16 dimms here: https://gist.github.com/geissonator/53a94f124c3501691a7870fb80c60c80 Which responded with dimms 1 and 11 being in the correct order. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0c8b28fd169c5a957fb4d36a7c6771473b06fc0c
2021-10-21Remove NTPServers duplicate values and null valuesGeorge Liu1-0/+39
When saving the set NTPServers values from webUI, NTPServer may contain duplicate values and null values and update them to D-Bus. Now, need to parse and verify the value of the ntpServers attribute,and remove duplicate values and null values. Tested:save NTP and check it via D-Bus without this patch: NTPServers property as 3 "" "10.164.29.2" "10.164.29.2" with this patch: NTPServers property as 2 "" "10.164.29.2" Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I52291e4608efd635b179f3934c3d3e805afd2209
2021-10-19Revert "Redfish: Support Host Log Entries"Ed Tanous2-184/+0
This commit appears to cause 500 errors on systems that don't have host-logger installed. Reverting for now to get the codebase back to stable; To the author, please fix the error and resubmit. The bump that failed is here: https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/47933 This reverts commit bf888502a247d8374c70e7ceddc9862bf0ad88bd. Change-Id: I346178f079245f96e2c1e03720490dcbcf19427b Signed-off-by: Ed Tanous <edtanous@google.com>
2021-10-19Collections should handle no members presentEd Tanous1-1/+8
Upon booting a new system that doesn't have an inventory system working, the mapper will return an error if no resources exist. This is unfortunate, but an error we should handle properly. This commit catches the "no paths found" return code from the mapper, and pushes back an empty collection, instead of returning internal error (500). Tested: Resolved https://192.168.1.224:18080/redfish/v1/Chassis on a system with no Chassis resources, and observed 200, and an empty collection returned. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iedaed198840e88fb0f3dc62423b064edff70972c
2021-10-19Only generate headers once in EventServiceEd Tanous1-2/+1
This patchset builds on https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/45761 and moves the header generation into the constructor, rather than attempting to repurpose addHeaders(). Tested: Per Appu: "Did basic check and its initialized to default as before." Per Sunitha: "Tested the basic event notification scenario with this commit. Works fine" https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/46703/2 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia9e8b89574c7e0137f0d93f08378e45c2fcf5376
2021-10-19Redfish: Support Host Log EntriesSpencerKu2-0/+184
This commit is designing and implementing a new logging service in Redfish to expose host serial console logs.The goal is that clients can talk to bmc via Redfish and get a real-time console. It will improve the debuggability of BMCs. We will add three paths to redfish tree to implement the feature: 1. /redfish/v1/Systems/system/LogServices/HostLogger 2. /redfish/v1/Systems/system/LogServices/HostLogger/Entries 3. /redfish/v1/Systems/system/LogServices/HostLogger/Entries/<str> To use this feature, we expect to use phosphor-hostlogger(stream mode) + rsyslog + bmcweb. Phosphor-hostlooger in stream mode forwards the byte stream into rsyslog via the imuxsock module. The log is persisted via the omfile module as soon as collected. It makes Host Logger leverage exsisting tools (rsyslog and logrotate). Then we can expose host serial console logs via bmcweb. This feature can be enabled or disabled by setting the option "redfish-host-logger", and the default value is "enabled". If you don't want to expose host serial console logs, you need to turn the value to "disabled". RedfishServiceValidator results: /redfish/v1/Systems/system/LogServices/HostLogger pass: 4 passGet: 1 skipOptional: 9 /redfish/v1/Systems/system/LogServices/HostLogger/Entries pass: 24 passGet: 1 skipOptional: 1 /redfish/v1/Systems/system/LogServices/HostLogger/Entries/<str> pass: 7 passGet: 1 skipOptional: 15 Sample Output: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/HostLogger/Entries { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger/Entries", "@odata.type": "#LogEntryCollection.LogEntryCollection", "Description": "Collection of HostLogger Entries", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/LogServices/HostLogger/Entries/1", "@odata.type": "#LogEntry.v1_4_0.LogEntry", "EntryType": "Event", "Id": "1", "Message": "[ 57.061546] gq 0000:16:00.0 eth0: link up, 100 Gbps, no PAUSE", "MessageArgs": [ "[ 57.061546] gq 0000:16:00.0 eth0: link up, 100 Gbps, no PAUSE" ], "MessageId": "OpenBMC.0.1.SerialLogAdded", "Name": "HostLogger Entries", "Severity": "OK" }, ... ], "Members@odata.count": 22, "Name": "HostLogger Entries" } Signed-off-by: SpencerKu <Spencer.Ku@quantatw.com> Change-Id: I5a7873caa117400fb0a737588a50bd743e8b5063
2021-10-18Define hex helper utilsEd Tanous1-0/+21
This commit attempts to optimize some code and reduce our dependence on boost libraries, as the coding standard recommends. It does this by introducing a new method, intToHexString, which is a greatly simplified "to hex" converter that doesn't require std::locale, or stream buffers, and is very efficient. This deletes our need for boost::format, as well as our need for boost::lexical_cast, both of which are fairly heavy libraries. Tested: Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3b0f6eeb10256f87320adcc0ae9396f6bcbc8740
2021-10-17Improve HttpHeaders in EventServiceEd Tanous1-11/+1
This commit moves the internal data structures to use boost::beast::http::fields as its internal data structure. fields is a hyper-optimized map implementation for http headers, and has a lot of nice escaping properties. It is what boost::beast::http::request uses under the covers, so this has some niceties in reducing the amount of code, and means we can completely remove the headers structure, and simply rely on req. When this conversion was done, now the type safety of the incoming data needs to have better checking, as loading into the keys has new requirements (like values must be strings), so that type conversion code for to and from json was added, and the POST and PATCH handler updated to put into the new structure. Tested: curl -vvvv --insecure -u root:0penBmc "https://192.168.7.2:443/redfish/v1/EventService/Subscriptions" -X POST -d "{\"Destination\":\"http://192.168.7.2:443/\",\"Context\":\"Public\",\"Protocol\":\"Redfish\",\"HttpHeaders\":[{\"Foo\":\"Bar\"}]}" returned 200. Tested various "bad" headers, and observed the correct type errors. Issued: systemctl restart bmcweb. Subscription restored properly verified with. GET https://localhost:8001/redfish/v1/EventService/Subscriptions/183211400 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I331f65e1a3960f1812c9baac27dbdcb1d54f112c
2021-09-30Add message registry entry for FirmwareResiliencyErrorChalapathi Venkataramashetty1-1/+13
Add an event log in redfish when firmware update failed due to FirmwareResiliencyError. The existing message entries BMCFirmwareResiliencyError(for BMC update failures) and BIOSFirmwareResiliencyError(for BIOS update failures) are not useful for the new platform. The new platform's CPLD report common error code for BMC, PCH or CPLD firmware update failures. Hence a common message entry is required to capture the firmware update failure events. This event is Implemented in the following review. https://gerrit.openbmc-project.xyz/c/openbmc/pfr-manager/+/43281 Tested: Redfish Service Validator passed for this change. Update BMC firmware with mismatched SVN POST: https://<BMC_IP>/redfish/v1/UpdateService/ with <BMC_Update_Capsule> binary file After BMC reboots check for Event log in Redfish Command: GET: https://<BMC_IP>/redfish/v1/Systems/system/LogServices/ EventLog/Entries Response: { "@odata.id": "/redfish/v1/Systems/system/LogServices/ EventLog/Entries/1621435142_1", "@odata.type": "#LogEntry.v1_4_0.LogEntry", "Created": "2021-05-19T14:39:02+00:00", "EntryType": "Event", "Id": "1621435142_1", "Message": "Firmware resiliency error. Error reason: Firmware update failed(MinorCode:0x02).", "MessageArgs": [ "Firmware update failed(MinorCode:0x02)" ], "MessageId": "OpenBMC.0.1.FirmwareResiliencyError", "Name": "System Event Log Entry", "Severity": "Critical" }, Signed-off-by: Chalapathi Venkataramashetty <chalapathix.venkataramashetty@intel.com> Change-Id: Id13a29ecc160b8e9e1c0b926f6caf882fa746567
2021-09-29log_services: Add download of post code log entriesGeorge Liu1-0/+1
- Add a GET method /redfish/v1/Systems/system/LogServices/PostCodes /Entries/<str>/attachment/, Get the attribute value through the getPostCodes method and encode it as base64, and send it off. - This allows the use 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. - Before, It broke post JSON content as HTTP https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44660 Now, I tested it passed. - 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 $curl -k https://127.0.0.1:2443/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment/ output: AgAAAQAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFNUQU5EQlkgICAgICAgICAgICAgICAgICAgICAgICAg Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ide684146a4ae9d55dc95fb765927867b042fc27c
2021-09-24Update error messages file w.r.t Base.1.11.0Asmitha Karunanithi1-1/+13
Tested By: Code compiles The error message is as follows: { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The operation failed because the service at /redfish/v1/Systems/system/LogServices/Dump/ is disabled and cannot accept requests.", "MessageArgs": [ "/redfish/v1/Systems/system/LogServices/Dump/" ], "MessageId": "Base.1.11.0.ServiceDisabled", "MessageSeverity": "Warning", "Resolution": "Enable the service and resubmit the request if the operation failed." } ], "code": "Base.1.11.0.ServiceDisabled", "message": "he operation failed because the service at /redfish/v1/Systems/system/LogServices/Dump/ is disabled and cannot accept requests." } } Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I923892ecd785e3b6c071fa663fee14a2754d5ef1
2021-09-23Bump up base_message_registry to version Base.1.11.0Sunitha Harish1-5/+92
Tested by: Code compiles Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I229e5662eb20889e6da5575de31dc3c27c63ecd2
2021-09-07Make code pass clang-tidy-13Ed Tanous1-1/+1
clang-tidy-13 appears to have improved its "use brace initialization" checker to handle more cases, and now correctly fails a couple cases that we posses. This commit simply makes the very mechanical changes to make this function. Tested: Ran previous commits checks to run ninja clang-tidy, and observed that clang-tidy now passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I665a7f3e71d25af93703e6b31af0f1eb12a44527
2021-08-24Fix search for OEM privilegesJoseph Reynolds1-1/+1
This fixes an off-by-one bug in the code which retrieves the OEM Privilege names. Tested: Yes, by patching in an OEM privilege and running the code. Signed-off-by: Joseph Reynolds <joseph-reynolds@charter.net> Change-Id: I3ea00fffbc62ec7f8c6bf8ff7e2947f19c92dfc8
2021-07-26EventService: Move subscription persistent dataJunLin Chen1-190/+148
This commit resolves https://github.com/openbmc/bmcweb/issues/168 Current store mechanism makes it very difficult to keep in sync with the existing files, and has caused several bugs because the path it uses different than the existing bmcweb_persistent_data.json, and it's missing several error checks. If there has old config in /var/lib/bmcweb/eventservice_config.json. Restart bmcweb will move old config to bmcweb_presistent_data.json and delete the old config. Tested: - Create new Subscription via POST https://${bmc}/redfish/v1/EventService/Subscriptions/ The subscription is successfully created and GET succussfully. Restart bmcweb or reboot. The subscription will restore. - Delete the Subscription via DELETE https://${bmc}/redfish/v1/EventService/Subscriptions/${subscription_id} The subscription is successfully delete. bmcweb_persistent_data.json will delete subscription content. - Modify EventService config via PATCH https://{{bmc}}/redfish/v1/EventService GET https://{{bmc}}/redfish/v1/EventService and the changes applied. bmcweb_persistent_data.json will apply modification after PATCH. Restart bmcweb or reboot The config maintains the changed. Signed-off-by: JunLin Chen <Jun-Lin.Chen@quantatw.com> Change-Id: Ic29385ea8231ba976bbf415af2803df2d30cb10a