summaryrefslogtreecommitdiff
path: root/redfish-core/lib
diff options
context:
space:
mode:
authorJohn Edward Broadbent <jebr@google.com>2021-06-29 20:46:46 +0300
committerEd Tanous <ed@tanous.net>2021-08-23 21:23:24 +0300
commit8338891aa2c5424c52fe3e0bea320172a5aedda3 (patch)
tree2bb9fe99478e01884f926481fe5a98201b9feaa2 /redfish-core/lib
parent476b9cc5e6d3433d140e82ca5e3981e861443a2d (diff)
downloadbmcweb-8338891aa2c5424c52fe3e0bea320172a5aedda3.tar.xz
Refactor callback to free function: Service root
This change will allow for unit testing of the free function. There are no changes to logic in the service root response. This is a demo change, if it looks good similar changes can be made to all the redfish responses. Also adds missing include (persistent_data.hpp). Tested: ran curl against qemu machine, looked good. $ curl -vvvv --insecure "https://192.168.7.2:18080/redfish/v1" Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: Ie056c64e841a2708d3189a55036385b8c905a7f4
Diffstat (limited to 'redfish-core/lib')
-rw-r--r--redfish-core/lib/service_root.hpp82
1 files changed, 43 insertions, 39 deletions
diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp
index 677814169a..63cc2109ea 100644
--- a/redfish-core/lib/service_root.hpp
+++ b/redfish-core/lib/service_root.hpp
@@ -16,55 +16,59 @@
#pragma once
#include <app.hpp>
+#include <persistent_data.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/systemd_utils.hpp>
namespace redfish
{
-inline void requestRoutesServiceRoot(App& app)
+inline void
+ handleServiceRootGet(const crow::Request&,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+
std::string uuid = persistent_data::getConfig().systemUuid;
+ asyncResp->res.jsonValue["@odata.type"] = "#ServiceRoot.v1_5_0.ServiceRoot";
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1";
+ 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["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"}};
+}
+
+inline void requestRoutesServiceRoot(App& app)
+{
BMCWEB_ROUTE(app, "/redfish/v1/")
.privileges(redfish::privileges::getServiceRoot)
- .methods(boost::beast::http::verb::get)(
- [uuid](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- asyncResp->res.jsonValue["@odata.type"] =
- "#ServiceRoot.v1_5_0.ServiceRoot";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1";
- 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["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"}};
- });
+ .methods(boost::beast::http::verb::get)(handleServiceRootGet);
}
} // namespace redfish