blob: bedef8170a461399376424530140129c78a32fcb [file] [log] [blame]
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05001#pragma once
2
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -05003#include <sdbusplus/server.hpp>
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05004#include <xyz/openbmc_project/Software/Activation/server.hpp>
Adriana Kobylakea9626f2017-04-05 15:37:40 -05005#include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp>
Saqib Khan7254f0e2017-04-10 21:45:37 -05006#include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp"
Saqib Khan942df8a2017-06-01 14:09:27 -05007#include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp"
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05008
9namespace openpower
10{
11namespace software
12{
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050013namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050014{
15
16using ActivationInherit = sdbusplus::server::object::object<
Saqib Khan7254f0e2017-04-10 21:45:37 -050017 sdbusplus::xyz::openbmc_project::Software::server::ExtendedVersion,
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050018 sdbusplus::xyz::openbmc_project::Software::server::Activation>;
Adriana Kobylakea9626f2017-04-05 15:37:40 -050019using ActivationBlocksTransitionInherit = sdbusplus::server::object::object<
20 sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>;
Saqib Khan942df8a2017-06-01 14:09:27 -050021using RedundancyPriorityInherit = sdbusplus::server::object::object<
22 sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>;
23
Michael Tritz9d25b602017-06-14 14:41:43 -050024namespace sdbusRule = sdbusplus::bus::match::rules;
25
Saqib Khan942df8a2017-06-01 14:09:27 -050026/** @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 */
39 RedundancyPriority(sdbusplus::bus::bus& bus,
40 const std::string& path) :
41 RedundancyPriorityInherit(bus,
42 path.c_str(), true)
43 {
44 // Set Property
45 priority(0);
46 // Emit deferred signal.
47 emit_object_added();
48 }
Saqib Khan2021b4c2017-06-07 14:37:36 -050049
50 /** @brief Overloaded Priority property set function
51 *
52 * @param[in] value - uint8_t
53 *
54 * @return Success or exception thrown
55 */
56 uint8_t priority(uint8_t value) override;
Saqib Khan942df8a2017-06-01 14:09:27 -050057};
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050058
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -050059/** @class ActivationBlocksTransition
60 * @brief OpenBMC ActivationBlocksTransition implementation.
61 * @details A concrete implementation for
62 * xyz.openbmc_project.Software.ActivationBlocksTransition DBus API.
63 */
64class ActivationBlocksTransition : public ActivationBlocksTransitionInherit
65{
66 public:
67 /** @brief Constructs ActivationBlocksTransition.
68 *
69 * @param[in] bus - The Dbus bus object
70 * @param[in] path - The Dbus object path
71 */
72 ActivationBlocksTransition(sdbusplus::bus::bus& bus,
73 const std::string& path) :
74 ActivationBlocksTransitionInherit(bus, path.c_str()) {}
75};
76
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050077/** @class Activation
78 * @brief OpenBMC activation software management implementation.
79 * @details A concrete implementation for
80 * xyz.openbmc_project.Software.Activation DBus API.
81 */
82class Activation : public ActivationInherit
83{
84 public:
85 /** @brief Constructs Activation Software Manager
86 *
87 * @param[in] bus - The Dbus bus object
88 * @param[in] path - The Dbus object path
Saqib Khan7254f0e2017-04-10 21:45:37 -050089 * @param[in] versionId - The software version id
90 * @param[in] extVersion - The extended version
Saqib Khana8ade7e2017-04-12 10:27:56 -050091 * @param[in] activationStatus - The status of Activation
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050092 */
Adriana Kobylakbc37a4c2017-04-10 09:45:36 -050093 Activation(sdbusplus::bus::bus& bus, const std::string& path,
Saqib Khan7254f0e2017-04-10 21:45:37 -050094 std::string& versionId,
Saqib Khana8ade7e2017-04-12 10:27:56 -050095 std::string& extVersion,
96 sdbusplus::xyz::openbmc_project::Software::
97 server::Activation::Activations activationStatus) :
Saqib Khan7254f0e2017-04-10 21:45:37 -050098 ActivationInherit(bus, path.c_str(), true),
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -050099 bus(bus),
100 path(path),
Michael Tritz9d25b602017-06-14 14:41:43 -0500101 versionId(versionId),
102 systemdSignals(
103 bus,
104 sdbusRule::type::signal() +
105 sdbusRule::member("JobRemoved") +
106 sdbusRule::path("/org/freedesktop/systemd1") +
107 sdbusRule::interface(
108 "org.freedesktop.systemd1.Manager"),
109 std::bind(std::mem_fn(&Activation::unitStateChange),
110 this, std::placeholders::_1))
Saqib Khan7254f0e2017-04-10 21:45:37 -0500111 {
Michael Tritz9d25b602017-06-14 14:41:43 -0500112 // Enable systemd signals
113 subscribeToSystemdSignals();
Saqib Khan7254f0e2017-04-10 21:45:37 -0500114 // Set Properties.
115 extendedVersion(extVersion);
Saqib Khana8ade7e2017-04-12 10:27:56 -0500116 activation(activationStatus);
Saqib Khan7254f0e2017-04-10 21:45:37 -0500117 // Emit deferred signal.
118 emit_object_added();
119 }
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -0500120
121 /** @brief Overloaded Activation property setter function
122 *
123 * @param[in] value - One of Activation::Activations
124 *
125 * @return Success or exception thrown
126 */
127 Activations activation(Activations value) override;
128
129 /** @brief Overloaded requestedActivation property setter function
130 *
131 * @param[in] value - One of Activation::RequestedActivations
132 *
133 * @return Success or exception thrown
134 */
135 RequestedActivations requestedActivation(RequestedActivations value)
136 override;
137
Michael Tritz9d25b602017-06-14 14:41:43 -0500138 /** @brief Check if systemd state change is relevant to this object
139 *
140 * Instance specific interface to handle the detected systemd state
141 * change
142 *
143 * @param[in] msg - Data associated with subscribed signal
144 *
145 */
146 void unitStateChange(sdbusplus::message::message& msg);
147
148 /**
149 * @brief subscribe to the systemd signals
150 *
151 * This object needs to capture when it's systemd targets complete
152 * so it can keep it's state updated
153 *
154 **/
155 void subscribeToSystemdSignals();
156
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -0500157 /** @brief Persistent sdbusplus DBus bus connection */
158 sdbusplus::bus::bus& bus;
159
160 /** @brief Persistent DBus object path */
161 std::string path;
162
Adriana Kobylakbc37a4c2017-04-10 09:45:36 -0500163 /** @brief Version id */
164 std::string versionId;
Adriana Kobylak2d8fa222017-03-15 12:34:32 -0500165
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -0500166 /** @brief Persistent ActivationBlocksTransition dbus object */
167 std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
Saqib Khan942df8a2017-06-01 14:09:27 -0500168
169 /** @brief Persistent RedundancyPriority dbus object */
170 std::unique_ptr<RedundancyPriority> redundancyPriority;
Michael Tritz9d25b602017-06-14 14:41:43 -0500171
172 /** @brief Used to subscribe to dbus systemd signals **/
173 sdbusplus::bus::match_t systemdSignals;
174
175 /** @brief Tracks whether the squashfs image has been loaded as part of
176 * the activation process. **/
177 bool squashfsLoaded = false;
178
179 /** @brief Tracks whether the read-write volumes have been created as
180 * part of the activation process. **/
181 bool rwVolumesCreated = false;
Adriana Kobylakea9626f2017-04-05 15:37:40 -0500182};
183
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -0500184} // namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -0500185} // namespace software
186} // namespace openpower