summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-05-06memory: correct type of MemorySizeInKBNan Zhou1-2/+2
This is needed for this code to work on both 32 and 64 bits system. According to the interface, https://github.com/openbmc/phosphor-dbus-interfaces/blob/388b58f9a878f45b8ec243152cac5eb44ec90ced/yaml/xyz/openbmc_project/Inventory/Item/Dimm.interface.yaml#L9, MemorySizeInKB is of type size_t. Tested: On real hardware, the memory resource is working as expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ie81d2610c245a08a22c3ea891495f34cc0bdc075
2022-05-05Implement etag headersEd Tanous1-0/+12
This commit implements a limited support for the production of etags on json resources. It is intended to cause two things: 1. To get bmcweb to pass the PROTO_ETAG_ON_GET_ACCOUNT check, as well as the redfish spec, which states: "Implementations shall support the return of ETag headers for GET requests of ManagerAccount resources." 2. Begin discussions on what client-facing caching could look like in the future, and to implement the fewest lines of code this author could think of, with the hope of extending it later. As written, it injects into the Response class a method that, for json responses, uses std::hash<json> to generate an etag. This was chosen under the assumption that it caused the least binary impact, and is already a function provided by nlohmann, so required minimal implementation effort to get something that functioned to the standard: https://json.nlohmann.me/api/basic_json/std_hash/#version-history I'm open to discussions if this should be improved in the future to include more entropy, or to be a "weak" etag, but I think starting with std::hash is a good first step. This patchset intentionally does notimplement handling of the If-None-Match, or If-Match headers that a caching client would likely send that implements this. That is not explicitly required by the spec, relatively complex, and probably has consequences that this author doesn't want to write the test cases for (yet). This lack of support makes this patchset largely only "useful" in passing the tests, and implementing the spec to the letter, it does not generalize a caching client feature that improves performance. Tested: curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1 Contains in the response: ETag: "765E4548" The redfish protocol validator now passes the PROTO_ETAG_ON_GET_ACCOUNT test, which increases our passing test count by 4 compared to previously. Current counts are 352 passing, 30 failing, 36 not tested. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3389b2ba98bf1276e1cb2d9c5954437b924f2d94
2022-05-04Fix bmcweb crash problem when no-authJunLin Chen1-1/+38
This change is similiar as https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/49465 After insecure-disable-auth=enabled. it is not needed to do login and establish session before request. GET/PATCH /redfish/v1/AccountService/Accounts/<accountname>. (no matter account exist or not) It won't get any status code and cause the bmcweb service crashed. Solutions: Add #ifndef BMCWEB_INSECURE_DISABLE_AUTHENTICATION and [[maybe_unused]] const crow::Request& req Test: GET / PATCH with authless https://<bmcip>/redfish/v1/AccountService/Accounts/TestAccount Return 200 { "@odata.id": "/redfish/v1/AccountService/Accounts/TestAccount", "@odata.type": "#ManagerAccount.v1_4_0.ManagerAccount", "AccountTypes": [ "Redfish" ], "Description": "User Account", "Enabled": true, "Id": "TestAccount", "Links": { "Role": { "@odata.id": "/redfish/v1/AccountService/Roles/Administrator" } }, "Locked": false, "Locked@Redfish.AllowableValues": [ "false" ], "Name": "User Account", "Password": null, "PasswordChangeRequired": false, "RoleId": "Administrator", "UserName": "TestAccount" } GET nonexistent account https://<bmcip>/redfish/v1/AccountService/Accounts/TestAccountsss { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type ManagerAccount named TestAccountsss was not found.", "MessageArgs": [ "ManagerAccount", "TestAccountsss" ], "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 ManagerAccount named TestAccountsss was not found." } } Signed-off-by: JunLin Chen <Jun-Lin.Chen@quantatw.com> Change-Id: Ic00020ac07950347973b54d49dacd44c4d4571b7 Signed-off-by: Tony Lee <tony.lee@quantatw.com> Signed-off-by: Ed Tanous <edtanous@google.com>
2022-05-04Document expectations for commit messagesEd Tanous1-0/+50
This commit tries to be more explicit about the expectations for commit messages and testing within bmcweb, and give maintainers something to point to instead of repeating the same statements over and over again. This will likely need to evolve, but I think it's a good start, and would help people put together commits that can be merged on the first try, rather than requiring followup. Tested: Documentation only, no testing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib60ac90eccdc4f2c3215a755bbb462fff4796dd4
2022-05-04Fix whitespacing on meson_options.txtEd Tanous1-34/+272
The meson_options.txt file is difficult to read and maintain because it has inconsistent whitespace, lines that are far longer than fit on a single monitor, and inline strings that are inconsistent. This commit fixes those, moving the syntax to use newlines for each option method key value, no space on the key colon, and wraps description strings using mesons multi-line syntax on 80 character boundaries. Doing this should make this file more maintainable in the future, and helps people to review, and read it better than previously. The intent is that this patchset has no functional changes, only whitespace and non-enforcing string manipulation, with one exception. Anywhere we noted a redfish path, we used escaped single quotes. Multiline strings in meson don't support escaping, so in lieu of worse alternatives, the quoting was removed, which inline with this patch, continues to improve the readability of the file. Tested: Code builds. No functional changes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I04f3e31e364bcd3d4b09a219afff21a8eaabc463
2022-05-02Add OpenBMC.1.0.ServiceStarted to registrySui Chen1-2/+11
This change adds OpenBMC.1.0.ServiceStarted to the registry, and adds a test case for getMessage and getMessageFromRegistry. The getMessageFromRegistry function is moved to a .cpp file so it can be called from the test. Unit test passes. When tested in QEMU: With https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/52591 applied, restarting a service generates a corresponding log entry. bmc# systemctl restart rsyslogd host$ wget -q -O - \ http://localhost:10080/redfish/v1/Systems/system/LogServices/EventLog/Entries/ ... { "@odata.id": /redfish/v1/Systems/system/LogServices/EventLog/Entries/47441_1", "@odata.type": "#LogEntry.v1_8_0.LogEntry", "Created": "1970-01-01T13:10:41+00:00", "EntryType": "Event", "Id": "47441_1", "Message": "Service rsyslog.service has started successfully.", "MessageArgs": [ "rsyslog.service" ], "MessageId": "OpenBMC.1.0.ServiceStarted", "Name": "System Event Log Entry", "Severity": "OK" }, Signed-off-by: Sui Chen <suichen@google.com> Change-Id: Iea6fa6e3ea8591853169043c1c04f5a7cf00b2f6
2022-05-02storage: Call function only if interfaces existWilly Tu1-4/+24
Avoid making the dbus call if the interface does not exist and is expected to error out to reduce the number of dbus calls. Tested: Redfish Validator passed for Drives ``` $ wget -qO- \ http://localhost:80/redfish/v1/Systems/system/Storage/1/Drives/drive { "@odata.id": "/redfish/v1/Systems/system/Storage/1/Drives/drive", "@odata.type": "#Drive.v1_7_0.Drive", "Id": "warthog", "Links": { "Chassis": { "@odata.id": "/redfish/v1/Chassis/chassis" } }, "Manufacturer": "XXX", "MediaType": "SSD", "Model": "XXX", "Name": "drive", "PartNumber": "xxxxxxxxxxxxx", "Protocol": "SATA", "SerialNumber": "123456", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" } } ``` Change-Id: Ic83c8ee5a49f75b71d443781faf8b65d8fab31b6 Signed-off-by: Willy Tu <wltu@google.com>
2022-04-30Fix unmounting image in proxy mode.Przemyslaw Czarnowski1-1/+1
Sometimes Slot0 got higher key than Slot1 and erase function for Slot1 invalidates elements with keys not less than the erased element. In that case invalid slot0 will be unmounted. Change order of calling close() and erase() functions to unmount correct device. Change-Id: I7a40a4518982f697d3eed635cde6d06978149cf0 Signed-off-by: Alicja Rybak <alicja.rybak@intel.com> Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2022-04-30Fix compilation of nbd_proxy.hppPrzemyslaw Czarnowski1-4/+6
Fixes compilation errors after introducing * 7772638ea777820234e6004ee63dc558e629e35e Remove AsyncResp from openHandler * b9d36b4791d77a47e1f3c5c4564fcdf7cc68c115 Consistently use dbus::utility types Tested: When nbd_proxy is enabled, code compiles. Change-Id: I6422bbcb7086a8ebc6cc48c7c72636afd1e3ac21 Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2022-04-29Delete forked function_traitsEd Tanous2-46/+8
The function_traits class was very clearly "borrowed" from boost::function traits, then added to to support lambdas. boost::function_traits has been superceeded by boost::callable_traits, which fixes the same shortcomings that we have fixed here. This commit replaces almost the entirety of the uses of function_traits with callable traits, with one exception: arg<i>. In the callable traits model, arg_t is a std::tuple, which, while better, doesn't unpack easily into a variadic pack that our router code expects. Ideally, at some point, we would rewrite the router core to not rely on std::make_integer_sequence, but that's a much more invasive change. Tested: Called curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1646953359619803 and verified callback return the correct result (not 404). That API has several flexible router parameters, which is the only thing this commit could break. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Icf3299b2d5c1a5ff111f68858bb46139735aaabe
2022-04-28Make log services use parameter delegationEd Tanous3-104/+195
The commit prior to this one added support for delegation of $expand and $only query param types; This commit adds support for delegation of top and skip (which we already have a few handlers for) and moves them to the new style. Note, this makes top and skip query params NOT below the insecure-enable-redfish-query. top and skip have existed for a while, and are unlikely to have security issues, as they're relatively simple transforms. Tested: curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Managers/bmc/LogServices/Journal/Entries\?\$top\=3\&\$skip\=0 With varying $top between 1-5 and $skip between 0-5 gave the expected number of log results. Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia213a5e929c40579825eaf251e4b9159bc84c802
2022-04-28Make insecure-enable-redfish-query more specificEd Tanous4-9/+12
insecure-enable-redfish-query is really only intended to protect the user from things that might run the system out of resources, like expand, or complex filter queries (ie queries that might pop the stack). This commit message moves the location where the parameters are enabled/disabled into the parser itself, such that some parameters (like top and skip in the next commit) can be executed outside of this option flag. Because of moving the expand support deeper in the call stack, some unit tests now need to be aware of whether or not expand is supported in the configuration. Tested: Enabled query option through local.conf with EXTRA_OEMESON:pn-bmcweb:append = "-Dinsecure-enable-redfish-query='enabled'" Then did: curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1\?\$expand\=\* Query expanded as expected; set insecure-enable-redfish-query='disabled' and observed that the same curl query returned QueryParameterValueFormatError, which is expected. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I24fbc2c9f64628d6457dd117b61ff22b276b0682
2022-04-27Fix Ethernet privilegesAbhishek Patel1-9/+3
Post method: 1) /redfish/v1/Managers/bmc/EthernetInterfaces/<str>/VLANs/ ConfigureComponents -> ConfigureManager Patch method: 1) /redfish/v1/Managers/bmc/EthernetInterfaces/<str>/VLANs/<str>/ ConfigureComponents -> ConfigureManager 2) /redfish/v1/Managers/bmc/EthernetInterfaces/<str>/ ConfigureComponents -> ConfigureManager (SubordinateOverrides) Delete method: 1) /redfish/v1/Managers/bmc/EthernetInterfaces/<str>/VLANs/<str>/ ConfigureComponents -> ConfigureManager This change allows only Admin user to post, patch, and delete on VLAN Network Interface Collection and restrict Operator user. Same for the EthernetInterfaces patch method. Tested: Ran curl test with admin and operator privileged user for all methods (post, patch, and delete). one test failing. Error: curl -k -H "X-Auth-Token: $bmc_token" -X PATCH -d '{"VLANId" :30 , "VLANEnable" : true}' https://${BMC_IP}/redfish/v1/Managers/bmc/EthernetInterfaces/ eth0/VLANs/eth0_50 This command is unable to update the VLANId value. instead, it deletes VLAN Email sent to openbmc list: https://lists.ozlabs.org/pipermail/openbmc/2021-August/027232.html Signed-off-by: Abhishek Patel <Abhishek.Patel@ibm.com> Change-Id: I4101c429db6fa788909982b66445b191ccacaec7
2022-04-27Fix certificate_service privilegesAbhishek Patel1-3/+1
Post method: 1) /redfish/v1/CertificateService/Actions/ CertificateService.GenerateCSR/ ConfigureComponents-> ConfigureManager This change allows only Admin users to Generate CSR Certificate and restrict Operator user. Tested: Ran curl Post requests with Admin and Operator privileged users Get output as expected. Email sent to openbmc list: https://lists.ozlabs.org/pipermail/openbmc/2021-August/027232.html Signed-off-by: Abhishek Patel <Abhishek.Patel@ibm.com> Change-Id: I46d505357cfc55a31911e75e8bd9948a0db90555
2022-04-27Simplify sensor path lookupsEd Tanous3-59/+52
This commit drops 8k from the binary size. Tested: SensorCollection returns sensor values as expected, same as previously Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ife1dc40ff6745585ac6bc3f99cd5e6c4811baa56
2022-04-26system: Fix incorrect WatchdogTimer PATCH handlerJiaqing Zhao1-1/+1
Changes the incorrect WatchdogTimer property name to HostWatchdogTimer in PATCH /redfish/v1/Systems/system handler to match the Redfish spec. Tested: Updating HostWatchdogTimer with PATCH request is handled properly. Change-Id: Ic7c9c72e3fd43fb738f4fc21eb39e335aa8d1bcd Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-25Sensors: Add humidity hierarchyGunnar Mills1-1/+7
As stated in PDI humidity is a valid hierarchy. https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Sensor/Value.interface.yaml From https://redfish.dmtf.org/schemas/v1/Sensor.v1_5_0.json: Humidity is a valid ReadingType and Humidity ReadingUnits shall be %. This follows the following Redfish mockup: https://redfish.dmtf.org/redfish/mockups/v1/1156 This is not under BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM due to not being part of the old thermal or power resources. Tested: Validator passes. See a Humidity sensor in the Sensor colleciton: { "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/Relative_Humidity", "@odata.type": "#Sensor.v1_0_0.Sensor", "Id": "Relative_Humidity", "Name": "Relative Humidity", "Reading": 61.935424802658005, "ReadingRangeMax": 100.0, "ReadingRangeMin": 0.0, "ReadingType": "Humidity", "ReadingUnits": "%", ... Signed-off-by: Gunnar Mills <gmills@us.ibm.com> Change-Id: Ib1f52b0b0e3d8c4bfec8c4389c811fdb8b9d887a
2022-04-19Remove regex uses in event service and consolidateEd Tanous8-98/+112
As the patch at https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/50994 can attest, parsing urls with a regex is error prone. We should avoid it where possible, and we have boost::urls that implements a full, correct, and unit tested parser. Ideally, eventually this helper function would devolve into just the parse_uri, and setting defaults portion, and we could rely on the boost::urls::url class to pass into things like http_client. As a side note, because boost url implements port as a proper type-safe uint16, some interfaces that previously accepted port by std::string& needed to be modified, and is included in this patch. Also, once moved, the branch on the ifdef for HTTP push support was failing a clang-tidy validation. This is a known limitation of using ifdefs for our code, and something we've solved with the header file, so move the http push enabler to the header file. Also note that given this reorganization, two EXPECT statements are added to the unit tests for user input behaviors that the old code previously did not handle properly. Tested: Unit tests passing Ran Redfish-Event-Listener, saw subscription create properly: Subcription is successful for https://192.168.7.2, /redfish/v1/EventService/Subscriptions/2197426973 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4127c6cbcde6002fe8a50348792024d1d615e8f
2022-04-19Implement odata annotations ignoringEd Tanous2-2/+44
From the quoted section of the spec in the patchset, we should be ignoring odata annotations on PATCH requests. This commit implements a preliminary loop through the json object, and removes the odata items before processing begins. Tested: curl -vvvv --insecure --user root:0penBmc -X PATCH -d '{"@odata.etag": "my_etag"}' https://192.168.7.2/redfish/v1/AccountService/Accounts/root returns: Base.1.11.0.NoOperation Redfish protocol validator now passes the REQ_PATCH_ODATA_PROPS test. Included unit tests passing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I62be75342681d147b8536fd122bbc793eeaa3788
2022-04-15ethernet: Fix naming conventionsJiaqing Zhao2-88/+87
Some variable names in ethernet.hpp does not match naming conventions, fix'em all. Tested: Only variable name changes, build pass. Change-Id: If275a77364e5ed827a5088342f44548274b059e1 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-15ethernet: Remove unused SendHostNameEnabled propertyJiaqing Zhao1-11/+0
Remove EthernetInterfaceData.SendHostNameEnabled as it is defined but never used excepting reading it from DBus. Tested: Build pass. Change-Id: Ib64792b5842a1e8fb95e3a38d40f11797cfb5641 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-15ethernet: Remove unused changeVlanId() functionJiaqing Zhao1-21/+0
In ethernet.hpp, changeVlanId() is defined but never used, and VLAN ID is not a writable property in phosphor-networkd. Remove it. Tested: Build pass. Change-Id: I1770e777529cca9d9a56831f62e0833c3f7de9df Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-15CertificateService: Enhance error handling for ReplaceCertificateJiaqing Zhao1-2/+9
Current implementation of the ReplaceCertificate API always returns ResourceNotFound if any error occurs when calling DBus, regardless of whether the certificate to be replaced exists or not. This patch checks the error code and only return ResourceNotFound when the object path does not exist, otherwise returns InternalError. Tested: * Replace HTTPS certificate at /redfish/v1/Managers/bmc/NetworkProtocol /HTTPS/Certificates/0 (Invalid URL) returns ResourceNotFound. * Replace HTTPS certificate at /redfish/v1/Managers/bmc/NetworkProtocol /HTTPS/Certificates/1 with CertificateString not containing private key returns InternalError. Change-Id: I67f6014c3856c192b4141e6a92f173a9a8c8189e Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-15pcie: Remove duplicate DeviceType property checkJiaqing Zhao1-10/+0
When reading PCIe device information from DBus, "DeviceType" is checked twice, remove the duplicated code. Tested: Build pass. Get /redfish/v1/Systems/system/PCIeDevices/{Device} still has "DeviceType" property. Change-Id: I18e426f4cb22b8b751f6d7faf62d06f4966f1290 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-14EventService: Enhance inotify event filename handlingJiaqing Zhao1-3/+2
In kernel inotify, the inotify_event.name is padded to a mutiple of sizeof(inotify_event) with '\0' and len is the size of char[] name, not the actual size of name. So constructing the name string with std::string(name, len) constructs a string with all the '\0's, which is not equal to the filename. This patch uses std::string(name) so that the string does not contain these '\0's. Tested: Manually create/delete /var/log/redfish, confirmed handler is entered by log. Change-Id: Ibaa96dd5c47b0205541a6ee155daa593b2e2114d Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-14doc: add a testing doc as guidelines for commitsNan Zhou2-79/+129
Context: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/50742 is a small but important change that changes how http_connection works. Maintainers recommends doing a more complete testing for this type of change. I found that having some docs as reference when performing testing is helpful for every contributor. Add a document for different types of testing we want contributors to perform and include results in their commit messages. This doc will evolve. Also moved relevant sections in existing docs into this doc. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ia0b35950540ec6efaa813516d0e545c4b8f7c609
2022-04-13Add common url segments parserSzymon Dompke4-29/+192
This change is adding helper template function, which can be used both to validate and read segments from segments_view returned by boost_url parser. Number of segments is also validated - in case when argument count differs from them, false will be returned. In case when we want to validate only existence of a segment, special argument can be passed in its place: 'anySegment'. Reasoning why url_view was chosen instead of strings: - This way code generation is kept minimal. - There are multiple parse functions in boost_url with different rules, but all of them return url_view. This solution should accommodate every use case. Testing done: - Unit tests are added, passing. - Refactored part of telemetry to use this new approach, no regression spotted during simple POST/GET tests. Change-Id: I677a34e1ee570d33f2322a80dc1629f88273e0d5 Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
2022-04-13Update odata.type version of /redfish/v1/AccountService/Anjaliintel-211-1/+1
Redfish validator was failing and throwing below error: *** /redfish/v1/AccountService AccountService.v1_10_0.ExternalAccountProvider:OAuth2Service : Could not get details on this property (argument of type 'NoneType' is not iterable) Type (#AccountService.v1_5_0.AccountService), GET SUCCESS (time: 1.283549) complex @odata.id: Expected @odata.id to match URI link /redfish/v1/AccountService#/Oem/OpenBMC FAIL... "OAuth2Service" is added in v1_7_x+ versions of AccountService schema. Even though schema's are updated to v1_10_x, Still source is pointing to v1_5_x which is causing undefined type and failing Redfish validator. So I updated odata.type to AccountService.v1_10_0.AccountService". Tested: *** /redfish/v1/AccountService Type (#AccountService.v1_10_0.AccountService), GET SUCCESS (time: 1.306433) complex @odata.id: Expected @odata.id to match URI link /redfish/v1/AccountService#/Oem/OpenBMC PASS After change OAuth2Service property error got disappeared - Redfish validator does not show any such error. But, Due to increased version number, there can be any new properties (deprecated or new) error shown in redfish validator. ( Note: odata.id error exist before and after the fix, which can be fixed as separate commit) All AccountService related URI's worked as expected and validation got succeeded. Signed-off-by: Anjaliintel-21 <anjali.ray@intel.com> Change-Id: Ic73319cd649ecebbf7108863b2a72bcd2768d477
2022-04-12Skip on log entries not found in the message registrySui Chen1-6/+6
Because logs populated by fillEventLogEntryJson are expected to be found in the message registry log entries that get returned in this function should have non-empty message and severity, because of the way registries work. Currently, for a log entry that is not present in the registry, the function will use its log entry as-is and leave the message and severity fields empty. This can cause the Redfish Service Validator to generate an error. This change fixes the fillEventLogEntryJson function so that when a log message is not found in the registry, the message is not used for populating the response, and is logged for further analysis. TESTED: First populate an offending entry. echo "1970-01-01T00:00:47.991326+00:00 OpenBMC.1.0.ServiceStarted," > \ /var/log/redfish Then run the Service Validator. Before this change: URL: /redfish/v1/Systems/system/LogServices/EventLog/Entries/60 *** /redfish/v1/Systems/system/LogServices/EventLog/Entries/60 Type (LogEntry.v1_8_0.LogEntry), GET SUCCESS (time: 0) Severity: Empty string found - Services should omit properties if not supported Severity: Value Enum not found in ['OK', 'Warning', 'Critical'] Message: Empty string found - Services should omit properties if not supported FAIL... After: the above response disappears from the response, the Validator error disappears, and the following appears in the system journal: (1970-01-01 13:01:47) [WARNING "log_services.hpp":1129] Log entry not found in registry: 1970-01-01T00:00:47.991326+00:00 OpenBMC.1.0.ServiceStarted, Signed-off-by: Sui Chen <suichen@google.com> Change-Id: Ifa600d1de0e6e0cea33e9e8dfde621ee9d4e3325
2022-04-11sensor collection: implement efficient expand handlerNan Zhou1-30/+94
This change adds an efficient expand handler for $levels=1 expand at the sensors collection. Instead of Query one sensor at time, it reuses existing codes for Thermal and Power (which has AutoExpand), and queries the whole sensor at one query. It's more efficient than the default expand handler as well since the default handler stills query all the sensors and filter other sensors when querying a single sensor. Performance improves dramatically on a real hardware with 220+ sensors: Before this change, time wget -qO- 'http://localhost/redfish/v1/Chassis/xxx/Sensors?$expand=.($levels=1)' > /tmp/log_slow.json real 0m33.786s user 0m0.000s sys 0m0.000s After this change time wget -qO- 'http://localhost/redfish/v1/Chassis/xxx/Sensors?$expand=.($levels=1)' > /tmp/log_fast.json real 0m0.769s user 0m0.010s sys 0m0.010s TESTED:: 1. QEMU Redfish/IPMI passed 2. Validator passed (though it doesn't support query paramters) 3. Tested on real hardware. { "@odata.id": "/redfish/v1/Chassis/xxx/Sensors", "@odata.type": "#SensorCollection.SensorCollection", "Description": "Collection of Sensors for this Chassis", "Members": [ { "@odata.id": "/redfish/v1/Chassis/xxx/Sensors/abc", "@odata.type": "#Sensor.v1_0_0.Sensor", "Id": "abc", "Name": "abc", "Reading": 3.133, "ReadingRangeMax": 5.8500060148599005, "ReadingRangeMin": 0.0, "ReadingType": "Voltage", "ReadingUnits": "V", "Status": { "Health": "OK", "State": "Enabled" }, "Thresholds": { "LowerCritical": { "Reading": 2.205 }, "UpperCritical": { "Reading": 3.507 } } }, ], "Members@odata.count": 225, "Name": "Sensors" } Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I745a31d6fe8d0aac08d532ea976bfc1a4a40b19c
2022-04-11query parameter: add a way to delegate certain parameterNan Zhou3-5/+127
The generic query parameter handlers might not be performant, e.g., Expand in the sensor collections. This change adds a way to delegate query parameter processsing to redfish-core codes: 1. introduced a separate struct in the setUpRedfishRoute function, with which redfish-core codes can easily set delegation for each parameter; for example, the children patch of this PR will implement an efficient handler for sensor collection Expand, top, and skip. 2. introduced a separate Redfish route for delegation; this routes takes the struct described above and changes the query object so that query parameters are delegated. 3. in order to avoid copying Query objects and run delegation check twice, the |setUpRedfishRouteWithDelegation| function sets |delegated| so that callers can directly use it to determinte if delegation is needed, and what delegated Queries are Tested: 1. added unit tests 2. the default redfish route is still working correctly Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I77597ad7e8b40ac179d86dc9be1a35767cc61284
2022-04-08sensors: move callback from lambda to inline functions with bind_frontNan Zhou1-37/+36
bind_front + function is more readable than local lambdas. Tested: Tested sensor collection, works as expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ib3bd6d4249df97c4be5afcd1393477ed424f5de8
2022-04-08registries: remove hardcoded size of MessageEntry arraysJason M. Bills6-11/+10
The latest C++ no longer requires the size of the array to be hardcoded. This removes the hardcoded size to simplify changes to the message arrays. Tested: Confirmed that event Messages are still correctly generated. Signed-off-by: Jason M. Bills <jason.m.bills@intel.com> Change-Id: I29e6a4a02c247865c275cf4ff71587bc188d5957
2022-04-08Add BIOSAttributesChanged message entrySnehalatha Venkatesh1-1/+10
When BIOS attributes are changed via OOB (using Redfish PATCH operation) No Redfish event is logged. Added a Message Registry entry to inform that a set of BIOS attributes are changed via OOB. It will be logged after BIOS reset, during which attributes are re-populated with patched values. Changing the BIOS attributes via OOB is possible only through Redfish PATCH operation currently and not supported through IPMI. This event is implemented for the following review. https://gerrit.openbmc-project.xyz/c/openbmc/intel-ipmi-oem/+/52320 Tested: 1. Redfish validator - passed for this new addition. 2. Enable "BMC Remote Setup" and Set BIOS admin password. 3. Do BIOS reset. 4. Check for the attributes in redfish uri GET: /redfish/v1/Systems/system/Bios Response: Success 5. Patch any attribute. PATCH: /redfish/v1/Systems/system/Bios/Settings Body: { "data": { "serialDebugMsgLvl": "0x2" }} Response: Success 6. Do BIOS reset. 7. Verified in Redfish, Biosattribute change message populated. GET: /redfish/v1/Systems/system/LogServices/EventLog/Entries Response: { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/32635", "@odata.type": "#LogEntry.v1_8_0.LogEntry", "Created": "1970-01-01T09:03:55+00:00", "EntryType": "Event", "Id": "32635", "Message": "Set of BIOS Attributes changed.", "MessageArgs": [], "MessageId": "OpenBMC.0.1.BIOSAttributesChanged", "Name": "System Event Log Entry", "Severity": "OK" } Signed-off-by: Snehalatha Venkatesh <snehalathax.v@intel.com> Change-Id: Id5c41a40e996b36ab63c7b0cae7fb024f71914fe
2022-04-07hostlogger service: don't reference integeralsNan Zhou1-4/+4
Copying integerals is cheap, and generally is cheaper than copying references. Tested: compiles. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I5cb08445d6bc06ed1d0c86c27ca1db1bf4cce316
2022-04-07Remove unused modeString in translatePowerMode()Jiaqing Zhao1-2/+0
In systems.hpp:translatePowerMode(), modeString is defined but never used. Compiler also doesn't give a warning. Remove it. Tested: Build pass. Change-Id: Ic48c77f74a398bf74a2c874d6a6969efdd440a5f Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-06Use multi-depth readJson to handle PATCH NetworkProtocolJiaqing Zhao1-56/+30
The new multi-depth readJson simplifies the PATCH handler and removes 3 extra readJson calls. Tested: Verified PATCH /redfish/v1/Managers/bmc/NetworkProtocol works exactly the same as before, all modifiable properties are handled properly. Change-Id: I836010273b5150576d6bc33eae82acda2de70e67 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-06Add setUpRedfishRoute to all nodes in redfishEd Tanous29-944/+1637
For better or worse, the series ahead of this is making use of setUpRedfishRoute to do the common "redfish specified" things that need to be done for a connection, like header checking, filtering, and other things. In the current model, where BMCWEB_ROUTE is a common function for all HTTP routes, this means we need to propagate this injection call into the whole tree ahead of the requests being handled. In a perfect world, we would invent something like a REDFISH_ROUTE macro, but because macros are discouraged, the routes take a variadic template of parameters, and each call to the route has a .privileges() call in the middle, there's no good way to effect this change in a less costly manner. This was messaged both in the prior reviews, and on discord sourcing improvements on this pattern, to which none arose. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id29cc799e214edad41e48fc7ce6eed0521f90ecb
2022-04-05Fix missing success code in Account PATCHEd Tanous1-0/+4
Everywhere else in this file, we return messages::success when a property is patched, except for the password success case. This normally wouldn't matter much, but redfish-protocol-validator seems to want to use Password setting as its check for a number of protocol tests (probably because all Redfish implementations have settable passwords). This commit adds the appropriate message Tested: curl -vvvv --insecure --user root:0penBmc -X PATCH -d '{"Password": "0penBmc1"}' https://192.168.7.2/redfish/v1/AccountService/Accounts/root Now returns the Success message from the message registry. Redfish-protocol-validator PROTO_JSON_ACCEPTED tests now succeed, improving bmcwebs protocol score by 3 tests passing that were failing. Counts are 356 passing, 27 failed, 36 not tested. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iff1096ca590f956b29b2a3dd6c9510d2fe4a0037
2022-04-05Implement odata-version checksEd Tanous1-0/+13
The redfish protocol validator is a cruel.... cruel test. In it, it attempts to send odata-version headers that are not supported by the spec. bmcweb has never had a use for those headers, and they are optional to send, so bmcweb ignored them. This patchset fixes that. The exact wording of the standard is in the patch. Tested: curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1 Returns service root curl --insecure --user root:0penBmc -H "Odata-version: 4.0" https://192.168.7.2/redfish/v1 returns service root curl --insecure --user root:0penBmc -H "Odata-version: 4.1" https://192.168.7.2/redfish/v1 returns precondition failed message from base registry, and 501 code. Redfish protocol validator now shows REQ_HEADERS_ODATA_VERSION test passing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7d2f4bd9f6b7f03655d7e169ee20f45f9aaa73e3
2022-04-05Implement ExpandEd Tanous7-20/+513
Section 7.3 of the Redfish specification lays out a feature called "expand" that allows users to expand portions of the Redfish tree automatically on the server side. This commit implements them to the specification. To accomplish this, a new class, MultiAsyncResp is created, that allows RAII objects to handle lifetime properly. When an expand query is generated, a MultiAsyncResp object is instantiated, which allows "new" requests to attach themselves to the multi object, and keep the request alive until they all complete. This also allows requests to be created, while requests are in flight, which is required for queries above depth=1. Negatives: Similar to the previous $only commit, this requires that all nodes redfish nodes now capture App by reference. This is common, but does interfere with some of our other patterns, and attempts to improve the syntactic sugar for this proved unworkable. This commit only adds the above to service root and Computer systems, in hopes that we find a better syntax before this merges. Left to future patches in series: Merging the error json structures in responses. The Redfish spec isn't very clear on how errors propagate for expanded queries, and in a conforming we shouldn't ever hit them, but nonetheless, I suspect the behavior we have is sub-optimal (attaching an error node to every place in the tree that had an issue) and we should attempt to do better in the future. Tested (on previous patch): curl --insecure --user root:0penBmc https://localhost:18080/redfish/v1\?\$expand\=.\(\$levels\=255\) Returns the full tree Setting $levels=1 query returns only a depth of 1 tree being returned. Unit tests passing Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I874aabfaa9df5dbf832a80ec62ae65369284791d
2022-04-05Redfish: Query parameters: OnlyEd Tanous6-5/+175
Add the query parameter "only" for redfish. The specification is based on DSP0266_1.8.0. This commit is inspired by the commit that carries the same title, but is largely unique, namely, in that it adds the core feature to be able to recall handle with a new Response object, and make sure the result gets to the connection. It does this by swapping the handlers and implementing move semantics on the Response object. It definitely needs broken up into a few smaller patches, but it does pass the below tests without any apparent seg faults or ownership issues. It implements a number of cleanups that deserve their own patches, and will be split up accordingly, but for the moment, I think this is a good start to getting filter and expand support in the future. Tested: Validator passes (on previous patchset) ~$ curl -i -k -H "X-Auth-Token: $token" -X GET "https://${bmc}/redfish/v1/Systems" ~$ curl -i -k -H "X-Auth-Token: $token" -X GET "https://${bmc}/redfish/v1/Systems?only" Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I123d8ab8bcd88a0b63ff131f6b98548951989755
2022-04-05Add new option for query parametersEd Tanous3-0/+6
Query parameters in their initial incarnation will likely have security consequences. For example, requesting ServiceRoot with expand depth 999 would likely run most BMCs out of memory. This isn't a good reason to keep those features out of master, as there are a number of services (webui-vue for example) that would like to test against them, and identify the weaknesses. The goal with this option is to allow users to test, so we can determine things like the max depth we should support, which query params have security consequences and how to mitigate them, and other testing. The end goal would be for this option to be enabled by default. If it's removed entirely would depend on the impacts of supporting query params and is something we will have to discuss at a later date. Tested: Code compiles. Use of this option is added in next patchset in series. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I93ff31c938e4be2d92eb07b59a3288f8bacde2ac
2022-03-30Use url_view for telemetry urisSzymon Dompke5-18/+35
This change refactor telemetry code to use bmcweb utility function for uri construction, which is safe and preferred way, instead of string operations. Testing done: - Some basic GET operations done on Telemetry, no regression. Signed-off-by: Szymon Dompke <szymon.dompke@intel.com> Change-Id: I6de5d79a078944d398357f27dc0c201c130c4302
2022-03-30registry: Add PropertyValueExternalConflict registryRamesh Iyyar2-0/+39
- Added the PropertyValueExternalConflict message registry that might used to send when the request is failed due to some other resource state or configuration. Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com> Change-Id: Ibdb8c21e285079dbaea54b99f207f45892b24ea9
2022-03-30registry: Add PropertyValueResourceConflict registryRamesh Iyyar2-0/+45
- Added the PropertyValueResourceConflict message registry that might used to send when the request is failed due to some other resource state or configuration. Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com> Change-Id: I2c03aee88442f6abe55f2a9f574211b8214aa30c
2022-03-29service root: add ProtocolFeaturesSupportedNan Zhou2-1/+34
This commits adds a dummy ProtocolFeaturesSupported object in the service root. It indicates that none of the Query Parameter is supported. Future commits will add supports for OnlyMemberQuery, ExpandQuery, and so on. Tested: 1. unit test 2. passed QEMU Redfish (which contains Redfish Validator) test This commit is split from these changes: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38952 https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474 Credits to maxiaochao@inspur.com, ed@tanous.net, and zhanghch05@inspur.com. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I81ff856514528f63a462558a8f18fefe4369edae
2022-03-29Remove AsyncResp from openHandlerzhanghch057-21/+9
This change, moving the openHandler back to only supporting websocket disconnects and not 404s.Because AsyncResp is removed from openHandler. Tested: (from previous commit) Opened KVM in webui-vue and it works. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I793f05836aeccdc275b7aaaeede41b3a2c276595
2022-03-28Drop unused App.sslFile() methodJiaqing Zhao1-41/+0
App.sslFile() method is never called, the sslContext is generated in ensuressl::getSslContext() function now. So remove these unused code. Tested: Build pass. Change-Id: I2737462a3a2ec2e0dc792e5070e9e5a7244bc889 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-03-28script: specify the interpreter to envNan Zhou3-3/+3
Env is generally more portable than hardcoding path. This change also keeps all scripts consistent. Tested: all can run directly. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ia2636420e54fae24a5a339377de65957ed40cc7e