Bring consistency to config options
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>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 1e5a34f..1453a4b 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -865,7 +865,7 @@
const std::string& entryID,
const std::string& dumpType)
{
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -1276,7 +1276,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -1305,25 +1305,29 @@
eventLog["@odata.id"] =
"/redfish/v1/Systems/system/LogServices/EventLog";
logServiceArray.emplace_back(std::move(eventLog));
-#ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
- nlohmann::json::object_t dumpLog;
- dumpLog["@odata.id"] = "/redfish/v1/Systems/system/LogServices/Dump";
- logServiceArray.emplace_back(std::move(dumpLog));
-#endif
+ if constexpr (BMCWEB_REDFISH_DUMP_LOG)
+ {
+ nlohmann::json::object_t dumpLog;
+ dumpLog["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Dump";
+ logServiceArray.emplace_back(std::move(dumpLog));
+ }
-#ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
- nlohmann::json::object_t crashdump;
- crashdump["@odata.id"] =
- "/redfish/v1/Systems/system/LogServices/Crashdump";
- logServiceArray.emplace_back(std::move(crashdump));
-#endif
+ if constexpr (BMCWEB_REDFISH_DUMP_LOG)
+ {
+ nlohmann::json::object_t crashdump;
+ crashdump["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Crashdump";
+ logServiceArray.emplace_back(std::move(crashdump));
+ }
-#ifdef BMCWEB_ENABLE_REDFISH_HOST_LOGGER
- nlohmann::json::object_t hostlogger;
- hostlogger["@odata.id"] =
- "/redfish/v1/Systems/system/LogServices/HostLogger";
- logServiceArray.emplace_back(std::move(hostlogger));
-#endif
+ if constexpr (BMCWEB_REDFISH_HOST_LOGGER)
+ {
+ nlohmann::json::object_t hostlogger;
+ hostlogger["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/HostLogger";
+ logServiceArray.emplace_back(std::move(hostlogger));
+ }
asyncResp->res.jsonValue["Members@odata.count"] =
logServiceArray.size();
@@ -1556,7 +1560,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -1661,7 +1665,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -1738,7 +1742,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -1935,7 +1939,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -2049,7 +2053,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -2089,7 +2093,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -2229,7 +2233,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -2273,7 +2277,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -2357,7 +2361,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -2435,57 +2439,59 @@
nlohmann::json& logServiceArray = asyncResp->res.jsonValue["Members"];
logServiceArray = nlohmann::json::array();
-#ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
- nlohmann::json::object_t journal;
- journal["@odata.id"] = "/redfish/v1/Managers/bmc/LogServices/Journal";
- logServiceArray.emplace_back(std::move(journal));
-#endif
+ if constexpr (BMCWEB_REDFISH_BMC_JOURNAL)
+ {
+ nlohmann::json::object_t journal;
+ journal["@odata.id"] = "/redfish/v1/Managers/bmc/LogServices/Journal";
+ logServiceArray.emplace_back(std::move(journal));
+ }
asyncResp->res.jsonValue["Members@odata.count"] = logServiceArray.size();
-#ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
- constexpr std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.Collection.DeleteAll"};
- dbus::utility::getSubTreePaths(
- "/xyz/openbmc_project/dump", 0, interfaces,
- [asyncResp](
- const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreePathsResponse& subTreePaths) {
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "handleBMCLogServicesCollectionGet respHandler got error {}",
- ec);
- // Assume that getting an error simply means there are no dump
- // LogServices. Return without adding any error response.
- return;
- }
-
- nlohmann::json& logServiceArrayLocal =
- asyncResp->res.jsonValue["Members"];
-
- for (const std::string& path : subTreePaths)
- {
- if (path == "/xyz/openbmc_project/dump/bmc")
+ if constexpr (BMCWEB_REDFISH_DUMP_LOG)
+ {
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Collection.DeleteAll"};
+ dbus::utility::getSubTreePaths(
+ "/xyz/openbmc_project/dump", 0, interfaces,
+ [asyncResp](const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreePathsResponse&
+ subTreePaths) {
+ if (ec)
{
- nlohmann::json::object_t member;
- member["@odata.id"] =
- "/redfish/v1/Managers/bmc/LogServices/Dump";
- logServiceArrayLocal.emplace_back(std::move(member));
+ BMCWEB_LOG_ERROR(
+ "handleBMCLogServicesCollectionGet respHandler got error {}",
+ ec);
+ // Assume that getting an error simply means there are no dump
+ // LogServices. Return without adding any error response.
+ return;
}
- else if (path == "/xyz/openbmc_project/dump/faultlog")
- {
- nlohmann::json::object_t member;
- member["@odata.id"] =
- "/redfish/v1/Managers/bmc/LogServices/FaultLog";
- logServiceArrayLocal.emplace_back(std::move(member));
- }
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- logServiceArrayLocal.size();
- });
-#endif
+ nlohmann::json& logServiceArrayLocal =
+ asyncResp->res.jsonValue["Members"];
+
+ for (const std::string& path : subTreePaths)
+ {
+ if (path == "/xyz/openbmc_project/dump/bmc")
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/Managers/bmc/LogServices/Dump";
+ logServiceArrayLocal.emplace_back(std::move(member));
+ }
+ else if (path == "/xyz/openbmc_project/dump/faultlog")
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/Managers/bmc/LogServices/FaultLog";
+ logServiceArrayLocal.emplace_back(std::move(member));
+ }
+ }
+
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logServiceArrayLocal.size();
+ });
+ }
}
inline void requestRoutesBMCLogServiceCollection(App& app)
@@ -3004,7 +3010,7 @@
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3040,7 +3046,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3242,7 +3248,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3300,7 +3306,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3417,7 +3423,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3493,7 +3499,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3527,7 +3533,7 @@
// Do not call getRedfishRoute here since the crashdump file is not a
// Redfish resource.
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3633,7 +3639,7 @@
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3769,7 +3775,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3823,7 +3829,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -3875,7 +3881,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -4236,7 +4242,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -4287,7 +4293,7 @@
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
@@ -4373,7 +4379,7 @@
{
return;
}
- if constexpr (bmcwebEnableMultiHost)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
// Option currently returns no systems. TBD
messages::resourceNotFound(asyncResp->res, "ComputerSystem",