summaryrefslogtreecommitdiff
path: root/redfish-core/src
AgeCommit message (Collapse)AuthorFilesLines
35 hoursImplement Fabric PortCollection and Port schemasHEADmasterGeorge Liu1-0/+2
This implements 2 schemas for FabricAdapters [1][2]. The implementation uses `GetAssociatedSubTreePathsById` & `GetAssociatedSubTreeById`. - https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/69999 The association is defined via - https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/62881. The backend port examples are also committed via - https://gerrit.openbmc.org/c/openbmc/openpower-vpd-parser/+/66540 - https://gerrit.openbmc.org/c/openbmc/openpower-vpd-parser/+/70888 - https://gerrit.openbmc.org/c/openbmc/openbmc/+/66541 The current submission only implements the basic properties of Port (e.g. Id, Name etc) as a foundation of the future additional properties. - Location - LocationIndicatorActive - Status One example of Ports is this cable card for the i/o expansion drawers and modeling the 2 ports on the cable card [3]. These ports have an identify led, a location code, and a status. Tested: - Redfish Validator passes - perform GET methods like these: ``` curl -k -X GET https://${bmc}/redfish/v1/Systems/system/FabricAdapters/disk_backplane0 { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0", "@odata.type": "#FabricAdapter.v1_4_0.FabricAdapter", "Id": "disk_backplane0", ... "Ports": { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports" }, ... } ``` ``` curl -k -X GET https://${bmc}/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports", "@odata.type": "#PortCollection.PortCollection", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports/dp0_connector4" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports/dp0_connector5" } ], "Members@odata.count": 2, "Name": "Port Collection" } ``` ``` curl -k -X GET https://${bmc}:18080/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports/dp0_connector4 { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports/dp0_connector4", "@odata.type": "#Port.v1_7_0.Port", "Id": "dp0_connector4", "Name": "dp0_connector4" }% ``` Also try the invalid port like ``` curl -k -X GET https://${bmc}:18080/redfish/v1/Systems/system/FabricAdapters/io_module1/Ports/INVALID { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Port named 'INVALID' was not found.", "MessageArgs": [ "Port", "INVALID" ], "MessageId": "Base.1.16.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.16.0.ResourceNotFound", "message": "The requested resource of type Port named 'INVALID' was not found." } }% ``` [1] https://redfish.dmtf.org/schemas/v1/PortCollection_v1.xml [2] https://redfish.dmtf.org/schemas/v1/Port_v1.xml [3] https://www.ibm.com/docs/en/power10?topic=details-pcie4-cable-adapter-fc-ej24-ccin-6b92 Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I8c64c16764e85c0716e264263708b18f897a2c0c Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-08-27Move common structuresEd Tanous2-2/+2
It's ideal if the various BMCWEB_ROUTE lib calls do not call from one another. This reduces the amount of code that's compiled each time separately. Tested: Code compiles. Change-Id: I4822ce66c122f261cc6aa34bbd99371b7eff48c8 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-08-26Fix includesEd Tanous1-2/+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-3/+0
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-18Generate update registryAlexander Hansen1-0/+311
Generate the update registry, needed to return correct error messages from update service. Change-Id: Ifaa699cad8531070aea47d2476c1834df7c61e08 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2025-07-25Work around nlohmann changesEd Tanous1-0/+11
https://github.com/nlohmann/json/issues/4475 recently changed behavior that we rely on in a lot of places, and unit tests appear to have caught the failure. Functionally, this changes the readJson* class of values to attempt to read as the type requested first, then attempt to read as the opposite int/uint type requested, with a range check. In addition, the range check functions now need updated to handle comparisons between non-similar value types. Luckily c++20 added cmp_less/greater type functions that we can make use of. Tested: unit tests pass. Change-Id: If114bd55225a3a9948e80a407b19b69f50d048b6 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-06-26Map Error.Unavailable to something betterGunnar Mills1-1/+2
This commit is meant to kick off discussion on how we map errors from dbus to Redfish. Currently WIP. Looking for feedback. Do we want a new xyz.openbmc_project.Common.Error.ResourceInStandby that we can map to Redfish's resourceInStandby? Do we think PropertyValueExternalConflict should be mapped to something different? Are we okay with this commit, does this work for AppliedConfig? xyz.openbmc_project.Common.Error.Unavailable was added to Logging Entry's Resolved Property as an error. It is used for cases when the users attempts to set the Resolved property but is prevented until some action is taken, "the system is not currently in a state to allow this", the PDI review here has some more discussion[1]. The current mapping of xyz.openbmc_project.Common.Error.Unavailable to resourceInStandby was added to SetProperty here[2] in April and comes from this AppliedConfig error handling which was added in May 2021 by Jonathan at Intel[3]. Mapping Error.Unavailable to resourceInStandby is a big assumption that might apply in the AppliedConfig usecase but wouldn't overall. PropertyValueExternalConflict is a bit broader and might work in this AppliedConfig case? The PDI AppliedConfig[4] and AppliedConfig in smbios[5]. Redfish doesn't have a Temporary Unavailable to mean "the system is not currently in a state to allow this", PropertyValueExternalConflict is as close as we get. xyz.openbmc_project.Common.Error.NotAllowed maps to Redfish's propertyNotWritable and that is "this property can never be wrote". We map a few things to serviceTemporarilyUnavailable, the only Redfish error to use the word "Unavailable", but that is for temporarily unavailable and retry in x seconds. These Redfish errors can be found at: https://redfish.dmtf.org/registries/Base.1.19.0.json [1]: https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/74019 [2]: https://github.com/openbmc/bmcweb/commit/87c449664e5375abb040af6fad63ef965c311bec [3]: https://github.com/openbmc/bmcweb/commit/3cde86f14b7835775d7c37e993fb84a3cd01ef9d [4]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/73c931fb942daa714bfff17e950b9d5622a25842/yaml/xyz/openbmc_project/Control/Processor/CurrentOperatingConfig.interface.yaml#L13 [5]: https://github.com/openbmc/smbios-mdr/blob/1d73dccc89f0bb9d1dce3543e5af6b3e3087d5f4/src/speed_select.cpp#L160 Tested: None. Change-Id: I4a48937b1801189acddd02c89aa01ca0cd15362b Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2025-06-06Make PropertyNotWritable 405Gunnar Mills1-1/+1
forbidden (403) - "a 403 error means there is an authorization / permission problem." 405 "Method Not Allowed" error means that the web server understands the request but refuses to process it because the HTTP method (like GET, POST, PUT, etc.) used in the request is not supported by the server or the resource.". Following a stackoverflow response here [1]. Dell mapped PropertyNotWritable to a 400 error. [2] A 400 would be my 2nd choice. [1]: https://stackoverflow.com/questions/52892076/http-code-to-return-for-unsupported-patch [2]: https://www.dell.com/support/manuals/en-in/idrac7-8-lifecycle-controller-v2.30.30.30/redfish_v2.30.30.30/managernetworkprotocol?guid=guid-b2be28b5-60a5-4782-83ac-3efb3af79ef2&lang=en-us Change-Id: Iff3f773a1fdbea96d65f8b82fec75cfc34519ae0 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2025-05-27Make registries return an object_tEd Tanous4-190/+206
All the registry helper functions should return an object_t, given that they're guaranteed to return an object. nlohmann::json as a type can technically be string/int/bool/null/object/array, so it causes some peculiarities in parsing. Change-Id: If296477cb8d066d7f44ef0d12f17d94a5301e450 Signed-off-by: Ed Tanous <ed@tanous.net>
2025-05-20registries: make registration dynamicPatrick Williams5-175/+208
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-29Fix more movesEd Tanous1-8/+19
This commit is fixing coverity issues reported for copy in stead of move. Tested: redfish service validator passes Change-Id: I97e755830f28390e7c4bfaba6f3f947898a21423 Signed-off-by: Ed Tanous <ed@tanous.net>
2025-04-25Fix race condition between subscription deletionsMyung Bae1-2/+4
After the connection max-retry with the policy of "TerminateAfterRetries", coredump may have been occurred although it seems rare. Stack frame of One occurrency indicates that an invalid memory access happened inside deleteSubscription(). 1) http_client is waiting for async_read() to handle sendEventToSubscriber(). ``` - recvMessage via async_read() [hold Connection with shared_from_this()] --> call afterRead(). - afterRead() find the invalid response (i.e. probably disconnected from the other end?), and call waitAndRetry() - waitAndRetry() detects the maxRetryAttempts (with the policy of "TerminateAfterRetries"), and invokes callback callback is ConnectionPool::afterSendData(). ``` 2) Meanwhile, the subscription is explicitly requested to delete via Redfish API. ``` BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/") ... .methods(boost::beast::http::verb::delete_)( ... if (!event.deleteSubscription(param)) ``` 3) Later on, http_client invokes resHandler() but this resHandler() is bound with its own subscription object like this. ``` bool Subscription::sendEventToSubscriber(std::string&& msg) { client->sendDataWithCallback( std::move(msg), userSub->destinationUrl, static_cast<ensuressl::VerifyCertificate>( userSub->verifyCertificate), httpHeadersCopy, boost::beast::http::verb::post, std::bind_front(&Subscription::resHandler, this)); <== ``` As the result, if the subscription object is already deleted outside (i.e. Redfish API delete), resHandler() which is from async_read callback may be accessing the invalid object. ``` void Subscription::resHandler(const crow::Response& res) { ... if (client->isTerminated()) { hbTimer.cancel(); if (deleter) { deleter(); --> This invokes deleteSubscription() } } } ``` Quick summary of stack frame: ``` 0 __GI_memcmp (s1=<optimized out>, s2=<optimized out>, len=<optimized out>) at memcmp.c:342 warning: 342 memcmp.c: No such file or directory at memcmp.c:342 at /usr/include/c++/13.2.0/bits/basic_string.h:3177 ... this=0x814fa8 <redfish::EventServiceManager::getInstance(boost::asio::io_context*)::handler>, id=...) at /usr/src/debug/bmcweb/1.0+git/redfish-core/include/event_service_manager.hpp:537 resHandler=..., keepAlive=false, connId=0, res=...) at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:803 ... at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:461 at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:440 bytesTransferred=<optimized out>) at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:398 ``` So, we would need to hold the subscription object until resHandler() is completed by holding up using `shared_from_this()` for sendEventToSubscriber().. ``` bool Subscription::sendEventToSubscriber(std::string&& msg) { client->sendDataWithCallback( ... std::bind_front(&Subscription::resHandler, this, shared_from_this())); <=== ``` Tested: - Compiles - Event Listener works - Attempt to delete subscriptions Change-Id: I5172c96e9d1bd2f03831916a95167e0ea532e9f2 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-04-25Use SPDX identifiers everywhereGunnar Mills2-30/+6
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/74513 moved most places over to SPDX but forgot a few, fix the ones found with grep. 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: Ie4c2ea53f7bc8d902bf87fef6df2a67c6b1de613 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2025-04-10Return forbidden return code for RestrictedRole operationsMyung Bae1-1/+1
This fixes the http error code of the operations of the restricted role which currently result in bad_request (400) instead of forbidden (403). Tested: ``` $ redfishtool -r ${bmc}:18080 -u ${user} -p ${pass} -S Always raw POST /redfish/v1/AccountService/Accounts -d '{"UserName":"service","Password":"newPwd1","RoleId":"Operator"}' redfishtool: Transport: Response Error: status_code: 403 -- Forbidden--user not authorized to perform action redfishtool: raw: Error sending POST to resource, aborting $ redfishtool -r ${bmc}:18080 -u ${user} -p ${pass} -S Always raw PATCH /redfish/v1/AccountService/Accounts/${user} -d '{"Password":"NewTestPwd123"}' redfishtool: Transport: Response Error: status_code: 403 -- Forbidden--user not authorized to perform action $ redfishtool -r ${bmc}:18080 -u ${user} -p ${pass} -S Always raw PATCH /redfish/v1/AccountService/Accounts/${user} -d '{"UserName":"new-service"}' redfishtool: Transport: Response Error: status_code: 403 -- Forbidden--user not authorized to perform action $ redfishtool -r ${bmc}:18080 -u ${user} -p ${pass} -S Always raw PATCH /redfish/v1/AccountService/Accounts/${user} -d '{"RoleId":"Operator"}' redfishtool: Transport: Response Error: status_code: 403 -- Forbidden--user not authorized to perform action $ redfishtool -r ${bmc}:18080 -u ${user} -p ${pass} -S Always raw DELETE /redfish/v1/AccountService/Accounts/${user} redfishtool: Transport: Response Error: status_code: 403 -- Forbidden--user not authorized to perform action redfishtool: raw: Error sending DELETE to resource, aborting ``` Change-Id: I1b212ccb5a630750eb5d4197970b4fb75fceffd7 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-04-03OEM Route Handling Infrastructurerohitpai1-0/+5
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-11Remove the last memcpyEd Tanous1-2/+3
This is the last memcpy in bmcweb. Remove it in leui of std::bit_cast Tested: Need help. Change-Id: Ibd6fbc1a8fa9e80cd7e7edf356f8a45448c16189 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-02-07Deduplicate event idsEd Tanous2-89/+22
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-04clang-format: update latest spec and reformatPatrick Williams5-34/+34
Copy the latest format file from the docs repository and apply. Change-Id: I2f0b9d0fb6e01ed36a2f34c750ba52de3b6d15d1 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2025-01-26Fix inotifyEd Tanous1-13/+24
We don't need the global variable here. Cleanup is handled by the stream_descriptor. Also check error codes per the documentation, not just on == -1 Tested: Created log file manually with redfish-event-listener enabled Saw log was sent to consumer. Change-Id: I27f13c7aedfdfe642128b7129f622047dd933380 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-01-26$filter Query parameter support for nested keys addedChandramohan Harkude1-7/+11
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-24Move time_utils to compile unitEd Tanous1-1/+465
There's no reason for these functions to be in a header, and pulling them into a compile unit can reduce compile times overall. Tested: Unit tests pass (Good coverage) Change-Id: Ia6dc50d16bf2967e647a3c7437ba13bd7ab7ca3c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-01-22Roll out error message utilsEd Tanous2-109/+125
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 Tanous7-15/+15
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-20Improve subscriptions loggingIgor Kanyuka2-1/+8
If the event is not sent to the destination it was supposed to be sent to, it's hard to find out why it was not sent, and what was the message content the code was working with. Having additional logging (mostly debug) helps with troubleshooting. Tested: Built an image with these changes, ran in QEMU, enabled debug logging, setup subscription: ``` { "@odata.id": "/redfish/v1/EventService/Subscriptions/3489160873", "@odata.type": "#EventDestination.v1_14_1.EventDestination", "Context": "127.0.0.1", "DeliveryRetryPolicy": "RetryForever", "Destination": "http://127.0.0.1:8888/events", "EventFormatType": "Event", "HeartbeatIntervalMinutes": 10, "HttpHeaders": [], "Id": "3489160873", "MessageIds": [], "MetricReportDefinitions": [], "Name": "Event Destination 3489160873", "Protocol": "Redfish", "RegistryPrefixes": [], "ResourceTypes": [], "SendHeartbeat": false, "SubscriptionType": "RedfishEvent", "VerifyCertificate": true } ``` and sent a message: ``` root@bmc:~# busctl call xyz.openbmc_project.Logging \ /xyz/openbmc_project/logging \ xyz.openbmc_project.Logging.Create \ Create 'ssa{ss}' \ OpenBMC.0.1.PowerButtonPressed \ xyz.openbmc_project.Logging.Entry.Level.Error 0 o "/xyz/openbmc_project/logging/entry/16" ``` Got this in the log: ``` Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:65] Handling new DBus Event Log Entry Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface org.freedesktop.DBus.Peer Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface org.freedesktop.DBus.Introspectable Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface org.freedesktop.DBus.Properties Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface xyz.openbmc_project.Common.FilePath Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface xyz.openbmc_project.Software.Version Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface xyz.openbmc_project.Association.Definitions Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface xyz.openbmc_project.Object.Delete Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:74] Found dbus interface xyz.openbmc_project.Logging.Entry Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG dbus_log_watcher.cpp:59] Found Event Log Entry Id=16, Timestamp=, Message= Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG subscription.cpp:283] Processing logEntry: 16, '' Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG event_log.cpp:134] formatEventLogEntry: could not find messageID '' for log entry 16 in registry Jan 13 04:13:13 bmc bmcwebd[823]: [WARNING subscription.cpp:292] Read eventLog entry failed Jan 13 04:13:13 bmc bmcwebd[823]: [DEBUG subscription.cpp:317] No log entries available to be transferred. ``` Change-Id: I5cc8d48a0258f2419a7bd4f726f185abbd628110 Signed-off-by: Igor Kanyuka <ifelmail@gmail.com>
2025-01-13dbus event subscriptions: test dbus_log_watcherAlexander Hansen1-3/+3
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>
2025-01-13dbus event subscription: add MessageIdAlexander Hansen1-0/+9
Use dbus property 'Message' for the redfish Message Id. The dbus property is not documented to be used for this purpose in the interface definition [1] but the design [3] uses it. If there is no valid MessageId, the event filtering code will drop the event anyways. Tested: The code was already tested in this form in [2] but found to perhaps not be compliant to the redfish specification References: [1] https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Logging/Entry.interface.yaml[2] 6c58a03e1f6818c3cd0a521466f69ef9e869bf25 [3] https://github.com/openbmc/docs/blob/d886ce89fe66c128b3ab492e530ad48fa0c1b4eb/designs/event-logging.md?plain=1#L448 Change-Id: I4dfe0194e02dc657403d3c0c7162528ec7a597c2 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2025-01-13dbus event subscription: add timestampAlexander Hansen1-0/+3
Get the timestamp from dbus xyz.openbmc_project.Logging.Entry 'Timestamp' property. This is then transformed into 'EventTimestamp' property. Tested: Manually tested [1] This is already done in this way for the polling api, in log_services.hpp 1455 objectToFillOut["Created"] = 1456 redfish::time_utils::getDateTimeUintMs(entry.Timestamp); using the same function. So there is nothing new here. [1] https://discord.com/channels/775381525260664832/1285909954095616050/1327330501937205382 Change-Id: I49670b13d609ac54a5c9d21da9ff1697c7524b5d Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2025-01-13ci: fix ci ubasan failureAlexander Hansen1-4/+2
remove an unused std::shared_ptr<Subscription>& from void Subscription::resHandler(...) Since it was just a reference, it was non-owning anyways and removing it should not have any impact to the lifetime of the managed object. Tested: Inspection only. Change-Id: Iab57e456d5a7ae32305e1a38ddcc37c0f0156ed4 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2025-01-04Add content type to HTTP eventsEd Tanous1-1/+6
Some receiving servers require that content-type be sent. The Redfish specification does not clarify whether or not content-type should be specified, but the HTTP RFC makees it clear, as does security guidelines. Tested: Set up Redfish-Event-Listener and modify to print headers. Observe that application/json header is now set when events are submitted to the server. Change-Id: Idc96848e04f185743b14bd345d46418d38f5f5b1 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-27Update Submit Test event feature to send custom dataChandramohan Harkude1-10/+45
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-21Generate heartbeat registryEd Tanous1-0/+62
Generate the heartbeat registry, and adjust the #includes of the other generated registries. Tested: Redfish service validator succeeds. Change-Id: Iedbf1ae8dc6559666691f1feb71af08e856d5c80 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-21Generate resource eventEd Tanous1-0/+426
Generate Resource event registry Tested: On last patch of series. No behavior changes. Change-Id: I924919db0e7fbde8ed698de6b59b86f788de9708 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-21Generate task eventEd Tanous1-0/+168
Generate the task event registry. Tested: on last patch of series Change-Id: I55b7914978f7a1d637cad6dfae398949af0a7107 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-20Reformat for clang-19Ed Tanous1-2/+1
Change-Id: I6d677b16219482db16c64d5d8412ca557142a597 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-12Fix clang-tidy for gcc-14Ed Tanous1-0/+2
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-07Implement Subscription Heartbeat LogicMyung Bae1-2/+85
This implements the subscription heartbeat logic which will send the message `RedfishServiceFunctional` periodically with the interval of `HeartbeatIntervalMinutes` specified in subscription property [1][2], if `SendHeartbeat` is enabled.. Note the heartbeat enablement is per event destination as DMTF specifies [3] like ``` ... This message shall only be sent if specifically requested by an event destination during the creation of a subscription... ``` This also add `HeartbeatEvent` to supported registry prefixes like ``` curl -k -X GET https://${bmc}/redfish/v1/EventService/ { ... "RegistryPrefixes": [ "Base", "OpenBMC", "TaskEvent", "HeartbeatEvent" ], "ResourceTypes": [ "Task", "Heartbeat" ], ``` Tested: 1) A single subscription and heartbeat via Redfish Event Listener - Create a subscription via Redfish Event Listener - PATCH `SendHeartbeat=true` and `HeartbeatIntervalMinutes` like ``` curl -k -X PATCH https://${bmc}/redfish/v1/EventService/Subscriptions/${SUBID} \ -H "Content-Type: application/json" \ -d '{"SendHeartbeat":true, "HeartbeatIntervalMinutes":1}' ``` - Monitor the Redfish Event Listener and check the following heartbeat messages periodically (per HeartbeatIntervalMinutes) ``` response_type: POST headers: {'Host': '9.3.62.209', 'Content-Length': '230'} response={ "@odata.type": "#Event.v1_4_0.Event", "Events": [ { "@odata.type": "#Message.v1_1_1.Message", "EventId": "HeartbeatId", "EventTimestamp": "2024-11-21T12:21:47+00:00", "MemberId": "0", "Message": "Redfish service is functional.", "MessageArgs": [], "MessageId": "HeartbeatEvent.1.0.1.RedfishServiceFunctional", "MessageSeverity": "OK", "OriginOfCondition": "/redfish/v1/EventService/Subscriptions/1521743607", "Resolution": "None." } ], "Id": "HeartbeatId", "Name": "Event Log" } ``` - Change `SendHeartbeat` to false and see whether the heartbeat message is stopped. 2) Multiple sbscribers with the different heartbeat setups - create 2 event listeners with 2 different destinations (e.g., port 8080 and 8081). - Patch sendheartbeat=true to only one subscriber. - Check whether the only subscriber that enables `SendHeartbeat` is receiving the heartbeat messages. 3) Redfish Service Validator passes [1] https://github.com/openbmc/bmcweb/blob/02ea923f13de196726ac2f022766a6f80bee1c0a/redfish-core/schema/dmtf/json-schema/EventDestination.v1_15_0.json#L356 [2] https://redfish.dmtf.org/registries/HeartbeatEvent.1.0.1.json [3] https://github.com/DMTF/Redfish/blob/d9e54fc8393d8930bd42e8b134741f5051a2680f/registries/HeartbeatEvent.1.0.1.json#L14 Change-Id: I8682e05f4459940913ba189f1ed016874e38dd4a Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2024-11-27event service: dbus log: enable event subscriptionAlexander Hansen1-0/+77
enable the event subscriptions /redfish/v1/EventService/Subscriptions/ to work for the dbus event log. So if you are enabling redfish-dbus-log option, event subscriptions should work similar to when this option is disabled, with one difference: - 'MessageArgs' property is currently not implemented and cannot be found in the returned json. Tested: - Using Redfish Event Listener, test subscriptions and eventing. - Manual Test below with the Redfish Event Listener: 1. Created a maximal Event Log Subscription redfish { "@odata.id": "/redfish/v1/EventService/Subscriptions/2023893979", "@odata.type": "#EventDestination.v1_8_0.EventDestination", "Context": "EventLogSubscription", "DeliveryRetryPolicy": "TerminateAfterRetries", "Destination": "http://${ip}:5000/event-receiver", "EventFormatType": "Event", "HttpHeaders": [], "Id": "2023893979", "MessageIds": [], "MetricReportDefinitions": [], "Name": "Event Destination 2023893979", "Protocol": "Redfish", "RegistryPrefixes": [], "ResourceTypes": [], "SubscriptionType": "RedfishEvent", "VerifyCertificate": true } which matches on all registries and all message ids. 2. created a new phosphor-logging entry busctl call xyz.openbmc_project.Logging \ /xyz/openbmc_project/logging \ xyz.openbmc_project.Logging.Create \ Create 'ssa{ss}' \ OpenBMC.0.1.PowerButtonPressed \ xyz.openbmc_project.Logging.Entry.Level.Error 0 3. bmcweb picks up this new entry via the dbus match, this can be verified by putting bmcweb in debug logging mode. 4. the event log entry makes it through the filtering code 5. the POST request is sent to the subscribed server as expected, and contains the same properties as with the file-based backend. Change-Id: I122e1121389f72e67a998706aeadd052ae607d60 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2024-11-27Break out Filesystem events into classesEd Tanous1-38/+102
EventServiceManager is already too large. Implement the TODO from run that these should be classes, and fix the issue where events are being registered on startup, not on a subscription being created. To accomplish this, this patch takes global state and breaks them out into RAII classes from EventServiceManager, one for monitoring DBus matches, and one for monitoring filesystem log events using inotify. Each of these connect to static methods on EventService that can send the relevant events to the user. Fundamentally, no code within the two new classes is changed, and the only changes to event service are made to support creation and destruction of the RAII classes. Tested: WIP No TelemetryService tests exist in Redfish. Change-Id: I74210a10002eb39fddc9e42b0690a7c3d42fbd4c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-27Break out long lambda in filesystem eventsEd Tanous1-83/+80
This lambda is very large. Break it out into a smaller method. Tested: Last patch in series. Change-Id: Id80de2296fb6301fa26eba0c38bab3570bf82a35 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-27Break out Dbus events into classEd Tanous1-1/+13
EventServiceManager is already too large. Implement the TODO from run that these should be classes, and fix the issue where events are being registered on startup, not on a subscription being created. To accomplish this, this patch takes global state and breaks them out into RAII classes from EventServiceManager, one for monitoring DBus matches, and one for monitoring filesystem log events using inotify. Each of these connect to static methods on EventService that can send the relevant events to the user. Fundamentally, no code within the two new classes is changed, and the only changes to event service are made to support creation and destruction of the RAII classes. There are a number of call sites, like cacheRedfishLogFile, that are obsoleted when the class is raii. The file will be re-cached on creation. Tested: WIP No TelemetryService tests exist in Redfish. Change-Id: Ibc91cd1496edf4a080e2d60bfc1a32e00a6c74b8 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-26Break out dbus telemetry watcherEd Tanous1-0/+57
EventServiceManager is too large. Make it smaller by breaking out the dbus log watching mechanisims into a class. No changes are made, with the exception of the addition of sendTelemetryReportToSubs to allow sending events from outside the class, without needing the subscription list, which should be private. Tested: On last patch in series. Change-Id: Idf17886971ddff5dddeabeeb6ae44e733063b909 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Break out filesystem watcher into separate fileEd Tanous1-0/+181
EventServiceManager is very large. Break out two of the functions, and the global variables into a separate compile unit. Code is copied as-is, with no improvements made in this patch. Tested: At end of series. Change-Id: I89a3605885e5bafa86a6083f1ff8c5db3bb8daf9 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Make all ints size_tEd Tanous1-4/+5
We should be consistent when we declare index types. Nlohmann uses an underlying uint64_t as the integer type, so use that for all index types. Size_t is directly creatable from it in both 32 and 64 bit modes. Tested: On last patch in series. Change-Id: Id1da0e7be2e2046bdbd732247d208b6e9e8c008c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Order by order in DMTF registryEd Tanous1-777/+777
The DMTF registry has a defined order. Previously these were randomly ordered dependent on the hash function used when they were generated years ago. Functionally the only change here is to parse_registries.py, to remove the sorting, then to regenerate the files. Tested: On last patch in series. Change-Id: I7432c26ec4a1b18acf63ece85500df370f4758d3 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Generate error messages sourceEd Tanous1-55/+587
This file has gotten desynced from the standard, and maintaining it is a pain. refactor the parse_registries.py script to generate this file and update all wrong instances to the correct types. To the extent possible, the generated code tries to be replaced with 1:1 identical structures to make review simpler. Tested: On last patch in series. Change-Id: Ic203a93fd26e0487475ce82c62beb6a22612368a Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Remove InvalidUpload response codeEd Tanous1-36/+0
Invalid response is something from the openbmc registry, so it's not a valid thing to return as a response code. For this patch, remove the generated error message, and replace the one place it's used with internalError. Tested: On last patch in series. Change-Id: I8215935f00923c72fd7763645c06d0b6af73c01d Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Don't pretty print inline argumentsEd Tanous1-12/+12
For consistency, keep all json value printing in error messages non pretty printed. This allows us to generate this file easier. Tested: On last patch in series. Change-Id: I1a205e9594e2c917d2b758d537a3f58018cd83d9 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Rename parameters to keep conventionEd Tanous1-6/+5
These two properties were added with argument names that while more descriptive than most, prevent us from generating this file automatically. Rename to arg1 and arg2. Tested: at end of series. Change-Id: I2ddb675bd5e0770583d0a4de105c8eb3b54993d7 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-20Enable gcc-14 buildsEd Tanous1-0/+2
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-11-20Refactor: move registries functions to their fileAlexander Hansen2-21/+10
There were same functions from namespace 'registries' in event_service_manager.hpp. Move them to registries.cpp/hpp. Tested: - Using Redfish Event Listener, test subscriptions and eventing. - Redfish Service Validator passes Change-Id: Id0912f6581637bb4117e67b138122c355256b561 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com> Signed-off-by: Ed Tanous <ed@tanous.net>