blob: d0fbccfed87837cdcaf75af19b315f33df96bd00 [file] [log] [blame]
Lewanczyk, Dawid08777fb2018-03-22 23:33:49 +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#include "sensors.hpp"
20
Ed Tanous1abe55e2018-09-05 08:30:59 -070021namespace redfish
22{
Lewanczyk, Dawid08777fb2018-03-22 23:33:49 +010023
Ed Tanous1abe55e2018-09-05 08:30:59 -070024class Thermal : public Node
25{
26 public:
27 Thermal(CrowApp& app) :
28 Node((app), "/redfish/v1/Chassis/<str>/Thermal/", std::string())
29 {
Ed Tanous1abe55e2018-09-05 08:30:59 -070030 entityPrivileges = {
31 {boost::beast::http::verb::get, {{"Login"}}},
32 {boost::beast::http::verb::head, {{"Login"}}},
33 {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
34 {boost::beast::http::verb::put, {{"ConfigureManager"}}},
35 {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
36 {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
Lewanczyk, Dawid08777fb2018-03-22 23:33:49 +010037 }
Lewanczyk, Dawid08777fb2018-03-22 23:33:49 +010038
Ed Tanous1abe55e2018-09-05 08:30:59 -070039 private:
40 void doGet(crow::Response& res, const crow::Request& req,
41 const std::vector<std::string>& params) override
42 {
43 if (params.size() != 1)
44 {
Jason M. Billsf12894f2018-10-09 12:45:45 -070045 messages::internalError(res);
Ed Tanous1abe55e2018-09-05 08:30:59 -070046 res.end();
47 return;
48 }
49 const std::string& chassisName = params[0];
50
Ed Tanous0f74e642018-11-12 15:17:05 -080051 res.jsonValue["@odata.type"] = "#Thermal.v1_4_0.Thermal";
52 res.jsonValue["@odata.context"] =
53 "/redfish/v1/$metadata#Thermal.Thermal";
54 res.jsonValue["Id"] = "Thermal";
55 res.jsonValue["Name"] = "Thermal";
Ed Tanous2474adf2018-09-05 16:31:16 -070056
Ed Tanous0f74e642018-11-12 15:17:05 -080057 res.jsonValue["@odata.id"] =
Ed Tanous2474adf2018-09-05 16:31:16 -070058 "/redfish/v1/Chassis/" + chassisName + "/Thermal";
59
Ed Tanous2474adf2018-09-05 16:31:16 -070060 auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
Ed Tanous1abe55e2018-09-05 08:30:59 -070061 res, chassisName,
62 std::initializer_list<const char*>{
63 "/xyz/openbmc_project/sensors/fan",
Ed Tanous6f6d0d32018-10-12 11:16:43 -070064 "/xyz/openbmc_project/sensors/temperature",
Ed Tanous2474adf2018-09-05 16:31:16 -070065 "/xyz/openbmc_project/sensors/fan_pwm"},
66 "Thermal");
67
68 // TODO Need to get Chassis Redundancy information.
69 getChassisData(sensorAsyncResp);
Ed Tanous1abe55e2018-09-05 08:30:59 -070070 }
Lewanczyk, Dawid08777fb2018-03-22 23:33:49 +010071};
72
Ed Tanous1abe55e2018-09-05 08:30:59 -070073} // namespace redfish