blob: 3b2aae532bcddb00d375fa13d689ee7ec77ec667 [file] [log] [blame]
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +01001/*
2// Copyright (c) 2018 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#pragma once
17
18#include "node.hpp"
19
Ed Tanous1abe55e2018-09-05 08:30:59 -070020#include <systemd/sd-id128.h>
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010021
Ed Tanous1abe55e2018-09-05 08:30:59 -070022namespace redfish
23{
Ed Tanous3ebd75f2018-03-05 18:20:01 -080024
Ed Tanous1abe55e2018-09-05 08:30:59 -070025class ServiceRoot : public Node
26{
27 public:
28 ServiceRoot(CrowApp& app) : Node(app, "/redfish/v1/")
29 {
Ed Tanous1abe55e2018-09-05 08:30:59 -070030 entityPrivileges = {
31 {boost::beast::http::verb::get, {}},
32 {boost::beast::http::verb::head, {}},
33 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
34 {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
35 {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
36 {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
Ed Tanouse0625902018-05-16 13:35:08 -070037 }
Ed Tanous1abe55e2018-09-05 08:30:59 -070038
39 private:
40 void doGet(crow::Response& res, const crow::Request& req,
41 const std::vector<std::string>& params) override
42 {
Ed Tanous0f74e642018-11-12 15:17:05 -080043 res.jsonValue["@odata.type"] = "#ServiceRoot.v1_1_1.ServiceRoot";
44 res.jsonValue["@odata.id"] = "/redfish/v1/";
45 res.jsonValue["@odata.context"] =
46 "/redfish/v1/$metadata#ServiceRoot.ServiceRoot";
47 res.jsonValue["Id"] = "RootService";
48 res.jsonValue["Name"] = "Root Service";
49 res.jsonValue["RedfishVersion"] = "1.1.0";
50 res.jsonValue["Links"]["Sessions"] = {
51 {"@odata.id", "/redfish/v1/SessionService/Sessions"}};
52 res.jsonValue["AccountService"] = {
53 {"@odata.id", "/redfish/v1/AccountService"}};
54 res.jsonValue["Chassis"] = {{"@odata.id", "/redfish/v1/Chassis"}};
55 res.jsonValue["JsonSchemas"] = {
56 {"@odata.id", "/redfish/v1/JsonSchemas"}};
Ed Tanousaa7cb212018-11-29 13:47:36 -080057 res.jsonValue["Managers"] = {{"@odata.id", "/redfish/v1/Managers"}};
Ed Tanous0f74e642018-11-12 15:17:05 -080058 res.jsonValue["SessionService"] = {
Gunnar Mills8d3cae62018-12-13 16:22:42 -060059 {"@odata.id", "/redfish/v1/SessionService"}};
Ed Tanous0f74e642018-11-12 15:17:05 -080060 res.jsonValue["Systems"] = {{"@odata.id", "/redfish/v1/Systems"}};
61 res.jsonValue["Registries"] = {{"@odata.id", "/redfish/v1/Registries"}};
62
63 res.jsonValue["UpdateService"] = {
64 {"@odata.id", "/redfish/v1/UpdateService"}};
65
66 res.jsonValue["UUID"] = getUuid();
Ed Tanous1abe55e2018-09-05 08:30:59 -070067 res.end();
68 }
69
70 const std::string getUuid()
71 {
Ed Tanous24436512018-11-14 16:50:18 -080072 std::string ret;
Ed Tanous1abe55e2018-09-05 08:30:59 -070073 // This ID needs to match the one in ipmid
Ed Tanous24436512018-11-14 16:50:18 -080074 sd_id128_t appId = SD_ID128_MAKE(e0, e1, 73, 76, 64, 61, 47, da, a5, 0c,
75 d0, cc, 64, 12, 45, 78);
76 sd_id128_t machineId = SD_ID128_NULL;
77
78 if (sd_id128_get_machine_app_specific(appId, &machineId) == 0)
Ed Tanous1abe55e2018-09-05 08:30:59 -070079 {
Ed Tanous24436512018-11-14 16:50:18 -080080 std::array<char, SD_ID128_STRING_MAX> str;
81 ret = sd_id128_to_string(machineId, str.data());
82 ret.insert(8, 1, '-');
83 ret.insert(13, 1, '-');
84 ret.insert(18, 1, '-');
85 ret.insert(23, 1, '-');
Ed Tanous1abe55e2018-09-05 08:30:59 -070086 }
Ed Tanous24436512018-11-14 16:50:18 -080087
88 return ret;
Ed Tanous1abe55e2018-09-05 08:30:59 -070089 }
Borawski.Lukaszb6df6dc2018-01-24 10:20:45 +010090};
91
Ed Tanous1abe55e2018-09-05 08:30:59 -070092} // namespace redfish