1b6df6dc7SBorawski.Lukasz /* 2b6df6dc7SBorawski.Lukasz // Copyright (c) 2018 Intel Corporation 3b6df6dc7SBorawski.Lukasz // 4b6df6dc7SBorawski.Lukasz // Licensed under the Apache License, Version 2.0 (the "License"); 5b6df6dc7SBorawski.Lukasz // you may not use this file except in compliance with the License. 6b6df6dc7SBorawski.Lukasz // You may obtain a copy of the License at 7b6df6dc7SBorawski.Lukasz // 8b6df6dc7SBorawski.Lukasz // http://www.apache.org/licenses/LICENSE-2.0 9b6df6dc7SBorawski.Lukasz // 10b6df6dc7SBorawski.Lukasz // Unless required by applicable law or agreed to in writing, software 11b6df6dc7SBorawski.Lukasz // distributed under the License is distributed on an "AS IS" BASIS, 12b6df6dc7SBorawski.Lukasz // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b6df6dc7SBorawski.Lukasz // See the License for the specific language governing permissions and 14b6df6dc7SBorawski.Lukasz // limitations under the License. 15b6df6dc7SBorawski.Lukasz */ 16b6df6dc7SBorawski.Lukasz #pragma once 17b6df6dc7SBorawski.Lukasz 18b6df6dc7SBorawski.Lukasz #include "node.hpp" 19b6df6dc7SBorawski.Lukasz 201abe55efSEd Tanous #include <systemd/sd-id128.h> 21b6df6dc7SBorawski.Lukasz 221abe55efSEd Tanous namespace redfish 231abe55efSEd Tanous { 241abe55efSEd Tanous 251abe55efSEd Tanous class ServiceRoot : public Node 261abe55efSEd Tanous { 27b6df6dc7SBorawski.Lukasz public: 281abe55efSEd Tanous ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/") 291abe55efSEd Tanous { 30e0625906SEd Tanous entityPrivileges = { 31e0625906SEd Tanous {boost::beast::http::verb::get, {}}, 32e0d918bcSEd Tanous {boost::beast::http::verb::head, {}}, 33e0d918bcSEd Tanous {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, 34e0d918bcSEd Tanous {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, 35e0d918bcSEd Tanous {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, 36e0d918bcSEd Tanous {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; 37b6df6dc7SBorawski.Lukasz } 38b6df6dc7SBorawski.Lukasz 39b6df6dc7SBorawski.Lukasz private: 4055c7b7a2SEd Tanous void doGet(crow::Response& res, const crow::Request& req, 411abe55efSEd Tanous const std::vector<std::string>& params) override 421abe55efSEd Tanous { 430f74e643SEd Tanous res.jsonValue["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot"; 44ceac6f75SEd Tanous res.jsonValue["@odata.id"] = "/redfish/v1"; 450f74e643SEd Tanous res.jsonValue["@odata.context"] = 460f74e643SEd Tanous "/redfish/v1/$metadata#ServiceRoot.ServiceRoot"; 470f74e643SEd Tanous res.jsonValue["Id"] = "RootService"; 480f74e643SEd Tanous res.jsonValue["Name"] = "Root Service"; 49*029573d4SEd Tanous res.jsonValue["RedfishVersion"] = "1.6.1"; 500f74e643SEd Tanous res.jsonValue["Links"]["Sessions"] = { 510f74e643SEd Tanous {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; 520f74e643SEd Tanous res.jsonValue["AccountService"] = { 530f74e643SEd Tanous {"@odata.id", "/redfish/v1/AccountService"}}; 540f74e643SEd Tanous res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}}; 550f74e643SEd Tanous res.jsonValue["JsonSchemas"] = { 560f74e643SEd Tanous {"@odata.id", "/redfish/v1/JsonSchemas"}}; 57aa7cb211SEd Tanous res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}}; 580f74e643SEd Tanous res.jsonValue["SessionService"] = { 598d3cae6bSGunnar Mills {"@odata.id", "/redfish/v1/SessionService"}}; 60ceac6f75SEd Tanous res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}}; 610f74e643SEd Tanous res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}}; 620f74e643SEd Tanous res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}}; 630f74e643SEd Tanous 640f74e643SEd Tanous res.jsonValue["UpdateService"] = { 650f74e643SEd Tanous {"@odata.id", "/redfish/v1/UpdateService"}}; 660f74e643SEd Tanous 670f74e643SEd Tanous res.jsonValue["UUID"] = getUuid(); 68b6df6dc7SBorawski.Lukasz res.end(); 69b6df6dc7SBorawski.Lukasz } 70e0625906SEd Tanous 711abe55efSEd Tanous const std::string getUuid() 721abe55efSEd Tanous { 7324436516SEd Tanous std::string ret; 74e0625906SEd Tanous // This ID needs to match the one in ipmid 7524436516SEd Tanous sd_id128_t appId = SD_ID128_MAKE(e0, e1, 73, 76, 64, 61, 47, da, a5, 0c, 7624436516SEd Tanous d0, cc, 64, 12, 45, 78); 7724436516SEd Tanous sd_id128_t machineId = SD_ID128_NULL; 7824436516SEd Tanous 7924436516SEd Tanous if (sd_id128_get_machine_app_specific(appId, &machineId) == 0) 801abe55efSEd Tanous { 8124436516SEd Tanous std::array<char, SD_ID128_STRING_MAX> str; 8224436516SEd Tanous ret = sd_id128_to_string(machineId, str.data()); 8324436516SEd Tanous ret.insert(8, 1, '-'); 8424436516SEd Tanous ret.insert(13, 1, '-'); 8524436516SEd Tanous ret.insert(18, 1, '-'); 8624436516SEd Tanous ret.insert(23, 1, '-'); 87e0625906SEd Tanous } 8824436516SEd Tanous 8924436516SEd Tanous return ret; 90e0625906SEd Tanous } 91b6df6dc7SBorawski.Lukasz }; 92b6df6dc7SBorawski.Lukasz 93b6df6dc7SBorawski.Lukasz } // namespace redfish 94