summaryrefslogtreecommitdiff
path: root/redfish-core/lib/sensors.hpp
AgeCommit message (Collapse)AuthorFilesLines
2022-04-27Simplify sensor path lookupsEd Tanous1-37/+48
This commit drops 8k from the binary size. Tested: SensorCollection returns sensor values as expected, same as previously Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ife1dc40ff6745585ac6bc3f99cd5e6c4811baa56
2022-04-25Sensors: Add humidity hierarchyGunnar Mills1-1/+7
As stated in PDI humidity is a valid hierarchy. https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Sensor/Value.interface.yaml From https://redfish.dmtf.org/schemas/v1/Sensor.v1_5_0.json: Humidity is a valid ReadingType and Humidity ReadingUnits shall be %. This follows the following Redfish mockup: https://redfish.dmtf.org/redfish/mockups/v1/1156 This is not under BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM due to not being part of the old thermal or power resources. Tested: Validator passes. See a Humidity sensor in the Sensor colleciton: { "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/Relative_Humidity", "@odata.type": "#Sensor.v1_0_0.Sensor", "Id": "Relative_Humidity", "Name": "Relative Humidity", "Reading": 61.935424802658005, "ReadingRangeMax": 100.0, "ReadingRangeMin": 0.0, "ReadingType": "Humidity", "ReadingUnits": "%", ... Signed-off-by: Gunnar Mills <gmills@us.ibm.com> Change-Id: Ib1f52b0b0e3d8c4bfec8c4389c811fdb8b9d887a
2022-04-11sensor collection: implement efficient expand handlerNan Zhou1-30/+94
This change adds an efficient expand handler for $levels=1 expand at the sensors collection. Instead of Query one sensor at time, it reuses existing codes for Thermal and Power (which has AutoExpand), and queries the whole sensor at one query. It's more efficient than the default expand handler as well since the default handler stills query all the sensors and filter other sensors when querying a single sensor. Performance improves dramatically on a real hardware with 220+ sensors: Before this change, time wget -qO- 'http://localhost/redfish/v1/Chassis/xxx/Sensors?$expand=.($levels=1)' > /tmp/log_slow.json real 0m33.786s user 0m0.000s sys 0m0.000s After this change time wget -qO- 'http://localhost/redfish/v1/Chassis/xxx/Sensors?$expand=.($levels=1)' > /tmp/log_fast.json real 0m0.769s user 0m0.010s sys 0m0.010s TESTED:: 1. QEMU Redfish/IPMI passed 2. Validator passed (though it doesn't support query paramters) 3. Tested on real hardware. { "@odata.id": "/redfish/v1/Chassis/xxx/Sensors", "@odata.type": "#SensorCollection.SensorCollection", "Description": "Collection of Sensors for this Chassis", "Members": [ { "@odata.id": "/redfish/v1/Chassis/xxx/Sensors/abc", "@odata.type": "#Sensor.v1_0_0.Sensor", "Id": "abc", "Name": "abc", "Reading": 3.133, "ReadingRangeMax": 5.8500060148599005, "ReadingRangeMin": 0.0, "ReadingType": "Voltage", "ReadingUnits": "V", "Status": { "Health": "OK", "State": "Enabled" }, "Thresholds": { "LowerCritical": { "Reading": 2.205 }, "UpperCritical": { "Reading": 3.507 } } }, ], "Members@odata.count": 225, "Name": "Sensors" } Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I745a31d6fe8d0aac08d532ea976bfc1a4a40b19c
2022-04-08sensors: move callback from lambda to inline functions with bind_frontNan Zhou1-37/+36
bind_front + function is more readable than local lambdas. Tested: Tested sensor collection, works as expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ib3bd6d4249df97c4be5afcd1393477ed424f5de8
2022-04-06Add setUpRedfishRoute to all nodes in redfishEd Tanous1-47/+59
For better or worse, the series ahead of this is making use of setUpRedfishRoute to do the common "redfish specified" things that need to be done for a connection, like header checking, filtering, and other things. In the current model, where BMCWEB_ROUTE is a common function for all HTTP routes, this means we need to propagate this injection call into the whole tree ahead of the requests being handled. In a perfect world, we would invent something like a REDFISH_ROUTE macro, but because macros are discouraged, the routes take a variadic template of parameters, and each call to the route has a .privileges() call in the middle, there's no good way to effect this change in a less costly manner. This was messaged both in the prior reviews, and on discord sourcing improvements on this pattern, to which none arose. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id29cc799e214edad41e48fc7ce6eed0521f90ecb
2022-03-22Consitently use dbus::utility typesEd Tanous1-117/+118
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-03-12Enable readability checksEd Tanous1-5/+5
clang-tidy readability checks are overall a good thing, and help us to write consistent and readable code, even if it doesn't change the result. All changes done by the robot. Tested: Code compiles, inspection only (changes made by robot) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iee4a0c74a11eef9f158f0044eae675ebc518b549
2022-03-01Change the completionhandler to accept ResNan Zhou1-3/+2
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). It will be used in future CLs for Query Parameters. The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Also fixed a self-move assignment bug. Context: Originally submitted: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/480020 Reveted here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/48880 Because of failures here: https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Tested: 1. Romulus QEMU + Robot tests; all passed 2. Use scripts/websocket_test.py to test websockets. It is still work correctly. 3. Tested in real hardware; no new validator errors; tested both authless, session, and basic auth. 4. Hacked codes to return 500 errors on certain resource; response is expected; 5. Tested Eventing, the push style one (not SSE which is still under review), worked as expected. 6. Tested 404 errors; response is expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: I52adb174476e0f6656335baa6657456752a031be
2022-02-15Enable readability-implicit-bool-conversion checksEd Tanous1-2/+2
These checks ensure that we're not implicitly converting ints or pointers into bools, which makes the code easier to read. Tested: Ran series through redfish service validator. No changes observed. UUID failing in Qemu both before and after. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1ca0be980d136bd4e5474341f4fd62f2f6bbdbae
2022-02-11Add readability-redundant-* checksEd Tanous1-10/+6
There's a number of redundancies in our code that clang can sanitize out. Fix the existing problems, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie63d7b7f0777b702fbf1b23a24e1bed7b4f5183b
2022-02-09Enable readability-avoid-const-params-in-declsEd Tanous1-15/+17
This check involves explicitly declaring variables const when they're declared auto, which helps in readability, and makes it more clear that the variables are const. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
2022-01-28Enable readability-container-size-empty testsEd Tanous1-4/+4
This one is a little trivial, but it does help in readability. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa
2022-01-12Fix regresssion in nameEd Tanous1-1/+1
It's unclear whether clang-format lost its mind, or if I did this unintentionally, but it's clearly wrong, and for systems that have sensors in warning, causes a ERROR - Health: Value wARNING Enum not found in ['OK', 'Warning', 'Critical'] error in the service validator. Fix this. Tested: Code compiles, revert. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If79654fd7026080c89de0ece2c553e6edf97fd8f
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-12Enable init checkerEd Tanous1-2/+2
clang-tidy added cppcoreguidelines-init-variables as a check, which is something we already enforce to some extent, but getting CI to enforce it will help reviews move faster. Tested: Code compiles. Noop changes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7e10950de617b1d3262265572b1703f2e60b69d0
2022-01-12Enable clang-tidy forward reference checksEd Tanous1-14/+23
Clang-13 adds new checks we can turn on, which find quite a few errors. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I74b780760014c898cc440b37aea640b33e91c439
2022-01-10Consistently use ManagedObjectTypeEd Tanous1-199/+168
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-103/+54
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-12-28Move to common variantEd Tanous1-64/+65
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
2021-12-15Fix - RedFish response for non-manufacturing modeJayaprakash Mutyala1-50/+56
Issue: If system is not in manufacturing mode, RedFish response is success but sensor value is not updated Fix: If the system is not in manufacturing mode, return proper error as actionNotSupported. Tested: 1. Redfish validator - passed for this new change 2. Verified RedFish response when system in not manufacturing mode. Patch: https://<BMC-IP>/redfish/v1/Chassis/<Baseboard>/Thermal Body: { "Temperatures": [ { "MemberId": "BMC_Temp", "ReadingCelsius": 34.313 }] } Response: { "@odata.id": "/redfish/v1/Chassis/<Baseboard>/Thermal", "@odata.type": "#Thermal.v1_4_0.Thermal", "Fans": [], "Id": "Thermal", "Name": "Thermal", "Temperatures": [], "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "There are insufficient privileges for the account or credentials associated with the current session to perform the requested operation.", "MessageArgs": [], "MessageId": "Base.1.8.1.InsufficientPrivilege", "MessageSeverity": "Critical", "Resolution": "Either abandon the operation or change the associated access rights and resubmit the request if the operation failed." } ], "code": "Base.1.8.1.InsufficientPrivilege", "message": "There are insufficient privileges for the account or credentials associated with the current session to perform the requested operation." } } Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com> Change-Id: I3c6bfc9d37e1e8648ad0ff713929ad3fd06f437b
2021-11-19Update clang-formatGeorge Liu1-2/+1
refer: https://github.com/openbmc/docs/blob/master/style/cpp/.clang-format `Don't break long string literals` Tested: built bmcweb successfully and RedfishValidator Passed. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ib58f7c942fd3838592e043c57e0b6ffcdc3d963b
2021-11-16Revert "Change the completionhandler to accept Res"Gunnar Mills1-2/+3
This reverts commit 91995f3272010875e1559397e98ca93354066a0e. Seeing bumps fail. https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Please fix, test, and resubmit. Change-Id: Id539fe66d5a093caf8f22a393f7af7b58ead5247 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2021-11-16Change the completionhandler to accept Reszhanghch051-3/+2
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). And they will be used in Redfish:Query Parameters:Only. (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38952) The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Tested: 1.Basic and Token auth both still work. 2.Use scripts/websocket_test.py to test websockets. It is still work correctly. python3 websocket_test.py --host 127.0.0.1:2443 This modification is a public part, so you can use any URL to test this function. The response is the same as before. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I570e32fb47a9a90fe111fcd1f4054060cd21def3
2021-11-10redfish:sensors: change verbose error trace to debugAndrew Geissler1-1/+1
It was noticed recently when enabling bmcweb error traces to assist with some debug, the journal was filling with logs like this: Nov 09 21:23:46 p10bmc bmcweb[249]: (2021-11-09 21:23:46) [ERROR "sensors.hpp":2584] fan3_1 not in sensor list Nov 09 21:23:46 p10bmc bmcweb[249]: (2021-11-09 21:23:46) [ERROR "sensors.hpp":2584] fan3_0 not in sensor list Nov 09 21:23:46 p10bmc bmcweb[249]: (2021-11-09 21:23:46) [ERROR "sensors.hpp":2584] fan4_0 not in sensor list ... This was the result of a test case reading a single sensor: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/Sensors/fan4_1 This code logic is fairly complex but appears to get all sensors of the type passed in, then iterates through them looking for the one(s) of interest. This code path should not be an error. Tested: - Verified that after running the following command, the unwanted logs were no longer in the journal: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/Sensors/fan4_1{ "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fan4_1", "@odata.type": "#Sensor.v1_0_0.Sensor", "Id": "fan4_1", "Name": "fan4 1", "Reading": 7772.0, "ReadingRangeMax": null, "ReadingRangeMin": null, "ReadingType": "Rotational", "ReadingUnits": "RPM", "Status": { "Health": "OK", "State": "Enabled" } } Change-Id: Iaffd0243ddcd148b72486b3025673bb35d0dd7a3 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
2021-10-29Revert "Use AsyncResp in retrieveUriToDbusMap"Krzysztof Grobelny1-5/+6
This reverts commit 9d832618c74052bd445d6e8b3461946f3c431ca3. Reason for revert: Power schema should not be returned as reposponse to POST request Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: I01806a8c24c67f264dab4e9972497323c1499017
2021-10-27Use AsyncResp in retrieveUriToDbusMapzhanghch051-6/+5
Initially, when the change to use AsyncResp everywhere was made, the retrieveUriToDbusMap was skipped. This commit address that issue, by adding AsyncResp to retrieveUriToDbusMap. Tested: curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/TelemetryService/MetricReportDefinitions/ -d '{"Id": "lxw1", "Metrics": [{"MetricId": "123", "MetricProperties": ["/redfish/v1/Chassis/chassis/Power#/Voltages/0 /ReadingVolts"]}], "MetricReportDefinitionType": "OnRequest", "ReportActions": ["LogToMetricReportsCollection"], "Schedule": {"RecurrenceInterval": "100"}}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The resource has been created successfully", "MessageArgs": [], "MessageId": "Base.1.8.1.Created", "MessageSeverity": "OK", "Resolution": "None" } ], "@odata.id": "/redfish/v1/Chassis/chassis/Power", "@odata.type": "#Power.v1_5_2.Power", "Id": "Power", "Name": "Power", "Redundancy": [], "Voltages": [ { "@odata.id": "/redfish/v1/Chassis/chassis/Power#/Voltages/0", "@odata.type": "#Power.v1_0_0.Voltage", "LowerThresholdCritical": 10.8, "LowerThresholdNonCritical": 11.16, "MaxReadingRange": 12600.0, "MemberId": "P12V", "MinReadingRange": 11400.0, "Name": "P12V", "ReadingVolts": 22.930140000000005, "Status": { "Health": "Critical", "State": "Enabled" }, "UpperThresholdCritical": 13.200000000000001, "UpperThresholdNonCritical": 12.84 }, ... The response is too long, so I omitted the following content. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I6f82bdb234ddade67f689d79d004d672593fba4f
2021-08-20Move sensor collection to all sensorsGeorge Liu1-0/+8
Redfish's thinking on what sensors should be included in the sensor collection has changed. Roughly two years ago their thinking was "for sensors that are not covered elsewhere in the model-meaning do not duplicate Power and Thermal" and that is what OpenBMC implemented. Today, as described in the new thermalSubsystem and powerSubsystem doc the sensor collection should contain all sensors that are associated with that chassis. Link with: https://redfishforum.com/thread/190/sensorcollection-contain-all-sensors-chassis All things considered as "sensors" should be included in the Sensor collection. To make this transition as easy as possible for clients, create a new meson option, new-powersubsystem-thermalsubsystem. This "all sensors in the sensor collection" behavior as well as the new ThermalSubsystem, PowerSubsystem, Fans, and Power Supplies schemas will be under this option. This option is defaulted to disabled. At a later time, the default will move to enabled. Move Redfish SensorCollection to show all sensors from /xyz/openbmc_project/sensors with the "all_sensors" association for that chassis if this option is enabled. The SensorCollection is found at /redfish/v1/Chassis/<Id>/Sensors. Tested: 1. Enabled redfish-new-powersubsystem-thermalsubsystem and validator passes. 2. Performance testing (average of 5 times): a. Redfish validator time: without this patch: 71.375s with this patch: 71.763s b. Number of sensors tested: without this patch: 8 with this patch: 63 c. Run `https://${bmc}/redfish/v1/Chassis/chassis/Sensors`: without this patch: 0.197s with this patch: 0.228s Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I2bdddcf616dc72cf0683515c9ab8453bd35eee09
2021-07-28Add support for System Airflow sensorBasheer Ahmed Muddebihal1-0/+1
Added DBUS object path for Airflow sensor to get the system airflow sensor. This fix requires following fix dbus-sensors https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/45241 Tested: Checked redfish/v1/Chassis/<chassis_id>/Sensors/ System_Airflow displayed the correct values. Signed-off-by: Basheer Ahmed Muddebihal <basheerx.muddebihal@intel.com> Change-Id: I32134e659a9fa7a5357fe5928ecebc0fc121c2bc
2021-07-08Automate PrivilegeRegistry to codeEd Tanous1-2/+3
This commit attempts to automate the creation of our privileges structures from the redfish privilege registry. It accomplishes this by updating parse_registries.py to also pull down the privilege registry from DMTF. The script then generates privilege_registry.hpp, which include const defines for all the privilege registry entries in the same format that the Privileges struct accepts. This allows new clients to simply reference the variable to these privilege structures, instead of having to manually (ie error pronely) put the privileges in themselves. This commit updates all the routes. For the moment, override and OEM schemas are not considered. Today we don't have any OEM-specific Redfish routes, so the existing ones inherit their parents schema. Overrides have other issues, and are already incorrect as Redfish defines them. Binary size remains unchanged after this patchset. Tested: Ran redfish service validator Ran test case from f9a6708c4c6490257e2eb6a8c04458f500902476 to ensure that the new privileges constructor didn't cause us to regress the brace construction initializer. Checked binary size with: gzip -c $BBPATH/tmp/work/s7106-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/bin/bmcweb | wc -c 1244048 (tested on previous patchset) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ideede3d5b39d50bffe7fe78a0848bdbc22ac387f
2021-06-16Remove ambiguous privileges constructorEd Tanous1-2/+2
There are a number of endpoints that assume that a given routes privileges are governed by a single set of privileges, instead of multiple sets ORed together. To handle this, there were two overloads of the privileges() method, one that took a vector of Privileges, and one that took an initializer_list of const char*. Unfortunately, this leads some code in AccountService to pick the wrong overload when it's called like this .privileges( {{"ConfigureUsers"}, {"ConfigureManager"}, {"ConfigureSelf"}}) This is supposed to be "User must have ConfigureUsers, or ConfigureManager, or ConfigureSelf". Currently, because it selects the wrong overload, it computes to "User must have ConfigureUsers AND ConfigureManager AND ConfigureSelf. The double braces are supposed to cause this to form a vector of Privileges, but it appears that the initializer list gets consumed, and the single invocation of initializer list is called. Interestingly, trying to put in a privileges overload of intializer_list<initializer_list<const char*>> causes the compilation to fail with an ambiguous call error, which is what I would've expected to see previously in this case, but alas, I'm only a novice when it comes to how the C++ standard works in these edge cases. This is likely due in part to the fact that they were templates of an unused template param (seemingly copied from the previous method) and SFINAE rules around templates. This commit functionally removes one of the privileges overloads, and adds a second set of braces to every privileges call that previously had a single set of braces. Previous code will not compile now, which is IMO a good thing. This likely popped up in the Node class removal, because the Node class explicitly constructs a vector of Privilege objects, ensuing it can hit the right overload Tested: Ran Redfish service validator Tested the specific use case outlined on discord with: Creating a new user with operator privilege: ``` redfishtool -S Always -u root -p 0penBmc -vvvvvvvvv -r 192.168.7.2 AccountService adduser foo mysuperPass1 Operator ``` Then attempting to list accounts: ``` curl -vvvv --insecure --user foo:mysuperPass1 https://192.168.7.2/redfish/v1/AccountService/Accounts/foo ``` Which succeeded and returned the account in question. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I83e62b70e97f56dc57d43b9081f333a02fe85495
2021-06-04Remove checkAndDoSensorsOverride functionBruce Lee1-130/+0
Remove checkAndDoSensorsOverride function, this will be handled via dbus-sensor when the user set-value from external. This is unlikely to break any users because the Intel special mode function is no change, only move to dbus-sensor to handle, "busctl" command also belongs to the external setting, so move to dbus-sensor is more suitable, this will including users to set value use busctl command and Redfish from external. Dbus-sensor needs to be merged at the same time. Dbus-sensor changes are pushed to Gerrit: https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/42453 The mailing list discussion links: https://lists.ozlabs.org/pipermail/openbmc/2021-March/025597.html Signed-off-by: Bruce Lee <Bruce_Lee@quantatw.com> Change-Id: I74356f2b65e41cc0e9d8947c160f313334b78331
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-162/+126
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-20fixed crash in getChassisDataKrzysztof Grobelny1-4/+5
crow::Response was create on stack and passed to async function which was called after crow::Response was deleted Tested: - mentioned issue doesn't produce errors anymore - no additional errors detected Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: I16b338e0f6a4102415b5dca5defc307495db0c8e
2021-04-08Using AsyncResp everywherezhanghch051-84/+100
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
2021-03-29Sync ReadingUnit with Redfish Sensor SchemaWludzik, Jozef1-11/+104
Actual attribute "ReadingUnits" does not match with Redfish Sensor Schema. This change match "ReadingUnits" with Redfish Sensor Scheme 1.0.0 and add missing "ReadingType" attribute. This change affect all users that depends on old units that does not match with Redfish standard. Added toReadingType and toReadingUnit function that uses values taken from Redfish Sensor Scheme 1.0.0. Latest version 1.2.0 of Sensor scheme defines same units. Changed value stored in ReadingUnits for Sensor resource: - "Watts" -> "W" - "Amperes" -> "A" - "Percent" -> "%" Tested: - RedfishServiceValidator pass - Verified that Sensors contain proper ReadingUnits - Webui-Vue displays ReadingUnits properly in Health tab Change-Id: I0c8820eba7271022c427cd25dec321db36aa0176 Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2021-02-24Fix the build on clang-11Ed Tanous1-1/+1
Clang tidy 11 got some really neat checks that do a much better job. Unfortunately, this, combined with the change in how std::executors has defined how callbacks should work differently in the past, which we picked up in 1.73, and now in theory we have recursion in a bunch of our IO loops that we have to break manually. In practice, this is unlikely to matter, as there's almost a 0% chance that we go through N thousand requests without ever starving the IO buffer. Other changes to make this build include: 1. Adding inline on the appropriate places where declared in a header. 2. Removing an Openssl call that did nothing, as the result was immediately overwritten. 3. Declaring the subproject dependencies as system dependencies, which silences the clang-tidy checks for those projects. Tested: Code builds again, clang-tidy passes Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic11b1002408e8ac19a17a955e9477cac6e0d7504
2021-02-23clang-format-11: reformatPatrick Williams1-4/+4
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I0f662e2e6d594567cc10eee34e1df2ca89614870
2021-02-17Replace rfind method in sensors.hppGeorge Liu1-34/+34
Remove the rfind method and use the filename method of sdbusplus::message::Object_path. Tested: Built successfully and validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I762360474b18092987feb64b13f78371db144baa
2020-12-18Fix .clang-tidyEd Tanous1-75/+75
camelLower is not a type, camelBack is. Changes were made automatically with clang-tidy --fix-errors To be able to apply changes automatically, the only way I've found that works was to build the version of clang/clang-tidy that yocto has, and run the fix script within bitbake -c devshell bmcweb. Unfortunately, yocto has clang-tidy 11, which can apparently find a couple extra errors in tests we already had enabled. As such, a couple of those are also included. Tested: Ran clang-tidy-11 and got a clean result. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9d1080b67f0342229c2f267160849445c065ca51
2020-10-23Turn on ALL perf checksEd Tanous1-11/+11
1st, alphabetize the tidy-list for good housekeeping. Next, enable all the clang-tidy performance checks, and resolve all the issues. most of the issues boil down to: 1. Using std::move on const variables. This does nothing. 2. Passing big variables (like std::string) by value. 3. Using double quotes on a find call, which constructs an intermediate string, rather than using the character overload. Tested Loaded on system, logged in successfully and pulled down webui-vue. No new errors. Walked the Redfish tree a bit, and observed no new problems. Ran redfish service validator. Got no new failures (although there are a lot of log service deprecation warnings that we should look at). Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I2238958c4b22c1e554e09a0a1787c744bdbca43e
2020-10-15Lots of performance improvementsEd Tanous1-48/+51
(In the voice of the kid from sixth sense) I see string copies... Apparently there are a lot of places we make unnecessary copies. This fixes all of them. Not sure how to split this up into smaller patches, or if it even needs split up. It seems pretty easy to review to me, because basically every diff is identical. Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369 Signed-off-by: Ed Tanous <ed@tanous.net> Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
2020-10-09Write the clang-tidy file OpenBMC needsEd Tanous1-3/+1
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 unused variable warnings and resolveEd Tanous1-4/+4
This commit enables the "unused variables" warning in clang. Throughout this, it did point out several issues that would've been functional bugs, so I think it was worthwhile. It also cleaned up several unused variable from old constructs that no longer exist. Tested: Built with clang. Code no longer emits warnings. Downloaded bmcweb to system and pulled up the webui, observed webui loads and logs in properly. Change-Id: I51505f4222cc147d6f2b87b14d7e2ac4a74cafa8 Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-17Enable clang warningsEd Tanous1-26/+27
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-08-17Remove middlewaresEd Tanous1-2/+2
Middlewares, while kinda cool from an academic standpoint, make our build times even worse than they already are. Given that we only really use 1 real middleware today (token auth) and it needs to move into the parser mode anyway (for security limiting buffer sizes), we might as well use this as an opportunity to delete some code. Some other things that happen: 1. Persistent data now moves out of the crow namespace 2. App is no longer a template 3. All request_routes implementations no longer become templates. This should be a decent (unmeasured) win on compile times. This commit was part of a commit previously called "various cleanups". This separates ONLY the middleware deletion part of that. Note, this also deletes about 400 lines of hard to understand code. Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a Signed-off-by: Ed Tanous <ed@tanous.net>
2020-07-09Fix -1 issue when fan collection size is 0.Kuiying Wang1-2/+5
When fan collection size is 0, the MinNumNeeded shown -1 (4294967295/0xffffffff) but not 0. "Redundancy": [ { "@odata.id": "/redfish/v1/Chassis/WC_Baseboard/Thermal#/Redundancy/0", "@odata.type": "#Redundancy.v1_3_2.Redundancy", "MemberId": "Tach", "MinNumNeeded": 4294967295, "Mode": "N+m", "Name": "Tach", "RedundancySet": [], "Status": { "Health": "OK", "State": "Enabled" } } Tested: "MinNumNeeded" is 0 correctly. https://bmc_ip/redfish/v1/Chassis/WC_Baseboard/Thermal "Redundancy": [ { "@odata.id": "/redfish/v1/Chassis/WC_Baseboard/Thermal#/Redundancy/0", "@odata.type": "#Redundancy.v1_3_2.Redundancy", "MemberId": "Tach", "MinNumNeeded": 0, "Mode": "N+m", "Name": "Tach", "RedundancySet": [], "Status": { "Health": "OK", "State": "Enabled" } } Change-Id: I8bf01dacd705e5309c161c5f04289d2df45ca583 Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
2020-06-26Enable retrieving mapping of Redfish URI to D-Bus sensor pathAdrian Ambrożewicz1-35/+170
Background: Change is necessary to support TelemetryService implementation. TelemetryService specifies its own resource type for data - MetricDefinition. In principle - MetricDefinition might point to Redfish Sensor in the system. Each MetricDefinition requires MetricProperty - URI to specific property in resource wih the value. This change allows retrieving such data alongside corresponding D-Bus sensor to be used as source of Metrics value. This change: Function was implemented to allow retrieving mapping of Redfish URI paths to D-Bus sensors in the system. Some minor refactoring in regards to SensorsAsyncResponse were also introduced to enhance code locality. Idea for the changes was to be the least intrusive if possible, as retrieving sensors in the system requires lots of processing. Existing logic was used and left intact. Utilizing existing logic required to 'fake' a HTTP request to traverse the sensors in the system and build the response. It's crucial to use exact logic of building Redfish nodes representation, as goal of the function is to retrieve exact Redfish URI for sensor value. Extra parameter was introduced to SensorsAsyncResp - callback to be called when sensor data will be fully determined. After processing is complete caller is notified with the outcome (success or failure) and map<URI:D-Bus sensor>. Testing: - all positive cases (3 chassis, 3 subnodes) in the system, one of obtained mappings looked like the following: { /redfish/v1/Chassis/WP_Baseboard/Power#/Voltages/3/ReadingVolts : /xyz/openbmc_project/sensors/voltage/P1V8_PCH } - negative cases (wrong chassis, wrong subnode) - callback with error status was called - RedfishServiceValidator passed Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com> Change-Id: I4389eb3df275126974168d1bb9af33dbf5cdb5b7
2020-06-11clang-format: update to latest from docs repoGunnar Mills1-3/+3
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-08Add 'utilization' sensor to 'Sensors' pageAdrian Ambrożewicz1-1/+6
Recent change to xyz.openbmc_project.Sensor.Value interface has introduced new type of sensor - 'utilization'. This change makes bmcweb able to expose this kind of sensors in Sensors schema under /Chassis/{}/Sensors. Testing: - implemented simple mocked sensor and verified that: -- sensor appears in /Chassis/{}/Sensors -- sensor values are properly shown in /Chassis/{}/Sensors/{} -- 'ReadingUnits' is shown in /Chassis/{}/Sensors/{} - RedfishServiceValidator passed Change-Id: I9e4dc0b9db049a9815e79a0a64df60f275eeb822 Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
2020-05-14sdbusplus: replace message::variant with std::variantPatrick Williams1-2/+1
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ia5d0845741f1d8d4bc6fd227c6d2e6f3a8d42b2e