blob: 611ee8be1aad95b3a3a24062c9087216ffa20ba1 [file] [log] [blame]
Matthew Barth0c4b1572020-10-22 14:39:46 -05001/**
Matthew Barth41a34082021-01-27 15:31:48 -06002 * Copyright © 2021 IBM Corporation
Matthew Barth0c4b1572020-10-22 14:39:46 -05003 *
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 Barth12cb1252021-03-08 16:47:30 -060018#include "../zone.hpp"
Matthew Barth0c4b1572020-10-22 14:39:46 -050019#include "action.hpp"
Matthew Barth12cb1252021-03-08 16:47:30 -060020#include "group.hpp"
Matthew Barth0c4b1572020-10-22 14:39:46 -050021
22#include <nlohmann/json.hpp>
23
24namespace phosphor::fan::control::json
25{
26
27using json = nlohmann::json;
28
29/**
Matthew Barthe47c9582021-03-09 14:24:02 -060030 * @class DefaultFloor - Action to default the fan floor
Matthew Barth0c4b1572020-10-22 14:39:46 -050031 *
Matthew Barthe47c9582021-03-09 14:24:02 -060032 * Sets the fan floor to the defined default fan floor when a service associated
33 * to a given group has terminated. Once all services are functional and
34 * providing the sensors, the fan floor is allowed to be set normally again.
Matthew Barth0c4b1572020-10-22 14:39:46 -050035 */
36class DefaultFloor : public ActionBase, public ActionRegister<DefaultFloor>
37{
38 public:
39 /* Name of this action */
40 static constexpr auto name = "default_floor_on_missing_owner";
41
42 DefaultFloor() = delete;
43 DefaultFloor(const DefaultFloor&) = delete;
44 DefaultFloor(DefaultFloor&&) = delete;
45 DefaultFloor& operator=(const DefaultFloor&) = delete;
46 DefaultFloor& operator=(DefaultFloor&&) = delete;
47 ~DefaultFloor() = default;
48
Matthew Barth41a34082021-01-27 15:31:48 -060049 /**
Matthew Barthe47c9582021-03-09 14:24:02 -060050 * @brief Default the fan floor
Matthew Barth41a34082021-01-27 15:31:48 -060051 *
Matthew Barthbfd7e1b2021-02-04 14:25:47 -060052 * @param[in] jsonObj - JSON configuration of this action
Matthew Barth19c77492021-04-08 10:06:06 -050053 * @param[in] groups - Groups of dbus objects the action uses
Matthew Barth41a34082021-01-27 15:31:48 -060054 */
Matthew Barth19c77492021-04-08 10:06:06 -050055 DefaultFloor(const json& jsonObj, const std::vector<Group>& groups);
Matthew Barth0c4b1572020-10-22 14:39:46 -050056
Matthew Barth41a34082021-01-27 15:31:48 -060057 /**
58 * @brief Run the action
59 *
60 * Updates the services of the group, then determines if any of the
61 * services hosting the members of the group are not owned on dbus
62 * resulting in the zone's floor being set/held at the default floor.
63 *
64 * @param[in] zone - Zone to run the action on
Matthew Barth41a34082021-01-27 15:31:48 -060065 */
Matthew Barth6d2476c2021-04-08 10:48:57 -050066 void run(Zone& zone) override;
Matthew Barth0c4b1572020-10-22 14:39:46 -050067};
68
69} // namespace phosphor::fan::control::json