Skip to content

Commit

Permalink
Parse Message Registry header info from the file
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Jason M. Bills authored and edtanous committed May 8, 2019
1 parent 70304cb commit 351d306
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
12 changes: 12 additions & 0 deletions redfish-core/include/registries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
12 changes: 11 additions & 1 deletion redfish-core/include/registries/base_message_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 18 additions & 11 deletions redfish-core/lib/message_registries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ class BaseMessageRegistryFile : public Node
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();
Expand Down Expand Up @@ -144,17 +146,22 @@ class BaseMessageRegistry : public Node
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();

Expand Down
17 changes: 15 additions & 2 deletions scripts/parse_registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
namespace redfish::message_registries::{}
{{
const std::array registry = {{
'''

SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -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))
Expand Down

0 comments on commit 351d306

Please sign in to comment.