summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-01-19Add the GetObject method to dbus_utilityGeorge Liu7-102/+90
There are currently many files that use the GetObject method. Since they are a general method, they are defined in the dbus_utility.hpp file and refactors them. Tested: Built bmcweb successfully and Validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If2af77294389b023b611987252ee6149906fcd25
2023-01-19Add Get for PCIe property LanesInUseMyung Bae2-1/+15
Added Redfish property 'LanesInUse' to PCIeDevices under redfish/v1/Systems. LanesInUse maps to dbus LanesInUse property for the Inventory.Item.PCIeDevice interface. Note: GUI might map this property to 'LinkWidth' Tested: 1) Redfish validator passed 2) Curl testing curl -k <token> \ https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card8 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", ... "PCIeInterface": { "LanesInUse": 16, "PCIeType": "Gen4" }, ... } Signed-off-by: Myung Bae <myungbae@us.ibm.com> Change-Id: I896abe44f55414f25d01c5a93a31bb585264657e
2023-01-18Fix a boatload of #includesEd Tanous81-297/+378
Most of these missing includes were found by running clang-tidy on all files, including headers. The existing scripts just run clang-tidy on source files, which doesn't catch most of these. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic741fbb2cc9e5e92955fd5a1b778a482830e80e8
2023-01-17Refactor ipv4VerifyIpAndGetBitcountEd Tanous1-64/+54
Boost has a number of ip related functions that can do a lot of this parsing for us, we should make use of them. Unfortunately, boost::asio::network_v4[1] doesn't have a no-throw variant of this constructor. It's not clear if this was an intentional omission, but for the moment, this patchset chooses to reimplement the mask code in-place for the moment. Even with this, the code is still simpler than what was present. [1] https://www.boost.org/doc/libs/1_80_0/doc/html/boost_asio/reference/ip__network_v4/network_v4.html Tested: Unit tests pass. Pretty good coverage. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia50b50ce0096a5acbb9da814ee15aa8edbfe0e31
2023-01-17Add unit tests for ipv4VerifyIpAndGetBitcountEd Tanous1-1/+89
Per the title, add unit tests for this function. Tested: Unit tests pass Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ifdd9c314d2fa62ae3fa3b8f8150fcdd224a7eb03
2023-01-17Add check for globalsEd Tanous18-24/+55
We don't follow this cpp core guidelines rule well. This is something that we should aspire to cleaning up in the future, but for the moment, lets turn the rule on in clang-tidy to stop the bleeding, add ignores for the things that we know need some better abstractions, and work on these over time. Most of this commit is just adding NOLINTNEXTLINE exceptions for all of our globals. There was one case in the sensor code where clang correctly noted that those globals weren't actually const, which got missed because of the use of auto. Tested: CI should be good enough for this. Passes clang-tidy. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ieda08fee69a3b209d4b3e9771809a6c41524f066
2023-01-14LogService: Use DeleteAll DBus method in clearDumpClaire Weinan2-113/+38
Update the clearDump() implementation to call the DeleteAll D-Bus method instead of iterating through D-Bus objects representing individual log entries and calling the Delete D-Bus method on each one. (It's more efficient for phosphor-debug-collector to iterate through entries in its DeleteAll method handler than for bmcweb to iterate through them.) It seems like clearDump() wasn't originally implemented using DeleteAll because dumps of various types were under the same D-Bus path namespace at the time and there wasn't a way to selectively clear dumps of only a specific type. The commit at [1] put different dump types under different path namespaces (enabling us to now use DeleteAll). Now clients should see a bit of performance improvement when running the ClearLog action on dump LogServices, due to the reduced number of D-Bus method calls needed to execute ClearLog. Also updated getDumpServiceInfo() to populate the ClearLog action for dump LogServices based on whether their dump manager object implements xyz.openbmc_project.Collection.DeleteAll. Tested: Cleared the fault log containing 100 entries. Ran with the time command several times before and after the change: ``` time curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/FaultLog/Actions/LogService.ClearLog ``` Before the change, "real" time reported was ~1.2s. After the change, "real" time reported was ~0.4s. Forced creation of dump entries and then ran Redfish ClearLog action on each dump type: ``` curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/FaultLog/Actions/LogService.ClearLog curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog ``` Then verified that there were no dump LogService entries afterwards: ``` curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Entries curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Managers/bmc/LogServices/FaultLog/Entries curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Systems/system/LogServices/Dump/Entries ``` Also verified that the corresponding D-Bus objects were gone from the D-Bus tree after running ClearLog on each dump type: Before ClearLog: busctl tree xyz.openbmc_project.Dump.Manager `-/xyz `-/xyz/openbmc_project `-/xyz/openbmc_project/dump |-/xyz/openbmc_project/dump/bmc | `-/xyz/openbmc_project/dump/bmc/entry | `-/xyz/openbmc_project/dump/bmc/entry/101 |-/xyz/openbmc_project/dump/faultlog | `-/xyz/openbmc_project/dump/faultlog/entry | |-/xyz/openbmc_project/dump/faultlog/entry/11 | |-/xyz/openbmc_project/dump/faultlog/entry/12 | |-/xyz/openbmc_project/dump/faultlog/entry/13 | |-/xyz/openbmc_project/dump/faultlog/entry/14 | |-/xyz/openbmc_project/dump/faultlog/entry/15 | |-/xyz/openbmc_project/dump/faultlog/entry/16 | |-/xyz/openbmc_project/dump/faultlog/entry/17 | |-/xyz/openbmc_project/dump/faultlog/entry/18 | |-/xyz/openbmc_project/dump/faultlog/entry/19 | `-/xyz/openbmc_project/dump/faultlog/entry/20 |-/xyz/openbmc_project/dump/internal | `-/xyz/openbmc_project/dump/internal/manager `-/xyz/openbmc_project/dump/system `-/xyz/openbmc_project/dump/system/entry |-/xyz/openbmc_project/dump/system/entry/3 `-/xyz/openbmc_project/dump/system/entry/4 After ClearLog: busctl tree xyz.openbmc_project.Dump.Manager `-/xyz `-/xyz/openbmc_project `-/xyz/openbmc_project/dump |-/xyz/openbmc_project/dump/bmc |-/xyz/openbmc_project/dump/faultlog |-/xyz/openbmc_project/dump/internal | `-/xyz/openbmc_project/dump/internal/manager `-/xyz/openbmc_project/dump/system Confirmed that ClearLog action is listed for the following LogServices: /redfish/v1/Managers/bmc/LogServices/Dump /redfish/v1/Managers/bmc/LogServices/FaultLog /redfish/v1/Systems/system/LogServices/Dump Then ran "systemctl stop xyz.openbmc_project.Dump.Manager" (which removes dump manager objects including their xyz.openbmc_project.Collection.DeleteAll interface) and saw that the ClearLog action was no longer listed. Also locally built a version of phosphor-debug-collecor with the interface xyz.openbmc_project.Collection.DeleteAll removed from dump managers and ran it and saw that the ClearLog action wasn't listed. Redfish Service Validator passed on the following URIs (with service xyz.openbmc_project.Dump.Manager running): /redfish/v1/Managers/bmc/LogServices/Dump /redfish/v1/Managers/bmc/LogServices/FaultLog /redfish/v1/Systems/system/LogServices/Dump Note: Most dump LogService unit tests were removed in this patchset since this patchset adds a D-Bus call to getDumpServiceInfo(), and we haven't decided how to mock D-Bus calls for unit testing yet. [1] https://github.com/openbmc/phosphor-debug-collector/commit/fef66a951fe6fe283515480b2c493dfdc2275a95 Signed-off-by: Claire Weinan <cweinan@google.com> Change-Id: Ic5f8f9e3528f521887766d8710bd77f969d8236a
2023-01-13Remove a couple references to @odata.contextEd Tanous1-4/+0
9440096005902d13e27fdb8911d33c657f8c7b77 removed all uses of odata.context from the system, but there were a few left in static files, that unfortunately got propagated to code when we did the migration from static files. This commit fixes the last couple that were left. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ifc77ff02939c663106029dc57807db3b8ad537b7
2023-01-12Fix keepalive falseEd Tanous1-4/+4
When we changed [1] to using a std::move of the Request object instead of an unsafe reference, we missed one spot where we were using the request object, post handle. This commit moves the keepalive function to be set on the response object before calling handle. Tested: curl request with -H "Connection: close", -H "Connection: keep-alive" and no header all return the correct values. [1] 2d6cb56b6b47c3fbb0d234ade5c1208edb69ef1f Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I91fe32162407f1e1bdfcc06f1751e02d11f8a697
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