Fix errors introduced in Message Registries
A recent commit introduced Service Validator regressions in the
Registries that we use. This was largely because the commits were
structured in a way that was hard to review.
This commit Resolves that, and structures the data memebers in a more
readable way.
Tested:
ran service validator, observed no failures on Registries.
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I7e15899187e333f843e5571ac9908b22624c16e9
diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp
index 970d767..df561ed 100644
--- a/redfish-core/include/registries/openbmc_message_registry.hpp
+++ b/redfish-core/include/registries/openbmc_message_registry.hpp
@@ -846,7 +846,7 @@
.resolution = "None.",
}},
MessageEntry{
- "PCIeFatalReceivedERR_NONFATALMessage",
+ "PCIeFatalReceivedErrNonFatalMessage",
{
.description =
"Indicates a PCIe Received ERR_NONFATAL Message Error.",
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index 31412f3..ef443af 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -46,28 +46,24 @@
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> ¶ms) override
{
- std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
// Collections don't include the static data added by SubRoute because
// it has a duplicate entry for members
- asyncResp->res.jsonValue["@odata.type"] =
- "#MessageRegistryFileCollection.MessageRegistryFileCollection";
- asyncResp->res.jsonValue["@odata.context"] =
- "/redfish/v1/"
- "$metadata#MessageRegistryFileCollection."
- "MessageRegistryFileCollection";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Registries";
- asyncResp->res.jsonValue["Name"] = "MessageRegistryFile Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of MessageRegistryFiles";
- nlohmann::json &messageRegistryFileArray =
- asyncResp->res.jsonValue["Members"];
- messageRegistryFileArray = nlohmann::json::array();
- messageRegistryFileArray.push_back(
- {{"@odata.id", "/redfish/v1/Registries/Base"}});
- messageRegistryFileArray.push_back(
- {{"@odata.id", "/redfish/v1/Registries/OpenBMC"}});
- asyncResp->res.jsonValue["Members@odata.count"] =
- messageRegistryFileArray.size();
+
+ res.jsonValue = {
+ {"@odata.type",
+ "#MessageRegistryFileCollection.MessageRegistryFileCollection"},
+ {"@odata.context", "/redfish/v1/"
+ "$metadata#MessageRegistryFileCollection."
+ "MessageRegistryFileCollection"},
+ {"@odata.id", "/redfish/v1/Registries"},
+ {"Name", "MessageRegistryFile Collection"},
+ {"Description", "Collection of MessageRegistryFiles"},
+ {"Members@odata.count", 2},
+ {"Members",
+ {{{"@odata.id", "/redfish/v1/Registries/Base"}},
+ {{"@odata.id", "/redfish/v1/Registries/OpenBMC"}}}}};
+
+ res.end();
}
};
@@ -91,36 +87,24 @@
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> ¶ms) override
{
- std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
-
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Registries/Base";
- asyncResp->res.jsonValue["@odata.type"] =
- "#MessageRegistryFile.v1_1_0.MessageRegistryFile";
- asyncResp->res.jsonValue["@odata.context"] =
- "/redfish/v1/$metadata#MessageRegistryFile.MessageRegistryFile";
- asyncResp->res.jsonValue["Name"] = "Base Message Registry File";
- asyncResp->res.jsonValue["Description"] =
- "DMTF Base Message Registry File Location";
- 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();
- messageRegistryLanguageArray.push_back({"en"});
- asyncResp->res.jsonValue["Languages@odata.count"] =
- messageRegistryLanguageArray.size();
- nlohmann::json &messageRegistryLocationArray =
- asyncResp->res.jsonValue["Location"];
- messageRegistryLocationArray = nlohmann::json::array();
- messageRegistryLocationArray.push_back(
- {{"Language", "en"},
- {"PublicationUri",
- "https://redfish.dmtf.org/registries/Base.1.4.0.json"},
- {"Uri", "/redfish/v1/Registries/Base/Base"}});
- asyncResp->res.jsonValue["Location@odata.count"] =
- messageRegistryLocationArray.size();
+ res.jsonValue = {
+ {"@odata.id", "/redfish/v1/Registries/Base"},
+ {"@odata.type", "#MessageRegistryFile.v1_1_0.MessageRegistryFile"},
+ {"@odata.context",
+ "/redfish/v1/$metadata#MessageRegistryFile.MessageRegistryFile"},
+ {"Name", "Base Message Registry File"},
+ {"Description", "DMTF Base Message Registry File Location"},
+ {"Id", message_registries::base::header.registryPrefix},
+ {"Registry", message_registries::base::header.id},
+ {"Languages", {"en"}},
+ {"Languages@odata.count", 1},
+ {"Location",
+ {{{"Language", "en"},
+ {"PublicationUri",
+ "https://redfish.dmtf.org/registries/Base.1.4.0.json"},
+ {"Uri", "/redfish/v1/Registries/Base/Base"}}}},
+ {"Location@odata.count", 1}};
+ res.end();
}
};
@@ -144,43 +128,33 @@
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> ¶ms) override
{
- std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
+ res.jsonValue = {
+ {"@Redfish.Copyright", message_registries::base::header.copyright},
+ {"@odata.type", message_registries::base::header.type},
+ {"Id", message_registries::base::header.id},
+ {"Name", message_registries::base::header.name},
+ {"Language", message_registries::base::header.language},
+ {"Description", message_registries::base::header.description},
+ {"RegistryPrefix", message_registries::base::header.registryPrefix},
+ {"RegistryVersion",
+ message_registries::base::header.registryVersion},
+ {"OwningEntity", message_registries::base::header.owningEntity}};
- asyncResp->res.jsonValue["@Redfish.Copyright"] =
- message_registries::base::header.copyright;
- asyncResp->res.jsonValue["@odata.type"] =
- 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"] =
- 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();
+ nlohmann::json &messageObj = res.jsonValue["Messages"];
// Go through the Message Registry and populate each Message
for (const message_registries::MessageEntry &message :
message_registries::base::registry)
{
- messageArray.push_back(
- {{message.first,
- {{"Description", message.second.description},
+ nlohmann::json &obj = messageObj[message.first];
+ obj = {{"Description", message.second.description},
{"Message", message.second.message},
{"Severity", message.second.severity},
{"NumberOfArgs", message.second.numberOfArgs},
- {"Resolution", message.second.resolution}}}});
+ {"Resolution", message.second.resolution}};
if (message.second.numberOfArgs > 0)
{
- nlohmann::json &messageParamArray =
- messageArray.back()[message.first]["ParamTypes"];
+ nlohmann::json &messageParamArray = obj["ParamTypes"];
for (const char *str : message.second.paramTypes)
{
if (str == nullptr)
@@ -191,6 +165,7 @@
}
}
}
+ res.end();
}
};
@@ -214,35 +189,23 @@
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> ¶ms) override
{
- std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
+ res.jsonValue = {
+ {"@odata.id", "/redfish/v1/Registries/OpenBMC"},
+ {"@odata.type", "#MessageRegistryFile.v1_1_0.MessageRegistryFile"},
+ {"@odata.context",
+ "/redfish/v1/$metadata#MessageRegistryFile.MessageRegistryFile"},
+ {"Name", "Open BMC Message Registry File"},
+ {"Description", "Open BMC Message Registry File Location"},
+ {"Id", message_registries::openbmc::header.registryPrefix},
+ {"Registry", message_registries::openbmc::header.id},
+ {"Languages", {"en"}},
+ {"Languages@odata.count", 1},
+ {"Location",
+ {{{"Language", "en"},
+ {"Uri", "/redfish/v1/Registries/OpenBMC/OpenBMC"}}}},
+ {"Location@odata.count", 1}};
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Registries/OpenBMC";
- asyncResp->res.jsonValue["@odata.type"] =
- "#MessageRegistryFile.v1_1_0.MessageRegistryFile";
- asyncResp->res.jsonValue["@odata.context"] =
- "/redfish/v1/$metadata#MessageRegistryFile.MessageRegistryFile";
- asyncResp->res.jsonValue["Name"] = "Open BMC Message Registry File";
- asyncResp->res.jsonValue["Description"] =
- "Open BMC Message Registry File Location";
- asyncResp->res.jsonValue["Id"] =
- message_registries::openbmc::header.registryPrefix;
- asyncResp->res.jsonValue["Registry"] =
- message_registries::openbmc::header.id;
- nlohmann::json &messageRegistryLanguageArray =
- asyncResp->res.jsonValue["Languages"];
- messageRegistryLanguageArray = nlohmann::json::array();
- messageRegistryLanguageArray.push_back({"en"});
- asyncResp->res.jsonValue["Languages@odata.count"] =
- messageRegistryLanguageArray.size();
- nlohmann::json &messageRegistryLocationArray =
- asyncResp->res.jsonValue["Location"];
- messageRegistryLocationArray = nlohmann::json::array();
- messageRegistryLocationArray.push_back(
- {{"Language", "en"},
- {"Uri", "/redfish/v1/Registries/OpenBMC/OpenBMC"}});
- asyncResp->res.jsonValue["Location@odata.count"] =
- messageRegistryLocationArray.size();
+ res.end();
}
};
@@ -266,49 +229,41 @@
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> ¶ms) override
{
- std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
+ res.jsonValue = {
+ {"@Redfish.Copyright",
+ message_registries::openbmc::header.copyright},
+ {"@odata.type", message_registries::openbmc::header.type},
+ {"Id", message_registries::openbmc::header.id},
+ {"Name", message_registries::openbmc::header.name},
+ {"Language", message_registries::openbmc::header.language},
+ {"Description", message_registries::openbmc::header.description},
+ {"RegistryPrefix",
+ message_registries::openbmc::header.registryPrefix},
+ {"RegistryVersion",
+ message_registries::openbmc::header.registryVersion},
+ {"OwningEntity", message_registries::openbmc::header.owningEntity}};
- asyncResp->res.jsonValue["@Redfish.Copyright"] =
- message_registries::openbmc::header.copyright;
- asyncResp->res.jsonValue["@odata.type"] =
- message_registries::openbmc::header.type;
- asyncResp->res.jsonValue["Id"] = message_registries::openbmc::header.id;
- asyncResp->res.jsonValue["Name"] =
- message_registries::openbmc::header.name;
- asyncResp->res.jsonValue["Language"] =
- message_registries::openbmc::header.language;
- asyncResp->res.jsonValue["Description"] =
- message_registries::openbmc::header.description;
- asyncResp->res.jsonValue["RegistryPrefix"] =
- message_registries::openbmc::header.registryPrefix;
- asyncResp->res.jsonValue["RegistryVersion"] =
- message_registries::openbmc::header.registryVersion;
- asyncResp->res.jsonValue["OwningEntity"] =
- message_registries::openbmc::header.owningEntity;
- nlohmann::json &messageArray = asyncResp->res.jsonValue["Messages"];
- messageArray = nlohmann::json::array();
-
+ nlohmann::json &messageObj = res.jsonValue["Messages"];
// Go through the Message Registry and populate each Message
for (const message_registries::MessageEntry &message :
message_registries::openbmc::registry)
{
- messageArray.push_back(
- {{message.first,
- {{"Description", message.second.description},
+ nlohmann::json &obj = messageObj[message.first];
+ obj = {{"Description", message.second.description},
{"Message", message.second.message},
{"Severity", message.second.severity},
{"NumberOfArgs", message.second.numberOfArgs},
- {"Resolution", message.second.resolution}}}});
+ {"Resolution", message.second.resolution}};
if (message.second.numberOfArgs > 0)
{
- nlohmann::json &messageParamArray =
- messageArray.back()[message.first]["ParamTypes"];
+ nlohmann::json &messageParamArray = obj["ParamTypes"];
for (int i = 0; i < message.second.numberOfArgs; i++)
{
messageParamArray.push_back(message.second.paramTypes[i]);
}
}
}
+ res.end();
}
};