1ccaf2db9SMatthew Barth /** 2ccaf2db9SMatthew Barth * Copyright © 2020 IBM Corporation 3ccaf2db9SMatthew Barth * 4ccaf2db9SMatthew Barth * Licensed under the Apache License, Version 2.0 (the "License"); 5ccaf2db9SMatthew Barth * you may not use this file except in compliance with the License. 6ccaf2db9SMatthew Barth * You may obtain a copy of the License at 7ccaf2db9SMatthew Barth * 8ccaf2db9SMatthew Barth * http://www.apache.org/licenses/LICENSE-2.0 9ccaf2db9SMatthew Barth * 10ccaf2db9SMatthew Barth * Unless required by applicable law or agreed to in writing, software 11ccaf2db9SMatthew Barth * distributed under the License is distributed on an "AS IS" BASIS, 12ccaf2db9SMatthew Barth * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ccaf2db9SMatthew Barth * See the License for the specific language governing permissions and 14ccaf2db9SMatthew Barth * limitations under the License. 15ccaf2db9SMatthew Barth */ 16ccaf2db9SMatthew Barth #pragma once 17ccaf2db9SMatthew Barth 18ccaf2db9SMatthew Barth #include "json_config.hpp" 199ea8bee7SMatthew Barth #include "trust_group.hpp" 209ea8bee7SMatthew Barth #include "types.hpp" 21ccaf2db9SMatthew Barth 22ccaf2db9SMatthew Barth #include <nlohmann/json.hpp> 23ccaf2db9SMatthew Barth #include <sdbusplus/bus.hpp> 24ccaf2db9SMatthew Barth 25ccaf2db9SMatthew Barth namespace phosphor::fan::monitor 26ccaf2db9SMatthew Barth { 27ccaf2db9SMatthew Barth 28ccaf2db9SMatthew Barth using json = nlohmann::json; 29ccaf2db9SMatthew Barth 30ccaf2db9SMatthew Barth constexpr auto confAppName = "monitor"; 31ccaf2db9SMatthew Barth constexpr auto confFileName = "config.json"; 32ccaf2db9SMatthew Barth 339ea8bee7SMatthew Barth // Trust group class handler function 349ea8bee7SMatthew Barth using trustHandler = std::function<CreateGroupFunction( 359ea8bee7SMatthew Barth const std::vector<trust::GroupDefinition>&)>; 369ea8bee7SMatthew Barth 37ccaf2db9SMatthew Barth /** 38ccaf2db9SMatthew Barth * @brief Get the JSON object 39ccaf2db9SMatthew Barth * 40ccaf2db9SMatthew Barth * @param[in] bus - The dbus bus object 41ccaf2db9SMatthew Barth * 42ccaf2db9SMatthew Barth * @return JSON object 43ccaf2db9SMatthew Barth * A JSON object created after loading the JSON configuration file 44ccaf2db9SMatthew Barth */ 45ccaf2db9SMatthew Barth inline const json getJsonObj(sdbusplus::bus::bus& bus) 46ccaf2db9SMatthew Barth { 47ccaf2db9SMatthew Barth return fan::JsonConfig::load( 48ccaf2db9SMatthew Barth fan::JsonConfig::getConfFile(bus, confAppName, confFileName)); 49ccaf2db9SMatthew Barth } 50ccaf2db9SMatthew Barth 519ea8bee7SMatthew Barth /** 529ea8bee7SMatthew Barth * @brief Get any configured trust groups 539ea8bee7SMatthew Barth * 549ea8bee7SMatthew Barth * @param[in] obj - JSON object to parse from 559ea8bee7SMatthew Barth * 569ea8bee7SMatthew Barth * @return List of functions applied on trust groups 579ea8bee7SMatthew Barth */ 589ea8bee7SMatthew Barth const std::vector<CreateGroupFunction> getTrustGrps(const json& obj); 599ea8bee7SMatthew Barth 60*22ab93b4SMatthew Barth /** 61*22ab93b4SMatthew Barth * @brief Get the configured sensor definitions that make up a fan 62*22ab93b4SMatthew Barth * 63*22ab93b4SMatthew Barth * @param[in] sensor - JSON object containing a list of sensors 64*22ab93b4SMatthew Barth * 65*22ab93b4SMatthew Barth * @return List of sensor definition data that make up a fan being monitored 66*22ab93b4SMatthew Barth */ 67*22ab93b4SMatthew Barth const std::vector<SensorDefinition> getSensorDefs(const json& sensors); 68*22ab93b4SMatthew Barth 69*22ab93b4SMatthew Barth /** 70*22ab93b4SMatthew Barth * @brief Get the configured fan definitions to be monitored 71*22ab93b4SMatthew Barth * 72*22ab93b4SMatthew Barth * @param[in] obj - JSON object to parse from 73*22ab93b4SMatthew Barth * 74*22ab93b4SMatthew Barth * @return List of fan definition data on the fans to be monitored 75*22ab93b4SMatthew Barth */ 76*22ab93b4SMatthew Barth const std::vector<FanDefinition> getFanDefs(const json& obj); 77*22ab93b4SMatthew Barth 78ccaf2db9SMatthew Barth } // namespace phosphor::fan::monitor 79