blob: 1807134296ed1deb1dabd6986c9fab59f70a37f1 [file] [log] [blame]
Gunnar Millsec1b41c2017-05-02 12:20:36 -05001#pragma once
2
Saqib Khanb0774702017-05-23 16:02:41 -05003#include <sdbusplus/server.hpp>
Gunnar Millsec1b41c2017-05-02 12:20:36 -05004#include <xyz/openbmc_project/Software/Activation/server.hpp>
Saqib Khanb0774702017-05-23 16:02:41 -05005#include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp>
Saqib Khan4c1aec02017-07-06 11:46:13 -05006#include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp"
Gunnar Millsec1b41c2017-05-02 12:20:36 -05007
8namespace phosphor
9{
10namespace software
11{
12namespace updater
13{
14
15using ActivationInherit = sdbusplus::server::object::object<
16 sdbusplus::xyz::openbmc_project::Software::server::Activation>;
Saqib Khanb0774702017-05-23 16:02:41 -050017using ActivationBlocksTransitionInherit = sdbusplus::server::object::object<
18 sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>;
Saqib Khan4c1aec02017-07-06 11:46:13 -050019using RedundancyPriorityInherit = sdbusplus::server::object::object<
20 sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>;
21
22class ItemUpdater;
23class Activation;
24class RedundancyPriority;
25
26/** @class RedundancyPriority
27 * @brief OpenBMC RedundancyPriority implementation
28 * @details A concrete implementation for
29 * xyz.openbmc_project.Software.RedundancyPriority DBus API.
30 */
31class RedundancyPriority : public RedundancyPriorityInherit
32{
33 public:
34 /** @brief Constructs RedundancyPriority.
35 *
36 * @param[in] bus - The Dbus bus object
37 * @param[in] path - The Dbus object path
38 * @param[in] parent - Parent object.
39 * @param[in] value - The redundancyPriority value
40 */
41 RedundancyPriority(sdbusplus::bus::bus& bus,
42 const std::string& path,
43 Activation& parent,
44 uint8_t value) :
45 RedundancyPriorityInherit(bus,
46 path.c_str(), true),
47 parent(parent)
48 {
49 // Set Property
50 priority(value);
51 // Emit deferred signal.
52 emit_object_added();
53 }
54
55 /** @brief Overloaded Priority property set function
56 *
57 * @param[in] value - uint8_t
58 *
59 * @return Success or exception thrown
60 */
61 uint8_t priority(uint8_t value) override;
62
63 /** @brief Priority property get function
64 *
65 * @returns uint8_t - The Priority value
66 */
67 using RedundancyPriorityInherit::priority;
68
69 /** @brief Parent Object. */
70 Activation& parent;
71};
Saqib Khanb0774702017-05-23 16:02:41 -050072
73/** @class ActivationBlocksTransition
74 * @brief OpenBMC ActivationBlocksTransition implementation.
75 * @details A concrete implementation for
76 * xyz.openbmc_project.Software.ActivationBlocksTransition DBus API.
77 */
78class ActivationBlocksTransition : public ActivationBlocksTransitionInherit
79{
80 public:
81 /** @brief Constructs ActivationBlocksTransition.
82 *
83 * @param[in] bus - The Dbus bus object
84 * @param[in] path - The Dbus object path
85 */
86 ActivationBlocksTransition(sdbusplus::bus::bus& bus,
87 const std::string& path) :
88 ActivationBlocksTransitionInherit(bus, path.c_str()) {}
89};
Gunnar Millsec1b41c2017-05-02 12:20:36 -050090
91/** @class Activation
92 * @brief OpenBMC activation software management implementation.
93 * @details A concrete implementation for
94 * xyz.openbmc_project.Software.Activation DBus API.
95 */
96class Activation : public ActivationInherit
97{
98 public:
99 /** @brief Constructs Activation Software Manager
100 *
101 * @param[in] bus - The Dbus bus object
102 * @param[in] path - The Dbus object path
Saqib Khan4c1aec02017-07-06 11:46:13 -0500103 * @param[in] parent - Parent object.
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500104 * @param[in] versionId - The software version id
105 * @param[in] activationStatus - The status of Activation
Gunnar Millsec1b41c2017-05-02 12:20:36 -0500106 */
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500107 Activation(sdbusplus::bus::bus& bus, const std::string& path,
Saqib Khan4c1aec02017-07-06 11:46:13 -0500108 ItemUpdater& parent,
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500109 std::string& versionId,
110 sdbusplus::xyz::openbmc_project::Software::
111 server::Activation::Activations activationStatus) :
112 ActivationInherit(bus, path.c_str(), true),
113 bus(bus),
114 path(path),
Saqib Khan4c1aec02017-07-06 11:46:13 -0500115 parent(parent),
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500116 versionId(versionId)
117 {
118 // Set Properties.
119 activation(activationStatus);
120 // Emit deferred signal.
121 emit_object_added();
122 }
123
Saqib Khanb0774702017-05-23 16:02:41 -0500124 /** @brief Overloaded Activation property setter function
125 *
126 * @param[in] value - One of Activation::Activations
127 *
128 * @return Success or exception thrown
129 */
130 Activations activation(Activations value) override;
131
132 /** @brief Overloaded requestedActivation property setter function
133 *
134 * @param[in] value - One of Activation::RequestedActivations
135 *
136 * @return Success or exception thrown
137 */
138 RequestedActivations requestedActivation(RequestedActivations value)
139 override;
140
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500141 /** @brief Persistent sdbusplus DBus bus connection */
142 sdbusplus::bus::bus& bus;
143
144 /** @brief Persistent DBus object path */
145 std::string path;
146
Saqib Khan4c1aec02017-07-06 11:46:13 -0500147 /** @brief Parent Object. */
148 ItemUpdater& parent;
149
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500150 /** @brief Version id */
151 std::string versionId;
Saqib Khanb0774702017-05-23 16:02:41 -0500152
153 /** @brief Persistent ActivationBlocksTransition dbus object */
154 std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
Saqib Khan4c1aec02017-07-06 11:46:13 -0500155
156 /** @brief Persistent RedundancyPriority dbus object */
157 std::unique_ptr<RedundancyPriority> redundancyPriority;
Gunnar Millsec1b41c2017-05-02 12:20:36 -0500158};
159
160} // namespace updater
161} // namespace software
162} // namespace phosphor