summaryrefslogtreecommitdiff
path: root/redfish-core/lib/managers.hpp
AgeCommit message (Collapse)AuthorFilesLines
4 daysRevert "Refactor Managers with getValidManagerPath"Gunnar Mills1-75/+157
This reverts commit 0775449c62385f163a207d0f0c8e1f6338de1062. CI bumps are failing. Romulus is failing [1]. (UTC) 2025/09/07 07:28:06.903907 - 0.212714 - Executing: get('/redfish/v1/Managers/bmc') [1]: https://discord.com/channels/775381525260664832/855566794994221117/1414329724477636649 Change-Id: I0ff80780cf1eb2f14484fdd0a521f90cc15e914b Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
8 daysRefactor Managers with getValidManagerPathMyung Bae1-157/+75
This adds getValidManagerPath() to find the valid manager dbus path and its service name. This can be used for manager GET and PATCH operations. Tested: - GET /redfish/v1/Managers/bmc - PATCH /redfish/v1/Managers/ LocationIndicatorActive - Redfish Service Validator passes Change-Id: Id46dd12be3050a2097364696a471b188b8167016 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-08-26Fix includesEd Tanous1-1/+0
Our includes haven't been enforced by tidy in a while. Run the script, check in the result, minus the false positives. Change-Id: I6a6da26f5ba5082d9b4aa17cdc9f55ebd8cd41a6 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-08-22Refactor Manager Reset ActionsMyung Bae1-165/+148
This refactors manager reset action handling codes and also merges the requestRoute function into one. - handleManagerResetAction - handleManagerResetToDefaultsAction - handleManagerResetActionInfo This also rearranges requestRouteManager setup functions into one. - requestRoutesManager - requestRoutesManagerCollection Tested: - Perform Manager Reset actions - Redfish Service Validator passes Change-Id: Ia76719d98aac8b871f0f275b0bc99999562fe796 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-08-21Refactor Managers codeMyung Bae1-238/+236
This refactors manager handling code by breaking out the route bodies of codes instead of keeping the large code lines in requestRoute function. - handleManagerGet - handleManagerPatch - handleManagerCollectionGet Tested: - Compare GET /redfish/v1/Managers before and after the change - Redfish Service Validator passes Change-Id: Idaa9cc904fd8b42f22389af2230f37e9af05d596 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-07-07Add ServiceIdentificationCorey Ethington1-2/+13
Implements GET and PATCH support for ServiceIdentification in Managers/bmc and service root. Tested: - Refish Service Validator passes - Tested on romulus: 1. GET initial value ``` curl -k "https://$BMC/redfish/v1" { ... } ``` ServiceIdentification is not yet present in service root, as expected ``` curl -k -H "X-Auth-Token: $XAUTH_TOKEN" "https://$BMC/redfish/v1/Managers/bmc" { ... "ServiceIdentification": "", ... } ``` 2. PATCH and GET with valid value ``` curl -k -X PATCH "https://$BMC/redfish/v1/Managers/bmc" -H "X-Auth-Token: $XAUTH_TOKEN" \ -H 'Content-Type: application/json' --data-raw '{"ServiceIdentification": "foo"}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request completed successfully.", "MessageArgs": [], "MessageId": "Base.1.19.Success", "MessageSeverity": "OK", "Resolution": "None." } ] } curl -k "https://$BMC/redfish/v1" { ... "ServiceIdentification": "foo", ... } curl -k -H "X-Auth-Token: $XAUTH_TOKEN" "https://$BMC/redfish/v1/Managers/bmc" { ... "ServiceIdentification": "foo", ... } ``` 3. PATCH and GET with invalid value ``` curl -k -X PATCH "https://$BMC/redfish/v1/Managers/bmc" -H "X-Auth-Token: $XAUTH_TOKEN" \ -H 'Content-Type: application/json' --data-raw '{"ServiceIdentification": "$$$"}' { "ServiceIdentification@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value provided for the property ServiceIdentification is not valid.", "MessageArgs": [ "ServiceIdentification" ], "MessageId": "Base.1.19.PropertyValueError", "MessageSeverity": "Warning", "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed." } ] } curl -k -X PATCH "https://$BMC/redfish/v1/Managers/bmc" -H "X-Auth-Token: $XAUTH_TOKEN" \ -H 'Content-Type: application/json' --data-raw '{"ServiceIdentification": "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"}' { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The string 'ServiceIdentification' exceeds the length limit 99.", "MessageArgs": [ "ServiceIdentification", "99" ], "MessageId": "Base.1.19.StringValueTooLong", "MessageSeverity": "Warning", "Resolution": "Resubmit the request with an appropriate string length." } ], "code": "Base.1.19.StringValueTooLong", "message": "The string 'ServiceIdentification' exceeds the length limit 99." } } curl -k "https://$BMC/redfish/v1" { ... "ServiceIdentification": "foo", ... } curl -k -H "X-Auth-Token: $XAUTH_TOKEN" "https://$BMC/redfish/v1/Managers/bmc" { ... "ServiceIdentification": "foo", ... } ``` Change-Id: I5b71a73e947ec64cabb8d93c8503a18fb43b8937 Signed-off-by: Corey Ethington <cethington@coreweave.com>
2025-06-30Implement LocationIndicatorActive for Manager resourceGeorge Liu1-0/+72
Implement LocationIndicatorActive for Manager schema to set and get the status of the location LED for the manager.[1] This property was added to the Manager schema in version v1_11_0. Uses the utility functions getLocationIndicatorActive() and setLocationIndicatorActive() to follow the association and get or set the LED value. [1] https://redfish.dmtf.org/schemas/v1/Manager.v1_22_0.json Tested: - Redfish Service Validator passes - Tested on p10bmc hardware simulator: 1. Get LocationIndicatorActive ``` curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", ... "LocationIndicatorActive": false, "LogServices": { "@odata.id": "/redfish/v1/Managers/bmc/LogServices" }, ... } ``` 2. Set LocationIndicatorActive to true ``` curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PATCH -d '{"LocationIndicatorActive":true}' https://${bmc}/redfish/v1/Managers/bmc curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", ... "LocationIndicatorActive": true, ... } ``` 3. Use busctl set-propery to change the value back to false ``` busctl get-property xyz.openbmc_project.LED.GroupManager /xyz/openbmc_project/led/groups/bmc_ingraham_identify xyz.openbmc_project.Led.Group Asserted b true busctl set-property xyz.openbmc_project.LED.GroupManager /xyz/openbmc_project/led/groups/bmc_ingraham_identify xyz.openbmc_project.Led.Group Asserted b false curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", ... "LocationIndicatorActive": false, ... } ``` 4. Error returned when trying to set the value to non-boolean ``` curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PATCH -d '{"LocationIndicatorActive":1}' https://${bmc}/redfish/v1/Managers/bmc { "LocationIndicatorActive@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value '1' for the property LocationIndicatorActive is not a type that the property can accept.", "MessageArgs": [ "1", "LocationIndicatorActive" ], "MessageId": "Base.1.19.PropertyValueTypeError", "MessageSeverity": "Warning", "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed." } ] } ``` 5. Error returned when specifying an unknown Manager resource ``` curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PATCH -d '{"LocationIndicatorActive":true}' https://${bmc}/redfish/v1/Managers/bmc2 { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Manager named 'bmc2' was not found.", "MessageArgs": [ "Manager", "bmc2" ], "MessageId": "Base.1.19.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.19.ResourceNotFound", "message": "The requested resource of type Manager named 'bmc2' was not found." } } curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc2 { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Manager named 'bmc2' was not found.", "MessageArgs": [ "Manager", "bmc2" ], "MessageId": "Base.1.19.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.19.ResourceNotFound", "message": "The requested resource of type Manager named 'bmc2' was not found." } } ``` Signed-off-by: George Liu <liuxiwei@inspur.com> Signed-off-by: Janet Adkins <janeta@us.ibm.com> Change-Id: I7155e2298962a950491da89e92f8480f98dbeccb
2025-06-24Managers: Factor out large lambdasJanet Adkins1-124/+136
Restructure to move large lambdas to named functions for getting the properties for the manager. No semantic changes were made. Note: I refactored only some of the large lambdas in this file and path. The ones I refactored are in the flow for a follow-on commit to add the LocationIndicatorActive Redfish property to the Manager. ``` curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", ... } ``` Tested: Confirmed same output before and after change. Change-Id: I350ecbc5add46cfc6356d05b4feb484bb448a323 Signed-off-by: Janet Adkins <janeta@us.ibm.com>
2025-05-14Remove ResetToDefaultsType since timeGunnar Mills1-62/+51
ResetToDefaultsType states remove in 2Q24, it is now 2Q25 so let's do that. Don't see this used in any of our code. More of the history can be found on the commit adding the correct parameter type ResetType [1]. [1]: https://github.com/openbmc/bmcweb/commit/9970e93f794d0110de436828775e333e81330ad5 Tested: Builds. Removes code only, changes a comment. Just a crazy amount of formatting for some reason. Change-Id: Ic8bc941ac98bec398972de979eef336b9faae21f Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2025-04-15Redfish OEM Patch Route Handlingrohitpai1-42/+2
Extension of OEM route infra to support registration of handlers for OEM patch requests. When patch request is made on a redfish resource, first the main route handler will be called and if request patch payload contains any OEM fragments then, registered OEM patch handler will be called. Tested 1. UT passes with new test cases added for OEM patch handling 2. Patch on FAN OEM property works as expected ``` Step 1: Creating new fan controller... Create PATCH data: { "Oem": { "OpenBmc": { "Fan": { "FanControllers": { "Fan_TEST_391715": { "FFGainCoefficient": 2.0, "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone_1" } ] } } } } } } HTTP Response Code (PATCH /redfish/v1/Managers/bmc): 200 HTTP Response Code (GET /redfish/v1/Managers/bmc): 200 ✓ Fan controller created successfully Step 2: Updating the fan controller... Update PATCH data: { "Oem": { "OpenBmc": { "Fan": { "FanControllers": { "Fan_TEST_391715": { "FFGainCoefficient": 3.0 } } } } } } HTTP Response Code (PATCH /redfish/v1/Managers/bmc): 200 HTTP Response Code (GET /redfish/v1/Managers/bmc): 200 Final Configuration: { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers/Fan_TEST_391715", "@odata.type": "#OpenBMCManager.v1_0_0.Manager.FanController", "FFGainCoefficient": 3.0, "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone_1" } ] } ✓ Fan controller updated successfully ``` Test Summary ``` [+] Tests DateTime update after NTP disable. Payload: {DateTime: <date-string>}. Expects: 204 success, validates date matches update.: PASSED [-] Tests invalid property in request. Payload: {InvalidProperty: 'value', DateTime: <date-string>}. Expects: 400 PropertyUnknown error, validates DateTime unchanged.: PASSED [-] Tests fan controller with invalid property. Payload: Oem/OpenBmc/Fan/FanControllers with InvalidProperty. Expects: 400 PropertyUnknown error, fan not created.: PASSED [-] Tests empty PATCH request. Payload: {}. Expects: 400 MalformedJSON error.: PASSED [-] Tests malformed fan controller JSON. Payload: Fan property as string instead of object. Expects: 400 PropertyValueTypeError error.: PASSED [-] Tests DateTime with wrong type. Payload: {DateTime: 12345}. Expects: 400 PropertyValueTypeError error, DateTime unchanged.: PASSED [-] Tests PATCH to invalid manager path. Payload: Valid DateTime and fan update to /invalid_bmc. Expects: 404 ResourceNotFound error.: PASSED [+] Tests fan controller creation. Payload: Oem/OpenBmc/Fan/FanControllers with FFGainCoefficient and Zones. Expects: 200 success with success message.: PASSED [-] Tests fan controller without required Zones. Payload: Oem/OpenBmc/Fan/FanControllers with only FFGainCoefficient. Expects: 500 InternalError, fan not created.: PASSED [+] Tests combined DateTime and fan update. Payload: DateTime and Oem/OpenBmc/Fan/FanControllers. Expects: 200 success with success message.: PASSED [-] Tests PATCH with wrong Content-Type header. Payload: Valid DateTime update with text/plain content-type. Expects: 400 UnrecognizedRequestBody error.: PASSED [+] Tests fan controller creation and update. Payload: Create with FFGainCoefficient=2.0, then update to 3.0. Expects: 200 success for both operations, verifies all properties.: PASSED ``` Change-Id: Ib2498b6a4db0343d5d4a405a5a8e4d78f615bed8 Signed-off-by: Rohit PAI <rohitpai77@gmail.com>
2025-04-03OEM Route Handling Infrastructurerohitpai1-8/+3
Goal of the MR is to provide infrastructure support in bmcweb to manage the OEM fragment handling separately. OEM schema are vendor defined and per DMTF resource we could have multiple vendor defined OEM schema to be enabled. The feature allows registration of route handler per schema per OEM namespace. Example ``` REDFISH_SUB_ROUTE<"/redfish/v1/Managers/<str>/#/Oem/OpenBmc">(service, HttpVerb::Get)(oemOpenBmcCallback); REDFISH_SUB_ROUTE<"/redfish/v1/Managers/<str>/#/Oem/Nvidia">(service, HttpVerb::Get)(oemNidiaCallback); ``` We can have separate vendor defined route handlers per resource. Each of these route handlers can populate their own vendor specific OEM data. The OEM code can be better organized and enabled/disabled as per the platform needs. The current MR has the code changes related to handling GET requests alone. The feature only supports requests where the response payload is JSON. Tests - All UT cases passes - New UT added for RF OEM router passes - Service Validator passes on qemu - GET Response on Manager/bmc resource contains the OEM fragment ``` curl -c cjar -b cjar -k -X GET https://127.0.0.1:2443/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", "Oem": { "OpenBmc": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc", "@odata.type": "#OpenBMCManager.v1_0_0.Manager", "Certificates": { "@odata.id": "/redfish/v1/Managers/bmc/Truststore/Certificates" } } }, "UUID": "40575e98-90d7-4c10-9eb5-8d8a7156c9b9" } ``` Change-Id: Ic82aa5fe760eda31e2792fbdfb6884ac3ea613dc Signed-off-by: Rohit PAI <rohitpai77@gmail.com>
2025-02-18Migration of OpenBMC Manager OEM schemarohitpai1-1454/+2
With the support of OEM route infrastructure each OEM implementation can be separated into an OEM route handler. The MR migrates OEM resource of manager resource into new files and route handlers Tested - All unit tests are passing - GET request on /redfish/v1/Managers/<bmcid> has OpenBMC OEM properties Change-Id: I935524dcdad6a6cc38a5532b6e7e7ffa1cb0369f Signed-off-by: rohitpai <rohitpai77@gmail.com> Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-02-04clang-format: update latest spec and reformatPatrick Williams1-65/+65
Copy the latest format file from the docs repository and apply. Change-Id: I2f0b9d0fb6e01ed36a2f34c750ba52de3b6d15d1 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2025-01-31Fix includesEd Tanous1-1/+23
Clang-tidy misc-include-cleaner appears to now be enforcing significantly more headers than previously. That is overall a good thing, but forces us to fix some issues. This commit is largely just taking the clang-recommended fixes and checking them in. Subsequent patches will fix the more unique issues. Note, that a number of new ignores are added into the .clang-tidy file. These can be cleaned up over time as they're understood. The majority are places where boost includes a impl/x.hpp and x.hpp, but expects you to use the later. include-cleaner opts for the impl, but it isn't clear why. Change-Id: Id3fdd7ee6df6c33b2fd35626898523048dd51bfb Signed-off-by: Ed Tanous <etanous@nvidia.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2025-01-20Use SPDX identifiersEd Tanous1-15/+3
SPDX identifiers are simpler, and reduce the amount of cruft we have in code files. They are recommended by linux foundation, and therefore we should do as they allow. This patchset does not intend to modify any intent on any existing copyrights or licenses, only to standardize their inclusion. [1] https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects Change-Id: I935c7c0156caa78fc368c929cebd0f068031e830 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-17Move getProperty calls to utilityEd Tanous1-15/+13
Having all dbus calls run through the same utility reduces the amount of generated code, and more importantly, gives us a place where we can log the requests and responses to help with debugging. Tested: Redfish service validator passes. Change-Id: Ic1bf45130b5069cd57f7af26e12c8d3159c87c67 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-15Manager: Remove SerialConsole and TODOGunnar Mills1-9/+0
In 2020, the OCP Profile moved to accept SerialConsole in either Manager or System.[1] That was the reason of still having this code. SerialConsole was deprecated in Manager v1_10_0. v1_19_2 is the latest Manager version[2]. SerialConsole was added to System in 2021[3]. In 2023, SerialConsole was enhanced to get the status not just hardcode to enabled. [1]: https://github.com/opencomputeproject/HWMgmt-OCP-Profiles/issues/23 [2]: https://redfish.dmtf.org/schemas/v1/Manager.v1_19_2.json [3]: https://github.com/openbmc/bmcweb/commit/0e8ac5e706c531d2a3e2fc8390d9a31b90a91eb1 [4]: https://github.com/openbmc/bmcweb/commit/5c3e927283e32e1633ccd409f34ee17fab626ca1 Tested: Covered by automated tests. Change-Id: I0a95e9215d4aa4626a3da75c989cb7d5eaf94be1 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-11-13update service name for UPDATESERVICE_USE_DBUSJagpal Singh Gill1-5/+21
Update the Dbus service name and path for BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS. As part of updated implementation the new BMC code updater daemon name is xyz.openbmc_project.Software.Manager, update setActiveImage and FactoryReset flows to reflect so. Tested: ``` > curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X POST https://${bmc}/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults -d '{"ResetType": "ResetAll"}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request completed successfully.", "MessageArgs": [], "MessageId": "Base.1.19.0.Success", "MessageSeverity": "OK", "Resolution": "None." } ] } > curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PATCH https://${bmc}/redfish/v1/Managers/bmc -d '{"Links": {"ActiveSoftwareImage": {"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/70f4c0cb"}}}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request completed successfully.", "MessageArgs": [], "MessageId": "Base.1.19.0.Success", "MessageSeverity": "OK", "Resolution": "None." } ] } ``` Change-Id: I42ef2485fa119474b7fd12ea94dd654c3432c067 Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
2024-10-14Format readjsonMyung Bae1-41/+60
clang-format may potentially reformat the readJson calls if they may have more keys or key names are longer. This makes formatting in a way that's readable by forcing to break a line for each key using an empty-comment (`//`) each line. It also allows trivially alphabetizing the list such that new additions are less likely to have merge conflicts. Tested: - Check whitespace only. - Code compiles. - Redfish Service Validator with the same results before this Change-Id: I3824a8c4faa9fa7c820d5d2fab6b565404926e2c Signed-off-by: Ed Tanous <etanous@nvidia.com> Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2024-09-11Remove duplicated block commentsEd Tanous1-13/+13
Static analysis flags that these two comments are redundant[1], which seem to be duplicated a lot in copyright headers. Although there is a larger discussion that can likely be had. [1] https://sonarcloud.io/project/issues?issueStatuses=OPEN%2CCONFIRMED&id=edtanous_bmcweb&open=AY9_HYjgKXKyw1ZFwgVP Tested: Comment change only. Code compiles. Change-Id: Ia960317761f558a87842347ca0b5f3da63f8e730 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-08-17clang-format: re-format for clang-18Patrick Williams1-1061/+1115
clang-format-18 isn't compatible with the clang-format-17 output, so we need to reformat the code with the latest version. The way clang-18 handles lambda formatting also changed, so we have made changes to the organization default style format to better handle lambda formatting. See I5e08687e696dd240402a2780158664b7113def0e for updated style. See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement. Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2024-08-02Consistently use generated enumerationsEd Tanous1-9/+16
This commit causes all of Redfish to use generated enum values for enum types. Using generated code prevents problems, and makes it more clear what types are allowed. Doing this found two places where we had structs that didn't fulfill the schema. They have been commented, but will be fixed with a breaking change at some point in the future. Tested: WIP Change-Id: I5fdd2f2dfb6ec05606a522e1f4e331f982c8e476 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-07-17Fix OpenBMC OEMManagerEd Tanous1-11/+14
The OpenBMC OEM schemas have had many things wrong since their creation, to the point where nobody could be using them to generate values. This commit fixes the issues, namely. OemManager schema and namespace are renamed to OpenBMCManager, in line with the Redfish specification around OEM naming conventions. OpenBMCManager now includes versions, which is a partial fix for #184. json-schemas are regenerated from the CSDL to json script in Redfish-Tools, rather than being handmade. This also introduces versions in the json-schema. Tested: Redfish service validator passes. Change-Id: I18f7d0445105a361775c04ae614d6ae2e297bbf6 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-06-14Fix regression in Manager chassis findingEd Tanous1-2/+2
18f8f60 introduced two regressions where the config was checking parent_path() instead of filename, where previously they used ends_with, not starts_with. This was found via inspection. Testing: Unclear how to exactly test this, but we should at least get the code to appear correct in inspection. [1] https://github.com/openbmc/bmcweb/commit/18f8f608b966c802b3e2a389e3c1ec5a1fd9407b#diff-c49b52746d73fb038cb7892f9204d663efd1b9e4fa6b4dac38c5c9620b2c2944R1495 Change-Id: I45441a6e1549f09e7a570c74d3ee4438ecc07cbe Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-21Allow configuring "bmc" and "system"Ed Tanous1-39/+102
In the early days of bmcweb, we made two pretty critical assumptions; First, is that a given platform would only have a single BMC instance (represented as "bmc") and a single host instance (represented as "system"). Second we assumed that, given that Redfish suggests against hardcoding URIs in client implementation and leaves them freeform, clients would code to the standard. Our own webui-vue hardcodes Redfish URIs [1], and the documentation is littered with examples of hardcoded curl examples of hardcoding these URIs. That bug was filed in 2020, and the issue has only gotten worse over time. This patchset is an attempt to give a target that we can start solving these issues, without trying to boil the ocean and fix all clients in parallel. This commit adds the meson options redfish-manager-uri-name and redfish-system-uri-name These are used to control the "name" that bmcweb places in the fixed locations in the ManagerCollection and ComputerSystemCollection schemas. Note, managers is added, but is not currently testable. It will be iterated on over time. Tested: Changed the URL options to "edsbmc" and "edssystem" in meson options. Redfish service validator passes. URLs appear changed when walking the tree. [1] https://github.com/openbmc/webui-vue/issues/43 Change-Id: I4b44685067051512bd065da8c2e3db68ae5ce23a Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-01Bring consistency to config optionsEd Tanous1-40/+47
The configuration options that exist in bmcweb are an amalgimation of CROW options, CMAKE options using #define, pre-bmcweb ifdef mechanisms and meson options using a config file. This history has led to a lot of different ways to configure code in the codebase itself, which has led to problems, and issues in consistency. ifdef options do no compile time checking of code not within the branch. This is good when you have optional dependencies, but not great when you're trying to ensure both options compile. This commit moves all internal configuration options to: 1. A namespace called bmcweb 2. A naming scheme matching the meson option. hyphens are replaced with underscores, and the option is uppercased. This consistent transform allows matching up option keys with their code counterparts, without naming changes. 3. All options are bool true = enabled, and any options with _ENABLED or _DISABLED postfixes have those postfixes removed. (note, there are still some options with disable in the name, those are left as-is) 4. All options are now constexpr booleans, without an explicit compare. To accomplish this, unfortunately an option list in config/meson.build is required, given that meson doesn't provide a way to dump all options, as is a manual entry in bmcweb_config.h.in, in addition to the meson_options. This obsoletes the map in the main meson.build, which helps some of the complexity. Now that we've done this, we have some rules that will be documented. 1. Runtime behavior changes should be added as a constexpr bool to bmcweb_config.h 2. Options that require optionally pulling in a dependency shall use an ifdef, defined in the primary meson.build. (note, there are no options that currently meet this class, but it's included for completeness.) Note, that this consolidation means that at configure time, all options are printed. This is a good thing and allows direct comparison of configs in log files. Tested: Code compiles Server boots, and shows options configured in the default build. (HTTPS, log level, etc) Change-Id: I94e79a56bcdc01755036e4e7278c7e69e25809ce Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-30Consolidate Vm implementationsEd Tanous1-4/+5
As much as the two vm implementations SEEM different, the differences largely lie in how we're getting the nbd proxy socket. One is relying on launching a process (nbd-proxy), the other is getting the fd from dbus. Given [1] exists and is in process, we need to have a plan for getting these two VM implementations into one, once that patchset is complete. This commit: Splits the vm-websocket option into vm-websocket-provider, providing two options, nbd-proxy, and virtual-media (the names of the respective apps). To accomplish this, it moves the contents of nbd-proxy into include/vm-websocket, so we can compare the similarities and start consolidating. The longer term intent is that the nbd-proxy option will be completely removed, and the code deleted. This has the additional advantage that we will no longer require the boost::process dependency, as all info will be available on dbus. As part of this, the nbd proxy websocket is also registered at /vm/0/0, to be backward compatible with the old interfaces. Tested: Code compiles. Need some help here. [1] https://gerrit.openbmc.org/c/openbmc/jsnbd/+/49944 Change-Id: Iedbca169ea40d45a8775f843792b874a248bb594 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-04Remove redfish-health-populateGunnar Mills1-7/+0
The redfish-health-populate option was scheduled to be removed in 1Q 2024. It is now 2Q, so remove the option. No upstream layers enabled it and did not find a downstream layer that did either. This was always limited to a few resources. Overall this design was only half done. A future "HealthRollup" can be proposed. Some discord discussion: [1]: https://discord.com/channels/775381525260664832/855566794994221117/1110728560819327069 Commit disabling this (merged 10 months ago): [2]: https://github.com/openbmc/bmcweb/commit/6f8273e49cffdd347c223b9538558edfb05e818a Tested: Code compiles Change-Id: I4d33c1e674ecdb0fd256df62f3795073454ae7a1 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-03-21Clean up Manager to use readJsonEd Tanous1-107/+86
Change-Id: If4237a21aa0c5f414e20cd9e7eee2f1188097e14 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-19Call systemd SetTime directlyEd Tanous1-19/+43
Internally inside phosphor-time-manager, the elapsed(uint64) dbus call just forwards the request directly to systemd after static casting to int64_t (signed). bmcweb should just call systemd directly, for several reasons. phosphor-timesyncd might block on other calls, given it's a single threaded blocking design, due to bugs like #264. Calling systemd directly means that calls that don't require phosphor networkd won't be blocked. Calling systemd directly allows bmcweb to drop some code that parses a date as int64_t, then converts it to uint64_t to fulfill the phosphor datetime interface. We can now keep int64_t all the way through. Calling systemd directly allows bmcweb to give a more specific error code in the case there NTP is enabled, registering a PropertyValueConflict error, instead of a 500 InternalError. Tested: Patching DateTime property with NTP enabled returns 400, PropertyValueConflict ``` curl -vvvv -k --user "root:0penBmc" -H "Content-Type: application/json" -X PATCH -d '{"DateTime":"2020-12-15T15:40:52+00:00"}' https://192.168.7.2/redfish/v1/Managers/bmc ``` Disabling NTP using the following command: ``` curl -vvvv -k --user "root:0penBmc" -H "Content-Type: application/json" -X PATCH -d '{"NTP":{"ProtocolEnabled":false}}' https://192.168.7.2/redfish/v1/Managers/bmc/NetworkProtocol ``` Allows the prior command to succeed. [1] https://github.com/openbmc/phosphor-time-manager/blob/5ce9ac0e56440312997b25771507585905e8b360/bmc_epoch.cpp#L126 Change-Id: I6fbb6f63e17de8ab847ca5ed4eadc2bd313586d2 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-16Fix PID Zone interface namePavanKumarIntel1-1/+1
The interface name is being loaded incorrectly which causes the DBus call to fail resulting in Internal server error. This commit changes the interface to the correct name. This is a regression caused by ea2b670d306d85d6975b6174024985491af04a89 TESTED: - PATCH /redfish/v1/Managers/bmc with below body succeeded { "Oem": { "OpenBmc": { "Fan": { "FanZones": { "Left": { "MinThermalOutput": 30.0 } } } } } } Change-Id: I0bcf858cd541dc11e802431ad983954a57d8c790 Signed-off-by: PavanKumarIntel <pavanx.kumar.martha@intel.com>
2024-03-13Correct Actions/Manager.ResetToDefaults parameter nameKonstantin Aladyshev1-10/+21
According to the Redfish Data Model specification the correct parameter name for the '/Actions/Manager.ResetToDefaults' action is not 'ResetToDefaults' but 'ResetType'. The mistake was originally introduced in the commit "Redfish: Manager: ResetToDefault" (3e40fc742265c3ec1384e7e5994e62aed356331f). Change parameter name to match with the specification. Leave some support for the old parameter name to keep the compatibility with the old clients. Tested: The POST request /redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults with {"ResetType": "ResetAll"} body accepted successfully. Redfish validator passed. Change-Id: I6aab20314f85dbda16ad3758091de8822943b761 Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
2024-01-19Remove some boost includesEd Tanous1-4/+3
The less we rely on boost, and more on std algorithms, the less people have to look up, and the more likely that our code will deduplicate. Replace all uses of boost::algorithms with std alternatives. Tested: Redfish Service Validator passes. Change-Id: I8a26f39b5709adc444b4178e92f5f3c7b988b05b Signed-off-by: Ed Tanous <edtanous@google.com>
2023-11-20managers: use async_method_call() set PID propertiesPotin Lai1-5/+5
In sdbusplus::asio::setProperty(), the property value will be wrapped by std:variant automaticly, it will fail and show `Invalid argument [generic:22]` error if we pass the property value that has been wrapped by std::variant into sdbusplus::asio::setProperty(). Because the type of property.second is DbusVariantType, we cannot use sdbusplus::asio::setProperty() for property setting, so change it back to use async_method_call(). Tested on Bletchley: Success PATCH the properties of StepwiseControllers. ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "Test1": { "NegativeHysteresis": 7.0, "PositiveHysteresis": 8.0 } } } } } } ``` Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: I92d9e0d6ffe97fa6ce2905e17497d4d0fffa1d58
2023-10-24clang-format: copy latest and re-formatPatrick Williams1-28/+28
clang-format-17 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository. Change-Id: I2f9540cf0d545a2da4d6289fc87b754f684bc9a7 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-08-21Use rangesEd Tanous1-14/+13
C++20 brought us std::ranges for a lot of algorithms. Most of these conversions were done using comby, similar to: ``` comby -verbose 'std::lower_bound(:[a].begin(),:[b].end(),:[c])' 'std::ranges::lower_bound(:[a], :[c])' $(git ls-files | grep "\.[hc]\(pp\)\?$") -in-place ``` Change-Id: I0c99c04e9368312555c08147d474ca93a5959e8d Signed-off-by: Ed Tanous <edtanous@google.com>
2023-08-14Reduce some Error log severitiesCarson Labrado1-1/+1
There are instances of ERROR logs that would work better as WARNING or DEBUG since they do not actually result in bailing early and returning an error response. Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I1e7bca0bb38487b26a4642ab72ce475170bb53c6
2023-07-20Replace logging with std::formatEd Tanous1-109/+105
std::format is a much more modern logging solution, and gives us a lot more flexibility, and better compile times when doing logging. Unfortunately, given its level of compile time checks, it needs to be a method, instead of the stream style logging we had before. This requires a pretty substantial change. Fortunately, this change can be largely automated, via the script included in this commit under scripts/replace_logs.py. This is to aid people in moving their patchsets over to the new form in the short period where old patches will be based on the old logging. The intention is that this script eventually goes away. The old style logging (stream based) looked like. BMCWEB_LOG_DEBUG << "Foo " << foo; The new equivalent of the above would be: BMCWEB_LOG_DEBUG("Foo {}", foo); In the course of doing this, this also cleans up several ignored linter errors, including macro usage, and array to pointer deconstruction. Note, This patchset does remove the timestamp from the log message. In practice, this was duplicated between journald and bmcweb, and there's no need for both to exist. One design decision of note is the addition of logPtr. Because the compiler can't disambiguate between const char* and const MyThing*, it's necessary to add an explicit cast to void*. This is identical to how fmt handled it. Tested: compiled with logging meson_option enabled, and launched bmcweb Saw the usual logging, similar to what was present before: ``` [Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled [Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800 [Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist [Info src/webserver_main.cpp:59] Starting webserver on port 18080 [Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file. [Info src/webserver_main.cpp:137] Start Hostname Monitor Service... ``` Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8
2023-06-28Refactor setProperty methodGeorge Liu1-36/+29
SetProperty is a method we should use more, and use consistently in the codebase, this commit makes it consistently used from the utility namespace. Tested: Refactor. Code compiles. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I5939317d23483e16bd98a8298f53e75604ef374d
2023-06-21Add an option flag for multi-computersystemEd Tanous1-9/+11
A number of discussions have occurred, and it's clear that multi-computer system is not a transition that can be done in a single series of commits, and needs to be done incrementally over time. This commit adds the initial option for multi-computer system support, with an option flag that can be enabled when the new behavior is desired. This is to prevent needing a long-lived fork. This option operatates such that if enabled, all ComputerSystem route options will now return 404. This is to allow the redfish service validator to pass, and to be used for incremental development. As the routes are moved over, they will be enabled, and service validator re-run. Per the description in the meson options, this option flag, and all code beneath of it will be removed on 9/1/23. The expectation is that by this date, given the appropriate level of effort in implementation, there will be no code remaining under that option flag. After this date, code beneath this option flag will be removed. Tested: No functional changes without option. With option enabled, /redfish/v1/Systems produces no entries. Spot check of various routes returns 404. Redfish service validator passes. Change-Id: I3b58642cb76d61df668076c2e0f1e7bed110ae25 Signed-off-by: Ed Tanous <ed@tanous.net>
2023-06-20Refactor getManagedObjects methodGeorge Liu1-16/+16
Since the getManagedObjects method has been implemented in dbus_utility and this commit is to integrate all the places where the GetManagedObjects method is obtained, and use the method in dbus_utility uniformly. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ic13f2bef7b30f805cd3444a75d7df17b031f2eb0
2023-06-13Make propertyValueFormatError more typesafeEd Tanous1-3/+2
Similar to other patches, make propertyValueFormatError accept a nlohmann::json object, which removes a lot of the unsafe dump code that we have littered about. Tested: No easy to replicate error. Code is identical to previous patchsets. Inspection and code compilation only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic9d0f196b6e198073189f744b738db7ffa2f1b74
2023-06-13Make propertyValueNotInList typesafeEd Tanous1-2/+2
The error codes for this function accept a string_view, which has caused a number of cases of users of this function to call dump() to_string() and all manner of other conversions. Considering that dump() is something that's difficult to call correctly, and overly wordy, it would be ideal if the message code just handled that for us. Therefore, this commit changes the prototype to include a nlohmann::json object as an argument instead of string_view, then audits the codebase for all uses, and moves them to a more normalized usage, which allows the calling code to call "dump" for them. Tested: PATCH /redfish/v1/SessionService {"SessionTimeout": 1} Returns the PropertyValueNotInList error as it did before. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If62909072db1f067ad1f8aa590bb716c84181219
2023-06-09Consistently name AsyncResp variablesEd Tanous1-27/+28
In about half of our code, AsyncResp objects take the name asyncResp, and in the other half they take the name aResp. While the difference between them is negligeble and arbitrary, having two naming conventions makes it more difficult to do automated changes over time via grep. This commit was generated automtatically with the command: git grep -l 'aResp' | xargs sed -i 's|aResp|asyncResp|g' Tested: Code compiles. Change-Id: Id363437b6a78f51e91cbf60aa0a0c2286f36a037 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-05-31health: Add option to disable health-populateWilly Tu1-3/+8
The Health populate calls GetManagedObjects at `/` which can take a lot of time. Add the option to disable to improve performance if it is not needed. Tested: ``` $ meson build -Dhealth-populate=disabled ... User defined options backend : ninja health-populate : disabled ``` Build passed. Health Status removed. Some resource still create HealthPopulate, but does not populate. It will require further refactoring to clean it out. Testing on `/redfish/v1/Chassis?$expand=.($levels=1)` On 14 chassis, from about 2.5 seconds to 400 ms. :) Before: ``` Getting times for chassis Getting good line count with wget -q -O- localhost:80/redfish/v1/Chassis?$expand=.($levels=1) Line count: 980 17:05:56: real 0m2.908s user 0m0.000s sys 0m0.030s 17:05:59: real 0m2.414s user 0m0.010s sys 0m0.010s 17:05:03: real 0m3.410s user 0m0.000s sys 0m0.020s 17:05:09: real 0m2.372s user 0m0.000s sys 0m0.010s 17:05:13: real 0m3.407s user 0m0.010s sys 0m0.000s 17:05:19: real 0m2.420s user 0m0.010s sys 0m0.000s 17:05:23: real 0m3.463s user 0m0.010s sys 0m0.000s 17:05:29: real 0m2.414s user 0m0.000s sys 0m0.010s 17:05:33: real 0m2.843s user 0m0.010s sys 0m0.010s 17:05:38: real 0m2.512s user 0m0.000s sys 0m0.020s 17:05:42: real 0m2.474s user 0m0.000s sys 0m0.010s 17:05:47: real 0m2.557s user 0m0.010s sys 0m0.010s 17:05:52: real 0m2.439s user 0m0.020s sys 0m0.000s 17:05:56: real 0m3.127s user 0m0.010s sys 0m0.000s 17:05:01: real 0m2.563s user 0m0.020s sys 0m0.000s 17:05:06: real 0m2.392s user 0m0.020s sys 0m0.020s 17:05:10: real 0m2.405s user 0m0.020s sys 0m0.000s 17:05:15: real 0m2.514s user 0m0.010s sys 0m0.010s 17:05:19: real 0m2.809s user 0m0.020s sys 0m0.010s 17:05:24: real 0m2.944s user 0m0.010s sys 0m0.010s 17:05:29: real 0m2.537s user 0m0.010s sys 0m0.000s 17:05:34: real 0m3.290s user 0m0.000s sys 0m0.000s 17:05:39: real 0m2.601s user 0m0.040s sys 0m0.000s 17:05:43: real 0m2.398s user 0m0.010s sys 0m0.040s 17:05:48: real 0m2.664s user 0m0.000s sys 0m0.020s 17:05:53: real 0m2.323s user 0m0.010s sys 0m0.000s 17:05:57: real 0m3.033s user 0m0.000s sys 0m0.010s 17:05:02: real 0m3.243s user 0m0.000s sys 0m0.010s 17:05:07: real 0m2.604s user 0m0.010s sys 0m0.010s 17:05:12: real 0m2.813s user 0m0.010s sys 0m0.010s 17:05:17: real 0m2.325s user 0m0.020s sys 0m0.000s 17:05:21: real 0m2.577s user 0m0.010s sys 0m0.000s 17:05:26: real 0m2.882s user 0m0.030s sys 0m0.000s 17:05:31: real 0m2.572s user 0m0.000s sys 0m0.020s 17:05:35: real 0m2.678s user 0m0.010s sys 0m0.010s 17:05:40: real 0m2.656s user 0m0.010s sys 0m0.010s 17:05:45: real 0m2.921s user 0m0.020s sys 0m0.000s 17:05:49: real 0m2.723s user 0m0.000s sys 0m0.020s 17:05:54: real 0m2.910s user 0m0.010s sys 0m0.010s 17:05:59: real 0m2.601s user 0m0.020s sys 0m0.000s 17:05:04: real 0m2.615s user 0m0.000s sys 0m0.000s ``` After: ``` Getting times for chassis Getting good line count with wget -q -O- localhost:80/redfish/v1/Chassis?$expand=.($levels=1) Line count: 980 16:04:43: real 0m0.188s user 0m0.020s sys 0m0.000s 16:04:43: real 0m0.195s user 0m0.010s sys 0m0.000s 16:04:45: real 0m0.219s user 0m0.010s sys 0m0.000s 16:04:48: real 0m0.226s user 0m0.020s sys 0m0.000s 16:04:50: real 0m0.208s user 0m0.020s sys 0m0.010s 16:04:52: real 0m0.226s user 0m0.010s sys 0m0.010s 16:04:54: real 0m0.419s user 0m0.000s sys 0m0.010s 16:04:57: real 0m0.222s user 0m0.010s sys 0m0.020s 16:04:59: real 0m0.194s user 0m0.000s sys 0m0.010s 16:04:01: real 0m0.191s user 0m0.010s sys 0m0.010s 16:04:04: real 0m0.276s user 0m0.010s sys 0m0.020s 16:04:06: real 0m0.183s user 0m0.020s sys 0m0.000s 16:04:08: real 0m0.193s user 0m0.040s sys 0m0.000s 16:04:10: real 0m0.406s user 0m0.020s sys 0m0.010s 16:04:13: real 0m0.317s user 0m0.000s sys 0m0.000s 16:04:15: real 0m0.442s user 0m0.005s sys 0m0.005s 16:04:18: real 0m0.226s user 0m0.010s sys 0m0.000s 16:04:20: real 0m0.217s user 0m0.020s sys 0m0.000s 16:04:22: real 0m0.200s user 0m0.010s sys 0m0.030s 16:04:24: real 0m0.423s user 0m0.010s sys 0m0.010s 16:04:27: real 0m0.203s user 0m0.020s sys 0m0.010s 16:04:29: real 0m0.433s user 0m0.000s sys 0m0.000s 16:04:31: real 0m0.318s user 0m0.020s sys 0m0.000s 16:04:34: real 0m1.206s user 0m0.000s sys 0m0.010s 16:04:37: real 0m0.403s user 0m0.000s sys 0m0.020s 16:04:39: real 0m0.353s user 0m0.010s sys 0m0.000s 16:04:42: real 0m0.291s user 0m0.000s sys 0m0.030s 16:04:44: real 0m0.742s user 0m0.020s sys 0m0.010s 16:04:47: real 0m0.369s user 0m0.010s sys 0m0.000s 16:04:49: real 0m0.215s user 0m0.020s sys 0m0.000s 16:04:52: real 0m0.204s user 0m0.000s sys 0m0.010s 16:04:54: real 0m0.418s user 0m0.000s sys 0m0.000s 16:04:56: real 0m0.215s user 0m0.000s sys 0m0.010s 16:04:58: real 0m0.202s user 0m0.010s sys 0m0.010s 16:04:01: real 0m0.202s user 0m0.010s sys 0m0.010s 16:04:03: real 0m0.212s user 0m0.010s sys 0m0.000s 16:04:05: real 0m0.694s user 0m0.010s sys 0m0.010s 16:04:08: real 0m0.201s user 0m0.010s sys 0m0.010s 16:04:10: real 0m0.230s user 0m0.000s sys 0m0.020s 16:04:12: real 0m0.206s user 0m0.010s sys 0m0.010s 16:04:15: real 0m0.446s user 0m0.010s sys 0m0.010s ``` Change-Id: I90b242e2cd24973420de871fedf9793dd1e310f3 Signed-off-by: Willy Tu <wltu@google.com>
2023-05-24Add check for "quiesced" bmc manager stateEd Tanous1-25/+42
The bmc now supports the Quiesced state, which is tracked using systemd targets. Previously, the bmc startup state was determined by systemd alone. The old systemd startup behavior is retained, but if the bmc is found to be started, this commit also check the quiesced target to determine if we should set that state as well. This allows phosphor-state-manager users to have a state that works for the quiesced use case, while avoiding race conditions on startup, or having to impose a hard dependency on phosphor-state-manager, which we know some users do not use. The reasons for not using phosphor-state-manager are outside of the scope of this commit. In comparison to the alternative: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/50318 This actually seems to have a smaller diff, so while there's some concern about adding complexity to bmcweb, this seems like this patch gets us the same behavior with slightly less code. Tested: Loaded onto a p10bmc and see this new state. systemctl start obmc-bmc-service-quiesce@0.target root@xxx:~# obmcutil state CurrentBMCState : xyz.openbmc_project.State.BMC.BMCState.Quiesced curl -k https://$bmc/redfish/v1/Managers/bmc ... "Status": { "Health": "Critical", "State": "Quiesced" }, Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I718b8ad0a43327051cb5fdf0da59a1ccfbde9940 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-05-19Clear json objectEd Tanous1-1/+0
nlohmann::json::clear() has different behavior dependent on what the underlying object is, rather than doing the expected behavior of completely clearing the json object. This didn't matter because of a similar bug in http_connection that relied on nlohmann:json::empty() which is ALSO type dependent, so these worked. Unfortunately, in 02e01b5108d46720a0b438c0d79952464320d954 we wanted to allow empty objects, and this bug was exposed. There are two places where clear() is used, once in Response, which is clearly not the intent, which is to reset the object to the original constructed state. The other place we call clear is in Manager, where we use it to clear incremental results. That was a previous best practice that has been eliminated everywhere else (now we return as many results with the error as we are able). It has been removed. Tested: Logging into the webui in firefox no longer core dumps. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic89a037b30fb40c0e6eaeb939cae6e006dd0ffac
2023-05-16Boost::urls::formatEd Tanous1-21/+19
Boost 1.82 dropped a lovely new toy, boost::urls::format, which is a lot like our urlFromPieces method, but better in that it makes the resulting uris more readable, and allows doing things like fragments in a single line instead of multiple. We should prefer it in some cases. Tested: Redfish service validator passes. Spot checks of URLs work as expected. Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia7b38f0a95771c862507e7d5b4aa68aa1c98403c
2023-05-12fix more push vs emplace callsPatrick Williams1-2/+2
It seems like clang-tidy doesn't catch every place that an emplace could be used instead of a push. Use a few grep/sed pairs to find and fix up some common patterns. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I93eaec26b8e3be240599e92b66cf54947073dc4c
2023-05-12use emplace where appropriate per clang-tidyPatrick Williams1-5/+5
The clang-tidy warning 'modernize-use-emplace' correctly flags a few places where emplace should be used over push. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I6ca79285a87d6927e718345dc8dce0387e6b1eda