| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 1 | /** | 
| Mike Capps | b2e9a4f | 2022-06-13 10:15:42 -0400 | [diff] [blame] | 2 | * Copyright © 2022 IBM Corporation | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 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 |  | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 18 | #include "action.hpp" | 
| Matthew Barth | 44ab769 | 2021-03-26 11:40:10 -0500 | [diff] [blame] | 19 | #include "event.hpp" | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 20 | #include "group.hpp" | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 21 | #include "json_config.hpp" | 
| Matthew Barth | 48f44da | 2021-05-27 15:43:34 -0500 | [diff] [blame] | 22 | #include "power_state.hpp" | 
| Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 23 | #include "profile.hpp" | 
| Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 24 | #include "sdbusplus.hpp" | 
| Matthew Barth | bd52ed0 | 2022-02-07 15:15:10 -0600 | [diff] [blame] | 25 | #include "utils/flight_recorder.hpp" | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 26 | #include "zone.hpp" | 
| Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 27 |  | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 28 | #include <nlohmann/json.hpp> | 
| Matthew Barth | 68ac004 | 2021-06-01 15:38:36 -0500 | [diff] [blame] | 29 | #include <phosphor-logging/log.hpp> | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 30 | #include <sdbusplus/bus.hpp> | 
| Matthew Barth | 1542fb5 | 2021-06-10 14:09:09 -0500 | [diff] [blame] | 31 | #include <sdbusplus/server/manager.hpp> | 
| Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 32 | #include <sdeventplus/event.hpp> | 
| Matt Spinler | 2fc0a35 | 2021-10-04 15:10:57 -0500 | [diff] [blame] | 33 | #include <sdeventplus/source/event.hpp> | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 34 | #include <sdeventplus/utility/timer.hpp> | 
|  | 35 |  | 
|  | 36 | #include <chrono> | 
| Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 37 | #include <format> | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 38 | #include <map> | 
|  | 39 | #include <memory> | 
|  | 40 | #include <optional> | 
|  | 41 | #include <tuple> | 
|  | 42 | #include <utility> | 
|  | 43 | #include <vector> | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 44 |  | 
|  | 45 | namespace phosphor::fan::control::json | 
|  | 46 | { | 
|  | 47 |  | 
|  | 48 | using json = nlohmann::json; | 
| Matthew Barth | 68ac004 | 2021-06-01 15:38:36 -0500 | [diff] [blame] | 49 | using namespace phosphor::logging; | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 50 |  | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 51 | /* Application name to be appended to the path for loading a JSON config file */ | 
|  | 52 | constexpr auto confAppName = "control"; | 
|  | 53 |  | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 54 | /* Type of timers supported */ | 
|  | 55 | enum class TimerType | 
|  | 56 | { | 
|  | 57 | oneshot, | 
|  | 58 | repeating, | 
|  | 59 | }; | 
| Mike Capps | b2e9a4f | 2022-06-13 10:15:42 -0400 | [diff] [blame] | 60 |  | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 61 | /** | 
|  | 62 | * Package of data required when a timer expires | 
|  | 63 | * Tuple constructed of: | 
|  | 64 | *      std::string = Timer package unique identifier | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 65 | *      std::vector<std::unique_ptr<ActionBase>> = List of pointers to actions | 
|  | 66 | * that run when the timer expires | 
| Matt Spinler | ade0c37 | 2021-10-28 16:09:44 -0500 | [diff] [blame] | 67 | *      const std::vector<Group> = List of groups | 
|  | 68 | *      bool = If groups should be preloaded before actions are run | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 69 | */ | 
| Matthew Barth | 00f6aa0 | 2021-04-09 10:49:47 -0500 | [diff] [blame] | 70 | using TimerPkg = | 
| Matt Spinler | ade0c37 | 2021-10-28 16:09:44 -0500 | [diff] [blame] | 71 | std::tuple<std::string, std::vector<std::unique_ptr<ActionBase>>&, | 
|  | 72 | const std::vector<Group>&, bool>; | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 73 | /** | 
|  | 74 | * Data associated with a running timer that's used when it expires | 
|  | 75 | * Pair constructed of: | 
|  | 76 | *      TimerType = Type of timer to manage expired timer instances | 
|  | 77 | *      TimerPkg = Package of data required when the timer expires | 
|  | 78 | */ | 
|  | 79 | using TimerData = std::pair<TimerType, TimerPkg>; | 
|  | 80 | /* Dbus event timer */ | 
|  | 81 | using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>; | 
|  | 82 |  | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 83 | /* Dbus signal object */ | 
|  | 84 | constexpr auto Path = 0; | 
|  | 85 | constexpr auto Intf = 1; | 
|  | 86 | constexpr auto Prop = 2; | 
|  | 87 | using SignalObject = std::tuple<std::string, std::string, std::string>; | 
|  | 88 | /* Dbus signal actions */ | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 89 | using TriggerActions = | 
| Matthew Barth | c3a6908 | 2021-11-15 14:32:48 -0600 | [diff] [blame] | 90 | std::vector<std::reference_wrapper<std::unique_ptr<ActionBase>>>; | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 91 | /** | 
|  | 92 | * Signal handler function that handles parsing a signal's message for a | 
|  | 93 | * particular signal object and stores the results in the manager | 
|  | 94 | */ | 
| Patrick Williams | cb356d4 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 95 | using SignalHandler = | 
|  | 96 | std::function<bool(sdbusplus::message_t&, const SignalObject&, Manager&)>; | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 97 | /** | 
|  | 98 | * Package of data required when a signal is received | 
|  | 99 | * Tuple constructed of: | 
|  | 100 | *     SignalHandler = Signal handler function | 
|  | 101 | *     SignalObject = Dbus signal object | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 102 | *     TriggerActions = List of actions that are run when the signal is received | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 103 | */ | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 104 | using SignalPkg = std::tuple<SignalHandler, SignalObject, TriggerActions>; | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 105 | /** | 
|  | 106 | * Data associated to a subscribed signal | 
|  | 107 | * Tuple constructed of: | 
| Matthew Barth | c024d78 | 2021-11-09 16:15:49 -0600 | [diff] [blame] | 108 | *     std::unique_ptr<std::vector<SignalPkg>> = | 
|  | 109 | *         Pointer to list of the signal's packages | 
| Patrick Williams | 3ea9ec2 | 2021-11-19 12:21:08 -0600 | [diff] [blame] | 110 | *     std::unique_ptr<sdbusplus::bus::match_t> = | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 111 | *         Pointer to match holding the subscription to a signal | 
|  | 112 | */ | 
| Matthew Barth | c024d78 | 2021-11-09 16:15:49 -0600 | [diff] [blame] | 113 | using SignalData = std::tuple<std::unique_ptr<std::vector<SignalPkg>>, | 
| Patrick Williams | 3ea9ec2 | 2021-11-19 12:21:08 -0600 | [diff] [blame] | 114 | std::unique_ptr<sdbusplus::bus::match_t>>; | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 115 |  | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 116 | /** | 
| Mike Capps | 1a19ead | 2021-10-22 09:15:14 -0400 | [diff] [blame] | 117 | * Package of data from a D-Bus call to get managed objects | 
|  | 118 | * Tuple constructed of: | 
|  | 119 | *     std::map<Path,            // D-Bus Path | 
|  | 120 | *       std::map<Intf,          // D-Bus Interface | 
|  | 121 | *         std::map<Property,    // D-Bus Property | 
|  | 122 | *         std::variant>>>       // Variant value of that property | 
|  | 123 | */ | 
|  | 124 | using Path_v = sdbusplus::message::object_path; | 
|  | 125 | using Intf_v = std::string; | 
|  | 126 | using Prop_v = std::string; | 
|  | 127 | using ManagedObjects = | 
|  | 128 | std::map<Path_v, std::map<Intf_v, std::map<Prop_v, PropertyVariantType>>>; | 
|  | 129 |  | 
|  | 130 | /** | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 131 | * Actions to run when a parameter trigger runs. | 
|  | 132 | */ | 
|  | 133 | using ParamTriggerData = std::vector< | 
|  | 134 | std::reference_wrapper<const std::vector<std::unique_ptr<ActionBase>>>>; | 
|  | 135 |  | 
|  | 136 | /** | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 137 | * @class Manager - Represents the fan control manager's configuration | 
|  | 138 | * | 
|  | 139 | * A fan control manager configuration is optional, therefore the "manager.json" | 
|  | 140 | * file is also optional. The manager configuration is used to populate | 
|  | 141 | * fan control's manager parameters which are used in how the application | 
|  | 142 | * operates, not in how the fans are controlled. | 
|  | 143 | * | 
|  | 144 | * When no manager configuration exists, the fan control application starts, | 
|  | 145 | * processes any configured events and then begins controlling fans according | 
|  | 146 | * to those events. | 
|  | 147 | */ | 
|  | 148 | class Manager | 
|  | 149 | { | 
|  | 150 | public: | 
|  | 151 | Manager() = delete; | 
|  | 152 | Manager(const Manager&) = delete; | 
|  | 153 | Manager(Manager&&) = delete; | 
|  | 154 | Manager& operator=(const Manager&) = delete; | 
|  | 155 | Manager& operator=(Manager&&) = delete; | 
|  | 156 | ~Manager() = default; | 
|  | 157 |  | 
|  | 158 | /** | 
|  | 159 | * Constructor | 
|  | 160 | * Parses and populates the fan control manager attributes from a json file | 
|  | 161 | * | 
| Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 162 | * @param[in] event - sdeventplus event loop | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 163 | */ | 
| Matt Spinler | 9b06243 | 2023-01-26 14:38:50 -0600 | [diff] [blame] | 164 | explicit Manager(const sdeventplus::Event& event); | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 165 |  | 
|  | 166 | /** | 
| Matthew Barth | e91ac86 | 2021-05-25 16:22:17 -0500 | [diff] [blame] | 167 | * @brief Callback function to handle receiving a HUP signal to reload the | 
|  | 168 | * JSON configurations. | 
|  | 169 | */ | 
|  | 170 | void sighupHandler(sdeventplus::source::Signal&, | 
|  | 171 | const struct signalfd_siginfo*); | 
|  | 172 |  | 
|  | 173 | /** | 
| Matt Spinler | 2fc0a35 | 2021-10-04 15:10:57 -0500 | [diff] [blame] | 174 | * @brief Callback function to handle receiving a USR1 signal to dump | 
|  | 175 | * the flight recorder. | 
|  | 176 | */ | 
| Matt Spinler | 27f5f4e | 2022-09-01 14:57:39 -0500 | [diff] [blame] | 177 | void dumpDebugData(sdeventplus::source::Signal&, | 
|  | 178 | const struct signalfd_siginfo*); | 
| Matt Spinler | 2fc0a35 | 2021-10-04 15:10:57 -0500 | [diff] [blame] | 179 |  | 
|  | 180 | /** | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 181 | * @brief Get the active profiles of the system where an empty list | 
|  | 182 | * represents that only configuration entries without a profile defined will | 
|  | 183 | * be loaded. | 
|  | 184 | * | 
|  | 185 | * @return - The list of active profiles | 
|  | 186 | */ | 
|  | 187 | static const std::vector<std::string>& getActiveProfiles(); | 
|  | 188 |  | 
|  | 189 | /** | 
|  | 190 | * @brief Load the configuration of a given JSON class object based on the | 
|  | 191 | * active profiles | 
|  | 192 | * | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 193 | * @param[in] isOptional - JSON configuration file is optional or not | 
| Matthew Barth | 603ef16 | 2021-03-24 15:34:53 -0500 | [diff] [blame] | 194 | * @param[in] args - Arguments to be forwarded to each instance of `T` | 
| Matthew Barth | e6d1f78 | 2021-05-14 12:52:20 -0500 | [diff] [blame] | 195 | *   (*Note that a sdbusplus bus object is required as the first argument) | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 196 | * | 
|  | 197 | * @return Map of configuration entries | 
|  | 198 | *     Map of configuration keys to their corresponding configuration object | 
|  | 199 | */ | 
| Matthew Barth | 603ef16 | 2021-03-24 15:34:53 -0500 | [diff] [blame] | 200 | template <typename T, typename... Args> | 
| Matthew Barth | e6d1f78 | 2021-05-14 12:52:20 -0500 | [diff] [blame] | 201 | static std::map<configKey, std::unique_ptr<T>> getConfig(bool isOptional, | 
|  | 202 | Args&&... args) | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 203 | { | 
|  | 204 | std::map<configKey, std::unique_ptr<T>> config; | 
|  | 205 |  | 
| Mike Capps | 808d7fe | 2022-06-13 10:12:16 -0400 | [diff] [blame] | 206 | auto confFile = fan::JsonConfig::getConfFile( | 
|  | 207 | confAppName, T::confFileName, isOptional); | 
|  | 208 |  | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 209 | if (!confFile.empty()) | 
|  | 210 | { | 
| Matthew Barth | bd52ed0 | 2022-02-07 15:15:10 -0600 | [diff] [blame] | 211 | FlightRecorder::instance().log( | 
| Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 212 | "main", std::format("Loading configuration from {}", | 
| Matthew Barth | bd52ed0 | 2022-02-07 15:15:10 -0600 | [diff] [blame] | 213 | confFile.string())); | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 214 | for (const auto& entry : fan::JsonConfig::load(confFile)) | 
|  | 215 | { | 
|  | 216 | if (entry.contains("profiles")) | 
|  | 217 | { | 
|  | 218 | std::vector<std::string> profiles; | 
|  | 219 | for (const auto& profile : entry["profiles"]) | 
|  | 220 | { | 
|  | 221 | profiles.emplace_back( | 
|  | 222 | profile.template get<std::string>()); | 
|  | 223 | } | 
|  | 224 | // Do not create the object if its profiles are not in the | 
|  | 225 | // list of active profiles | 
| Matthew Barth | 4242805 | 2021-03-30 12:50:59 -0500 | [diff] [blame] | 226 | if (!profiles.empty() && | 
|  | 227 | !std::any_of(profiles.begin(), profiles.end(), | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 228 | [](const auto& name) { | 
| Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 229 | return std::find(getActiveProfiles().begin(), | 
|  | 230 | getActiveProfiles().end(), | 
|  | 231 | name) != getActiveProfiles().end(); | 
| Patrick Williams | 5e15c3b | 2023-10-20 11:18:11 -0500 | [diff] [blame] | 232 | })) | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 233 | { | 
|  | 234 | continue; | 
|  | 235 | } | 
|  | 236 | } | 
| Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 237 | auto obj = std::make_unique<T>(entry, | 
|  | 238 | std::forward<Args>(args)...); | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 239 | config.emplace( | 
|  | 240 | std::make_pair(obj->getName(), obj->getProfiles()), | 
|  | 241 | std::move(obj)); | 
|  | 242 | } | 
| Matthew Barth | 68ac004 | 2021-06-01 15:38:36 -0500 | [diff] [blame] | 243 | log<level::INFO>( | 
| Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 244 | std::format("Configuration({}) loaded successfully", | 
| Matthew Barth | 68ac004 | 2021-06-01 15:38:36 -0500 | [diff] [blame] | 245 | T::confFileName) | 
|  | 246 | .c_str()); | 
| Matthew Barth | bd52ed0 | 2022-02-07 15:15:10 -0600 | [diff] [blame] | 247 | FlightRecorder::instance().log( | 
| Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 248 | "main", std::format("Configuration({}) loaded successfully", | 
| Matthew Barth | bd52ed0 | 2022-02-07 15:15:10 -0600 | [diff] [blame] | 249 | T::confFileName)); | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 250 | } | 
|  | 251 | return config; | 
|  | 252 | } | 
|  | 253 |  | 
|  | 254 | /** | 
| Matthew Barth | 0206c72 | 2021-03-30 15:20:05 -0500 | [diff] [blame] | 255 | * @brief Check if the given input configuration key matches with another | 
|  | 256 | * configuration key that it's to be included in | 
|  | 257 | * | 
|  | 258 | * @param[in] input - Config key to be included in another config object | 
|  | 259 | * @param[in] comp - Config key of the config object to compare with | 
|  | 260 | * | 
|  | 261 | * @return Whether the configuration object should be included | 
|  | 262 | */ | 
|  | 263 | static bool inConfig(const configKey& input, const configKey& comp); | 
|  | 264 |  | 
|  | 265 | /** | 
| Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 266 | * @brief Check if the given path and inteface is owned by a dbus service | 
|  | 267 | * | 
|  | 268 | * @param[in] path - Dbus object path | 
|  | 269 | * @param[in] intf - Dbus object interface | 
|  | 270 | * | 
|  | 271 | * @return - Whether the service has an owner for the given object path and | 
|  | 272 | * interface | 
|  | 273 | */ | 
|  | 274 | static bool hasOwner(const std::string& path, const std::string& intf); | 
|  | 275 |  | 
|  | 276 | /** | 
| Matthew Barth | 6d8e2d3 | 2022-02-01 16:47:08 -0600 | [diff] [blame] | 277 | * @brief Sets the dbus service owner state for all entries in the _servTree | 
|  | 278 | * cache and removes associated objects from the _objects cache | 
|  | 279 | * | 
|  | 280 | * @param[in] serv - Dbus service name | 
|  | 281 | * @param[in] hasOwner - Dbus service owner state | 
|  | 282 | */ | 
|  | 283 | void setOwner(const std::string& serv, bool hasOwner); | 
|  | 284 |  | 
|  | 285 | /** | 
| Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 286 | * @brief Sets the dbus service owner state of a given object | 
|  | 287 | * | 
|  | 288 | * @param[in] path - Dbus object path | 
|  | 289 | * @param[in] serv - Dbus service name | 
|  | 290 | * @param[in] intf - Dbus object interface | 
|  | 291 | * @param[in] isOwned - Dbus service owner state | 
|  | 292 | */ | 
|  | 293 | void setOwner(const std::string& path, const std::string& serv, | 
|  | 294 | const std::string& intf, bool isOwned); | 
|  | 295 |  | 
|  | 296 | /** | 
|  | 297 | * @brief Add a set of services for a path and interface by retrieving all | 
|  | 298 | * the path subtrees to the given depth from root for the interface | 
|  | 299 | * | 
| Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 300 | * @param[in] intf - Interface to add services for | 
|  | 301 | * @param[in] depth - Depth of tree traversal from root path | 
|  | 302 | * | 
|  | 303 | * @throws - DBusMethodError | 
|  | 304 | * Throws a DBusMethodError when the `getSubTree` method call fails | 
|  | 305 | */ | 
| Matthew Barth | 98f6fc1 | 2021-04-16 10:48:37 -0500 | [diff] [blame] | 306 | static void addServices(const std::string& intf, int32_t depth); | 
| Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 307 |  | 
|  | 308 | /** | 
|  | 309 | * @brief Get the service for a given path and interface from cached | 
|  | 310 | * dataset and attempt to add all the services for the given path/interface | 
|  | 311 | * when it's not found | 
|  | 312 | * | 
|  | 313 | * @param[in] path - Path to get service for | 
|  | 314 | * @param[in] intf - Interface to get service for | 
|  | 315 | * | 
|  | 316 | * @return - The now cached service name | 
|  | 317 | * | 
|  | 318 | * @throws - DBusMethodError | 
|  | 319 | * Ripples up a DBusMethodError exception from calling addServices | 
|  | 320 | */ | 
|  | 321 | static const std::string& getService(const std::string& path, | 
|  | 322 | const std::string& intf); | 
|  | 323 |  | 
|  | 324 | /** | 
| Matthew Barth | f41e947 | 2021-05-13 16:38:06 -0500 | [diff] [blame] | 325 | * @brief Get all the object paths for a given service and interface from | 
|  | 326 | * the cached dataset and try to add all the services for the given | 
|  | 327 | * interface when no paths are found and then attempt to get all the object | 
|  | 328 | * paths again | 
|  | 329 | * | 
|  | 330 | * @param[in] serv - Service name to get paths for | 
|  | 331 | * @param[in] intf - Interface to get paths for | 
|  | 332 | * | 
|  | 333 | * @return The cached object paths | 
|  | 334 | */ | 
|  | 335 | std::vector<std::string> getPaths(const std::string& serv, | 
|  | 336 | const std::string& intf); | 
|  | 337 |  | 
|  | 338 | /** | 
|  | 339 | * @brief Add objects to the cached dataset by first using | 
|  | 340 | * `getManagedObjects` for the same service providing the given path and | 
|  | 341 | * interface or just add the single object of the given path, interface, and | 
|  | 342 | * property if that fails. | 
|  | 343 | * | 
|  | 344 | * @param[in] path - Dbus object's path | 
|  | 345 | * @param[in] intf - Dbus object's interface | 
|  | 346 | * @param[in] prop - Dbus object's property | 
|  | 347 | * | 
|  | 348 | * @throws - DBusMethodError | 
|  | 349 | * Throws a DBusMethodError when the the service is failed to be found or | 
|  | 350 | * when the `getManagedObjects` method call fails | 
|  | 351 | */ | 
|  | 352 | void addObjects(const std::string& path, const std::string& intf, | 
| Matt Spinler | 9ac325c | 2022-04-25 14:13:49 -0500 | [diff] [blame] | 353 | const std::string& prop) | 
|  | 354 | { | 
|  | 355 | addObjects(path, intf, prop, std::string{}); | 
|  | 356 | } | 
|  | 357 |  | 
|  | 358 | /** | 
|  | 359 | * @copydoc Manager::addObjects() | 
|  | 360 | * | 
|  | 361 | * If the service is known, then it can be used to add all objects | 
|  | 362 | * in that service with the interface passed in to the cache instead of | 
|  | 363 | * having to look it up.  This is done so objects can still be | 
|  | 364 | * added even when the D-Bus path passed in doesn't exist so it | 
|  | 365 | * can't be used to get a service name. | 
|  | 366 | * | 
|  | 367 | * @param[in] path - Dbus object's path | 
|  | 368 | * @param[in] intf - Dbus object's interface | 
|  | 369 | * @param[in] prop - Dbus object's property | 
|  | 370 | * @param[in] serviceName - The service of the path/intf/prop if known | 
|  | 371 | */ | 
|  | 372 | void addObjects(const std::string& path, const std::string& intf, | 
|  | 373 | const std::string& prop, const std::string& serviceName); | 
| Matthew Barth | f41e947 | 2021-05-13 16:38:06 -0500 | [diff] [blame] | 374 |  | 
|  | 375 | /** | 
|  | 376 | * @brief Get an object's property value | 
|  | 377 | * | 
|  | 378 | * @param[in] path - Dbus object's path | 
|  | 379 | * @param[in] intf - Dbus object's interface | 
|  | 380 | * @param[in] prop - Dbus object's property | 
|  | 381 | */ | 
|  | 382 | const std::optional<PropertyVariantType> | 
|  | 383 | getProperty(const std::string& path, const std::string& intf, | 
|  | 384 | const std::string& prop); | 
|  | 385 |  | 
|  | 386 | /** | 
| Matthew Barth | baeeb8f | 2021-05-13 16:03:54 -0500 | [diff] [blame] | 387 | * @brief Set/update an object's property value | 
|  | 388 | * | 
|  | 389 | * @param[in] path - Dbus object's path | 
|  | 390 | * @param[in] intf - Dbus object's interface | 
|  | 391 | * @param[in] prop - Dbus object's property | 
|  | 392 | * @param[in] value - Dbus object's property value | 
|  | 393 | */ | 
|  | 394 | void setProperty(const std::string& path, const std::string& intf, | 
| Mike Capps | 1a19ead | 2021-10-22 09:15:14 -0400 | [diff] [blame] | 395 | const std::string& prop, PropertyVariantType value); | 
| Matthew Barth | baeeb8f | 2021-05-13 16:03:54 -0500 | [diff] [blame] | 396 |  | 
|  | 397 | /** | 
| Matthew Barth | c269140 | 2021-05-13 16:20:32 -0500 | [diff] [blame] | 398 | * @brief Remove an object's interface | 
|  | 399 | * | 
|  | 400 | * @param[in] path - Dbus object's path | 
|  | 401 | * @param[in] intf - Dbus object's interface | 
|  | 402 | */ | 
|  | 403 | inline void removeInterface(const std::string& path, | 
|  | 404 | const std::string& intf) | 
|  | 405 | { | 
|  | 406 | auto itPath = _objects.find(path); | 
|  | 407 | if (itPath != std::end(_objects)) | 
|  | 408 | { | 
|  | 409 | _objects[path].erase(intf); | 
|  | 410 | } | 
|  | 411 | } | 
|  | 412 |  | 
|  | 413 | /** | 
| Matthew Barth | 07fecfc | 2021-01-29 09:04:43 -0600 | [diff] [blame] | 414 | * @brief Get the object's property value as a variant | 
|  | 415 | * | 
|  | 416 | * @param[in] path - Path of the object containing the property | 
|  | 417 | * @param[in] intf - Interface name containing the property | 
|  | 418 | * @param[in] prop - Name of property | 
|  | 419 | * | 
|  | 420 | * @return - The object's property value as a variant | 
|  | 421 | */ | 
|  | 422 | static inline auto getObjValueVariant(const std::string& path, | 
|  | 423 | const std::string& intf, | 
|  | 424 | const std::string& prop) | 
|  | 425 | { | 
|  | 426 | return _objects.at(path).at(intf).at(prop); | 
|  | 427 | }; | 
|  | 428 |  | 
|  | 429 | /** | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 430 | * @brief Add a dbus timer | 
|  | 431 | * | 
|  | 432 | * @param[in] type - Type of timer | 
|  | 433 | * @param[in] interval - Timer interval in microseconds | 
|  | 434 | * @param[in] pkg - Packaged data for when timer expires | 
|  | 435 | */ | 
|  | 436 | void addTimer(const TimerType type, | 
|  | 437 | const std::chrono::microseconds interval, | 
|  | 438 | std::unique_ptr<TimerPkg> pkg); | 
|  | 439 |  | 
|  | 440 | /** | 
|  | 441 | * @brief Callback when a timer expires | 
|  | 442 | * | 
|  | 443 | * @param[in] data - Data to be used when the timer expired | 
|  | 444 | */ | 
|  | 445 | void timerExpired(TimerData& data); | 
|  | 446 |  | 
|  | 447 | /** | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 448 | * @brief Get the signal data for a given match string | 
|  | 449 | * | 
|  | 450 | * @param[in] sigMatch - Signal match string | 
|  | 451 | * | 
|  | 452 | * @return - Reference to the signal data for the given match string | 
|  | 453 | */ | 
|  | 454 | std::vector<SignalData>& getSignal(const std::string& sigMatch) | 
|  | 455 | { | 
|  | 456 | return _signals[sigMatch]; | 
|  | 457 | } | 
|  | 458 |  | 
|  | 459 | /** | 
|  | 460 | * @brief Handle receiving signals | 
|  | 461 | * | 
|  | 462 | * @param[in] msg - Signal message containing the signal's data | 
|  | 463 | * @param[in] pkgs - Signal packages associated to the signal being handled | 
|  | 464 | */ | 
| Patrick Williams | cb356d4 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 465 | void handleSignal(sdbusplus::message_t& msg, | 
| Matthew Barth | c024d78 | 2021-11-09 16:15:49 -0600 | [diff] [blame] | 466 | const std::vector<SignalPkg>* pkgs); | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 467 |  | 
|  | 468 | /** | 
| Matthew Barth | eebde06 | 2021-04-14 12:48:52 -0500 | [diff] [blame] | 469 | * @brief Get the sdbusplus bus object | 
|  | 470 | */ | 
|  | 471 | inline auto& getBus() | 
|  | 472 | { | 
|  | 473 | return _bus; | 
|  | 474 | } | 
|  | 475 |  | 
|  | 476 | /** | 
| Matthew Barth | 48f44da | 2021-05-27 15:43:34 -0500 | [diff] [blame] | 477 | * @brief Is the power state on | 
|  | 478 | * | 
|  | 479 | * @return Current power state of the system | 
|  | 480 | */ | 
|  | 481 | inline bool isPowerOn() const | 
|  | 482 | { | 
|  | 483 | return _powerState->isPowerOn(); | 
|  | 484 | } | 
|  | 485 |  | 
| Matthew Barth | 3770a1d | 2021-06-10 15:09:37 -0500 | [diff] [blame] | 486 | /** | 
|  | 487 | * @brief Load all the fan control JSON configuration files | 
|  | 488 | * | 
|  | 489 | * This is where all the fan control JSON configuration files are parsed and | 
|  | 490 | * loaded into their associated objects. Anything that needs to be done when | 
|  | 491 | * the Manager object is constructed or handling a SIGHUP to reload the | 
|  | 492 | * configurations needs to be done here. | 
|  | 493 | */ | 
|  | 494 | void load(); | 
|  | 495 |  | 
| Matt Spinler | d76351b | 2021-08-05 16:23:09 -0500 | [diff] [blame] | 496 | /** | 
|  | 497 | * @brief Sets a value in the parameter map. | 
|  | 498 | * | 
| Matt Spinler | 72c4af4 | 2021-11-29 14:40:17 -0600 | [diff] [blame] | 499 | * If it's a std::nullopt, it will be deleted instead. | 
|  | 500 | * | 
| Matt Spinler | d76351b | 2021-08-05 16:23:09 -0500 | [diff] [blame] | 501 | * @param[in] name - The parameter name | 
|  | 502 | * @param[in] value - The parameter value | 
|  | 503 | */ | 
|  | 504 | static void setParameter(const std::string& name, | 
| Matt Spinler | 72c4af4 | 2021-11-29 14:40:17 -0600 | [diff] [blame] | 505 | const std::optional<PropertyVariantType>& value) | 
| Matt Spinler | d76351b | 2021-08-05 16:23:09 -0500 | [diff] [blame] | 506 | { | 
| Matt Spinler | 72c4af4 | 2021-11-29 14:40:17 -0600 | [diff] [blame] | 507 | if (value) | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 508 | { | 
| Matt Spinler | 72c4af4 | 2021-11-29 14:40:17 -0600 | [diff] [blame] | 509 | auto it = _parameters.find(name); | 
|  | 510 | auto changed = (it == _parameters.end()) || | 
|  | 511 | ((it != _parameters.end()) && it->second != *value); | 
|  | 512 | _parameters[name] = *value; | 
|  | 513 |  | 
|  | 514 | if (changed) | 
|  | 515 | { | 
|  | 516 | runParameterActions(name); | 
|  | 517 | } | 
|  | 518 | } | 
|  | 519 | else | 
|  | 520 | { | 
|  | 521 | size_t deleted = _parameters.erase(name); | 
|  | 522 |  | 
|  | 523 | if (deleted) | 
|  | 524 | { | 
|  | 525 | runParameterActions(name); | 
|  | 526 | } | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 527 | } | 
| Matt Spinler | d76351b | 2021-08-05 16:23:09 -0500 | [diff] [blame] | 528 | } | 
|  | 529 |  | 
|  | 530 | /** | 
|  | 531 | * @brief Returns a value from the parameter map | 
|  | 532 | * | 
|  | 533 | * @param[in] name - The parameter name | 
|  | 534 | * | 
|  | 535 | * @return The parameter value, or std::nullopt if not found | 
|  | 536 | */ | 
|  | 537 | static std::optional<PropertyVariantType> | 
|  | 538 | getParameter(const std::string& name) | 
|  | 539 | { | 
|  | 540 | auto it = _parameters.find(name); | 
|  | 541 | if (it != _parameters.end()) | 
|  | 542 | { | 
|  | 543 | return it->second; | 
|  | 544 | } | 
|  | 545 |  | 
|  | 546 | return std::nullopt; | 
|  | 547 | } | 
|  | 548 |  | 
|  | 549 | /** | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 550 | * @brief Runs the actions registered to a parameter | 
|  | 551 | *        trigger with this name. | 
|  | 552 | * | 
|  | 553 | * @param[in] name - The parameter name | 
|  | 554 | */ | 
|  | 555 | static void runParameterActions(const std::string& name); | 
|  | 556 |  | 
|  | 557 | /** | 
|  | 558 | * @brief Adds a parameter trigger | 
|  | 559 | * | 
|  | 560 | * @param[in] name - The parameter name | 
|  | 561 | * @param[in] actions - The actions to run on the trigger | 
|  | 562 | */ | 
|  | 563 | static void | 
|  | 564 | addParameterTrigger(const std::string& name, | 
|  | 565 | std::vector<std::unique_ptr<ActionBase>>& actions); | 
|  | 566 |  | 
| Matt Spinler | 7787def | 2021-10-14 16:33:16 -0500 | [diff] [blame] | 567 | /* The name of the dump file */ | 
|  | 568 | static const std::string dumpFile; | 
|  | 569 |  | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 570 | private: | 
| Mike Capps | 1a19ead | 2021-10-22 09:15:14 -0400 | [diff] [blame] | 571 | /** | 
|  | 572 | * @brief Helper to detect when a property's double contains a NaN | 
|  | 573 | * (not-a-number) value. | 
|  | 574 | * | 
|  | 575 | * @param[in] value - The property to test | 
|  | 576 | */ | 
|  | 577 | static bool PropertyContainsNan(const PropertyVariantType& value) | 
|  | 578 | { | 
|  | 579 | return (std::holds_alternative<double>(value) && | 
|  | 580 | std::isnan(std::get<double>(value))); | 
|  | 581 | } | 
|  | 582 |  | 
|  | 583 | /** | 
|  | 584 | * @brief Insert managed objects into cache, but filter out properties | 
| Matt Spinler | c2c2db7 | 2022-04-07 13:59:37 -0500 | [diff] [blame] | 585 | * containing unwanted NaN (not-a-number) values and properties that | 
|  | 586 | * are on D-Bus paths that aren't in an existing Group object. | 
| Mike Capps | 1a19ead | 2021-10-22 09:15:14 -0400 | [diff] [blame] | 587 | * | 
|  | 588 | * @param[in] ref - The map of ManagedObjects to insert into cache | 
|  | 589 | */ | 
|  | 590 | void insertFilteredObjects(ManagedObjects& ref); | 
|  | 591 |  | 
| Matthew Barth | 1542fb5 | 2021-06-10 14:09:09 -0500 | [diff] [blame] | 592 | /* The sdbusplus bus object to use */ | 
| Patrick Williams | cb356d4 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 593 | sdbusplus::bus_t& _bus; | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 594 |  | 
| Matthew Barth | 1542fb5 | 2021-06-10 14:09:09 -0500 | [diff] [blame] | 595 | /* The sdeventplus even loop to use */ | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 596 | sdeventplus::Event _event; | 
|  | 597 |  | 
| Matthew Barth | 1542fb5 | 2021-06-10 14:09:09 -0500 | [diff] [blame] | 598 | /* The sdbusplus manager object to set the ObjectManager interface */ | 
| Patrick Williams | cb356d4 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 599 | sdbusplus::server::manager_t _mgr; | 
| Matthew Barth | 1542fb5 | 2021-06-10 14:09:09 -0500 | [diff] [blame] | 600 |  | 
| Matthew Barth | 3770a1d | 2021-06-10 15:09:37 -0500 | [diff] [blame] | 601 | /* Whether loading the config files is allowed or not */ | 
|  | 602 | bool _loadAllowed; | 
|  | 603 |  | 
| Matthew Barth | 48f44da | 2021-05-27 15:43:34 -0500 | [diff] [blame] | 604 | /* The system's power state determination object */ | 
|  | 605 | std::unique_ptr<PowerState> _powerState; | 
|  | 606 |  | 
| Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 607 | /* List of profiles configured */ | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 608 | std::map<configKey, std::unique_ptr<Profile>> _profiles; | 
| Matthew Barth | 0676494 | 2021-03-04 09:28:40 -0600 | [diff] [blame] | 609 |  | 
|  | 610 | /* List of active profiles */ | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 611 | static std::vector<std::string> _activeProfiles; | 
|  | 612 |  | 
| Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 613 | /* Subtree map of paths to services of interfaces(with ownership state) */ | 
|  | 614 | static std::map< | 
|  | 615 | std::string, | 
|  | 616 | std::map<std::string, std::pair<bool, std::vector<std::string>>>> | 
| Matthew Barth | 12cb125 | 2021-03-08 16:47:30 -0600 | [diff] [blame] | 617 | _servTree; | 
|  | 618 |  | 
| Matthew Barth | 07fecfc | 2021-01-29 09:04:43 -0600 | [diff] [blame] | 619 | /* Object map of paths to interfaces of properties and their values */ | 
|  | 620 | static std::map< | 
|  | 621 | std::string, | 
|  | 622 | std::map<std::string, std::map<std::string, PropertyVariantType>>> | 
|  | 623 | _objects; | 
|  | 624 |  | 
| Matthew Barth | d9cb63b | 2021-03-24 14:36:49 -0500 | [diff] [blame] | 625 | /* List of timers and their data to be processed when expired */ | 
|  | 626 | std::vector<std::pair<std::unique_ptr<TimerData>, Timer>> _timers; | 
|  | 627 |  | 
| Matthew Barth | ebabc04 | 2021-05-13 15:38:58 -0500 | [diff] [blame] | 628 | /* Map of signal match strings to a list of signal handler data */ | 
|  | 629 | std::unordered_map<std::string, std::vector<SignalData>> _signals; | 
|  | 630 |  | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 631 | /* List of zones configured */ | 
|  | 632 | std::map<configKey, std::unique_ptr<Zone>> _zones; | 
|  | 633 |  | 
| Matthew Barth | 44ab769 | 2021-03-26 11:40:10 -0500 | [diff] [blame] | 634 | /* List of events configured */ | 
|  | 635 | std::map<configKey, std::unique_ptr<Event>> _events; | 
|  | 636 |  | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 637 | /** | 
| Matt Spinler | d76351b | 2021-08-05 16:23:09 -0500 | [diff] [blame] | 638 | * @brief A map of parameter names and values that are something | 
|  | 639 | *        other than just D-Bus property values that other actions | 
|  | 640 | *        can set and use. | 
|  | 641 | */ | 
|  | 642 | static std::unordered_map<std::string, PropertyVariantType> _parameters; | 
|  | 643 |  | 
|  | 644 | /** | 
| Matt Spinler | d0ba86a | 2021-11-09 10:09:13 -0600 | [diff] [blame] | 645 | * @brief Map of parameter names to the actions to run when their | 
|  | 646 | *        values change. | 
|  | 647 | */ | 
|  | 648 | static std::unordered_map<std::string, TriggerActions> _parameterTriggers; | 
|  | 649 |  | 
|  | 650 | /** | 
| Matthew Barth | b2cd93f | 2021-06-16 16:37:40 -0500 | [diff] [blame] | 651 | * @brief Callback for power state changes | 
|  | 652 | * | 
|  | 653 | * @param[in] powerStateOn - Whether the power state is on or not | 
|  | 654 | * | 
|  | 655 | * Callback function bound to the PowerState object instance to handle each | 
|  | 656 | * time the power state changes. | 
|  | 657 | */ | 
|  | 658 | void powerStateChanged(bool powerStateOn); | 
|  | 659 |  | 
|  | 660 | /** | 
| Matthew Barth | 4ca87fa | 2021-04-14 11:31:13 -0500 | [diff] [blame] | 661 | * @brief Find the service name for a given path and interface from the | 
|  | 662 | * cached dataset | 
|  | 663 | * | 
|  | 664 | * @param[in] path - Path to get service for | 
|  | 665 | * @param[in] intf - Interface to get service for | 
|  | 666 | * | 
|  | 667 | * @return - The cached service name | 
|  | 668 | */ | 
|  | 669 | static const std::string& findService(const std::string& path, | 
|  | 670 | const std::string& intf); | 
|  | 671 |  | 
|  | 672 | /** | 
| Matthew Barth | f41e947 | 2021-05-13 16:38:06 -0500 | [diff] [blame] | 673 | * @brief Find all the paths for a given service and interface from the | 
|  | 674 | * cached dataset | 
|  | 675 | * | 
|  | 676 | * @param[in] serv - Service name to get paths for | 
|  | 677 | * @param[in] intf - Interface to get paths for | 
|  | 678 | * | 
|  | 679 | * @return - The cached object paths | 
|  | 680 | */ | 
|  | 681 | std::vector<std::string> findPaths(const std::string& serv, | 
|  | 682 | const std::string& intf); | 
|  | 683 |  | 
|  | 684 | /** | 
| Matthew Barth | acd737c | 2021-03-04 11:04:01 -0600 | [diff] [blame] | 685 | * @brief Parse and set the configured profiles from the profiles JSON file | 
|  | 686 | * | 
|  | 687 | * Retrieves the optional profiles JSON configuration file, parses it, and | 
|  | 688 | * creates a list of configured profiles available to the other | 
|  | 689 | * configuration files. These profiles can be used to remove or include | 
|  | 690 | * entries within the other configuration files. | 
|  | 691 | */ | 
|  | 692 | void setProfiles(); | 
| Matt Spinler | 2fc0a35 | 2021-10-04 15:10:57 -0500 | [diff] [blame] | 693 |  | 
|  | 694 | /** | 
| Matt Spinler | b5c21a2 | 2021-10-14 16:52:12 -0500 | [diff] [blame] | 695 | * @brief Dump the _objects, _servTree, and _parameters maps to JSON | 
|  | 696 | * | 
|  | 697 | * @param[out] data - The JSON that will be filled in | 
|  | 698 | */ | 
|  | 699 | void dumpCache(json& data); | 
| Matt Spinler | ade0c37 | 2021-10-28 16:09:44 -0500 | [diff] [blame] | 700 |  | 
|  | 701 | /** | 
| Matthew Barth | 2f359f7 | 2022-02-15 10:00:26 -0600 | [diff] [blame] | 702 | * @brief Add a list of groups to the cache dataset. | 
| Matt Spinler | ade0c37 | 2021-10-28 16:09:44 -0500 | [diff] [blame] | 703 | * | 
| Matthew Barth | 2f359f7 | 2022-02-15 10:00:26 -0600 | [diff] [blame] | 704 | * @param[in] groups - The groups to add | 
| Matt Spinler | ade0c37 | 2021-10-28 16:09:44 -0500 | [diff] [blame] | 705 | */ | 
| Matthew Barth | 2f359f7 | 2022-02-15 10:00:26 -0600 | [diff] [blame] | 706 | void addGroups(const std::vector<Group>& groups); | 
| Matthew Barth | a227a16 | 2020-08-05 10:51:45 -0500 | [diff] [blame] | 707 | }; | 
|  | 708 |  | 
|  | 709 | } // namespace phosphor::fan::control::json |