registries: make registration dynamic
Rather than having to manually hook code for registries, add a small
registration function to the registry header and use this registration
results throughout the registry interactions.
Tested:
Confirmed registries have same behavior.
```
$ curl -s -k https://localhost:18080/redfish/v1/Registries/ | jq '.Members | map(."@odata.id")'
[
"/redfish/v1/Registries/Base",
"/redfish/v1/Registries/HeartbeatEvent",
"/redfish/v1/Registries/OpenBMC",
"/redfish/v1/Registries/ResourceEvent",
"/redfish/v1/Registries/TaskEvent",
"/redfish/v1/Registries/Telemetry"
]
```
```
$ curl -s -k https://localhost:18080/redfish/v1/Registries/TaskEvent/TaskEvent | jq ".Messages | keys"
[
"TaskAborted",
"TaskCancelled",
"TaskCompletedOK",
"TaskCompletedWarning",
"TaskPaused",
"TaskProgressChanged",
"TaskRemoved",
"TaskResumed",
"TaskStarted"
]
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iaa355420736a2587d9da4e995208d579443ca9b8
diff --git a/redfish-core/include/registries.hpp b/redfish-core/include/registries.hpp
index d379147..f7a8df3 100644
--- a/redfish-core/include/registries.hpp
+++ b/redfish-core/include/registries.hpp
@@ -11,6 +11,9 @@
#include <charconv>
#include <cstddef>
#include <format>
+#include <functional>
+#include <map>
+#include <optional>
#include <span>
#include <string>
#include <string_view>
@@ -43,6 +46,30 @@
const char* resolution;
};
using MessageEntry = std::pair<const char*, const Message>;
+using MessageEntries = std::span<const MessageEntry>;
+
+struct RegistryEntry
+{
+ const Header& header;
+ const char* url;
+ MessageEntries entries;
+};
+using RegistryEntryRef = std::reference_wrapper<RegistryEntry>;
+
+auto allRegistries() -> std::map<std::string, RegistryEntry>&;
+
+auto getRegistryFromPrefix(const std::string& registryName)
+ -> std::optional<RegistryEntryRef>;
+
+auto getRegistryMessagesFromPrefix(const std::string& registryName)
+ -> MessageEntries;
+
+template <typename T>
+void registerRegistry()
+{
+ allRegistries().emplace(T::header.registryPrefix,
+ RegistryEntry{T::header, T::url, T::registry});
+}
inline std::string fillMessageArgs(
const std::span<const std::string_view> messageArgs, std::string_view msg)
diff --git a/redfish-core/include/registries/base_message_registry.hpp b/redfish-core/include/registries/base_message_registry.hpp
index c35a7a5..e82c728 100644
--- a/redfish-core/include/registries/base_message_registry.hpp
+++ b/redfish-core/include/registries/base_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::base
+namespace redfish::registries
{
-const Header header = {
+struct Base
+{
+static constexpr Header header = {
"Copyright 2014-2024 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Base",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Base.1.19.0.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"AccessDenied",
@@ -1479,4 +1482,9 @@
undeterminedFault = 112,
unrecognizedRequestBody = 113,
};
-} // namespace redfish::registries::base
+}; // struct base
+
+[[gnu::constructor]] inline void registerBase()
+{ registerRegistry<Base>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/composition_message_registry.hpp b/redfish-core/include/registries/composition_message_registry.hpp
index 26e465f..3152350 100644
--- a/redfish-core/include/registries/composition_message_registry.hpp
+++ b/redfish-core/include/registries/composition_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::composition
+namespace redfish::registries
{
-const Header header = {
+struct Composition
+{
+static constexpr Header header = {
"Copyright 2019-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Composition",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Composition.1.1.2.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"ConstrainedResourceAlreadyReserved",
@@ -209,4 +212,9 @@
specifiedResourceAlreadyReserved = 11,
unableToProcessStanzaRequest = 12,
};
-} // namespace redfish::registries::composition
+}; // struct composition
+
+[[gnu::constructor]] inline void registerComposition()
+{ registerRegistry<Composition>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/environmental_message_registry.hpp b/redfish-core/include/registries/environmental_message_registry.hpp
index dc3d66d..5f267cf 100644
--- a/redfish-core/include/registries/environmental_message_registry.hpp
+++ b/redfish-core/include/registries/environmental_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::environmental
+namespace redfish::registries
{
-const Header header = {
+struct Environmental
+{
+static constexpr Header header = {
"Copyright 2024 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Environmental",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Environmental.1.1.0.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"FanFailed",
@@ -1280,4 +1283,9 @@
temperatureNormal = 85,
temperatureWarning = 86,
};
-} // namespace redfish::registries::environmental
+}; // struct environmental
+
+[[gnu::constructor]] inline void registerEnvironmental()
+{ registerRegistry<Environmental>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/ethernet_fabric_message_registry.hpp b/redfish-core/include/registries/ethernet_fabric_message_registry.hpp
index a19b114..04e1fb9 100644
--- a/redfish-core/include/registries/ethernet_fabric_message_registry.hpp
+++ b/redfish-core/include/registries/ethernet_fabric_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::ethernet_fabric
+namespace redfish::registries
{
-const Header header = {
+struct EthernetFabric
+{
+static constexpr Header header = {
"Copyright 2020-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"EthernetFabric",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/EthernetFabric.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"LLDPInterfaceDisabled",
@@ -154,4 +157,9 @@
mLAGPeerUp = 6,
routingFailureThresholdExceeded = 7,
};
-} // namespace redfish::registries::ethernet_fabric
+}; // struct ethernet_fabric
+
+[[gnu::constructor]] inline void registerEthernetFabric()
+{ registerRegistry<EthernetFabric>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/fabric_message_registry.hpp b/redfish-core/include/registries/fabric_message_registry.hpp
index 3b3c68b..295dbf0 100644
--- a/redfish-core/include/registries/fabric_message_registry.hpp
+++ b/redfish-core/include/registries/fabric_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::fabric
+namespace redfish::registries
{
-const Header header = {
+struct Fabric
+{
+static constexpr Header header = {
"Copyright 2014-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Fabric",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Fabric.1.0.2.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"AddressPoolCreated",
@@ -634,4 +637,9 @@
zoneModified = 40,
zoneRemoved = 41,
};
-} // namespace redfish::registries::fabric
+}; // struct fabric
+
+[[gnu::constructor]] inline void registerFabric()
+{ registerRegistry<Fabric>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/heartbeat_event_message_registry.hpp b/redfish-core/include/registries/heartbeat_event_message_registry.hpp
index d669556..b98876e 100644
--- a/redfish-core/include/registries/heartbeat_event_message_registry.hpp
+++ b/redfish-core/include/registries/heartbeat_event_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::heartbeat_event
+namespace redfish::registries
{
-const Header header = {
+struct HeartbeatEvent
+{
+static constexpr Header header = {
"Copyright 2021-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"HeartbeatEvent",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/HeartbeatEvent.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"RedfishServiceFunctional",
@@ -53,4 +56,9 @@
{
redfishServiceFunctional = 0,
};
-} // namespace redfish::registries::heartbeat_event
+}; // struct heartbeat_event
+
+[[gnu::constructor]] inline void registerHeartbeatEvent()
+{ registerRegistry<HeartbeatEvent>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/job_event_message_registry.hpp b/redfish-core/include/registries/job_event_message_registry.hpp
index 68eb7f3..6096398 100644
--- a/redfish-core/include/registries/job_event_message_registry.hpp
+++ b/redfish-core/include/registries/job_event_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::job_event
+namespace redfish::registries
{
-const Header header = {
+struct JobEvent
+{
+static constexpr Header header = {
"Copyright 2014-2023 DMTF in cooperation with the Storage Networking Industry Association (SNIA). All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"JobEvent",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/JobEvent.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"JobCancelled",
@@ -147,4 +150,9 @@
jobStarted = 6,
jobSuspended = 7,
};
-} // namespace redfish::registries::job_event
+}; // struct job_event
+
+[[gnu::constructor]] inline void registerJobEvent()
+{ registerRegistry<JobEvent>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/license_message_registry.hpp b/redfish-core/include/registries/license_message_registry.hpp
index 28a2428..30bf1a2 100644
--- a/redfish-core/include/registries/license_message_registry.hpp
+++ b/redfish-core/include/registries/license_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::license
+namespace redfish::registries
{
-const Header header = {
+struct License
+{
+static constexpr Header header = {
"Copyright 2014-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"License",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/License.1.0.3.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"DaysBeforeExpiration",
@@ -142,4 +145,9 @@
notApplicableToTarget = 6,
targetsRequired = 7,
};
-} // namespace redfish::registries::license
+}; // struct license
+
+[[gnu::constructor]] inline void registerLicense()
+{ registerRegistry<License>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/log_service_message_registry.hpp b/redfish-core/include/registries/log_service_message_registry.hpp
index 700692b..6294f98 100644
--- a/redfish-core/include/registries/log_service_message_registry.hpp
+++ b/redfish-core/include/registries/log_service_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::log_service
+namespace redfish::registries
{
-const Header header = {
+struct LogService
+{
+static constexpr Header header = {
"Copyright 2020-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"LogService",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/LogService.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"DiagnosticDataCollected",
@@ -55,4 +58,9 @@
{
diagnosticDataCollected = 0,
};
-} // namespace redfish::registries::log_service
+}; // struct log_service
+
+[[gnu::constructor]] inline void registerLogService()
+{ registerRegistry<LogService>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/network_device_message_registry.hpp b/redfish-core/include/registries/network_device_message_registry.hpp
index 996a47f..933596e 100644
--- a/redfish-core/include/registries/network_device_message_registry.hpp
+++ b/redfish-core/include/registries/network_device_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::network_device
+namespace redfish::registries
{
-const Header header = {
+struct NetworkDevice
+{
+static constexpr Header header = {
"Copyright 2019-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"NetworkDevice",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/NetworkDevice.1.0.3.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"CableInserted",
@@ -132,4 +135,9 @@
degradedConnectionEstablished = 4,
linkFlapDetected = 5,
};
-} // namespace redfish::registries::network_device
+}; // struct network_device
+
+[[gnu::constructor]] inline void registerNetworkDevice()
+{ registerRegistry<NetworkDevice>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp
index 16b5c24..0f22153 100644
--- a/redfish-core/include/registries/openbmc_message_registry.hpp
+++ b/redfish-core/include/registries/openbmc_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::openbmc
+namespace redfish::registries
{
-const Header header = {
+struct Openbmc
+{
+static constexpr Header header = {
"Copyright 2022 OpenBMC. All rights reserved.",
"#MessageRegistry.v1_4_0.MessageRegistry",
0,
@@ -31,10 +33,11 @@
"OpenBMC",
"OpenBMC",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://raw.githubusercontent.com/openbmc/bmcweb/refs/heads/master/redfish-core/include/registries/openbmc.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"ADDDCCorrectable",
@@ -2549,4 +2552,9 @@
systemPowerOnFailed = 190,
voltageRegulatorOverheated = 191,
};
-} // namespace redfish::registries::openbmc
+}; // struct openbmc
+
+[[gnu::constructor]] inline void registerOpenbmc()
+{ registerRegistry<Openbmc>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/platform_message_registry.hpp b/redfish-core/include/registries/platform_message_registry.hpp
index e092879..cfae35d 100644
--- a/redfish-core/include/registries/platform_message_registry.hpp
+++ b/redfish-core/include/registries/platform_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::platform
+namespace redfish::registries
{
-const Header header = {
+struct Platform
+{
+static constexpr Header header = {
"Copyright 2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Platform",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Platform.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"OperatingSystemCrash",
@@ -88,4 +91,9 @@
platformErrorAtLocation = 2,
unhandledExceptionDetectedAfterReset = 3,
};
-} // namespace redfish::registries::platform
+}; // struct platform
+
+[[gnu::constructor]] inline void registerPlatform()
+{ registerRegistry<Platform>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/power_message_registry.hpp b/redfish-core/include/registries/power_message_registry.hpp
index cb5c966..13fb5a7 100644
--- a/redfish-core/include/registries/power_message_registry.hpp
+++ b/redfish-core/include/registries/power_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::power
+namespace redfish::registries
{
-const Header header = {
+struct Power
+{
+static constexpr Header header = {
"Copyright 2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Power",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Power.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"BreakerFault",
@@ -1053,4 +1056,9 @@
voltageNormal = 69,
voltageWarning = 70,
};
-} // namespace redfish::registries::power
+}; // struct power
+
+[[gnu::constructor]] inline void registerPower()
+{ registerRegistry<Power>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/resource_event_message_registry.hpp b/redfish-core/include/registries/resource_event_message_registry.hpp
index 7c84971..48b8a1c 100644
--- a/redfish-core/include/registries/resource_event_message_registry.hpp
+++ b/redfish-core/include/registries/resource_event_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::resource_event
+namespace redfish::registries
{
-const Header header = {
+struct ResourceEvent
+{
+static constexpr Header header = {
"Copyright 2014-2023 DMTF in cooperation with the Storage Networking Industry Association (SNIA). All rights reserved.",
"#MessageRegistry.v1_6_0.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"ResourceEvent",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/ResourceEvent.1.3.0.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"AggregationSourceDiscovered",
@@ -395,4 +398,9 @@
testMessage = 25,
uRIForResourceChanged = 26,
};
-} // namespace redfish::registries::resource_event
+}; // struct resource_event
+
+[[gnu::constructor]] inline void registerResourceEvent()
+{ registerRegistry<ResourceEvent>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/sensor_event_message_registry.hpp b/redfish-core/include/registries/sensor_event_message_registry.hpp
index 3716398..fe6e301 100644
--- a/redfish-core/include/registries/sensor_event_message_registry.hpp
+++ b/redfish-core/include/registries/sensor_event_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::sensor_event
+namespace redfish::registries
{
-const Header header = {
+struct SensorEvent
+{
+static constexpr Header header = {
"Copyright 2022-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"SensorEvent",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/SensorEvent.1.0.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"InvalidSensorReading",
@@ -301,4 +304,9 @@
sensorReadingNormalRange = 15,
sensorRestored = 16,
};
-} // namespace redfish::registries::sensor_event
+}; // struct sensor_event
+
+[[gnu::constructor]] inline void registerSensorEvent()
+{ registerRegistry<SensorEvent>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/storage_device_message_registry.hpp b/redfish-core/include/registries/storage_device_message_registry.hpp
index 5e48038..c384470 100644
--- a/redfish-core/include/registries/storage_device_message_registry.hpp
+++ b/redfish-core/include/registries/storage_device_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::storage_device
+namespace redfish::registries
{
-const Header header = {
+struct StorageDevice
+{
+static constexpr Header header = {
"Copyright 2020-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"StorageDevice",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/StorageDevice.1.2.1.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"BatteryCharging",
@@ -493,4 +496,9 @@
writeCacheProtected = 32,
writeCacheTemporarilyDegraded = 33,
};
-} // namespace redfish::registries::storage_device
+}; // struct storage_device
+
+[[gnu::constructor]] inline void registerStorageDevice()
+{ registerRegistry<StorageDevice>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/task_event_message_registry.hpp b/redfish-core/include/registries/task_event_message_registry.hpp
index 08e9014..137f181 100644
--- a/redfish-core/include/registries/task_event_message_registry.hpp
+++ b/redfish-core/include/registries/task_event_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::task_event
+namespace redfish::registries
{
-const Header header = {
+struct TaskEvent
+{
+static constexpr Header header = {
"Copyright 2014-2020 DMTF in cooperation with the Storage Networking Industry Association (SNIA). All rights reserved.",
"#MessageRegistry.v1_4_1.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"TaskEvent",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/TaskEvent.1.0.3.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"TaskAborted",
@@ -160,4 +163,9 @@
taskResumed = 7,
taskStarted = 8,
};
-} // namespace redfish::registries::task_event
+}; // struct task_event
+
+[[gnu::constructor]] inline void registerTaskEvent()
+{ registerRegistry<TaskEvent>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/telemetry_message_registry.hpp b/redfish-core/include/registries/telemetry_message_registry.hpp
index ed59bf6..abb2874 100644
--- a/redfish-core/include/registries/telemetry_message_registry.hpp
+++ b/redfish-core/include/registries/telemetry_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::telemetry
+namespace redfish::registries
{
-const Header header = {
+struct Telemetry
+{
+static constexpr Header header = {
"Copyright 2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Telemetry",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Telemetry.1.0.0.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"TriggerDiscreteConditionMet",
@@ -168,4 +171,9 @@
triggerNumericBelowUpperCritical = 6,
triggerNumericReadingNormal = 7,
};
-} // namespace redfish::registries::telemetry
+}; // struct telemetry
+
+[[gnu::constructor]] inline void registerTelemetry()
+{ registerRegistry<Telemetry>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries/update_message_registry.hpp b/redfish-core/include/registries/update_message_registry.hpp
index 0c5d1f6..578b77a 100644
--- a/redfish-core/include/registries/update_message_registry.hpp
+++ b/redfish-core/include/registries/update_message_registry.hpp
@@ -17,9 +17,11 @@
// clang-format off
-namespace redfish::registries::update
+namespace redfish::registries
{
-const Header header = {
+struct Update
+{
+static constexpr Header header = {
"Copyright 2014-2023 DMTF. All rights reserved.",
"#MessageRegistry.v1_6_2.MessageRegistry",
1,
@@ -31,10 +33,11 @@
"Update",
"DMTF",
};
-constexpr const char* url =
+
+static constexpr const char* url =
"https://redfish.dmtf.org/registries/Update.1.0.2.json";
-constexpr std::array registry =
+static constexpr std::array registry =
{
MessageEntry{
"ActivateFailed",
@@ -245,4 +248,9 @@
verificationFailed = 13,
verifyingAtComponent = 14,
};
-} // namespace redfish::registries::update
+}; // struct update
+
+[[gnu::constructor]] inline void registerUpdate()
+{ registerRegistry<Update>(); }
+
+} // namespace redfish::registries
diff --git a/redfish-core/include/registries_selector.hpp b/redfish-core/include/registries_selector.hpp
index 01160b7..6440ca5 100644
--- a/redfish-core/include/registries_selector.hpp
+++ b/redfish-core/include/registries_selector.hpp
@@ -1,83 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#pragma once
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries.hpp"
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries/base_message_registry.hpp"
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries/heartbeat_event_message_registry.hpp"
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries/openbmc_message_registry.hpp"
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries/resource_event_message_registry.hpp"
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries/task_event_message_registry.hpp"
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries/telemetry_message_registry.hpp"
-
-#include <optional>
-#include <span>
-#include <string_view>
-
-namespace redfish::registries
-{
-struct HeaderAndUrl
-{
- const Header& header;
- const char* url;
-};
-
-inline std::optional<registries::HeaderAndUrl>
- getRegistryHeaderAndUrlFromPrefix(std::string_view registryName)
-{
- if (base::header.registryPrefix == registryName)
- {
- return HeaderAndUrl{base::header, base::url};
- }
- if (heartbeat_event::header.registryPrefix == registryName)
- {
- return HeaderAndUrl{heartbeat_event::header, heartbeat_event::url};
- }
- if (openbmc::header.registryPrefix == registryName)
- {
- return HeaderAndUrl{openbmc::header, openbmc::url};
- }
- if (resource_event::header.registryPrefix == registryName)
- {
- return HeaderAndUrl{resource_event::header, resource_event::url};
- }
- if (task_event::header.registryPrefix == registryName)
- {
- return HeaderAndUrl{task_event::header, task_event::url};
- }
- if (telemetry::header.registryPrefix == registryName)
- {
- return HeaderAndUrl{telemetry::header, telemetry::url};
- }
- return std::nullopt;
-}
-
-inline std::span<const MessageEntry> getRegistryFromPrefix(
- std::string_view registryName)
-{
- if (base::header.registryPrefix == registryName)
- {
- return {base::registry};
- }
- if (heartbeat_event::header.registryPrefix == registryName)
- {
- return {heartbeat_event::registry};
- }
- if (openbmc::header.registryPrefix == registryName)
- {
- return {openbmc::registry};
- }
- if (resource_event::header.registryPrefix == registryName)
- {
- return {resource_event::registry};
- }
- if (task_event::header.registryPrefix == registryName)
- {
- return {task_event::registry};
- }
- if (telemetry::header.registryPrefix == registryName)
- {
- return {telemetry::registry};
- }
- return {openbmc::registry};
-}
-} // namespace redfish::registries
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 66f49ab..a9093b3 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -16,7 +16,6 @@
#include "query.hpp"
#include "registries.hpp"
#include "registries/privilege_registry.hpp"
-#include "registries_selector.hpp"
#include "snmp_trap_event_clients.hpp"
#include "subscription.hpp"
#include "utils/json_utils.hpp"
@@ -41,7 +40,6 @@
#include <memory>
#include <optional>
#include <ranges>
-#include <span>
#include <string>
#include <utility>
#include <vector>
@@ -652,9 +650,9 @@
// Check for Message ID in each of the selected Registry
for (const std::string& it : registryPrefix)
{
- const std::span<const redfish::registries::MessageEntry>
- registry =
- redfish::registries::getRegistryFromPrefix(it);
+ const registries::MessageEntries registry =
+ redfish::registries::getRegistryMessagesFromPrefix(
+ it);
if (std::ranges::any_of(
registry,
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index 6bbdb48..325fe6b 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -10,17 +10,15 @@
#include "query.hpp"
#include "registries.hpp"
#include "registries/privilege_registry.hpp"
-#include "registries_selector.hpp"
#include <boost/beast/http/verb.hpp>
#include <boost/url/format.hpp>
-#include <array>
#include <format>
#include <functional>
#include <memory>
#include <optional>
-#include <span>
+#include <ranges>
#include <utility>
namespace redfish
@@ -46,11 +44,7 @@
nlohmann::json& members = asyncResp->res.jsonValue["Members"];
- static constexpr const auto registryFiles = std::to_array(
- {"Base", "TaskEvent", "ResourceEvent", "OpenBMC", "Telemetry",
- "HeartbeatEvent"});
-
- for (const char* memberName : registryFiles)
+ for (const auto& memberName : std::views::keys(registries::allRegistries()))
{
nlohmann::json::object_t member;
member["@odata.id"] =
@@ -81,10 +75,10 @@
return;
}
std::string dmtf = "DMTF ";
- std::optional<registries::HeaderAndUrl> headerAndUrl =
- registries::getRegistryHeaderAndUrlFromPrefix(registry);
+ std::optional<registries::RegistryEntryRef> registryEntry =
+ registries::getRegistryFromPrefix(registry);
- if (!headerAndUrl)
+ if (!registryEntry)
{
messages::resourceNotFound(asyncResp->res, "MessageRegistryFile",
registry);
@@ -94,8 +88,8 @@
{
dmtf.clear();
}
- const registries::Header& header = headerAndUrl->header;
- const char* url = headerAndUrl->url;
+ const registries::Header& header = registryEntry->get().header;
+ const char* url = registryEntry->get().url;
asyncResp->res.jsonValue["@odata.id"] =
boost::urls::format("/redfish/v1/Registries/{}", registry);
@@ -145,16 +139,16 @@
return;
}
- std::optional<registries::HeaderAndUrl> headerAndUrl =
- registries::getRegistryHeaderAndUrlFromPrefix(registry);
- if (!headerAndUrl)
+ std::optional<registries::RegistryEntryRef> registryEntry =
+ registries::getRegistryFromPrefix(registry);
+ if (!registryEntry)
{
messages::resourceNotFound(asyncResp->res, "MessageRegistryFile",
registry);
return;
}
- const registries::Header& header = headerAndUrl->header;
+ const registries::Header& header = registryEntry->get().header;
if (registry != registryMatch)
{
messages::resourceNotFound(asyncResp->res, header.type, registryMatch);
@@ -178,8 +172,8 @@
nlohmann::json& messageObj = asyncResp->res.jsonValue["Messages"];
// Go through the Message Registry and populate each Message
- const std::span<const registries::MessageEntry> registryEntries =
- registries::getRegistryFromPrefix(registry);
+ const registries::MessageEntries registryEntries =
+ registries::getRegistryMessagesFromPrefix(registry);
for (const registries::MessageEntry& message : registryEntries)
{
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 9637bd4..1d6a544 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -40,16 +40,16 @@
namespace messages
{
-static nlohmann::json getLog(redfish::registries::base::Index name,
+static nlohmann::json getLog(redfish::registries::Base::Index name,
std::span<const std::string_view> args)
{
size_t index = static_cast<size_t>(name);
- if (index >= redfish::registries::base::registry.size())
+ if (index >= redfish::registries::Base::registry.size())
{
return {};
}
- return getLogFromRegistry(redfish::registries::base::header,
- redfish::registries::base::registry, index, args);
+ return getLogFromRegistry(redfish::registries::Base::header,
+ redfish::registries::Base::registry, index, args);
}
/**
@@ -61,7 +61,7 @@
*/
nlohmann::json success()
{
- return getLog(redfish::registries::base::Index::success, {});
+ return getLog(redfish::registries::Base::Index::success, {});
}
void success(crow::Response& res)
@@ -78,7 +78,7 @@
*/
nlohmann::json generalError()
{
- return getLog(redfish::registries::base::Index::generalError, {});
+ return getLog(redfish::registries::Base::Index::generalError, {});
}
void generalError(crow::Response& res)
@@ -96,7 +96,7 @@
*/
nlohmann::json created()
{
- return getLog(redfish::registries::base::Index::created, {});
+ return getLog(redfish::registries::Base::Index::created, {});
}
void created(crow::Response& res)
@@ -114,7 +114,7 @@
*/
nlohmann::json noOperation()
{
- return getLog(redfish::registries::base::Index::noOperation, {});
+ return getLog(redfish::registries::Base::Index::noOperation, {});
}
void noOperation(crow::Response& res)
@@ -132,7 +132,7 @@
*/
nlohmann::json propertyDuplicate(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyDuplicate,
+ return getLog(redfish::registries::Base::Index::propertyDuplicate,
std::to_array({arg1}));
}
@@ -151,7 +151,7 @@
*/
nlohmann::json propertyUnknown(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyUnknown,
+ return getLog(redfish::registries::Base::Index::propertyUnknown,
std::to_array({arg1}));
}
@@ -173,7 +173,7 @@
{
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::propertyValueTypeError,
+ return getLog(redfish::registries::Base::Index::propertyValueTypeError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -196,7 +196,7 @@
{
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::propertyValueFormatError,
+ return getLog(redfish::registries::Base::Index::propertyValueFormatError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -219,7 +219,7 @@
{
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::propertyValueNotInList,
+ return getLog(redfish::registries::Base::Index::propertyValueNotInList,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -242,7 +242,7 @@
{
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
+ return getLog(redfish::registries::Base::Index::propertyValueOutOfRange,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -262,7 +262,7 @@
*/
nlohmann::json propertyValueError(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyValueError,
+ return getLog(redfish::registries::Base::Index::propertyValueError,
std::to_array({arg1}));
}
@@ -281,7 +281,7 @@
*/
nlohmann::json propertyNotWritable(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyNotWritable,
+ return getLog(redfish::registries::Base::Index::propertyNotWritable,
std::to_array({arg1}));
}
@@ -300,7 +300,7 @@
*/
nlohmann::json propertyNotUpdated(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyNotUpdated,
+ return getLog(redfish::registries::Base::Index::propertyNotUpdated,
std::to_array({arg1}));
}
@@ -319,7 +319,7 @@
*/
nlohmann::json propertyMissing(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyMissing,
+ return getLog(redfish::registries::Base::Index::propertyMissing,
std::to_array({arg1}));
}
@@ -338,7 +338,7 @@
*/
nlohmann::json malformedJSON()
{
- return getLog(redfish::registries::base::Index::malformedJSON, {});
+ return getLog(redfish::registries::Base::Index::malformedJSON, {});
}
void malformedJSON(crow::Response& res)
@@ -356,7 +356,7 @@
*/
nlohmann::json invalidJSON(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::invalidJSON,
+ return getLog(redfish::registries::Base::Index::invalidJSON,
std::to_array({arg1}));
}
@@ -375,7 +375,7 @@
*/
nlohmann::json emptyJSON()
{
- return getLog(redfish::registries::base::Index::emptyJSON, {});
+ return getLog(redfish::registries::Base::Index::emptyJSON, {});
}
void emptyJSON(crow::Response& res)
@@ -393,7 +393,7 @@
*/
nlohmann::json actionNotSupported(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::actionNotSupported,
+ return getLog(redfish::registries::Base::Index::actionNotSupported,
std::to_array({arg1}));
}
@@ -413,7 +413,7 @@
nlohmann::json actionParameterMissing(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::actionParameterMissing,
+ return getLog(redfish::registries::Base::Index::actionParameterMissing,
std::to_array({arg1, arg2}));
}
@@ -434,7 +434,7 @@
nlohmann::json actionParameterDuplicate(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::actionParameterDuplicate,
+ return getLog(redfish::registries::Base::Index::actionParameterDuplicate,
std::to_array({arg1, arg2}));
}
@@ -455,7 +455,7 @@
nlohmann::json actionParameterUnknown(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::actionParameterUnknown,
+ return getLog(redfish::registries::Base::Index::actionParameterUnknown,
std::to_array({arg1, arg2}));
}
@@ -479,7 +479,7 @@
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
- redfish::registries::base::Index::actionParameterValueTypeError,
+ redfish::registries::Base::Index::actionParameterValueTypeError,
std::to_array<std::string_view>({arg1Str, arg2, arg3}));
}
@@ -505,7 +505,7 @@
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
- redfish::registries::base::Index::actionParameterValueFormatError,
+ redfish::registries::Base::Index::actionParameterValueFormatError,
std::to_array<std::string_view>({arg1Str, arg2, arg3}));
}
@@ -529,7 +529,7 @@
std::string_view arg1, std::string_view arg2, std::string_view arg3)
{
return getLog(
- redfish::registries::base::Index::actionParameterValueNotInList,
+ redfish::registries::Base::Index::actionParameterValueNotInList,
std::to_array({arg1, arg2, arg3}));
}
@@ -552,7 +552,7 @@
std::string_view arg1, std::string_view arg2, std::string_view arg3)
{
return getLog(
- redfish::registries::base::Index::actionParameterValueOutOfRange,
+ redfish::registries::Base::Index::actionParameterValueOutOfRange,
std::to_array({arg1, arg2, arg3}));
}
@@ -577,7 +577,7 @@
{
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::actionParameterValueError,
+ return getLog(redfish::registries::Base::Index::actionParameterValueError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -598,7 +598,7 @@
nlohmann::json actionParameterNotSupported(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::actionParameterNotSupported,
+ return getLog(redfish::registries::Base::Index::actionParameterNotSupported,
std::to_array({arg1, arg2}));
}
@@ -620,7 +620,7 @@
nlohmann::json arraySizeTooLong(std::string_view arg1, uint64_t arg2)
{
std::string arg2Str = std::to_string(arg2);
- return getLog(redfish::registries::base::Index::arraySizeTooLong,
+ return getLog(redfish::registries::Base::Index::arraySizeTooLong,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -639,7 +639,7 @@
*/
nlohmann::json arraySizeTooShort(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::arraySizeTooShort,
+ return getLog(redfish::registries::Base::Index::arraySizeTooShort,
std::to_array({arg1, arg2}));
}
@@ -663,7 +663,7 @@
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
- redfish::registries::base::Index::queryParameterValueTypeError,
+ redfish::registries::Base::Index::queryParameterValueTypeError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -688,7 +688,7 @@
std::string arg1Str =
arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
- redfish::registries::base::Index::queryParameterValueFormatError,
+ redfish::registries::Base::Index::queryParameterValueFormatError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -709,7 +709,7 @@
*/
nlohmann::json queryParameterValueError(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::queryParameterValueError,
+ return getLog(redfish::registries::Base::Index::queryParameterValueError,
std::to_array({arg1}));
}
@@ -729,7 +729,7 @@
nlohmann::json queryParameterOutOfRange(
std::string_view arg1, std::string_view arg2, std::string_view arg3)
{
- return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
+ return getLog(redfish::registries::Base::Index::queryParameterOutOfRange,
std::to_array({arg1, arg2, arg3}));
}
@@ -750,7 +750,7 @@
*/
nlohmann::json queryNotSupportedOnResource()
{
- return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
+ return getLog(redfish::registries::Base::Index::queryNotSupportedOnResource,
{});
}
@@ -770,7 +770,7 @@
nlohmann::json queryNotSupportedOnOperation()
{
return getLog(
- redfish::registries::base::Index::queryNotSupportedOnOperation, {});
+ redfish::registries::Base::Index::queryNotSupportedOnOperation, {});
}
void queryNotSupportedOnOperation(crow::Response& res)
@@ -788,7 +788,7 @@
*/
nlohmann::json queryNotSupported()
{
- return getLog(redfish::registries::base::Index::queryNotSupported, {});
+ return getLog(redfish::registries::Base::Index::queryNotSupported, {});
}
void queryNotSupported(crow::Response& res)
@@ -806,7 +806,7 @@
*/
nlohmann::json queryCombinationInvalid()
{
- return getLog(redfish::registries::base::Index::queryCombinationInvalid,
+ return getLog(redfish::registries::Base::Index::queryCombinationInvalid,
{});
}
@@ -825,7 +825,7 @@
*/
nlohmann::json queryParameterUnsupported(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::queryParameterUnsupported,
+ return getLog(redfish::registries::Base::Index::queryParameterUnsupported,
std::to_array({arg1}));
}
@@ -844,7 +844,7 @@
*/
nlohmann::json sessionLimitExceeded()
{
- return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
+ return getLog(redfish::registries::Base::Index::sessionLimitExceeded, {});
}
void sessionLimitExceeded(crow::Response& res)
@@ -863,7 +863,7 @@
nlohmann::json eventSubscriptionLimitExceeded()
{
return getLog(
- redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
+ redfish::registries::Base::Index::eventSubscriptionLimitExceeded, {});
}
void eventSubscriptionLimitExceeded(crow::Response& res)
@@ -881,7 +881,7 @@
*/
nlohmann::json resourceCannotBeDeleted()
{
- return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
+ return getLog(redfish::registries::Base::Index::resourceCannotBeDeleted,
{});
}
@@ -900,7 +900,7 @@
*/
nlohmann::json resourceInUse()
{
- return getLog(redfish::registries::base::Index::resourceInUse, {});
+ return getLog(redfish::registries::Base::Index::resourceInUse, {});
}
void resourceInUse(crow::Response& res)
@@ -919,7 +919,7 @@
nlohmann::json resourceAlreadyExists(
std::string_view arg1, std::string_view arg2, std::string_view arg3)
{
- return getLog(redfish::registries::base::Index::resourceAlreadyExists,
+ return getLog(redfish::registries::Base::Index::resourceAlreadyExists,
std::to_array({arg1, arg2, arg3}));
}
@@ -940,7 +940,7 @@
*/
nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::resourceNotFound,
+ return getLog(redfish::registries::Base::Index::resourceNotFound,
std::to_array({arg1, arg2}));
}
@@ -960,7 +960,7 @@
*/
nlohmann::json payloadTooLarge()
{
- return getLog(redfish::registries::base::Index::payloadTooLarge, {});
+ return getLog(redfish::registries::Base::Index::payloadTooLarge, {});
}
void payloadTooLarge(crow::Response& res)
@@ -978,7 +978,7 @@
*/
nlohmann::json insufficientStorage()
{
- return getLog(redfish::registries::base::Index::insufficientStorage, {});
+ return getLog(redfish::registries::Base::Index::insufficientStorage, {});
}
void insufficientStorage(crow::Response& res)
@@ -996,7 +996,7 @@
*/
nlohmann::json missingOrMalformedPart()
{
- return getLog(redfish::registries::base::Index::missingOrMalformedPart, {});
+ return getLog(redfish::registries::Base::Index::missingOrMalformedPart, {});
}
void missingOrMalformedPart(crow::Response& res)
@@ -1014,7 +1014,7 @@
*/
nlohmann::json invalidURI(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::invalidURI,
+ return getLog(redfish::registries::Base::Index::invalidURI,
std::to_array({arg1}));
}
@@ -1034,7 +1034,7 @@
nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
{
return getLog(
- redfish::registries::base::Index::createFailedMissingReqProperties,
+ redfish::registries::Base::Index::createFailedMissingReqProperties,
std::to_array({arg1}));
}
@@ -1056,7 +1056,7 @@
nlohmann::json createLimitReachedForResource()
{
return getLog(
- redfish::registries::base::Index::createLimitReachedForResource, {});
+ redfish::registries::Base::Index::createLimitReachedForResource, {});
}
void createLimitReachedForResource(crow::Response& res)
@@ -1074,7 +1074,7 @@
*/
nlohmann::json serviceShuttingDown()
{
- return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
+ return getLog(redfish::registries::Base::Index::serviceShuttingDown, {});
}
void serviceShuttingDown(crow::Response& res)
@@ -1092,7 +1092,7 @@
*/
nlohmann::json serviceInUnknownState()
{
- return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
+ return getLog(redfish::registries::Base::Index::serviceInUnknownState, {});
}
void serviceInUnknownState(crow::Response& res)
@@ -1110,7 +1110,7 @@
*/
nlohmann::json noValidSession()
{
- return getLog(redfish::registries::base::Index::noValidSession, {});
+ return getLog(redfish::registries::Base::Index::noValidSession, {});
}
void noValidSession(crow::Response& res)
@@ -1128,7 +1128,7 @@
*/
nlohmann::json insufficientPrivilege()
{
- return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
+ return getLog(redfish::registries::Base::Index::insufficientPrivilege, {});
}
void insufficientPrivilege(crow::Response& res)
@@ -1146,7 +1146,7 @@
*/
nlohmann::json accountModified()
{
- return getLog(redfish::registries::base::Index::accountModified, {});
+ return getLog(redfish::registries::Base::Index::accountModified, {});
}
void accountModified(crow::Response& res)
@@ -1164,7 +1164,7 @@
*/
nlohmann::json accountNotModified()
{
- return getLog(redfish::registries::base::Index::accountNotModified, {});
+ return getLog(redfish::registries::Base::Index::accountNotModified, {});
}
void accountNotModified(crow::Response& res)
@@ -1182,7 +1182,7 @@
*/
nlohmann::json accountRemoved()
{
- return getLog(redfish::registries::base::Index::accountRemoved, {});
+ return getLog(redfish::registries::Base::Index::accountRemoved, {});
}
void accountRemoved(crow::Response& res)
@@ -1201,7 +1201,7 @@
nlohmann::json accountForSessionNoLongerExists()
{
return getLog(
- redfish::registries::base::Index::accountForSessionNoLongerExists, {});
+ redfish::registries::Base::Index::accountForSessionNoLongerExists, {});
}
void accountForSessionNoLongerExists(crow::Response& res)
@@ -1219,7 +1219,7 @@
*/
nlohmann::json invalidObject(const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::invalidObject,
+ return getLog(redfish::registries::Base::Index::invalidObject,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1238,7 +1238,7 @@
*/
nlohmann::json internalError()
{
- return getLog(redfish::registries::base::Index::internalError, {});
+ return getLog(redfish::registries::Base::Index::internalError, {});
}
void internalError(crow::Response& res, const std::source_location location)
@@ -1259,7 +1259,7 @@
*/
nlohmann::json unrecognizedRequestBody()
{
- return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
+ return getLog(redfish::registries::Base::Index::unrecognizedRequestBody,
{});
}
@@ -1278,7 +1278,7 @@
*/
nlohmann::json resourceMissingAtURI(const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::resourceMissingAtURI,
+ return getLog(redfish::registries::Base::Index::resourceMissingAtURI,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1300,7 +1300,7 @@
const boost::urls::url_view_base& arg1)
{
return getLog(
- redfish::registries::base::Index::resourceAtUriInUnknownFormat,
+ redfish::registries::Base::Index::resourceAtUriInUnknownFormat,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1321,7 +1321,7 @@
nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view_base& arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
+ return getLog(redfish::registries::Base::Index::resourceAtUriUnauthorized,
std::to_array<std::string_view>({arg1.buffer(), arg2}));
}
@@ -1343,7 +1343,7 @@
nlohmann::json couldNotEstablishConnection(
const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
+ return getLog(redfish::registries::Base::Index::couldNotEstablishConnection,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1365,7 +1365,7 @@
const boost::urls::url_view_base& arg1, std::string_view arg2)
{
return getLog(
- redfish::registries::base::Index::sourceDoesNotSupportProtocol,
+ redfish::registries::Base::Index::sourceDoesNotSupportProtocol,
std::to_array<std::string_view>({arg1.buffer(), arg2}));
}
@@ -1387,7 +1387,7 @@
*/
nlohmann::json accessDenied(const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::accessDenied,
+ return getLog(redfish::registries::Base::Index::accessDenied,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1407,7 +1407,7 @@
nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
{
return getLog(
- redfish::registries::base::Index::serviceTemporarilyUnavailable,
+ redfish::registries::Base::Index::serviceTemporarilyUnavailable,
std::to_array({arg1}));
}
@@ -1428,7 +1428,7 @@
nlohmann::json invalidIndex(uint64_t arg1)
{
std::string arg1Str = std::to_string(arg1);
- return getLog(redfish::registries::base::Index::invalidIndex,
+ return getLog(redfish::registries::Base::Index::invalidIndex,
std::to_array<std::string_view>({arg1Str}));
}
@@ -1450,7 +1450,7 @@
{
std::string arg2Str =
arg2.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::propertyValueModified,
+ return getLog(redfish::registries::Base::Index::propertyValueModified,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -1470,7 +1470,7 @@
*/
nlohmann::json resourceInStandby()
{
- return getLog(redfish::registries::base::Index::resourceInStandby, {});
+ return getLog(redfish::registries::Base::Index::resourceInStandby, {});
}
void resourceInStandby(crow::Response& res)
@@ -1488,7 +1488,7 @@
*/
nlohmann::json resourceExhaustion(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::resourceExhaustion,
+ return getLog(redfish::registries::Base::Index::resourceExhaustion,
std::to_array({arg1}));
}
@@ -1508,7 +1508,7 @@
nlohmann::json stringValueTooLong(std::string_view arg1, uint64_t arg2)
{
std::string arg2Str = std::to_string(arg2);
- return getLog(redfish::registries::base::Index::stringValueTooLong,
+ return getLog(redfish::registries::Base::Index::stringValueTooLong,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -1528,7 +1528,7 @@
*/
nlohmann::json stringValueTooShort(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::stringValueTooShort,
+ return getLog(redfish::registries::Base::Index::stringValueTooShort,
std::to_array({arg1, arg2}));
}
@@ -1548,7 +1548,7 @@
*/
nlohmann::json sessionTerminated()
{
- return getLog(redfish::registries::base::Index::sessionTerminated, {});
+ return getLog(redfish::registries::Base::Index::sessionTerminated, {});
}
void sessionTerminated(crow::Response& res)
@@ -1566,7 +1566,7 @@
*/
nlohmann::json subscriptionTerminated()
{
- return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
+ return getLog(redfish::registries::Base::Index::subscriptionTerminated, {});
}
void subscriptionTerminated(crow::Response& res)
@@ -1585,7 +1585,7 @@
nlohmann::json resourceTypeIncompatible(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
+ return getLog(redfish::registries::Base::Index::resourceTypeIncompatible,
std::to_array({arg1, arg2}));
}
@@ -1605,7 +1605,7 @@
*/
nlohmann::json passwordChangeRequired(const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::passwordChangeRequired,
+ return getLog(redfish::registries::Base::Index::passwordChangeRequired,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1625,7 +1625,7 @@
nlohmann::json resetRequired(const boost::urls::url_view_base& arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::resetRequired,
+ return getLog(redfish::registries::Base::Index::resetRequired,
std::to_array<std::string_view>({arg1.buffer(), arg2}));
}
@@ -1645,7 +1645,7 @@
*/
nlohmann::json resetRecommended(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::resetRecommended,
+ return getLog(redfish::registries::Base::Index::resetRecommended,
std::to_array({arg1, arg2}));
}
@@ -1665,7 +1665,7 @@
*/
nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::chassisPowerStateOnRequired,
+ return getLog(redfish::registries::Base::Index::chassisPowerStateOnRequired,
std::to_array({arg1}));
}
@@ -1685,7 +1685,7 @@
nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
{
return getLog(
- redfish::registries::base::Index::chassisPowerStateOffRequired,
+ redfish::registries::Base::Index::chassisPowerStateOffRequired,
std::to_array({arg1}));
}
@@ -1705,7 +1705,7 @@
nlohmann::json propertyValueConflict(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::propertyValueConflict,
+ return getLog(redfish::registries::Base::Index::propertyValueConflict,
std::to_array({arg1, arg2}));
}
@@ -1730,7 +1730,7 @@
std::string arg2Str =
arg2.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
- redfish::registries::base::Index::propertyValueResourceConflict,
+ redfish::registries::Base::Index::propertyValueResourceConflict,
std::to_array<std::string_view>({arg1, arg2Str, arg3.buffer()}));
}
@@ -1756,7 +1756,7 @@
std::string arg2Str =
arg2.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
- redfish::registries::base::Index::propertyValueExternalConflict,
+ redfish::registries::Base::Index::propertyValueExternalConflict,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -1780,7 +1780,7 @@
{
std::string arg2Str =
arg2.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
- return getLog(redfish::registries::base::Index::propertyValueIncorrect,
+ return getLog(redfish::registries::Base::Index::propertyValueIncorrect,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -1800,7 +1800,7 @@
*/
nlohmann::json resourceCreationConflict(const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::resourceCreationConflict,
+ return getLog(redfish::registries::Base::Index::resourceCreationConflict,
std::to_array<std::string_view>({arg1.buffer()}));
}
@@ -1822,7 +1822,7 @@
std::string_view arg2)
{
return getLog(
- redfish::registries::base::Index::actionParameterValueConflict,
+ redfish::registries::Base::Index::actionParameterValueConflict,
std::to_array({arg1, arg2}));
}
@@ -1843,7 +1843,7 @@
*/
nlohmann::json maximumErrorsExceeded()
{
- return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
+ return getLog(redfish::registries::Base::Index::maximumErrorsExceeded, {});
}
void maximumErrorsExceeded(crow::Response& res)
@@ -1861,7 +1861,7 @@
*/
nlohmann::json preconditionFailed()
{
- return getLog(redfish::registries::base::Index::preconditionFailed, {});
+ return getLog(redfish::registries::Base::Index::preconditionFailed, {});
}
void preconditionFailed(crow::Response& res)
@@ -1879,7 +1879,7 @@
*/
nlohmann::json preconditionRequired()
{
- return getLog(redfish::registries::base::Index::preconditionRequired, {});
+ return getLog(redfish::registries::Base::Index::preconditionRequired, {});
}
void preconditionRequired(crow::Response& res)
@@ -1897,7 +1897,7 @@
*/
nlohmann::json headerMissing(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::headerMissing,
+ return getLog(redfish::registries::Base::Index::headerMissing,
std::to_array({arg1}));
}
@@ -1916,7 +1916,7 @@
*/
nlohmann::json headerInvalid(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::headerInvalid,
+ return getLog(redfish::registries::Base::Index::headerInvalid,
std::to_array({arg1}));
}
@@ -1935,7 +1935,7 @@
*/
nlohmann::json operationFailed()
{
- return getLog(redfish::registries::base::Index::operationFailed, {});
+ return getLog(redfish::registries::Base::Index::operationFailed, {});
}
void operationFailed(crow::Response& res)
@@ -1953,7 +1953,7 @@
*/
nlohmann::json operationTimeout()
{
- return getLog(redfish::registries::base::Index::operationTimeout, {});
+ return getLog(redfish::registries::Base::Index::operationTimeout, {});
}
void operationTimeout(crow::Response& res)
@@ -1971,7 +1971,7 @@
*/
nlohmann::json operationNotAllowed()
{
- return getLog(redfish::registries::base::Index::operationNotAllowed, {});
+ return getLog(redfish::registries::Base::Index::operationNotAllowed, {});
}
void operationNotAllowed(crow::Response& res)
@@ -1989,7 +1989,7 @@
*/
nlohmann::json undeterminedFault(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::undeterminedFault,
+ return getLog(redfish::registries::Base::Index::undeterminedFault,
std::to_array({arg1}));
}
@@ -2008,7 +2008,7 @@
*/
nlohmann::json conditionInRelatedResource()
{
- return getLog(redfish::registries::base::Index::conditionInRelatedResource,
+ return getLog(redfish::registries::Base::Index::conditionInRelatedResource,
{});
}
@@ -2027,7 +2027,7 @@
*/
nlohmann::json restrictedRole(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::restrictedRole,
+ return getLog(redfish::registries::Base::Index::restrictedRole,
std::to_array({arg1}));
}
@@ -2046,7 +2046,7 @@
*/
nlohmann::json restrictedPrivilege(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::restrictedPrivilege,
+ return getLog(redfish::registries::Base::Index::restrictedPrivilege,
std::to_array({arg1}));
}
@@ -2065,7 +2065,7 @@
*/
nlohmann::json strictAccountTypes(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::strictAccountTypes,
+ return getLog(redfish::registries::Base::Index::strictAccountTypes,
std::to_array({arg1}));
}
@@ -2084,7 +2084,7 @@
*/
nlohmann::json propertyDeprecated(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::propertyDeprecated,
+ return getLog(redfish::registries::Base::Index::propertyDeprecated,
std::to_array({arg1}));
}
@@ -2103,7 +2103,7 @@
*/
nlohmann::json resourceDeprecated(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::resourceDeprecated,
+ return getLog(redfish::registries::Base::Index::resourceDeprecated,
std::to_array({arg1}));
}
@@ -2123,7 +2123,7 @@
nlohmann::json propertyValueDeprecated(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::base::Index::propertyValueDeprecated,
+ return getLog(redfish::registries::Base::Index::propertyValueDeprecated,
std::to_array({arg1, arg2}));
}
@@ -2143,7 +2143,7 @@
*/
nlohmann::json actionDeprecated(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::actionDeprecated,
+ return getLog(redfish::registries::Base::Index::actionDeprecated,
std::to_array({arg1}));
}
@@ -2163,7 +2163,7 @@
nlohmann::json networkNameResolutionNotConfigured()
{
return getLog(
- redfish::registries::base::Index::networkNameResolutionNotConfigured,
+ redfish::registries::Base::Index::networkNameResolutionNotConfigured,
{});
}
@@ -2183,7 +2183,7 @@
nlohmann::json networkNameResolutionNotSupported()
{
return getLog(
- redfish::registries::base::Index::networkNameResolutionNotSupported,
+ redfish::registries::Base::Index::networkNameResolutionNotSupported,
{});
}
@@ -2202,7 +2202,7 @@
*/
nlohmann::json serviceDisabled(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::serviceDisabled,
+ return getLog(redfish::registries::Base::Index::serviceDisabled,
std::to_array({arg1}));
}
@@ -2221,7 +2221,7 @@
*/
nlohmann::json eventBufferExceeded()
{
- return getLog(redfish::registries::base::Index::eventBufferExceeded, {});
+ return getLog(redfish::registries::Base::Index::eventBufferExceeded, {});
}
void eventBufferExceeded(crow::Response& res)
@@ -2239,7 +2239,7 @@
*/
nlohmann::json authenticationTokenRequired()
{
- return getLog(redfish::registries::base::Index::authenticationTokenRequired,
+ return getLog(redfish::registries::Base::Index::authenticationTokenRequired,
{});
}
@@ -2258,7 +2258,7 @@
*/
nlohmann::json oneTimePasscodeSent(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::oneTimePasscodeSent,
+ return getLog(redfish::registries::Base::Index::oneTimePasscodeSent,
std::to_array({arg1}));
}
@@ -2277,7 +2277,7 @@
*/
nlohmann::json licenseRequired(std::string_view arg1)
{
- return getLog(redfish::registries::base::Index::licenseRequired,
+ return getLog(redfish::registries::Base::Index::licenseRequired,
std::to_array({arg1}));
}
@@ -2296,7 +2296,7 @@
*/
nlohmann::json propertyModified()
{
- return getLog(redfish::registries::base::Index::propertyModified, {});
+ return getLog(redfish::registries::Base::Index::propertyModified, {});
}
void propertyModified(crow::Response& res)
@@ -2314,7 +2314,7 @@
*/
nlohmann::json generateSecretKeyRequired(const boost::urls::url_view_base& arg1)
{
- return getLog(redfish::registries::base::Index::generateSecretKeyRequired,
+ return getLog(redfish::registries::Base::Index::generateSecretKeyRequired,
std::to_array<std::string_view>({arg1.buffer()}));
}
diff --git a/redfish-core/src/heartbeat_messages.cpp b/redfish-core/src/heartbeat_messages.cpp
index 3cef110..2f9575e 100644
--- a/redfish-core/src/heartbeat_messages.cpp
+++ b/redfish-core/src/heartbeat_messages.cpp
@@ -31,16 +31,16 @@
namespace messages
{
-static nlohmann::json getLog(redfish::registries::heartbeat_event::Index name,
+static nlohmann::json getLog(redfish::registries::HeartbeatEvent::Index name,
std::span<const std::string_view> args)
{
size_t index = static_cast<size_t>(name);
- if (index >= redfish::registries::heartbeat_event::registry.size())
+ if (index >= redfish::registries::HeartbeatEvent::registry.size())
{
return {};
}
- return getLogFromRegistry(redfish::registries::heartbeat_event::header,
- redfish::registries::heartbeat_event::registry,
+ return getLogFromRegistry(redfish::registries::HeartbeatEvent::header,
+ redfish::registries::HeartbeatEvent::registry,
index, args);
}
@@ -54,7 +54,7 @@
nlohmann::json redfishServiceFunctional()
{
return getLog(
- redfish::registries::heartbeat_event::Index::redfishServiceFunctional,
+ redfish::registries::HeartbeatEvent::Index::redfishServiceFunctional,
{});
}
diff --git a/redfish-core/src/registries.cpp b/redfish-core/src/registries.cpp
index 1549dd3..2a426bf 100644
--- a/redfish-core/src/registries.cpp
+++ b/redfish-core/src/registries.cpp
@@ -2,11 +2,17 @@
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#include "registries.hpp"
+// We need the registries_selector pulled into some cpp part so that the
+// registration hooks run.
+// NOLINTNEXTLINE(misc-include-cleaner)
#include "registries_selector.hpp"
#include "str_utility.hpp"
#include <algorithm>
#include <cstring>
+#include <functional>
+#include <map>
+#include <optional>
#include <ranges>
#include <span>
#include <string>
@@ -16,6 +22,36 @@
namespace redfish::registries
{
+auto allRegistries() -> std::map<std::string, RegistryEntry>&
+{
+ static std::map<std::string, RegistryEntry> registries;
+ return registries;
+}
+
+auto getRegistryFromPrefix(const std::string& registryName)
+ -> std::optional<RegistryEntryRef>
+{
+ auto& registries = allRegistries();
+ if (auto it = registries.find(registryName); it != registries.end())
+ {
+ return std::ref(it->second);
+ }
+
+ return std::nullopt;
+}
+
+auto getRegistryMessagesFromPrefix(const std::string& registryName)
+ -> MessageEntries
+{
+ auto registry = getRegistryFromPrefix(registryName);
+ if (!registry)
+ {
+ return {};
+ }
+
+ return registry->get().entries;
+}
+
const Message* getMessageFromRegistry(const std::string& messageKey,
std::span<const MessageEntry> registry)
{
@@ -48,9 +84,8 @@
const std::string& messageKey = fields[3];
// Find the right registry and check it for the MessageKey
- // Find the right registry and check it for the MessageKey
return getMessageFromRegistry(messageKey,
- getRegistryFromPrefix(registryName));
+ getRegistryMessagesFromPrefix(registryName));
}
} // namespace redfish::registries
diff --git a/redfish-core/src/resource_messages.cpp b/redfish-core/src/resource_messages.cpp
index 0bda0b0..55fa8ee 100644
--- a/redfish-core/src/resource_messages.cpp
+++ b/redfish-core/src/resource_messages.cpp
@@ -31,16 +31,16 @@
namespace messages
{
-static nlohmann::json getLog(redfish::registries::resource_event::Index name,
+static nlohmann::json getLog(redfish::registries::ResourceEvent::Index name,
std::span<const std::string_view> args)
{
size_t index = static_cast<size_t>(name);
- if (index >= redfish::registries::resource_event::registry.size())
+ if (index >= redfish::registries::ResourceEvent::registry.size())
{
return {};
}
- return getLogFromRegistry(redfish::registries::resource_event::header,
- redfish::registries::resource_event::registry,
+ return getLogFromRegistry(redfish::registries::ResourceEvent::header,
+ redfish::registries::ResourceEvent::registry,
index, args);
}
@@ -53,7 +53,7 @@
*/
nlohmann::json resourceCreated()
{
- return getLog(redfish::registries::resource_event::Index::resourceCreated,
+ return getLog(redfish::registries::ResourceEvent::Index::resourceCreated,
{});
}
@@ -66,7 +66,7 @@
*/
nlohmann::json resourceRemoved()
{
- return getLog(redfish::registries::resource_event::Index::resourceRemoved,
+ return getLog(redfish::registries::ResourceEvent::Index::resourceRemoved,
{});
}
@@ -81,7 +81,7 @@
std::string_view arg2)
{
return getLog(
- redfish::registries::resource_event::Index::resourceErrorsDetected,
+ redfish::registries::ResourceEvent::Index::resourceErrorsDetected,
std::to_array({arg1, arg2}));
}
@@ -96,7 +96,7 @@
std::string_view arg2)
{
return getLog(
- redfish::registries::resource_event::Index::resourceErrorsCorrected,
+ redfish::registries::ResourceEvent::Index::resourceErrorsCorrected,
std::to_array({arg1, arg2}));
}
@@ -110,7 +110,7 @@
nlohmann::json resourceErrorThresholdExceeded(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::
+ return getLog(redfish::registries::ResourceEvent::Index::
resourceErrorThresholdExceeded,
std::to_array({arg1, arg2}));
}
@@ -125,7 +125,7 @@
nlohmann::json resourceErrorThresholdCleared(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::
+ return getLog(redfish::registries::ResourceEvent::Index::
resourceErrorThresholdCleared,
std::to_array({arg1, arg2}));
}
@@ -140,7 +140,7 @@
nlohmann::json resourceWarningThresholdExceeded(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::
+ return getLog(redfish::registries::ResourceEvent::Index::
resourceWarningThresholdExceeded,
std::to_array({arg1, arg2}));
}
@@ -155,7 +155,7 @@
nlohmann::json resourceWarningThresholdCleared(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::
+ return getLog(redfish::registries::ResourceEvent::Index::
resourceWarningThresholdCleared,
std::to_array({arg1, arg2}));
}
@@ -171,7 +171,7 @@
std::string_view arg2)
{
return getLog(
- redfish::registries::resource_event::Index::resourceStatusChangedOK,
+ redfish::registries::ResourceEvent::Index::resourceStatusChangedOK,
std::to_array({arg1, arg2}));
}
@@ -185,9 +185,9 @@
nlohmann::json resourceStatusChangedWarning(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::
- resourceStatusChangedWarning,
- std::to_array({arg1, arg2}));
+ return getLog(
+ redfish::registries::ResourceEvent::Index::resourceStatusChangedWarning,
+ std::to_array({arg1, arg2}));
}
/**
@@ -200,7 +200,7 @@
nlohmann::json resourceStatusChangedCritical(std::string_view arg1,
std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::
+ return getLog(redfish::registries::ResourceEvent::Index::
resourceStatusChangedCritical,
std::to_array({arg1, arg2}));
}
@@ -216,7 +216,7 @@
std::string_view arg2)
{
return getLog(
- redfish::registries::resource_event::Index::resourceStateChanged,
+ redfish::registries::ResourceEvent::Index::resourceStateChanged,
std::to_array({arg1, arg2}));
}
@@ -229,7 +229,7 @@
*/
nlohmann::json resourcePoweredOn(std::string_view arg1)
{
- return getLog(redfish::registries::resource_event::Index::resourcePoweredOn,
+ return getLog(redfish::registries::ResourceEvent::Index::resourcePoweredOn,
std::to_array({arg1}));
}
@@ -242,9 +242,8 @@
*/
nlohmann::json resourcePoweringOn(std::string_view arg1)
{
- return getLog(
- redfish::registries::resource_event::Index::resourcePoweringOn,
- std::to_array({arg1}));
+ return getLog(redfish::registries::ResourceEvent::Index::resourcePoweringOn,
+ std::to_array({arg1}));
}
/**
@@ -256,9 +255,8 @@
*/
nlohmann::json resourcePoweredOff(std::string_view arg1)
{
- return getLog(
- redfish::registries::resource_event::Index::resourcePoweredOff,
- std::to_array({arg1}));
+ return getLog(redfish::registries::ResourceEvent::Index::resourcePoweredOff,
+ std::to_array({arg1}));
}
/**
@@ -271,7 +269,7 @@
nlohmann::json resourcePoweringOff(std::string_view arg1)
{
return getLog(
- redfish::registries::resource_event::Index::resourcePoweringOff,
+ redfish::registries::ResourceEvent::Index::resourcePoweringOff,
std::to_array({arg1}));
}
@@ -284,7 +282,7 @@
*/
nlohmann::json resourcePaused(std::string_view arg1)
{
- return getLog(redfish::registries::resource_event::Index::resourcePaused,
+ return getLog(redfish::registries::ResourceEvent::Index::resourcePaused,
std::to_array({arg1}));
}
@@ -298,7 +296,7 @@
nlohmann::json uRIForResourceChanged()
{
return getLog(
- redfish::registries::resource_event::Index::uRIForResourceChanged, {});
+ redfish::registries::ResourceEvent::Index::uRIForResourceChanged, {});
}
/**
@@ -310,7 +308,7 @@
*/
nlohmann::json resourceChanged()
{
- return getLog(redfish::registries::resource_event::Index::resourceChanged,
+ return getLog(redfish::registries::ResourceEvent::Index::resourceChanged,
{});
}
@@ -324,7 +322,7 @@
nlohmann::json resourceVersionIncompatible(std::string_view arg1)
{
return getLog(
- redfish::registries::resource_event::Index::resourceVersionIncompatible,
+ redfish::registries::ResourceEvent::Index::resourceVersionIncompatible,
std::to_array({arg1}));
}
@@ -338,7 +336,7 @@
nlohmann::json resourceSelfTestFailed(std::string_view arg1)
{
return getLog(
- redfish::registries::resource_event::Index::resourceSelfTestFailed,
+ redfish::registries::ResourceEvent::Index::resourceSelfTestFailed,
std::to_array({arg1}));
}
@@ -352,7 +350,7 @@
nlohmann::json resourceSelfTestCompleted()
{
return getLog(
- redfish::registries::resource_event::Index::resourceSelfTestCompleted,
+ redfish::registries::ResourceEvent::Index::resourceSelfTestCompleted,
{});
}
@@ -365,7 +363,7 @@
*/
nlohmann::json testMessage()
{
- return getLog(redfish::registries::resource_event::Index::testMessage, {});
+ return getLog(redfish::registries::ResourceEvent::Index::testMessage, {});
}
/**
@@ -379,7 +377,7 @@
std::string_view arg2)
{
return getLog(
- redfish::registries::resource_event::Index::aggregationSourceDiscovered,
+ redfish::registries::ResourceEvent::Index::aggregationSourceDiscovered,
std::to_array({arg1, arg2}));
}
@@ -392,7 +390,7 @@
*/
nlohmann::json licenseExpired(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::licenseExpired,
+ return getLog(redfish::registries::ResourceEvent::Index::licenseExpired,
std::to_array({arg1, arg2}));
}
@@ -405,7 +403,7 @@
*/
nlohmann::json licenseChanged(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::licenseChanged,
+ return getLog(redfish::registries::ResourceEvent::Index::licenseChanged,
std::to_array({arg1, arg2}));
}
@@ -418,7 +416,7 @@
*/
nlohmann::json licenseAdded(std::string_view arg1, std::string_view arg2)
{
- return getLog(redfish::registries::resource_event::Index::licenseAdded,
+ return getLog(redfish::registries::ResourceEvent::Index::licenseAdded,
std::to_array({arg1, arg2}));
}
diff --git a/redfish-core/src/task_messages.cpp b/redfish-core/src/task_messages.cpp
index ebc7cf6..1521a4a 100644
--- a/redfish-core/src/task_messages.cpp
+++ b/redfish-core/src/task_messages.cpp
@@ -33,16 +33,16 @@
namespace messages
{
-static nlohmann::json getLog(redfish::registries::task_event::Index name,
+static nlohmann::json getLog(redfish::registries::TaskEvent::Index name,
std::span<const std::string_view> args)
{
size_t index = static_cast<size_t>(name);
- if (index >= redfish::registries::task_event::registry.size())
+ if (index >= redfish::registries::TaskEvent::registry.size())
{
return {};
}
- return getLogFromRegistry(redfish::registries::task_event::header,
- redfish::registries::task_event::registry, index,
+ return getLogFromRegistry(redfish::registries::TaskEvent::header,
+ redfish::registries::TaskEvent::registry, index,
args);
}
@@ -55,7 +55,7 @@
*/
nlohmann::json taskStarted(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskStarted,
+ return getLog(redfish::registries::TaskEvent::Index::taskStarted,
std::to_array({arg1}));
}
@@ -68,7 +68,7 @@
*/
nlohmann::json taskCompletedOK(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskCompletedOK,
+ return getLog(redfish::registries::TaskEvent::Index::taskCompletedOK,
std::to_array({arg1}));
}
@@ -81,7 +81,7 @@
*/
nlohmann::json taskCompletedWarning(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskCompletedWarning,
+ return getLog(redfish::registries::TaskEvent::Index::taskCompletedWarning,
std::to_array({arg1}));
}
@@ -94,7 +94,7 @@
*/
nlohmann::json taskAborted(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskAborted,
+ return getLog(redfish::registries::TaskEvent::Index::taskAborted,
std::to_array({arg1}));
}
@@ -107,7 +107,7 @@
*/
nlohmann::json taskCancelled(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskCancelled,
+ return getLog(redfish::registries::TaskEvent::Index::taskCancelled,
std::to_array({arg1}));
}
@@ -120,7 +120,7 @@
*/
nlohmann::json taskRemoved(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskRemoved,
+ return getLog(redfish::registries::TaskEvent::Index::taskRemoved,
std::to_array({arg1}));
}
@@ -133,7 +133,7 @@
*/
nlohmann::json taskPaused(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskPaused,
+ return getLog(redfish::registries::TaskEvent::Index::taskPaused,
std::to_array({arg1}));
}
@@ -146,7 +146,7 @@
*/
nlohmann::json taskResumed(std::string_view arg1)
{
- return getLog(redfish::registries::task_event::Index::taskResumed,
+ return getLog(redfish::registries::TaskEvent::Index::taskResumed,
std::to_array({arg1}));
}
@@ -160,7 +160,7 @@
nlohmann::json taskProgressChanged(std::string_view arg1, uint64_t arg2)
{
std::string arg2Str = std::to_string(arg2);
- return getLog(redfish::registries::task_event::Index::taskProgressChanged,
+ return getLog(redfish::registries::TaskEvent::Index::taskProgressChanged,
std::to_array<std::string_view>({arg1, arg2Str}));
}