summaryrefslogtreecommitdiff
path: root/redfish-core/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-02-24Take boost error_code by referenceEd Tanous28-252/+258
By convention, we should be following boost here, and passing error_code by reference, not by value. This makes our code consistent, and removes the need for a copy in some cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id42ea4a90b6685a84818b87d1506c11256b3b9ae
2023-02-24Pass string views by valueEd Tanous4-13/+10
string_view should always be passed by value; This commit is a sed replace of the code to make all string_views pass by value, per general coding guidelines[1]. [1] https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/ Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I55b342a29a0fbfce0a4ed9ea63db6014d03b134c
2023-02-23Session: Add v1 to urlFromPiecesGunnar Mills1-2/+2
Commit eddfc43 forgot the v1 in these URLs. The bump is failing the validator: ``` 138 err.Session.Session errors in /redfish/v1/SessionService/Sessions 138 failMandatoryProp errors in /redfish/v1/SessionService/Sessions 1 failGet errors in /redfish/SessionService/Sessions/laEDBoxyVi 1 failGet errors in /redfish/SessionService/Sessions/NP9WrNsFwx ``` Note the missing v1 above Tested: None. Change-Id: I95c114f6e151b0a91080a47f3fcd7ae6d3a9668e Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-02-23Update most resources to use urlFromPiecesWilly Tu17-134/+185
Only id in event_service and account_service have not been updated due to the risk of it breaking the username/id. It will require further testing to verify. Use urlFromPieces wherever that is needed to insert a variable in the URI. Don't use urlFromPieces when it is hardcoded values. This allow us to control all resource URIs that is dynamically added and to sync with the current recommanded method for `@odata.id`. The goal is to have a common place to manage the url created from dbus-paths in order to manage/update it easily when needed. Tested: RedfishValidtor Passed for all resource including the sensors with the fragments. Change-Id: I95cdfaaee58fc7f21c95f5944e1e5c813b3215f2 Signed-off-by: Willy Tu <wltu@google.com> Signed-off-by: Ed Tanous <edtanous@google.com>
2023-02-17Don't decrease journal messages time precisionKonstantin Aladyshev1-2/+1
Journal messages are produced in sequence one by one and it is important to keep the order of the messages correct. Messages are produced with a time marker of a usec precision. Currently this time is truncated to sec, and it makes it impossible to restore original order of the messages since there are can be more than one message per second. To correct this output journal messages with original usec precision. Tested: Tested on the AMD EthanolX CRB. Journal messages in Redfish now have 'Created' data with a usec precision. Change-Id: I92fc1d211d273c096a84b0996d643ed4dc3f72ed Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
2023-02-17Don't decrease POST codes time precisionKonstantin Aladyshev1-2/+1
POST codes are produced in sequence one by one and it is important to keep the order of the messages correct. 'phosphor-post-code-manager' provides POST codes with a time marker of a usec precision. Currently this time is truncated to sec, and it makes it impossible to restore original POST codes order for the boards that produce more than one POST code in a second. To correct this output POST codes with original usec precision. Tested: Tested on the AMD EthanolX CRB. Sorting POST codes in the webui-vue application by 'Created' field now works as expected. Change-Id: Icc0aa279aa385018923e8df916c76a7064922f6c Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
2023-02-17Add option for validating content-type headerEd Tanous2-7/+9
For systems implementing to the OWASP security guidelines[1] (of which all should ideally) we should be checking the content-type header all times that we parse a request as JSON. This commit adds an option for parsing content-type, and sets a default of "must get content-type". Ideally this would not be a breaking change, but given the number of guides and scripts that omit the content type, it seems worthwhile to add a trapdoor, such that people can opt into their own model on how they would like to see this checking work. Tested: ``` curl --insecure -H "Content-Type: application/json" -X POST -D headers.txt https://${bmc}/redfish/v1/SessionService/Sessions -d '{"UserName":"root", "Password":"0penBmc"}' ``` Succeeds. Removing Content-Type argument causes bmc to return Base.1.13.0.UnrecognizedRequestBody. [1] cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html Change-Id: Iaa47dd563b40036ff2fc2cacb70d941fd8853038 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-02-17Fix missed includeLakshmi Yadlapati1-0/+2
53ffeca5ae50e522338b9e167e5840bf967a429b missed this include. It uses sdbusplus::unpackPropertiesNoThrow and should have the include. It uses dbus_utils::UnpackErrorPrinter and should have the include. Tested: None. Change-Id: I4811791d7393b7d11163d099519589ec6e6d1dbc Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-02-17Implement alternative to on boost::splitEd Tanous2-7/+7
boost::split has a documented false-positive in clang-tidy. While normally we'd handle this with NOLINTNEXTLINE, this doesn't appear to work in all cases. Unclear why, but seems to be due to some of our lambda callback complexity. Each of these uses is a case where we should be using a more specific check, rather than split, but for the moment, this is the best we have. Tested: clang-tidy passes. [1] https://github.com/llvm/llvm-project/issues/40486 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I144c6610cb740287b7225e2be03b4142a64f9563
2023-02-17Fix missed includeGunnar Mills1-0/+1
53ffeca5ae50e522338b9e167e5840bf967a429b missed this include. It uses sdbusplus::asio::getProperty and should have the include. Tested: None. Change-Id: I84a023b2abdba396dc93348cdaf22173e26aed1f Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-02-16Revert "Implement Manager/ServiceRootUptime"Ed Tanous1-44/+0
This reverts commit ee61a619da7f180a3148317d569d2dabd1cd9832. This feature was tested against an old version of schemas, and upstream DMTF seems to have changed the definition in the meantime. This wasn't caught because of the same test failure as yesterday. Mea Culpa Change-Id: I0be095f5dea0f036927202f367542275abc0ebe3 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-02-16Add Health information for FabricAdapterLakshmi Yadlapati1-0/+28
This commit is to add health information according to the Redfish FabricAdapter schema. If the `xyz.openbmc_project.State.Decorator.OperationalStatus` interface does not exist, the health information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/FabricAdapter.v1_4_0.json Tested: Validator passes # ``` curl -k 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", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS0042-P1" } }, "Model": "6B89", "Name": "Fabric Adapter", "PartNumber": "02WG682", "SerialNumber": "YA31UF09P002", "SparePartNumber": "02WG681", "Status": { "Health": "OK", "State": "Enabled" } } ``` Change-Id: I1fc4549fbac37189e29ba5e49137634b14a08a36 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-02-16Add State information for FabricAdapterLakshmi Yadlapati1-0/+29
This commit is to add state information according to the Redfish FabricAdapter schema. If the `xyz.openbmc_project.Inventory.Item` interface does not exist, the state information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/FabricAdapter.v1_4_0.json Tested: Validator passes # ``` curl -k 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", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS0042-P1" } }, "Model": "6B89", "Name": "Fabric Adapter", "PartNumber": "02WG682", "SerialNumber": "YA31UF09P002", "SparePartNumber": "02WG681", "Status": { "State": "Enabled" } } ``` Change-Id: I1e541910d8d3d69b21594ee05e972517d8b8c12d Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-02-16Add Asset information for FabricAdapterLakshmi Yadlapati1-0/+60
This commit is to add asset information according to the Redfish FabricAdapter schema. If the `xyz.openbmc_project.Inventory.Decorator.Asset` interface does not exist, the asset information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/FabricAdapter.v1_4_0.json Tested: Validator passes # ``` curl -k 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", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS0042-P1" } }, "Model": "6B89", "Name": "Fabric Adapter", "PartNumber": "02WG682", "SerialNumber": "YA31UF09P002", "SparePartNumber": "02WG681" } ``` Change-Id: Id9265b8bd323aa1503c32122899eaa458bcdbb51 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-02-16Make pcie_slots compileEd Tanous1-18/+18
This code doesn't compile; Including it in redfish.hpp, even if it's not used, ensures that we keep code compiling. Tested: Code compiles. No functional impact. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia1009416a692b9700998d6329a297a6754076cf0
2023-02-16Fix some more includesEd Tanous3-0/+3
clang-tidy warns on these when run directly in a header file. Fix them. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib3366699c36e85644107690c23467f2ed22e398d
2023-02-16Add Location information for FabricAdapterLakshmi Yadlapati1-5/+36
This commit is to add location information according to the Redfish FabricAdapter schema. If the `xyz.openbmc_project.Inventory.Decorator.LocationCode` interface does not exist, the location information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/FabricAdapter.v1_4_0.json Tested: Validator passes ``` curl -k 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", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS0042-P1" } }, "Name": "Fabric Adapter" } ``` Change-Id: I0dad37dce06e4727057d9821b5c40c71db004ee6 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-02-15Implement Manager/ServiceRootUptimeEd Tanous1-0/+44
This property was added in Redfish 2022.2 to denote how long this service has been up and available. This implementation opts to go to systemd to get the bmcweb service uptime rather than track it through internal process state, given that systemd already has an API that tracks the bmcweb uptime, and bmcweb attempts to keep as little state as possible. Given that we already have helper functions that give durations in milliseconds precision, this patchset opts to keep the millisecond granularity, rather than dropping to microsecond precision of the systemd API. There are no use cases that would require microsecond precision, so this patchset opts for lower complexity. Tested: Redfish service validator passes. GET /redfish/v1/Managers/bmc Returns a ServiceRootUptime property. Value matches systemctl status bmcweb. systemctl restart bmcweb, causes counter to reset. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae7e805f3f7f5f26745476eaeaecb63bda16a957
2023-02-13Fix a couple #includesEd Tanous3-0/+5
In the continual quest to get tidy passing when run in isolation, fix some more includes. This includes removing a circular #include to app.hpp. We don't use app.hpp in these files, which is why our code compiles but having this include it here causes a few circular dependencies app.hpp -> http_server.hpp -> persistent_data.hpp -> app.hpp. app.hpp -> http_server.hpp -> authentication.hpp -> app.hpp. This confuses clang when run on header files directly. Fix a couple more includes at the same time. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib62d78b49c7e38ef7061c9fbbf6b3d463f11917d
2023-02-10Correct Id parameter for two log servicesEd Tanous1-2/+2
The Journal and EventLog now fail redfish-service-validators new test. Per the specification, the "Id" parameter should match the elements odata id segment in the collection. The validator now tests for this, and these two fail. Tested: Redfish service validator now passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I463eea7ae7a7dfd6a9d6d562ae4f03dc887a9478
2023-02-09Implementation of FabricAdapter schema in bmcwebSunny Srivastava2-0/+210
This commit implements FabricAdapter and FabricAdapter collection schema. This code assumes all FabricAdapters are under /redfish/v1/Systems/system like we do for Memory and Processors. The schema can be used to publish inventory properties for FRUs which can be modelled as Fabric adapters. As a current use case, this schema is required to link ports on fabric adapters back to the system. A FabricAdapter represents the physical fabric adapter capable of connecting to an interconnect fabric. Examples include but are not limited to Ethernet, NVMe over Fabrics, Gen-Z, and SAS fabric adapters. Tested: Manually tested on the system, Run Redfish validator. Found no error. { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters", "@odata.type": "#FabricAdapterCollection.FabricAdapterCollection", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane1" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card0" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card3" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card4" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card8" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card10" }, { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card11" } ], "Members@odata.count": 8, "Name": "Fabric Adapter Collection" } { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card11", "@odata.type": "#FabricAdapter.v1_0_0.FabricAdapter", "Id": "pcie_card11", "Name": "Fabric Adapter" } Signed-off-by: sunny srivastava <sunnsr25@in.ibm.com> Change-Id: I4d3bc31a6f0036c262c0e30481d0da4aaf59b5ab Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-02-08Fix OemAccountService schemaEd Tanous1-1/+1
This schema as-written broke a bunch of Redfish specification rules for schemas, naming and other things. This commit starts to fix them. It can be used as a starting point for fixing the existing schemas. This working through testing. Tested: OpenBMCAccountService_v1.xml now passes the redfish odata schema validator. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id991794344b8b7d36af3c44bba7214bf025deec8
2023-02-07ethernet: Fix getting empty IP addressTony Lee1-8/+48
Dbus for "xyz.openbmc_project.Network" changed to no protocol in object path[0]. And this is in line with expectations[1]. Since that, it will get empty IP address when calling "/redfish/v1/Managers/bmc/EthernetInterfaces/eth1". Dbus before: /xyz/openbmc_project/network/eth0/ipv4/52348b91 Now: /xyz/openbmc_project/network/eth0/_66e80_3a_3aa00_3a27ff_3afee1_3a5408 Test: Before: GET /redfish/v1/Managers/bmc/EthernetInterfaces/eth1 ``` { "IPv4Addresses": [], "IPv4StaticAddresses": [], "IPv6AddressPolicyTable": [], "IPv6Addresses": [], } ``` After: GET /redfish/v1/Managers/bmc/EthernetInterfaces/eth1 ``` { "IPv4Addresses": [ { "Address": "192.168.1.108", "AddressOrigin": "DHCP", "Gateway": "192.168.1.2", "SubnetMask": "255.255.255.0" } ], "IPv6Addresses": [ { "Address": "fe80::e24f:43ff:fefe:ca5d", "AddressOrigin": "LinkLocal", "AddressState": null, "PrefixLength": 64 } ], } ``` [0]: https://github.com/openbmc/phosphor-networkd/commit/59e5b91d9784274d1d99b4c10e939c38606efacc [1]: https://discord.com/channels/775381525260664832/775381525260664836/1044873098010316840 Change-Id: I40a5357e6ad31afa7156ac3bce908ae48d26a0cf Signed-off-by: Tony Lee <tony.lee@quantatw.com> Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
2023-02-02Fix some warnings by cppcheckGeorge Liu1-4/+2
Warning message: redfish-core/include/redfish_aggregator.hpp:800:21: style: The scope of the variable 'collectionItem' can be reduced. [variableScope] std::string collectionItem; ^ redfish-core/lib/power.hpp:279:33: style: The scope of the variable 'value' can be reduced. [variableScope] nlohmann::json& value = ^ Tested: Verify that there are no such warnings in local CI. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie379dcb04a22a00b495f9ab3948d97e2e537f395
2023-01-31Set state to Absent on Present == falseWilly Tu1-6/+6
- State=Absent means this function or resource is either not present or detected. - State=Disabled means that the device exists, but has been disabled. Tested: Redfish Validator Passed Verified that absence of Drive shows [Status][State] = "Absent" ``` wget -qO- http://localhost:80/redfish/v1/Chassis/mychassis/Drives/Drive_0 { "@odata.id": "/redfish/v1/Chassis/mychassis/Drives/Drive_0", "@odata.type": "#Drive.v1_7_0.Drive", "Id": "Drive_0", "Links": { "Chassis": { "@odata.id": "/redfish/v1/Chassis/mychassis" } }, ....., ....., ....., "Protocol": "....", "Status": { "State": "Absent" } } ``` Change-Id: I99217c1c3c94df5c10fb158d3d1ef65d70d0ebb3 Signed-off-by: Willy Tu <wltu@google.com> Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2023-01-28Fix handleAccounttDelete spellingGunnar Mills1-4/+4
Extra t, make the method match others like handleAccountPatch. 1ef4c3423f1f13ba6a804f72427641e6f8287dba has this wrong. Tested: None. It builds. Change-Id: I7e465d525ddb3ce89567b6918933e41726a4faa4 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-01-27Remove unused variablesEd Tanous1-3/+0
These were found by inspection. Tested: Code Compiles. Dead code elimination. Change-Id: I53455672f96faa44ad0e94146baf2d28daf8e10a Signed-off-by: Ed Tanous <edtanous@google.com>
2023-01-24Refactor GetSubTree methodGeorge Liu12-322/+252
Since the GetSubTree method has been implemented in dbus_utility and this commit is to integrate all the places where the GetSubTree method is called, and use the method in dbus_utility uniformly. Tested: Redfish Validator Passed Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If3852b487d74e7cd8f123e0efffbd4affe92743c
2023-01-23Break out set time function and unit test itEd Tanous1-37/+20
This function is something that's easily unit tested. Do it. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8d664c77ec4b3a9886128597449c5f9c041b86b3
2023-01-19Remove proprietary OEMSession supportEd Tanous1-36/+1
Per https://gerrit.openbmc.org/c/openbmc/bmcweb/+/56088, this feature would be supported to the end of 2022, at which point people will have moved over to the standard Context parameter in the DMTF-published Session schema. Tested: Code removal. Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0ae832bde740b025150242085bf1d2909ed1ec21
2023-01-19Add the GetObject method to dbus_utilityGeorge Liu5-67/+54
There are currently many files that use the GetObject method. Since they are a general method, they are defined in the dbus_utility.hpp file and refactors them. Tested: Built bmcweb successfully and Validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If2af77294389b023b611987252ee6149906fcd25
2023-01-19Add Get for PCIe property LanesInUseMyung Bae1-1/+10
Added Redfish property 'LanesInUse' to PCIeDevices under redfish/v1/Systems. LanesInUse maps to dbus LanesInUse property for the Inventory.Item.PCIeDevice interface. Note: GUI might map this property to 'LinkWidth' Tested: 1) Redfish validator passed 2) Curl testing curl -k <token> \ https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card8 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", ... "PCIeInterface": { "LanesInUse": 16, "PCIeType": "Gen4" }, ... } Signed-off-by: Myung Bae <myungbae@us.ibm.com> Change-Id: I896abe44f55414f25d01c5a93a31bb585264657e
2023-01-18Fix a boatload of #includesEd Tanous37-171/+196
Most of these missing includes were found by running clang-tidy on all files, including headers. The existing scripts just run clang-tidy on source files, which doesn't catch most of these. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic741fbb2cc9e5e92955fd5a1b778a482830e80e8
2023-01-17Add check for globalsEd Tanous4-13/+21
We don't follow this cpp core guidelines rule well. This is something that we should aspire to cleaning up in the future, but for the moment, lets turn the rule on in clang-tidy to stop the bleeding, add ignores for the things that we know need some better abstractions, and work on these over time. Most of this commit is just adding NOLINTNEXTLINE exceptions for all of our globals. There was one case in the sensor code where clang correctly noted that those globals weren't actually const, which got missed because of the use of auto. Tested: CI should be good enough for this. Passes clang-tidy. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ieda08fee69a3b209d4b3e9771809a6c41524f066
2023-01-14LogService: Use DeleteAll DBus method in clearDumpClaire Weinan1-22/+38
Update the clearDump() implementation to call the DeleteAll D-Bus method instead of iterating through D-Bus objects representing individual log entries and calling the Delete D-Bus method on each one. (It's more efficient for phosphor-debug-collector to iterate through entries in its DeleteAll method handler than for bmcweb to iterate through them.) It seems like clearDump() wasn't originally implemented using DeleteAll because dumps of various types were under the same D-Bus path namespace at the time and there wasn't a way to selectively clear dumps of only a specific type. The commit at [1] put different dump types under different path namespaces (enabling us to now use DeleteAll). Now clients should see a bit of performance improvement when running the ClearLog action on dump LogServices, due to the reduced number of D-Bus method calls needed to execute ClearLog. Also updated getDumpServiceInfo() to populate the ClearLog action for dump LogServices based on whether their dump manager object implements xyz.openbmc_project.Collection.DeleteAll. Tested: Cleared the fault log containing 100 entries. Ran with the time command several times before and after the change: ``` time curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/FaultLog/Actions/LogService.ClearLog ``` Before the change, "real" time reported was ~1.2s. After the change, "real" time reported was ~0.4s. Forced creation of dump entries and then ran Redfish ClearLog action on each dump type: ``` curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/FaultLog/Actions/LogService.ClearLog curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog ``` Then verified that there were no dump LogService entries afterwards: ``` curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Entries curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Managers/bmc/LogServices/FaultLog/Entries curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Systems/system/LogServices/Dump/Entries ``` Also verified that the corresponding D-Bus objects were gone from the D-Bus tree after running ClearLog on each dump type: Before ClearLog: busctl tree xyz.openbmc_project.Dump.Manager `-/xyz `-/xyz/openbmc_project `-/xyz/openbmc_project/dump |-/xyz/openbmc_project/dump/bmc | `-/xyz/openbmc_project/dump/bmc/entry | `-/xyz/openbmc_project/dump/bmc/entry/101 |-/xyz/openbmc_project/dump/faultlog | `-/xyz/openbmc_project/dump/faultlog/entry | |-/xyz/openbmc_project/dump/faultlog/entry/11 | |-/xyz/openbmc_project/dump/faultlog/entry/12 | |-/xyz/openbmc_project/dump/faultlog/entry/13 | |-/xyz/openbmc_project/dump/faultlog/entry/14 | |-/xyz/openbmc_project/dump/faultlog/entry/15 | |-/xyz/openbmc_project/dump/faultlog/entry/16 | |-/xyz/openbmc_project/dump/faultlog/entry/17 | |-/xyz/openbmc_project/dump/faultlog/entry/18 | |-/xyz/openbmc_project/dump/faultlog/entry/19 | `-/xyz/openbmc_project/dump/faultlog/entry/20 |-/xyz/openbmc_project/dump/internal | `-/xyz/openbmc_project/dump/internal/manager `-/xyz/openbmc_project/dump/system `-/xyz/openbmc_project/dump/system/entry |-/xyz/openbmc_project/dump/system/entry/3 `-/xyz/openbmc_project/dump/system/entry/4 After ClearLog: busctl tree xyz.openbmc_project.Dump.Manager `-/xyz `-/xyz/openbmc_project `-/xyz/openbmc_project/dump |-/xyz/openbmc_project/dump/bmc |-/xyz/openbmc_project/dump/faultlog |-/xyz/openbmc_project/dump/internal | `-/xyz/openbmc_project/dump/internal/manager `-/xyz/openbmc_project/dump/system Confirmed that ClearLog action is listed for the following LogServices: /redfish/v1/Managers/bmc/LogServices/Dump /redfish/v1/Managers/bmc/LogServices/FaultLog /redfish/v1/Systems/system/LogServices/Dump Then ran "systemctl stop xyz.openbmc_project.Dump.Manager" (which removes dump manager objects including their xyz.openbmc_project.Collection.DeleteAll interface) and saw that the ClearLog action was no longer listed. Also locally built a version of phosphor-debug-collecor with the interface xyz.openbmc_project.Collection.DeleteAll removed from dump managers and ran it and saw that the ClearLog action wasn't listed. Redfish Service Validator passed on the following URIs (with service xyz.openbmc_project.Dump.Manager running): /redfish/v1/Managers/bmc/LogServices/Dump /redfish/v1/Managers/bmc/LogServices/FaultLog /redfish/v1/Systems/system/LogServices/Dump Note: Most dump LogService unit tests were removed in this patchset since this patchset adds a D-Bus call to getDumpServiceInfo(), and we haven't decided how to mock D-Bus calls for unit testing yet. [1] https://github.com/openbmc/phosphor-debug-collector/commit/fef66a951fe6fe283515480b2c493dfdc2275a95 Signed-off-by: Claire Weinan <cweinan@google.com> Change-Id: Ic5f8f9e3528f521887766d8710bd77f969d8236a
2023-01-13Remove a couple references to @odata.contextEd Tanous1-4/+0
9440096005902d13e27fdb8911d33c657f8c7b77 removed all uses of odata.context from the system, but there were a few left in static files, that unfortunately got propagated to code when we did the migration from static files. This commit fixes the last couple that were left. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ifc77ff02939c663106029dc57807db3b8ad537b7
2023-01-11Fix parameter type for calling getSubTreePaths methodGeorge Liu1-1/+1
The interface attribute type that calls the getSubTreePaths method should use std::string_view instead of const char*. bump is failing. https://gerrit.openbmc.org/c/openbmc/openbmc/+/60221 https://jenkins.openbmc.org/job/ci-openbmc/15513/distro=ubuntu,label=docker-builder,target=witherspoon/console Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I9dc4a710da0bdcec91a73ded89a253baa04a3550
2023-01-11Refactor GetSubTreePaths methodGeorge Liu17-162/+166
Since the GetSubTreePaths method has been implemented in dbus_utility and this commit is to integrate all the places where the GetSubTreePaths method is called, and use the method in dbus_utility uniformly. Requires https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/60020 to build. Tested: Redfish Validator Passed Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie4140d4484a7e4f4b943013f4371ffd2d44a22e9
2023-01-10Use actionParams struct instead of fieldsPrzemyslaw Czarnowski1-37/+33
Make validateParams use of actionParams (InsertMediaActionParams structure) instead of fields one by one. This will make possible to remove reference to crow::Response in lambda containing vaildateParams structure. Tested: none, code change Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Change-Id: I0f2ac76f6f7e578cb29527cd1e8f1d8ba9e94960
2023-01-05Add ServiceProviderNotifyAbhishek Patel1-2/+46
Add ServiceProviderNotify property that can be used to indicate that this event log should be notified to the service provider, if that is implemented on the system. ServiceProviderNotify is an enum. Supported options are - "NotSupported", "Notify" and "Inhibit". The dbus interface and all implementations have been moved to an enum with the default value of NotSupported. When the value is NotSupported, this property is left off Redfish. For more details refer to https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/47683 Tested: Manually tested on the system, Run Redfish validator. Found no error. ''' curl -k https://$bmc/redfish/v1/Systems/system/LogServices/EventLog/Entries { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries", "@odata.type": "#LogEntryCollection.LogEntryCollection", "Description": "Collection of System Event Log Entries", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", "@odata.type": "#LogEntry.v1_9_0.LogEntry", "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1/attachment", "Created": "1970-01-01T00:04:20.865+00:00", "EntryType": "Event", "Id": "1", "Message": "xyz.openbmc_project.Software.Image.Error.ImageFailure", "Modified": "1970-01-01T00:04:20.865+00:00", "Name": "System Event Log Entry", "Resolved": false, "Severity": "Critical" }, .... .... ], "Members@odata.count": 49, "Name": "System Event Log Entries" } ''' busctl set-property xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/99 xyz.openbmc_project.Logging.Entry ServiceProviderNotify s xyz.openbmc_project.Logging.Entry.Notify.Notify busctl get-property xyz.openbmc_project.Logging /xyz/openbmc_project/logging/entry/99 xyz.openbmc_project.Logging.Entry ServiceProviderNotify Entry ServiceProviderNotify Signed-off-by: Abhishek Patel <Abhishek.Patel@ibm.com> Change-Id: I774bfec157481ccc9b4966bf5e8cc8f7d9a06fd0 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-01-04Problem with RemoteRoleMapping JSONJorge Cisneros1-9/+2
The current LDAP group map on /redfish/v1/AccountService is incorrect and is creating a bad JSON response. instead of an array of objects, is creating a nested array of objects. The problem is visible on the website adding a new LDAP group map, it will show 2 empty rows instead of one with the correct data. The current JSON data is: "RemoteRoleMapping": [ [ { "RemoteGroup": "groupname" } ], [ { "LocalRole": "Operator" } ] ], The correct JSON is: "RemoteRoleMapping": [ { "LocalRole": "Operator", "RemoteGroup": "groupname" } ], The tests redfish/account_service/test_ldap_configuration crashed BMCWEB generates around 9 core dump files. Tested: redfish/account_service/test_ldap_configuration passed the tests Adding a new LDAP group map on the website, showing the correct data, Change-Id: I5de7db372ceff1cc596da2b04f5fd730415f7216 Signed-off-by: Jorge Cisneros <jcisneros3@lenovo.com>
2023-01-03Remove old TODOEd Tanous1-5/+0
This TODO was implemented long ago by DMTF. Remove the comment. Tested: Comment only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4b0fc7c6fefa316d1cf824711d542f17a6f1a682
2023-01-03Remove extra semi colonsEd Tanous1-8/+0
Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I710b68218f5df32088a0ce90250763cd765b054a
2023-01-03Add missing inline on function prototypeEd Tanous1-1/+1
Clang correctly notes that this function is missing an inline definition. Tested: Code compiles further on clang (other failures still present). Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7d6420e2bb1c0c9360ff8427857aa916142c5a66
2023-01-03Fix sensor overrideEd Tanous1-16/+32
c1d019a6056a2a0ef50e577b3139ab5a8dc49355 Sensor Optimization Recently changed the way Ids were calculated in the sensor subsystem. Unfortunately, it wasn't clear to the author that this would effect the sensor override system, which relies on matching up a member ID with a dbus path, and was broken by this change. This commit breaks out the code to calculate the type and name from a given URI segment into a helper method. Tested: Inspection only. Very few systems support this feature. Code appears more correct than previously, which is known broken, so the lack of testing here seems reasonable. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9aa8099a947a36b5ce914bc07ae60f1ebf0d209b
2022-12-29Add missing const in update serviceEd Tanous1-1/+1
Per cpp core guidelines, this type should be const. Tested: Code compiles. Trivial const change. cppcheck no longer warns on this line. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I04aae41701ba1203ff4a68f0b06df2459ee7bb2f
2022-12-28Fix some use-after-move issuesEd Tanous1-79/+77
This diff looks bad. The only thing that changed functionally is changing: password(std::move(password)), roleId(std::move(roleId)) in the labmda capture to password, roldId because password and roleid are getting used later. Unfortunately, clang decides to rearrange this whole lambda. Tested: Passes cppcheck. ''' curl -vvvv --insecure --user root:0penBmc -X PATCH -d '{"Password": "0penBmc1"}' https://192.168.7.2/redfish/v1/AccountService/Accounts/root ''' Succeeds at patching the root password. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I97b10a40d0b271b211bf4e6c09888d3cd568a3d0
2022-12-22Fix cppcheck errorEd Tanous1-29/+15
cppcheck comments that this can be const. Unfortunately, this looks like a false positive, where cppcheck cannot see through the std::replace template. Tested: This is in the set pid loop handler that doesn't have any good tests with it. Code compiles, and only inspection is possible at this time. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I21eaadcc37b2f3993e63b39d471cbf118d88119a
2022-12-22Avoid copyEd Tanous1-1/+1
cppcheck warns that this is a copy, so fix it. Tested: cppcheck no longer warns on this line. Unfortunately, virtual media does not have a backend, so this is dead code. No way to test at this point. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1e98ca63ee346ad683844e5637a173f64286102a
2022-12-21Change variable scopesEd Tanous5-11/+11
cppcheck correctly notes that a lot of our variables can be declared at more specific scopes, and in every case, it seems to be correct. Tested: Redfish service validator passes. Unit test coverage on others. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416