summaryrefslogtreecommitdiff
path: root/meson.build
AgeCommit message (Collapse)AuthorFilesLines
7 daysAdd extra subscription params supportEd Tanous1-0/+1
OriginResource allows filtering messages on a per-device basis. This was already listed as supported in our docs. RegistryPrefixes is also added. Tested: Unit tests pass. Change-Id: Idfde8416f2f466ce11957177e052b540fc669888 Signed-off-by: Ed Tanous <etanous@nvidia.com>
10 daysRe-eenable boost conceptsEd Tanous1-1/+0
We disabled this to fight some old boost bugs around the initial run of concepts. Between new compilers and new boost these seem solved, so re-enable the concepts. Tested: Unit tests pass. Has coverage of asio. Change-Id: Ib430bff53635acecaf184ab2eadd8cde3900a19b Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-14Reorganize gtestEd Tanous1-21/+21
Currently, gtest is included as a source library. This means that every test application compiles its own version of gtest. This is wasteful, even though it's likely not that expensive compared to other compile time things. Move gtest into a library, upgrade our version of gtest at the same time. Tested: unit tests pass Change-Id: I5064848bd42d6b119a8d4aa9bcac13ad8ec65955 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-05Break out post codesEd Tanous1-1/+2
Similar to other patches, break out the post codes log services into their own file. log_services.hpp is far too large. Change-Id: I3cb644d52a9d3b5f9a15a2f90c1b69c87491e5c8 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-04meson: switch code dependency to libsystemdPatrick Williams1-2/+3
For a while now systemd has packaged a separate `libsystemd`. For meson dependency, `systemd` should be used when looking for systemd service file paths and `libsystemd` should be used for `sd_*` functions. Update the dependency accordingly. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ie797742655ef9af8c93edd279cc162b842a711a2
2024-08-26Reformat meson files with meson formatEd Tanous1-44/+46
Meson recently got a new format command in 1.5.0 [1]. It makes slightly different formatting decisions compared to muon (what we used previously) but given it's the official tool, we should switch to it. There is one bug resolved recently that requires this format be done using the meson from master. Ideally this would be enforced by CI in the future, but that's WIP. Tested: Whitespace only, code compiles. [1] https://mesonbuild.com/Commands.html#format [2] https://github.com/mesonbuild/meson/commit/df706807239095ddbbfd2975b3fe067ad6b5d535 Change-Id: I91506efb659c431e913c717d8a26aa349fccbd75 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-08-23Enable bmcweb dynamic loggingAushim Nagarkatti1-11/+40
Create a CLI app called "bmcweb" that can set logging levels on "bmcwebd", the new bmcweb daemon. Create a dbus connection to set log level using the CLI app Define the "setLogLevel" method on dbus to control logging level in bmcwebd Add logic to move logging level from build option to dynamic overloading Reason: bmcweb picks up logging level as a compile flag. We want it to be more flexible to debug errors in the field. Using the bmcweb CLI app, we can set log levels on the bmcweb daemon during runtime. Splitting bmcweb. For example, to set logging level to INFO on the target: bmcweb -l INFO Change-Id: I7192e4d0ac7aa3a91babecc473521be27ea8acd1 Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
2024-08-23Update to boost 1.86.0Ed Tanous1-0/+2
Update to Boost 1.86.0 Note, there are some internal dependencies that don't pass -Wunused checks. Presumably they'll be fixed in 1.86.1, but no reason to hold off upgrading now. Note, this is the version we'll pick up in the next yocto update. Tested: Code compiles Change-Id: I3a178dc6fc77e9c7e84343257afe238b99a8058e Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-08-22build: upgrade to C++23Patrick Williams1-3/+3
Meson 1.1.1 and GCC-13 both support C++23 and a sufficient portion of the standard has been implemented. Upgrade the build to leverage it. Change-Id: Ica48aad491c506716c74dc74921664188ccf85e2 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2024-08-22Sensors: Create utility class for sensorsJanet Adkins1-1/+1
Create a separate utility class for sensors. The goal is to make these functions easily available for use outside of sensors for paths which need reference sensors. Moved splitSensorNameAndType() into new utility class. Created new utility function getSensorId(). The Id for a sensor is built from its name and type in a few different locations. These are modified to call the new function. The function has also been simplified to use std::format() to build the Id. Tested: - Checked before and after results for queries using this function: (Note: I was not able to confirm the setSensorsOverride() caller as it is only being used for redfish-allow-deprecated-power-thermal URI.) ''' - https://${bmc}/redfish/v1/Chassis/chassis/Sensors - https://${bmc}/redfish/v1/Chassis/chassis/Sensors/<str> where <str> was sensors of different types - https://${bmc}/redfish/v1/Chassis/chassis/Sensors?\$expand=* - https://${bmc}/redfish/v1/Chassis/chassis/ThermalSubsystem/Fans - https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies ''' - Redfish Validator passed Change-Id: Ifa200b6e63f8e52d47f70c33d350999f5c527bbd Signed-off-by: Janet Adkins <janeta@us.ibm.com>
2024-07-30Break out SSL key handler into a compile unitEd Tanous1-3/+3
This commit allows for no code to have to pull in openssl headers directly. All openssl code is now included in compile units, or transitively from boost. Because http2 is optional, no-unneeded-internal-declaration is needed to prevent clang from marking the functions as unused. Chromium has disabled this as well[1] Tested: Redfish service validator passes. [1] https://issues.chromium.org/issues/40340369 Change-Id: I327e8ffa45941c2282db804d0be56cf64155e67d Signed-off-by: Ed Tanous <ed@tanous.net>
2024-07-30Add SSE filter param supportEd Tanous1-21/+17
The Redfish spec require filtering of SSE entries to be supported. This commit rearranges the code, and implements SSE sorting as well as support for Last-Event-Id. To do this it adds a dependency on boost circular_buffer. Tested: SSE connections succeed. Show filtered results. Change-Id: I7aeb266fc40471519674c7b65cd5cc4625019e68 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-07-23Make journal log efficientEd Tanous1-0/+2
Journal logging currently loops over all entries to find even a single entry. This was reasonable at the time when bmc couldn't really store a lot, but now that BMCs are getting significantly more flash storage, this simplification is insufficient. In an example system with an AST2600, this API takes 32 seconds to respond. This is mediocre for obvious reasons. This commit updates to use the sd_journal APIs to let journald do the skipping, which can use internal details and can be a lot more efficient. To get the total size, bmcweb still needs to pull the sequenceids of HEAD and TAIL to determine the complete size, but this is still reasonable. Tested: Redfish service validator passes. Various versions of top and skip return the correct result, pulling various top sizes from 0, omitted to the limit. https://gerrit.openbmc.org/c/openbmc/openbmc-tools/+/72975 To test all corner cases. Change-Id: I0456bca4e037529f70eaee0bdd9191e9d5839226 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-07-12Make schemas selectableEd Tanous1-2/+2
Which schemas are installed should be selectable in both a meson config, and trivially by forks. This commit gets us closer to that idea. It does it in several ways, first, the code for generating JsonSchemaFile resources has been changed to be generated at runtime, based on files on disk. This is slightly slower, but allows installing schemas from anywhere, and matches the CSDL handling. Next, the schema folders are separated into two sets csdl -> This includes the complete schema pack from dmtf installed -> this includes only the schemas the bmc includes Similar folders exist for json-schema and json-schema-installed. This allows any additional schemas to be a single symlink addition. Note, this also checks in all of the dmtf json schemas, not just the versions we use. This allows us to update the schema pack without needing to break our versions we ship. Because the static files are now selectable, all files need to be in a folder. This forces the css and image for the redfish built-in gui to be moved. Tested: /redfish/v1/JsonSchemas returns the correct result /redfish/v1/JsonSchemas/UpdateService returns a JsonSchemaFile instance /redfish/v1/JsonSchemas/UpdateService/UpdateService<version>json returns the JsonSchemaFile contents. Redfish service validator passes. Change-Id: Ie96b2e4b623788dc2ec94eb40fcfd80325f0d826 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-07-01Add filter parameter supportEd Tanous1-0/+3
$filter is a parameter documented in the Redfish specification, section 7.3.4. It defines a mechanism for filtering arbitrary collections of parameters based on a set of arbitrary language expressions. From the specification, it supports the following language operators: () Precedence grouping operator. (Status/State eq 'Enabled' and Status/Health eq 'OK') or SystemType eq 'Physical' and Logical and operator. ProcessorSummary/Count eq 2 and MemorySummary/TotalSystemMemoryGiB gt 64 eq Equal comparison operator. ProcessorSummary/Count eq 2 ge Greater than or equal to comparison operator. ProcessorSummary/Count ge 2 gt Great than comparison operator. ProcessorSummary/Count gt 2 le Less than or equal to comparison operator MemorySummary/TotalSystemMemoryGiB le 64 lt Less than comparison operator. MemorySummary/TotalSystemMemoryGiB lt 64 ne Not equal comparison operator. SystemType ne 'Physical' not Logical negation operator. not (ProcessorSummary/Count eq 2) or Logical or operator. ProcessorSummary/Count eq 2 or ProcessorSummary/Count eq 4 Support for these operators have been added in previous commits. This commit enables them behind the insecure-enable-redfish-query meson option. This is an arbitrary language, so the likelihood there's some improper implementation in the patch is high. This gives folks the ability to test it. Tested: Lots of unit tests included in this patch. Functionally tested the basic operators: ``` GET /redfish/v1/Managers/bmc/LogServices/Journal/Entries?\$filter=EntryType+eq+'Oem' GET /redfish/v1/Managers/bmc/LogServices/Journal/Entries?\$filter=EntryType+ne+'Oem' ``` Function as expected, producing multiple results or no results respectively. GET /redfish/v1 reports "FilterQuery": true Redfish service validator passes. Change-Id: Id568acc5dcfce868af12da5ee16c4f0caae8060a Signed-off-by: Ed Tanous <ed@tanous.net>
2024-07-01Filter Expression parserEd Tanous1-1/+7
This commit implements a parser for $filter expressions, per the redfish specification and odata specification. This is intended to be used to support $filter query for collections. For parsing libraries, this commit chooses boost spirit x3. It's chosen because it doesn't require a new external dependency, and is done entirely in the compiler, using C++ syntax. While the syntax is still somewhat difficult to read, there's a slew of unit tests included to make sure that at least the common things we expect to work will parse correctly. Tested: Unit tests pass (good coverage). Code not yet used. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1b0ab615bc49064acab4dad47f0a8aa499557bfc
2024-06-28meson_options.txt -> meson.optionsEd Tanous1-1/+1
The new format for this file seems to be meson.options. Move to it. Update the minimum meson version to 1.3. 1.1 is the minimum required for meson.options, but we already have warnings about features in 1.3, so might as well go straight there. Tested: Code compiles Change-Id: Id42643d4aeb680032754158e061ddbf1c9658477 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-06-10Make cert generate for readonly directoriesEd Tanous1-0/+1
When run from a development PC, we shouldn't REQUIRE that the cert directory exists or is writable. This commit reworks the SSL cert generation to generate a string with the certification info, instead of writing it to disk and reading it back. This allows bmcweb to start up in read-only environments, or environments where there isn't access to the key information. Tested: Launching the application on a dev desktop without an ssl directory present no longer crashes. Change-Id: I0d44eb1ce8d298986c5560803ca2d72958d3707c Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-28Generate metadata at runtimeEd Tanous1-0/+1
In the initial implementation of metadata indexing the bmc knew at compile time what schemas it could potentially publish. bmcweb took the approach of adding all schemas of all versions to the $metadata resource. Since that was made, two major changes have happened. First, Redfish has added significantly more versions of each schema, as well as significantly more schemas to the point where the metadata index is now 213KB. While this file compresses fairly well, the size is obvious from the large amount of time that redfish service validator takes to parse the schemas, compared to actually acquiring BMC redfish resources. Second, aggregation was added, where an aggregated Redfish service might implement any number of schemas, including OEM ones. In an effort to fix this, this patch takes the compile-time algorithm in update_schemas.py, and moves it into bmcweb itself, parsing the files on disk as needed on demand. This has some immediate benefits; First, is that now schemas can be potentially installed from anywhere, not only from within the bmcweb build, and they will be resolved at runtime. Second, patches that want to add support for a given schema need to only symlink the schema into the correct folder, without needing to rerun update_schemas.py. This saves time in review. Finally, this opens to door to reducing the schema versions present in the metadata to the unique set of only what this bmcweb instance, and its aggregated BMCs expose. Tested: Redfish service validator passes. Need A/B checking to verify the file is byte for byte the same. GET /redfish/v1/$metadata returns what looks like sane results, with a correct content-type. Unit tests require the use of TemporaryFileHandle, so that class is moved into a more general folder, outside of test/http. Change-Id: I326159099c6b6c4056023b2e173c5f074ed88ce1 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-28Add symlinks to folderEd Tanous1-1/+1
Now that we have the schemas moved, add symlinks back to the schemas that we use, so that they will be installed correctly. The meson option of follow_symlinks: true is added to suppress a warning about potential change in behavior in meson in the future. Change-Id: Ie24536ca04038d8137818c201d9411b95361b14f Signed-off-by: Ed Tanous <ed@tanous.net>
2024-05-01Bring consistency to config optionsEd Tanous1-88/+1
The configuration options that exist in bmcweb are an amalgimation of CROW options, CMAKE options using #define, pre-bmcweb ifdef mechanisms and meson options using a config file. This history has led to a lot of different ways to configure code in the codebase itself, which has led to problems, and issues in consistency. ifdef options do no compile time checking of code not within the branch. This is good when you have optional dependencies, but not great when you're trying to ensure both options compile. This commit moves all internal configuration options to: 1. A namespace called bmcweb 2. A naming scheme matching the meson option. hyphens are replaced with underscores, and the option is uppercased. This consistent transform allows matching up option keys with their code counterparts, without naming changes. 3. All options are bool true = enabled, and any options with _ENABLED or _DISABLED postfixes have those postfixes removed. (note, there are still some options with disable in the name, those are left as-is) 4. All options are now constexpr booleans, without an explicit compare. To accomplish this, unfortunately an option list in config/meson.build is required, given that meson doesn't provide a way to dump all options, as is a manual entry in bmcweb_config.h.in, in addition to the meson_options. This obsoletes the map in the main meson.build, which helps some of the complexity. Now that we've done this, we have some rules that will be documented. 1. Runtime behavior changes should be added as a constexpr bool to bmcweb_config.h 2. Options that require optionally pulling in a dependency shall use an ifdef, defined in the primary meson.build. (note, there are no options that currently meet this class, but it's included for completeness.) Note, that this consolidation means that at configure time, all options are printed. This is a good thing and allows direct comparison of configs in log files. Tested: Code compiles Server boots, and shows options configured in the default build. (HTTPS, log level, etc) Change-Id: I94e79a56bcdc01755036e4e7278c7e69e25809ce Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-30Consolidate Vm implementationsEd Tanous1-1/+0
As much as the two vm implementations SEEM different, the differences largely lie in how we're getting the nbd proxy socket. One is relying on launching a process (nbd-proxy), the other is getting the fd from dbus. Given [1] exists and is in process, we need to have a plan for getting these two VM implementations into one, once that patchset is complete. This commit: Splits the vm-websocket option into vm-websocket-provider, providing two options, nbd-proxy, and virtual-media (the names of the respective apps). To accomplish this, it moves the contents of nbd-proxy into include/vm-websocket, so we can compare the similarities and start consolidating. The longer term intent is that the nbd-proxy option will be completely removed, and the code deleted. This has the additional advantage that we will no longer require the boost::process dependency, as all info will be available on dbus. As part of this, the nbd proxy websocket is also registered at /vm/0/0, to be backward compatible with the old interfaces. Tested: Code compiles. Need some help here. [1] https://gerrit.openbmc.org/c/openbmc/jsnbd/+/49944 Change-Id: Iedbca169ea40d45a8775f843792b874a248bb594 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-18Update nghttp2 1.60->1.61Ed Tanous1-2/+7
They seem to have gotten rid of the nghttp2_static target, so go back to relying on the "normal" target. Change-Id: Ic44d9ffe5fa2d88f38c018756738197371b0dc89 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-18Remove ibm locks featureSunitha Harish1-1/+0
This feature was introduced to manage the operation sync at BMC while multiple clients manage the BMC. This feature scope has gone away and it is not a simple code to maintain as per the growing standards of bmcweb. This commit removes the feature from this repo. Tested by: Locks routes are not available anymore Change-Id: I257225cfb1f43d7d5dadb21a28a2ee5345c5112a Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-17Reformat meson filesEd Tanous1-335/+360
Meson has a style guide, we should follow it. This includes: 4 space indents on new scopes. Trailing commas on the final entry in a list/array Tested: Whitespace only. Code compiles. Change-Id: Ib7f96a2bd722b55410818c766c0261f5d44cb84d Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-16Remove OpenSSL warnings ignoreEd Tanous1-5/+0
If we include OpenSSL in extern "C" blocks consistently, c++ warnings no longer appear. This means we can remove the special case from meson. Tested: Code compiles when built locally on an ubuntu 22.04 system. Change-Id: I5add4113b32cd88b7fdd874174c845425a7c287a Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-10Move run and redfish to compile unitsEd Tanous1-1/+6
Meson supports unity builds[1] natively. There's no reason to continue with the pseudo unity build we've been using by putting implementations in header files. This commit is the first in a long series of starting to break this up into smaller compile units, in the hopes of dropping incremental compile times for developers, and reduce the total per-core memory usage that gcc requires. This commit breaks out the run() function from main() and the constructor of RedfishService from redfish.hpp into their own compile units. According to tracing, even after broken out, these are still by far the two longest to compile units in the build. Tested: Code compiles. Debug build on a 24 core build server results in a decrease in compile time for compiling just bmcweb from 1m38s to 1m22s. [1] https://mesonbuild.com/Unity-builds.html Change-Id: Ibf352e8aba61d64c9a41a7a76e94ab3b5a0dde4b Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-03meson: Disable tests build for tinyxml2 dependencyKonstantin Aladyshev1-0/+1
Currently local meson build breaks on tinyxml2 since the code from this package produces a warning and all warnings are treated as errors: """ ../subprojects/tinyxml2-9.0.0/xmltest.cpp:711:38: error: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] """ The warning above comes from the compilation of the tinyxml2 unit tests. Since we don't really need them, disable 'tests' option for tinyxml2 dependency to fix the meson build. Tested: Locally executed "meson setup build && cd build && meson compile" now finishes successfully. Change-Id: I7148856a3eebbda22d03c9715955b6ab78a933fe Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
2024-04-01Make boost/nghttp2 cmake build static librariesEd Tanous1-2/+4
When running compiling from local dependencies, it's nice to be able to move binaries around wherever they're needed. When we moved to the cmake version of boost, we started building shared libraries on accident. nghttp2 has always pulled shared libraries since introduction. Go back to building static libraries. Tested: Binary build from desktop launches directly without a "missing boost_url.so" error. Change-Id: I9858f27f21841097bd03a6bbcac953b08caa4b14 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-01Use no-switch-default on clangEd Tanous1-0/+1
clang-18 improves this check so that we can actually use it. Enable it and fix all violations. Change-Id: Ibe4ce19c423d447a4cbe593d1abba948362426af Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-28Create Redfish specific setProperty callEd Tanous1-0/+2
There are currently 78 sdbusplus::asio::setProperty calls in redfish-core. The error handler for nearly all of them looks something like: ``` if (ec) { const sd_bus_error* dbusError = msg.get_error(); if ((dbusError != nullptr) && (dbusError->name == std::string_view( "xyz.openbmc_project.Common.Error.InvalidArgument"))) { BMCWEB_LOG_WARNING("DBUS response error: {}", ec); messages::propertyValueIncorrect(asyncResp->res, "<PropertyName>", <PropertyValue>); return; } messages::internalError(asyncResp->res); return; } messages::success(asyncResp->res); ``` In some cases there are more errors handled that translate to more error messages, but the vast majority only handle InvalidArgument. Many of these, like the ones in account_service.hpp, do the error handling in a lambda, which causes readability problems. This commit starts to make things more consistent, and easier for trivial property sets. This commit invents a setDbusProperty method in the redfish namespace that tries to handle all DBus errors in a consistent manner. Looking for input on whether this will work before changing over the other 73 calls. Overall this is less code, fewer inline lambdas, and defaults that should work for MOST use cases of calling an OpenBMC daemon, and fall back to more generic errors when calling a "normal" dbus daemon. As part of this, I've ported over several examples. Some things that might be up in the air: 1. Do we always return 204 no_content on property sets? Today there's a mix of 200, with a Base::Success message, and 204, with an empty body. 2. Do all DBus response codes map to the same error? A majority are covered by xyz.openbmc_project.Common.Error.InvalidArgument, but there are likely differences. If we allow any daemon to return any return code, does that cause compatibility problems later? Tested: ``` curl -k --user "root:0penBmc" -H "Content-Type: application/json" -X PATCH -d '{"HostName":"openbmc@#"}' https://192.168.7.2/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 ``` Returns the appropriate error in the response Base.1.16.0.PropertyValueIncorrect Change-Id: If033a1112ba516792c9386c997d090c8f9094f3a Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-25Require specific compiler versionsEd Tanous1-32/+26
Quite often do I compile this project, and see an error message that makes no sense. Multiple times I've seen posted about compiler errors that amount to using an old version of clang or gcc. Explicitly require clang-17 and gcc-13 in the meson config, and give better errors if they're not present. This also allows simplifying our warning flags (which probably need a review soon) by making two sets of flags, one for each compiler. Note, clang has the -Weverything flag, which we use, so explicitly enabling warnings isn't really required, only disabling the ones that we don't use. Tested: Code compiles. Change-Id: I09fa74e6d36feaf05710a4bb7d266f80ff1cc592 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-21Allow no spaces in content-typeEd Tanous1-0/+1
For the content type header application/json;charset=utf-8 The Redfish specification DSP0266 shows no space between the ; and charset. Sites like mozilla show the space included [1] Considering the discrepancy, we should just accept both. Resolves #271 [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type Tested: Submitter reports issue fixed. Change-Id: I77b7db91d65acc84f2221ec50985d4b942fbe77f Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-19Rename FileBody to HttpBodyEd Tanous1-1/+1
Now that our custom body type does things more than files, it makes sense to rename it. This commit renames the header itself, then all instances of the class. Tested: Basic GET requests succeed. Change-Id: If4361ac8992fc7c268f48a336707f96e68d3576c Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-18Add unit test for SSEEd Tanous1-0/+1
Writing this test exposed some bugs in SSE that got merged. sendSSEHeader was never called, leading to a connection that starts and immediately closes with no error code. This issue has been corrected in code, such that the sockets start. To allow for unit tests, the io_service needs to be passed into the class, previously, the SSE connection was pulling the io_context from the DBus connection, which is odd, given that the SSE connection has no other dependencies on DBus. Unit tests should help keep it working. Tested: Unit tests pass. Change-Id: I48080d2a94b6349989f556cd1c7b103bad498526 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-16Update boost 1.83->1.84Ed Tanous1-1/+1
This is the same version yocto uses. Tested: Code compiles Change-Id: I3bf7be18ecd0e5863ab8afd57748f918837ba5a3 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-04AllowedHostTransitions: look for on dbusAndrew Geissler1-0/+1
Commit [1] introduced a new optional dbus property that OpenBMC developers can populate to define which redfish/v1/Systems/system/ResetActionInfo AllowableValues are. Look for that new property on dbus. If not found, hard code the previous values otherwise utilize the property to fill in the return value. Tested: - Put new property on dbus and confirmed Redfish API returned expected values: ``` curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system/ResetActionInfo { "@odata.id": "/redfish/v1/Systems/system/ResetActionInfo", "@odata.type": "#ActionInfo.v1_1_2.ActionInfo", "Id": "ResetActionInfo", "Name": "Reset Action Info", "Parameters": [ { "AllowableValues": [ "ForceOff", "PowerCycle", "Nmi", "On", "ForceOn", "ForceRestart", "GracefulRestart", "GracefulShutdown" ], "DataType": "String", "Name": "ResetType", "Required": true } ] } ``` - Did not run redfish validator as response was same as previous [1]: https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/68933 Change-Id: Iecece14e7ff55db98d96df71b106ecc9e3f0ac33 Signed-off-by: Andrew Geissler <geissonator@yahoo.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2024-02-23manager_diagnostic_data: add metric getJagpal Singh Gill1-0/+1
Add support to fetch MemoryStatistics, FreeStorageSpaceKiB and ProcessorStatistics for Manager Diagnostic Data. https://redfish.dmtf.org/schemas/v1/ManagerDiagnosticData.v1_2_1.json This change is in relation to following design and D-Bus interface - https://gerrit.openbmc.org/c/openbmc/docs/+/64917 https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/64914 Test: Redfish query output - { "@odata.id": "/redfish/v1/Managers/bmc/ManagerDiagnosticData", "@odata.type": "#ManagerDiagnosticData.v1_2_0.ManagerDiagnosticData", "FreeStorageSpaceKiB": 3772, "Id": "ManagerDiagnosticData", "MemoryStatistics": { "AvailableBytes": 354224066, "BuffersAndCacheBytes": 78984633, "SharedBytes": 11876066, "TotalBytes": 425516000 }, "Name": "Manager Diagnostic Data", "ProcessorStatistics": { "KernelPercent": 13.0234, "UserPercent": 5.7374 }, "ServiceRootUptimeSeconds": 2255.117 } Redfish service validator passing - Elapsed time: 0:03:12 metadataNamespaces: 3726 pass: 5133 passAction: 9 passGet: 205 passRedfishUri: 197 skipNoSchema: 3 skipOptional: 3492 warnDeprecated: 4 warningPresent: 7 Validation has succeeded. Change-Id: I43758a993eb7f342cb9ac5f5574498b37261c2cc Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
2024-02-16Write unit tests for http2 connectionEd Tanous1-0/+1
This unit test currently only tests a simple connect and settings frame transfer, but should form the basis for more complex testing in the future. Tested: Unit tests pass Change-Id: Ieb803dbe490129ec5fe99fb3d4505a06202e282e Signed-off-by: Ed Tanous <ed@tanous.net>
2024-02-16Add unit tests for file bodyEd Tanous1-1/+2
File body needs some unit tests for managing the move constructors. Tested: Unit tests pass. Change-Id: Ia640aec75a6f3f85640a50f5dd492638871f9eca Signed-off-by: Ed Tanous <ed@tanous.net>
2024-01-19Clean up tftp update to use URLEd Tanous1-0/+1
Similar to transforms we've done elsewhere, we shouldn't be parsing urls using std::string::find, regex, or anything else, as they don't handle URL % encoding properly. Change-Id: I48bb30c0c737c4df2ae73f40fc49c63bac5b658f Signed-off-by: Ed Tanous <edtanous@google.com>
2023-12-12Use MonotonicTimeStamp for bmc log idMyung Bae1-0/+1
/redfish/v1/Managers/bmc/LogServices/Journal/Entries gives the system journal entries whose ID is based on the realtime timestmap. However, the system realtime may go backward if the system time is changed either manually or via NTP. If that happens, those entries may not found via redfish GET as `sd_journal_seek_realtime_usec()`[1] may not always work on the entries which are not sorted in time-order. This may cause the inconsistency between the content of `/redfish/v1/Managers/bmc/LogServices/Journal/Entries/` and /redfish/v1/Managers/bmc/LogServices/Journal/Entries/<bmc_journal_id>`. For example, ``` sudo journalctl --vacuum-time=1s <wait for a while to clear up journal> date -s "<backward-time>" date -s "<forward-time>" ``` Run redfish journal entries and get each entry id from the output ``` curl -k -X GET https://${bmc}/redfish/v1/Managers/bmc/LogServices/Journal/Entries > rj.out ``` Take some logEntry Id that its time going backward like ``` grep "@odata.id" rj.out ``` Run redfish query for each id, and some of them can't be successful. ``` % curl -k -X GET https://${bmc}/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800002075 { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type LogEntry named '1701604800002075' was not found.", "MessageArgs": [ "LogEntry", "1701604800002075" ], "MessageId": "Base.1.13.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.0.ResourceNotFound", "message": "The requested resource of type LogEntry named '1701604800002075' was not found." } }% ``` This can also be verified by checking the failure of Redfish Validator run ``` python3 RedfishServiceValidator.py --auth Session -i https://${bmc} -u admin -p 0penBmc0 --payload Tree /redfish/v1/Managers/bmc/LogServices/Journal/Entries ``` For example, ``` ERROR - Members: GET of resource at URI /redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800002075 returned HTTP error. Check URI. ERROR - Members: GET of resource at URI /redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800065949 returned HTTP error. Check URI. ERROR - Members: GET of resource at URI /redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701607680003048 returned HTTP error. Check URI. ``` ``` --Time goes backwrd { "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701604800002075", "@odata.type": "#LogEntry.v1_9_0.LogEntry", "Created": "2023-12-03T12:00:00+00:00", "EntryType": "Oem", "Id": "1701604800002075", "Message": "systemd-resolved: Clock change detected. Flushing caches.", "Name": "BMC Journal Entry", "OemRecordFormat": "BMC Journal Entry", "Severity": "OK" }, ... { "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1701607680003048", "@odata.type": "#LogEntry.v1_9_0.LogEntry", "Created": "2023-12-03T12:48:00+00:00", "EntryType": "Oem", "Id": "1701607680003048", "Message": "systemd-resolved: Clock change detected. Flushing caches.", "Name": "BMC Journal Entry", "OemRecordFormat": "BMC Journal Entry", "Severity": "OK" }, -- Time comes back to the previous moment ``` The solution is proposed to use <bootid> + <monototic timestamp> as the redfish journal entry id instead of realtime timestamp. Unlike realtime timestamp which may go backward, <monotonic timestamp> is monotonically increasing. Tested: - Redfish Validator passes - GET Journal Entry ID will be found even if its time goes backward. [1] https://github.com/openbmc/bmcweb/blob/7164bc62dd26ec92b01985aaae97ecc48276dea5/redfish-core/lib/log_services.hpp#L2690 Change-Id: I83bfb1ed88c9cf036f594757aa4a00d2709dd196 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2023-12-09mutual-tls: Add support for Meta certificatesMarco Kawajiri1-0/+1
Meta Inc's client certificates use an internal Subject CN format which AFAIK is specific to Meta and don't adhere to a known standard: Subject: CN = <type>:<entity>/<hostname> Commit adds the `mutual-tls-common-name-parsing=meta` option to, on Meta builds, parse the Subject CN field and map either the <entity> to a local user. The <type> field determines what kind of client identity the cert represents. Only type="user" is supported for now with <entity> being the unixname of a Meta employee. For example, the Subject CN string below maps to a local BMC user named "kawmarco": Subject CN = "user:kawmarco/dev123.facebook.com" Tested: Unit tests, built and tested on romulus using the script below: https://gist.github.com/kawmarco/87170a8250020023d913ed5f7ed5c01f Flags used in meta-ibm/meta-romulus/conf/layer.conf : ``` -Dbmcweb-logging='enabled' -Dmutual-tls-common-name-parsing='meta' ``` Change-Id: I35ee9b92d163ce56815a5bd9cce5296ba1a44eef Signed-off-by: Marco Kawajiri <kawajiri@meta.com>
2023-12-09Add mutual tls unit testEd Tanous1-3/+20
Mutual TLS paths were not tested. Add some unit tests. Because CI doesn't actually compile dependent libraries with ASAN enabled, and these tests call into openssl, we need to add a check for if we're compiling with asan enabled. Tested: unit tests pass. Change-Id: I02dcb69708619cc00fffd840738c608db3ae8bdf Signed-off-by: Ed Tanous <ed@tanous.net>
2023-12-08Reponse: Fix incomplete implementation in writeAbhilash Raju1-0/+1
Write function in http_response.hpp missing implementation for first write after changing from filebody. Usecase: Current resonse type is filebody. Developer tries to change the body type to stringbody by calling write function. Observed: The write fails to update the body type. Expected: Write should succeed and body should change to string body. Tested: Unit test has been added for crow::Response. Manual sanity test done for file offloads using curl. Change-Id: Icbf8585b5b04c3ac5120d7b334c13d89ed3eb4aa Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>
2023-12-07meson: adjust nlohmann-json dependencyPatrick Williams1-7/+2
* Simplify the meson.build boiler-plate for meson. * Rename the wrap file for consistency with other repositories. * Adjust the meson required version to match the wrap file. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I2da418c10fbe0450944567d276b17f3196da0b55
2023-12-05Unit test ConnectionEd Tanous1-0/+1
Boost asio provides a test stream object that we can use to begin unit testing the connection object. This patchset uses it to re-enable some simple http1.1 tests. There's some features that have snuck into the connection class that aren't compatible with a stream (like ip address getting), so unfortunately we do need the connection class to be aware if it's in test mode, but that tradeoff seems worthwhile. Tested: Unit test pass. Change-Id: Id8b1f8866582b58502dbafe6139f841bf64b8ef3 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-11-29build: use allowed over enabledPatrick Williams1-5/+5
Meson feature options are typically in a tri-state of enabled, disabled, or auto. The enabled and disabled functions on an option (from `get_option`) no longer return true for auto features. Instead, the expectation is to use `allowed()` which is true for both enabled and auto. Switch all uses of `enabled` to `allowed`. Change-Id: Ia40b13fdce7af88085cf23a4a87d9be939edd1e3 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-11-06Don't warn on unused macrosEd Tanous1-0/+1
Change-Id: If12934606c3ef00025d05a9f0b8bd46000865c9a Signed-off-by: Ed Tanous <edtanous@google.com>
2023-10-24Fix boost build locallyEd Tanous1-7/+0
Change I1d00ef561fed7e3ba799969a112ee58b6578ce32 fixed local compilation of bmcweb, but it is causing failures when attempting to SRCREV bump. This should fix the issues during SRCREV bump while still allowing local builds to succeed. Tested (Carson): I was able to locally build bmcweb without having previously installed any boost libraries. All unit tests also passed. meson buildlocal && ninja -C buildlocal test Change-Id: I8cbb764dc564b84b4adb06ba80cb87b2a2c4701f Signed-off-by: Ed Tanous <edtanous@google.com> Signed-off-by: Carson Labrado <clabrado@google.com>