Age | Commit message (Collapse) | Author | Files | Lines |
|
C++20 brought us std::ranges for a lot of algorithms. Most of these
conversions were done using comby, similar to:
```
comby -verbose 'std::lower_bound(:[a].begin(),:[b].end(),:[c])' 'std::ranges::lower_bound(:[a], :[c])' $(git ls-files | grep "\.[hc]\(pp\)\?$") -in-place
```
Change-Id: I0c99c04e9368312555c08147d474ca93a5959e8d
Signed-off-by: Ed Tanous <edtanous@google.com>
|
|
There are instances of ERROR logs that would work better as WARNING or
DEBUG since they do not actually result in bailing early and returning
an error response.
Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: I1e7bca0bb38487b26a4642ab72ce475170bb53c6
|
|
std::format is a much more modern logging solution, and gives us a lot
more flexibility, and better compile times when doing logging.
Unfortunately, given its level of compile time checks, it needs to be a
method, instead of the stream style logging we had before. This
requires a pretty substantial change. Fortunately, this change can be
largely automated, via the script included in this commit under
scripts/replace_logs.py. This is to aid people in moving their
patchsets over to the new form in the short period where old patches
will be based on the old logging. The intention is that this script
eventually goes away.
The old style logging (stream based) looked like.
BMCWEB_LOG_DEBUG << "Foo " << foo;
The new equivalent of the above would be:
BMCWEB_LOG_DEBUG("Foo {}", foo);
In the course of doing this, this also cleans up several ignored linter
errors, including macro usage, and array to pointer deconstruction.
Note, This patchset does remove the timestamp from the log message. In
practice, this was duplicated between journald and bmcweb, and there's
no need for both to exist.
One design decision of note is the addition of logPtr. Because the
compiler can't disambiguate between const char* and const MyThing*, it's
necessary to add an explicit cast to void*. This is identical to how
fmt handled it.
Tested: compiled with logging meson_option enabled, and launched bmcweb
Saw the usual logging, similar to what was present before:
```
[Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled
[Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800
[Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist
[Info src/webserver_main.cpp:59] Starting webserver on port 18080
[Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file.
[Info src/webserver_main.cpp:137] Start Hostname Monitor Service...
```
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8
|
|
SetProperty is a method we should use more, and use consistently in the
codebase, this commit makes it consistently used from the utility
namespace.
Tested: Refactor. Code compiles.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I5939317d23483e16bd98a8298f53e75604ef374d
|
|
A number of discussions have occurred, and it's clear that
multi-computer system is not a transition that can be done in a single
series of commits, and needs to be done incrementally over time. This
commit adds the initial option for multi-computer system support, with
an option flag that can be enabled when the new behavior is desired.
This is to prevent needing a long-lived fork.
This option operatates such that if enabled, all ComputerSystem route
options will now return 404. This is to allow the redfish service
validator to pass, and to be used for incremental development. As the
routes are moved over, they will be enabled, and service validator
re-run.
Per the description in the meson options, this option flag, and all code
beneath of it will be removed on 9/1/23. The expectation is that by
this date, given the appropriate level of effort in implementation,
there will be no code remaining under that option flag. After this
date, code beneath this option flag will be removed.
Tested: No functional changes without option.
With option enabled, /redfish/v1/Systems produces no entries.
Spot check of various routes returns 404.
Redfish service validator passes.
Change-Id: I3b58642cb76d61df668076c2e0f1e7bed110ae25
Signed-off-by: Ed Tanous <ed@tanous.net>
|
|
Since the getManagedObjects method has been implemented in
dbus_utility and this commit is to integrate all the places where the
GetManagedObjects method is obtained, and use the method in
dbus_utility uniformly.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ic13f2bef7b30f805cd3444a75d7df17b031f2eb0
|
|
Similar to other patches, make propertyValueFormatError accept a
nlohmann::json object, which removes a lot of the unsafe dump code that
we have littered about.
Tested: No easy to replicate error. Code is identical to previous
patchsets. Inspection and code compilation only.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic9d0f196b6e198073189f744b738db7ffa2f1b74
|
|
The error codes for this function accept a string_view, which has caused
a number of cases of users of this function to call dump() to_string()
and all manner of other conversions. Considering that dump() is
something that's difficult to call correctly, and overly wordy, it would
be ideal if the message code just handled that for us.
Therefore, this commit changes the prototype to include a nlohmann::json
object as an argument instead of string_view, then audits the codebase
for all uses, and moves them to a more normalized usage, which allows
the calling code to call "dump" for them.
Tested: PATCH /redfish/v1/SessionService {"SessionTimeout": 1}
Returns the PropertyValueNotInList error as it did before.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If62909072db1f067ad1f8aa590bb716c84181219
|
|
In about half of our code, AsyncResp objects take the name asyncResp,
and in the other half they take the name aResp. While the difference
between them is negligeble and arbitrary, having two naming conventions
makes it more difficult to do automated changes over time via grep.
This commit was generated automtatically with the command:
git grep -l 'aResp' | xargs sed -i 's|aResp|asyncResp|g'
Tested: Code compiles.
Change-Id: Id363437b6a78f51e91cbf60aa0a0c2286f36a037
Signed-off-by: Ed Tanous <edtanous@google.com>
|
|
The Health populate calls GetManagedObjects at `/` which can take a lot
of time. Add the option to disable to improve performance if it is not
needed.
Tested:
```
$ meson build -Dhealth-populate=disabled
...
User defined options
backend : ninja
health-populate : disabled
```
Build passed.
Health Status removed. Some resource still create HealthPopulate, but
does not populate. It will require further refactoring to clean it out.
Testing on `/redfish/v1/Chassis?$expand=.($levels=1)`
On 14 chassis, from about 2.5 seconds to 400 ms. :)
Before:
```
Getting times for chassis
Getting good line count with wget -q -O- localhost:80/redfish/v1/Chassis?$expand=.($levels=1)
Line count: 980
17:05:56: real 0m2.908s user 0m0.000s sys 0m0.030s
17:05:59: real 0m2.414s user 0m0.010s sys 0m0.010s
17:05:03: real 0m3.410s user 0m0.000s sys 0m0.020s
17:05:09: real 0m2.372s user 0m0.000s sys 0m0.010s
17:05:13: real 0m3.407s user 0m0.010s sys 0m0.000s
17:05:19: real 0m2.420s user 0m0.010s sys 0m0.000s
17:05:23: real 0m3.463s user 0m0.010s sys 0m0.000s
17:05:29: real 0m2.414s user 0m0.000s sys 0m0.010s
17:05:33: real 0m2.843s user 0m0.010s sys 0m0.010s
17:05:38: real 0m2.512s user 0m0.000s sys 0m0.020s
17:05:42: real 0m2.474s user 0m0.000s sys 0m0.010s
17:05:47: real 0m2.557s user 0m0.010s sys 0m0.010s
17:05:52: real 0m2.439s user 0m0.020s sys 0m0.000s
17:05:56: real 0m3.127s user 0m0.010s sys 0m0.000s
17:05:01: real 0m2.563s user 0m0.020s sys 0m0.000s
17:05:06: real 0m2.392s user 0m0.020s sys 0m0.020s
17:05:10: real 0m2.405s user 0m0.020s sys 0m0.000s
17:05:15: real 0m2.514s user 0m0.010s sys 0m0.010s
17:05:19: real 0m2.809s user 0m0.020s sys 0m0.010s
17:05:24: real 0m2.944s user 0m0.010s sys 0m0.010s
17:05:29: real 0m2.537s user 0m0.010s sys 0m0.000s
17:05:34: real 0m3.290s user 0m0.000s sys 0m0.000s
17:05:39: real 0m2.601s user 0m0.040s sys 0m0.000s
17:05:43: real 0m2.398s user 0m0.010s sys 0m0.040s
17:05:48: real 0m2.664s user 0m0.000s sys 0m0.020s
17:05:53: real 0m2.323s user 0m0.010s sys 0m0.000s
17:05:57: real 0m3.033s user 0m0.000s sys 0m0.010s
17:05:02: real 0m3.243s user 0m0.000s sys 0m0.010s
17:05:07: real 0m2.604s user 0m0.010s sys 0m0.010s
17:05:12: real 0m2.813s user 0m0.010s sys 0m0.010s
17:05:17: real 0m2.325s user 0m0.020s sys 0m0.000s
17:05:21: real 0m2.577s user 0m0.010s sys 0m0.000s
17:05:26: real 0m2.882s user 0m0.030s sys 0m0.000s
17:05:31: real 0m2.572s user 0m0.000s sys 0m0.020s
17:05:35: real 0m2.678s user 0m0.010s sys 0m0.010s
17:05:40: real 0m2.656s user 0m0.010s sys 0m0.010s
17:05:45: real 0m2.921s user 0m0.020s sys 0m0.000s
17:05:49: real 0m2.723s user 0m0.000s sys 0m0.020s
17:05:54: real 0m2.910s user 0m0.010s sys 0m0.010s
17:05:59: real 0m2.601s user 0m0.020s sys 0m0.000s
17:05:04: real 0m2.615s user 0m0.000s sys 0m0.000s
```
After:
```
Getting times for chassis
Getting good line count with wget -q -O- localhost:80/redfish/v1/Chassis?$expand=.($levels=1)
Line count: 980
16:04:43: real 0m0.188s user 0m0.020s sys 0m0.000s
16:04:43: real 0m0.195s user 0m0.010s sys 0m0.000s
16:04:45: real 0m0.219s user 0m0.010s sys 0m0.000s
16:04:48: real 0m0.226s user 0m0.020s sys 0m0.000s
16:04:50: real 0m0.208s user 0m0.020s sys 0m0.010s
16:04:52: real 0m0.226s user 0m0.010s sys 0m0.010s
16:04:54: real 0m0.419s user 0m0.000s sys 0m0.010s
16:04:57: real 0m0.222s user 0m0.010s sys 0m0.020s
16:04:59: real 0m0.194s user 0m0.000s sys 0m0.010s
16:04:01: real 0m0.191s user 0m0.010s sys 0m0.010s
16:04:04: real 0m0.276s user 0m0.010s sys 0m0.020s
16:04:06: real 0m0.183s user 0m0.020s sys 0m0.000s
16:04:08: real 0m0.193s user 0m0.040s sys 0m0.000s
16:04:10: real 0m0.406s user 0m0.020s sys 0m0.010s
16:04:13: real 0m0.317s user 0m0.000s sys 0m0.000s
16:04:15: real 0m0.442s user 0m0.005s sys 0m0.005s
16:04:18: real 0m0.226s user 0m0.010s sys 0m0.000s
16:04:20: real 0m0.217s user 0m0.020s sys 0m0.000s
16:04:22: real 0m0.200s user 0m0.010s sys 0m0.030s
16:04:24: real 0m0.423s user 0m0.010s sys 0m0.010s
16:04:27: real 0m0.203s user 0m0.020s sys 0m0.010s
16:04:29: real 0m0.433s user 0m0.000s sys 0m0.000s
16:04:31: real 0m0.318s user 0m0.020s sys 0m0.000s
16:04:34: real 0m1.206s user 0m0.000s sys 0m0.010s
16:04:37: real 0m0.403s user 0m0.000s sys 0m0.020s
16:04:39: real 0m0.353s user 0m0.010s sys 0m0.000s
16:04:42: real 0m0.291s user 0m0.000s sys 0m0.030s
16:04:44: real 0m0.742s user 0m0.020s sys 0m0.010s
16:04:47: real 0m0.369s user 0m0.010s sys 0m0.000s
16:04:49: real 0m0.215s user 0m0.020s sys 0m0.000s
16:04:52: real 0m0.204s user 0m0.000s sys 0m0.010s
16:04:54: real 0m0.418s user 0m0.000s sys 0m0.000s
16:04:56: real 0m0.215s user 0m0.000s sys 0m0.010s
16:04:58: real 0m0.202s user 0m0.010s sys 0m0.010s
16:04:01: real 0m0.202s user 0m0.010s sys 0m0.010s
16:04:03: real 0m0.212s user 0m0.010s sys 0m0.000s
16:04:05: real 0m0.694s user 0m0.010s sys 0m0.010s
16:04:08: real 0m0.201s user 0m0.010s sys 0m0.010s
16:04:10: real 0m0.230s user 0m0.000s sys 0m0.020s
16:04:12: real 0m0.206s user 0m0.010s sys 0m0.010s
16:04:15: real 0m0.446s user 0m0.010s sys 0m0.010s
```
Change-Id: I90b242e2cd24973420de871fedf9793dd1e310f3
Signed-off-by: Willy Tu <wltu@google.com>
|
|
The bmc now supports the Quiesced state, which is tracked using systemd
targets. Previously, the bmc startup state was determined by systemd
alone. The old systemd startup behavior is retained, but if the bmc is
found to be started, this commit also check the quiesced target to
determine if we should set that state as well. This allows
phosphor-state-manager users to have a state that works for the quiesced
use case, while avoiding race conditions on startup, or having to impose
a hard dependency on phosphor-state-manager, which we know some users
do not use. The reasons for not using phosphor-state-manager are
outside of the scope of this commit.
In comparison to the alternative:
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/50318
This actually seems to have a smaller diff, so while there's some
concern about adding complexity to bmcweb, this seems like this patch
gets us the same behavior with slightly less code.
Tested: Loaded onto a p10bmc and see this new state.
systemctl start obmc-bmc-service-quiesce@0.target
root@xxx:~# obmcutil state
CurrentBMCState : xyz.openbmc_project.State.BMC.BMCState.Quiesced
curl -k https://$bmc/redfish/v1/Managers/bmc
...
"Status": {
"Health": "Critical",
"State": "Quiesced"
},
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I718b8ad0a43327051cb5fdf0da59a1ccfbde9940
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
|
|
nlohmann::json::clear() has different behavior dependent on what the
underlying object is, rather than doing the expected behavior of
completely clearing the json object. This didn't matter because of a
similar bug in http_connection that relied on nlohmann:json::empty()
which is ALSO type dependent, so these worked.
Unfortunately, in 02e01b5108d46720a0b438c0d79952464320d954 we wanted to
allow empty objects, and this bug was exposed.
There are two places where clear() is used, once in Response, which is
clearly not the intent, which is to reset the object to the original
constructed state. The other place we call clear is in Manager, where
we use it to clear incremental results. That was a previous best practice that has been eliminated everywhere else (now we return as
many results with the error as we are able). It has been removed.
Tested: Logging into the webui in firefox no longer core dumps.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic89a037b30fb40c0e6eaeb939cae6e006dd0ffac
|
|
Boost 1.82 dropped a lovely new toy, boost::urls::format, which is a lot
like our urlFromPieces method, but better in that it makes the resulting
uris more readable, and allows doing things like fragments in a single
line instead of multiple. We should prefer it in some cases.
Tested:
Redfish service validator passes.
Spot checks of URLs work as expected.
Unit tests pass.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia7b38f0a95771c862507e7d5b4aa68aa1c98403c
|
|
It seems like clang-tidy doesn't catch every place that an emplace could
be used instead of a push. Use a few grep/sed pairs to find and fix up
some common patterns.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I93eaec26b8e3be240599e92b66cf54947073dc4c
|
|
The clang-tidy warning 'modernize-use-emplace' correctly flags a
few places where emplace should be used over push.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I6ca79285a87d6927e718345dc8dce0387e6b1eda
|
|
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: I75f89d2959b0f1338c20d72ad669fbdc1d720835
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
|
|
Notice a bug of patching existed object if the object name contains
space or underscore.
Normally dbus replace space with underscore for object path.
Replacing all spaces in input name with underscore to find the correct
dbus object path.
Tested results:
- Add new object
Input JSON
```
{
"Oem": {
"OpenBmc": {
"Fan": {
"StepwiseControllers": {
"Test_1": {
"Direction": "Floor",
"Inputs": [
"MB_U402_THERM_LOCAL"
],
"NegativeHysteresis": 0.0,
"PositiveHysteresis": 0.0,
"Steps": [
{
"Output": 0.0,
"Target": 48.0
},
{
"Output": 40.0,
"Target": 52.0
}
],
"Zones": [
{
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0"
}
]
}
}
}
}
}
}
```
Check result from /redfish/v1/Managers/bmc
```
"Test_1": {
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/Test_1",
"@odata.type": "#OemManager.StepwiseController",
"Direction": "Floor",
"Inputs": [
"MB U402 THERM LOCAL"
],
"NegativeHysteresis": 0.0,
"PositiveHysteresis": 0.0,
"Steps": [
{
"Output": 0.0,
"Target": 48.0
},
{
"Output": 40.0,
"Target": 52.0
}
],
"Zones": [
{
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0"
}
]
}
```
- Patching existed object successful
Input JSON
```
{
"Oem": {
"OpenBmc": {
"Fan": {
"StepwiseControllers": {
"Test_1": {
"NegativeHysteresis": 0.0,
"PositiveHysteresis": 5.0,
}
}
}
}
}
}
```
Check result from /redfish/v1/Managers/bmc
```
"Test_1": {
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/Test_1",
"@odata.type": "#OemManager.StepwiseController",
"Direction": "Floor",
"Inputs": [
"MB U402 THERM LOCAL"
],
"NegativeHysteresis": 0.0,
"PositiveHysteresis": 5.0,
"Steps": [
{
"Output": 0.0,
"Target": 48.0
},
{
"Output": 40.0,
"Target": 52.0
}
],
"Zones": [
{
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0"
}
]
}
```
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I12c78e52801bd0814ba2d928cf020e0a04214c39
|
|
Currently code search for underscore and replace space in the
dbus object path , which construct invalid object path.This
Patch construct proper dbus object path by replacing space
with underscore.
Tested:
Verified that object path is created in proper format.
Change-Id: Ibdf18c13ce30aa007f165e1ccfe7f68e86d50c32
Signed-off-by: Yaswanth Reddy M <yaswanthx.reddy.munukuru@intel.com>
|
|
nlohmann::json::dump() calls are very wordy, have a lot of code to them,
and have some odd usages in exception safety (that are documented in
COMMON_ERRORS.md). Therefore, we should minimize how many places we
call it.
This file dumped the json values to the console for logging, which no
other handler does, and if we want, we have generic ways to do it.
readJson these days has quite a bit of built-in logging that should
cover all of these cases for debug.
Remove the logging, and make managers take on the style of the other
code around it.
Tested: Debug logging deletes only. Code compiles
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I019dd0549d65e4698e2cee863d9815ca7ddae5a2
|
|
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
|
|
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>
|
|
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>
|
|
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
|
|
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
|
|
This function is something that's easily unit tested. Do it.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8d664c77ec4b3a9886128597449c5f9c041b86b3
|
|
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
|
|
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
|
|
Only set createNewObject to true when corresponding interface not found
in the object.
Tested on Bletchley:
- Add new StepwiseController called SWTest
Body in JSON format
```
{
"Oem": {
"OpenBmc": {
"Fan": {
"StepwiseControllers": {
"SWTest": {
"Direction": "Floor",
"Inputs": [
"MB_U402_THERM_LOCAL"
],
"NegativeHysteresis": 1.0,
"PositiveHysteresis": 2.0,
"Steps": [
{
"Output": 0.0,
"Target": 48.0
},
{
"Output": 15.0,
"Target": 49.0
}
],
"Zones": [
{
"@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0"
}
]
}
}
}
}
}
}
```
Checking object from dbus
```
root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \
> /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \
> xyz.openbmc_project.Configuration.Stepwise
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Delete method - - -
.Class property s "Floor" emits-change writable
.Inputs property as 1 "MB U402 THERM LOCAL" emits-change writable
.Name property s "SWTest" emits-change writable
.NegativeHysteresis property d 1 emits-change writable
.Output property ad 2 0 15 emits-change writable
.PositiveHysteresis property d 2 emits-change writable
.Reading property ad 2 48 49 emits-change writable
.Type property s "Stepwise" emits-change writable
.Zones property as 1 "Zone0" emits-change writable
```
- Patch SWTest properties
Body in JSON format
```
{
"Oem": {
"OpenBmc": {
"Fan": {
"StepwiseControllers": {
"SWTest": {
"NegativeHysteresis": 3.0,
"PositiveHysteresis": 4.0
}
}
}
}
}
}
```
Checking object from dbus
```
root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \
> /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \
> xyz.openbmc_project.Configuration.Stepwise
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Delete method - - -
.Class property s "Floor" emits-change writable
.Inputs property as 1 "MB U402 THERM LOCAL" emits-change writable
.Name property s "SWTest" emits-change writable
.NegativeHysteresis property d 3 emits-change writable
.Output property ad 2 0 15 emits-change writable
.PositiveHysteresis property d 4 emits-change writable
.Reading property ad 2 48 49 emits-change writable
.Type property s "Stepwise" emits-change writable
.Zones property as 1 "Zone0" emits-change writable
```
- Delete SWTest object
Body in JSON format
```
{
"Oem": {
"OpenBmc": {
"Fan": {
"StepwiseControllers": {
"SWTest": null
}
}
}
}
}
```
Object deleted from dbus
```
root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \
> /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \
> xyz.openbmc_project.Configuration.Stepwise
Failed to introspect object /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest of service xyz.openbmc_project.EntityManager: Unknown object '/xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest'.
```
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I482e942ee3c76dca17af522765d8b3aa9dc8678b
|
|
EntityManager moves its ObjectManager in commit [1], this patch is to
change accordingly. Please see [1] for why we made that change.
[1] https://gerrit.openbmc.org/c/openbmc/entity-manager/+/57279
Tested: code compiles.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Idf5657463d54022f53d12e860483d06b5c5c7ccd
|
|
There's a few last places (outside of tests) where we still use
nlohmann brace initialization. Per the transforms we've been doing,
move these to constructing the objects explicitly, using operator[],
nlohmann::object_t and nlohmann::array_t. Theses were found by manual
inspection grepping for all uses of nlohmann::json.
This is done to reduce binary size and reduce the number of intermediate
objects being constructed. This commit saves a trivial amount of size
(~4KB, Half a percent of total) and in addition but makes our
construction consistent.
Tested:
Redfish service validator passes.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I7478479a9fdc41b254eef325002d413c1fb411a0
|
|
The newest version of clang detects this as an exception thrown in a
destructor. To solve this, this commit moves the returned data to a
struct, and loads it backs into io::service::post().
Tested:
Not sure I know how to test this, and this code was checked in prior to
tested statements being required.
Change-Id: Ieef32e43d89043fe99fbbf46cceb794b08db8b13
Signed-off-by: Ed Tanous <edtanous@google.com>
|
|
It looks like one of the patchset merge conflicts got rebased poorly (ie
commented out). In the meantime, a number of these structures have gone
from map->vector, so modify the algorithm to account for that.
Tested:
1. Redfish validator - passed with this change.
2. Verified from Redfish by patching "StepwiseControllers" sensors.
Signed-off-by: Ed Tanous <edtanous@google.com>
Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: I89d36f1b0b3699b6bf07a17af029e5a2504c85de
|
|
We've accumulated several time utility functions in the http classes.
Time isn't a core HTTP primitive, so http is not where those functions
below.
This commit moves all the time functions from the crow::utility
namespace into the redfish::time_utils namespace, as well as moves the
unit tests.
No code changes where made to the individual functions, with the
exception of changing the namespace on the unit tests.
Tested: Unit tests pass.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8493375f60aea31899c84ae703e0f71a17dbdb73
|
|
used sdbusplus::unpackPropertiesNoThrow in managers.hpp, also replaced
all usages of "GetAll" with sdbusplus::asio::getAllProperties
bmcweb size: 2677080 -> 2672984 (-4096)
compressed size: 1128633 -> 1128611 (-22)
Tested:
Performed get on:
- /redfish/v1/Managers
- /redfish/v1/Managers/bmc
Get result before and after the change was the same
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: If1a0227eda106361ed9dda74a5f13ada3ef07d69
|
|
IBM doesn't use the Redfish OEM fan data in OemManager.
IBM does not use phosphor-pid-control instead using
phosphor-fan-presence and such.
This is data such as PidControllers, StepwiseControllers, FanZones,
FanControllers, and Profile.
This has been in bmcweb since Oct 2018 so defaulting this flag to
enabled to not break anyone.
Why we want a flag:
1) Have observed 500 errors with getting the thermalMode.
"Jan 24 16:34:57 rain534 bmcweb[435]: (2022-01-24 16:34:57) [ERROR
"managers.hpp":1196] GetPIDValues: Can't get thermalModeIface
/xyz/openbmc_project/control/thermal/0"
2) This Redfish OEM fan data includes PATCHing.
Commit turning this off in meta-ibm:
https://gerrit.openbmc.org/c/openbmc/openbmc/+/56327
Tested: With this flag enabled and disabled.
Manager resource looks as expected.
Before on a dummy PATCH to this:
curl -k -X PATCH https://$bmc/redfish/v1/Managers/bmc -d \
'{"Oem":{"OpenBmc":{"Fan":{"Profile":"Acoustic"}}}}'
{
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The request failed due to an internal service...
With this change and the meta-ibm change (instead see a PropertyUnknown)
curl -k -X PATCH https://$bmc/redfish/v1/Managers/bmc -d \
'{"Oem":{"OpenBmc":{"Fan":{"Profile" : "Acoustic"} }}}'
{
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The property %1 is not in the list of valid...
"MessageArgs": [
"Oem"
],
"MessageId": "Base.1.13.0.PropertyUnknown",
PATCHed the DateTime with this enabled.
Change-Id: I374292ca2798e096b18d49df5bbc7a93c7f1c400
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
|
|
Per our coding standard, we should be using std namespace methods for
these things when both a boost one and a std one exist. Update the
code.
Tested: Code compiles. I don't think we have great examples of the
usages of these APIs.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I35cfa25c4f8038ba8d9e3dbe337b5b3d72c64144
|
|
This change adds a link in the Manager for all BMCs to an empty
ManagerDiagnosticData resource and a minimum ManagerDiagnosticData
handler.
This service is backed by phosphor-health-monitor (PHM), which is
enabled by default through the "obmc-apps" package group. If PHM is
disabled, the resource will be empty.
$ curl http://${bmc}:10080/redfish/v1/Managers/bmc/ManagerDiagnosticData
{
"@odata.id": "/redfish/v1/Managers/bmc/ManagerDiagnosticData",
"@odata.type": "#ManagerDiagnosticData.v1_0_0.ManagerDiagnosticData",
"Id": "ManagerDiagnosticData",
"Name": "Manager Diagnostic Data"
}
Also ran the Redfish Service Validator to make sure no new errors are
introduced with the introduction of ManagerDiagnosticData.
Signed-off-by: Sui Chen <suichen@google.com>
Change-Id: Iba242bc3b6ebec851dbd26e149d5c92c19a7992e
|
|
cppcheck correctly notes that a lot of variables in the new code can be
const. Make most of them const.
Tested: WIP
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8f37b6353fd707923f533e1d61c5b5419282bf23
|
|
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
|
|
This patchset is the conclusion of a multi-year effort to try to fix
shadowed variable names. Variables seem to be shadowed all over, and in
most places they exist, there's a "code smell" of things that aren't
doing what the author intended.
This commit attempts to clean up these in several ways by:
1. Renaming variables where appropriate.
2. Preferring to refer to member variables directly when operating
within a class
3. Rearranging code so that pass through variables are handled in the
calling scope, rather than passing them through.
These patterns are applied throughout the codebase, to the point where
-Wshadow can be enabled in meson.build.
Tested: Code compiles, unit tests pass. Still need to run redfish
service validator.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If703398c2282f9e096ca2694fd94515de36a098b
|
|
Rename to Software so we can reuse it for software inventory. This make
is more consistent to the SoftwareVersion dbus interface that is used.
Change-Id: I97fb10fccf744a6d6d4cba57f970759431bf4744
Signed-off-by: Willy Tu <wltu@google.com>
|
|
For Redfish Aggregation, we need a common point to check the D-Bus
for satellite configs. If they are available then we perform the
aggregation operations. The functions in query.hpp are used by all
endpoints making them the logical location. The aggregation code
requires a shared_ptr to the AsyncResp so these functions need to be
able to supply that.
This patch is broken out of a future patch for routing Redfish
Aggregation requests
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/53310
The follow commands can be used to perform most of the replacements:
find . -type f | xargs sed -i 's/setUpRedfishRoute(app, req, asyncResp->res/setUpRedfishRoute(app, req, asyncResp/g'
find . -type f | xargs sed -i 's/setUpRedfishRouteWithDelegation(app, req, asyncResp->res/setUpRedfishRouteWithDelegation(app, req, asyncResp/g'
Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: I4f4f9f22cdcfb14a3bd94b9a8f3d64aae34e57bc
|
|
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
|
|
Brace initialization of json objects, while quite interesting from an
academic sense, are very difficult for people to grok, and lead to
inconsistencies. This patchset aims to remove a majority of them in
lieu of operator[]. Interestingly, this saves about 1% of the binary
size of bmcweb.
This also has an added benefit that as a design pattern, we're never
constructing a new object, then moving it into place, we're always
adding to the existing object, which in the future _could_ make things
like OEM schemas or properties easier, as there's no case where we're
completely replacing the response object.
Tested:
Ran redfish service validator. No new failures.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
|
|
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
|
|
This saves about 4k on the binary size
Tested: Redfish service validator passes.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I9546227a19c691b1aecb80e80307889548c0293f
|
|
In the upcoming fmt patch, we remove the use of streams, and a number of
our logging statements are relying on them. This commit changes them to
no longer rely on operator>> or operator+ to build their strings. This
alone isn't very useful, but in the context of the next patch makes the
automation able to do a complete conversion of all log statements
automatically.
Tested: enabled logging on local and saw log statements print to console
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I0e5dc2cf015c6924037e38d547535eda8175a6a1
|
|
using std::string_view on these lets us call them in more contexts, and
allows us to inline some previously more complex code. In general, for
APIs like this, std::string_view should be preferred as it gives more
flexibility in calling conventions.
Tested:
curl --insecure "https://localhost:18080/redfish/v1/AccountService/Roles/foobar" ✔
{
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The requested resource of type Role named 'foobar' was not found.",
"MessageArgs": [
"Role",
"foobar"
],
"MessageId": "Base.1.11.0.ResourceNotFound",
"MessageSeverity": "Critical",
"Resolution": "Provide a valid resource identifier and resubmit the request."
}
],
"code": "Base.1.11.0.ResourceNotFound",
"message": "The requested resource of type Role named 'foobar' was not found."
}
}
This is the same response as previously.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8ee17120c42d2a13677648c3395aa4f9ec2bd51a
|
|
There are a number of places where we use message registry messages
incorrectly. This patchset attempts to fix them, and invoke some type
safety when they're used such that they're more obvious to use.
Namely, it changes a number of the message registry methods to accept a
boost::urls::url_view for its argument instead of a const std::string&.
This forces the calling code to correctly encode a URL to use the
method, which should make it obvious that it's not for an ID, a property
name, or anything else. In the course of doing this, several places
were found to be using the first argument incorrectly.
Tested:
curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Chassis/foobar
Returns:
{
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The requested resource of type #Chassis.v1_16_0.Chassis named foobar was not found.",
"MessageArgs": [
"#Chassis.v1_16_0.Chassis",
"foobar"
],
"MessageId": "Base.1.8.1.ResourceNotFound",
"MessageSeverity": "Critical",
"Resolution": "Provide a valid resource identifier and resubmit the request."
}
],
"code": "Base.1.8.1.ResourceNotFound",
"message": "The requested resource of type #Chassis.v1_16_0.Chassis named foobar was not found."
}
Identically to previously.
Also tested with IDs that contained % encoded characters, like
foobar%10, which gave the same result.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Icbb3bce5d190a260610087c9ef35e7becc5a50c7
|
|
Added support for readJson for Patch and Action. The only difference is
that Patch does not allow empty json input while Action does. Action with
empty input will use the default value based on the implementation and
return 200 OK response code.
readJsonPatch will replace the existing readJson and be used for path
requests. It will not allow empty json input and all requested
keys are required in the json input.
readJsonAction will be used for Action requests where it is possible for
all of the properties to be optional and allow empty request.
The optional properties are determined by the requested values type.
All current Action readJson are replaced with readJsonAction. It does
not change the existing behavior since it needs `std::optional`.
This will have to be updated later as we define the default behavior.
Tested:
Added unit tests and readJsonAction allows empty empty json object.
No Change to Redfish Tree.
Change-Id: Ia5e1f81695c528a20f1dc985aee19c920d8adaea
Signed-off-by: Willy Tu <wltu@google.com>
|