summaryrefslogtreecommitdiff
path: root/test/redfish-core
AgeCommit message (Collapse)AuthorFilesLines
5 daysRemove deprecated json decodesEd Tanous1-4/+7
These decodes haven't been standard practice for a while. While they will likely break some downstream builds, we need to clean things up. If you are seeing this commit message because your downstream build is broken, please migrate your code to using nlohmann::json::object_t instead of nlohmann::json when it does the unpack. Tested: Code compiles. Change-Id: Id892ee381b2d6b40a6366ee0622cde04d2cacd7b Signed-off-by: Ed Tanous <etanous@nvidia.com>
6 daysAdd check to omit `DateTime` from etag calculationCorey Ethington1-0/+34
Ignores any json property named `DateTime` when calculating the etag value of an HTTP response as per the updated Redfish Spec (section 6.5: ETags) Tested: - Redfish Service Validator passes - Tested on romulus: 1. GET resource with a "DateTime" field ``` curl -k -H "X-Auth-Token: $XAUTH_TOKEN" "https://$BMC/redfish/v1/TaskService" \ --etag-save ./etag.txt -v ... < etag: "6A4CE897" ... { "@odata.id": "/redfish/v1/TaskService", "@odata.type": "#TaskService.v1_1_4.TaskService", "CompletedTaskOverWritePolicy": "Oldest", "DateTime": "2025-07-23T17:08:20+00:00", "Id": "TaskService", "LifeCycleEventOnTaskStateChange": true, "Name": "Task Service", "ServiceEnabled": true, "Status": { "State": "Enabled" }, "Tasks": { "@odata.id": "/redfish/v1/TaskService/Tasks" } ``` 2. GET same resource again later, etag is same as before ``` curl -k -H "X-Auth-Token: $XAUTH_TOKEN" "https://$BMC/redfish/v1/TaskService" \ --etag-save ./etag.txt -v ... < etag: "6A4CE897" ... { "@odata.id": "/redfish/v1/TaskService", "@odata.type": "#TaskService.v1_1_4.TaskService", "CompletedTaskOverWritePolicy": "Oldest", "DateTime": "2025-07-23T17:10:48+00:00", "Id": "TaskService", "LifeCycleEventOnTaskStateChange": true, "Name": "Task Service", "ServiceEnabled": true, "Status": { "State": "Enabled" }, "Tasks": { "@odata.id": "/redfish/v1/TaskService/Tasks" } ``` "DateTime" is the only value to have changed, but since it is ignored the etag did not change 3. GET with if-none-match returns 304 ``` curl -k -H "X-Auth-Token: $XAUTH_TOKEN" "https://$BMC/redfish/v1/TaskService" \ --etag-save ./etag.txt --etag-compare ./etag.txt -v ... > if-none-match: "6A4CE897" ... < HTTP/2 304 < allow: GET < odata-version: 4.0 < strict-transport-security: max-age=31536000; includeSubdomains < pragma: no-cache < cache-control: no-store, max-age=0 < x-content-type-options: nosniff < etag: "6A4CE897" < date: Wed, 23 Jul 2025 17:14:39 GMT < content-length: 0 < ... ``` Change-Id: I51f7668e75719c69c55535e4a1e48c8bae7c9488 Signed-off-by: Corey Ethington <cethington@coreweave.com>
2025-08-26Multi-host support for GET routes in systems.hppOliver Brewka1-0/+68
Add support for multi-host GET request-handling under the /redfish/v1/Systems/{computerSystemId}/ redfish resource. All multi-host supported redfish URIs can be found in this listing [1]. Multi-host meson options needed: -Dexperimental-redfish-multi-computer-system=enabled Tested: Validator passes on single-host machine and yv4 qemu emulation. [1] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/76118 Change-Id: I67c17c3dd7a354fa9a2ebbc56d4def7a7e788909 Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
2025-06-04Remove implicit conversionsEd Tanous2-10/+21
Since 2020, nlohmann has recognized that implicit conversions to and from json are an issue. Many bugs have been caused at both development time and runtime due to unexpected implicit conversions from json to std::string/int/bool. This commit disables implicit conversions using JSON_USE_IMPLICIT_CONVERSIONS [1]. This option will become the default in the future. That comment was written 3 years ago at this point, so we should prepare. Tested: Redfish service validator passes. [1] https://json.nlohmann.me/api/macros/json_use_implicit_conversions/ Change-Id: Id6cc47b9bbf8889e4777fd6d77ec992f3139962c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-05-20registries: make registration dynamicPatrick Williams1-2/+2
Rather than having to manually hook code for registries, add a small registration function to the registry header and use this registration results throughout the registry interactions. Tested: Confirmed registries have same behavior. ``` $ curl -s -k https://localhost:18080/redfish/v1/Registries/ | jq '.Members | map(."@odata.id")' [ "/redfish/v1/Registries/Base", "/redfish/v1/Registries/HeartbeatEvent", "/redfish/v1/Registries/OpenBMC", "/redfish/v1/Registries/ResourceEvent", "/redfish/v1/Registries/TaskEvent", "/redfish/v1/Registries/Telemetry" ] ``` ``` $ curl -s -k https://localhost:18080/redfish/v1/Registries/TaskEvent/TaskEvent | jq ".Messages | keys" [ "TaskAborted", "TaskCancelled", "TaskCompletedOK", "TaskCompletedWarning", "TaskPaused", "TaskProgressChanged", "TaskRemoved", "TaskResumed", "TaskStarted" ] ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Iaa355420736a2587d9da4e995208d579443ca9b8
2025-04-15Redfish OEM Patch Route Handlingrohitpai1-0/+98
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-15Avoid http request copy in OEM handlerRohit PAI1-2/+2
Initial copy was done to avoid request object going out of scope before OEM handler are invoked. The MR avoids the whole copy of the request object and create a sub route object which contains elements required for OEM route handling. Tested - Service Validator Passes - OpenBMC OEM properties and rendered well. Change-Id: I3ef80a130afe6ab764a13704a8b672f5b0635126 Signed-off-by: Rohit PAI <ropai@nvidia.com>
2025-04-03OEM Route Handling Infrastructurerohitpai1-0/+70
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-07Deduplicate event idsEd Tanous2-59/+28
Redfish specification states: ``` The value of the id field shall be the same as the Id property in the event payload. The value of the Id property in the event payload should be the same as the EventId property of the last event record in the Events array. The value of the EventId property for an event record should be a positive integer value and should be generated in a sequential manner. ``` The event service code did not implement that correctly. So: 1. Add ID fields for all events. 2. Remove the per-sse connection id field and rely solely on EventServiceManager. 3. Make sure all paths, (including metric report) are generating an event id that's based on the eventservice event id Tested: Redfish event listener now sees events populated. LastEventId when sent to the SSE socket now sees a contiguous id. ``` uri=$(curl -s --user "root:0penBmc" -k "https://192.168.7.2/redfish/v1/EventService" | jq -r .ServerSentEventUri) curl -u root:0penBmc -vvv -k -N -H "Accept: text/event-stream" -H "Last-Event-Id: 0" "https://192.168.7.2$uri" ``` Change-Id: Ic32e036f40a53a9b2715639ae384d7891c768260 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-02-05Fix Message arg error in JSON Patchrohitpai1-0/+16
When array/vector object is expected in JSON patch the error info does not contain the actual wrong property instead shows "null". Fix is to correct the value in the error info. Tested - add new test case to verify this - unit tests are passing. Change-Id: Ica26ac9e501b5a34a5b118769cc1917eeab30524 Signed-off-by: rohitpai <rohitpai77@gmail.com>
2025-02-03Move error code utils into new filerohitpai2-141/+161
Error code utils can be used for aggregating error responses from multiples responses including use case for managing separate route handlers for OEM namespace Tests Units tests are passing. Change-Id: I2223d41fb318c0276de1ca64dd3e841bb988d902 Signed-off-by: rohitpai <rohitpai77@gmail.com>
2025-01-31Move io context to singletonEd Tanous1-5/+1
The way we pass around io contexts is somewhat odd. Boost maintainers in slack recommended that we just have a method that returns an io context, and from there we can control this (context link lost years ago). The new version of clang claims the singleton pattern of passing in an io_context pattern is a potential nullptr dereference. It's technically correct, as calling the singleton without immediately initializing the io context will lead to a crash. This commit implements what the boost maintainers suggested, having a single method that returns "the context" that should be used. This also helps to maintain isolation, as some pieces are no longer tied directly to dbus to get their reactor. Tested: WIP Change-Id: Ifaa11335ae00a3d092ecfdfb26a38380227e8576 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-01-26$filter Query parameter support for nested keys addedChandramohan Harkude1-0/+17
Implemented the code to identify the '/' character in the key and perform the level by level search Testing : Tested query parameter with path separated by / example curl -k -u root:0penBmc https://<IP>/redfish/v1/Systems/ Baseboard/LogServices/FaultLog/Entries?$filter=CPER/Oem/ OEM/IpSignature eq 'DRAM-CHANNELS' Results having 'DRAM-CHANNELS' in nested path "CPER/Oem/ OEM/IpSignature" are listed. Change-Id: Ie6cf796026a29ec7a3e8a0366bbfd0c658d0ac7e Signed-off-by: Chandramohan Harkude <chandramohan.harkude@gmail.com>
2025-01-22Roll out error message utilsEd Tanous1-1/+0
This code should really be in a cpp/hpp file, not in a generated python script. The python script housed this temporarily to allow us to generate the registries. It's time to roll it out. Tested: Message registries generate successfully on GET. Redfish service validator passes. Change-Id: I7aca2d0a7fac6d530511421b667ff732617df61e Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-01-20Use SPDX identifiersEd Tanous23-0/+46
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>
2025-01-13dbus event subscriptions: test dbus_log_watcherAlexander Hansen1-0/+76
Currently that code is still unfinished, but we can already define some trivial testcases. The main result of this function is populating EventLogObjectsType. Tested: Unit tests pass. Change-Id: I2e23147190be33192d41176413c16cd98c7bfd81 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2024-12-27Fix setting gatewaysEd Tanous1-0/+212
There's a number of conditions in setting gateways that don't work properly. Specifically, one of the issues is setting a gateway on an address that already exists. It returns a PropertyValueConflict error on Ipv4Addresses/1/Gateway with Ipv4Addresses/1/Gateway Obviously an address can't conflict with itself, so this is wrong. To address this, move the gateway setting and selection code into a routine outside of the main loop, after all the gateways are accounted for, and so we can treat them separately. Tested; PATCH to an existing ip address works, and no longer returns the error. More test cases likely needed. Change-Id: I0339e02fc27164337416637153d0b0f744b64ad8 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-27Update Submit Test event feature to send custom dataChandramohan Harkude1-0/+104
Changes Added : Updated the submit test event feature to send test data as per spec https://www.dmtf.org/sites/default/files/standards/documents/ DSP2046_2019.1.pdf Testing : Tested sending custom test data and same data received at the event listener Change-Id: I2c2363a676aafd39c121c9fe4e16402c0f5961e2 Signed-off-by: Chandramohan Harkude <chandramohan.harkude@gmail.com>
2024-12-12Fix clang-tidy for gcc-14Ed Tanous1-0/+1
We use these pragmas, that we must've been getting transitively through chrono in the past. Now we need to include them explicitly. Change-Id: Iee4c0a8866981b91adaa17bee0678b2c10e65ea9 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-11Put simple update behind an optionEd Tanous1-18/+9
4e338b2313f9f2a91aa1fb36693e36a328d58933 Removed tftp update support from the codebase, but left SimpleUpdate in a non functional state. Given that a number of forks have implemented the HTTPS/SCP versions of simple update, we don't want to fully delete the code at this time, so for the moment put it behind an option flag. Tested: WIP Change-Id: Ibab1e3a48ff640787eabf8ed5f7a5c08e3381307 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-11Always fall back to ChassisType RackMountGunnar Mills1-1/+2
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/75914 added support for dynamic ChassisType. Before 75914, ChassisType was hardcoded to RackMount. If you implement Inventory.Item.Chassis the default Chassis Type is Unknown. Unknown in 75914 maps to Invalid and ChassisType is left off the Redfish Chassis resource. The Redfish Validator flags this as an error since ChassisType is a required property in the Chassis schema. The implementations should be setting the ChassisType but let's get bmcweb bumps back on the rails and just set ChassisType = RackMount if there is an error or if the Chassis Type is something we can't map (like Unknown). This "your default ChassisType is RackMount" matches what we had before. Tested: Inspection and unit tests only. Change-Id: Id577be522be7c2d3463da9c497d9063a284a4d54 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-12-10Make message registries use 2 digit versionsEd Tanous2-4/+4
Redfish specification, section 9.5.11.2 says: The MessageId property value shall be in the format: <MessageRegistryPrefix>.<MajorVersion>.<MinorVersion>.<MessageKey> bmcweb in certain places has incorrectly used the 3 digit version instead of the 2 digit version. This commit fixes that by modifying the parse_registries script to generate 3 separate struct entries to represent the registry version, and parse them where appropriate. MessageRegistryFileCollection uses the 3 digit version. No behavior changes. Message/event log entries use the 2 digit version. This will cause a MessageId change from: Base.1.19.0.InternalError to Base.1.19.InternalError This is a breaking change, so a new option to allow the old behavior is provided. Tested: Redfish Service validator passes. Heartbeat events on EventService show 2 digit versions. Change-Id: I4165e994f73e200f13bed8ea76cb58bee2b69faa Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-04Simplify journal pagingEd Tanous1-71/+0
sd-journal has its own paging mechanisms for generating and seeking to unique ids. Ironically they look fairly similar to what we've implemented here, but they have more content, presumably because they can use internal implementation details to do paging. This commit switches all sd-journal paging to use cursors. Functionally this changes the odata.id from being a concatenated string into being a base64 encoded identifier that is much longer. The end result is vastly simplified code. Tested: check journal script [1] succeeds [1] https://github.com/openbmc/openbmc-tools/blob/master/check_journal/check_journal Script runs to completion and shows all tests passed. Change-Id: Ia49fbfc272bef6dfbe1ea45a8d993dc785041659 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-02Dynamically determine ChassisType for RedfishJoseph-Jonathan Salzano1-0/+95
The function handleChassisGetSubTree will now handle properties that are part of the xyz.openbmc_project.Inventory.Item.Chassis interface. At time of development this is only ChassisType. The new function "handleChassisProperties" will attempt to get the Type property from the interface, translate it to a Redfish standard string and set it as the ChassisType value. If the property cannot be found the default "RackMount" will be used. Tested: Added and ran 4 new unit tests. Ran manual tests with ChassisType being exposed via dbus in QEMU emulated environments. Tested on ASPEED 2600 eval board. Change-Id: Ibbd048db5007f5154e88495ec6e651a3a2137b06 Signed-off-by: Joseph-Jonathan Salzano <joseph-jonathan.salzano@hp.com>
2024-11-22json utility: fixed core dump during sensor loadJayanth Othayoth1-0/+8
bmcweb replaces underscores with spaces in sensor names for better readability. The existing objectKeyCmp function did not handle this case, leading to core dumps in the sensor load path. Error details are provided below. ``` bmcwebd[1368]: [DEBUG sensors.hpp:507] Added sensor P0_NS_VR_FAN_2 bmcwebd[1368]: terminate called after throwing an instance of 'boost::detail::with_throw_location<boost::system::system_error>' bmcwebd[1368]: what(): leftover [boost.url.grammar:4] ``` Implemented a new algorithm that alphabetically sorts non-URL keys and retains the existing logic for URL-type keys. Tested: Updated and verified the test cases. Change-Id: I39c3f7cc54dec5e7cf9658977e1078acb827afb2 Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com> Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-21Unit test: event_log.cppAlexander Hansen1-0/+181
Provide basic unit test coverage for the functions from event_log.cpp. Tested: Unit tests pass. Change-Id: Ib555d2404e0f5cc5d5610d466100d0f07c79f5d9 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2024-11-20Enable gcc-14 buildsEd Tanous1-0/+7
gcc-14 enables the std::chrono features we need for doing lots of time conversions. For whatever reason, std::chrono accepts a an hour of 60, whereas date.h didn't. This test case is really just a corner case, so accept either answer. Tested: Unit tests pass. Good coverage. Change-Id: I2fb7fcbebb2a4126b36f99d27b216b835d1e2994 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-10-17Handling of OutOfRange in ReadJsonMyung Bae1-0/+21
Currently readJsonPatch returns `PropertValueNotInList` in case when an input integer is out of range. This change is to return `PropertyValueOutOfRange` for the case out-of-range integer input. Tested: - Verify PATCH with an out-of-value integer. e.g. ``` $ curl -k -X PATCH https://${bmc}/redfish/v1/EventService/ -H "Content-Type: application/json" -d '{ "DeliveryRetryIntervalSeconds" : 4294967296}' ``` Before the change, its `MessageId` is `PropertyValueNotInList`. ``` "Message": "The value '4294967296' for the property DeliveryRetryIntervalSeconds is not in the list of acceptable values.", "MessageId": "Base.1.19.0.PropertyValueNotInList", "MessageSeverity": "Warning", "Resolution": "Choose a value from the enumeration list that the implementation can support and resubmit the request if the operation failed." ``` After the change, its `MessageId` will be `PropertyValueOutOfRange`. ``` "Message": "The value '4294967296' for the property DeliveryRetryIntervalSeconds is not in the supported range of acceptable values.", "MessageId": "Base.1.19.0.PropertyValueOutOfRange", "MessageSeverity": "Warning", "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed." ``` - Redfish Service Validator passes Change-Id: I0d0c5ecbc9f416b68fa7c0e81a0ea896ec2e50af Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2024-10-14Implement TemperatureReadingsCelsius property for ThermalMetricsGeorge Liu1-0/+19
The ThermalMetrics schema[1] provides for efficient thermal metric gathering for thermal sensors. The schema allows retrieving just the thermal metrics with one Redfish URI. This prevents the additional work required when returning all the sensor data, or multiple Redfish URI calls to retrieve the properties for all of the thermal sensors. This commit implements the TemperatureReadingsCelsius property of ThermalMetrics[1]. ThermalMetrics is a property of ThermalSubsystem[2]. TemperatureReadingsCelsius is a SensorArrayExcerpt[3]. [1] https://redfish.dmtf.org/schemas/v1/ThermalMetrics.v1_0_1.json [2] https://redfish.dmtf.org/schemas/v1/ThermalSubsystem.v1_3_2.json [3] http://redfish.dmtf.org/schemas/v1/Sensor.v1_9_0.json#/definitions/SensorArrayExcerpt The temperature sensors are found by finding 'all_sensors' endpoints for specific chassis of D-Bus service /xyz/openbmc_project/sensors/temperature. An entry of SensorArrayExcerpt is built for each temperature sensor retrieved. Implementation Notes: - Common function sensor_utils::objectPropertiesToJson() is used to fill in sensor excerpt properties. Currently the only excerpt ChassisSubNode is ThermalMetrics. However there are others excerpts defined by Redfish. Right now mostly this is just skipping things, but I'm expecting when other sensor excerpts are implemented that some of the other properties may be added for excerpts as well. I'm expecting the combination of the chassisSubNode and the sensorType will be used to determine which properties are included for a particular call to build a sensor Json representation. - New sensor_utils::objectExcerptToJson() function created. This wraps sensor_utils::objectPropertiesToJson() and builds DataSourceUri for a sensor excerpt. - New sensor_utils::getAllSensorObjects() function created. This builds list of 'all_sensors' association endpoints for specified D-Bus path with specified D-Bus interfaces. Callback function is called with list for handling sensors. Tested: 1. Redfish Service Validator passed. 2. doGet method: ``` curl -k -H "X-Auth-Token: ${token}" -X GET https://${bmc}/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics { "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics", "@odata.type": "#ThermalMetrics.v1_0_1.ThermalMetrics", "Id": "ThermalMetrics", "Name": "Thermal Metrics", "TemperatureReadingsCelsius": [ { "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps0_temp0", "Reading": -131072000.0 }, { "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps0_temp1", "Reading": -131072000.0 }, { "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps0_temp2", "Reading": -131072000.0 }, { "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps1_temp0", "Reading": -131072000.0 }, { "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps1_temp1", "Reading": -131072000.0 }, { "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps1_temp2", "Reading": -131072000.0 } ], "TemperatureReadingsCelsius@odata.count": 6 } ``` 3. Verification of DataSourceUri: ``` curl -k -H "X-Auth-Token: ${token}" -X GET https://${bmc}/redfish/v1/Chassis/chassis/Sensors/temperature_ps1_temp0 { "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/temperature_ps1_temp0", "@odata.type": "#Sensor.v1_2_0.Sensor", "Id": "temperature_ps1_temp0", "Name": "ps1 temp0", "Reading": -131072000.0, "ReadingType": "Temperature", "ReadingUnits": "Cel", "Status": { "Health": "OK", "State": "Enabled" } } ``` 4. A bad chassis ID: ``` curl -k -H "X-Auth-Token: ${token}" -X GET https://${bmc}/redfish/v1/Chassis/chassisBAD/ThermalSubsystem/ThermalMetrics { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Chassis named 'chassisBAD' was not found.", "MessageArgs": [ "Chassis", "chassisBAD" ], "MessageId": "Base.1.18.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.18.1.ResourceNotFound", "message": "The requested resource of type Chassis named 'chassisBAD' was not found." } } ``` Signed-off-by: George Liu <liuxiwei@ieisystem.com> Change-Id: I6e4ed1f281fd5371c978983b6cc5666badd3752c Signed-off-by: Janet Adkins <janeta@us.ibm.com>
2024-10-14Refactor eventMatchesFilterEd Tanous2-108/+82
eventMatchesFilter no longer needs to be a member of the Subscription class, because it no longer uses subscription data. Refactor so it can be in its own file, with its own set of unit tests. Tested: Unit Tests pass. Change-Id: I718fa36021078973609591c704cb717d31079df7 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-10-14Move UserSubscription to compositionEd Tanous1-21/+27
This allows for two very important simplifying changes. First, we can use the default copy operators on the UserSubscription class, which is far less error prone than writing it manually, which we have two copies of in code already. Second, it allows the Subscription class to move to using values rather than shared_ptr everywhere, which cleans up a significant amount of code. Tested: Ran Redfish-Event-Listener, subscription created and destroyed correctly. Calling POST SubmitTestEvent showed events propagating to server. Change-Id: I6d258cfe3594edddf3960ae2d4559d70acca1bf8 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-10-09Add unit test for trailing slashesEd Tanous1-0/+9
Common error #9 requires that most urls end in a trailing slash. Given the redfish standard, we know that all redfish routes need to end in a trailing slash, so write a unit test that verifies that is true. Despite code review, this appears to have snuck into the codebase in 4 different handlers. Fix those at the same time so the tests pass. Tested: Unit tests pass. Change-Id: I0299a7231662725a7100d5308b3977a549b49253 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-10-09Support ProductionDate reportHieu Huynh1-0/+11
DSP0268 Redfish Data Model Specification provides ProductionDate property for various schema. phosphor-dbus-interface [1] also supports BuildDate property which we can map from FRU data, like `Board Manufacturer Date`. This adds code to support which gets the date from BuildDate property and report via Redfish. [1] https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Decorator/Asset.interface.yaml#L16 Tested: Redfish Validator passes Signed-off-by: Hieu Huynh <hieuh@os.amperecomputing.com> Change-Id: Ie4ae564fa00218e7896f04ec61941fa92b23b912
2024-10-09Write test to ensure that redfish validatesEd Tanous1-0/+26
Dependent on configuration options, we might have overlapping paths, as what had to be fixed in: 36a59eafed32c0063d444fc0722f899c0024092d and 5ffd11f248f155614bf30b498cb01a4e2065094d We should be able to catch these in a unit test, so this commit adds a test that initializes the Redfish tree, and ensures that the router validates. In theory this will catch any misconfigurations we might have. Tested: Unit tests pass. Change-Id: I8721380c96301b57e40819f5ae2e725057ea1bb7 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-10-05dateStringToEpoch: add the additional formatHieu Huynh1-0/+13
This adds the additional format for ISO 8601, such as YYYYMMDD or YYYYMMDDThhmmssZ. Tested: Test case 1: The input ISO 8601 timestamp: 20230531T000000Z The output Epoch timestamp: 1685491200000000 Test case 2: The input ISO 8601 timestamp: 20230531 The output Epoch timestamp: 1685491200000000 Signed-off-by: Hieu Huynh <hieuh@os.amperecomputing.com> Change-Id: I23080a466b2edeecb5d8a4fb7ec0b00739454056
2024-10-03json utility: Update sort algorithmsEd Tanous1-2/+78
Modified sort utility to be able to sort on a specified key. New utility function sortJsonArrayByKey() added. Note: - Function odataObjectCmp() renamed to objectKeyCmp() - New function odataObjectCmp() created which calls objectKeyCmp() with @odata.id key specified. - Comments for odataObjectCmp() didn't match behavior for object without key. These objects are sorted as less than objects with the key. - sortJSONResponse() modified to use the new sortJsonArrayByKey(). Tested: - Added new unit tests. These tests are in addition to the existing tests. So they focus on testing comparing by different keys. The existing tests already cover the different permutations of the basic comparisons. - Redfish Service validator passes Change-Id: I949b7cb868c59a8eeda3798e6a82a1572bbc5792 Signed-off-by: Ed Tanous <etanous@nvidia.com> Signed-off-by: Janet Adkins <janeta@us.ibm.com>
2024-10-01Bump base registry to 1.19.0Jishnu CM1-3/+3
Adds GenerateSecretKeyRequired registry to the Base for MFA Change-Id: Ia690639b4bebbbd265b223bd626b0eb814103f99 Signed-off-by: Jishnu CM <jishnunambiarcm@duck.com>
2024-09-23Add extra subscription params supportEd Tanous1-0/+102
OriginResource allows filtering messages on a per-device basis. This was already listed as supported in our docs. RegistryPrefixes is also added. Tested: Unit tests pass. Change-Id: Idfde8416f2f466ce11957177e052b540fc669888 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-05Sensors: Add enum for chassis sub nodesJanet Adkins1-0/+37
Added ChassisSubNode enum for defining the different chassis subNode paths to retrieving sensor data. Modified path building sensor data to use the enum. Other paths were left still using the string. Specifically the paths using SensorsAsyncResp as these primarily use the strings for human readable output. Added utility functions to convert to/from enum to string value. Added unit tests for new utility functions. Tested: - Verified sensor paths before and after change had no change: - /redfish/v1/Chassis/chassis/Sensors - /redfish/v1/Chassis/chassis/Thermal - /redfish/v1/Chassis/chassis/Power - Selection of: /redfish/v1/Chassis/chassis/Sensors/<sensor> - /redfish/v1/Chassis/chassis/Sensors?\$expand=* - Redfish Validator passes Change-Id: I02bb5f3c0c49d85dbd1dff911d9f1a8467d6b1db Signed-off-by: Janet Adkins <janeta@us.ibm.com>
2024-09-05Break out post codesEd Tanous2-30/+43
Similar to other patches, break out the post codes log services into their own file. log_services.hpp is far too large. Change-Id: I3cb644d52a9d3b5f9a15a2f90c1b69c87491e5c8 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-04Remove IWYU pragmasEd Tanous10-64/+16
These were added as part of d5c80ad9c07b94465d8ea62d2b6f87c30cac765e: test treewide: iwyu Since then, Nan hasn't been very active on the project, and to my knowledge, since the initial run, we've never used IWYU again. clang-include-cleaner seems to work well without needing these pragmas, and is what we're using, even if it's less useful than IWYU. Remove all mention of IWYU. Tested: Code compiles. Change-Id: I06feedeeac9a114f5bdec81d59ca83223efd8aa7 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-04Fix includesEd Tanous6-6/+8
This commit is automatically generated by enabling clang-include-fixer. Tested: Code compiles. Change-Id: I475d7b9d43e95bbdeeaadf11905d3b2a60aa8ef3 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-03Filter out query params in searchCollectionsArrayJoonwon Kang1-0/+3
Previously searchCollectionsArray() had an implicit assumption that it would not receive query parameters in the input URI. This patch adds the assumption that it will. Tested: Unit tests pass Confirmed that the query to the URI `/redfish/v1/UpdateService?$expand=.($levels=1)` worked as expected now. Change-Id: Ia33ece024c58e9d32f5815b2c69e8ab62c0c2127 Signed-off-by: Joonwon Kang <joonwonkang@google.com> Signed-off-by: Ed Tanous <etanous@nvidia.com> Signed-off-by: Carson Labrado <clabrado@google.com>
2024-08-24Make PATCH return 204 againEd Tanous1-0/+13
It was correctly pointed out that for PATCH, we cannot return 200 success without also returning the object, per Redfish. This commit partially reverts cdf25ff, to give PATCH the old (204) behavior again. Tested: Patch now returns 204 Change-Id: I8ede932a73ae064586d94c47393e4418350adb00 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-08-22Sensors: Create utility class for sensorsJanet Adkins2-36/+52
Create a separate utility class for sensors. The goal is to make these functions easily available for use outside of sensors for paths which need reference sensors. Moved splitSensorNameAndType() into new utility class. Created new utility function getSensorId(). The Id for a sensor is built from its name and type in a few different locations. These are modified to call the new function. The function has also been simplified to use std::format() to build the Id. Tested: - Checked before and after results for queries using this function: (Note: I was not able to confirm the setSensorsOverride() caller as it is only being used for redfish-allow-deprecated-power-thermal URI.) ''' - https://${bmc}/redfish/v1/Chassis/chassis/Sensors - https://${bmc}/redfish/v1/Chassis/chassis/Sensors/<str> where <str> was sensors of different types - https://${bmc}/redfish/v1/Chassis/chassis/Sensors?\$expand=* - https://${bmc}/redfish/v1/Chassis/chassis/ThermalSubsystem/Fans - https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies ''' - Redfish Validator passed Change-Id: Ifa200b6e63f8e52d47f70c33d350999f5c527bbd Signed-off-by: Janet Adkins <janeta@us.ibm.com>
2024-08-17clang-format: re-format for clang-18Patrick Williams3-55/+59
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-17Make set properties return 200 Success not 204Ed Tanous1-2/+14
Both 200 and 204 are allowed by the Redfish specification. Table 11 states: 200 OK Success, and the action's schema definition does not contain an action response. 204 No Content: Success, and the action's schema definition does not contain an action response. While both of these are allowed, we accidentally changed behavior in the following commit: 87c4496 Move to Redfish setProperty call When we transitioned these over to the common dbus calling methods. This commit restores the old behavior of returning 200 success on actions, which some implementations are expecting. Tested: WIP. Change-Id: I02e47585acf85bd04dcb9d428ef3e39a21d9c75f Signed-off-by: Ed Tanous <ed@tanous.net>
2024-07-30Add SSE filter param supportEd Tanous1-2/+2
The Redfish spec require filtering of SSE entries to be supported. This commit rearranges the code, and implements SSE sorting as well as support for Last-Event-Id. To do this it adds a dependency on boost circular_buffer. Tested: SSE connections succeed. Show filtered results. Change-Id: I7aeb266fc40471519674c7b65cd5cc4625019e68 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-07-25Fix Task Monitor URIEd Tanous1-2/+19
Fixes #272 The TaskMonitor urls we create aren't correct per Redfish. Per DSP0266 section 12.2, our TaskMonitor URIs should take the form /redfish/v1/TaskService/TaskMonitors/<id> Note that even though this appears to be a collection, it is not, and does not "exist" in the Redfish schema, hence why it is called out explicitly. Tested: Started dump collection task with POST ``` /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData ``` GET /redfish/v1/Tasks/0 Returned TaskMonitor = /redfish/v1/Tasks/TaskMonitors/0 GET /redfish/v1/Tasks/TaskMonitors/0 returned 200 Change-Id: I9fb1d62090f7787d7649c077b748b51ac3202f8a Signed-off-by: Ed Tanous <ed@tanous.net>
2024-07-23Make journal log efficientEd Tanous1-5/+9
Journal logging currently loops over all entries to find even a single entry. This was reasonable at the time when bmc couldn't really store a lot, but now that BMCs are getting significantly more flash storage, this simplification is insufficient. In an example system with an AST2600, this API takes 32 seconds to respond. This is mediocre for obvious reasons. This commit updates to use the sd_journal APIs to let journald do the skipping, which can use internal details and can be a lot more efficient. To get the total size, bmcweb still needs to pull the sequenceids of HEAD and TAIL to determine the complete size, but this is still reasonable. Tested: Redfish service validator passes. Various versions of top and skip return the correct result, pulling various top sizes from 0, omitted to the limit. https://gerrit.openbmc.org/c/openbmc/openbmc-tools/+/72975 To test all corner cases. Change-Id: I0456bca4e037529f70eaee0bdd9191e9d5839226 Signed-off-by: Ed Tanous <etanous@nvidia.com>