Generate heartbeat registry
Generate the heartbeat registry, and adjust the #includes of the
other generated registries.
Tested: Redfish service validator succeeds.
Change-Id: Iedbf1ae8dc6559666691f1feb71af08e856d5c80
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/meson.build b/meson.build
index 4c58262..093e60f 100644
--- a/meson.build
+++ b/meson.build
@@ -356,15 +356,16 @@
'http/mutual_tls.cpp',
'redfish-core/src/dbus_log_watcher.cpp',
'redfish-core/src/error_messages.cpp',
- 'redfish-core/src/resource_messages.cpp',
- 'redfish-core/src/task_messages.cpp',
'redfish-core/src/event_log.cpp',
'redfish-core/src/filesystem_log_watcher.cpp',
'redfish-core/src/filter_expr_executor.cpp',
'redfish-core/src/filter_expr_printer.cpp',
+ 'redfish-core/src/heartbeat_messages.cpp',
'redfish-core/src/redfish.cpp',
'redfish-core/src/registries.cpp',
+ 'redfish-core/src/resource_messages.cpp',
'redfish-core/src/subscription.cpp',
+ 'redfish-core/src/task_messages.cpp',
'redfish-core/src/utils/dbus_utils.cpp',
'redfish-core/src/utils/json_utils.cpp',
'redfish-core/src/utils/time_utils.cpp',
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 2b4a156..d9a3bb3 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -15,9 +15,7 @@
#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
-#include <cstdint>
#include <source_location>
-#include <string>
#include <string_view>
// IWYU pragma: no_forward_declare crow::Response
diff --git a/redfish-core/include/heartbeat_messages.hpp b/redfish-core/include/heartbeat_messages.hpp
index 0d4839b..709dbe1 100644
--- a/redfish-core/include/heartbeat_messages.hpp
+++ b/redfish-core/include/heartbeat_messages.hpp
@@ -1,38 +1,31 @@
#pragma once
-#include "registries/heartbeat_event_message_registry.hpp"
+/****************************************************************
+ * READ THIS WARNING FIRST
+ * This is an auto-generated header which contains definitions
+ * for Redfish DMTF defined messages.
+ * DO NOT modify this registry outside of running the
+ * parse_registries.py script. The definitions contained within
+ * this file are owned by DMTF. Any modifications to these files
+ * should be first pushed to the relevant registry in the DMTF
+ * github organization.
+ ***************************************************************/
+#include "http_response.hpp"
+
+#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
-#include <array>
-#include <span>
+#include <source_location>
#include <string_view>
-namespace redfish::messages
+// IWYU pragma: no_forward_declare crow::Response
+
+namespace redfish
{
-inline nlohmann::json
- getLogHeartbeat(redfish::registries::heartbeat_event::Index name,
- std::span<const std::string_view> args)
+namespace messages
{
- size_t index = static_cast<size_t>(name);
- if (index >= redfish::registries::heartbeat_event::registry.size())
- {
- return {};
- }
- return getLogFromRegistry(redfish::registries::heartbeat_event::header,
- redfish::registries::heartbeat_event::registry,
- index, args);
+nlohmann::json redfishServiceFunctional();
+
}
-
-/**
- * @brief Formats RedfishServiceFunctional message into JSON
- * Message body: "Redfish service is functional."
- *
- * @returns Message RedfishServiceFunctional formatted to JSON */
-inline nlohmann::json redfishServiceFunctional()
-{
- return getLogHeartbeat(
- registries::heartbeat_event::Index::redfishServiceFunctional, {});
-}
-
-} // namespace redfish::messages
+} // namespace redfish
diff --git a/redfish-core/include/resource_messages.hpp b/redfish-core/include/resource_messages.hpp
index dd3c280..aab01a4 100644
--- a/redfish-core/include/resource_messages.hpp
+++ b/redfish-core/include/resource_messages.hpp
@@ -15,9 +15,7 @@
#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
-#include <cstdint>
#include <source_location>
-#include <string>
#include <string_view>
// IWYU pragma: no_forward_declare crow::Response
diff --git a/redfish-core/include/task_messages.hpp b/redfish-core/include/task_messages.hpp
index 36d4721..d7a02fe 100644
--- a/redfish-core/include/task_messages.hpp
+++ b/redfish-core/include/task_messages.hpp
@@ -15,9 +15,7 @@
#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
-#include <cstdint>
#include <source_location>
-#include <string>
#include <string_view>
// IWYU pragma: no_forward_declare crow::Response
diff --git a/redfish-core/src/heartbeat_messages.cpp b/redfish-core/src/heartbeat_messages.cpp
new file mode 100644
index 0000000..3cef110
--- /dev/null
+++ b/redfish-core/src/heartbeat_messages.cpp
@@ -0,0 +1,62 @@
+/****************************************************************
+ * READ THIS WARNING FIRST
+ * This is an auto-generated header which contains definitions
+ * for Redfish DMTF defined messages.
+ * DO NOT modify this registry outside of running the
+ * parse_registries.py script. The definitions contained within
+ * this file are owned by DMTF. Any modifications to these files
+ * should be first pushed to the relevant registry in the DMTF
+ * github organization.
+ ***************************************************************/
+#include "heartbeat_messages.hpp"
+
+#include "registries.hpp"
+#include "registries/heartbeat_event_message_registry.hpp"
+
+#include <nlohmann/json.hpp>
+
+#include <array>
+#include <cstddef>
+#include <span>
+#include <string_view>
+
+// Clang can't seem to decide whether this header needs to be included or not,
+// and is inconsistent. Include it for now
+// NOLINTNEXTLINE(misc-include-cleaner)
+#include <utility>
+
+namespace redfish
+{
+
+namespace messages
+{
+
+static nlohmann::json getLog(redfish::registries::heartbeat_event::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())
+ {
+ return {};
+ }
+ return getLogFromRegistry(redfish::registries::heartbeat_event::header,
+ redfish::registries::heartbeat_event::registry,
+ index, args);
+}
+
+/**
+ * @internal
+ * @brief Formats RedfishServiceFunctional message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json redfishServiceFunctional()
+{
+ return getLog(
+ redfish::registries::heartbeat_event::Index::redfishServiceFunctional,
+ {});
+}
+
+} // namespace messages
+} // namespace redfish
diff --git a/scripts/parse_registries.py b/scripts/parse_registries.py
index fda2124..13fb52a 100755
--- a/scripts/parse_registries.py
+++ b/scripts/parse_registries.py
@@ -419,9 +419,7 @@
#include <boost/url/url_view_base.hpp>
#include <nlohmann/json.hpp>
-#include <cstdint>
#include <source_location>
-#include <string>
#include <string_view>
// IWYU pragma: no_forward_declare crow::Response
@@ -508,7 +506,7 @@
headers.append("<cstddef>")
headers.append("<span>")
- if registry_name != "ResourceEvent":
+ if registry_name not in ("ResourceEvent", "HeartbeatEvent"):
headers.append("<cstdint>")
headers.append("<string>")
headers.append("<string_view>")
@@ -795,6 +793,13 @@
files[0], dmtf_registries[0][1], "Base", "base", "error"
)
create_error_registry(
+ files[5],
+ dmtf_registries[5][1],
+ "HeartbeatEvent",
+ "heartbeat_event",
+ "heartbeat",
+ )
+ create_error_registry(
files[12],
dmtf_registries[12][1],
"ResourceEvent",