blob: f266c40c196186cf2a2907ff262b12f6bb35574b [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"}}},
Richard Marian Thomaiyar6f4fd472019-02-13 10:10:59 +053033 {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
Ed Tanous1abe55e2018-09-05 08:30:59 -070034 {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:
Ed Tanousb01bf292019-03-25 19:25:26 +000040 std::initializer_list<const char*> typeList = {
Richard Marian Thomaiyar8afa1b92019-02-13 06:02:39 +053041 "/xyz/openbmc_project/sensors/fan_tach",
Richard Marian Thomaiyar413961d2019-02-01 00:43:39 +053042 "/xyz/openbmc_project/sensors/temperature",
43 "/xyz/openbmc_project/sensors/fan_pwm"};
Ed Tanous1abe55e2018-09-05 08:30:59 -070044 void doGet(crow::Response& res, const crow::Request& req,
45 const std::vector<std::string>& params) override
46 {
47 if (params.size() != 1)
48 {
Jason M. Billsf12894f2018-10-09 12:45:45 -070049 messages::internalError(res);
Ed Tanous1abe55e2018-09-05 08:30:59 -070050 res.end();
51 return;
52 }
53 const std::string& chassisName = params[0];
Gunnar Mills603a6642019-01-21 17:03:51 -060054#ifdef BMCWEB_ENABLE_REDFISH_ONE_CHASSIS
55 // In a one chassis system the only supported name is "chassis"
56 if (chassisName != "chassis")
57 {
58 messages::resourceNotFound(res, "#Chassis.v1_4_0.Chassis",
59 chassisName);
60 res.end();
61 return;
62 }
63#endif
Ed Tanous1abe55e2018-09-05 08:30:59 -070064
Ed Tanous0f74e642018-11-12 15:17:05 -080065 res.jsonValue["@odata.type"] = "#Thermal.v1_4_0.Thermal";
66 res.jsonValue["@odata.context"] =
67 "/redfish/v1/$metadata#Thermal.Thermal";
68 res.jsonValue["Id"] = "Thermal";
69 res.jsonValue["Name"] = "Thermal";
Ed Tanous2474adf2018-09-05 16:31:16 -070070
Ed Tanous0f74e642018-11-12 15:17:05 -080071 res.jsonValue["@odata.id"] =
Ed Tanous2474adf2018-09-05 16:31:16 -070072 "/redfish/v1/Chassis/" + chassisName + "/Thermal";
Shawn McCarneyde629b62019-03-08 10:42:51 -060073
Ed Tanous2474adf2018-09-05 16:31:16 -070074 auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
Richard Marian Thomaiyar413961d2019-02-01 00:43:39 +053075 res, chassisName, typeList, "Thermal");
Ed Tanous2474adf2018-09-05 16:31:16 -070076
77 // TODO Need to get Chassis Redundancy information.
78 getChassisData(sensorAsyncResp);
Ed Tanous1abe55e2018-09-05 08:30:59 -070079 }
Richard Marian Thomaiyar413961d2019-02-01 00:43:39 +053080 void doPatch(crow::Response& res, const crow::Request& req,
81 const std::vector<std::string>& params) override
82 {
83 setSensorOverride(res, req, params, typeList, "Thermal");
84 }
Lewanczyk, Dawid08777fb2018-03-22 23:33:49 +010085};
86
Ed Tanous1abe55e2018-09-05 08:30:59 -070087} // namespace redfish