Implement AggregationService
AggregationService is used to inform a client that some of the results
might be aggregated, and to allow setting up aggregation sources.
Today, this resource only contains the basic fields, as well as
"Enabled", which informs the client of the fact that the service is
aggregation enabled.
AggregationService was one of the schemas we ignored, so this adds it to
the supported list.
Tested: Redfish service validator passes.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ifb16a86ff81e387f01016a83f9e69240c8928614
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index e1d07a2..55ffeec 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -16,6 +16,7 @@
#pragma once
#include "account_service.hpp"
+#include "aggregation_service.hpp"
#include "bios.hpp"
#include "cable.hpp"
#include "certificate_service.hpp"
@@ -71,6 +72,9 @@
explicit RedfishService(App& app)
{
requestAccountServiceRoutes(app);
+#ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION
+ requestAggregationServiceRoutes(app);
+#endif
requestRoutesRoles(app);
requestRoutesRoleCollection(app);
requestRoutesServiceRoot(app);
diff --git a/redfish-core/include/schemas.hpp b/redfish-core/include/schemas.hpp
index 8267338..c81e304 100644
--- a/redfish-core/include/schemas.hpp
+++ b/redfish-core/include/schemas.hpp
@@ -17,6 +17,7 @@
constexpr std::array schemas {
"AccountService",
"ActionInfo",
+ "AggregationService",
"Assembly",
"AttributeRegistry",
"Bios",
diff --git a/redfish-core/lib/aggregation_service.hpp b/redfish-core/lib/aggregation_service.hpp
new file mode 100644
index 0000000..e03047a
--- /dev/null
+++ b/redfish-core/lib/aggregation_service.hpp
@@ -0,0 +1,63 @@
+#pragma once
+
+#include "app.hpp"
+#include "error_messages.hpp"
+#include "http_request.hpp"
+#include "http_response.hpp"
+#include "query.hpp"
+#include "registries/privilege_registry.hpp"
+
+#include <nlohmann/json.hpp>
+
+#include <functional>
+#include <memory>
+
+namespace redfish
+{
+
+inline void handleAggregationServiceHead(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/AggregationService/AggregationService.json>; rel=describedby");
+}
+
+inline void handleAggregationServiceGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/AggregationService/AggregationService.json>; rel=describedby");
+ nlohmann::json& json = asyncResp->res.jsonValue;
+ json["@odata.id"] = "/redfish/v1/AggregationService";
+ json["@odata.type"] = "#AggregationService.v1_0_1.AggregationService";
+ json["Id"] = "AggregationService";
+ json["Name"] = "Aggregation Service";
+ json["Description"] = "Aggregation Service";
+ json["ServiceEnabled"] = true;
+}
+
+inline void requestAggregationServiceRoutes(App& app)
+{
+ BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/")
+ .privileges(redfish::privileges::headAggregationService)
+ .methods(boost::beast::http::verb::head)(
+ std::bind_front(handleAggregationServiceHead, std::ref(app)));
+ BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/")
+ .privileges(redfish::privileges::getAggregationService)
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleAggregationServiceGet, std::ref(app)));
+}
+
+} // namespace redfish
diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp
index 98d39d6..7d586cb 100644
--- a/redfish-core/lib/service_root.hpp
+++ b/redfish-core/lib/service_root.hpp
@@ -58,6 +58,10 @@
"/redfish/v1/SessionService/Sessions";
asyncResp->res.jsonValue["AccountService"]["@odata.id"] =
"/redfish/v1/AccountService";
+#ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION
+ asyncResp->res.jsonValue["AggregationService"]["@odata.id"] =
+ "/redfish/v1/AggregationService";
+#endif
asyncResp->res.jsonValue["Chassis"]["@odata.id"] = "/redfish/v1/Chassis";
asyncResp->res.jsonValue["JsonSchemas"]["@odata.id"] =
"/redfish/v1/JsonSchemas";