summaryrefslogtreecommitdiff
path: root/redfish-core/lib/pcie.hpp
AgeCommit message (Collapse)AuthorFilesLines
2023-02-24Take boost error_code by referenceEd Tanous1-3/+3
By convention, we should be following boost here, and passing error_code by reference, not by value. This makes our code consistent, and removes the need for a copy in some cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id42ea4a90b6685a84818b87d1506c11256b3b9ae
2023-02-23Update most resources to use urlFromPiecesWilly Tu1-14/+18
Only id in event_service and account_service have not been updated due to the risk of it breaking the username/id. It will require further testing to verify. Use urlFromPieces wherever that is needed to insert a variable in the URI. Don't use urlFromPieces when it is hardcoded values. This allow us to control all resource URIs that is dynamically added and to sync with the current recommanded method for `@odata.id`. The goal is to have a common place to manage the url created from dbus-paths in order to manage/update it easily when needed. Tested: RedfishValidtor Passed for all resource including the sensors with the fragments. Change-Id: I95cdfaaee58fc7f21c95f5944e1e5c813b3215f2 Signed-off-by: Willy Tu <wltu@google.com> Signed-off-by: Ed Tanous <edtanous@google.com>
2023-01-19Add Get for PCIe property LanesInUseMyung Bae1-1/+10
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 Tanous1-5/+4
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-11Refactor GetSubTreePaths methodGeorge Liu1-8/+5
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
2022-12-08Generate Redfish enums from schemasEd Tanous1-9/+11
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-11-28pcie:Fix get PCIeFunctionTony Lee1-1/+1
GET /redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions/<str> return resourceNotFound messages. Test: GET /redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions/<str> return the expected information of PCIeDevices. Signed-off-by: Tony Lee <tony.lee@quantatw.com> Change-Id: I1587a74e77225939dec8030bba7fb04865e8051e
2022-10-31pcie: Fixed return nothing when get PCIeDeviceIdTony Lee1-5/+3
GET /redfish/v1/Systems/system/PCIeDevices/<str> nothing will be returned if their 'generationInUse' is Unknown. The original intention is that if it is Unknown, there is no need to display '"PCIeType"'. But the others still have to show. After fix: PCIeType is not Unknown: GET http://${bmc}/redfish/v1/Systems/system/PCIeDevices/<str> { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>.", "@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice", "DeviceType": "SingleFunction", "Id": "<str>", "Manufacturer": "Intel Corporation", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions" }, "PCIeInterface": { "PCIeType": "Gen1" } } PCIeType is Unknown: GET http://${bmc}/redfish/v1/Systems/system/PCIeDevices/<str> { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>", "@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice", "DeviceType": "SingleFunction", "Id": "<str>", "Manufacturer": "Intel Corporation", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions" } } Signed-off-by: Tony Lee <tony.lee@quantatw.com> Change-Id: I85a97e0370a5789e4526964272381a557ce942a0
2022-10-18pcie: fixed filpped empty checkNan Zhou1-1/+1
It's obvious that we want to skip if the string is empty, not if it is valid. Tested: code compiles. Trivial change. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I892e81fb0f87a8999eb880100fd284419054eece
2022-10-18pcie: fix Members@odata.countNan Zhou1-1/+1
I believe this was a typo. We shouldn't return when a deviceId is not found. Tested: s7106 doesn't have PCIe backend configured. I tested it on a downstream system and Members@odata.count shows up. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I38491caf8998fac5fafa0c0f07396cf32066348b
2022-10-04Make routes start matching RedfishEd Tanous1-4/+18
This is preliminary patch to set up the route handling such that it's ready for the addition of multiple hosts, multiple managers in the future. Routes previously took the form of /redfish/v1/Systems/system which essentially hardcoded the name "system" into a number of places. As the stack evolves to support multiple systems, this needs to change. This patchset changes all the ComputerSystem resources to the form: /redfish/v1/Systems/<str> and adds 404 checks to each route such that they will be handled properly still. This means that as we evolve our multi-host support, each individual route can be moved one at a time to support multi-host. In the future, moving these to redfish-spec-defined routing would likely mean that we could generate this code in the future at some point, which reduces the likelihood that people do it incorrectly. This patch currently sets the resource id and resource type in the resourceNotFound message to empty string (""). This handling is still arguably more correct than what we had before, which just returned 404 with an empty payload, although this will be corrected in the future. Tested: None yet. RFC to see if this is a pattern we'd like to propogate Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If9c07ad69f5287bb054645f460d7e370d433dc27
2022-09-09used sdbusplus::unpackPropertiesNoThrow part 8Krzysztof Grobelny1-54/+55
used sdbusplus::unpackPropertiesNoThrow in other places, also replaced all usages of "GetAll" with sdbusplus::asio::getAllProperties bmcweb size: 2697640 -> 2685336 (-12304) compressed size: 1129728 -> 1126078 (-3650) Tested: - Executed redfish service validator, no new errors detected Change-Id: I916e462e004fcbde67c209daef295de8f5fb68eb Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2022-06-17Revert "Implement Redfish PCIeSlots schema"Ed Tanous1-2/+3
This reverts commit 7691cc2f7ef1f0ceedf3de0554045a614f25776d. This causes validator failures ERROR - JsonSchemas: GET of resource at URI /redfish/v1/JsonSchemas returned HTTP 404. Check URI. ERROR - PCIeSlots: GET of resource at URI /redfish/v1/Chassis/motherboard/PCIeSlots returned HTTP 404. Check URI. ERROR - PCIeSlots: GET of resource at URI /redfish/v1/Chassis/chassis/PCIeSlots returned HTTP 404. Check URI. Change-Id: Ibcdf238a222da83127a89d8f38c8180501ffe882 Signed-off-by: Ed Tanous <edtanous@google.com>
2022-06-17Implement Redfish PCIeSlots schemaChicago Duan1-3/+2
PCIeSlotCollection, and PCIeSlot schemas are used for determining and inspecting the PCIe physical topology of a system. It is used to determine what a particular physical slots formfactor is. This commit supports the as documented in Redfish.md. https://redfish.dmtf.org/schemas/PCIeSlots_v1.xml Tested: Validator passes (on previous patchset) 1、Get PCIe slots curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PCIeSlots { "@odata.id": "/redfish/v1/Chassis/chassis/PCIeSlots", "@odata.type": "#PCIeSlots.v1_4_1.PCIeSlots", "Id": "PCIeSlots", "Name": "PCIe Slot Information", "Slots": [ { "HotPluggable": false, "Lanes": 16, "PCIeType": "Gen1", "SlotType": "FullLength" }, { "HotPluggable": false, "Lanes": 16, "PCIeType": "Gen2", "SlotType": "OEM" } ] } 2、No PCIeSlots curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PCIeSlots { "@odata.id": "/redfish/v1/Chassis/chassis/PCIeSlots", "@odata.type": "#PCIeSlots.v1_4_1.PCIeSlots", "Id": "PCIeSlots", "Name": "PCIe Slot Information", "Slots": [] } 3、Bad chassis ID return 404 curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/badChassisID/PCIeSlots Returns 404 and ResourceNotFound Signed-off-by: Chicago Duan <duanzhijia01@inspur.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I11e1bf94b3865986cbd580293ea906fe96067912
2022-06-15Expose AsyncResp shared_ptr when handling responseCarson Labrado1-4/+4
For Redfish Aggregation, we need a common point to check the D-Bus for satellite configs. If they are available then we perform the aggregation operations. The functions in query.hpp are used by all endpoints making them the logical location. The aggregation code requires a shared_ptr to the AsyncResp so these functions need to be able to supply that. This patch is broken out of a future patch for routing Redfish Aggregation requests https://gerrit.openbmc.org/c/openbmc/bmcweb/+/53310 The follow commands can be used to perform most of the replacements: find . -type f | xargs sed -i 's/setUpRedfishRoute(app, req, asyncResp->res/setUpRedfishRoute(app, req, asyncResp/g' find . -type f | xargs sed -i 's/setUpRedfishRouteWithDelegation(app, req, asyncResp->res/setUpRedfishRouteWithDelegation(app, req, asyncResp/g' Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I4f4f9f22cdcfb14a3bd94b9a8f3d64aae34e57bc
2022-06-01Try to fix the lambda formatting issueEd Tanous1-315/+292
clang-tidy has a setting, LambdaBodyIndentation, which it says: "For callback-heavy code, it may improve readability to have the signature indented two levels and to use OuterScope." bmcweb is very callback heavy code. Try to enable it and see if that improves things. There are many cases where the length of a lambda call will change, and reindent the entire lambda function. This is really bad for code reviews, as it's difficult to see the lines changed. This commit should resolve it. This does have the downside of reindenting a lot of functions, which is unfortunate, but probably worth it in the long run. All changes except for the .clang-format file were made by the robot. Tested: Code compiles, whitespace changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
2022-05-13Remove brace initialization of json objectsEd Tanous1-48/+52
Brace initialization of json objects, while quite interesting from an academic sense, are very difficult for people to grok, and lead to inconsistencies. This patchset aims to remove a majority of them in lieu of operator[]. Interestingly, this saves about 1% of the binary size of bmcweb. This also has an added benefit that as a design pattern, we're never constructing a new object, then moving it into place, we're always adding to the existing object, which in the future _could_ make things like OEM schemas or properties easier, as there's no case where we're completely replacing the response object. Tested: Ran redfish service validator. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
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-06Add setUpRedfishRoute to all nodes in redfishEd Tanous1-166/+177
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-03-22Consitently use dbus::utility typesEd Tanous1-193/+192
This saves about 4k on the binary size Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9546227a19c691b1aecb80e80307889548c0293f
2022-02-11Change PcieType to PCIeTypeAnjaliintel-211-1/+1
In the patch: https://github.com/openbmc/bmcweb/commit/62cd45af311e7741064c114581ba34186d6e508c Mismatch of PCIeType from pcie.hpp to PCIeDevice_v1.xml.In function requestRoutesSystemPCIeDevice, PCIeType mentioned for PCIeInterface details, was written as PcieType but in PCIeDevice_v1.xml, property name is PCIeType which was giving error in the validator. Tested using RedfishServiceValidator: *** /redfish/v1/Systems/system/PCIeDevices Type (#PCIeDeviceCollection.PCIeDeviceCollection), GET SUCCESS (time: 1.35205) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B1D0 Type (#PCIeDevice.v1_4_0.PCIeDevice), GET SUCCESS (time: 1.290409) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B1D0/PCIeFunctions Type (#PCIeFunctionCollection.PCIeFunctionCollection), GET SUCCESS (time: 1.287055) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B1D0/PCIeFunctions/0 Type (#PCIeFunction.v1_2_0.PCIeFunction), GET SUCCESS (time: 1.336434) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B2D0 Type (#PCIeDevice.v1_4_0.PCIeDevice), GET SUCCESS (time: 1.282768) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B2D0/PCIeFunctions Type (#PCIeFunctionCollection.PCIeFunctionCollection), GET SUCCESS (time: 1.401044) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B2D0/PCIeFunctions/0 Type (#PCIeFunction.v1_2_0.PCIeFunction), GET SUCCESS (time: 1.286989) PASS *** /redfish/v1/Systems/system/PCIeDevices/S0B3D0 Type (#PCIeDevice.v1_4_0.PCIeDevice), GET SUCCESS (time: 1.331661) PASS Elapsed time: 0:01:17 Counter({'metadataNamespaces': 2337, 'skipOptional': 67, 'pass': 51, 'passGet': 8, 'serviceNamespaces': 4}) Validation has succeeded. Signed-off-by: Anjaliintel-21 <anjali.ray@intel.com> Change-Id: I134988f29c9db3462b54362104922e922f5c5b04
2022-01-28Enable readability-container-size-empty testsEd Tanous1-3/+3
This one is a little trivial, but it does help in readability. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa
2022-01-20Fix undefined property in PCIeFunctionCollectionJiaqing Zhao1-1/+1
According to Redfish spec, current "PCIeFunctions@odata.count" in PCIeFunctionCollection should be "Members@odata.count". Tested: Redfish validator passed. Change-Id: Iaabcad0f19b619eea26e2902944d3262fe499a5b Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2021-12-28Move to common variantEd Tanous1-165/+189
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
2021-12-21PCIe: Implement "PcieType" PCIe device propertySpencer Ku1-0/+58
This commit publishes PCIe device property "PcieType" which defined in the Redfish PCIeDevice schema. New property: PCIeType : The PCIe interface generation in use by the device. Dbus interfaces dependency PR: https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/46437 Peci-pcie dependency PR: https://gerrit.openbmc-project.xyz/c/openbmc/peci-pcie/+/46438 Sample output: /redfish/v1/Systems/systemPCIeDevices/S0B1D0/ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/S0B1D0", "@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice", "DeviceType": "SingleFunction", "Id": "S0B1D0", "Manufacturer": "PLDA", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/S0B1D0/PCIeFunctions" }, "PCIeInterface": { "PcieType": "Gen2" } } Signed-off-by: Spencer Ku <Spencer.Ku@quantatw.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I550a9ca8a266cf1d2e1bff5b6a03656a3f1f0281
2021-09-27Revert "PCIe: Implement "PcieType" PCIe device property"Ed Tanous1-45/+0
This reverts commit 3e8c7dfce4869711e22ccc76c90cebb55984d36c. As pointed out in the review. The patchset doesn't implement the latest phosphor-dbus-interfaces interface. It was a mistake to merged it. To the submitter, please resubmit it once we have the right interface sorted out, and we'll be able to get this in. Change-Id: Id433b354cbebc11f12c49bcd965e931e72075008 Signed-off-by: Ed Tanous <edtanous@google.com>
2021-09-25PCIe: Implement "PcieType" PCIe device propertySpencer Ku1-0/+45
This commit publishes PCIe device property "PcieType" which defined in the Redfish PCIeDevice schema. New property: PCIeType : The PCIe interface generation in use by the device. Dbus interfaces dependency PR: https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/46437 Peci-pcie dependency PR: https://gerrit.openbmc-project.xyz/c/openbmc/peci-pcie/+/46438 Sample output: /redfish/v1/Systems/systemPCIeDevices/S0B1D0/ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/S0B1D0", "@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice", "DeviceType": "SingleFunction", "Id": "S0B1D0", "Manufacturer": "PLDA", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/S0B1D0/PCIeFunctions" }, "PCIeInterface": { "PcieType": "Gen2" } } Signed-off-by: Spencer Ku <Spencer.Ku@quantatw.com> Change-Id: Ic6bc19455c648a3d256856938a79a4265ce8eb59
2021-07-08Automate PrivilegeRegistry to codeEd Tanous1-4/+5
This commit attempts to automate the creation of our privileges structures from the redfish privilege registry. It accomplishes this by updating parse_registries.py to also pull down the privilege registry from DMTF. The script then generates privilege_registry.hpp, which include const defines for all the privilege registry entries in the same format that the Privileges struct accepts. This allows new clients to simply reference the variable to these privilege structures, instead of having to manually (ie error pronely) put the privileges in themselves. This commit updates all the routes. For the moment, override and OEM schemas are not considered. Today we don't have any OEM-specific Redfish routes, so the existing ones inherit their parents schema. Overrides have other issues, and are already incorrect as Redfish defines them. Binary size remains unchanged after this patchset. Tested: Ran redfish service validator Ran test case from f9a6708c4c6490257e2eb6a8c04458f500902476 to ensure that the new privileges constructor didn't cause us to regress the brace construction initializer. Checked binary size with: gzip -c $BBPATH/tmp/work/s7106-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/bin/bmcweb | wc -c 1244048 (tested on previous patchset) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ideede3d5b39d50bffe7fe78a0848bdbc22ac387f
2021-06-16Remove ambiguous privileges constructorEd Tanous1-4/+4
There are a number of endpoints that assume that a given routes privileges are governed by a single set of privileges, instead of multiple sets ORed together. To handle this, there were two overloads of the privileges() method, one that took a vector of Privileges, and one that took an initializer_list of const char*. Unfortunately, this leads some code in AccountService to pick the wrong overload when it's called like this .privileges( {{"ConfigureUsers"}, {"ConfigureManager"}, {"ConfigureSelf"}}) This is supposed to be "User must have ConfigureUsers, or ConfigureManager, or ConfigureSelf". Currently, because it selects the wrong overload, it computes to "User must have ConfigureUsers AND ConfigureManager AND ConfigureSelf. The double braces are supposed to cause this to form a vector of Privileges, but it appears that the initializer list gets consumed, and the single invocation of initializer list is called. Interestingly, trying to put in a privileges overload of intializer_list<initializer_list<const char*>> causes the compilation to fail with an ambiguous call error, which is what I would've expected to see previously in this case, but alas, I'm only a novice when it comes to how the C++ standard works in these edge cases. This is likely due in part to the fact that they were templates of an unused template param (seemingly copied from the previous method) and SFINAE rules around templates. This commit functionally removes one of the privileges overloads, and adds a second set of braces to every privileges call that previously had a single set of braces. Previous code will not compile now, which is IMO a good thing. This likely popped up in the Node class removal, because the Node class explicitly constructs a vector of Privilege objects, ensuing it can hit the right overload Tested: Ran Redfish service validator Tested the specific use case outlined on discord with: Creating a new user with operator privilege: ``` redfishtool -S Always -u root -p 0penBmc -vvvvvvvvv -r 192.168.7.2 AccountService adduser foo mysuperPass1 Operator ``` Then attempting to list accounts: ``` curl -vvvv --insecure --user foo:mysuperPass1 https://192.168.7.2/redfish/v1/AccountService/Accounts/foo ``` Which succeeded and returned the account in question. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I83e62b70e97f56dc57d43b9081f333a02fe85495
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-305/+257
Reduces the total number of lines and will allow for easier testing of the redfish responses. A main purpose of the node class was to set app.routeDynamic(). However now app.routeDynamic can handle the complexity that was once in critical to node. The macro app.routeDynamic() provides a shorter cleaner interface to the unerlying app.routeDyanic call. The old pattern set permissions for 6 interfaces (get, head, patch, put, delete_, and post) even if only one interface is created. That pattern creates unneeded code that can be safely removed with no effect. Unit test for the responses would have to mock the node the class in order to fully test responses. see https://github.com/openbmc/bmcweb/issues/181 The following files still need node to be extracted. virtual_media.hpp account_service.hpp redfish_sessions.hpp ethernet.hpp The files above use a pattern that is not trivial to address. Often their responses call an async lambda capturing the inherited class. ie (https://github.com/openbmc/bmcweb/blob/ffed87b5ad1797ca966d030e7f979770 28d258fa/redfish-core/lib/account_service.hpp#L1393) At a later point I plan to remove node from the files above. Tested: I ran the docker unit test with the following command. WORKSPACE=$(pwd) UNIT_TEST_PKG=bmcweb ./openbmc-build-scripts/run-unit-test-docker.sh I ran the validator and this change did not create any issues. python3 RedfishServiceValidator.py -c config.ini Signed-off-by: John Edward Broadbent <jebr@google.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I147a0289c52cb4198345b1ad9bfe6fdddf57f3df
2021-04-08Using AsyncResp everywherezhanghch051-10/+9
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
2020-10-15Lots of performance improvementsEd Tanous1-2/+3
(In the voice of the kid from sixth sense) I see string copies... Apparently there are a lot of places we make unnecessary copies. This fixes all of them. Not sure how to split this up into smaller patches, or if it even needs split up. It seems pretty easy to review to me, because basically every diff is identical. Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369 Signed-off-by: Ed Tanous <ed@tanous.net> Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
2020-10-09Write the clang-tidy file OpenBMC needsEd Tanous1-1/+1
Now that CI can handle clang-tidy, and a lot of the individual fixes have landed for the various static analysis checks, lets see how close we are. This includes bringing a bunch of the code up to par with the checks that require. Most of them fall into the category of extraneous else statements, const correctness problems, or extra copies. Tested: CI only. Unit tests pass. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9fbd346560a75fdd3901fa40c57932486275e912
2020-08-17Enable unused variable warnings and resolveEd Tanous1-5/+5
This commit enables the "unused variables" warning in clang. Throughout this, it did point out several issues that would've been functional bugs, so I think it was worthwhile. It also cleaned up several unused variable from old constructs that no longer exist. Tested: Built with clang. Code no longer emits warnings. Downloaded bmcweb to system and pulled up the webui, observed webui loads and logs in properly. Change-Id: I51505f4222cc147d6f2b87b14d7e2ac4a74cafa8 Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-17Remove middlewaresEd Tanous1-6/+4
Middlewares, while kinda cool from an academic standpoint, make our build times even worse than they already are. Given that we only really use 1 real middleware today (token auth) and it needs to move into the parser mode anyway (for security limiting buffer sizes), we might as well use this as an opportunity to delete some code. Some other things that happen: 1. Persistent data now moves out of the crow namespace 2. App is no longer a template 3. All request_routes implementations no longer become templates. This should be a decent (unmeasured) win on compile times. This commit was part of a commit previously called "various cleanups". This separates ONLY the middleware deletion part of that. Note, this also deletes about 400 lines of hard to understand code. Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a Signed-off-by: Ed Tanous <ed@tanous.net>
2020-06-11clang-format: update to latest from docs repoGunnar Mills1-42/+42
This is from openbmc/docs/style/cpp/.clang-format Other OpenBMC repos are doing the same. Tested: Built and validator passed. Change-Id: Ief26c755c9ce012823e16a506342b0547a53517a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-05-14sdbusplus: replace message::variant with std::variantPatrick Williams1-6/+5
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ia5d0845741f1d8d4bc6fd227c6d2e6f3a8d42b2e
2020-05-14sdbusplus: remove deprecated variant_nsPatrick Williams1-118/+99
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I86e11299512704fa1df1e5f6517ea25cc6eced8f
2020-02-20pcie: Remove odata.contextGunnar Mills1-10/+0
Redfish made odata.context optional (1.6.0 of DSP0266) and has removed odata.context from example payloads in the specification (1.7.0 of DSP0266), removed it from the mockups, and Redfish recommended not using. Change-Id: I262f21aac32634f8e87863cca7816e4b9236227a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2019-10-29Update to Chassis 1.10 and add PCIeDeviceCollection supportJason M. Bills1-30/+67
v1.10 of Chassis adds a PCIeDeviceCollection. This change adds support for the PCIeDeviceCollection and references it from Chassis. Tested: Passed the Redfish Service Validator. Change-Id: If3bb75f4fa90a9df4a2a94a7c7e0bcaf37673723 Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
2019-10-22Update to PCIeDevices 1.4 and add PCIeFunctionCollection supportJason M. Bills1-8/+86
v1.4 of PCIe Devices changed from an array of Links to PCIeFunctions to a PCIeFunctionCollection. This change adds support for the PCIeFunctionCollection and references it from the PCIeDevices. Tested: Passed the Redfish Service Validator. Change-Id: I76f0265c588b52bd02a35bf669ae6edacfb6c2a4 Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
2019-10-11Fix a bunch of warningsEd Tanous1-2/+2
using the list of warnings from here: https://github.com/lefticus/cppbestpractices/blob/e73393f25a85f83fed7399d8b65cb117d00b2231/02-Use_the_Tools_Available.md#L100 Seems like a good place to start, and would improve things a bit type-wise. This patchset attempts to correct all the issues in one shot. Tested: It builds. Will test various subsystems that have been touched Signed-off-by: Ed Tanous <ed.tanous@intel.com> Change-Id: I588c26440e5a97f718a0f0ea74cc84107d53aa1e
2019-07-12pcie: Don't return error if no PCIe presentAndrew Geissler1-2/+2
Resolves openbmc/bmcweb#98 Tested: Before the fix: curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/Systems/system { "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", "@odata.id": "/redfish/v1/Systems/system", "@odata.type": "#ComputerSystem.v1_6_0.ComputerSystem", ... "SystemType": "Physical", "error": { "@Message.ExtendedInfo": [ { "@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message", "Message": "The request failed due to an internal service error. The service is still operational.", "MessageArgs": [], "MessageId": "Base.1.4.0.InternalError", "Resolution": "Resubmit the request. If the problem persists, consider resetting the service.", "Severity": "Critical" } ], "code": "Base.1.4.0.InternalError", "message": "The request failed due to an internal service error. The service is still operational." } After the fix: curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/Systems/system { "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", "@odata.id": "/redfish/v1/Systems/system", "@odata.type": "#ComputerSystem.v1_6_0.ComputerSystem", ... "SerialNumber": "1318ECA", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Disabled" }, "SystemType": "Physical" } Change-Id: I0cc2a86decdea47164103c901ce7bd631f8adaf2 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
2019-07-11Add Redfish PCIe informationJason M. Bills1-0/+345
This adds the capability to get PCIe device information from D-Bus and display it in the appropriate Redfish PCIeDevice and PCIeFunction objects. Tested: Passed the Redfish validator for the new PCIeDevice and PCIeFunction objects. Change-Id: I06f3b0e7d283e48d2235b7d34f78f603b22de79f Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>