summaryrefslogtreecommitdiff
path: root/redfish-core/src/redfish.cpp
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-18 01:40:31 +0300
committerEd Tanous <ed@tanous.net>2024-05-01 18:14:17 +0300
commit25b54dba775b31021a3a4677eb79e9771bcb97f7 (patch)
treefcf84de17508887775cc14a9c15ad4a41d72b049 /redfish-core/src/redfish.cpp
parentaca174983be5a0d2af08044dd93487908ae6cfe5 (diff)
downloadbmcweb-25b54dba775b31021a3a4677eb79e9771bcb97f7.tar.xz
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>
Diffstat (limited to 'redfish-core/src/redfish.cpp')
-rw-r--r--redfish-core/src/redfish.cpp158
1 files changed, 84 insertions, 74 deletions
diff --git a/redfish-core/src/redfish.cpp b/redfish-core/src/redfish.cpp
index 66a43d76f0..e7a58c1f41 100644
--- a/redfish-core/src/redfish.cpp
+++ b/redfish-core/src/redfish.cpp
@@ -51,31 +51,34 @@ namespace redfish
RedfishService::RedfishService(App& app)
{
requestAccountServiceRoutes(app);
-#ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION
- requestRoutesAggregationService(app);
- requestRoutesAggregationSourceCollection(app);
- requestRoutesAggregationSource(app);
-#endif
+ if constexpr (BMCWEB_REDFISH_AGGREGATION)
+ {
+ requestRoutesAggregationService(app);
+ requestRoutesAggregationSourceCollection(app);
+ requestRoutesAggregationSource(app);
+ }
requestRoutesRoles(app);
requestRoutesRoleCollection(app);
requestRoutesServiceRoot(app);
requestRoutesNetworkProtocol(app);
requestRoutesSession(app);
requestEthernetInterfacesRoutes(app);
-#ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
- requestRoutesThermal(app);
- requestRoutesPower(app);
-#endif
-#ifdef BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM
- requestRoutesEnvironmentMetrics(app);
- requestRoutesPowerSubsystem(app);
- requestRoutesPowerSupply(app);
- requestRoutesPowerSupplyCollection(app);
- requestRoutesThermalMetrics(app);
- requestRoutesThermalSubsystem(app);
- requestRoutesFan(app);
- requestRoutesFanCollection(app);
-#endif
+ if constexpr (BMCWEB_REDFISH_ALLOW_DEPRECATED_POWER_THERMAL)
+ {
+ requestRoutesThermal(app);
+ requestRoutesPower(app);
+ }
+ if constexpr (BMCWEB_REDFISH_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM)
+ {
+ requestRoutesEnvironmentMetrics(app);
+ requestRoutesPowerSubsystem(app);
+ requestRoutesPowerSupply(app);
+ requestRoutesPowerSupplyCollection(app);
+ requestRoutesThermalMetrics(app);
+ requestRoutesThermalSubsystem(app);
+ requestRoutesFan(app);
+ requestRoutesFanCollection(app);
+ }
requestRoutesManagerCollection(app);
requestRoutesManager(app);
requestRoutesManagerResetAction(app);
@@ -106,47 +109,51 @@ RedfishService::RedfishService(App& app)
requestRoutesPostCodesEntry(app);
requestRoutesPostCodesEntryCollection(app);
-#ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
- requestRoutesSystemDumpService(app);
- requestRoutesSystemDumpEntryCollection(app);
- requestRoutesSystemDumpEntry(app);
- requestRoutesSystemDumpCreate(app);
- requestRoutesSystemDumpClear(app);
-
- requestRoutesBMCDumpService(app);
- requestRoutesBMCDumpEntryCollection(app);
- requestRoutesBMCDumpEntry(app);
- requestRoutesBMCDumpEntryDownload(app);
- requestRoutesBMCDumpCreate(app);
- requestRoutesBMCDumpClear(app);
-
- requestRoutesFaultLogDumpService(app);
- requestRoutesFaultLogDumpEntryCollection(app);
- requestRoutesFaultLogDumpEntry(app);
- requestRoutesFaultLogDumpClear(app);
-#endif
-
-#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
- requestRoutesJournalEventLogEntryCollection(app);
- requestRoutesJournalEventLogEntry(app);
- requestRoutesJournalEventLogClear(app);
-#endif
+ if constexpr (BMCWEB_REDFISH_DUMP_LOG)
+ {
+ requestRoutesSystemDumpService(app);
+ requestRoutesSystemDumpEntryCollection(app);
+ requestRoutesSystemDumpEntry(app);
+ requestRoutesSystemDumpCreate(app);
+ requestRoutesSystemDumpClear(app);
+
+ requestRoutesBMCDumpService(app);
+ requestRoutesBMCDumpEntryCollection(app);
+ requestRoutesBMCDumpEntry(app);
+ requestRoutesBMCDumpEntryDownload(app);
+ requestRoutesBMCDumpCreate(app);
+ requestRoutesBMCDumpClear(app);
+
+ requestRoutesFaultLogDumpService(app);
+ requestRoutesFaultLogDumpEntryCollection(app);
+ requestRoutesFaultLogDumpEntry(app);
+ requestRoutesFaultLogDumpClear(app);
+ }
+
+ if constexpr (BMCWEB_REDFISH_DBUS_LOG)
+ {
+ requestRoutesJournalEventLogEntryCollection(app);
+ requestRoutesJournalEventLogEntry(app);
+ requestRoutesJournalEventLogClear(app);
+ }
requestRoutesBMCLogServiceCollection(app);
-#ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
- requestRoutesBMCJournalLogService(app);
- requestRoutesBMCJournalLogEntryCollection(app);
- requestRoutesBMCJournalLogEntry(app);
-#endif
-
-#ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
- requestRoutesCrashdumpService(app);
- requestRoutesCrashdumpEntryCollection(app);
- requestRoutesCrashdumpEntry(app);
- requestRoutesCrashdumpFile(app);
- requestRoutesCrashdumpClear(app);
- requestRoutesCrashdumpCollect(app);
-#endif // BMCWEB_ENABLE_REDFISH_CPU_LOG
+ if constexpr (BMCWEB_REDFISH_BMC_JOURNAL)
+ {
+ requestRoutesBMCJournalLogService(app);
+ requestRoutesBMCJournalLogEntryCollection(app);
+ requestRoutesBMCJournalLogEntry(app);
+ }
+
+ if constexpr (BMCWEB_REDFISH_CPU_LOG)
+ {
+ requestRoutesCrashdumpService(app);
+ requestRoutesCrashdumpEntryCollection(app);
+ requestRoutesCrashdumpEntry(app);
+ requestRoutesCrashdumpFile(app);
+ requestRoutesCrashdumpClear(app);
+ requestRoutesCrashdumpCollect(app);
+ }
requestRoutesProcessorCollection(app);
requestRoutesProcessor(app);
@@ -160,22 +167,25 @@ RedfishService::RedfishService(App& app)
requestRoutesBiosService(app);
requestRoutesBiosReset(app);
-#ifdef BMCWEB_ENABLE_VM_NBDPROXY
- requestNBDVirtualMediaRoutes(app);
-#endif // BMCWEB_ENABLE_VM_NBDPROXY
-
-#ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
- requestRoutesDBusLogServiceActionsClear(app);
- requestRoutesDBusEventLogEntryCollection(app);
- requestRoutesDBusEventLogEntry(app);
- requestRoutesDBusEventLogEntryDownload(app);
-#endif
-
-#ifdef BMCWEB_ENABLE_REDFISH_HOST_LOGGER
- requestRoutesSystemHostLogger(app);
- requestRoutesSystemHostLoggerCollection(app);
- requestRoutesSystemHostLoggerLogEntry(app);
-#endif
+ if constexpr (BMCWEB_VM_NBDPROXY)
+ {
+ requestNBDVirtualMediaRoutes(app);
+ }
+
+ if constexpr (BMCWEB_REDFISH_DBUS_LOG)
+ {
+ requestRoutesDBusLogServiceActionsClear(app);
+ requestRoutesDBusEventLogEntryCollection(app);
+ requestRoutesDBusEventLogEntry(app);
+ requestRoutesDBusEventLogEntryDownload(app);
+ }
+
+ if constexpr (BMCWEB_REDFISH_HOST_LOGGER)
+ {
+ requestRoutesSystemHostLogger(app);
+ requestRoutesSystemHostLoggerCollection(app);
+ requestRoutesSystemHostLoggerLogEntry(app);
+ }
requestRoutesMessageRegistryFileCollection(app);
requestRoutesMessageRegistryFile(app);