summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-02-24Systems: Add support to read AllowedPowerModesChris Cain1-48/+85
Instead of hardcodeing the AllowedPowerModes property, the data will be read from dbus if it exists. If data is empty/not found, the property will be set to the default value: [ "MaximumPerformance", "PowerSaving", "Static" ] Tested on Rainier hardware and Validator passed When dbus property is empty, it will show default modes: ''' xyz.openbmc_project.Control.Power.Mode interface - - - .AllowedPowerModes property as 0 const .PowerMode property s "xyz.openbmc_project.Control.Power.Mode.PowerMode.MaximumPerformance" emits-change writable "PowerMode": "MaximumPerformance", "PowerMode@Redfish.AllowableValues": [ "MaximumPerformance", "PowerSaving", "Static" ], "PowerRestorePolicy": "AlwaysOff", ''' When dbus property populated with 6 modes: ''' - xyz.openbmc_project.Control.Power.Mode interface - - - .AllowedPowerModes property as 6 "xyz.openbmc_project.Control.Power.Mode.PowerMode.BalancedPerformance" "xyz.openbmc_project.Control.Power.Mode.PowerMode.EfficiencyFavorPerformance" "xyz.openbmc_project.Control.Power.Mode.PowerMode.EfficiencyFavorPower" "xyz.openbmc_project.Control.Power.Mode.PowerMode.MaximumPerformance" "xyz.openbmc_project.Control.Power.Mode.PowerMode.PowerSaving" "xyz.openbmc_project.Control.Power.Mode.PowerMode.Static" const .PowerMode property s "xyz.openbmc_project.Control.Power.Mode.PowerMode.MaximumPerformance" emits-change writable "PowerMode": "MaximumPerformance", "PowerMode@Redfish.AllowableValues": [ "BalancedPerformance", "EfficiencyFavorPerformance", "EfficiencyFavorPower", "MaximumPerformance", "PowerSaving", "Static" ], "PowerRestorePolicy": "AlwaysOff", ''' When dbus property not defined it will show default modes: ''' xyz.openbmc_project.Control.Power.Mode interface - - - .PowerMode property s "xyz.openbmc_project.Control.Power.Mode.PowerMode.MaximumPerformance" emits-change writable "PowerMode": "MaximumPerformance", "PowerMode@Redfish.AllowableValues": [ "MaximumPerformance", "PowerSaving", "Static" ], "PowerRestorePolicy": "AlwaysOff", ''' Signed-off-by: Chris Cain <cjcain@us.ibm.com> Change-Id: Ic9882d2760a39dd1a0ea353624eb3c8575f4c6a0
2024-02-23manager_diagnostic_data: add metric getJagpal Singh Gill4-0/+247
Add support to fetch MemoryStatistics, FreeStorageSpaceKiB and ProcessorStatistics for Manager Diagnostic Data. https://redfish.dmtf.org/schemas/v1/ManagerDiagnosticData.v1_2_1.json This change is in relation to following design and D-Bus interface - https://gerrit.openbmc.org/c/openbmc/docs/+/64917 https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/64914 Test: Redfish query output - { "@odata.id": "/redfish/v1/Managers/bmc/ManagerDiagnosticData", "@odata.type": "#ManagerDiagnosticData.v1_2_0.ManagerDiagnosticData", "FreeStorageSpaceKiB": 3772, "Id": "ManagerDiagnosticData", "MemoryStatistics": { "AvailableBytes": 354224066, "BuffersAndCacheBytes": 78984633, "SharedBytes": 11876066, "TotalBytes": 425516000 }, "Name": "Manager Diagnostic Data", "ProcessorStatistics": { "KernelPercent": 13.0234, "UserPercent": 5.7374 }, "ServiceRootUptimeSeconds": 2255.117 } Redfish service validator passing - Elapsed time: 0:03:12 metadataNamespaces: 3726 pass: 5133 passAction: 9 passGet: 205 passRedfishUri: 197 skipNoSchema: 3 skipOptional: 3492 warnDeprecated: 4 warningPresent: 7 Validation has succeeded. Change-Id: I43758a993eb7f342cb9ac5f5574498b37261c2cc Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
2024-02-23Refactor to pass dbus error code to callerMyung Bae1-59/+102
The aux function `getValidFabricAdapterPath()` currently handles the error uniformly for all callers. This commit is to make the function to pass the error conddition to the caller so that it can be handled appropriately in the caller's context. Tested: - Check `resourceNotFound` is generated by caller. ``` $ curl -k -X GET https://${bmc}:18080/redfish/v1/Systems/system/FabricAdapters/badAdapter [WARNING fabric_adapters.hpp:270] Adapter not found ``` - Validator passes Change-Id: I37a61a3a79138aa898ab18332f58e3007496e302 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2024-02-21Chassis: Add support for Version propertyCarson Labrado1-0/+19
Add support for the Version property of Chassis resources. That property was added in Chassis schema v1.21.0. This makes use of the "xyz.openbmc_project.Inventory.Decorator.Revision" interface that is already defined by phosphor-dbus-interfaces. Tested: Validator passed and Version property was correctly populated. No issues on other Chassis resources which do not have a Version property. I added this to an entity-manager json config: "xyz.openbmc_project.Inventory.Decorator.Revision": { "Version": "$PRODUCT_VERSION" } The PRODUCT_VERSION field from a given FRU eeprom was picked up by FruDevice and it was exposed under the associated Chassis resource: busctl get-property xyz.openbmc_project.FruDevice \ /xyz/openbmc_project/FruDevice/Test \ xyz.openbmc_project.FruDevice PRODUCT_VERSION s "V1.0" curl -s 'localhost/redfish/v1/Chassis/TestChassis' { "@odata.id": "/redfish/v1/Chassis/TestChassis", ... "Version": "V1.0" } Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: Ie1391d46e81fd8c503fe4b1e6d683dd4553a5419
2024-02-21multi-host: give some more timePatrick Williams1-1/+1
Extend the deletion deadline until 9/1/2024 as Meta intends to have someone work on this feature shortly. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I3683aa3f04905c20fa7bb406dde54e549fdd2d8c
2024-02-21OWNERS: Update Gunnar's email addressGunnar Mills1-1/+1
I have multiple email addresses in my Gerrit account but as https://gerrit.openbmc.org/c/openbmc/bmcweb/+/69506 shows my Preferred email has to match the OWNERS file, do that. More discussion in Discord at [1] https://discord.com/channels/775381525260664832/817151035197358081/1209585278025601094 Change-Id: I94ba5bd8d9c2a3c23314aae051b3a083562e43cb Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-02-16Write unit tests for http2 connectionEd Tanous3-0/+224
This unit test currently only tests a simple connect and settings frame transfer, but should form the basis for more complex testing in the future. Tested: Unit tests pass Change-Id: Ieb803dbe490129ec5fe99fb3d4505a06202e282e Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-16Simplify HTTP/2 bufferingEd Tanous2-72/+46
Using the mem_send methods of nghttp2 can reduce the amount of buffering we need to do. This is recommended by the nghttp2 docs. Tested: Enabled experimental-http. Curl succeeds on /redfish/v1, and shows: * using HTTP/2 * [HTTP/2] [1] OPENED stream for https://localhost:18080/redfish/v1 Change-Id: I287d8c956f064d244116fac853055a17fca915a2 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-16Add unit tests for file bodyEd Tanous4-24/+168
File body needs some unit tests for managing the move constructors. Tested: Unit tests pass. Change-Id: Ia640aec75a6f3f85640a50f5dd492638871f9eca Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-16Simplify bodyEd Tanous10-379/+350
Now that we have a custom boost http body class, we can use it in more cases. There's some significant overhead and code when switching to a file body, namely removing all the headers. Making the body class support strings would allow us to completely avoid that inefficiency. At the same time, it would mean that we can now use that class for all cases, including HttpClient, and http::Request. This leads to some code reduction overall, and means we're reliant on fewer beast structures. As an added benefit, we no longer have to take a dependency on boost::variant2. Tested: Redfish service validator passes, with the exception of badNamespaceInclude, which is showing warnings prior to this commit. Change-Id: I061883a73230d6085d951c15891465c2c8445969 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-16Configure DHCP4 and DHCP6 parameters independentlyJishnu CM1-75/+117
At present, DHCP parameters like DNSEnabled, NTPEnabled and HostNameEnabled are at the system level at the network backend. It is common across both IPv4 and IPv6 network types. Thus when a redfish command is sent to enable the DNSEnabled property for IPv4 on eth0 interface, it internally sets the DNSEnabled to true for both IPv4 and IPv6 on eth0 and eth1. Here the change in parameter value for a non-requested network type in the non-requested interface might be an unexpected behaviour for the user. Also, with the current implementation in bmcweb and networkd, the user has no option to configure DHCP parameters differently for different interfaces and network types though it is supported by the redfish. With this change, the Redfish query for updating DHCP parameters will only modify the requested parameter for the specified network type and interface. User must make separate requests to modify the DHCP parameters as per the DMTF schema Current behavior: Request: curl -k -H "X-Auth-Token: $bmc_token" -X PATCH -d '{"DHCPv4":{"UseDNSServers":false}}' https://${bmc}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 Result: UseDNSServers value is set to false for DHCPv4 and DHCPv6 for all interfaces. After this commit: Request: curl -k -H "X-Auth-Token: $bmc_token" -X PATCH -d '{"DHCPv4":{"UseDNSServers":false}}' https://${bmc}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 Result: UseDNSServers value is set to false only for DHCPv4 only in eth0 as mentioned in the redfish request. The DHCP configuration was in the network manager level earlier, it has been moved to interface level with https://gerrit.openbmc.org/c/openbmc/phosphor-networkd/+/63124. This bmcweb change is to separate out the values for IPv4 and IPv6 and to move the dbus object to the interface level. Tested by: Patching the DHCP parameters with redfish request: curl -k -H "X-Auth-Token: $bmc_token" -X PATCH -d '{"<network_type>":{"<DHCP_param>":<value>}}' https://${bmc}/redfish/v1/Managers/bmc/EthernetInterfaces/<interface_id> Verify the value is updated in the network configuration. Retrieve the DHCP parametrer value with the Get Request: curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Managers/bmc/EthernetInterfaces/<interface_id> Change-Id: I5db29b6dfc8966ff5af51041da11e5b79da7d1dd Signed-off-by: Jishnu CM <jishnunambiarcm@duck.com>
2024-02-08Systems: Add support for new eco power modesChris Cain1-11/+49
Add support for the following new power modes: - Efficiency Favor Performance - Efficiency Favor Power - Balanced Performance New modes were added in ComputerSystem schema to v1.22 Tested on Rainier and passed Validator ''' GET /redfish/v1/Systems/system: "@odata.type": "#ComputerSystem.v1_22_0.ComputerSystem", ... "PowerMode": "EfficiencyFavorPerformance", "PowerMode@Redfish.AllowableValues": [ "Static", "MaximumPerformance", "PowerSaving" ], PATCH -d '{ "PowerMode":"BalancedPerformance"}' https://$bmc/redfish/v1/Systems/system "PowerMode": "BalancedPerformance", PATCH -d '{ "PowerMode":"EfficiencyFavorPerformance"}' https://$bmc/redfish/v1/Systems/system "PowerMode": "EfficiencyFavorPerformance", PATCH -d '{ "PowerMode":"EfficiencyFavorPower"}' https://$bmc/redfish/v1/Systems/system "PowerMode": "EfficiencyFavorPower", PATCH -d '{ "PowerMode":"MaximumPerformance"}' https://$bmc/redfish/v1/Systems/system "PowerMode": "MaximumPerformance", PATCH -d '{ "PowerMode":"NotARealMode"}' https://$bmc/redfish/v1/Systems/system { "PowerMode@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value '\"NotARealMode\"' for the property PowerMode is not in the list of acceptable values.", "MessageArgs": [ "\"NotARealMode\"", "PowerMode" ], "MessageId": "Base.1.13.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." } ] ''' Validator Results: ''' Type (ComputerSystem.v1_22_0.ComputerSystem), GET SUCCESS (time: 0:00:00.107269) ... PASS ... Elapsed time: 0:15:07 invalidPropertyValue: 62 metadataNamespaces: 4324 pass: 14323 passAction: 20 passGet: 1051 passRedfishUri: 1002 skipNoSchema: 3 skipOptional: 25582 unverifiedAdditional.complex: 21 warnDeprecated: 8 warningPresent: 83 warnings: 67 Validation has succeeded. ''' Change-Id: I56296a524b01d64adccad2d3da1757056900b6db Signed-off-by: Chris Cain <cjcain@us.ibm.com>
2024-02-08Enable redfish-new-powersubsystem-thermalsubsystemGunnar Mills1-4/+4
This is just the default, but enable redfish-new-powersubsystem-thermalsubsystem. As discussed on discord 4 companies enabled it upstream and I see a few more downstream forks enabling it as well. This does enable all sensors in the sensor collection, this is following Redfish as described in the new thermalSubsystem and powerSubsystem doc the sensor collection should contain all sensors that are associated with that chassis. [1] [1] https://redfishforum.com/thread/190/sensorcollection-contain-all-sensors-chassis Redfish release 2020.4 was the new powersubsystem, thermalsubsystem schemas. Redfish has continued to add to them, deprecate the old, and stated this is the new schemas are the future direction. Leave the old redfish-allow-deprecated-power-thermal alone (enabled), this allows for an easier client transition. Also, it would be best if the few outstanding new powersubsystem, thermalsubsystem children resources could get in first. Added a warning about disabling redfish-allow-deprecated-power-thermal in June 2024. Tested: See these APIs, a validator run with both of these enabled (average (2 runs) 6:06) and a validator run with just redfish-new-powersubsystem-thermalsubsystm (average 2 runs 5:52). 3.8% increase. I think this increase is worth it for the client compatibility. Change-Id: Ideb0f1999289b11b80ee0b8288e7ce53de0a7433 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-02-07Add StandbyOffline to Redfish sensor getStateMatt Simmering1-5/+28
Currently in Redfish a sensor's state will only be "Absent" or "Enabled". In the case where a sensor is marked as not available on D-Bus it would be more accurate and informative to have the state as "StandbyOffline". A sensor's availability will be published on its xyz.openbmc_project.State.Decorator.Availability interface. Tested on Intel system. Put sensors into an unavailable state by putting CPU into S5 power state, and verified that Redfish state is "StandbyOffline". Then when sensors are back in an available state their Redfish state is back to "Enabled". Change-Id: I4b846b678a0f90f60d182ac38f1becd21265cdd2 Signed-off-by: Matt Simmering <matthew.simmering@intel.com>
2024-02-06Make tests not require body interactionEd Tanous2-197/+231
The muitipart test interacts with some significant details of the response class. This was largely only done because Request lacked an addHeader method that Request already had. Add addHeader() method to the Request class, and adapt multipart unit tests to use it. Tested: Unit tests pass. Unit test only changes. Change-Id: Icb3b92dce6d17011ae0063a962678173b1b01a87 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-06Update gtest to 1.14.0Ed Tanous1-8/+14
This file is directly downloaded from wrapdb. Tested: Code compiles, unit tests pass. Change-Id: I2fb3dc7f89b9d39d31cc494533519196cfc401d1 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-01Bump Redfish schemas to 2023.3Gunnar Mills139-1853/+6474
Redfish released 2023.3 1/25/2024. https://www.dmtf.org/content/redfish-release-20233-now-available It is several new schemas and added properties to a pile of schemas. One use case is: ComputerSystem v1.22.0 Added EfficiencyFavorPower and EfficiencyFavorPerformance to PowerMode https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/69122 This is a one line change to scripts/update_schemas.py and then ran the script. Tested: See the new schema versions (e.g. System 1.22.0). No new Validator errors on p10bmc. Change-Id: I5c10d78e891da71fd14187f63aa6ac682cf15598 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-01-29Reformat scriptsEd Tanous1-3/+3
Change-Id: Ie8fb9f9733e75b887b14516cfa12f662aa5d3a82 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-01-23Implements ThermalMetrics schemazhanghch054-0/+103
The ThermalMetrics schema is a resource in Redfish version 2022.2[1]. It contains an array of temperature readings. It is a child of ThermalSubsystem schema[2] and it represents the thermal metrics of a chassis. Reading the current value of each temperature sensor and the corresponding link enumeration will be implemented in the next patch. This commit implements the Get and Head methods of the Redfish ThermalMetrics schema and implemented the basic information of Get. [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0268_2022.2.pdf [2] https://redfish.dmtf.org/schemas/v1/ThermalMetrics.v1_0_1.json Test: 1. 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", } """ 3. 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.13.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.0.ResourceNotFound", "message": "The requested resource of type Chassis named 'chassisBAD' was not found." } } """ Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: Ib4182e7dc6e204371636a33a391e8e2a58dad113
2024-01-22Make use of filebody for dump offloadAbhilash Raju4-53/+354
Logservice has been rewritten to use file_body to offload dump files from BMC. There are two kind of dump files, BMC dump and System dump.While BMC dump just requires default support from beast::file_body, System dump requires base64 encoding support from beast. But beast::file_body do not have ready-made support for base64 encoding. So a custom file_body has been written for the base64 encoding. The openFile apis in crow::Response do not have support for unix file descriptor. Since dump files are accesses via descriptors, added new openFile api that accepts descriptors. Tested: Functionality test have been executed to verify the bmc dump offload. Did sanity test by invoking bmcweb pages via browser. Change-Id: I24192657c03d8b2f0394d31e7424c6796ba3227a Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>
2024-01-22Make base64 encoder incrementalEd Tanous2-33/+126
As part of https://gerrit.openbmc.org/c/openbmc/bmcweb/+/67667, it would be desirable if we could incrementally encode base64 in chunks. Given that base64 encoding requires encoding 3 characters to 4, there's a possibility that a chunk might not be mod 3 length. This commit moves the base64 encoder into a class that can run incrementally. Tested: Unit tests pass. More tests in next commit. Change-Id: Ic7da3fd4db865c99fcbd96ae06fdecb87628f94c Signed-off-by: Ed Tanous <ed@tanous.net>
2024-01-19Remove some boost includesEd Tanous21-104/+145
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>
2024-01-19Clean up tftp update to use URLEd Tanous3-51/+125
Similar to transforms we've done elsewhere, we shouldn't be parsing urls using std::string::find, regex, or anything else, as they don't handle URL % encoding properly. Change-Id: I48bb30c0c737c4df2ae73f40fc49c63bac5b658f Signed-off-by: Ed Tanous <edtanous@google.com>
2024-01-17Pass correct Argument Types to propertyValueIncorrect Error MessageGinu George3-11/+11
Changed the code to pass the parameters according to their types. Tested: Code Compiles properly and tested. Change-Id: Ie0e13d39cd892afda36dfabec871f0fe8d8498e4 Signed-off-by: Ginu George <ginugeorge@ami.com>
2024-01-16DBus REST: Fix array and dict handlingMikhail Zhvakin1-3/+3
The bmcweb DBus REST API cannot currently handle array or dictionary data types correctly. This commit is meant to fix that. Tested: get/set DBus attributes (consisting of array and/or dictionary) via bmcweb DBus REST API. Change-Id: I9694cb888375c90d7a8fb1a10e53bdb5c0bce3bb Signed-off-by: Mikhail Zhvakin <striker_1993@mail.ru>
2024-01-15redfish: Fix the property name to get EncryptionStatusKonda Reddy Kachana1-2/+2
Update the property name to get the EncryptionStatus correctly Tested: curl localhost/redfish/v1/.../emmc { "@odata.type": "#Drive.v1_7_0.Drive", "EncryptionStatus": "Unlocked", } Change-Id: Ie7b84caba1d2566c372805330353e708ec1b3c3d Signed-off-by: Konda Reddy Kachana <kkachana@google.com>
2024-01-09Fix spelling mistakesEd Tanous34-69/+83
These were found with: codespell -w $(git ls-files | grep "\.[hc]\(pp\)\?$") At some point in the future, we might want to get this enabled in CI. Change-Id: Iccb57b2adfd06a2e177e99db2923fe4e8e329118 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-01-09http_client: fix for broken connectionAbhilash Raju1-11/+37
http_client is not handling connection termination by server due to keep alive timeout. At present client is not aware of connection termination from server. So whenever next redfish is event ready to be sent, the client will try send/receives data over broken connection. After failed operation the client will try to restart the connection by closing the current connection. Problems: 1) Restart is not attempted on all failure paths. Eg: stream_truncated error was ignored, which usually happens when try to read from broken connection, due to which retry is never performed. 2) Ssl shutdown over broken connection often fails to call the shutdown callback 3) ssl session was reused for new connection attempt. Which is wrong Solution: This patch will try to reattempt the connection in all failure cases. It uses new socket object and new ssl session for the retries Tested by: Test normal event flow between redfish-event clients and the BMC Test failure event flow between redfish-event clients and the BMC Tested the bad path by keeping the setup idle for 3 hours on the above two setups. Verified the events flow after this idle time Change-Id: I3d725b9d77bea22e2e8860e01ee0dfc971789008 Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com> Signed-off-by: Ed Tanous <ed@tanous.net>
2023-12-25bmcweb: Add nullptr check for weakptrzhaogang.01081-0/+5
When we call a null weakptr, it will cause a crash. Add nullptr check for weakptr can avoid this situation. Tested: bmcweb.service did not experience core-dump. Change-Id: I4490d68c70ea5d43681f4fb18b3859afb01ed70a Signed-off-by: Zhao Gang <zhaogang.0108@bytedance.com>
2023-12-21Fix typo in collection.hppMyung Bae1-1/+1
Commit https://gerrit.openbmc.org/c/openbmc/bmcweb/+/64087 has a typo in redfish-core/include/utils/collection.hpp ``` L33: jsonCountKeyName /= back + "@data.count"; --> jsonCountKeyName /= back + "@odata.count"; ``` Tested: - Validator passes Change-Id: Ied52944bd43ec5080c4eef141813674bab1cc0b4 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2023-12-18Refactor PCIeDeviceList to use getCollectionMembersLakshmi Yadlapati4-48/+41
This commit refactors the code in the PCIeDeviceList function to use the getCollectionMembers function for retrieving collection members. Additionally, a new function getCollectionToKey() is added to handle the retrieval of collection members with custom key name. Tested: Validator passed ''' Test1: Redfish query of PCI devices on a system that does not have any PCIe devices curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices", "@odata.type": "#PCIeDeviceCollection.PCIeDeviceCollection", "Description": "Collection of PCIe Devices", "Members": [], "Members@odata.count": 0, "Name": "PCIe Device Collection" } Test2: Redfish query of PCIe devices on a system that has PCIe devices curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices", "@odata.type": "#PCIeDeviceCollection.PCIeDeviceCollection", "Description": "Collection of PCIe Devices", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/drive0" }, ....... { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card1" }, { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card2" }, ....... { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card12" } ], "Members@odata.count": 22, "Name": "PCIe Device Collection" } Test3: Redfish query of system with PCIe devices curl -k https://$bmc/redfish/v1/Systems/system { "@odata.id": "/redfish/v1/Systems/system", "@odata.type": "#ComputerSystem.v1_16_0.ComputerSystem", "Actions": { "#ComputerSystem.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Systems/system/ResetActionInfo", "target": "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset" } }, ...... "PCIeDevices": [ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/drive0" }, ....... { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card1" }, .... ], "PCIeDevices@odata.count": 22, "PartNumber": "", .... "SubModel": "S0", "SystemType": "Physical" } ''' Change-Id: Icb38945a2c7bc5219ff3917fbbc8a9986c9c6155 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-12-12Use MonotonicTimeStamp for bmc log idMyung Bae3-17/+131
/redfish/v1/Managers/bmc/LogServices/Journal/Entries gives the system journal entries whose ID is based on the realtime timestmap. However, the system realtime may go backward if the system time is changed either manually or via NTP. If that happens, those entries may not found via redfish GET as `sd_journal_seek_realtime_usec()`[1] may not always work on the entries which are not sorted in time-order. This may cause the inconsistency between the content of `/redfish/v1/Managers/bmc/LogServices/Journal/Entries/` and /redfish/v1/Managers/bmc/LogServices/Journal/Entries/<bmc_journal_id>`. For example, ``` sudo journalctl --vacuum-time=1s <wait for a while to clear up journal> date -s "<backward-time>" date -s "<forward-time>" ``` Run redfish journal entries and get each entry id from the output ``` curl -k -X GET https://${bmc}/redfish/v1/Managers/bmc/LogServices/Journal/Entries > rj.out ``` Take some logEntry Id that its time going backward like ``` grep "@odata.id" rj.out ``` Run redfish query for each id, and some of them can't be successful. ``` % curl -k -X GET https://${bmc}/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800002075 { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type LogEntry named '1701604800002075' was not found.", "MessageArgs": [ "LogEntry", "1701604800002075" ], "MessageId": "Base.1.13.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.0.ResourceNotFound", "message": "The requested resource of type LogEntry named '1701604800002075' was not found." } }% ``` This can also be verified by checking the failure of Redfish Validator run ``` python3 RedfishServiceValidator.py --auth Session -i https://${bmc} -u admin -p 0penBmc0 --payload Tree /redfish/v1/Managers/bmc/LogServices/Journal/Entries ``` For example, ``` ERROR - Members: GET of resource at URI /redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800002075 returned HTTP error. Check URI. ERROR - Members: GET of resource at URI /redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800065949 returned HTTP error. Check URI. ERROR - Members: GET of resource at URI /redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701607680003048 returned HTTP error. Check URI. ``` ``` --Time goes backwrd { "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800002075", "@odata.type": "#LogEntry.v1_9_0.LogEntry", "Created": "2023-12-03T12:00:00+00:00", "EntryType": "Oem", "Id": "1701604800002075", "Message": "systemd-resolved: Clock change detected. Flushing caches.", "Name": "BMC Journal Entry", "OemRecordFormat": "BMC Journal Entry", "Severity": "OK" }, ... { "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701607680003048", "@odata.type": "#LogEntry.v1_9_0.LogEntry", "Created": "2023-12-03T12:48:00+00:00", "EntryType": "Oem", "Id": "1701607680003048", "Message": "systemd-resolved: Clock change detected. Flushing caches.", "Name": "BMC Journal Entry", "OemRecordFormat": "BMC Journal Entry", "Severity": "OK" }, -- Time comes back to the previous moment ``` The solution is proposed to use <bootid> + <monototic timestamp> as the redfish journal entry id instead of realtime timestamp. Unlike realtime timestamp which may go backward, <monotonic timestamp> is monotonically increasing. Tested: - Redfish Validator passes - GET Journal Entry ID will be found even if its time goes backward. [1] https://github.com/openbmc/bmcweb/blob/7164bc62dd26ec92b01985aaae97ecc48276dea5/redfish-core/lib/log_services.hpp#L2690 Change-Id: I83bfb1ed88c9cf036f594757aa4a00d2709dd196 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2023-12-09mutual-tls: Add support for Meta certificatesMarco Kawajiri7-1/+155
Meta Inc's client certificates use an internal Subject CN format which AFAIK is specific to Meta and don't adhere to a known standard: Subject: CN = <type>:<entity>/<hostname> Commit adds the `mutual-tls-common-name-parsing=meta` option to, on Meta builds, parse the Subject CN field and map either the <entity> to a local user. The <type> field determines what kind of client identity the cert represents. Only type="user" is supported for now with <entity> being the unixname of a Meta employee. For example, the Subject CN string below maps to a local BMC user named "kawmarco": Subject CN = "user:kawmarco/dev123.facebook.com" Tested: Unit tests, built and tested on romulus using the script below: https://gist.github.com/kawmarco/87170a8250020023d913ed5f7ed5c01f Flags used in meta-ibm/meta-romulus/conf/layer.conf : ``` -Dbmcweb-logging='enabled' -Dmutual-tls-common-name-parsing='meta' ``` Change-Id: I35ee9b92d163ce56815a5bd9cce5296ba1a44eef Signed-off-by: Marco Kawajiri <kawajiri@meta.com>
2023-12-09Simplify mutual TLS checksEd Tanous2-116/+38
bmcweb should be using the openssl primitives for these checks. There are examples where we've known to have gotten the behavior incorrect, so given that OpenSSL clearly should know these things better than we do, use it. Tested: unit tests pass. Change-Id: I0bcd381a9e3c9a1e8e6dc39534e81fa698570689 Signed-off-by: Ed Tanous <ed@tanous.net>
2023-12-09Add mutual tls unit testEd Tanous3-3/+210
Mutual TLS paths were not tested. Add some unit tests. Because CI doesn't actually compile dependent libraries with ASAN enabled, and these tests call into openssl, we need to add a check for if we're compiling with asan enabled. Tested: unit tests pass. Change-Id: I02dcb69708619cc00fffd840738c608db3ae8bdf Signed-off-by: Ed Tanous <ed@tanous.net>
2023-12-08Reponse: Fix incomplete implementation in writeAbhilash Raju3-2/+97
Write function in http_response.hpp missing implementation for first write after changing from filebody. Usecase: Current resonse type is filebody. Developer tries to change the body type to stringbody by calling write function. Observed: The write fails to update the body type. Expected: Write should succeed and body should change to string body. Tested: Unit test has been added for crow::Response. Manual sanity test done for file offloads using curl. Change-Id: Icbf8585b5b04c3ac5120d7b334c13d89ed3eb4aa Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>
2023-12-07meson: adjust nlohmann-json dependencyPatrick Williams1-7/+2
* Simplify the meson.build boiler-plate for meson. * Rename the wrap file for consistency with other repositories. * Adjust the meson required version to match the wrap file. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I2da418c10fbe0450944567d276b17f3196da0b55
2023-12-05Fix missing dateEd Tanous2-7/+21
At some point, the date got removed from http1 requests. HTTP2 does not show this issue, but this showed up in unit tests (which is why the prior commit is adding unit tests). The Date Header is useful for synchronizing things like Cache-Control-Policy, with the actual server time, instead of the local system time. Tested: Unit tests pass. Change-Id: I8f105f0cbb6c816c5ec6b14cbeae587d728a20d2 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-12-05Unit test ConnectionEd Tanous6-107/+180
Boost asio provides a test stream object that we can use to begin unit testing the connection object. This patchset uses it to re-enable some simple http1.1 tests. There's some features that have snuck into the connection class that aren't compatible with a stream (like ip address getting), so unfortunately we do need the connection class to be aware if it's in test mode, but that tradeoff seems worthwhile. Tested: Unit test pass. Change-Id: Id8b1f8866582b58502dbafe6139f841bf64b8ef3 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-11-29chassis: Tidy up lambda funcs in get chassisChau Ly1-294/+289
This commit tries to avoid the cumbersomeness of lambda functions used directly or indirectly by handleChassisGet method. Lengthy lambda functions are replaced by or involve normal functions. There's no functional change in this commit. Change-Id: I67e028cdab3ea4407dafde0a510b37a160497f48 Signed-off-by: Chau Ly <chaul@amperecomputing.com>
2023-11-29build: use allowed over enabledPatrick Williams2-13/+13
Meson feature options are typically in a tri-state of enabled, disabled, or auto. The enabled and disabled functions on an option (from `get_option`) no longer return true for auto features. Instead, the expectation is to use `allowed()` which is true for both enabled and auto. Switch all uses of `enabled` to `allowed`. Change-Id: Ia40b13fdce7af88085cf23a4a87d9be939edd1e3 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
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-11-15ethernet: change MTU type to size_tAnthony1-2/+2
Modify the type to get this working on 64-bit system. In phosphor-dbus-interfaces, the type is `size`: https://github.com/openbmc/phosphor-dbus-interfaces/blob/8a2674b/yaml/xyz/openbmc_project/Network/EthernetInterface.interface.yaml#L26 phoshor-networkd has this correct and no other places use. https://github.com/openbmc/phosphor-networkd/blob/6f256bc591bec72dd1448522d941874b21145a81/src/ethernet_interface.hpp#L146 Tested: ``` Before: curl localhost/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 -s | grep MTU "MTUSize": 0, After: curl localhost/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 -s | grep MTU "MTUSize": 1500, ``` Change-Id: If3506c6274d2083b61c5c27cc6d8e178495ccea0 Signed-off-by: Anthony <anthonyhkf@google.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-11-14Fix Dump and EventLog URIRavi Teja1-2/+2
This commit fixes the Dump and EventLog URI while registering BMCWEB_ROUTE Commit 168d1b1ac forgot to include the "/" at the end. Add that. Tested By: GET /redfish/v1/Managers/bmc/LogServices/Dump/Entries/id/attachment/ Change-Id: Ie8a4d8a1d5fa2b508499cc578efe531d06185c1a Signed-off-by: Ravi Teja <raviteja28031990@gmail.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-11-06Fix SNMP invalid Destination errorRavi Teja1-13/+25
This commit handles invalid SNMP destination error Tested by: Configure SNMP with invalid destination IP address '{"Destination": "snmp://10.6.6.256:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' Change-Id: I88f81a79a6665a7adc654e138b4f07ce321898a4 Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
2023-11-06Make callback a template to avoid memory leakEd Tanous1-2/+4
Tested: Gunnar built this and below for a p10bmc, webui-vue looks reasonable and the Validator had no new errors. Did a few operations: delete a log, set an ntp server, etc. Change-Id: I587ccd04515164fce1ea0bf5baf9f820347c63e6 Signed-off-by: Ed Tanous <edtanous@google.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-11-06Don't warn on unused macrosEd Tanous1-0/+1
Change-Id: If12934606c3ef00025d05a9f0b8bd46000865c9a Signed-off-by: Ed Tanous <edtanous@google.com>
2023-11-06Remove use after free in error handling pathEd Tanous1-1/+2
Change-Id: I04476b016584f1d19af035ae51e0c04076b4de0b Signed-off-by: Ed Tanous <edtanous@google.com>
2023-11-06Break out retrieveUriToDbusMapEd Tanous1-14/+19
Change-Id: I7c01c9e455b077348ceb67e524158f997fb0c6cf Signed-off-by: Ed Tanous <edtanous@google.com>
2023-11-06Move date_h to pragma onceEd Tanous1-5/+1
Change-Id: I04864e8c47c8bb1763016b6ba1e5826450afdc72 Signed-off-by: Ed Tanous <edtanous@google.com>