blob: f5c994b9d14fc7a84ee7bd9f28b4f099ca50373b [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 Barth41a34082021-01-27 15:31:48 -060053 */
Matthew Barthbfd7e1b2021-02-04 14:25:47 -060054 explicit DefaultFloor(const json& jsonObj);
Matthew Barth0c4b1572020-10-22 14:39:46 -050055
Matthew Barth41a34082021-01-27 15:31:48 -060056 /**
57 * @brief Run the action
58 *
59 * Updates the services of the group, then determines if any of the
60 * services hosting the members of the group are not owned on dbus
61 * resulting in the zone's floor being set/held at the default floor.
62 *
63 * @param[in] zone - Zone to run the action on
64 * @param[in] group - Group of dbus objects the action runs against
65 */
66 void run(Zone& zone, const Group& group) override;
Matthew Barth0c4b1572020-10-22 14:39:46 -050067};
68
69} // namespace phosphor::fan::control::json