summaryrefslogtreecommitdiff
path: root/redfish-core/lib/hypervisor_system.hpp
AgeCommit message (Collapse)AuthorFilesLines
2025-02-04clang-format: update latest spec and reformatPatrick Williams1-26/+26
Copy the latest format file from the docs repository and apply. Change-Id: I2f0b9d0fb6e01ed36a2f34c750ba52de3b6d15d1 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2025-01-31Fix includesEd Tanous1-2/+16
Clang-tidy misc-include-cleaner appears to now be enforcing significantly more headers than previously. That is overall a good thing, but forces us to fix some issues. This commit is largely just taking the clang-recommended fixes and checking them in. Subsequent patches will fix the more unique issues. Note, that a number of new ignores are added into the .clang-tidy file. These can be cleaned up over time as they're understood. The majority are places where boost includes a impl/x.hpp and x.hpp, but expects you to use the later. include-cleaner opts for the impl, but it isn't clear why. Change-Id: Id3fdd7ee6df6c33b2fd35626898523048dd51bfb Signed-off-by: Ed Tanous <etanous@nvidia.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2025-01-20Use SPDX identifiersEd Tanous1-0/+2
SPDX identifiers are simpler, and reduce the amount of cruft we have in code files. They are recommended by linux foundation, and therefore we should do as they allow. This patchset does not intend to modify any intent on any existing copyrights or licenses, only to standardize their inclusion. [1] https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects Change-Id: I935c7c0156caa78fc368c929cebd0f068031e830 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-17Move getProperty calls to utilityEd Tanous1-2/+2
Having all dbus calls run through the same utility reduces the amount of generated code, and more importantly, gives us a place where we can log the requests and responses to help with debugging. Tested: Redfish service validator passes. Change-Id: Ic1bf45130b5069cd57f7af26e12c8d3159c87c67 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-10-14Format readjsonMyung Bae1-7/+13
clang-format may potentially reformat the readJson calls if they may have more keys or key names are longer. This makes formatting in a way that's readable by forcing to break a line for each key using an empty-comment (`//`) each line. It also allows trivially alphabetizing the list such that new additions are less likely to have merge conflicts. Tested: - Check whitespace only. - Code compiles. - Redfish Service Validator with the same results before this Change-Id: I3824a8c4faa9fa7c820d5d2fab6b565404926e2c Signed-off-by: Ed Tanous <etanous@nvidia.com> Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2024-09-03Hypervisor: Fix redfish validator errorsAsmitha Karunanithi1-19/+2
Currently, Redfish validator fails for displaying empty mac address when doing a GET on hypervisor ethernet interfaces. This commit ensures that the redfish validator passes by making the macaddress an optional property in EthernetInterfaceData structure and removing the un-implemented "MACAddress" interface check in the hypervisor GET handler method. The following was the validator error: [1] ERROR - MACAddress: String '' does not match pattern ''^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'' Tested By: Validator Passed. Change-Id: Ib3f8085841093647ee97dee5602a0bb78fdd67c5 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
2024-08-21Fix 404 on Hypervisor ResetGunnar Mills1-11/+1
/redfish/v1/Systems/hypervisor/Actions/ComputerSystem.Reset was returning a 404. On closer inspection, it was due to hitting the System .Reset Action and not making it to the Hypervisor specific action. [1]. Remove the Hypervisor specific action and call the method from the System .Reset Action. This is how we do the handleHypervisorSystemGet already. Believe this was broke by 7f3e84a151. [2] It is only now being discovered due to a recent rebase with upstream. Follow the commit before and put this behind the new Hypervisor Computer System Option. [1]: https://github.com/openbmc/bmcweb/blob/cd504a94c827fbc98908b2a712f49ea0adf7aab8/redfish-core/lib/systems.hpp#L3493 [2]: https://github.com/openbmc/bmcweb/commit/7f3e84a151e106d9227d08358e9ee3fd225b34c4 Tested: On Patchset 2, /redfish/v1/Systems/hypervisor/Actions/ComputerSystem.Reset returns a 204. Change-Id: I3599bb8419604d71684ce61ca992f4b87c1d3fa5 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-08-21Add a Hypervisor Computer System OptionGunnar Mills1-36/+18
Today to determine if the hypervisor computer system resource should be added to the System Collection a call to the Settings Manager is made. Based on discussion in https://gerrit.openbmc.org/c/openbmc/bmcweb/+/73203 and to help the multihost stuff move forward, lets move this hypervisor under a meson option which any company that needs can enable. I think IBM is the only one who uses this so the risk of breaking someone should be small. One day hope to converge at some point, this probably doesn't happen until after the multihost stuff goes in. This is also better for implementations that don't have this backend because now routes like /redfish/v1/Systems/hypervisor/EthernetInterfaces/ aren't put out. I.e. a call to /redfish/v1/Systems/hypervisor/EthernetInterfaces/ is now going to return 404 instead of 500 on systems without this backend support. Tested: Enabled this and see the hypervisor system. Without this enabled do not see the hypervisor system. No new validator errors either way. Change-Id: Ie05e6644dd6f640cf8225f96becb99b9c2d0de20 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-08-17clang-format: re-format for clang-18Patrick Williams1-286/+298
clang-format-18 isn't compatible with the clang-format-17 output, so we need to reformat the code with the latest version. The way clang-18 handles lambda formatting also changed, so we have made changes to the organization default style format to better handle lambda formatting. See I5e08687e696dd240402a2780158664b7113def0e for updated style. See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement. Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2024-08-02Consistently use generated enumerationsEd Tanous1-14/+26
This commit causes all of Redfish to use generated enum values for enum types. Using generated code prevents problems, and makes it more clear what types are allowed. Doing this found two places where we had structs that didn't fulfill the schema. They have been commented, but will be fixed with a breaking change at some point in the future. Tested: WIP Change-Id: I5fdd2f2dfb6ec05606a522e1f4e331f982c8e476 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-06-27Pass redfishPropertyName earlier argumentGinu George1-24/+24
It was pointed out that the setDbusProperty method should have an end that approximately matches dbus-send and busctl set-property in its arguments, to aid with debug. This seems reasonable. Tested: Redfish service validator passes. Change-Id: Ic20295d93c71c957e3e76704e1eda9da187861b1 Signed-off-by: Ginu George <ginugeorge@ami.com> Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-21Allow configuring "bmc" and "system"Ed Tanous1-1/+2
In the early days of bmcweb, we made two pretty critical assumptions; First, is that a given platform would only have a single BMC instance (represented as "bmc") and a single host instance (represented as "system"). Second we assumed that, given that Redfish suggests against hardcoding URIs in client implementation and leaves them freeform, clients would code to the standard. Our own webui-vue hardcodes Redfish URIs [1], and the documentation is littered with examples of hardcoded curl examples of hardcoding these URIs. That bug was filed in 2020, and the issue has only gotten worse over time. This patchset is an attempt to give a target that we can start solving these issues, without trying to boil the ocean and fix all clients in parallel. This commit adds the meson options redfish-manager-uri-name and redfish-system-uri-name These are used to control the "name" that bmcweb places in the fixed locations in the ManagerCollection and ComputerSystemCollection schemas. Note, managers is added, but is not currently testable. It will be iterated on over time. Tested: Changed the URL options to "edsbmc" and "edssystem" in meson options. Redfish service validator passes. URLs appear changed when walking the tree. [1] https://github.com/openbmc/webui-vue/issues/43 Change-Id: I4b44685067051512bd065da8c2e3db68ae5ce23a Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-09Move to Redfish Action specific setProperty callAsmitha Karunanithi1-26/+6
This commit will migrate all the setProperty calls initiated by a redfish"Action" to "setDbusProperty" method in Redfish namespace that handles all DBuserrors in a consistent manner. This method will determine if a setProperty is called during redfish "Action" or just setting of a dbus property and internally call appropriate methods that handles different set of errors. All the Redfish action specific errors are defined in error_messages.hpp file. This specific change moves setProperty call in hypervisor_system.hpp and covers errors in the mentioned file only. Tested-By: <Yet to test this usecase> Change-Id: I3da48fbeabcdcf088c4481021232f08a44797c86 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-07Fix moves/forwardEd Tanous1-1/+1
Clang has new checks for std::move/std::forward correctness, which catches quite a few "wrong" things where we were making copies of callback handlers. Unfortunately, the lambda syntax of callback{std::forward<Callback>(callback)} in a capture confuses it, so change usages to callback = std::forward<Callback>(callback) to be consistent. Tested: Redfish service validator passes. Change-Id: I7a111ec00cf78ecb7d5f5b102c786c1c14d74384 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-04Clean up hypervisor to use readJsonEd Tanous1-116/+69
Use multiple level direct read. Tested: Visual only. Need help if anyone wants to test. Change-Id: Ifcf716a2ba93fd565bbf134d4132532e60e3b4f0 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-01hypervisor: Move to setProperty dbus util methodAsmitha Karunanithi1-81/+39
This commit changes sdbusplus setProperty calls in hypervisor_system.hpp file to "setDbusProperty" method in Redfish namespace that handles all DBus errors in a consistent manner. Change-Id: Iebca5eb4e28159d61cd4b13c0343b78efd0f1f39 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
2023-10-24clang-format: copy latest and re-formatPatrick Williams1-41/+40
clang-format-17 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: I2f9540cf0d545a2da4d6289fc87b754f684bc9a7 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-07-20Replace logging with std::formatEd Tanous1-31/+31
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
2023-06-28Rename all error_code instances to ecEd Tanous1-4/+4
We're not consistent here, which leads to people copying and pasting code all over, which has lead to a bunch of different names for error codes. This commit changes to coerce them all to "ec", because that's what boost uses for a naming convention. Tested: Rename only, code compiles. Change-Id: I7053cc738faa9f7a82f55fc46fc78618bdf702a5 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-28Refactor setProperty methodGeorge Liu1-63/+45
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
2023-06-20Refactor getManagedObjects methodGeorge Liu1-4/+4
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
2023-06-13Make propertyValueFormatError more typesafeEd Tanous1-10/+4
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
2023-06-13Make propertyValueTypeError more typesafeEd Tanous1-6/+3
Similar to the prior patchset in this series, propertyValueTypeError can be moved to safer constructs. This ensures that we are minimizing how many places we are calling dump() from, and allows us to reduce the amount of code written for error handling. Tested: PATCH /redfish/v1/SessionService {"SessionTimeout": "foo"} Returns PropertyValueTypeError in the same behavior as prior to this patch. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iddff4b787f35c49bf923663d61bba156687f358c
2023-06-09Consistently name AsyncResp variablesEd Tanous1-36/+36
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>
2023-06-08ethernet: Bump EthernetInterface schema 1.6.0 -> 1.9.0Jiaqing Zhao1-1/+1
After removing all usages of VLanNetworkInterface that deprecated in EthernetInterface 1.7.0, time to bump it to 1.9.0 for implementing the new API design. Tested: Redfish validator passed. Change-Id: Ia89d56a1325918c23ce54c9b8c0dde4342e32764 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2023-05-17Remove flat_set from EthernetInterfacesEd Tanous1-20/+14
None of these are actually used as a set, we should avoid taking the overhead of using these as a set. Tested in next commit. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7a7f2c9761a2adc70f6c6ab127facc9d801a2209
2023-05-16Boost::urls::formatEd Tanous1-6/+5
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
2023-05-12fix more push vs emplace callsPatrick Williams1-2/+2
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
2023-05-12use emplace where appropriate per clang-tidyPatrick Williams1-3/+3
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
2023-05-11clang-format: copy latest and re-formatPatrick Williams1-2/+2
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>
2023-03-11Update hypervisor todoGunnar Mills1-5/+0
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/61237/3 merged. hypervisor is no longer in its own namespace. Tested: None. Change-Id: I3dc3e01a0c3bcfd9a00a060f04505a6bc70860e6 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-03-11Fix hypervisor system GetAsmitha Karunanithi1-24/+0
The reason for this change is that there are two routes defined: [1] /redfish/v1/Systems/<str> in systems.hpp [2] /redfish/v1/Systems/hypervisor in hypervisor_system.hpp Whenever a user does a get on /redfish/v1/Systems/hypervisor, the first route is hit and that checks if <str> is "system" and if not, bmcweb returns resource not found error. ``` Error: ERROR - Members: GET of resource at URI /redfish/v1/Systems/hypervisor returned HTTP error. Check URI. ERROR - URI did not return resource /redfish/v1/Systems/hypervisor GET Failure HTTP Code (404) ``` The below upstream commit is causing this issue: [1] openbmc/bmcweb@22d268c#diff-cddfc26fddb6ba29f3fd81ecf5840fc6d9a8554bbca92f578d81b97db8b14895 To resolve this issue, an if hypervisor is inserted in the /redfish/v1/Systems/<str> and that calls handleHypervisorSystemGet. The /redfish/v1/Systems/hypervisor in redfish-core/lib/hypervisor_system.hpp is removed. Also fix /redfish/v1/Systems/hypervisor/ResetActionInfo/. Redfish validator passed. redfish/v1/Systems/hypervisor looks good. /redfish/v1/Systems/hypervisor/ResetActionInfo/ looks good. Change-Id: Ie2d9d19c258236ce86d6552ae4a3bd486e02de01 Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-03-09Move hypervisor system to separate methodGunnar Mills1-41/+43
Similar to the code we've been building elsewhere, move Hypervisor system to a separate method, and avoid lambdas. Tested: Code compiles. Tested as part of top patch. Change-Id: Iac49b1d2e216bf785aa0b0aced6d169457ef5a3c Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-03-09Move hypervisor ethernet to separate methodsGunnar Mills1-193/+198
Similar to the code we've been building elsewhere, move ethernet Hypervisor to separate methods, and avoid lambdas. Tested: Code compiles. Tested as part of top patch. Change-Id: I3f49b3824c212a9b1e8129b99265ed7a470b3e18 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-03-09Move hypervisor reset to separate methodsGunnar Mills1-120/+127
Similar to the code we've been building elsewhere, move Reset Hypervisor to separate methods, and avoid lambdas. Tested: Code compiles. Tested as part of top patch. Change-Id: I19ee473908fac42e69985d406c34cdd6da44c2c6 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-03-08Remove the redfish hypervisor namespaceEd Tanous1-6/+6
This namespace was created due to some conflicts between these two namespaces. This commit renames the function that's overloaded and removes the namespace, along with the TODO. Tested: No access to hypervisor to test. Inspection only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib94fc23571660fdb74ca90c58f7ab729bced544f
2023-02-24Take boost error_code by referenceEd Tanous1-11/+11
By convention, we should be following boost here, and passing error_code by reference, not by value. This makes our code consistent, and removes the need for a copy in some cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id42ea4a90b6685a84818b87d1506c11256b3b9ae
2023-02-23Update most resources to use urlFromPiecesWilly Tu1-3/+5
Only id in event_service and account_service have not been updated due to the risk of it breaking the username/id. It will require further testing to verify. Use urlFromPieces wherever that is needed to insert a variable in the URI. Don't use urlFromPieces when it is hardcoded values. This allow us to control all resource URIs that is dynamically added and to sync with the current recommanded method for `@odata.id`. The goal is to have a common place to manage the url created from dbus-paths in order to manage/update it easily when needed. Tested: RedfishValidtor Passed for all resource including the sensors with the fragments. Change-Id: I95cdfaaee58fc7f21c95f5944e1e5c813b3215f2 Signed-off-by: Willy Tu <wltu@google.com> Signed-off-by: Ed Tanous <edtanous@google.com>
2023-01-19Add the GetObject method to dbus_utilityGeorge Liu1-16/+12
There are currently many files that use the GetObject method. Since they are a general method, they are defined in the dbus_utility.hpp file and refactors them. Tested: Built bmcweb successfully and Validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: If2af77294389b023b611987252ee6149906fcd25
2023-01-18Fix a boatload of #includesEd Tanous1-6/+7
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/+8
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-3/+2
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-09-12Remove nlohmann brace initializationEd Tanous1-5/+6
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
2022-09-09ethernet: Bump EthernetInterface schema 1.4.1 -> 1.6.0Jiaqing Zhao1-1/+1
EthernetInterface v1.6.0 adds EthernetInterfaceType property indicating the type (either Physical or Virtual) of an interface. This property will be used by the incoming change #53186 which exposes VLAN interface as EthernetInterface. Since the "VLANs" property deprecated from v1.7.0 is still needed for creating/deleting VLAN interfaces, bmcweb won't bump to a newer schema version until Redfish spec defines a better way for it. Tested: Redfish validator passed. Change-Id: I9e005e10b0b38046a2a222264b01c6e6223ebf31 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-09-02Move ipv4VerifyIpAndGetBitcount into ip_utilsEd Tanous1-3/+6
This is a minor reorganization of helper code from ethernet (which is redfish specific) into utils. This function is generic, and should be in ip utils. Tested: Code compiles. Code move only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4aac5a98379c9844aea6c21d2294d1ed7ae2ea9b
2022-06-15Expose AsyncResp shared_ptr when handling responseCarson Labrado1-6/+6
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
2022-06-01Try to fix the lambda formatting issueEd Tanous1-459/+438
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-13Remove brace initialization of json objectsEd Tanous1-65/+75
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
2022-04-15ethernet: Fix naming conventionsJiaqing Zhao1-10/+10
Some variable names in ethernet.hpp does not match naming conventions, fix'em all. Tested: Only variable name changes, build pass. Change-Id: If275a77364e5ed827a5088342f44548274b059e1 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-04-06Add setUpRedfishRoute to all nodes in redfishEd Tanous1-27/+53
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