summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-01-12Add FabricAdapter schemaLakshmi Yadlapati7-0/+926
Will be used in commit https://gerrit.openbmc.org/c/openbmc/bmcweb/+/41216 From the Redfish schema "A FabricAdapter represents the physical fabric adapter capable of connecting to an interconnect fabric. Examples include but are not limited to Ethernet, NVMe over Fabrics, Gen-Z, and SAS fabric adapters." Tested: built bmcweb successfully and validator passes Change-Id: I9f8fb3bfc5b68a86b078b1261445437bdd5c550a Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-01-12Clean up http end_of_stream tracesMyung Bae1-1/+2
http::end_of_stream log is not properly detected and thus it is being traced as error. It will be fixed to be traced as warning so they do not show up when just error traces are enabled (new default) Here's the log we was getting: Jan 10 13:34:32 ever6bmc bmcweb[2496]: (2023-01-10 13:34:32) \ [ERROR "http_connection.hpp":784] 0x14bd360 Error while \ reading: end of stream Change-Id: I6ecee813c4f7806a676ba0ad3e4ab1a8f78747fd Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2023-01-12Aggregation: Improve prefix fixup matchingCarson Labrado4-87/+192
Utilize the new array of top level collection URIs to determine if a given URI in the response needs to have the aggregation prefix added. This removes the need to check for specific collections like /redfish/v1/UpdateService/FirmwareInventory which do not fit the generic format of /redfish/v1/<collection>. Future patches will use this same approach to improve the logic for initially determining if and how a request should be aggregated. This patch also adds a series of unit tests for the function responsible for adding a prefix to a given URI. Cases covered include valid URIs that involve a selection of aggregated resources, top level collection URIs, other invalid URIs, and URIs with a trailing "/". Tested: Unit tests pass. Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I676983d3c77ae3126c04e9f57ad8698c51df2675
2023-01-12Refactor mtls callbacks into their own fileEd Tanous2-161/+174
Mutual TLS is non-trivial enough that it definitely shouldn't be done in an inline lambda method. This commit moves the code. Tested: WIP. This is a pretty negligible code move; Minimal touch testing should be good. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7a15a6bc66f4d8fb090411509549628f6d1045a5
2023-01-12Optimize task event registryEd Tanous1-79/+46
Very similar to the optimizations done for the other registries, do the same for task service, using the common implementations of the registries to deduplicate the strings present in the registry. Tested: GET /redfish/v1/Registries/TaskEvent/TaskEvent Returns the same result as previously, with the exception of an updated schema version. Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I25bfda5d60f9dee584c9e47a5b7b995b7a14f841
2023-01-11Fix parameter type for calling getSubTreePaths methodGeorge Liu1-1/+1
The interface attribute type that calls the getSubTreePaths method should use std::string_view instead of const char*. bump is failing. https://gerrit.openbmc.org/c/openbmc/openbmc/+/60221 https://jenkins.openbmc.org/job/ci-openbmc/15513/distro=ubuntu,label=docker-builder,target=witherspoon/console Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I9dc4a710da0bdcec91a73ded89a253baa04a3550
2023-01-11Refactor GetSubTreePaths methodGeorge Liu22-192/+202
Since the GetSubTreePaths method has been implemented in dbus_utility and this commit is to integrate all the places where the GetSubTreePaths method is called, and use the method in dbus_utility uniformly. Requires https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/60020 to build. Tested: Redfish Validator Passed Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie4140d4484a7e4f4b943013f4371ffd2d44a22e9
2023-01-10Use actionParams struct instead of fieldsPrzemyslaw Czarnowski1-37/+33
Make validateParams use of actionParams (InsertMediaActionParams structure) instead of fields one by one. This will make possible to remove reference to crow::Response in lambda containing vaildateParams structure. Tested: none, code change Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Change-Id: I0f2ac76f6f7e578cb29527cd1e8f1d8ba9e94960
2023-01-10Use intermediate bmcweb object filesEd Tanous1-2/+11
If you look at an OpenBMC build, every source file is compiled for every source unit. This is pretty wasteful, but meson documents how to reuse object files between link units. This has a couple benefits: - Source files are only compiled once - There are less likely to be unit-test specific binary differences (if, for example, the unit tests used different compiler flags). - Errors in a source file only appear once in the output, instead of 10 times. On my 36 core Xeon, a normal build went from 2m38s down to 2m34s, which is quite underwhelming, and less than you'd expect from a change this large, but it turns out that if you have more parallelism than you have compile units, building things twice doesn't appear to matter much. With that said, if I simulate a smaller machine, using -J 8, the build time with this commit remains at 2m38s, whereas the commit previous to this takes 4m48s, so clearly there's some benefit here. This regression appears to have been caused by 0ad63df8aa8ab60f74395794d8ffce64c82ee031 which caused us to build multiple executables (one per unit test). This fixes the regression. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib77e8679b69e0f2242f65c20b129f2fb8e370edb
2023-01-08Aggregation: Generate collections from schemaCarson Labrado4-0/+357
In aggregation we need to account for when a satellite BMC supports a resource collection that the aggregating BMC does not. We need to add links in responses from upstream resources to indicate that these satellite only resources exist. These top level collections do not always have the location format of /redfish/v1/<collection_id>. We determine all of those from the schema rather than hardcoding a few choice exceptions that do not fit that format such as /redfish/v1/UpdateService/FirmwareInventory. This patch is the first step in accomplishing this. We parse all xml schema files in order to determine what are the top level collection URIs. For URIs that are upstream from top level collections we'll be able to derive what URIs could appear in the response which are also on the same path to a top level collection. The xml files for resources that aren't currently supported by bmcweb are ignored when creating the schema index and later deleted once the above parsing completes. Later patches will use this information to make sure that we are properly handling all schema defined top level collections. Tested: Compiles with aggregation enabled Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: Icff825f4e4e9d84c96254561350f82839abdc074
2023-01-05Add ServiceProviderNotifyAbhishek Patel1-2/+46
Add ServiceProviderNotify property that can be used to indicate that this event log should be notified to the service provider, if that is implemented on the system. ServiceProviderNotify is an enum. Supported options are - "NotSupported", "Notify" and "Inhibit". The dbus interface and all implementations have been moved to an enum with the default value of NotSupported. When the value is NotSupported, this property is left off Redfish. For more details refer to https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/47683 Tested: Manually tested on the system, Run Redfish validator. Found no error. ''' curl -k https://$bmc/redfish/v1/Systems/system/LogServices/EventLog/Entries { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries", "@odata.type": "#LogEntryCollection.LogEntryCollection", "Description": "Collection of System Event Log Entries", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", "@odata.type": "#LogEntry.v1_9_0.LogEntry", "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1/attachment", "Created": "1970-01-01T00:04:20.865+00:00", "EntryType": "Event", "Id": "1", "Message": "xyz.openbmc_project.Software.Image.Error.ImageFailure", "Modified": "1970-01-01T00:04:20.865+00:00", "Name": "System Event Log Entry", "Resolved": false, "Severity": "Critical" }, .... .... ], "Members@odata.count": 49, "Name": "System Event Log Entries" } ''' busctl set-property xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/99 xyz.openbmc_project.Logging.Entry ServiceProviderNotify s xyz.openbmc_project.Logging.Entry.Notify.Notify busctl get-property xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/99 xyz.openbmc_project.Logging.Entry ServiceProviderNotify Entry ServiceProviderNotify Signed-off-by: Abhishek Patel <Abhishek.Patel@ibm.com> Change-Id: I774bfec157481ccc9b4966bf5e8cc8f7d9a06fd0 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-01-04Problem with RemoteRoleMapping JSONJorge Cisneros1-9/+2
The current LDAP group map on /redfish/v1/AccountService is incorrect and is creating a bad JSON response. instead of an array of objects, is creating a nested array of objects. The problem is visible on the website adding a new LDAP group map, it will show 2 empty rows instead of one with the correct data. The current JSON data is: "RemoteRoleMapping": [ [ { "RemoteGroup": "groupname" } ], [ { "LocalRole": "Operator" } ] ], The correct JSON is: "RemoteRoleMapping": [ { "LocalRole": "Operator", "RemoteGroup": "groupname" } ], The tests redfish/account_service/test_ldap_configuration crashed BMCWEB generates around 9 core dump files. Tested: redfish/account_service/test_ldap_configuration passed the tests Adding a new LDAP group map on the website, showing the correct data, Change-Id: I5de7db372ceff1cc596da2b04f5fd730415f7216 Signed-off-by: Jorge Cisneros <jcisneros3@lenovo.com>
2023-01-03Remove old TODOEd Tanous1-5/+0
This TODO was implemented long ago by DMTF. Remove the comment. Tested: Comment only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4b0fc7c6fefa316d1cf824711d542f17a6f1a682
2023-01-03Ignore clang warningEd Tanous1-0/+1
Clang warns on this enum no matter what we do. Rather than adding all 27 entries of the boost::beast::verb to this, lets just ignore the warning. Tested: Code compiles on clang without warnings Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iba5809d8f855abe7f040d81d6052eb385be8f5a1
2023-01-03Remove extra semi colonsEd Tanous1-8/+0
Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I710b68218f5df32088a0ce90250763cd765b054a
2023-01-03Add missing inline on function prototypeEd Tanous1-1/+1
Clang correctly notes that this function is missing an inline definition. Tested: Code compiles further on clang (other failures still present). Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7d6420e2bb1c0c9360ff8427857aa916142c5a66
2023-01-03Fix sensor overrideEd Tanous3-16/+69
c1d019a6056a2a0ef50e577b3139ab5a8dc49355 Sensor Optimization Recently changed the way Ids were calculated in the sensor subsystem. Unfortunately, it wasn't clear to the author that this would effect the sensor override system, which relies on matching up a member ID with a dbus path, and was broken by this change. This commit breaks out the code to calculate the type and name from a given URI segment into a helper method. Tested: Inspection only. Very few systems support this feature. Code appears more correct than previously, which is known broken, so the lack of testing here seems reasonable. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9aa8099a947a36b5ce914bc07ae60f1ebf0d209b
2022-12-29cppcheck: Fix Ineffective call of function 'substr'Ed Tanous1-2/+2
This likely has no performance implications in practice, but getting a clean cppcheck run is good. Suggestion was implemented per cppcheck. Tested: This is in the deprecated rest API. Not sure how much testing we need to do. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1658697730ac07c7cdefd2b73c80ee65fba4dedb
2022-12-29Add missing const in update serviceEd Tanous1-1/+1
Per cpp core guidelines, this type should be const. Tested: Code compiles. Trivial const change. cppcheck no longer warns on this line. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I04aae41701ba1203ff4a68f0b06df2459ee7bb2f
2022-12-28Generate includes for all schemasEd Tanous42-8/+2569
Even for schemas we ignore, we should still generate the enums for them, just to keep changes like [1] smaller. Tested: Code compiles. No functional binary change. [1] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/55215 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I78adf1204a319bc14900152f94161afea21f2e07
2022-12-28Add CBOR supportEd Tanous2-4/+11
CBOR is a more efficient way to represent json, and something that, as you can see from this patch, is relatively trivial to implement in our current nlohmann json handlers. This allows users that specify an accepts header of "application/cbor" to request the BMC produce a cbor response. This feature adds 1520 bytes (1.48KB) to the binary size of bmcweb. For ServiceRoot GET /redfish/v1 Accepts: application/json - returns json GET /redfish/v1 Accepts: application/cbor - returns cbor GET /redfish/v1 Accepts: */* - returns json GET /redfish/v1 Accepts: text/html - returns html GET /redfish/v1 no-accepts header - returns json For service root, CBOR encoding drops the payload size from 1520 bytes on my system, to 1021 byes, which is a significant improvement in the number of bytes we need to compress. Redfish-service-validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I847e678cf79dfd7d55e6d3b26960c419e47063af
2022-12-28Add missing usage of new verb class in routerSnehalatha Venkatesh1-4/+4
Despite introduction of a new enum class containing method verbs, some functions were still using the one from Boost. This had caused erratic behaviour when trying to create a websocket (e.g. /nbd/<str>), because enum value of old type was compared to the one of new type. This change fixes that. Tested: Verified that websockets are now created without errors. Change-Id: I52c874de9b02463618143d3b031f5c795dd42ad8 Signed-off-by: Michal Orzel <michalx.orzel@intel.com> Signed-off-by: Snehalatha Venkatesh <snehalathax.v@intel.com>
2022-12-28Fix some use-after-move issuesEd Tanous1-79/+77
This diff looks bad. The only thing that changed functionally is changing: password(std::move(password)), roleId(std::move(roleId)) in the labmda capture to password, roldId because password and roleid are getting used later. Unfortunately, clang decides to rearrange this whole lambda. Tested: Passes cppcheck. ''' curl -vvvv --insecure --user root:0penBmc -X PATCH -d '{"Password": "0penBmc1"}' https://192.168.7.2/redfish/v1/AccountService/Accounts/root ''' Succeeds at patching the root password. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I97b10a40d0b271b211bf4e6c09888d3cd568a3d0
2022-12-22Use owning strings for aggregator URIEd Tanous1-2/+2
Clang correctly notes that, because the segments() object is an rvalue, and is destroyed after the std::string_view is used on the next line, this is technically undefined behavior. Make these use owning std::strings instead of std::string_view to avoid the lifetime problem. Tested: Enabled aggregation without including a satellite config. Sending a GET request to /redfish/v1/Chassis/5B247A_Test returned a 404 due to hitting one of the sections of changed code. The other section is not currently reachable, but uses the same type of change. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1b2b2ad444e2718c0cb167f4506ea1d0915b3a5b Signed-off-by: Carson Labrado <clabrado@google.com>
2022-12-22Fix cppcheck errorEd Tanous1-29/+15
cppcheck comments that this can be const. Unfortunately, this looks like a false positive, where cppcheck cannot see through the std::replace template. Tested: This is in the set pid loop handler that doesn't have any good tests with it. Code compiles, and only inspection is possible at this time. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I21eaadcc37b2f3993e63b39d471cbf118d88119a
2022-12-22Avoid copyEd Tanous1-1/+1
cppcheck warns that this is a copy, so fix it. Tested: cppcheck no longer warns on this line. Unfortunately, virtual media does not have a backend, so this is dead code. No way to test at this point. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1e98ca63ee346ad683844e5637a173f64286102a
2022-12-21Return bad request if can't constructGunnar Mills1-0/+2
If given a bad URI, e.g. "https://$bmc/?a=id;" return http bad request (400) like we do other places, e.g. a few lines below. Certain scanners expect to see bad request when crawling and probing for vulnerabilities and using not valid URIs. Just dropping the connection causes errors with these scanners. They think connection problem or worse the server was taken down. Tested: Tested downstream https://$bmc/?a=id; returns bad request. Change-Id: I99a52d4c5e7f366046c5de1cf22c4db95ab39e13 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2022-12-21Change variable scopesEd Tanous12-30/+21
cppcheck correctly notes that a lot of our variables can be declared at more specific scopes, and in every case, it seems to be correct. Tested: Redfish service validator passes. Unit test coverage on others. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416
2022-12-20Correct boost 1.81.0 expected hashCarson Labrado1-1/+1
The expected hash value is incorrect resulting in meson failing when downloading boost 1.81.0. Updates the expcted value to be the actual hash value. Tested: Boost 1.81.0 is downloaded by meson when it does not exist on the local machine. All tests pass. Run-time dependency Boost found: NO (tried system) Downloading boost source from https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.bz2 Download size: 118797750 Downloading: .......... Executing subproject boost Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I36f26ec883bd08922fda3e5dc3a272bc4ef496a6
2022-12-16Restrict use of subfolder in configfiles pathcm-jishnu1-3/+6
GET function on the config files path now lists all the contents including sub directories. Creation of subdirectories under config files is not allowed from the UI, however its possible to create manually. If we try to access a subfolder with GET command, bmcweb handle the folder name as file name and crashes trying to open. Hence we limit the use of subfolder under config files by not listing them in the response of the GET command. And returning an error if the user is trying to run a GET on subfolder created manually. Tested: Create subfolder under configfiles path curl -k -H "X-Auth-Token: $bmc_token" -X GET -D patch1.txt https://${bmc}/ibm/v1/Host/ConfigFiles Without fix: Lists all contents of the ConfigFiles folder With Fix: lists only the regular files Run the command with subfolder curl -k -H "X-Auth-Token: $bmc_token" -X GET -D patch1.txt https://${bmc}/ibm/v1/Host/ConfigFiles/testfolder Without fix: bmcweb crashes With the fix: “Description”: “Resource Not Found” Change-Id: I71ef5523c6bc425e880a28a6e1175c677ef0a102 Signed-off-by: Jishnu C M <jishnunambiarcm@duck.com>
2022-12-16Correct the dhcp object pathJian Zhang1-3/+2
Due to the path of the dhcp has been changed from `/xyz/openbmc_project/network/config/dhcp` to `/xyz/openbmc_project/network/dhcp`. Cause cannot get/set the dhcp configuration. See: https: //gerrit.openbmc.org/c/openbmc/phosphor-networkd/+/58725 Tested: ``` Without internal error. ~# curl -k -X PATCH -H "X-Auth-Token: $token" https://$bmc/redfish/v1/Managers/bmc/EthernetInterfaces/eth1 \ --data-raw '{"DHCPv4":{"DHCPEnabled":false}}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request completed successfully.", "MessageArgs": [], "MessageId": "Base.1.13.0.Success", "MessageSeverity": "OK", "Resolution": "None" } ] } ``` Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com> Change-Id: Ib455cbe69c47b3075321a8225a5a69bff136dbe8
2022-12-15Prepare for boost::url upgradeEd Tanous17-126/+79
The new boost URL now interops properly with std::string_view, which is great, and cleans up a bunch of mediocre code to convert one to another. It has also been pulled into boost-proper, so we no longer need a boost-url dependency that's separate. Unfortunately, boost url makes these improvements by changing boost::string_view for boost::urls::const_string, which causes us to have some compile errors on the missing type. The bulk of these changes fall into a couple categories, and have to be executed in one commit. string() is replaced with buffer() on the url and url_view types boost::string_view is replaced by std::string_view for many times, in many cases removing a temporary that we had in the code previously. Tested: Code compiles with boost 1.81.0 beta. Redfish service validator passes. Pretty good unit test coverage for URL-specific use cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8d3dc89b53d1cc390887fe53605d4867f75f76fd
2022-12-13Fix for incorrect Task Progress and State valuesGayathri Leburu1-13/+10
While performing the firmware updates, task will be created for tracking the background update progress and state. There are error associated with that code currently. Errors on TaskId's: - Internal errors "Messages": [ .... { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request failed due to an internal service error. The service is still operational.", .... } ] - Always task is in RUNNING state. "PercentComplete": 0, "TaskState": "Running", Issue details: - Percentage: The "Progress" property in D-Bus interface "xyz.openbmc_project.Software.ActivationProgress" is of type "uint8_t" but bmcweb is reading type as string and that is leading to failure and invalid values. - TaskState: TaskState is read from d-bus after recieving associated signal but that is not updated properly and that caused the failure. this commit corrects the same. Tested: After fix, task which is created for firmware update is showing correct "PercentageComplete" and 'TaskState". "PercentComplete": 100, "TaskState": "Completed", Signed-off-by: Gayathri Leburu <gayathri.leburu@intel.com> Signed-off-by: moni kumar <monix.kumar@intel.com> Signed-off-by: AppaRao Puli <apparao.puli@intel.com> Change-Id: I0354cdecc9d9ddd47b017591402fd7b3149d12ca
2022-12-13black: re-formatPatrick Williams2-20/+12
black and isort are enabled in the openbmc-build-scripts on Python files to have a consistent formatting. Re-run the formatter on the whole repository. Change-Id: I00a6615fdb2b47ffee38e4bf649dd644eb636844 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2022-12-12Mark redfish-protocol-validator 100% passingEd Tanous1-1/+1
Redfish, the final frontier. These are the voyages of bmcweb. Its five-year mission: to explore strange new protocols, to seek out new corner cases and new segmentation faults, to boldly go where no web-server has gone before. This commit marks a journey that has taken years, getting a fully compliant, open source Redfish instance. While there is still quite a few things to improve, Redfish Protocol Validator passing means that bmcweb is capable of implementing all the "shall" statements in the protocol standard that are being tested. A great thanks go out to all the 173 unique contributors that got it to this point. Tested: Documentation only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I786d194c602e4a424f15ddea180da939535e48e9
2022-12-12Fix python packaging problemEd Tanous2-36/+35
Python packaging seems to have changed to be much more stringent about what version strings is accepts. It's not clear why this was done, but we need a fix to unbreak CI. This commit adds more parsing code into the script to parse out version numbers from the form of LogEntry.v1_2_3 to split them up into a custom class, and sort manually. Despite dropping the dependency, this ends up dropping a net 7 lines of code compared to using the library, so it seems worth it, especially given the breaking API change. One seemingly unrelated change was that we were adding schema folders to the sort lists, which don't sort well because they have no version numbers or extensions. This fixes to only add individual files to the list of things to sort. Tested: Code no longer crashes. Running update_schemas.py generates the same result (with one minor same-prefix sort order change). Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1a792ffb4ad7bc71637ab1aa0648a245949aeeee
2022-12-09Make inventory get inventory pathsEd Tanous1-1/+1
A recent regression causes failures on Thermal and Power paths that have to grab inventory items. This commit changes to search for the right path. Tested: Gunnar tested on a Witherspoon. No longer see Internal Errors. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0f7468ecf948f3cbfecb20c9ad470dced370ad3a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2022-12-09Add Accuracy property to sensorsGeorge Liu1-0/+2
Base on Sensor.v1_2_0.json[1], add the Accuracy property to sensors. At present, the D-Bus interface[2] has been exposed in the phosphor-hwmon repo[3], and this function will be synchronized to the dbus-sensor repo in the future. [1]http://redfish.dmtf.org/schemas/v1/Sensor.v1_2_0.json [2]https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/53569 [3]https://gerrit.openbmc.org/c/openbmc/phosphor-hwmon/+/57839 Tested: built bmcweb successfully and validator passes get Accuracy: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/ Chassis/chassis/Sensors/temperature_inlet { "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/temperature_inlet", "@odata.type": "#Sensor.v1_2_0.Sensor", "Accuracy": 5.0, "Id": "Sensors_inlet", "Name": "inlet", ... } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie51356d810f63ba70c56ce702d6bbeb97e279530
2022-12-09Remove ObjectManager search code in sensorsEd Tanous1-152/+34
Per [1], daemons implementing sensors are supposed to implement an ObjectManager at /xyz/openbmc_project/sensors. Once this is made consistent, there is no need for this complex code to search for an ObjectManager instance, when we can simply look it up. This commit deletes the ObjectManager search code, which saves a Dbus call for any sensor read done within thermal or sensor schemas. This does have the negative of requiring that ObjectMapper implements its ObjectManager on "/". Considering there is only one implementation of ObjectMapper, this seems reasonable to hardcode. Tested: Redfish Service Validator passes. ''' curl --insecure --user root:0penBmc https://192.168.10.156/redfish/v1/Chassis/Tyan_S7106_Baseboard/Thermal ''' returns the sensors on an S7106 platform. [1] https://github.com/openbmc/phosphor-dbus-interfaces/blob/991b2b8bdbc950f2a85aebfc29d1b34ea3264686/yaml/xyz/openbmc_project/Sensor/Value.interface.yaml#L18 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I69071848c685c33320d920d9faec16e5a1b563ca
2022-12-08Generate Redfish enums from schemasEd Tanous54-42/+4162
OpenBMC tends to have a significant problem in doing the appropriate lookups from the schema files, and many bugs have been injected by users picking a bad enum, or mistyping the casing of an enum value. At the same time, nlohmann::json has recently added first class support for enums, https://json.nlohmann.me/features/enum_conversion/ This commit attempts to build a set of redfish includes file with all the available Redfish enums in an easy to use enum class. This makes it very clear which enums are supported by the schemas we produce, and adds very little to no extra boilerplate on the human-written code we produced previously. Note, in the generated enum class, because of our use of the clang-tidy check for macros, the clang-tidy check needs an exception for these macros that don't technically follow the coding standard. This seems like a reasonable compromise, and in this case, given that nlohmann doesn't support a non-macro version of this. One question that arises is what this does to the binary size.... Under the current compiler optimizations, and with the current best practices, it leads to an overall increase in binary size of ~1200 bytes for the enum machinery, then approximately 200 bytes for every call site we switch over. We should decide if this nominal increase is reasonable. Tested: Redfish protocol validator runs with same number of failures as previously. Redfish Service Validator passes (one unrelated qemu-specific exception) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7c7ee4db0823f7c57ecaa59620b280b53a46e2c1
2022-12-08Aggregation: Detect and fix all URI propertiesCarson Labrado4-32/+80
There are a number of properties of Type "string (uri)" for which we do not currently support adding prefixes. This patch adds support for all existing URI properties which are missed by the existing implementation. This change will be needed by future patches which will expand aggregation support to all top level collections defined by the schema. Those collections that are not currently supported include properties whose URIs should be fixed, but would be missed by the existing implementation. Tested: New unit test passes. URI properties are still handled correctly. ```shell curl localhost/redfish/v1/Chassis/5B247A_<chassisID> { "@odata.id": "/redfish/v1/Chassis/5B247A_<chassisID>", "@odata.type": "#Chassis.v1_16_0.Chassis", "Actions": { "#Chassis.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Chassis/5B247A_<chassisID>/ResetActionInfo", "target": "/redfish/v1/Chassis/5B247A_<chassisID>/Actions/Chassis.Reset" } }, ... } ``` Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I3b3e06ee3191564d266598f7bc9f1641e6fcb333
2022-12-07clang-ignore: remove unneeded filePatrick Williams1-1/+0
openbmc-build-scripts by default uses git-ls-files and so does meson. There is no reason to add untracked files into the .clang-ignore. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ie308bf5d8d18eadcfe8f4943b467f4f61a92f289
2022-12-07markdownlint: fix all warningsPatrick Williams13-349/+353
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I1402cbd84c916792ca2fc0ad0f34db661cbdfa72
2022-12-07format: reformat with latest openbmc-build-scriptsPatrick Williams17-528/+755
Reformat the repository using the latest from openbmc-build-scripts. Add the `static/redfish` directory to be ignored by prettier since these files come from elsewhere and having the ability to do a direct diff is handy. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I74464d6f97047b4888a591e0d8a4f5ca970ac69e
2022-12-07log_service: Fix behavior of getting single PostCode entryJiaqing Zhao1-78/+82
Currently getting single PostCode entry returns a LogEntryCollection with the specified LogEntry in its Members. Since Redfish Service Validator does not follow the links in LogServiceCollection[1], such unexpected behavior passes the validator. This commit makes it return the LogEntry itself (or 404 Not Found) when requesting it. Fixes Github issue #236 (https://github.com/openbmc/bmcweb/issues/236) [1] https://github.com/DMTF/Redfish-Service-Validator/issues/519 Tested: * Confirmed getting a valid PostCode entry now returns a LogEntry, and getting invalid entries like B0-1, B1-0, B1-999 or 123 (Not properly- formatted ID) responds with 404 Not Found. * Get PostCode log entries collection still returns LogEntryCollection containing first 1000 PostCode entries by default. * Redfish Service Validator passed. Change-Id: Ice6b8742caea96ad3d436d57898202fe7362b150 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-12-07Implement If-Match header in Http layerEd Tanous4-16/+116
If-Match is a header in the HTTP specification[1] designed for handling atomic operations within a given HTTP tree. It allows a mechanism for an implementation to explicitly declare "only take this action if the resource has not been changed". While most things within the Redfish tree don't require this level of interlocking, it continues to round out our redfish support for the specific use cases that might require it. Redfish specification 6.5 states: If a service supports the return of the ETag header on a resource, the service may respond with HTTP 428 status code if the If-Match or If-None-Match header is missing from the PUT or PATCH request for the same resource, as specified in RFC6585 This commit implements that behavior for all handlers to follow the following flow. If If-Match is present Repeat the same request as a GET Compare the ETag produced by the GET, to the one provided by If-Match If they don't match, return 428 if they do match, re-run the query. [1] https://www.rfc-editor.org/rfc/rfc2616#section-14.24 As a consequence, this requires declaring copy and move constructors onto the Request object, so the request object can have its lifetime extended through a request, which is very uncommon. Tested: Tests run on /redfish/v1/AccountService/Accounts/root PATCH with correct If-Match returns 200 success PATCH with an incorrect If-Match returns 419 precondition required GET returns the resource as expected Redfish service validator passes Redfish protocol validator passes! ! ! ! ! Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I530ab255259c32fe4402eb8e5104bd091925c77b
2022-12-06Code move to prevent circular dependencyEdward Lee2-8/+8
While implementing https://gerrit.openbmc.org/c/openbmc/bmcweb/+/57932, there has been an issue where there is a circular dependency between routing.hpp and privileges.hpp. This code move predates this change to resolve it before implementing the heart of redfish authz. Circular dependency will occur when we try to use the http verb index variables in privilege.hpp. If this occurs routing.hpp and privilege.hpp will co-depend on each other and this code move prevents this from occuring. Tested: bitbake bmcweb Code compiles (code move only) Redfish Validator passed on next commit Signed-off-by: Edward Lee <edwarddl@google.com> Change-Id: I46551d9fe222e702d239ed3ea6d3d7e505d488c8
2022-12-06Make router take up less space for verbsEd Tanous4-18/+153
As is, the router designates routes for every possible boost verb, of which there are 31. In bmcweb, we only make use of 6 of those verbs, so that ends up being quite a bit of wasted space and cache non-locality. This commit invents a new enum class for declaring a subset of boost verbs that we support, and a mapping between bmcweb verbs and boost verbs. Then it walks through and updates the router to support converting one to another. Tested: Unit Tested Redfish Service Validator performed on future commit Signed-off-by: Ed Tanous <edtanous@google.com> Signed-off-by: Edward Lee <edwarddl@google.com> Change-Id: I3c89e896c632a5d4134dbd08a30b313c12a60de6
2022-12-05python: fix flake8 warningsPatrick Williams2-9/+7
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I6bcc6c72e1855c7de7c8b1e88cbab01e92b4070d
2022-12-05Prevent unconditionally writing over the LinkStatusJohnathan Mantey1-2/+1
The NIC LinkStatus was being assigned a LinkUp or NoLink value depending on whether the NIC is enabled. Subsequent code unconditionally overwrites the LinkStatus. The LinkStatus needs to take into account the NIC enabled state as well as the link up/down state. Tested: Confirmed NIC enabled/link active resulted in LinkUp. Confrimed NIC enabled/no-carrier resulted in LinkDown. Connfimred NIC disable resulted in NoLink. Change-Id: Iece3686cac9714e427b0e100f486a4ced334f7af Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>