summaryrefslogtreecommitdiff
path: root/redfish-core/lib/health.hpp
AgeCommit message (Collapse)AuthorFilesLines
2023-02-24Take boost error_code by referenceEd Tanous1-1/+1
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-01-18Fix a boatload of #includesEd Tanous1-2/+2
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-11Refactor GetSubTreePaths methodGeorge Liu1-9/+9
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
2022-12-21Change variable scopesEd Tanous1-1/+1
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
2022-07-16Remove usages of boost::starts/ends_withEd Tanous1-11/+10
Per the coding standard, now that C++ supports std::string::starts_with and std::string::ends_with, we should be using them over the boost alternatives. This commit goes through and updates all usages. Arguably some of these are incorrect, and instances of common error 13, but because this is mostly a mechanical it intentionally doesn't try to handle it. Tested: Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic4c6e5d0da90f7442693199dc691a47d2240fa4f
2022-06-30Require explicit decorator on one arg constructorsEd Tanous1-2/+4
We essentially follow this rule already, not relying on implicit operators, although there are a number of cases where in theory we could've implicitly constructed an object. This commit enables the clang-tidy check. Tested: Code compiles, passes clang-tidy. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia428463313b075c69614fdb326e8c5c094e7adde
2022-06-27health: remove boost container headerNan Zhou1-1/+0
This header is not used. Tested: compiles. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Icb07db21b10b99c068eb93529136fe444819908a
2022-06-01Try to fix the lambda formatting issueEd Tanous1-20/+19
clang-tidy has a setting, LambdaBodyIndentation, which it says: "For callback-heavy code, it may improve readability to have the signature indented two levels and to use OuterScope." bmcweb is very callback heavy code. Try to enable it and see if that improves things. There are many cases where the length of a lambda call will change, and reindent the entire lambda function. This is really bad for code reviews, as it's difficult to see the lines changed. This commit should resolve it. This does have the downside of reindenting a lot of functions, which is unfortunate, but probably worth it in the long run. All changes except for the .clang-format file were made by the robot. Tested: Code compiles, whitespace changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
2022-05-26health: take json_ptr instead of reference when filling statusNan Zhou1-4/+12
The existing codes populates the health status on the |AsyncResponse| or a given JSON reference. This doesn't work if we want to populates status on an array of objects, since the array can be resized which changes the address of each object. This commit changed the contructor to take a JSON pointer instead. |HealthPopulate| will populates status on |AsyncResponse->res.jsonValue|[json_ptr]. If the point can't be resolved in the |jsonValue|, |HealthPopulate| populates nothing. Fixed all places where the old reference based constructor is used. This commit is extremely useful when implementing efficient level-1 expand handler on ResourceCollections. It also prevents issues on reference lifecycles. Tested: 1. It builds 2. Tested DIMM/System/Storage health on real hardware, works as expected 3. Tested on Redfish Service Validator, no new failures on health properties. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I305515522af50b48be92a3f4689d8166f3bc0cc0
2022-03-22Consitently use dbus::utility typesEd Tanous1-1/+1
This saves about 4k on the binary size Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9546227a19c691b1aecb80e80307889548c0293f
2022-01-12Enable cppcoreguidelines-special-member-functions checksEd Tanous1-0/+5
Part of enforcing cpp core guidelines involves explicitly including all constructors required on a non-trivial class. We were missing quite a few. In all cases, the copy/move/and operator= methods are simply deleted. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8d6e8bf2bc311fa21a9ae48b0d61ee5c1940999
2022-01-12Fix seg fault in healthEd Tanous1-4/+4
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/49840 was recently checked in that made some changes here, and had issues that weren't caught on my system because of how my sensor setup is setup. This commit changes to only make a single copy, then filter the copy inplace, rather than make a copy, filter, then do the move. Tested: Ran redfish service validator in a similar setup to Romulus, and saw that it passed with the same failures as previously. Unit tested: curl --insecure -u root:0penBmc "https://192.168.7.2:443/redfish/v1/TaskService" now succeeds Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5b59b7074e0a7aad4e95c5ddb625ff24170f3981
2022-01-10Enforce const correctnessEd Tanous1-5/+6
For all async calls, we should be consistently capturing non trivial objects by const reference. This corrects bmcweb to be consistent and capture errors by const value, and objects by const reference. Tested: Code compiles. Trivial changes. This saves about 300 bytes on our compressed binary size. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib3e0b6edef9803a1c480701556949488406305d4
2022-01-10Consistently use ManagedObjectTypeEd Tanous1-32/+34
Some subsystems seem to have invented their own typedefs for this stuff, move to using the one typedef in dbus::utility so we're consistent, and we reduce our templates. Tested: code compiles This saves a negligible amount (104 bytes compressed) on our binary size. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I952ea1f960aa703808d0ac80f35dc24cdd8d5027
2021-12-28Using sdbusplus::asio::getPropertyJonathan Doman1-0/+1
It simplifies a lot of code and after changing sdbusplus implementation slightly reduces binary size if used together with: https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/49467 * Uncompressed size: 3033148 -> 3012164, -20984 B * gzip compressed size: 1220586 -> 1214625, -5961 B Tested: - Redfish validator output is the same before and after the change Change-Id: Ibe3227d3f4230de2363ba3d9396e51130c8240a5 Signed-off-by: Jonathan Doman <jonathan.doman@intel.com> Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2021-07-29HealthPopulate: Fix imprecise matchingKarol Wojciechowski1-2/+9
This commit resolves https://github.com/openbmc/bmcweb/issues/208 Issue was an example of common error https://github.com/openbmc/bmcweb/issues/12 Current mechanism creates incorrect propagation of health statuses to additional nodes. Dbus paths are matched solely by looking at beginning of their path using boost::starts_with. To make an example on memory health statuses system, that created unwanted one-sided connection of dimms placed on path ".../dimm2" and '.../dimm21'. When status object with path '.../dimm21/warning' appeared, it was altering the health setting on both dimms mentioned, just because their beginning path was in fact matching string-wise. That behaviour needed a change to prevent presented imprecise matching. This commit adds a check for a slash '/' sign which marks closing of singular path part. Now objects that are compared to their destination paths are guaranteed not to interact with partially cut names where single characters could determine its match. A slash '/' is not required to match to an object if their path is exactly identical (due to paths not being finished by slash) - that is ensured by use of second, alternative match condition checked with boost::equals. Tested: I used bmcweb's memory mechanism (redfish-core/lib/memory.hpp) to assess that statuses are not being incorrectly propagated anymore after introduction of this commit. All dimm health statuses are presented on redfish. I checked health statuses of example dimms that could be vulnerable to this issue, to be exact dimm10 and dimm1. Then, I proceeded to create an warning status (reverse association object: "warning") association object (https://github.com/openbmc/docs/blob/master/architecture/object-mapper.md#associations) with object path /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm10 so that getAllStatusAssociations() function in redfish-core/lib/health.hpp could find it and apply health status change. By getting the data before and after creating association object prepared for dimm10, the difference was seen only in status of dimm10, which is appropriate to created association. I repeated the process again for dimm22 and dimm2. Observation of health statuses of both dimms in mentioned cases led to trustworthy conclusion - string-wise comparition does not create unwanted propagations anymore. Signed-off-by: Karol Wojciechowski <karol.wojciechowski@intel.com> Change-Id: Id5e113373f537afa33dc206ed9e2e90598e23f8f
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-0/+1
Reduces the total number of lines and will allow for easier testing of the redfish responses. A main purpose of the node class was to set app.routeDynamic(). However now app.routeDynamic can handle the complexity that was once in critical to node. The macro app.routeDynamic() provides a shorter cleaner interface to the unerlying app.routeDyanic call. The old pattern set permissions for 6 interfaces (get, head, patch, put, delete_, and post) even if only one interface is created. That pattern creates unneeded code that can be safely removed with no effect. Unit test for the responses would have to mock the node the class in order to fully test responses. see https://github.com/openbmc/bmcweb/issues/181 The following files still need node to be extracted. virtual_media.hpp account_service.hpp redfish_sessions.hpp ethernet.hpp The files above use a pattern that is not trivial to address. Often their responses call an async lambda capturing the inherited class. ie (https://github.com/openbmc/bmcweb/blob/ffed87b5ad1797ca966d030e7f979770 28d258fa/redfish-core/lib/account_service.hpp#L1393) At a later point I plan to remove node from the files above. Tested: I ran the docker unit test with the following command. WORKSPACE=$(pwd) UNIT_TEST_PKG=bmcweb ./openbmc-build-scripts/run-unit-test-docker.sh I ran the validator and this change did not create any issues. python3 RedfishServiceValidator.py -c config.ini Signed-off-by: John Edward Broadbent <jebr@google.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I147a0289c52cb4198345b1ad9bfe6fdddf57f3df
2021-04-08Using AsyncResp everywherezhanghch051-3/+3
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
2020-10-09Write the clang-tidy file OpenBMC needsEd Tanous1-2/+2
Now that CI can handle clang-tidy, and a lot of the individual fixes have landed for the various static analysis checks, lets see how close we are. This includes bringing a bunch of the code up to par with the checks that require. Most of them fall into the category of extraneous else statements, const correctness problems, or extra copies. Tested: CI only. Unit tests pass. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9fbd346560a75fdd3901fa40c57932486275e912
2020-08-17Enable clang warningsEd Tanous1-8/+8
This commit enables clang warnings, and fixes all warnings that were found. Most of these fall into a couple categories: Variable shadow issues were fixed by renaming variables unused parameter warnings were resolved by either checking error codes that had been ignored, or removing the name of the variable from the scope. Other various warnings were fixed in the best way I was able to come up with. Note, the redfish Node class is especially insidious, as it causes all imlementers to have variables for parameters, regardless of whether or not they are used. Deprecating the Node class is on my list of things to do, as it adds extra overhead, and in general isn't a useful abstraction. For now, I have simply fixed all the handlers. Tested: Added the current meta-clang meta layer into bblayers.conf, and added TOOLCHAIN_pn-bmcweb = "clang" to my local.conf Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
2020-06-11clang-format: update to latest from docs repoGunnar Mills1-18/+17
This is from openbmc/docs/style/cpp/.clang-format Other OpenBMC repos are doing the same. Tested: Built and validator passed. Change-Id: Ief26c755c9ce012823e16a506342b0547a53517a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-06-10Memory: add health supportJames Feist1-1/+17
This adds health support to dimms. It also updates the health object to look for an individual inventory items health. Tested: Validator passed { "@odata.id": "/redfish/v1/Systems/system/Memory/memory_device11", "@odata.type": "#Memory.v1_6_0.Memory", "CapacityMiB": 129728, "DataWidthBits": 64, "Id": "memory_device11", "Manufacturer": "Intel", "MemoryDeviceType": "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.Logical", "Name": "DIMM Slot", "PartNumber": "", "SerialNumber": "", "Status": { "Health": "Critical", "HealthRollup": "Critical", "State": "Enabled" } } Change-Id: If2e1450b4228036f00ff78e6484e8da409a8039b Signed-off-by: James Feist <james.feist@linux.intel.com>
2019-11-25Health: Allow populate to only be called onceJames Feist1-0/+6
Populate does a mapper call and a get managed objects and should only be called once. Enforce it. Tested: No actual change, it is currently never called twice, this is just for future protection with multiple async calls. Change-Id: I8fb9d8d19b2aa2a1c957a0ac8b609adf5e6ba6d0 Signed-off-by: James Feist <james.feist@linux.intel.com>
2019-10-24Add Health to Memory and Processor SummaryJames Feist1-4/+25
These fields were missing Health. Add health objects to get the health associated with these items. Also update the health object to be able to add more than the 'main' health for a url, by allowing passing a json reference. Also, add a 'children' vector of more shared_ptr<HealthPopulate> so we don't double up on d-bus calls. Tested: "MemorySummary": { "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Disabled" }, "TotalSystemMemoryGiB": 0 }, "Model": "S2600WFT", "Name": "system", "PartNumber": "..........", "PowerState": "On", "ProcessorSummary": { "Count": 2, "Model": "Intel Xeon processor", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" } }, Change-Id: I06f802da93a44cfbac40b63d507e3b9faf0c999a Signed-off-by: James Feist <james.feist@linux.intel.com>
2019-10-11Fix a bunch of warningsEd Tanous1-2/+1
using the list of warnings from here: https://github.com/lefticus/cppbestpractices/blob/e73393f25a85f83fed7399d8b65cb117d00b2231/02-Use_the_Tools_Available.md#L100 Seems like a good place to start, and would improve things a bit type-wise. This patchset attempts to correct all the issues in one shot. Tested: It builds. Will test various subsystems that have been touched Signed-off-by: Ed Tanous <ed.tanous@intel.com> Change-Id: I588c26440e5a97f718a0f0ea74cc84107d53aa1e
2019-06-27Health / Rollup SupportJames Feist1-0/+194
Look for associations for inventory and compare the inventory warning / critical and global warning / critical to get HealthRollup and Health respectively. Tested: Used sensor override to set BMC temp to Upper critical and saw: { "@odata.context": "/redfish/v1/$metadata#Chassis.Chassis", "@odata.id": "/redfish/v1/Chassis/WFP_Baseboard", "@odata.type": "#Chassis.v1_4_0.Chassis", "ChassisType": "RackMount", "Id": "WFP_Baseboard", "Links": { "ComputerSystems": [ { "@odata.id": "/redfish/v1/Systems/system" } ], "ManagedBy": [ { "@odata.id": "/redfish/v1/Managers/bmc" } ] }, "Manufacturer": "Intel Corporation", "Model": "S2600WFT", "Name": "WFP_Baseboard", "PartNumber": "123456789", "Power": { "@odata.id": "/redfish/v1/Chassis/WFP_Baseboard/Power" }, "PowerState": "Off", "SerialNumber": "123454321", "Status": { "Health": "Warning", "HealthRollup": "Critical", "State": "StandbyOffline" }, "Thermal": { "@odata.id": "/redfish/v1/Chassis/WFP_Baseboard/Thermal" } } Change-Id: Idd9e832db18bb4769f1452fe243d68339a6f844d Signed-off-by: James Feist <james.feist@linux.intel.com>