summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-03-15 20:44:42 +0300
committerEd Tanous <edtanous@google.com>2022-05-13 01:08:18 +0300
commit1476687deb1697d865b20458a0097c9ab5fd44e2 (patch)
tree6964ba82c382d03522f7a413a61ae1164b8e242e
parent1656b296313d75b172dcdbe5f37ff1d1b54800dc (diff)
downloadbmcweb-1476687deb1697d865b20458a0097c9ab5fd44e2.tar.xz
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
-rw-r--r--include/dbus_monitor.hpp13
-rw-r--r--include/ibm/management_console_rest.hpp12
-rw-r--r--include/image_upload.hpp15
-rw-r--r--include/login_routes.hpp22
-rw-r--r--include/openbmc_dbus_rest.hpp112
-rw-r--r--include/persistent_data.hpp81
-rw-r--r--redfish-core/include/event_service_manager.hpp34
-rw-r--r--redfish-core/include/utils/collection.hpp4
-rw-r--r--redfish-core/lib/account_service.hpp145
-rw-r--r--redfish-core/lib/certificate_service.hpp135
-rw-r--r--redfish-core/lib/chassis.hpp96
-rw-r--r--redfish-core/lib/ethernet.hpp216
-rw-r--r--redfish-core/lib/event_service.hpp53
-rw-r--r--redfish-core/lib/hypervisor_system.hpp140
-rw-r--r--redfish-core/lib/log_services.hpp153
-rw-r--r--redfish-core/lib/managers.hpp120
-rw-r--r--redfish-core/lib/message_registries.hpp83
-rw-r--r--redfish-core/lib/network_protocol.hpp5
-rw-r--r--redfish-core/lib/pcie.hpp100
-rw-r--r--redfish-core/lib/power.hpp17
-rw-r--r--redfish-core/lib/processor.hpp24
-rw-r--r--redfish-core/lib/redfish_sessions.hpp9
-rw-r--r--redfish-core/lib/redfish_v1.hpp2
-rw-r--r--redfish-core/lib/roles.hpp42
-rw-r--r--redfish-core/lib/sensors.hpp92
-rw-r--r--redfish-core/lib/service_root.hpp51
-rw-r--r--redfish-core/lib/storage.hpp23
-rw-r--r--redfish-core/lib/systems.hpp132
-rw-r--r--redfish-core/lib/task.hpp34
-rw-r--r--redfish-core/lib/trigger.hpp19
-rw-r--r--redfish-core/lib/update_service.hpp124
-rw-r--r--redfish-core/src/error_messages.cpp18
32 files changed, 1140 insertions, 986 deletions
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 764d157985..977f3a3a3a 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -45,8 +45,9 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
return 0;
}
sdbusplus::message::message message(m);
- nlohmann::json j{{"event", message.get_member()},
- {"path", message.get_path()}};
+ nlohmann::json json;
+ json["event"] = message.get_member();
+ json["path"] = message.get_path();
if (strcmp(message.get_member(), "PropertiesChanged") == 0)
{
nlohmann::json data;
@@ -63,8 +64,8 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
}
// data is type sa{sv}as and is an array[3] of string, object, array
- j["interface"] = data[0];
- j["properties"] = data[1];
+ json["interface"] = data[0];
+ json["properties"] = data[1];
}
else if (strcmp(message.get_member(), "InterfacesAdded") == 0)
{
@@ -88,7 +89,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
auto it = thisSession->second.interfaces.find(entry.key());
if (it != thisSession->second.interfaces.end())
{
- j["interfaces"][entry.key()] = entry.value();
+ json["interfaces"][entry.key()] = entry.value();
}
}
}
@@ -100,7 +101,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
}
connection->sendText(
- j.dump(2, ' ', true, nlohmann::json::error_handler_t::replace));
+ json.dump(2, ' ', true, nlohmann::json::error_handler_t::replace));
return 0;
}
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 8e307464ca..0fbd2e22c1 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -690,12 +690,12 @@ inline void requestRoutes(App& app)
asyncResp->res.jsonValue["@odata.id"] = "/ibm/v1/";
asyncResp->res.jsonValue["Id"] = "IBM Rest RootService";
asyncResp->res.jsonValue["Name"] = "IBM Service Root";
- asyncResp->res.jsonValue["ConfigFiles"] = {
- {"@odata.id", "/ibm/v1/Host/ConfigFiles"}};
- asyncResp->res.jsonValue["LockService"] = {
- {"@odata.id", "/ibm/v1/HMC/LockService"}};
- asyncResp->res.jsonValue["BroadcastService"] = {
- {"@odata.id", "/ibm/v1/HMC/BroadcastService"}};
+ asyncResp->res.jsonValue["ConfigFiles"]["@odata.id"] =
+ "/ibm/v1/Host/ConfigFiles";
+ asyncResp->res.jsonValue["LockService"]["@odata.id"] =
+ "/ibm/v1/HMC/LockService";
+ asyncResp->res.jsonValue["BroadcastService"]["@odata.id"] =
+ "/ibm/v1/HMC/BroadcastService";
});
BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles")
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index 330ea9c379..aefb27e3a8 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -51,12 +51,10 @@ inline void
}
asyncResp->res.result(boost::beast::http::status::bad_request);
- asyncResp->res.jsonValue = {
- {"data",
- {{"description",
- "Version already exists or failed to be extracted"}}},
- {"message", "400 Bad Request"},
- {"status", "error"}};
+ asyncResp->res.jsonValue["data"]["description"] =
+ "Version already exists or failed to be extracted";
+ asyncResp->res.jsonValue["message"] = "400 Bad Request";
+ asyncResp->res.jsonValue["status"] = "error";
};
std::function<void(sdbusplus::message::message&)> callback =
@@ -80,8 +78,9 @@ inline void
leaf = path.str;
}
- asyncResp->res.jsonValue = {
- {"data", leaf}, {"message", "200 OK"}, {"status", "ok"}};
+ asyncResp->res.jsonValue["data"] = leaf;
+ asyncResp->res.jsonValue["message"] = "200 OK";
+ asyncResp->res.jsonValue["status"] = "ok";
BMCWEB_LOG_DEBUG << "ending response";
fwUpdateMatcher = nullptr;
}
diff --git a/include/login_routes.hpp b/include/login_routes.hpp
index abcdaee3dc..a4fa9b7ad1 100644
--- a/include/login_routes.hpp
+++ b/include/login_routes.hpp
@@ -199,11 +199,11 @@ inline void requestRoutes(App& app)
// structure, and doesn't actually look at the status
// code.
// TODO(ed).... Fix that upstream
- asyncResp->res.jsonValue = {
- {"data",
- "User '" + std::string(username) + "' logged in"},
- {"message", "200 OK"},
- {"status", "ok"}};
+
+ asyncResp->res.jsonValue["data"] =
+ "User '" + std::string(username) + "' logged in";
+ asyncResp->res.jsonValue["message"] = "200 OK";
+ asyncResp->res.jsonValue["status"] = "ok";
// Hack alert. Boost beast by default doesn't let you
// declare multiple headers of the same name, and in
@@ -226,8 +226,8 @@ inline void requestRoutes(App& app)
else
{
// if content type is json, assume json token
- asyncResp->res.jsonValue = {
- {"token", session->sessionToken}};
+ asyncResp->res.jsonValue["token"] =
+ session->sessionToken;
}
}
}
@@ -245,10 +245,10 @@ inline void requestRoutes(App& app)
const auto& session = req.session;
if (session != nullptr)
{
- asyncResp->res.jsonValue = {
- {"data", "User '" + session->username + "' logged out"},
- {"message", "200 OK"},
- {"status", "ok"}};
+ asyncResp->res.jsonValue["data"] =
+ "User '" + session->username + "' logged out";
+ asyncResp->res.jsonValue["message"] = "200 OK";
+ asyncResp->res.jsonValue["status"] = "ok";
persistent_data::SessionStore::getInstance().removeSession(
session);
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 4f4bd71ff6..75e31f19f9 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -57,9 +57,9 @@ inline void setErrorResponse(crow::Response& res,
const std::string_view msg)
{
res.result(result);
- res.jsonValue = {{"data", {{"description", desc}}},
- {"message", msg},
- {"status", "error"}};
+ res.jsonValue["data"]["description"] = desc;
+ res.jsonValue["message"] = msg;
+ res.jsonValue["status"] = "error";
}
inline void
@@ -69,9 +69,9 @@ inline void
{
if (transaction->res.jsonValue.is_null())
{
- transaction->res.jsonValue = {{"status", "ok"},
- {"bus_name", processName},
- {"objects", nlohmann::json::array()}};
+ transaction->res.jsonValue["status"] = "ok";
+ transaction->res.jsonValue["bus_name"] = processName;
+ transaction->res.jsonValue["objects"] = nlohmann::json::array();
}
crow::connections::systemBus->async_method_call(
@@ -87,8 +87,10 @@ inline void
<< "\n";
return;
}
- transaction->res.jsonValue["objects"].push_back(
- {{"path", objectPath}});
+ nlohmann::json::object_t object;
+ object["path"] = objectPath;
+
+ transaction->res.jsonValue["objects"].push_back(std::move(object));
tinyxml2::XMLDocument doc;
@@ -468,9 +470,9 @@ struct InProgressActionData
}
else
{
- res.jsonValue = {{"status", "ok"},
- {"message", "200 OK"},
- {"data", methodResponse}};
+ res.jsonValue["status"] = "ok";
+ res.jsonValue["message"] = "200 OK";
+ res.jsonValue["data"] = methodResponse;
}
}
}
@@ -1626,9 +1628,9 @@ inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
}
else
{
- asyncResp->res.jsonValue = {{"status", "ok"},
- {"message", "200 OK"},
- {"data", objectPaths}};
+ asyncResp->res.jsonValue["status"] = "ok";
+ asyncResp->res.jsonValue["message"] = "200 OK";
+ asyncResp->res.jsonValue["data"] = objectPaths;
}
},
"xyz.openbmc_project.ObjectMapper",
@@ -1642,9 +1644,9 @@ inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
{
BMCWEB_LOG_DEBUG << "Doing enumerate on " << objectPath;
- asyncResp->res.jsonValue = {{"message", "200 OK"},
- {"status", "ok"},
- {"data", nlohmann::json::object()}};
+ asyncResp->res.jsonValue["message"] = "200 OK";
+ asyncResp->res.jsonValue["status"] = "ok";
+ asyncResp->res.jsonValue["data"] = nlohmann::json::object();
crow::connections::systemBus->async_method_call(
[objectPath, asyncResp](
@@ -1773,10 +1775,11 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
}
else
{
- asyncResp->res.jsonValue = {
- {"status", "ok"},
- {"message", "200 OK"},
- {"data", *response}};
+ asyncResp->res.jsonValue["status"] = "ok";
+ asyncResp->res.jsonValue["message"] =
+ "200 OK";
+ asyncResp->res.jsonValue["data"] =
+ *response;
}
}
});
@@ -2000,11 +2003,17 @@ inline void handlePut(const crow::Request& req,
else
{
transaction->asyncResp
- ->res.jsonValue = {
- {"status", "ok"},
- {"message",
- "200 OK"},
- {"data", nullptr}};
+ ->res.jsonValue
+ ["status"] =
+ "ok";
+ transaction->asyncResp
+ ->res.jsonValue
+ ["message"] =
+ "200 OK";
+ transaction->asyncResp
+ ->res
+ .jsonValue["data"] =
+ nullptr;
}
});
}
@@ -2178,16 +2187,17 @@ inline void
BMCWEB_LOG_ERROR << "XML document failed to parse "
<< processName << " " << objectPath
<< "\n";
- asyncResp->res.jsonValue = {{"status", "XML parse error"}};
+ asyncResp->res.jsonValue["status"] = "XML parse error";
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return;
}
BMCWEB_LOG_DEBUG << introspectXml;
- asyncResp->res.jsonValue = {{"status", "ok"},
- {"bus_name", processName},
- {"object_path", objectPath}};
+ asyncResp->res.jsonValue["status"] = "ok";
+ asyncResp->res.jsonValue["bus_name"] = processName;
+ asyncResp->res.jsonValue["object_path"] = objectPath;
+
nlohmann::json& interfacesArray =
asyncResp->res.jsonValue["interfaces"];
interfacesArray = nlohmann::json::array();
@@ -2199,7 +2209,9 @@ inline void
const char* ifaceName = interface->Attribute("name");
if (ifaceName != nullptr)
{
- interfacesArray.push_back({{"name", ifaceName}});
+ nlohmann::json::object_t interface;
+ interface["name"] = ifaceName;
+ interfacesArray.push_back(std::move(interface));
}
interface = interface->NextSiblingElement("interface");
@@ -2235,10 +2247,11 @@ inline void
boost::beast::http::status::internal_server_error);
return;
}
- asyncResp->res.jsonValue = {{"status", "ok"},
- {"bus_name", processName},
- {"interface", interfaceName},
- {"object_path", objectPath}};
+
+ asyncResp->res.jsonValue["status"] = "ok";
+ asyncResp->res.jsonValue["bus_name"] = processName;
+ asyncResp->res.jsonValue["interface"] = interfaceName;
+ asyncResp->res.jsonValue["object_path"] = objectPath;
nlohmann::json& methodsArray =
asyncResp->res.jsonValue["methods"];
@@ -2313,9 +2326,13 @@ inline void
uri += interfaceName;
uri += "/";
uri += name;
- methodsArray.push_back({{"name", name},
- {"uri", std::move(uri)},
- {"args", argsArray}});
+
+ nlohmann::json::object_t object;
+ object["name"] = name;
+ object["uri"] = std::move(uri);
+ object["args"] = argsArray;
+
+ methodsArray.push_back(std::move(object));
}
methods = methods->NextSiblingElement("method");
}
@@ -2343,8 +2360,10 @@ inline void
const char* name = signals->Attribute("name");
if (name != nullptr)
{
- signalsArray.push_back(
- {{"name", name}, {"args", argsArray}});
+ nlohmann::json::object_t object;
+ object["name"] = name;
+ object["args"] = argsArray;
+ signalsArray.push_back(std::move(object));
}
signals = signals->NextSiblingElement("signal");
@@ -2424,8 +2443,11 @@ inline void requestRoutes(App& app)
.methods(boost::beast::http::verb::get)(
[](const crow::Request&,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- asyncResp->res.jsonValue = {{"buses", {{{"name", "system"}}}},
- {"status", "ok"}};
+ nlohmann::json::array_t buses;
+ nlohmann::json& bus = buses.emplace_back();
+ bus["name"] = "system";
+ asyncResp->res.jsonValue["busses"] = std::move(buses);
+ asyncResp->res.jsonValue["status"] = "ok";
});
BMCWEB_ROUTE(app, "/bus/system/")
@@ -2445,11 +2467,13 @@ inline void requestRoutes(App& app)
else
{
std::sort(names.begin(), names.end());
- asyncResp->res.jsonValue = {{"status", "ok"}};
+ asyncResp->res.jsonValue["status"] = "ok";
auto& objectsSub = asyncResp->res.jsonValue["objects"];
for (auto& name : names)
{
- objectsSub.push_back({{"name", name}});
+ nlohmann::json::object_t object;
+ object["name"] = name;
+ objectsSub.push_back(std::move(object));
}
}
};
diff --git a/include/persistent_data.hpp b/include/persistent_data.hpp
index 6d0f7c1a1d..1ca925eb23 100644
--- a/include/persistent_data.hpp
+++ b/include/persistent_data.hpp
@@ -207,25 +207,25 @@ class ConfigFile
const auto& c = SessionStore::getInstance().getAuthMethodsConfig();
const auto& eventServiceConfig =
EventServiceStore::getInstance().getEventServiceConfig();
- nlohmann::json data{
- {"auth_config",
- {{"XToken", c.xtoken},
- {"Cookie", c.cookie},
- {"SessionToken", c.sessionToken},
- {"BasicAuth", c.basic},
- {"TLS", c.tls}}
+ nlohmann::json::object_t data;
+ nlohmann::json& authConfig = data["auth_config"];
- },
- {"eventservice_config",
- {{"ServiceEnabled", eventServiceConfig.enabled},
- {"DeliveryRetryAttempts", eventServiceConfig.retryAttempts},
- {"DeliveryRetryIntervalSeconds",
- eventServiceConfig.retryTimeoutInterval}}
+ authConfig["XToken"] = c.xtoken;
+ authConfig["Cookie"] = c.cookie;
+ authConfig["SessionToken"] = c.sessionToken;
+ authConfig["BasicAuth"] = c.basic;
+ authConfig["TLS"] = c.tls;
- },
- {"system_uuid", systemUuid},
- {"revision", jsonRevision},
- {"timeout", SessionStore::getInstance().getTimeoutInSeconds()}};
+ nlohmann::json& eventserviceConfig = data["eventservice_config"];
+ eventserviceConfig["ServiceEnabled"] = eventServiceConfig.enabled;
+ eventserviceConfig["DeliveryRetryAttempts"] =
+ eventServiceConfig.retryAttempts;
+ eventserviceConfig["DeliveryRetryIntervalSeconds"] =
+ eventServiceConfig.retryTimeoutInterval;
+
+ data["system_uuid"] = systemUuid;
+ data["revision"] = jsonRevision;
+ data["timeout"] = SessionStore::getInstance().getTimeoutInSeconds();
nlohmann::json& sessions = data["sessions"];
sessions = nlohmann::json::array();
@@ -234,16 +234,16 @@ class ConfigFile
if (p.second->persistence !=
persistent_data::PersistenceType::SINGLE_REQUEST)
{
- sessions.push_back({
- {"unique_id", p.second->uniqueId},
- {"session_token", p.second->sessionToken},
- {"username", p.second->username},
- {"csrf_token", p.second->csrfToken},
- {"client_ip", p.second->clientIp},
+ nlohmann::json::object_t session;
+ session["unique_id"] = p.second->uniqueId;
+ session["session_token"] = p.second->sessionToken;
+ session["username"] = p.second->username;
+ session["csrf_token"] = p.second->csrfToken;
+ session["client_ip"] = p.second->clientIp;
#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
- {"client_id", p.second->clientId},
+ session["client_id"] = p.second->clientId;
#endif
- });
+ sessions.push_back(std::move(session));
}
}
nlohmann::json& subscriptions = data["subscriptions"];
@@ -270,20 +270,23 @@ class ConfigFile
headers[std::move(name)] = header.value();
}
- subscriptions.push_back({
- {"Id", subValue->id},
- {"Context", subValue->customText},
- {"DeliveryRetryPolicy", subValue->retryPolicy},
- {"Destination", subValue->destinationUrl},
- {"EventFormatType", subValue->eventFormatType},
- {"HttpHeaders", std::move(headers)},
- {"MessageIds", subValue->registryMsgIds},
- {"Protocol", subValue->protocol},
- {"RegistryPrefixes", subValue->registryPrefixes},
- {"ResourceTypes", subValue->resourceTypes},
- {"SubscriptionType", subValue->subscriptionType},
- {"MetricReportDefinitions", subValue->metricReportDefinitions},
- });
+ nlohmann::json::object_t subscription;
+
+ subscription["Id"] = subValue->id;
+ subscription["Context"] = subValue->customText;
+ subscription["DeliveryRetryPolicy"] = subValue->retryPolicy;
+ subscription["Destination"] = subValue->destinationUrl;
+ subscription["EventFormatType"] = subValue->eventFormatType;
+ subscription["HttpHeaders"] = std::move(headers);
+ subscription["MessageIds"] = subValue->registryMsgIds;
+ subscription["Protocol"] = subValue->protocol;
+ subscription["RegistryPrefixes"] = subValue->registryPrefixes;
+ subscription["ResourceTypes"] = subValue->resourceTypes;
+ subscription["SubscriptionType"] = subValue->subscriptionType;
+ subscription["MetricReportDefinitions"] =
+ subValue->metricReportDefinitions;
+
+ subscriptions.push_back(std::move(subscription));
}
persistentFile << data;
}
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 58bf25786f..4e50e4b829 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -253,14 +253,14 @@ inline int formatEventLogEntry(const std::string& logEntryID,
}
// 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 @@ class Subscription : public persistent_data::UserSubscription
{"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 @@ class Subscription : public persistent_data::UserSubscription
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 2cb2f3dbbf..f4e37b5284 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -68,7 +68,9 @@ inline void
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 8d537995b0..e675e82256 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -160,24 +160,23 @@ inline void parseLDAPConfigData(nlohmann::json& jsonResponse,
{
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& roleMapArray = jsonResponse[ldapType]["RemoteRoleMapping"];
+
+ nlohmann::json& ldap = jsonResponse[ldapType];
+
+ 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 @@ inline void handleRoleMapPatch(
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 @@ inline void requestAccountServiceRoutes(App& app)
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 @@ inline void requestAccountServiceRoutes(App& app)
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 @@ inline void requestAccountServiceRoutes(App& app)
{
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 @@ inline void requestAccountServiceRoutes(App& app)
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 @@ inline void requestAccountServiceRoutes(App& app)
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 @@ inline void requestAccountServiceRoutes(App& app)
}
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 934f901a43..4ac3762d0f 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -54,13 +54,15 @@ inline void requestRoutesCertificateService(App& app)
{
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 @@ inline void requestRoutesCertificateService(App& app)
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 @@ static void getCSR(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
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 @@ static void getCertificateProperties(
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 @@ inline void requestRoutesHTTPSCertificateCollection(App& app)
{
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 @@ inline void requestRoutesHTTPSCertificateCollection(App& app)
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 @@ inline void requestRoutesHTTPSCertificateCollection(App& app)
}
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 @@ inline void
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 @@ inline void requestRoutesCertificateLocations(App& app)
{
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 @@ inline void requestRoutesLDAPCertificateCollection(App& app)
{
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 @@ inline void requestRoutesLDAPCertificateCollection(App& app)
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 @@ inline void requestRoutesTrustStoreCertificateCollection(App& app)
{
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 @@ inline void requestRoutesTrustStoreCertificateCollection(App& app)
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 47b507005f..1aa7b40bb6 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -94,8 +94,9 @@ inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> aResp,
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 @@ inline void requestRoutesChassis(App& app)
"/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 @@ inline void requestRoutesChassis(App& app)
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 @@ inline void requestRoutesChassisResetActionInfo(App& app)
{
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 33ff656722..734cab2d8e 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1751,18 +1751,18 @@ inline void parseInterfaceData(
{
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 @@ inline void parseInterfaceData(
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 @@ inline void requestEthernetInterfacesRoutes(App& app)
{
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)
+ 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)
{
- ifaceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
- ifaceItem}});
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- ifaceArray.size();
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Managers/bmc/EthernetInterfaces";
+ 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 @@ inline void requestEthernetInterfacesRoutes(App& app)
"/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;
}
+ // 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)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (ifaceList.find(rootInterfaceName) == ifaceList.end())
- {
- messages::resourceNotFound(asyncResp->res,
- "VLanNetworkInterfaceCollection",
- rootInterfaceName);
- 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";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#VLanNetworkInterfaceCollection."
+ "VLanNetworkInterfaceCollection";
+ asyncResp->res.jsonValue["Name"] =
+ "VLAN Network Interface Collection";
- nlohmann::json ifaceArray = nlohmann::json::array();
+ nlohmann::json ifaceArray = nlohmann::json::array();
- for (const std::string& ifaceItem : ifaceList)
- {
- if (boost::starts_with(ifaceItem, rootInterfaceName + "_"))
+ for (const std::string& ifaceItem : ifaceList)
{
- std::string path =
- "/redfish/v1/Managers/bmc/EthernetInterfaces/";
- path += rootInterfaceName;
- path += "/VLANs/";
- path += ifaceItem;
- ifaceArray.push_back({{"@odata.id", std::move(path)}});
+ 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";
+ 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 2b63955009..51c999f087 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -57,17 +57,17 @@ inline void requestRoutesEventService(App& app)
{
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 @@ inline void requestRoutesEventDestinationCollection(App& app)
{
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 @@ inline void requestRoutesEventDestinationCollection(App& app)
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 @@ inline void requestRoutesEventDestination(App& app)
}
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 @@ inline void requestRoutesEventDestination(App& app)
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 ae03e2c255..500dc04c89 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -501,19 +501,17 @@ inline void parseInterfaceData(
{
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 @@ inline void requestRoutesHypervisorSystems(App& app)
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";
-
- 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"
- });
- });
+ .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";
+ 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 @@ inline void requestRoutesHypervisorSystems(App& app)
{
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 @@ inline void requestRoutesHypervisorSystems(App& app)
// 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 3a8ce10900..d31602cd54 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -916,24 +916,29 @@ inline void requestRoutesSystemLogServiceCollection(App& app)
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 @@ inline void requestRoutesEventLogService(App& app)
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 @@ inline void requestRoutesSystemHostLogger(App& app)
{
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 @@ inline void requestRoutesBMCJournalLogService(App& app)
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 @@ inline void requestRoutesBMCDumpService(App& app)
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 @@ inline void requestRoutesSystemDumpService(App& app)
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 @@ inline void requestRoutesCrashdumpService(App& app)
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 @@ inline void requestRoutesPostCodesLogService(App& app)
{
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 aa4c694da9..cd9910ef55 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -242,17 +242,27 @@ inline void requestRoutesManagerResetActionInfo(App& app)
{
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 @@ inline void
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 @@ inline void
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 @@ inline void requestRoutesManager(App& app)
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 @@ inline void requestRoutesManager(App& app)
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 @@ inline void requestRoutesManager(App& app)
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 @@ inline void requestRoutesManager(App& app)
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 @@ inline void requestRoutesManagerCollection(App& app)
"#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 fe4c592006..bd9b0903a8 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -39,18 +39,18 @@ inline void handleMessageRegistryFileCollectionGet(
// 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 @@ inline void handleMessageRoutesMessageRegistryFileGet(
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 @@ inline void handleMessageRegistryGet(
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 @@ inline void handleMessageRegistryGet(
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 362163aaa6..a6dd3b0a40 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -165,9 +165,8 @@ inline void getNetworkData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
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 be5981112c..740e393bf4 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -60,9 +60,10 @@ static inline void
{
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 @@ inline void requestRoutesSystemPCIeDeviceCollection(App& app)
{
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 @@ inline void requestRoutesSystemPCIeDevice(App& app)
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 @@ inline void requestRoutesSystemPCIeFunctionCollection(App& app)
{
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 @@ inline void requestRoutesSystemPCIeFunctionCollection(App& app)
{
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 @@ inline void requestRoutesSystemPCIeFunction(App& app)
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 @@ inline void requestRoutesSystemPCIeFunction(App& app)
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 118f3976ba..d609acb40e 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -215,13 +215,16 @@ inline void requestRoutesPower(App& app)
{
// 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 2a0e028b87..e0346debc6 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -555,7 +555,9 @@ inline void getCpuConfigData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
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 @@ inline void getCpuConfigData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
}
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 @@ inline void
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 @@ inline void
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 6c55f75215..58499a5988 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -113,8 +113,9 @@ inline nlohmann::json getSessionCollectionMembers()
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 @@ inline void
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 9b5d460991..62ec724a03 100644
--- a/redfish-core/lib/redfish_v1.hpp
+++ b/redfish-core/lib/redfish_v1.hpp
@@ -15,7 +15,7 @@ inline void requestRoutes(App& app)
.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 dd8a790800..6f27b8e10c 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -93,16 +93,18 @@ inline void requestRoutesRoles(App& app)
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 @@ inline void requestRoutesRoleCollection(App& app)
{
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 @@ inline void requestRoutesRoleCollection(App& app)
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 3a5c73bfb3..c7676db0a7 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1263,7 +1263,7 @@ inline void populateFanRedundancy(
{
health = "Critical";
}
- std::vector<nlohmann::json> redfishCollection;
+ nlohmann::json::array_t redfishCollection;
const auto& fanRedfish =
sensorsAsyncResp->asyncResp->res
.jsonValue["Fans"];
@@ -1286,9 +1286,11 @@ inline void populateFanRedundancy(
});
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 @@ inline void populateFanRedundancy(
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 @@ inline void getSensorData(
// 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 @@ inline void getSensorData(
}
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 @@ inline void getChassisCallback(
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 d7214eeb30..7760b4c93f 100644
--- a/redfish-core/lib/service_root.hpp
+++ b/redfish-core/lib/service_root.hpp
@@ -39,35 +39,30 @@ inline void
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 0f5b0f96b0..c86adabe54 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -42,8 +42,11 @@ inline void requestRoutesStorageCollection(App& app)
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 @@ inline void requestRoutesStorage(App& app)
<< 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 @@ inline void requestRoutesDrive(App& app)
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 cedd28d23a..e136aeaff3 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -2675,15 +2675,18 @@ inline void requestRoutesSystemsCollection(App& app)
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 @@ inline void requestRoutesSystems(App& app)
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["Actions"]["#ComputerSystem.Reset"] = {
- {"target",
- "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"},
- {"@Redfish.ActionInfo",
- "/redfish/v1/Systems/system/ResetActionInfo"}};
-
- 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["Links"]["ManagedBy"] = {
- {{"@odata.id", "/redfish/v1/Managers/bmc"}}};
-
- asyncResp->res.jsonValue["Status"] = {
- {"Health", "OK"},
- {"State", "Enabled"},
- };
+ 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";
+ 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["Bios"]["@odata.id"] =
+ "/redfish/v1/Systems/system/Bios";
+
+ 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 @@ inline void requestRoutesSystems(App& app)
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 requestRoutesSystems(App& app)
*/
inline void requestRoutesSystemResetActionInfo(App& app)
{
-
/**
* Functions triggers appropriate requests on DBus
*/
@@ -3119,19 +3123,25 @@ inline void requestRoutesSystemResetActionInfo(App& app)
{
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 199bc84b7d..0c2eee410a 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -139,11 +139,13 @@ struct TaskData : std::enable_shared_from_this<TaskData>
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 @@ inline void requestRoutesTask(App& app)
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 @@ inline void requestRoutesTaskService(App& app)
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 e2f46ecef2..cdd58b830e 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -129,10 +129,10 @@ inline std::optional<nlohmann::json>
{
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 @@ inline nlohmann::json
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 70fe8dbd20..b5108ae3e6 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -560,8 +560,8 @@ inline void requestRoutesUpdateService(App& app)
"/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 @@ inline void requestRoutesSoftwareInventoryCollection(App& app)
{
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";
-
- 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())
+ .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);
- 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 @@ inline static void
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 5c4fb3110b..6353167013 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -54,8 +54,8 @@ static void addMessageToErrorJson(nlohmann::json& target,
<< "Attempt to add error message without Message";
return;
}
- error = {{"code", *messageIdIterator},
- {"message", *messageFieldIterator}};
+ error["code"] = *messageIdIterator;
+ error["message"] = *messageFieldIterator;
}
else
{
@@ -129,12 +129,14 @@ static nlohmann::json getLog(redfish::registries::base::Index name,
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;
}
/**