Remove brace initialization of json objects
Brace initialization of json objects, while quite interesting from an
academic sense, are very difficult for people to grok, and lead to
inconsistencies. This patchset aims to remove a majority of them in
lieu of operator[]. Interestingly, this saves about 1% of the binary
size of bmcweb.
This also has an added benefit that as a design pattern, we're never
constructing a new object, then moving it into place, we're always
adding to the existing object, which in the future _could_ make things
like OEM schemas or properties easier, as there's no case where we're
completely replacing the response object.
Tested:
Ran redfish service validator. No new failures.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 58bf257..4e50e4b 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -253,14 +253,14 @@
}
// Fill in the log entry with the gathered data
- logEntryJson = {{"EventId", logEntryID},
- {"EventType", "Event"},
- {"Severity", std::move(severity)},
- {"Message", std::move(msg)},
- {"MessageId", messageID},
- {"MessageArgs", messageArgs},
- {"EventTimestamp", std::move(timestamp)},
- {"Context", customText}};
+ logEntryJson["EventId"] = logEntryID;
+ logEntryJson["EventType"] = "Event";
+ logEntryJson["Severity"] = std::move(severity);
+ logEntryJson["Message"] = std::move(msg);
+ logEntryJson["MessageId"] = messageID;
+ logEntryJson["MessageArgs"] = messageArgs;
+ logEntryJson["EventTimestamp"] = std::move(timestamp);
+ logEntryJson["Context"] = customText;
return 0;
}
@@ -419,10 +419,11 @@
{"EventTimestamp", crow::utility::getDateTimeOffsetNow().first},
{"Context", customText}};
- nlohmann::json msg = {{"@odata.type", "#Event.v1_4_0.Event"},
- {"Id", std::to_string(eventSeqNum)},
- {"Name", "Event Log"},
- {"Events", logEntryArray}};
+ nlohmann::json msg;
+ msg["@odata.type"] = "#Event.v1_4_0.Event";
+ msg["Id"] = std::to_string(eventSeqNum);
+ msg["Name"] = "Event Log";
+ msg["Events"] = logEntryArray;
std::string strMsg =
msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
@@ -487,10 +488,11 @@
return;
}
- nlohmann::json msg = {{"@odata.type", "#Event.v1_4_0.Event"},
- {"Id", std::to_string(eventSeqNum)},
- {"Name", "Event Log"},
- {"Events", logEntryArray}};
+ nlohmann::json msg;
+ msg["@odata.type"] = "#Event.v1_4_0.Event";
+ msg["Id"] = std::to_string(eventSeqNum);
+ msg["Name"] = "Event Log";
+ msg["Events"] = logEntryArray;
std::string strMsg =
msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index 2cb2f3d..f4e37b5 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -68,7 +68,9 @@
std::string newPath = collectionPath;
newPath += '/';
newPath += leaf;
- members.push_back({{"@odata.id", std::move(newPath)}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] = std::move(newPath);
+ members.push_back(std::move(member));
}
aResp->res.jsonValue["Members@odata.count"] = members.size();
},
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 8d53799..e675e82 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -160,24 +160,23 @@
{
std::string service =
(ldapType == "LDAP") ? "LDAPService" : "ActiveDirectoryService";
- nlohmann::json ldap = {
- {"ServiceEnabled", confData.serviceEnabled},
- {"ServiceAddresses", nlohmann::json::array({confData.uri})},
- {"Authentication",
- {{"AuthenticationType", "UsernameAndPassword"},
- {"Username", confData.bindDN},
- {"Password", nullptr}}},
- {"LDAPService",
- {{"SearchSettings",
- {{"BaseDistinguishedNames",
- nlohmann::json::array({confData.baseDN})},
- {"UsernameAttribute", confData.userNameAttribute},
- {"GroupsAttribute", confData.groupAttribute}}}}},
- };
- jsonResponse[ldapType].update(ldap);
+ nlohmann::json& ldap = jsonResponse[ldapType];
- nlohmann::json& roleMapArray = jsonResponse[ldapType]["RemoteRoleMapping"];
+ ldap["ServiceEnabled"] = confData.serviceEnabled;
+ ldap["ServiceAddresses"] = nlohmann::json::array({confData.uri});
+ ldap["Authentication"]["AuthenticationType"] = "UsernameAndPassword";
+ ldap["Authentication"]["Username"] = confData.bindDN;
+ ldap["Authentication"]["Password"] = nullptr;
+
+ ldap["LDAPService"]["SearchSettings"]["BaseDistinguishedNames"] =
+ nlohmann::json::array({confData.baseDN});
+ ldap["LDAPService"]["SearchSettings"]["UsernameAttribute"] =
+ confData.userNameAttribute;
+ ldap["LDAPService"]["SearchSettings"]["GroupsAttribute"] =
+ confData.groupAttribute;
+
+ nlohmann::json& roleMapArray = ldap["RemoteRoleMapping"];
roleMapArray = nlohmann::json::array();
for (const auto& obj : confData.groupRoleList)
{
@@ -357,9 +356,10 @@
nlohmann::json& remoteRoleJson =
asyncResp->res
.jsonValue[serverType]["RemoteRoleMapping"];
- remoteRoleJson.push_back(
- {{"LocalRole", *localRole},
- {"RemoteGroup", *remoteGroup}});
+ nlohmann::json::object_t roleMapEntry;
+ roleMapEntry["LocalRole"] = *localRole;
+ roleMapEntry["RemoteGroup"] = *remoteGroup;
+ remoteRoleJson.push_back(std::move(roleMapEntry));
},
ldapDbusService, dbusObjectPath, ldapPrivMapperInterface,
"Create", *remoteGroup,
@@ -1274,30 +1274,33 @@
persistent_data::SessionStore::getInstance()
.getAuthMethodsConfig();
- asyncResp->res.jsonValue = {
- {"@odata.id", "/redfish/v1/AccountService"},
- {"@odata.type", "#AccountService."
- "v1_10_0.AccountService"},
- {"Id", "AccountService"},
- {"Name", "Account Service"},
- {"Description", "Account Service"},
- {"ServiceEnabled", true},
- {"MaxPasswordLength", 20},
- {"Accounts",
- {{"@odata.id", "/redfish/v1/AccountService/Accounts"}}},
- {"Roles", {{"@odata.id", "/redfish/v1/AccountService/Roles"}}},
- {"Oem",
- {{"OpenBMC",
- {{"@odata.type", "#OemAccountService.v1_0_0.AccountService"},
- {"@odata.id", "/redfish/v1/AccountService#/Oem/OpenBMC"},
- {"AuthMethods",
- {
- {"BasicAuth", authMethodsConfig.basic},
- {"SessionToken", authMethodsConfig.sessionToken},
- {"XToken", authMethodsConfig.xtoken},
- {"Cookie", authMethodsConfig.cookie},
- {"TLS", authMethodsConfig.tls},
- }}}}}}};
+ nlohmann::json& json = asyncResp->res.jsonValue;
+ json["@odata.id"] = "/redfish/v1/AccountService";
+ json["@odata.type"] = "#AccountService."
+ "v1_10_0.AccountService";
+ json["Id"] = "AccountService";
+ json["Name"] = "Account Service";
+ json["Description"] = "Account Service";
+ json["ServiceEnabled"] = true;
+ json["MaxPasswordLength"] = 20;
+ json["Accounts"]["@odata.id"] =
+ "/redfish/v1/AccountService/Accounts";
+ json["Roles"]["@odata.id"] = "/redfish/v1/AccountService/Roles";
+ json["Oem"]["OpenBMC"]["@odata.type"] =
+ "#OemAccountService.v1_0_0.AccountService";
+ json["Oem"]["OpenBMC"]["@odata.id"] =
+ "/redfish/v1/AccountService#/Oem/OpenBMC";
+ json["Oem"]["OpenBMC"]["AuthMethods"]["BasicAuth"] =
+ authMethodsConfig.basic;
+ json["Oem"]["OpenBMC"]["AuthMethods"]["SessionToken"] =
+ authMethodsConfig.sessionToken;
+ json["Oem"]["OpenBMC"]["AuthMethods"]["XToken"] =
+ authMethodsConfig.xtoken;
+ json["Oem"]["OpenBMC"]["AuthMethods"]["Cookie"] =
+ authMethodsConfig.cookie;
+ json["Oem"]["OpenBMC"]["AuthMethods"]["TLS"] =
+ authMethodsConfig.tls;
+
// /redfish/v1/AccountService/LDAP/Certificates is something only
// ConfigureManager can access then only display when the user has
// permissions ConfigureManager
@@ -1307,10 +1310,8 @@
if (isOperationAllowedWithPrivileges({{"ConfigureManager"}},
effectiveUserPrivileges))
{
- asyncResp->res.jsonValue["LDAP"] = {
- {"Certificates",
- {{"@odata.id",
- "/redfish/v1/AccountService/LDAP/Certificates"}}}};
+ asyncResp->res.jsonValue["LDAP"]["Certificates"]["@odata.id"] =
+ "/redfish/v1/AccountService/LDAP/Certificates";
}
crow::connections::systemBus->async_method_call(
[asyncResp](
@@ -1511,12 +1512,14 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id", "/redfish/v1/AccountService/Accounts"},
- {"@odata.type", "#ManagerAccountCollection."
- "ManagerAccountCollection"},
- {"Name", "Accounts Collection"},
- {"Description", "BMC User Accounts"}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Accounts";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ManagerAccountCollection."
+ "ManagerAccountCollection";
+ asyncResp->res.jsonValue["Name"] = "Accounts Collection";
+ asyncResp->res.jsonValue["Description"] = "BMC User Accounts";
Privileges effectiveUserPrivileges =
redfish::getUserPrivileges(req.userRole);
@@ -1567,10 +1570,11 @@
if (userCanSeeAllAccounts ||
(thisUser == user && userCanSeeSelf))
{
- memberArray.push_back(
- {{"@odata.id",
- "/redfish/v1/AccountService/Accounts/" +
- user}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/AccountService/Accounts/" +
+ user;
+ memberArray.push_back(std::move(member));
}
}
asyncResp->res.jsonValue["Members@odata.count"] =
@@ -1772,13 +1776,12 @@
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#ManagerAccount.v1_4_0.ManagerAccount"},
- {"Name", "User Account"},
- {"Description", "User Account"},
- {"Password", nullptr},
- {"AccountTypes", {"Redfish"}}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ManagerAccount.v1_4_0.ManagerAccount";
+ asyncResp->res.jsonValue["Name"] = "User Account";
+ asyncResp->res.jsonValue["Description"] = "User Account";
+ asyncResp->res.jsonValue["Password"] = nullptr;
+ asyncResp->res.jsonValue["AccountTypes"] = {"Redfish"};
for (const auto& interface : userIt->second)
{
@@ -1843,10 +1846,12 @@
}
asyncResp->res.jsonValue["RoleId"] = role;
- asyncResp->res.jsonValue["Links"]["Role"] =
- {{"@odata.id",
- "/redfish/v1/AccountService/Roles/" +
- role}};
+ nlohmann::json& roleEntry =
+ asyncResp->res
+ .jsonValue["Links"]["Role"];
+ roleEntry["@odata.id"] =
+ "/redfish/v1/AccountService/Roles/" +
+ role;
}
else if (property.first ==
"UserPasswordExpired")
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 934f901..4ac3762 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -54,13 +54,15 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#CertificateService.v1_0_0.CertificateService"},
- {"@odata.id", "/redfish/v1/CertificateService"},
- {"Id", "CertificateService"},
- {"Name", "Certificate Service"},
- {"Description", "Actions available to manage certificates"}};
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#CertificateService.v1_0_0.CertificateService";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/CertificateService";
+ asyncResp->res.jsonValue["Id"] = "CertificateService";
+ asyncResp->res.jsonValue["Name"] = "Certificate Service";
+ asyncResp->res.jsonValue["Description"] =
+ "Actions available to manage certificates";
// /redfish/v1/CertificateService/CertificateLocations is something
// only ConfigureManager can access then only display when the user
// has permissions ConfigureManager
@@ -69,9 +71,8 @@
if (isOperationAllowedWithPrivileges({{"ConfigureManager"}},
effectiveUserPrivileges))
{
- asyncResp->res.jsonValue["CertificateLocations"] = {
- {"@odata.id",
- "/redfish/v1/CertificateService/CertificateLocations"}};
+ asyncResp->res.jsonValue["CertificateLocations"]["@odata.id"] =
+ "/redfish/v1/CertificateService/CertificateLocations";
}
asyncResp->res
.jsonValue["Actions"]
@@ -234,8 +235,8 @@
return;
}
asyncResp->res.jsonValue["CSRString"] = csr;
- asyncResp->res.jsonValue["CertificateCollection"] = {
- {"@odata.id", certURI}};
+ asyncResp->res.jsonValue["CertificateCollection"]["@odata.id"] =
+ certURI;
},
service, csrObjPath, "xyz.openbmc_project.Certs.CSR", "CSR");
}
@@ -592,12 +593,12 @@
std::to_string(certId));
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id", certURL},
- {"@odata.type", "#Certificate.v1_0_0.Certificate"},
- {"Id", std::to_string(certId)},
- {"Name", name},
- {"Description", name}};
+ asyncResp->res.jsonValue["@odata.id"] = certURL;
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#Certificate.v1_0_0.Certificate";
+ asyncResp->res.jsonValue["Id"] = std::to_string(certId);
+ asyncResp->res.jsonValue["Name"] = name;
+ asyncResp->res.jsonValue["Description"] = name;
for (const auto& property : properties)
{
if (property.first == "CertificateString")
@@ -856,12 +857,14 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"},
- {"@odata.type", "#CertificateCollection.CertificateCollection"},
- {"Name", "HTTPS Certificates Collection"},
- {"Description", "A Collection of HTTPS certificate instances"}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#CertificateCollection.CertificateCollection";
+ asyncResp->res.jsonValue["Name"] = "HTTPS Certificates Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "A Collection of HTTPS certificate instances";
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
@@ -880,10 +883,11 @@
long id = getIDFromURL(cert.first.str);
if (id >= 0)
{
- members.push_back(
- {{"@odata.id",
- "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/" +
- std::to_string(id)}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/" +
+ std::to_string(id);
+ members.push_back(std::move(member));
}
}
asyncResp->res.jsonValue["Members@odata.count"] =
@@ -907,8 +911,8 @@
}
BMCWEB_LOG_DEBUG << "HTTPSCertificateCollection::doPost";
- asyncResp->res.jsonValue = {{"Name", "HTTPS Certificate"},
- {"Description", "HTTPS Certificate"}};
+ asyncResp->res.jsonValue["Name"] = "HTTPS Certificate";
+ asyncResp->res.jsonValue["Description"] = "HTTPS Certificate";
std::string certFileBody =
getCertificateFromReqBody(asyncResp, req);
@@ -987,8 +991,9 @@
long id = getIDFromURL(cert.first.str);
if (id >= 0)
{
- links.push_back(
- {{"@odata.id", certURL + std::to_string(id)}});
+ nlohmann::json::object_t link;
+ link["@odata.id"] = certURL + std::to_string(id);
+ links.push_back(std::move(link));
}
}
asyncResp->res.jsonValue["Links"]["Certificates@odata.count"] =
@@ -1013,16 +1018,15 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id",
- "/redfish/v1/CertificateService/CertificateLocations"},
- {"@odata.type",
- "#CertificateLocations.v1_0_0.CertificateLocations"},
- {"Name", "Certificate Locations"},
- {"Id", "CertificateLocations"},
- {"Description",
- "Defines a resource that an administrator can use in order to "
- "locate all certificates installed on a given service"}};
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/CertificateService/CertificateLocations";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#CertificateLocations.v1_0_0.CertificateLocations";
+ asyncResp->res.jsonValue["Name"] = "Certificate Locations";
+ asyncResp->res.jsonValue["Id"] = "CertificateLocations";
+ asyncResp->res.jsonValue["Description"] =
+ "Defines a resource that an administrator can use in order to "
+ "locate all certificates installed on a given service";
nlohmann::json& links =
asyncResp->res.jsonValue["Links"]["Certificates"];
@@ -1056,11 +1060,14 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id", "/redfish/v1/AccountService/LDAP/Certificates"},
- {"@odata.type", "#CertificateCollection.CertificateCollection"},
- {"Name", "LDAP Certificates Collection"},
- {"Description", "A Collection of LDAP certificate instances"}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/LDAP/Certificates";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#CertificateCollection.CertificateCollection";
+ asyncResp->res.jsonValue["Name"] = "LDAP Certificates Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "A Collection of LDAP certificate instances";
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
@@ -1082,10 +1089,11 @@
long id = getIDFromURL(cert.first.str);
if (id >= 0)
{
- members.push_back(
- {{"@odata.id",
- "/redfish/v1/AccountService/LDAP/Certificates/" +
- std::to_string(id)}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/AccountService/LDAP/Certificates/" +
+ std::to_string(id);
+ members.push_back(std::move(member));
}
}
count = members.size();
@@ -1200,13 +1208,15 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/Truststore/Certificates/"},
- {"@odata.type", "#CertificateCollection.CertificateCollection"},
- {"Name", "TrustStore Certificates Collection"},
- {"Description",
- "A Collection of TrustStore certificate instances"}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/Truststore/Certificates/";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#CertificateCollection.CertificateCollection";
+ asyncResp->res.jsonValue["Name"] =
+ "TrustStore Certificates Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "A Collection of TrustStore certificate instances";
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
@@ -1225,10 +1235,11 @@
long id = getIDFromURL(cert.first.str);
if (id >= 0)
{
- members.push_back(
- {{"@odata.id",
- "/redfish/v1/Managers/bmc/Truststore/Certificates/" +
- std::to_string(id)}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/Managers/bmc/Truststore/Certificates/" +
+ std::to_string(id);
+ members.push_back(std::move(member));
}
}
asyncResp->res.jsonValue["Members@odata.count"] =
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 47b5070..1aa7b40 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -94,8 +94,9 @@
return;
}
- aResp->res.jsonValue["PhysicalSecurity"] = {
- {"IntrusionSensorNumber", 1}, {"IntrusionSensor", value}};
+ aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensorNumber"] =
+ 1;
+ aResp->res.jsonValue["PhysicalSecurity"]["IntrusionSensor"] = value;
});
}
@@ -281,15 +282,16 @@
"/redfish/v1/Chassis/" + chassisId;
asyncResp->res.jsonValue["Name"] = "Chassis Collection";
asyncResp->res.jsonValue["ChassisType"] = "RackMount";
- asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"] =
- {{"target", "/redfish/v1/Chassis/" + chassisId +
- "/Actions/Chassis.Reset"},
- {"@Redfish.ActionInfo", "/redfish/v1/Chassis/" +
- chassisId +
- "/ResetActionInfo"}};
- asyncResp->res.jsonValue["PCIeDevices"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices"}};
+ asyncResp->res
+ .jsonValue["Actions"]["#Chassis.Reset"]["target"] =
+ "/redfish/v1/Chassis/" + chassisId +
+ "/Actions/Chassis.Reset";
+ asyncResp->res.jsonValue["Actions"]["#Chassis.Reset"]
+ ["@Redfish.ActionInfo"] =
+ "/redfish/v1/Chassis/" + chassisId +
+ "/ResetActionInfo";
+ asyncResp->res.jsonValue["PCIeDevices"]["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices";
const std::string& connectionName =
connectionNames[0].first;
@@ -384,29 +386,39 @@
asyncResp->res.jsonValue["Name"] = chassisId;
asyncResp->res.jsonValue["Id"] = chassisId;
#ifdef BMCWEB_ALLOW_DEPRECATED_POWER_THERMAL
- asyncResp->res.jsonValue["Thermal"] = {
- {"@odata.id", "/redfish/v1/Chassis/" +
- chassisId + "/Thermal"}};
+ asyncResp->res
+ .jsonValue["Thermal"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId +
+ "/Thermal";
// Power object
- asyncResp->res.jsonValue["Power"] = {
- {"@odata.id", "/redfish/v1/Chassis/" +
- chassisId + "/Power"}};
+ asyncResp->res.jsonValue["Power"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId +
+ "/Power";
#endif
// SensorCollection
- asyncResp->res.jsonValue["Sensors"] = {
- {"@odata.id", "/redfish/v1/Chassis/" +
- chassisId + "/Sensors"}};
- asyncResp->res.jsonValue["Status"] = {
- {"State", "Enabled"},
- };
-
asyncResp->res
- .jsonValue["Links"]["ComputerSystems"] = {
- {{"@odata.id",
- "/redfish/v1/Systems/system"}}};
+ .jsonValue["Sensors"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId +
+ "/Sensors";
+ asyncResp->res.jsonValue["Status"]["State"] =
+ "Enabled";
+
+ nlohmann::json::array_t computerSystems;
+ nlohmann::json::object_t system;
+ system["@odata.id"] =
+ "/redfish/v1/Systems/system";
+ computerSystems.push_back(std::move(system));
+ asyncResp->res
+ .jsonValue["Links"]["ComputerSystems"] =
+ std::move(computerSystems);
+
+ nlohmann::json::array_t managedBy;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] =
+ "/redfish/v1/Managers/bmc";
+ managedBy.push_back(std::move(manager));
asyncResp->res.jsonValue["Links"]["ManagedBy"] =
- {{{"@odata.id",
- "/redfish/v1/Managers/bmc"}}};
+ std::move(managedBy);
getChassisState(asyncResp);
},
connectionName, path,
@@ -696,17 +708,21 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
- {"@odata.id",
- "/redfish/v1/Chassis/" + chassisId + "/ResetActionInfo"},
- {"Name", "Reset Action Info"},
- {"Id", "ResetActionInfo"},
- {"Parameters",
- {{{"Name", "ResetType"},
- {"Required", true},
- {"DataType", "String"},
- {"AllowableValues", {"PowerCycle"}}}}}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId + "/ResetActionInfo";
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ nlohmann::json::object_t parameters;
+ parameters["Name"] = "ResetType";
+ parameters["Required"] = true;
+ parameters["DataType"] = "String";
+ nlohmann::json::array_t allowed;
+ allowed.push_back("PowerCycle");
+ parameters["AllowableValues"] = std::move(allowed);
+ asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
});
}
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 33ff656..734cab2 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1751,18 +1751,18 @@
{
gatewayStr = "0.0.0.0";
}
+ nlohmann::json::object_t ipv4;
+ ipv4["AddressOrigin"] = ipv4Config.origin;
+ ipv4["SubnetMask"] = ipv4Config.netmask;
+ ipv4["Address"] = ipv4Config.address;
+ ipv4["Gateway"] = gatewayStr;
- ipv4Array.push_back({{"AddressOrigin", ipv4Config.origin},
- {"SubnetMask", ipv4Config.netmask},
- {"Address", ipv4Config.address},
- {"Gateway", gatewayStr}});
if (ipv4Config.origin == "Static")
{
- ipv4StaticArray.push_back({{"AddressOrigin", ipv4Config.origin},
- {"SubnetMask", ipv4Config.netmask},
- {"Address", ipv4Config.address},
- {"Gateway", gatewayStr}});
+ ipv4StaticArray.push_back(ipv4);
}
+
+ ipv4Array.push_back(std::move(ipv4));
}
std::string ipv6GatewayStr = ethData.ipv6DefaultGateway;
@@ -1782,15 +1782,18 @@
ipv6AddrPolicyTable = nlohmann::json::array();
for (const auto& ipv6Config : ipv6Data)
{
- ipv6Array.push_back({{"Address", ipv6Config.address},
- {"PrefixLength", ipv6Config.prefixLength},
- {"AddressOrigin", ipv6Config.origin},
- {"AddressState", nullptr}});
+ nlohmann::json::object_t ipv6;
+ ipv6["Address"] = ipv6Config.address;
+ ipv6["PrefixLength"] = ipv6Config.prefixLength;
+ ipv6["AddressOrigin"] = ipv6Config.origin;
+ ipv6["AddressState"] = nullptr;
+ ipv6Array.push_back(std::move(ipv6));
if (ipv6Config.origin == "Static")
{
- ipv6StaticArray.push_back(
- {{"Address", ipv6Config.address},
- {"PrefixLength", ipv6Config.prefixLength}});
+ nlohmann::json::object_t ipv6Static;
+ ipv6Static["Address"] = ipv6Config.address;
+ ipv6Static["PrefixLength"] = ipv6Config.prefixLength;
+ ipv6StaticArray.push_back(std::move(ipv6Static));
}
}
}
@@ -1821,57 +1824,58 @@
{
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/EthernetInterfaces/")
.privileges(redfish::privileges::getEthernetInterfaceCollection)
- .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>&
- asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
-
- asyncResp->res.jsonValue["@odata.type"] =
- "#EthernetInterfaceCollection.EthernetInterfaceCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Managers/bmc/EthernetInterfaces";
- asyncResp->res.jsonValue["Name"] =
- "Ethernet Network Interface Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of EthernetInterfaces for this Manager";
-
- // Get eth interface list, and call the below callback for JSON
- // preparation
- getEthernetIfaceList([asyncResp](const bool& success,
- const boost::container::flat_set<
- std::string>& ifaceList) {
- if (!success)
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- messages::internalError(asyncResp->res);
return;
}
- nlohmann::json& ifaceArray =
- asyncResp->res.jsonValue["Members"];
- ifaceArray = nlohmann::json::array();
- std::string tag = "_";
- for (const std::string& ifaceItem : ifaceList)
- {
- std::size_t found = ifaceItem.find(tag);
- if (found == std::string::npos)
- {
- ifaceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
- ifaceItem}});
- }
- }
-
- asyncResp->res.jsonValue["Members@odata.count"] =
- ifaceArray.size();
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EthernetInterfaceCollection.EthernetInterfaceCollection";
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Managers/bmc/EthernetInterfaces";
+ asyncResp->res.jsonValue["Name"] =
+ "Ethernet Network Interface Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of EthernetInterfaces for this Manager";
+
+ // Get eth interface list, and call the below callback for JSON
+ // preparation
+ getEthernetIfaceList([asyncResp](
+ const bool& success,
+ const boost::container::flat_set<
+ std::string>& ifaceList) {
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ nlohmann::json& ifaceArray =
+ asyncResp->res.jsonValue["Members"];
+ ifaceArray = nlohmann::json::array();
+ std::string tag = "_";
+ for (const std::string& ifaceItem : ifaceList)
+ {
+ std::size_t found = ifaceItem.find(tag);
+ if (found == std::string::npos)
+ {
+ nlohmann::json::object_t iface;
+ iface["@odata.id"] =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
+ ifaceItem;
+ ifaceArray.push_back(std::move(iface));
+ }
+ }
+
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ ifaceArray.size();
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces";
+ });
});
- });
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::getEthernetInterface)
@@ -2267,64 +2271,66 @@
"/redfish/v1/Managers/bmc/EthernetInterfaces/<str>/VLANs/")
.privileges(redfish::privileges::getVLanNetworkInterfaceCollection)
- .methods(
- boost::beast::http::verb::
- get)([&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& rootInterfaceName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- // Get eth interface list, and call the below callback for JSON
- // preparation
- getEthernetIfaceList([asyncResp, rootInterfaceName](
- const bool& success,
- const boost::container::flat_set<
- std::string>& ifaceList) {
- if (!success)
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& rootInterfaceName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- messages::internalError(asyncResp->res);
return;
}
-
- if (ifaceList.find(rootInterfaceName) == ifaceList.end())
- {
- messages::resourceNotFound(asyncResp->res,
- "VLanNetworkInterfaceCollection",
- rootInterfaceName);
- return;
- }
-
- asyncResp->res.jsonValue["@odata.type"] =
- "#VLanNetworkInterfaceCollection."
- "VLanNetworkInterfaceCollection";
- asyncResp->res.jsonValue["Name"] =
- "VLAN Network Interface Collection";
-
- nlohmann::json ifaceArray = nlohmann::json::array();
-
- for (const std::string& ifaceItem : ifaceList)
- {
- if (boost::starts_with(ifaceItem, rootInterfaceName + "_"))
+ // Get eth interface list, and call the below callback for JSON
+ // preparation
+ getEthernetIfaceList([asyncResp, rootInterfaceName](
+ const bool& success,
+ const boost::container::flat_set<
+ std::string>& ifaceList) {
+ if (!success)
{
- std::string path =
- "/redfish/v1/Managers/bmc/EthernetInterfaces/";
- path += rootInterfaceName;
- path += "/VLANs/";
- path += ifaceItem;
- ifaceArray.push_back({{"@odata.id", std::move(path)}});
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- ifaceArray.size();
- asyncResp->res.jsonValue["Members"] = std::move(ifaceArray);
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
- rootInterfaceName + "/VLANs";
+ if (ifaceList.find(rootInterfaceName) == ifaceList.end())
+ {
+ messages::resourceNotFound(
+ asyncResp->res, "VLanNetworkInterfaceCollection",
+ rootInterfaceName);
+ return;
+ }
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#VLanNetworkInterfaceCollection."
+ "VLanNetworkInterfaceCollection";
+ asyncResp->res.jsonValue["Name"] =
+ "VLAN Network Interface Collection";
+
+ nlohmann::json ifaceArray = nlohmann::json::array();
+
+ for (const std::string& ifaceItem : ifaceList)
+ {
+ if (boost::starts_with(ifaceItem,
+ rootInterfaceName + "_"))
+ {
+ std::string path =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces/";
+ path += rootInterfaceName;
+ path += "/VLANs/";
+ path += ifaceItem;
+ nlohmann::json::object_t iface;
+ iface["@odata.id"] = std::move(path);
+ ifaceArray.push_back(std::move(iface));
+ }
+ }
+
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ ifaceArray.size();
+ asyncResp->res.jsonValue["Members"] = std::move(ifaceArray);
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
+ rootInterfaceName + "/VLANs";
+ });
});
- });
BMCWEB_ROUTE(app,
"/redfish/v1/Managers/bmc/EthernetInterfaces/<str>/VLANs/")
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 2b63955..51c999f 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -57,17 +57,17 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#EventService.v1_5_0.EventService"},
- {"Id", "EventService"},
- {"Name", "Event Service"},
- {"Subscriptions",
- {{"@odata.id", "/redfish/v1/EventService/Subscriptions"}}},
- {"Actions",
- {{"#EventService.SubmitTestEvent",
- {{"target",
- "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent"}}}}},
- {"@odata.id", "/redfish/v1/EventService"}};
+
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/EventService";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EventService.v1_5_0.EventService";
+ asyncResp->res.jsonValue["Id"] = "EventService";
+ asyncResp->res.jsonValue["Name"] = "Event Service";
+ asyncResp->res.jsonValue["Subscriptions"]["@odata.id"] =
+ "/redfish/v1/EventService/Subscriptions";
+ asyncResp->res.jsonValue["Actions"]["#EventService.SubmitTestEvent"]
+ ["target"] =
+ "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent";
const persistent_data::EventServiceConfig eventServiceConfig =
persistent_data::EventServiceStore::getInstance()
@@ -195,11 +195,12 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#EventDestinationCollection.EventDestinationCollection"},
- {"@odata.id", "/redfish/v1/EventService/Subscriptions"},
- {"Name", "Event Destination Collections"}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EventDestinationCollection.EventDestinationCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/EventService/Subscriptions";
+ asyncResp->res.jsonValue["Name"] =
+ "Event Destination Collections";
nlohmann::json& memberArray =
asyncResp->res.jsonValue["Members"];
@@ -212,9 +213,10 @@
for (const std::string& id : subscripIds)
{
- memberArray.push_back(
- {{"@odata.id",
- "/redfish/v1/EventService/Subscriptions/" + id}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/EventService/Subscriptions/" + id;
+ memberArray.push_back(std::move(member));
}
});
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/")
@@ -511,10 +513,9 @@
}
const std::string& id = param;
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#EventDestination.v1_7_0.EventDestination"},
- {"Protocol", "Redfish"}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EventDestination.v1_7_0.EventDestination";
+ asyncResp->res.jsonValue["Protocol"] = "Redfish";
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/EventService/Subscriptions/" + id;
asyncResp->res.jsonValue["Id"] = id;
@@ -538,10 +539,12 @@
asyncResp->res.jsonValue["DeliveryRetryPolicy"] =
subValue->retryPolicy;
- std::vector<nlohmann::json> mrdJsonArray;
+ nlohmann::json::array_t mrdJsonArray;
for (const auto& mdrUri : subValue->metricReportDefinitions)
{
- mrdJsonArray.push_back({{"@odata.id", mdrUri}});
+ nlohmann::json::object_t mdr;
+ mdr["@odata.id"] = mdrUri;
+ mrdJsonArray.emplace_back(std::move(mdr));
}
asyncResp->res.jsonValue["MetricReportDefinitions"] =
mrdJsonArray;
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index ae03e2c..500dc04 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -501,19 +501,17 @@
{
if (ipv4Config.isActive)
{
+ nlohmann::json::object_t ipv4;
+ ipv4["AddressOrigin"] = ipv4Config.origin;
+ ipv4["SubnetMask"] = ipv4Config.netmask;
+ ipv4["Address"] = ipv4Config.address;
+ ipv4["Gateway"] = ethData.defaultGateway;
- ipv4Array.push_back({{"AddressOrigin", ipv4Config.origin},
- {"SubnetMask", ipv4Config.netmask},
- {"Address", ipv4Config.address},
- {"Gateway", ethData.defaultGateway}});
if (ipv4Config.origin == "Static")
{
- ipv4StaticArray.push_back(
- {{"AddressOrigin", ipv4Config.origin},
- {"SubnetMask", ipv4Config.netmask},
- {"Address", ipv4Config.address},
- {"Gateway", ethData.defaultGateway}});
+ ipv4StaticArray.push_back(ipv4);
}
+ ipv4Array.push_back(std::move(ipv4));
}
}
}
@@ -729,46 +727,51 @@
BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/")
.privileges(redfish::privileges::getComputerSystem)
- .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>&
- asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- sdbusplus::asio::getProperty<std::string>(
- *crow::connections::systemBus, "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor",
- "xyz.openbmc_project.Network.SystemConfiguration", "HostName",
- [asyncResp](const boost::system::error_code ec,
- const std::string& /*hostName*/) {
- if (ec)
- {
- messages::resourceNotFound(asyncResp->res, "System",
- "hypervisor");
- return;
- }
- BMCWEB_LOG_DEBUG << "Hypervisor is available";
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ sdbusplus::asio::getProperty<std::string>(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor",
+ "xyz.openbmc_project.Network.SystemConfiguration",
+ "HostName",
+ [asyncResp](const boost::system::error_code ec,
+ const std::string& /*hostName*/) {
+ if (ec)
+ {
+ messages::resourceNotFound(asyncResp->res, "System",
+ "hypervisor");
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "Hypervisor is available";
- asyncResp->res.jsonValue["@odata.type"] =
- "#ComputerSystem.v1_6_0.ComputerSystem";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/hypervisor";
- asyncResp->res.jsonValue["Description"] = "Hypervisor";
- asyncResp->res.jsonValue["Name"] = "Hypervisor";
- asyncResp->res.jsonValue["Id"] = "hypervisor";
- asyncResp->res.jsonValue["SystemType"] = "OS";
- asyncResp->res.jsonValue["Links"]["ManagedBy"] = {
- {{"@odata.id", "/redfish/v1/Managers/bmc"}}};
- asyncResp->res.jsonValue["EthernetInterfaces"] = {
- {"@odata.id",
- "/redfish/v1/Systems/hypervisor/EthernetInterfaces"}};
- getHypervisorState(asyncResp);
- getHypervisorActions(asyncResp);
- // TODO: Add "SystemType" : "hypervisor"
- });
- });
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ComputerSystem.v1_6_0.ComputerSystem";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor";
+ asyncResp->res.jsonValue["Description"] = "Hypervisor";
+ asyncResp->res.jsonValue["Name"] = "Hypervisor";
+ asyncResp->res.jsonValue["Id"] = "hypervisor";
+ asyncResp->res.jsonValue["SystemType"] = "OS";
+ nlohmann::json::array_t managedBy;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] = "/redfish/v1/Managers/bmc";
+ managedBy.push_back(std::move(manager));
+ asyncResp->res.jsonValue["Links"]["ManagedBy"] =
+ std::move(managedBy);
+ asyncResp->res
+ .jsonValue["EthernetInterfaces"]["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor/EthernetInterfaces";
+ getHypervisorState(asyncResp);
+ getHypervisorActions(asyncResp);
+ // TODO: Add "SystemType" : "hypervisor"
+ });
+ });
/**
* HypervisorInterfaceCollection class to handle the GET and PATCH on
@@ -820,11 +823,11 @@
{
continue;
}
-
- ifaceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/hypervisor/EthernetInterfaces/" +
- name}});
+ nlohmann::json::object_t ethIface;
+ ethIface["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor/EthernetInterfaces/" +
+ name;
+ ifaceArray.push_back(std::move(ethIface));
}
asyncResp->res.jsonValue["Members@odata.count"] =
ifaceArray.size();
@@ -1033,17 +1036,24 @@
// The hypervisor object only support the ability to
// turn On The system object Action should be utilized
// for other operations
- asyncResp->res.jsonValue = {
- {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
- {"@odata.id",
- "/redfish/v1/Systems/hypervisor/ResetActionInfo"},
- {"Name", "Reset Action Info"},
- {"Id", "ResetActionInfo"},
- {"Parameters",
- {{{"Name", "ResetType"},
- {"Required", true},
- {"DataType", "String"},
- {"AllowableValues", {"On"}}}}}};
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor/ResetActionInfo";
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ nlohmann::json::array_t parameters;
+ nlohmann::json::object_t parameter;
+ parameter["Name"] = "ResetType";
+ parameter["Required"] = true;
+ parameter["DataType"] = "String";
+ nlohmann::json::array_t allowed;
+ allowed.push_back("On");
+ parameter["AllowableValues"] = std::move(allowed);
+ parameters.push_back(std::move(parameter));
+ asyncResp->res.jsonValue["Parameters"] =
+ std::move(parameters);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 3a8ce10..d31602c 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -916,24 +916,29 @@
nlohmann::json& logServiceArray =
asyncResp->res.jsonValue["Members"];
logServiceArray = nlohmann::json::array();
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/EventLog"}});
+ nlohmann::json::object_t eventLog;
+ eventLog["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/EventLog";
+ logServiceArray.push_back(std::move(eventLog));
#ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
- logServiceArray.push_back(
- {{"@odata.id", "/redfish/v1/Systems/system/LogServices/Dump"}});
+ nlohmann::json::object_t dumpLog;
+ eventLog["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Dump";
+ logServiceArray.push_back(std::move(dumpLog));
#endif
#ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/Crashdump"}});
+ nlohmann::json::object_t crashdump;
+ crashdump["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Crashdump";
+ logServiceArray.push_back(std::move(crashdump));
#endif
#ifdef BMCWEB_ENABLE_REDFISH_HOST_LOGGER
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/HostLogger"}});
+ nlohmann::json::object_t hostlogger;
+ hostlogger["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/HostLogger";
+ logServiceArray.push_back(std::move(hostlogger));
#endif
asyncResp->res.jsonValue["Members@odata.count"] =
logServiceArray.size();
@@ -999,9 +1004,8 @@
asyncResp->res.jsonValue["DateTimeLocalOffset"] =
redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/LogServices/EventLog/Entries"}};
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/EventLog/Entries";
asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"] = {
{"target",
@@ -1864,25 +1868,23 @@
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/HostLogger/")
.privileges(redfish::privileges::getLogService)
- .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>&
- asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/LogServices/HostLogger";
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_1_0.LogService";
- asyncResp->res.jsonValue["Name"] = "Host Logger Service";
- asyncResp->res.jsonValue["Description"] = "Host Logger Service";
- asyncResp->res.jsonValue["Id"] = "HostLogger";
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/LogServices/HostLogger/Entries"}};
- });
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/HostLogger";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_1_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "Host Logger Service";
+ asyncResp->res.jsonValue["Description"] = "Host Logger Service";
+ asyncResp->res.jsonValue["Id"] = "HostLogger";
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/HostLogger/Entries";
+ });
}
inline void requestRoutesSystemHostLoggerCollection(App& app)
@@ -2094,9 +2096,8 @@
asyncResp->res.jsonValue["DateTimeLocalOffset"] =
redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/LogServices/Journal/Entries"}};
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/LogServices/Journal/Entries";
});
}
@@ -2350,16 +2351,15 @@
asyncResp->res.jsonValue["DateTimeLocalOffset"] =
redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/LogServices/Dump/Entries"}};
- asyncResp->res.jsonValue["Actions"] = {
- {"#LogService.ClearLog",
- {{"target",
- "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog"}}},
- {"#LogService.CollectDiagnosticData",
- {{"target",
- "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"}}}};
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/LogServices/Dump/Entries";
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.ClearLog"]["target"] =
+ "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog";
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.CollectDiagnosticData"]
+ ["target"] =
+ "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData";
});
}
@@ -2482,16 +2482,16 @@
asyncResp->res.jsonValue["DateTimeLocalOffset"] =
redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/LogServices/Dump/Entries"}};
- asyncResp->res.jsonValue["Actions"] = {
- {"#LogService.ClearLog",
- {{"target",
- "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog"}}},
- {"#LogService.CollectDiagnosticData",
- {{"target",
- "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData"}}}};
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Dump/Entries";
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.ClearLog"]["target"] =
+ "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog";
+
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.CollectDiagnosticData"]
+ ["target"] =
+ "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData";
});
}
@@ -2623,16 +2623,15 @@
asyncResp->res.jsonValue["DateTimeLocalOffset"] =
redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/LogServices/Crashdump/Entries"}};
- asyncResp->res.jsonValue["Actions"] = {
- {"#LogService.ClearLog",
- {{"target",
- "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/LogService.ClearLog"}}},
- {"#LogService.CollectDiagnosticData",
- {{"target",
- "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/LogService.CollectDiagnosticData"}}}};
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Crashdump/Entries";
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.ClearLog"]["target"] =
+ "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/LogService.ClearLog";
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.CollectDiagnosticData"]
+ ["target"] =
+ "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/LogService.CollectDiagnosticData";
});
}
@@ -3116,17 +3115,17 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id",
- "/redfish/v1/Systems/system/LogServices/PostCodes"},
- {"@odata.type", "#LogService.v1_1_0.LogService"},
- {"Name", "POST Code Log Service"},
- {"Description", "POST Code Log Service"},
- {"Id", "BIOS POST Code Log"},
- {"OverWritePolicy", "WrapsWhenFull"},
- {"Entries",
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/PostCodes/Entries"}}}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/PostCodes";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_1_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "POST Code Log Service";
+ asyncResp->res.jsonValue["Description"] = "POST Code Log Service";
+ asyncResp->res.jsonValue["Id"] = "BIOS POST Code Log";
+ asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull";
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/PostCodes/Entries";
std::pair<std::string, std::string> redfishDateTimeOffset =
crow::utility::getDateTimeOffsetNow();
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index aa4c694..cd9910e 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -242,17 +242,27 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
- {"@odata.id", "/redfish/v1/Managers/bmc/ResetActionInfo"},
- {"Name", "Reset Action Info"},
- {"Id", "ResetActionInfo"},
- {"Parameters",
- {{{"Name", "ResetType"},
- {"Required", true},
- {"DataType", "String"},
- {"AllowableValues",
- {"GracefulRestart", "ForceRestart"}}}}}};
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/ResetActionInfo";
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ nlohmann::json::object_t parameter;
+ parameter["Name"] = "ResetType";
+ parameter["Required"] = true;
+ parameter["DataType"] = "String";
+
+ nlohmann::json::array_t allowableValues;
+ allowableValues.push_back("GracefulRestart");
+ allowableValues.push_back("ForceRestart");
+ parameter["AllowableValues"] = std::move(allowableValues);
+
+ nlohmann::json::array_t parameters;
+ parameters.push_back(std::move(parameter));
+
+ asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
});
}
@@ -526,9 +536,10 @@
steps = nlohmann::json::array();
for (size_t ii = 0; ii < keys->size(); ii++)
{
- steps.push_back(
- {{"Target", (*keys)[ii]},
- {"Output", (*values)[ii]}});
+ nlohmann::json::object_t step;
+ step["Target"] = (*keys)[ii];
+ step["Output"] = (*values)[ii];
+ steps.push_back(std::move(step));
}
}
}
@@ -571,10 +582,11 @@
for (std::string itemCopy : *inputs)
{
dbus::utility::escapePathForDbus(itemCopy);
- data.push_back(
- {{"@odata.id",
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" +
- itemCopy}});
+ nlohmann::json::object_t input;
+ input["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" +
+ itemCopy;
+ data.push_back(std::move(input));
}
}
// todo(james): may never happen, but this
@@ -1978,26 +1990,25 @@
asyncResp->res.jsonValue["Description"] =
"Baseboard Management Controller";
asyncResp->res.jsonValue["PowerState"] = "On";
- asyncResp->res.jsonValue["Status"] = {{"State", "Enabled"},
- {"Health", "OK"}};
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
+
asyncResp->res.jsonValue["ManagerType"] = "BMC";
asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid();
asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid;
asyncResp->res.jsonValue["Model"] =
"OpenBmc"; // TODO(ed), get model
- asyncResp->res.jsonValue["LogServices"] = {
- {"@odata.id", "/redfish/v1/Managers/bmc/LogServices"}};
-
- asyncResp->res.jsonValue["NetworkProtocol"] = {
- {"@odata.id", "/redfish/v1/Managers/bmc/NetworkProtocol"}};
-
- asyncResp->res.jsonValue["EthernetInterfaces"] = {
- {"@odata.id", "/redfish/v1/Managers/bmc/EthernetInterfaces"}};
+ asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/LogServices";
+ asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/NetworkProtocol";
+ asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces";
#ifdef BMCWEB_ENABLE_VM_NBDPROXY
- asyncResp->res.jsonValue["VirtualMedia"] = {
- {"@odata.id", "/redfish/v1/Managers/bmc/VirtualMedia"}};
+ asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/VirtualMedia";
#endif // BMCWEB_ENABLE_VM_NBDPROXY
// default oem data
@@ -2007,9 +2018,11 @@
oem["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem";
oemOpenbmc["@odata.type"] = "#OemManager.OpenBmc";
oemOpenbmc["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc";
- oemOpenbmc["Certificates"] = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/Truststore/Certificates"}};
+
+ nlohmann::json::object_t certificates;
+ certificates["@odata.id"] =
+ "/redfish/v1/Managers/bmc/Truststore/Certificates";
+ oemOpenbmc["Certificates"] = std::move(certificates);
// Manager.Reset (an action) can be many values, OpenBMC only
// supports BMC reboot.
@@ -2057,8 +2070,14 @@
asyncResp->res.jsonValue["Links"]["ManagerForServers@odata.count"] =
1;
- asyncResp->res.jsonValue["Links"]["ManagerForServers"] = {
- {{"@odata.id", "/redfish/v1/Systems/system"}}};
+
+ nlohmann::json::array_t managerForServers;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] = "/redfish/v1/Systems/system";
+ managerForServers.push_back(std::move(manager));
+
+ asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
+ std::move(managerForServers);
auto health = std::make_shared<HealthPopulate>(asyncResp);
health->isManagersHealth = true;
@@ -2072,17 +2091,20 @@
auto pids = std::make_shared<GetPIDValues>(asyncResp);
pids->run();
- getMainChassisId(
- asyncResp, [](const std::string& chassisId,
- const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
- aRsp->res
- .jsonValue["Links"]["ManagerForChassis@odata.count"] =
- 1;
- aRsp->res.jsonValue["Links"]["ManagerForChassis"] = {
- {{"@odata.id", "/redfish/v1/Chassis/" + chassisId}}};
- aRsp->res.jsonValue["Links"]["ManagerInChassis"] = {
- {"@odata.id", "/redfish/v1/Chassis/" + chassisId}};
- });
+ getMainChassisId(asyncResp, [](const std::string& chassisId,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>& aRsp) {
+ aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] =
+ 1;
+ nlohmann::json::array_t managerForChassis;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] = "/redfish/v1/Chassis/" + chassisId;
+ managerForChassis.push_back(std::move(manager));
+ aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
+ std::move(managerForChassis);
+ aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId;
+ });
static bool started = false;
@@ -2317,8 +2339,10 @@
"#ManagerCollection.ManagerCollection";
asyncResp->res.jsonValue["Name"] = "Manager Collection";
asyncResp->res.jsonValue["Members@odata.count"] = 1;
- asyncResp->res.jsonValue["Members"] = {
- {{"@odata.id", "/redfish/v1/Managers/bmc"}}};
+ nlohmann::json::array_t members;
+ nlohmann::json& bmc = members.emplace_back();
+ bmc["@odata.id"] = "/redfish/v1/Managers/bmc";
+ asyncResp->res.jsonValue["Members"] = std::move(members);
});
}
} // namespace redfish
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index fe4c592..bd9b090 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -39,18 +39,18 @@
// 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"},
- {"@odata.id", "/redfish/v1/Registries"},
- {"Name", "MessageRegistryFile Collection"},
- {"Description", "Collection of MessageRegistryFiles"},
- {"Members@odata.count", 4},
- {"Members",
- {{{"@odata.id", "/redfish/v1/Registries/Base"}},
- {{"@odata.id", "/redfish/v1/Registries/TaskEvent"}},
- {{"@odata.id", "/redfish/v1/Registries/ResourceEvent"}},
- {{"@odata.id", "/redfish/v1/Registries/OpenBMC"}}}}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#MessageRegistryFileCollection.MessageRegistryFileCollection";
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Registries";
+ asyncResp->res.jsonValue["Name"] = "MessageRegistryFile Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of MessageRegistryFiles";
+ asyncResp->res.jsonValue["Members@odata.count"] = 4;
+ asyncResp->res.jsonValue["Members"] = {
+ {{"@odata.id", "/redfish/v1/Registries/Base"}},
+ {{"@odata.id", "/redfish/v1/Registries/TaskEvent"}},
+ {{"@odata.id", "/redfish/v1/Registries/ResourceEvent"}},
+ {{"@odata.id", "/redfish/v1/Registries/OpenBMC"}}};
}
inline void requestRoutesMessageRegistryFileCollection(App& app)
@@ -105,19 +105,22 @@
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id", "/redfish/v1/Registries/" + registry},
- {"@odata.type", "#MessageRegistryFile.v1_1_0.MessageRegistryFile"},
- {"Name", registry + " Message Registry File"},
- {"Description", dmtf + registry + " Message Registry File Location"},
- {"Id", header->registryPrefix},
- {"Registry", header->id},
- {"Languages", {"en"}},
- {"Languages@odata.count", 1},
- {"Location",
- {{{"Language", "en"},
- {"Uri", "/redfish/v1/Registries/" + registry + "/" + registry}}}},
- {"Location@odata.count", 1}};
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Registries/" + registry;
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#MessageRegistryFile.v1_1_0.MessageRegistryFile";
+ asyncResp->res.jsonValue["Name"] = registry + " Message Registry File";
+ asyncResp->res.jsonValue["Description"] =
+ dmtf + registry + " Message Registry File Location";
+ asyncResp->res.jsonValue["Id"] = header->registryPrefix;
+ asyncResp->res.jsonValue["Registry"] = header->id;
+ asyncResp->res.jsonValue["Languages"] = {"en"};
+ asyncResp->res.jsonValue["Languages@odata.count"] = 1;
+ asyncResp->res.jsonValue["Location"] = {
+ {{"Language", "en"},
+ {"Uri", "/redfish/v1/Registries/" + registry + "/" + registry}}};
+
+ asyncResp->res.jsonValue["Location@odata.count"] = 1;
if (url != nullptr)
{
@@ -194,15 +197,15 @@
return;
}
- asyncResp->res.jsonValue = {{"@Redfish.Copyright", header->copyright},
- {"@odata.type", header->type},
- {"Id", header->id},
- {"Name", header->name},
- {"Language", header->language},
- {"Description", header->description},
- {"RegistryPrefix", header->registryPrefix},
- {"RegistryVersion", header->registryVersion},
- {"OwningEntity", header->owningEntity}};
+ asyncResp->res.jsonValue["@Redfish.Copyright"] = header->copyright;
+ asyncResp->res.jsonValue["@odata.type"] = header->type;
+ asyncResp->res.jsonValue["Id"] = header->id;
+ asyncResp->res.jsonValue["Name"] = header->name;
+ asyncResp->res.jsonValue["Language"] = header->language;
+ asyncResp->res.jsonValue["Description"] = header->description;
+ asyncResp->res.jsonValue["RegistryPrefix"] = header->registryPrefix;
+ asyncResp->res.jsonValue["RegistryVersion"] = header->registryVersion;
+ asyncResp->res.jsonValue["OwningEntity"] = header->owningEntity;
nlohmann::json& messageObj = asyncResp->res.jsonValue["Messages"];
@@ -210,12 +213,12 @@
for (const registries::MessageEntry* message : registryEntries)
{
nlohmann::json& obj = messageObj[message->first];
- obj = {{"Description", message->second.description},
- {"Message", message->second.message},
- {"Severity", message->second.messageSeverity},
- {"MessageSeverity", message->second.messageSeverity},
- {"NumberOfArgs", message->second.numberOfArgs},
- {"Resolution", message->second.resolution}};
+ obj["Description"] = message->second.description;
+ obj["Message"] = message->second.message;
+ obj["Severity"] = message->second.messageSeverity;
+ obj["MessageSeverity"] = message->second.messageSeverity;
+ obj["NumberOfArgs"] = message->second.numberOfArgs;
+ obj["Resolution"] = message->second.resolution;
if (message->second.numberOfArgs > 0)
{
nlohmann::json& messageParamArray = obj["ParamTypes"];
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 362163a..a6dd3b0 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -165,9 +165,8 @@
if (isOperationAllowedWithPrivileges({{"ConfigureManager"}},
effectiveUserPrivileges))
{
- asyncResp->res.jsonValue["HTTPS"]["Certificates"] = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"}};
+ asyncResp->res.jsonValue["HTTPS"]["Certificates"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates";
}
for (const auto& protocol : protocolToDBus)
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index be59811..740e393 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -60,9 +60,10 @@
{
continue;
}
- pcieDeviceList.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" + devName}});
+ nlohmann::json::object_t pcieDevice;
+ pcieDevice["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + devName;
+ pcieDeviceList.push_back(std::move(pcieDevice));
}
asyncResp->res.jsonValue[name + "@odata.count"] =
pcieDeviceList.size();
@@ -88,14 +89,16 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#PCIeDeviceCollection.PCIeDeviceCollection"},
- {"@odata.id", "/redfish/v1/Systems/system/PCIeDevices"},
- {"Name", "PCIe Device Collection"},
- {"Description", "Collection of PCIe Devices"},
- {"Members", nlohmann::json::array()},
- {"Members@odata.count", 0}};
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#PCIeDeviceCollection.PCIeDeviceCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices";
+ asyncResp->res.jsonValue["Name"] = "PCIe Device Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of PCIe Devices";
+ asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
getPCIeDeviceList(asyncResp, "Members");
});
}
@@ -174,16 +177,16 @@
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#PCIeDevice.v1_4_0.PCIeDevice"},
- {"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" + device},
- {"Name", "PCIe Device"},
- {"Id", device}};
- asyncResp->res.jsonValue["PCIeFunctions"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" + device +
- "/PCIeFunctions"}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#PCIeDevice.v1_4_0.PCIeDevice";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + device;
+ asyncResp->res.jsonValue["Name"] = "PCIe Device";
+ asyncResp->res.jsonValue["Id"] = device;
+
+ asyncResp->res.jsonValue["PCIeFunctions"]["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + device +
+ "/PCIeFunctions";
for (const auto& property : pcieDevProperties)
{
const std::string* propertyString =
@@ -259,14 +262,15 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#PCIeFunctionCollection.PCIeFunctionCollection"},
- {"@odata.id", "/redfish/v1/Systems/system/PCIeDevices/" +
- device + "/PCIeFunctions"},
- {"Name", "PCIe Function Collection"},
- {"Description",
- "Collection of PCIe Functions for PCIe Device " + device}};
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#PCIeFunctionCollection.PCIeFunctionCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + device +
+ "/PCIeFunctions";
+ asyncResp->res.jsonValue["Name"] = "PCIe Function Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of PCIe Functions for PCIe Device " + device;
auto getPCIeDeviceCallback =
[asyncResp, device](
@@ -315,11 +319,11 @@
{
return;
}
- pcieFunctionList.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" +
- device + "/PCIeFunctions/" +
- std::to_string(functionNum)}});
+ nlohmann::json::object_t pcieFunction;
+ pcieFunction["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + device +
+ "/PCIeFunctions/" + std::to_string(functionNum);
+ pcieFunctionList.push_back(std::move(pcieFunction));
}
asyncResp->res.jsonValue["Members@odata.count"] =
pcieFunctionList.size();
@@ -371,7 +375,8 @@
return;
}
- // Check if this function exists by looking for a device ID
+ // Check if this function exists by looking for a device
+ // ID
std::string functionName = "Function" + function;
std::string devIDProperty = functionName + "DeviceId";
@@ -392,19 +397,18 @@
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#PCIeFunction.v1_2_0.PCIeFunction"},
- {"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" + device +
- "/PCIeFunctions/" + function},
- {"Name", "PCIe Function"},
- {"Id", function},
- {"FunctionId", std::stoi(function)},
- {"Links",
- {{"PCIeDevice",
- {{"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" +
- device}}}}}};
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#PCIeFunction.v1_2_0.PCIeFunction";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + device +
+ "/PCIeFunctions/" + function;
+ asyncResp->res.jsonValue["Name"] = "PCIe Function";
+ asyncResp->res.jsonValue["Id"] = function;
+ asyncResp->res.jsonValue["FunctionId"] =
+ std::stoi(function);
+ asyncResp->res
+ .jsonValue["Links"]["PCIeDevice"]["@odata.id"] =
+ "/redfish/v1/Systems/system/PCIeDevices/" + device;
for (const auto& property : pcieDevProperties)
{
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 118f397..d609acb 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -215,13 +215,16 @@
{
// Mandatory properties odata.id and MemberId
// A warning without a odata.type
- tempArray.push_back(
- {{"@odata.type", "#Power.v1_0_0.PowerControl"},
- {"@odata.id", "/redfish/v1/Chassis/" +
- sensorAsyncResp->chassisId +
- "/Power#/PowerControl/0"},
- {"Name", "Chassis Power Control"},
- {"MemberId", "0"}});
+ nlohmann::json::object_t powerControl;
+ powerControl["@odata.type"] =
+ "#Power.v1_0_0.PowerControl";
+ powerControl["@odata.id"] =
+ "/redfish/v1/Chassis/" +
+ sensorAsyncResp->chassisId +
+ "/Power#/PowerControl/0";
+ powerControl["Name"] = "Chassis Power Control";
+ powerControl["MemberId"] = "0";
+ tempArray.push_back(std::move(powerControl));
}
nlohmann::json& sensorJson = tempArray.back();
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 2a0e028..e0346de 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -555,7 +555,9 @@
const std::string& dbusPath = dbusPathWrapper->str;
std::string uri = "/redfish/v1/Systems/system/Processors/" +
cpuId + "/OperatingConfigs";
- json["OperatingConfigs"] = {{"@odata.id", uri}};
+ nlohmann::json::object_t operatingConfig;
+ operatingConfig["@odata.id"] = uri;
+ json["OperatingConfigs"] = std::move(operatingConfig);
// Reuse the D-Bus config object name for the Redfish
// URI
@@ -571,7 +573,10 @@
}
uri += '/';
uri += dbusPath.substr(baseNamePos + 1);
- json["AppliedOperatingConfig"] = {{"@odata.id", uri}};
+ nlohmann::json::object_t appliedOperatingConfig;
+ appliedOperatingConfig["@odata.id"] = uri;
+ json["AppliedOperatingConfig"] =
+ std::move(appliedOperatingConfig);
// Once we found the current applied config, queue another
// request to read the base freq core ids out of that
@@ -885,8 +890,10 @@
turboArray = nlohmann::json::array();
for (const auto& [turboSpeed, coreCount] : *turboList)
{
- turboArray.push_back({{"ActiveCoreCount", coreCount},
- {"MaxSpeedMHz", turboSpeed}});
+ nlohmann::json::object_t turbo;
+ turbo["ActiveCoreCount"] = coreCount;
+ turbo["MaxSpeedMHz"] = turboSpeed;
+ turboArray.push_back(std::move(turbo));
}
}
else if (key == "BaseSpeedPrioritySettings")
@@ -904,10 +911,11 @@
baseSpeedArray = nlohmann::json::array();
for (const auto& [baseSpeed, coreList] : *baseSpeedList)
{
- baseSpeedArray.push_back(
- {{"CoreCount", coreList.size()},
- {"CoreIDs", coreList},
- {"BaseSpeedMHz", baseSpeed}});
+ nlohmann::json::object_t speed;
+ speed["CoreCount"] = coreList.size();
+ speed["CoreIDs"] = coreList;
+ speed["BaseSpeedMHz"] = baseSpeed;
+ baseSpeedArray.push_back(std::move(speed));
}
}
}
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 6c55f75..58499a5 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -113,8 +113,9 @@
nlohmann::json ret = nlohmann::json::array();
for (const std::string* uid : sessionIds)
{
- ret.push_back(
- {{"@odata.id", "/redfish/v1/SessionService/Sessions/" + *uid}});
+ nlohmann::json::object_t session;
+ session["@odata.id"] = "/redfish/v1/SessionService/Sessions/" + *uid;
+ ret.push_back(std::move(session));
}
return ret;
}
@@ -245,8 +246,8 @@
persistent_data::SessionStore::getInstance().getTimeoutInSeconds();
asyncResp->res.jsonValue["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["Sessions"] = {
- {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
+ asyncResp->res.jsonValue["Sessions"]["@odata.id"] =
+ "/redfish/v1/SessionService/Sessions";
}
inline void handleSessionServicePatch(
diff --git a/redfish-core/lib/redfish_v1.hpp b/redfish-core/lib/redfish_v1.hpp
index 9b5d460..62ec724 100644
--- a/redfish-core/lib/redfish_v1.hpp
+++ b/redfish-core/lib/redfish_v1.hpp
@@ -15,7 +15,7 @@
.methods(boost::beast::http::verb::get)(
[](const crow::Request&,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- asyncResp->res.jsonValue = {{"v1", "/redfish/v1/"}};
+ asyncResp->res.jsonValue["v1"] = "/redfish/v1/";
});
}
} // namespace redfish
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index dd8a790..6f27b8e 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -93,16 +93,18 @@
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#Role.v1_2_2.Role"},
- {"Name", "User Role"},
- {"Description", roleId + " User Role"},
- {"OemPrivileges", nlohmann::json::array()},
- {"IsPredefined", true},
- {"Id", roleId},
- {"RoleId", roleId},
- {"@odata.id", "/redfish/v1/AccountService/Roles/" + roleId},
- {"AssignedPrivileges", std::move(privArray)}};
+ asyncResp->res.jsonValue["@odata.type"] = "#Role.v1_2_2.Role";
+ asyncResp->res.jsonValue["Name"] = "User Role";
+ asyncResp->res.jsonValue["Description"] = roleId + " User Role";
+ asyncResp->res.jsonValue["OemPrivileges"] =
+ nlohmann::json::array();
+ asyncResp->res.jsonValue["IsPredefined"] = true;
+ asyncResp->res.jsonValue["Id"] = roleId;
+ asyncResp->res.jsonValue["RoleId"] = roleId;
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Roles/" + roleId;
+ asyncResp->res.jsonValue["AssignedPrivileges"] =
+ std::move(privArray);
});
}
@@ -117,11 +119,13 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.id", "/redfish/v1/AccountService/Roles"},
- {"@odata.type", "#RoleCollection.RoleCollection"},
- {"Name", "Roles Collection"},
- {"Description", "BMC User Roles"}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Roles";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#RoleCollection.RoleCollection";
+ asyncResp->res.jsonValue["Name"] = "Roles Collection";
+ asyncResp->res.jsonValue["Description"] = "BMC User Roles";
sdbusplus::asio::getProperty<std::vector<std::string>>(
*crow::connections::systemBus,
@@ -143,10 +147,10 @@
std::string role = getRoleFromPrivileges(priv);
if (!role.empty())
{
- memberArray.push_back(
- {{"@odata.id",
- "/redfish/v1/AccountService/Roles/" +
- role}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/AccountService/Roles/" + role;
+ memberArray.push_back(std::move(member));
}
}
asyncResp->res.jsonValue["Members@odata.count"] =
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 3a5c73b..c7676db 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1263,7 +1263,7 @@
{
health = "Critical";
}
- std::vector<nlohmann::json> redfishCollection;
+ nlohmann::json::array_t redfishCollection;
const auto& fanRedfish =
sensorsAsyncResp->asyncResp->res
.jsonValue["Fans"];
@@ -1286,9 +1286,11 @@
});
if (schemaItem != fanRedfish.end())
{
- redfishCollection.push_back(
- {{"@odata.id",
- (*schemaItem)["@odata.id"]}});
+ nlohmann::json::object_t collection;
+ collection["@odata.id"] =
+ (*schemaItem)["@odata.id"];
+ redfishCollection.emplace_back(
+ std::move(collection));
}
else
{
@@ -1307,23 +1309,25 @@
nlohmann::json& jResp =
sensorsAsyncResp->asyncResp->res
.jsonValue["Redundancy"];
- jResp.push_back(
- {{"@odata.id",
- "/redfish/v1/Chassis/" +
- sensorsAsyncResp->chassisId + "/" +
- sensorsAsyncResp->chassisSubNode +
- "#/Redundancy/" +
- std::to_string(jResp.size())},
- {"@odata.type",
- "#Redundancy.v1_3_2.Redundancy"},
- {"MinNumNeeded", minNumNeeded},
- {"MemberId", name},
- {"Mode", "N+m"},
- {"Name", name},
- {"RedundancySet", redfishCollection},
- {"Status",
- {{"Health", health},
- {"State", "Enabled"}}}});
+
+ nlohmann::json::object_t redundancy;
+ redundancy["@odata.id"] =
+ "/redfish/v1/Chassis/" +
+ sensorsAsyncResp->chassisId + "/" +
+ sensorsAsyncResp->chassisSubNode +
+ "#/Redundancy/" +
+ std::to_string(jResp.size());
+ redundancy["@odata.type"] =
+ "#Redundancy.v1_3_2.Redundancy";
+ redundancy["MinNumNeeded"] = minNumNeeded;
+ redundancy["MemberId"] = name;
+ redundancy["Mode"] = "N+m";
+ redundancy["Name"] = name;
+ redundancy["RedundancySet"] = redfishCollection;
+ redundancy["Status"]["Health"] = health;
+ redundancy["Status"]["State"] = "Enabled";
+
+ jResp.push_back(std::move(redundancy));
},
owner, path, "org.freedesktop.DBus.Properties",
"GetAll",
@@ -2616,12 +2620,13 @@
// Put multiple "sensors" into a single
// PowerControl. Follows MemberId naming and
// naming in power.hpp.
- tempArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Chassis/" +
- sensorsAsyncResp->chassisId + "/" +
- sensorsAsyncResp->chassisSubNode + "#/" +
- fieldName + "/0"}});
+ nlohmann::json::object_t power;
+ power["@odata.id"] =
+ "/redfish/v1/Chassis/" +
+ sensorsAsyncResp->chassisId + "/" +
+ sensorsAsyncResp->chassisSubNode + "#/" +
+ fieldName + "/0";
+ tempArray.push_back(std::move(power));
}
sensorJson = &(tempArray.back());
}
@@ -2636,22 +2641,23 @@
}
else if (fieldName == "Members")
{
- tempArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Chassis/" +
- sensorsAsyncResp->chassisId + "/" +
- sensorsAsyncResp->chassisSubNode + "/" +
- sensorName}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/Chassis/" +
+ sensorsAsyncResp->chassisId + "/" +
+ sensorsAsyncResp->chassisSubNode + "/" + sensorName;
+ tempArray.push_back(std::move(member));
sensorJson = &(tempArray.back());
}
else
{
- tempArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Chassis/" +
- sensorsAsyncResp->chassisId + "/" +
- sensorsAsyncResp->chassisSubNode + "#/" +
- fieldName + "/"}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] = "/redfish/v1/Chassis/" +
+ sensorsAsyncResp->chassisId +
+ "/" +
+ sensorsAsyncResp->chassisSubNode +
+ "#/" + fieldName + "/";
+ tempArray.push_back(std::move(member));
sensorJson = &(tempArray.back());
}
}
@@ -3004,9 +3010,11 @@
messages::internalError(asyncResp->asyncResp->res);
return;
}
- entriesArray.push_back(
- {{"@odata.id", "/redfish/v1/Chassis/" + asyncResp->chassisId + "/" +
- asyncResp->chassisSubNode + "/" + sensorName}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] = "/redfish/v1/Chassis/" + asyncResp->chassisId +
+ "/" + asyncResp->chassisSubNode + "/" +
+ sensorName;
+ entriesArray.push_back(std::move(member));
}
asyncResp->asyncResp->res.jsonValue["Members@odata.count"] =
diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp
index d7214ee..7760b4c 100644
--- a/redfish-core/lib/service_root.hpp
+++ b/redfish-core/lib/service_root.hpp
@@ -39,35 +39,30 @@
asyncResp->res.jsonValue["Id"] = "RootService";
asyncResp->res.jsonValue["Name"] = "Root Service";
asyncResp->res.jsonValue["RedfishVersion"] = "1.9.0";
- asyncResp->res.jsonValue["Links"]["Sessions"] = {
- {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
- asyncResp->res.jsonValue["AccountService"] = {
- {"@odata.id", "/redfish/v1/AccountService"}};
- asyncResp->res.jsonValue["Chassis"] = {
- {"@odata.id", "/redfish/v1/Chassis"}};
- asyncResp->res.jsonValue["JsonSchemas"] = {
- {"@odata.id", "/redfish/v1/JsonSchemas"}};
- asyncResp->res.jsonValue["Managers"] = {
- {"@odata.id", "/redfish/v1/Managers"}};
- asyncResp->res.jsonValue["SessionService"] = {
- {"@odata.id", "/redfish/v1/SessionService"}};
- asyncResp->res.jsonValue["Systems"] = {
- {"@odata.id", "/redfish/v1/Systems"}};
- asyncResp->res.jsonValue["Registries"] = {
- {"@odata.id", "/redfish/v1/Registries"}};
-
- asyncResp->res.jsonValue["UpdateService"] = {
- {"@odata.id", "/redfish/v1/UpdateService"}};
+ asyncResp->res.jsonValue["Links"]["Sessions"]["@odata.id"] =
+ "/redfish/v1/SessionService/Sessions";
+ asyncResp->res.jsonValue["AccountService"]["@odata.id"] =
+ "/redfish/v1/AccountService";
+ asyncResp->res.jsonValue["Chassis"]["@odata.id"] = "/redfish/v1/Chassis";
+ asyncResp->res.jsonValue["JsonSchemas"]["@odata.id"] =
+ "/redfish/v1/JsonSchemas";
+ asyncResp->res.jsonValue["Managers"]["@odata.id"] = "/redfish/v1/Managers";
+ asyncResp->res.jsonValue["SessionService"]["@odata.id"] =
+ "/redfish/v1/SessionService";
+ asyncResp->res.jsonValue["Systems"]["@odata.id"] = "/redfish/v1/Systems";
+ asyncResp->res.jsonValue["Registries"]["@odata.id"] =
+ "/redfish/v1/Registries";
+ asyncResp->res.jsonValue["UpdateService"]["@odata.id"] =
+ "/redfish/v1/UpdateService";
asyncResp->res.jsonValue["UUID"] = uuid;
- asyncResp->res.jsonValue["CertificateService"] = {
- {"@odata.id", "/redfish/v1/CertificateService"}};
- asyncResp->res.jsonValue["Tasks"] = {
- {"@odata.id", "/redfish/v1/TaskService"}};
- asyncResp->res.jsonValue["EventService"] = {
- {"@odata.id", "/redfish/v1/EventService"}};
- asyncResp->res.jsonValue["TelemetryService"] = {
- {"@odata.id", "/redfish/v1/TelemetryService"}};
- asyncResp->res.jsonValue["Cables"] = {{"@odata.id", "/redfish/v1/Cables"}};
+ asyncResp->res.jsonValue["CertificateService"]["@odata.id"] =
+ "/redfish/v1/CertificateService";
+ asyncResp->res.jsonValue["Tasks"]["@odata.id"] = "/redfish/v1/TaskService";
+ asyncResp->res.jsonValue["EventService"]["@odata.id"] =
+ "/redfish/v1/EventService";
+ asyncResp->res.jsonValue["TelemetryService"]["@odata.id"] =
+ "/redfish/v1/TelemetryService";
+ asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables";
nlohmann::json& protocolFeatures =
asyncResp->res.jsonValue["ProtocolFeaturesSupported"];
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index 0f5b0f9..c86adab 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -42,8 +42,11 @@
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Systems/system/Storage";
asyncResp->res.jsonValue["Name"] = "Storage Collection";
- asyncResp->res.jsonValue["Members"] = {
- {{"@odata.id", "/redfish/v1/Systems/system/Storage/1"}}};
+ nlohmann::json::array_t members;
+ nlohmann::json::object_t member;
+ member["@odata.id"] = "/redfish/v1/Systems/system/Storage/1";
+ members.emplace_back(member);
+ asyncResp->res.jsonValue["Members"] = std::move(members);
asyncResp->res.jsonValue["Members@odata.count"] = 1;
});
}
@@ -103,11 +106,11 @@
<< objpath;
continue;
}
-
- storageArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/Storage/1/Drives/" +
- objpath.substr(lastPos + 1)}});
+ nlohmann::json::object_t storage;
+ storage["@odata.id"] =
+ "/redfish/v1/Systems/system/Storage/1/Drives/" +
+ objpath.substr(lastPos + 1);
+ storageArray.push_back(std::move(storage));
}
count = storageArray.size();
@@ -549,9 +552,9 @@
asyncResp,
[](const std::string& chassisId,
const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
- aRsp->res.jsonValue["Links"]["Chassis"] = {
- {"@odata.id",
- "/redfish/v1/Chassis/" + chassisId}};
+ aRsp->res
+ .jsonValue["Links"]["Chassis"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId;
});
// default it to Enabled
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index cedd28d..e136aea 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -2675,15 +2675,18 @@
ifaceArray = nlohmann::json::array();
auto& count =
asyncResp->res.jsonValue["Members@odata.count"];
- ifaceArray.push_back(
- {{"@odata.id", "/redfish/v1/Systems/system"}});
+
+ nlohmann::json::object_t system;
+ system["@odata.id"] = "/redfish/v1/Systems/system";
+ ifaceArray.push_back(std::move(system));
count = ifaceArray.size();
if (!ec)
{
BMCWEB_LOG_DEBUG << "Hypervisor is available";
- ifaceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/hypervisor"}});
+ nlohmann::json::object_t hypervisor;
+ hypervisor["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor";
+ ifaceArray.push_back(std::move(hypervisor));
count = ifaceArray.size();
}
});
@@ -2883,54 +2886,56 @@
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Systems/system";
- asyncResp->res.jsonValue["Processors"] = {
- {"@odata.id", "/redfish/v1/Systems/system/Processors"}};
- asyncResp->res.jsonValue["Memory"] = {
- {"@odata.id", "/redfish/v1/Systems/system/Memory"}};
- asyncResp->res.jsonValue["Storage"] = {
- {"@odata.id", "/redfish/v1/Systems/system/Storage"}};
+ asyncResp->res.jsonValue["Processors"]["@odata.id"] =
+ "/redfish/v1/Systems/system/Processors";
+ asyncResp->res.jsonValue["Memory"]["@odata.id"] =
+ "/redfish/v1/Systems/system/Memory";
+ asyncResp->res.jsonValue["Storage"]["@odata.id"] =
+ "/redfish/v1/Systems/system/Storage";
- asyncResp->res.jsonValue["Actions"]["#ComputerSystem.Reset"] = {
- {"target",
- "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"},
- {"@Redfish.ActionInfo",
- "/redfish/v1/Systems/system/ResetActionInfo"}};
+ asyncResp->res
+ .jsonValue["Actions"]["#ComputerSystem.Reset"]["target"] =
+ "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset";
+ asyncResp->res.jsonValue["Actions"]["#ComputerSystem.Reset"]
+ ["@Redfish.ActionInfo"] =
+ "/redfish/v1/Systems/system/ResetActionInfo";
- asyncResp->res.jsonValue["LogServices"] = {
- {"@odata.id", "/redfish/v1/Systems/system/LogServices"}};
+ asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices";
+ asyncResp->res.jsonValue["Bios"]["@odata.id"] =
+ "/redfish/v1/Systems/system/Bios";
- asyncResp->res.jsonValue["Bios"] = {
- {"@odata.id", "/redfish/v1/Systems/system/Bios"}};
-
- asyncResp->res.jsonValue["Links"]["ManagedBy"] = {
- {{"@odata.id", "/redfish/v1/Managers/bmc"}}};
-
- asyncResp->res.jsonValue["Status"] = {
- {"Health", "OK"},
- {"State", "Enabled"},
- };
+ nlohmann::json::array_t managedBy;
+ nlohmann::json& manager = managedBy.emplace_back();
+ manager["@odata.id"] = "/redfish/v1/Managers/bmc";
+ asyncResp->res.jsonValue["Links"]["ManagedBy"] =
+ std::move(managedBy);
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
// Fill in SerialConsole info
asyncResp->res.jsonValue["SerialConsole"]["MaxConcurrentSessions"] =
15;
- asyncResp->res.jsonValue["SerialConsole"]["IPMI"] = {
- {"ServiceEnabled", true},
- };
+ asyncResp->res
+ .jsonValue["SerialConsole"]["IPMI"]["ServiceEnabled"] = true;
+
// TODO (Gunnar): Should look for obmc-console-ssh@2200.service
- asyncResp->res.jsonValue["SerialConsole"]["SSH"] = {
- {"ServiceEnabled", true},
- {"Port", 2200},
- // https://github.com/openbmc/docs/blob/master/console.md
- {"HotKeySequenceDisplay", "Press ~. to exit console"},
- };
+ asyncResp->res.jsonValue["SerialConsole"]["SSH"]["ServiceEnabled"] =
+ true;
+ asyncResp->res.jsonValue["SerialConsole"]["SSH"]["Port"] = 2200;
+ asyncResp->res
+ .jsonValue["SerialConsole"]["SSH"]["HotKeySequenceDisplay"] =
+ "Press ~. to exit console";
#ifdef BMCWEB_ENABLE_KVM
// Fill in GraphicalConsole info
- asyncResp->res.jsonValue["GraphicalConsole"] = {
- {"ServiceEnabled", true},
- {"MaxConcurrentSessions", 4},
- {"ConnectTypesSupported", {"KVMIP"}},
- };
+ asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] =
+ true;
+ asyncResp->res
+ .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4;
+ asyncResp->res.jsonValue["GraphicalConsole"]
+ ["ConnectTypesSupported"] = {"KVMIP"};
+
#endif // BMCWEB_ENABLE_KVM
constexpr const std::array<const char*, 4> inventoryForSystems = {
"xyz.openbmc_project.Inventory.Item.Dimm",
@@ -2960,8 +2965,8 @@
getMainChassisId(
asyncResp, [](const std::string& chassisId,
const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
- aRsp->res.jsonValue["Links"]["Chassis"] = {
- {{"@odata.id", "/redfish/v1/Chassis/" + chassisId}}};
+ aRsp->res.jsonValue["Links"]["Chassis"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId;
});
getLocationIndicatorActive(asyncResp);
@@ -3106,7 +3111,6 @@
*/
inline void requestRoutesSystemResetActionInfo(App& app)
{
-
/**
* Functions triggers appropriate requests on DBus
*/
@@ -3119,19 +3123,25 @@
{
return;
}
- asyncResp->res.jsonValue = {
- {"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
- {"@odata.id", "/redfish/v1/Systems/system/ResetActionInfo"},
- {"Name", "Reset Action Info"},
- {"Id", "ResetActionInfo"},
- {"Parameters",
- {{{"Name", "ResetType"},
- {"Required", true},
- {"DataType", "String"},
- {"AllowableValues",
- {"On", "ForceOff", "ForceOn", "ForceRestart",
- "GracefulRestart", "GracefulShutdown", "PowerCycle",
- "Nmi"}}}}}};
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/ResetActionInfo";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ asyncResp->res.jsonValue["Parameters"]["Name"] = "ResetType";
+ asyncResp->res.jsonValue["Parameters"]["Required"] = true;
+ asyncResp->res.jsonValue["Parameters"]["DataType"] = "String";
+ asyncResp->res.jsonValue["Parameters"]["AllowableValues"] = {
+ "On",
+ "ForceOff",
+ "ForceOn",
+ "ForceRestart",
+ "GracefulRestart",
+ "GracefulShutdown",
+ "PowerCycle",
+ "Nmi"};
});
}
} // namespace redfish
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 199bc84..0c2eee4 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -139,11 +139,13 @@
res.result(boost::beast::http::status::accepted);
std::string strIdx = std::to_string(index);
std::string uri = "/redfish/v1/TaskService/Tasks/" + strIdx;
- res.jsonValue = {{"@odata.id", uri},
- {"@odata.type", "#Task.v1_4_3.Task"},
- {"Id", strIdx},
- {"TaskState", state},
- {"TaskStatus", status}};
+
+ res.jsonValue["@odata.id"] = uri;
+ res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
+ res.jsonValue["Id"] = strIdx;
+ res.jsonValue["TaskState"] = state;
+ res.jsonValue["TaskStatus"] = status;
+
res.addHeader(boost::beast::http::field::location,
uri + "/Monitor");
res.addHeader(boost::beast::http::field::retry_after,
@@ -416,14 +418,16 @@
if (ptr->payload)
{
const task::Payload& p = *(ptr->payload);
- asyncResp->res.jsonValue["Payload"] = {
- {"TargetUri", p.targetUri},
- {"HttpOperation", p.httpOperation},
- {"HttpHeaders", p.httpHeaders},
- {"JsonBody",
- p.jsonBody.dump(
- 2, ' ', true,
- nlohmann::json::error_handler_t::replace)}};
+ asyncResp->res.jsonValue["Payload"]["TargetUri"] =
+ p.targetUri;
+ asyncResp->res.jsonValue["Payload"]["HttpOperation"] =
+ p.httpOperation;
+ asyncResp->res.jsonValue["Payload"]["HttpHeaders"] =
+ p.httpHeaders;
+ asyncResp->res.jsonValue["Payload"]["JsonBody"] =
+ p.jsonBody.dump(
+ 2, ' ', true,
+ nlohmann::json::error_handler_t::replace);
}
asyncResp->res.jsonValue["PercentComplete"] =
ptr->percentComplete;
@@ -493,8 +497,8 @@
health->populate();
asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
asyncResp->res.jsonValue["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["Tasks"] = {
- {"@odata.id", "/redfish/v1/TaskService/Tasks"}};
+ asyncResp->res.jsonValue["Tasks"]["@odata.id"] =
+ "/redfish/v1/TaskService/Tasks";
});
}
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index e2f46ec..cdd58b8 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -129,10 +129,10 @@
{
return std::nullopt;
}
-
- thresholds[type] = {{"Reading", reading},
- {"Activation", activation},
- {"DwellTime", *duration}};
+ nlohmann::json& threshold = thresholds[type];
+ threshold["Reading"] = reading;
+ threshold["Activation"] = activation;
+ threshold["DwellTime"] = *duration;
}
return std::make_optional(thresholds);
@@ -144,11 +144,12 @@
nlohmann::json reports = nlohmann::json::array();
for (const std::string& name : reportNames)
{
- reports.push_back(
- {{"@odata.id",
- crow::utility::urlFromPieces("redfish", "v1", "TelemetryService",
- "MetricReportDefinitions", name)
- .string()}});
+ nlohmann::json::object_t report;
+ report["@odata.id"] =
+ crow::utility::urlFromPieces("redfish", "v1", "TelemetryService",
+ "MetricReportDefinitions", name)
+ .string();
+ reports.push_back(std::move(report));
}
return reports;
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 70fe8db..b5108ae 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -560,8 +560,8 @@
"/redfish/v1/UpdateService";
// UpdateService cannot be disabled
asyncResp->res.jsonValue["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["FirmwareInventory"] = {
- {"@odata.id", "/redfish/v1/UpdateService/FirmwareInventory"}};
+ asyncResp->res.jsonValue["FirmwareInventory"]["@odata.id"] =
+ "/redfish/v1/UpdateService/FirmwareInventory";
// Get the MaxImageSizeBytes
asyncResp->res.jsonValue["MaxImageSizeBytes"] =
bmcwebHttpReqBodyLimitMb * 1024 * 1024;
@@ -725,66 +725,67 @@
{
BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/FirmwareInventory/")
.privileges(redfish::privileges::getSoftwareInventoryCollection)
- .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>&
- asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#SoftwareInventoryCollection.SoftwareInventoryCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/UpdateService/FirmwareInventory";
- asyncResp->res.jsonValue["Name"] = "Software Inventory Collection";
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#SoftwareInventoryCollection.SoftwareInventoryCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/UpdateService/FirmwareInventory";
+ asyncResp->res.jsonValue["Name"] =
+ "Software Inventory Collection";
- crow::connections::systemBus->async_method_call(
- [asyncResp](
- const boost::system::error_code ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Members"] =
- nlohmann::json::array();
- asyncResp->res.jsonValue["Members@odata.count"] = 0;
-
- for (const auto& obj : subtree)
- {
- sdbusplus::message::object_path path(obj.first);
- std::string swId = path.filename();
- if (swId.empty())
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
+ const dbus::utility::MapperGetSubTreeResponse&
+ subtree) {
+ if (ec)
{
messages::internalError(asyncResp->res);
- BMCWEB_LOG_DEBUG << "Can't parse firmware ID!!";
return;
}
+ asyncResp->res.jsonValue["Members"] =
+ nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
- nlohmann::json& members =
- asyncResp->res.jsonValue["Members"];
- members.push_back(
- {{"@odata.id",
- "/redfish/v1/UpdateService/FirmwareInventory/" +
- swId}});
- asyncResp->res.jsonValue["Members@odata.count"] =
- members.size();
- }
- },
- // Note that only firmware levels associated with a device
- // are stored under /xyz/openbmc_project/software therefore
- // to ensure only real FirmwareInventory items are returned,
- // this full object path must be used here as input to
- // mapper
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/software", static_cast<int32_t>(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Software.Version"});
- });
+ for (const auto& obj : subtree)
+ {
+ sdbusplus::message::object_path path(obj.first);
+ std::string swId = path.filename();
+ if (swId.empty())
+ {
+ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_DEBUG << "Can't parse firmware ID!!";
+ return;
+ }
+
+ nlohmann::json& members =
+ asyncResp->res.jsonValue["Members"];
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/UpdateService/FirmwareInventory/" +
+ swId;
+ members.push_back(std::move(member));
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ members.size();
+ }
+ },
+ // Note that only firmware levels associated with a device
+ // are stored under /xyz/openbmc_project/software therefore
+ // to ensure only real FirmwareInventory items are returned,
+ // this full object path must be used here as input to
+ // mapper
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree",
+ "/xyz/openbmc_project/software", static_cast<int32_t>(0),
+ std::array<const char*, 1>{
+ "xyz.openbmc_project.Software.Version"});
+ });
}
/* Fill related item links (i.e. bmc, bios) in for inventory */
inline static void
@@ -794,14 +795,17 @@
if (purpose == fw_util::bmcPurpose)
{
nlohmann::json& relatedItem = aResp->res.jsonValue["RelatedItem"];
- relatedItem.push_back({{"@odata.id", "/redfish/v1/Managers/bmc"}});
+ nlohmann::json::object_t item;
+ item["@odata.id"] = "/redfish/v1/Managers/bmc";
+ relatedItem.push_back(std::move(item));
aResp->res.jsonValue["RelatedItem@odata.count"] = relatedItem.size();
}
else if (purpose == fw_util::biosPurpose)
{
nlohmann::json& relatedItem = aResp->res.jsonValue["RelatedItem"];
- relatedItem.push_back(
- {{"@odata.id", "/redfish/v1/Systems/system/Bios"}});
+ nlohmann::json::object_t item;
+ item["@odata.id"] = "/redfish/v1/Systems/system/Bios";
+ relatedItem.push_back(std::move(item));
aResp->res.jsonValue["RelatedItem@odata.count"] = relatedItem.size();
}
else
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 5c4fb31..6353167 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -54,8 +54,8 @@
<< "Attempt to add error message without Message";
return;
}
- error = {{"code", *messageIdIterator},
- {"message", *messageFieldIterator}};
+ error["code"] = *messageIdIterator;
+ error["message"] = *messageFieldIterator;
}
else
{
@@ -129,12 +129,14 @@
std::string msgId = redfish::registries::base::header.id;
msgId += ".";
msgId += entry.first;
- return {{"@odata.type", "#Message.v1_1_1.Message"},
- {"MessageId", std::move(msgId)},
- {"Message", std::move(msg)},
- {"MessageArgs", std::move(jArgs)},
- {"MessageSeverity", entry.second.messageSeverity},
- {"Resolution", entry.second.resolution}};
+ nlohmann::json::object_t response;
+ response["@odata.type"] = "#Message.v1_1_1.Message";
+ response["MessageId"] = std::move(msgId);
+ response["Message"] = std::move(msg);
+ response["MessageArgs"] = std::move(jArgs);
+ response["MessageSeverity"] = entry.second.messageSeverity;
+ response["Resolution"] = entry.second.resolution;
+ return response;
}
/**