Parse Message Registry header info from the file
This extends the Message Registry parsing to include header
details that are part of the redfish resource.
Tested:
Verified that the MessageRegistry info all returns correctly
in the redfish response.
Change-Id: I6179c07f4067cd4520fce3e774d18530fede0a95
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/redfish-core/include/registries.hpp b/redfish-core/include/registries.hpp
index 7ee5232..6b30be9 100644
--- a/redfish-core/include/registries.hpp
+++ b/redfish-core/include/registries.hpp
@@ -16,6 +16,18 @@
#pragma once
namespace redfish::message_registries
{
+struct Header
+{
+ const char* copyright;
+ const char* type;
+ const char* id;
+ const char* name;
+ const char* language;
+ const char* description;
+ const char* registryPrefix;
+ const char* registryVersion;
+ const char* owningEntity;
+};
struct Message
{
diff --git a/redfish-core/include/registries/base_message_registry.hpp b/redfish-core/include/registries/base_message_registry.hpp
index 1d54fdd..472f51e 100644
--- a/redfish-core/include/registries/base_message_registry.hpp
+++ b/redfish-core/include/registries/base_message_registry.hpp
@@ -22,7 +22,17 @@
namespace redfish::message_registries::base
{
-
+const Header header = {
+ .copyright = "Copyright 2014-2018 DMTF. All rights reserved.",
+ .type = "#MessageRegistry.v1_0_0.MessageRegistry",
+ .id = "Base.1.4.0",
+ .name = "Base Message Registry",
+ .language = "en",
+ .description = "This registry defines the base messages for Redfish",
+ .registryPrefix = "Base",
+ .registryVersion = "1.4.0",
+ .owningEntity = "DMTF",
+};
const std::array registry = {
MessageEntry{
"AccessDenied",
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index f01caf9..e44e97d 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -100,8 +100,10 @@
asyncResp->res.jsonValue["Name"] = "Base Message Registry File";
asyncResp->res.jsonValue["Description"] =
"DMTF Base Message Registry File Location";
- asyncResp->res.jsonValue["Id"] = "Base";
- asyncResp->res.jsonValue["Registry"] = "Base.1.4";
+ asyncResp->res.jsonValue["Id"] =
+ message_registries::base::header.registryPrefix;
+ asyncResp->res.jsonValue["Registry"] =
+ message_registries::base::header.id;
nlohmann::json &messageRegistryLanguageArray =
asyncResp->res.jsonValue["Languages"];
messageRegistryLanguageArray = nlohmann::json::array();
@@ -144,17 +146,22 @@
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
asyncResp->res.jsonValue["@Redfish.Copyright"] =
- "Copyright 2014-2018 DMTF. All rights reserved.";
+ message_registries::base::header.copyright;
asyncResp->res.jsonValue["@odata.type"] =
- "#MessageRegistry.v1_0_0.MessageRegistry";
- asyncResp->res.jsonValue["Id"] = "Base.1.4.0";
- asyncResp->res.jsonValue["Name"] = "Base Message Registry";
- asyncResp->res.jsonValue["Language"] = "en";
+ message_registries::base::header.type;
+ asyncResp->res.jsonValue["Id"] = message_registries::base::header.id;
+ asyncResp->res.jsonValue["Name"] =
+ message_registries::base::header.name;
+ asyncResp->res.jsonValue["Language"] =
+ message_registries::base::header.language;
asyncResp->res.jsonValue["Description"] =
- "This registry defines the base messages for Redfish";
- asyncResp->res.jsonValue["RegistryPrefix"] = "Base";
- asyncResp->res.jsonValue["RegistryVersion"] = "1.4.0";
- asyncResp->res.jsonValue["OwningEntity"] = "DMTF";
+ message_registries::base::header.description;
+ asyncResp->res.jsonValue["RegistryPrefix"] =
+ message_registries::base::header.registryPrefix;
+ asyncResp->res.jsonValue["RegistryVersion"] =
+ message_registries::base::header.registryVersion;
+ asyncResp->res.jsonValue["OwningEntity"] =
+ message_registries::base::header.owningEntity;
nlohmann::json &messageArray = asyncResp->res.jsonValue["Messages"];
messageArray = nlohmann::json::array();
diff --git a/scripts/parse_registries.py b/scripts/parse_registries.py
index d9d6cf3..3eff312 100644
--- a/scripts/parse_registries.py
+++ b/scripts/parse_registries.py
@@ -37,8 +37,6 @@
namespace redfish::message_registries::{}
{{
-
-const std::array registry = {{
'''
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -65,6 +63,21 @@
with open(file, 'w') as registry:
registry.write(REGISTRY_HEADER.format(namespace))
+ # Parse the Registry header info
+ registry.write("const Header header = {")
+ registry.write(".copyright = \"{}\",".format(json["@Redfish.Copyright"]))
+ registry.write(".type = \"{}\",".format(json["@odata.type"]))
+ registry.write(".id = \"{}\",".format(json["Id"]))
+ registry.write(".name = \"{}\",".format(json["Name"]))
+ registry.write(".language = \"{}\",".format(json["Language"]))
+ registry.write(".description = \"{}\",".format(json["Description"]))
+ registry.write(".registryPrefix = \"{}\",".format(json["RegistryPrefix"]))
+ registry.write(".registryVersion = \"{}\",".format(json["RegistryVersion"]))
+ registry.write(".owningEntity = \"{}\",".format(json["OwningEntity"]))
+ registry.write("};")
+
+ # Parse each Message entry
+ registry.write("const std::array registry = {")
for messageId, message in sorted(json["Messages"].items()):
registry.write("MessageEntry{")
registry.write("\"{}\",".format(messageId))