From 5315c1b149b724d0395f42ca75d4660aaecdf351 Mon Sep 17 00:00:00 2001 From: Carson Labrado Date: Sat, 18 Feb 2023 01:02:18 +0000 Subject: Implement AggregationSourceCollection This is an intermediate step in setting up aggregation sources. A future patch will add aggregation sources based on the existence of satellite configs. For now the collection will always return as 0 members. Adds the AggregationSourceCollection schema which we previously ignored. Tested: Service Validator passes Signed-off-by: Carson Labrado Change-Id: I65c9231289bf0a9b6392696d55bc3feb0023c694 --- Redfish.md | 8 ++ redfish-core/include/redfish.hpp | 1 + redfish-core/include/schemas.hpp | 1 + redfish-core/lib/aggregation_service.hpp | 32 +++++++ scripts/update_schemas.py | 1 + static/redfish/v1/$metadata/index.xml | 3 + .../AggregationSourceCollection.json | 99 ++++++++++++++++++++++ .../v1/schema/AggregationSourceCollection_v1.xml | 69 +++++++++++++++ 8 files changed, 214 insertions(+) create mode 100644 static/redfish/v1/JsonSchemas/AggregationSourceCollection/AggregationSourceCollection.json create mode 100644 static/redfish/v1/schema/AggregationSourceCollection_v1.xml diff --git a/Redfish.md b/Redfish.md index deae38e9b4..689b586304 100644 --- a/Redfish.md +++ b/Redfish.md @@ -72,9 +72,17 @@ Fields common to all schemas #### AggregationService +- AggregationSources - Description - ServiceEnabled +### /redfish/v1/AggregationService/AggregationSources + +#### AggregationSourceCollection + +- Members +- Members@odata.count + ### /redfish/v1/AccountService/Accounts/ #### ManagerAccountCollection diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp index 9d7bbaa5b9..954dfc7db9 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -74,6 +74,7 @@ class RedfishService requestAccountServiceRoutes(app); #ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION requestAggregationServiceRoutes(app); + requestAggregationSourcesRoutes(app); #endif requestRoutesRoles(app); requestRoutesRoleCollection(app); diff --git a/redfish-core/include/schemas.hpp b/redfish-core/include/schemas.hpp index c81e304526..c2cbb8bd94 100644 --- a/redfish-core/include/schemas.hpp +++ b/redfish-core/include/schemas.hpp @@ -18,6 +18,7 @@ namespace redfish "AccountService", "ActionInfo", "AggregationService", + "AggregationSourceCollection", "Assembly", "AttributeRegistry", "Bios", diff --git a/redfish-core/lib/aggregation_service.hpp b/redfish-core/lib/aggregation_service.hpp index e03047aac4..f0eb651dc2 100644 --- a/redfish-core/lib/aggregation_service.hpp +++ b/redfish-core/lib/aggregation_service.hpp @@ -46,6 +46,8 @@ inline void handleAggregationServiceGet( json["Name"] = "Aggregation Service"; json["Description"] = "Aggregation Service"; json["ServiceEnabled"] = true; + json["AggregationSources"]["@odata.id"] = + "/redfish/v1/AggregationService/AggregationSources"; } inline void requestAggregationServiceRoutes(App& app) @@ -60,4 +62,34 @@ inline void requestAggregationServiceRoutes(App& app) std::bind_front(handleAggregationServiceGet, std::ref(app))); } +inline void handleAggregationSourcesGet( + App& app, const crow::Request& req, + const std::shared_ptr& asyncResp) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + asyncResp->res.addHeader( + boost::beast::http::field::link, + "; rel=describedby"); + nlohmann::json& json = asyncResp->res.jsonValue; + json["@odata.id"] = "/redfish/v1/AggregationService/AggregationSources"; + json["@odata.type"] = + "#AggregationSourceCollection.AggregationSourceCollection"; + json["Name"] = "Aggregation Source Collection"; + json["Members"] = nlohmann::json::array(); + json["Members@odata.count"] = 0; + + // TODO: Query D-Bus for satellite configs and add them to the Members array +} + +inline void requestAggregationSourcesRoutes(App& app) +{ + BMCWEB_ROUTE(app, "/redfish/v1/AggregationService/AggregationSources/") + .privileges(redfish::privileges::getAggregationService) + .methods(boost::beast::http::verb::get)( + std::bind_front(handleAggregationSourcesGet, std::ref(app))); +} + } // namespace redfish diff --git a/scripts/update_schemas.py b/scripts/update_schemas.py index 7fea60be7e..a27c156298 100755 --- a/scripts/update_schemas.py +++ b/scripts/update_schemas.py @@ -28,6 +28,7 @@ include_list = [ "AccountService", "ActionInfo", "AggregationService", + "AggregationSourceCollection", "Assembly", "AttributeRegistry", "Bios", diff --git a/static/redfish/v1/$metadata/index.xml b/static/redfish/v1/$metadata/index.xml index 0ef12fa517..92bcc0935d 100644 --- a/static/redfish/v1/$metadata/index.xml +++ b/static/redfish/v1/$metadata/index.xml @@ -118,6 +118,9 @@ + + + diff --git a/static/redfish/v1/JsonSchemas/AggregationSourceCollection/AggregationSourceCollection.json b/static/redfish/v1/JsonSchemas/AggregationSourceCollection/AggregationSourceCollection.json new file mode 100644 index 0000000000..64ce2d45da --- /dev/null +++ b/static/redfish/v1/JsonSchemas/AggregationSourceCollection/AggregationSourceCollection.json @@ -0,0 +1,99 @@ +{ + "$id": "http://redfish.dmtf.org/schemas/v1/AggregationSourceCollection.json", + "$ref": "#/definitions/AggregationSourceCollection", + "$schema": "http://redfish.dmtf.org/schemas/v1/redfish-schema-v1.json", + "copyright": "Copyright 2014-2022 DMTF. For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright", + "definitions": { + "AggregationSourceCollection": { + "anyOf": [ + { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/idRef" + }, + { + "additionalProperties": false, + "description": "The collection of AggregationSource resource instances.", + "longDescription": "This resource shall represent a resource collection of AggregationSource instances for a Redfish implementation.", + "patternProperties": { + "^([a-zA-Z_][a-zA-Z0-9_]*)?@(odata|Redfish|Message)\\.[a-zA-Z_][a-zA-Z0-9_]*$": { + "description": "This property shall specify a valid odata or Redfish property.", + "type": [ + "array", + "boolean", + "integer", + "number", + "null", + "object", + "string" + ] + } + }, + "properties": { + "@odata.context": { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/context" + }, + "@odata.etag": { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/etag" + }, + "@odata.id": { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/id" + }, + "@odata.type": { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/type" + }, + "Description": { + "anyOf": [ + { + "$ref": "http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Description" + }, + { + "type": "null" + } + ], + "readonly": true + }, + "Members": { + "description": "The members of this collection.", + "items": { + "$ref": "http://redfish.dmtf.org/schemas/v1/AggregationSource.json#/definitions/AggregationSource" + }, + "longDescription": "This property shall contain an array of links to the members of this collection.", + "readonly": true, + "type": "array" + }, + "Members@odata.count": { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/count" + }, + "Members@odata.nextLink": { + "$ref": "http://redfish.dmtf.org/schemas/v1/odata-v4.json#/definitions/nextLink" + }, + "Name": { + "$ref": "http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Name", + "readonly": true + }, + "Oem": { + "$ref": "http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Oem", + "description": "The OEM extension property.", + "longDescription": "This property shall contain the OEM extensions. All values for properties contained in this object shall conform to the Redfish Specification-described requirements." + } + }, + "required": [ + "Members", + "Members@odata.count", + "@odata.id", + "@odata.type", + "Name" + ], + "type": "object" + } + ], + "deletable": false, + "insertable": true, + "updatable": false, + "uris": [ + "/redfish/v1/AggregationService/AggregationSources" + ] + } + }, + "owningEntity": "DMTF", + "title": "#AggregationSourceCollection.AggregationSourceCollection" +} \ No newline at end of file diff --git a/static/redfish/v1/schema/AggregationSourceCollection_v1.xml b/static/redfish/v1/schema/AggregationSourceCollection_v1.xml new file mode 100644 index 0000000000..22dde6c446 --- /dev/null +++ b/static/redfish/v1/schema/AggregationSourceCollection_v1.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /redfish/v1/AggregationService/AggregationSources + + + + + + + + + + + + + + -- cgit v1.2.3