Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 3 | #include <sdbusplus/server.hpp> |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Software/Activation/server.hpp> |
Adriana Kobylak | ea9626f | 2017-04-05 15:37:40 -0500 | [diff] [blame] | 5 | #include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp> |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp" |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 7 | #include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp" |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 8 | #include "xyz/openbmc_project/Software/ActivationProgress/server.hpp" |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 9 | |
| 10 | namespace openpower |
| 11 | { |
| 12 | namespace software |
| 13 | { |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 14 | namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 15 | { |
| 16 | |
| 17 | using ActivationInherit = sdbusplus::server::object::object< |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 18 | sdbusplus::xyz::openbmc_project::Software::server::ExtendedVersion, |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 19 | sdbusplus::xyz::openbmc_project::Software::server::Activation>; |
Adriana Kobylak | ea9626f | 2017-04-05 15:37:40 -0500 | [diff] [blame] | 20 | using ActivationBlocksTransitionInherit = sdbusplus::server::object::object< |
| 21 | sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>; |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 22 | using RedundancyPriorityInherit = sdbusplus::server::object::object< |
| 23 | sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>; |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 24 | using ActivationProgressInherit = sdbusplus::server::object::object< |
| 25 | sdbusplus::xyz::openbmc_project::Software::server::ActivationProgress>; |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 26 | |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame] | 27 | namespace sdbusRule = sdbusplus::bus::match::rules; |
| 28 | |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 29 | class ItemUpdater; |
| 30 | class Activation; |
| 31 | class RedundancyPriority; |
| 32 | |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 33 | /** @class RedundancyPriority |
| 34 | * @brief OpenBMC RedundancyPriority implementation |
| 35 | * @details A concrete implementation for |
| 36 | * xyz.openbmc_project.Software.RedundancyPriority DBus API. |
| 37 | */ |
| 38 | class RedundancyPriority : public RedundancyPriorityInherit |
| 39 | { |
| 40 | public: |
| 41 | /** @brief Constructs RedundancyPriority. |
| 42 | * |
| 43 | * @param[in] bus - The Dbus bus object |
| 44 | * @param[in] path - The Dbus object path |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 45 | * @param[in] parent - Parent object. |
| 46 | * @param[in] value - The redundancyPriority value |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 47 | */ |
| 48 | RedundancyPriority(sdbusplus::bus::bus& bus, |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 49 | const std::string& path, |
| 50 | Activation& parent, |
| 51 | uint8_t value) : |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 52 | RedundancyPriorityInherit(bus, |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 53 | path.c_str(), true), |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 54 | parent(parent), |
| 55 | bus(bus), |
| 56 | path(path) |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 57 | { |
| 58 | // Set Property |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 59 | priority(value); |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 60 | std::vector<std::string> interfaces({interface}); |
| 61 | bus.emit_interfaces_added(path.c_str(), interfaces); |
| 62 | } |
| 63 | |
| 64 | ~RedundancyPriority() |
| 65 | { |
| 66 | std::vector<std::string> interfaces({interface}); |
| 67 | bus.emit_interfaces_removed(path.c_str(), interfaces); |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 68 | } |
Saqib Khan | 2021b4c | 2017-06-07 14:37:36 -0500 | [diff] [blame] | 69 | |
| 70 | /** @brief Overloaded Priority property set function |
| 71 | * |
| 72 | * @param[in] value - uint8_t |
| 73 | * |
| 74 | * @return Success or exception thrown |
| 75 | */ |
| 76 | uint8_t priority(uint8_t value) override; |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 77 | |
| 78 | /** @brief Priority property get function |
| 79 | * |
| 80 | * @returns uint8_t - The Priority value |
| 81 | */ |
| 82 | using RedundancyPriorityInherit::priority; |
| 83 | |
| 84 | /** @brief Parent Object. */ |
| 85 | Activation& parent; |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 86 | |
| 87 | private: |
| 88 | // TODO Remove once openbmc/openbmc#1975 is resolved |
| 89 | static constexpr auto interface = |
| 90 | "xyz.openbmc_project.Software.RedundancyPriority"; |
| 91 | sdbusplus::bus::bus& bus; |
| 92 | std::string path; |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 93 | }; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 94 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 95 | /** @class ActivationBlocksTransition |
| 96 | * @brief OpenBMC ActivationBlocksTransition implementation. |
| 97 | * @details A concrete implementation for |
| 98 | * xyz.openbmc_project.Software.ActivationBlocksTransition DBus API. |
| 99 | */ |
| 100 | class ActivationBlocksTransition : public ActivationBlocksTransitionInherit |
| 101 | { |
| 102 | public: |
| 103 | /** @brief Constructs ActivationBlocksTransition. |
| 104 | * |
| 105 | * @param[in] bus - The Dbus bus object |
| 106 | * @param[in] path - The Dbus object path |
| 107 | */ |
| 108 | ActivationBlocksTransition(sdbusplus::bus::bus& bus, |
| 109 | const std::string& path) : |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 110 | ActivationBlocksTransitionInherit(bus, path.c_str(), true), |
| 111 | bus(bus), |
| 112 | path(path) |
| 113 | { |
| 114 | std::vector<std::string> interfaces({interface}); |
| 115 | bus.emit_interfaces_added(path.c_str(), interfaces); |
| 116 | } |
| 117 | |
| 118 | ~ActivationBlocksTransition() |
| 119 | { |
| 120 | std::vector<std::string> interfaces({interface}); |
| 121 | bus.emit_interfaces_removed(path.c_str(), interfaces); |
| 122 | } |
| 123 | |
| 124 | private: |
| 125 | // TODO Remove once openbmc/openbmc#1975 is resolved |
| 126 | static constexpr auto interface = |
| 127 | "xyz.openbmc_project.Software.ActivationBlocksTransition"; |
| 128 | sdbusplus::bus::bus& bus; |
| 129 | std::string path; |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 130 | }; |
| 131 | |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 132 | class ActivationProgress : public ActivationProgressInherit |
| 133 | { |
| 134 | public: |
| 135 | /** @brief Constructs ActivationProgress. |
| 136 | * |
| 137 | * @param[in] bus - The Dbus bus object |
| 138 | * @param[in] path - The Dbus object path |
| 139 | */ |
| 140 | ActivationProgress(sdbusplus::bus::bus& bus, |
| 141 | const std::string& path) : |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 142 | ActivationProgressInherit(bus, path.c_str(), true), |
| 143 | bus(bus), |
| 144 | path(path) |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 145 | { |
| 146 | progress(0); |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 147 | std::vector<std::string> interfaces({interface}); |
| 148 | bus.emit_interfaces_added(path.c_str(), interfaces); |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 149 | } |
Adriana Kobylak | a8eda56 | 2017-07-17 15:24:29 -0500 | [diff] [blame] | 150 | |
| 151 | ~ActivationProgress() |
| 152 | { |
| 153 | std::vector<std::string> interfaces({interface}); |
| 154 | bus.emit_interfaces_removed(path.c_str(), interfaces); |
| 155 | } |
| 156 | |
| 157 | private: |
| 158 | // TODO Remove once openbmc/openbmc#1975 is resolved |
| 159 | static constexpr auto interface = |
| 160 | "xyz.openbmc_project.Software.ActivationProgress"; |
| 161 | sdbusplus::bus::bus& bus; |
| 162 | std::string path; |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 163 | }; |
| 164 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 165 | /** @class Activation |
| 166 | * @brief OpenBMC activation software management implementation. |
| 167 | * @details A concrete implementation for |
| 168 | * xyz.openbmc_project.Software.Activation DBus API. |
| 169 | */ |
| 170 | class Activation : public ActivationInherit |
| 171 | { |
| 172 | public: |
| 173 | /** @brief Constructs Activation Software Manager |
| 174 | * |
| 175 | * @param[in] bus - The Dbus bus object |
| 176 | * @param[in] path - The Dbus object path |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 177 | * @param[in] parent - Parent object. |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 178 | * @param[in] versionId - The software version id |
| 179 | * @param[in] extVersion - The extended version |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 180 | * @param[in] activationStatus - The status of Activation |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 181 | */ |
Adriana Kobylak | bc37a4c | 2017-04-10 09:45:36 -0500 | [diff] [blame] | 182 | Activation(sdbusplus::bus::bus& bus, const std::string& path, |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 183 | ItemUpdater& parent, |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 184 | std::string& versionId, |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 185 | std::string& extVersion, |
| 186 | sdbusplus::xyz::openbmc_project::Software:: |
| 187 | server::Activation::Activations activationStatus) : |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 188 | ActivationInherit(bus, path.c_str(), true), |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 189 | bus(bus), |
| 190 | path(path), |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 191 | parent(parent), |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame] | 192 | versionId(versionId), |
| 193 | systemdSignals( |
| 194 | bus, |
| 195 | sdbusRule::type::signal() + |
| 196 | sdbusRule::member("JobRemoved") + |
| 197 | sdbusRule::path("/org/freedesktop/systemd1") + |
| 198 | sdbusRule::interface( |
| 199 | "org.freedesktop.systemd1.Manager"), |
| 200 | std::bind(std::mem_fn(&Activation::unitStateChange), |
| 201 | this, std::placeholders::_1)) |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 202 | { |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame] | 203 | // Enable systemd signals |
| 204 | subscribeToSystemdSignals(); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 205 | // Set Properties. |
| 206 | extendedVersion(extVersion); |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 207 | activation(activationStatus); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 208 | // Emit deferred signal. |
| 209 | emit_object_added(); |
| 210 | } |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 211 | |
| 212 | /** @brief Overloaded Activation property setter function |
| 213 | * |
| 214 | * @param[in] value - One of Activation::Activations |
| 215 | * |
| 216 | * @return Success or exception thrown |
| 217 | */ |
| 218 | Activations activation(Activations value) override; |
| 219 | |
| 220 | /** @brief Overloaded requestedActivation property setter function |
| 221 | * |
| 222 | * @param[in] value - One of Activation::RequestedActivations |
| 223 | * |
| 224 | * @return Success or exception thrown |
| 225 | */ |
| 226 | RequestedActivations requestedActivation(RequestedActivations value) |
| 227 | override; |
| 228 | |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame] | 229 | /** @brief Check if systemd state change is relevant to this object |
| 230 | * |
| 231 | * Instance specific interface to handle the detected systemd state |
| 232 | * change |
| 233 | * |
| 234 | * @param[in] msg - Data associated with subscribed signal |
| 235 | * |
| 236 | */ |
| 237 | void unitStateChange(sdbusplus::message::message& msg); |
| 238 | |
| 239 | /** |
| 240 | * @brief subscribe to the systemd signals |
| 241 | * |
| 242 | * This object needs to capture when it's systemd targets complete |
| 243 | * so it can keep it's state updated |
| 244 | * |
| 245 | **/ |
| 246 | void subscribeToSystemdSignals(); |
| 247 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 248 | /** @brief Persistent sdbusplus DBus bus connection */ |
| 249 | sdbusplus::bus::bus& bus; |
| 250 | |
| 251 | /** @brief Persistent DBus object path */ |
| 252 | std::string path; |
| 253 | |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame] | 254 | /** @brief Parent Object. */ |
| 255 | ItemUpdater& parent; |
| 256 | |
Adriana Kobylak | bc37a4c | 2017-04-10 09:45:36 -0500 | [diff] [blame] | 257 | /** @brief Version id */ |
| 258 | std::string versionId; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 259 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 260 | /** @brief Persistent ActivationBlocksTransition dbus object */ |
| 261 | std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition; |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 262 | |
Michael Tritz | 1793b64 | 2017-06-28 18:35:58 -0500 | [diff] [blame] | 263 | /** @brief Persistent ActivationProgress dbus object */ |
| 264 | std::unique_ptr<ActivationProgress> activationProgress; |
| 265 | |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 266 | /** @brief Persistent RedundancyPriority dbus object */ |
| 267 | std::unique_ptr<RedundancyPriority> redundancyPriority; |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame] | 268 | |
| 269 | /** @brief Used to subscribe to dbus systemd signals **/ |
| 270 | sdbusplus::bus::match_t systemdSignals; |
| 271 | |
| 272 | /** @brief Tracks whether the squashfs image has been loaded as part of |
| 273 | * the activation process. **/ |
| 274 | bool squashfsLoaded = false; |
| 275 | |
| 276 | /** @brief Tracks whether the read-write volumes have been created as |
| 277 | * part of the activation process. **/ |
| 278 | bool rwVolumesCreated = false; |
Adriana Kobylak | ea9626f | 2017-04-05 15:37:40 -0500 | [diff] [blame] | 279 | }; |
| 280 | |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 281 | } // namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 282 | } // namespace software |
| 283 | } // namespace openpower |