Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 3 | #include <sdbusplus/server.hpp> |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Software/Activation/server.hpp> |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 5 | #include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp> |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp" |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace software |
| 11 | { |
| 12 | namespace updater |
| 13 | { |
| 14 | |
| 15 | using ActivationInherit = sdbusplus::server::object::object< |
| 16 | sdbusplus::xyz::openbmc_project::Software::server::Activation>; |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 17 | using ActivationBlocksTransitionInherit = sdbusplus::server::object::object< |
| 18 | sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>; |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 19 | using RedundancyPriorityInherit = sdbusplus::server::object::object< |
| 20 | sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>; |
| 21 | |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame] | 22 | namespace sdbusRule = sdbusplus::bus::match::rules; |
| 23 | |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 24 | class ItemUpdater; |
| 25 | class Activation; |
| 26 | class RedundancyPriority; |
| 27 | |
| 28 | /** @class RedundancyPriority |
| 29 | * @brief OpenBMC RedundancyPriority implementation |
| 30 | * @details A concrete implementation for |
| 31 | * xyz.openbmc_project.Software.RedundancyPriority DBus API. |
| 32 | */ |
| 33 | class RedundancyPriority : public RedundancyPriorityInherit |
| 34 | { |
| 35 | public: |
| 36 | /** @brief Constructs RedundancyPriority. |
| 37 | * |
| 38 | * @param[in] bus - The Dbus bus object |
| 39 | * @param[in] path - The Dbus object path |
| 40 | * @param[in] parent - Parent object. |
| 41 | * @param[in] value - The redundancyPriority value |
| 42 | */ |
| 43 | RedundancyPriority(sdbusplus::bus::bus& bus, |
| 44 | const std::string& path, |
| 45 | Activation& parent, |
| 46 | uint8_t value) : |
| 47 | RedundancyPriorityInherit(bus, |
| 48 | path.c_str(), true), |
| 49 | parent(parent) |
| 50 | { |
| 51 | // Set Property |
| 52 | priority(value); |
| 53 | // Emit deferred signal. |
| 54 | emit_object_added(); |
| 55 | } |
| 56 | |
| 57 | /** @brief Overloaded Priority property set function |
| 58 | * |
| 59 | * @param[in] value - uint8_t |
| 60 | * |
| 61 | * @return Success or exception thrown |
| 62 | */ |
| 63 | uint8_t priority(uint8_t value) override; |
| 64 | |
| 65 | /** @brief Priority property get function |
| 66 | * |
| 67 | * @returns uint8_t - The Priority value |
| 68 | */ |
| 69 | using RedundancyPriorityInherit::priority; |
| 70 | |
| 71 | /** @brief Parent Object. */ |
| 72 | Activation& parent; |
| 73 | }; |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 74 | |
| 75 | /** @class ActivationBlocksTransition |
| 76 | * @brief OpenBMC ActivationBlocksTransition implementation. |
| 77 | * @details A concrete implementation for |
| 78 | * xyz.openbmc_project.Software.ActivationBlocksTransition DBus API. |
| 79 | */ |
| 80 | class ActivationBlocksTransition : public ActivationBlocksTransitionInherit |
| 81 | { |
| 82 | public: |
| 83 | /** @brief Constructs ActivationBlocksTransition. |
| 84 | * |
| 85 | * @param[in] bus - The Dbus bus object |
| 86 | * @param[in] path - The Dbus object path |
| 87 | */ |
| 88 | ActivationBlocksTransition(sdbusplus::bus::bus& bus, |
| 89 | const std::string& path) : |
| 90 | ActivationBlocksTransitionInherit(bus, path.c_str()) {} |
| 91 | }; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 92 | |
| 93 | /** @class Activation |
| 94 | * @brief OpenBMC activation software management implementation. |
| 95 | * @details A concrete implementation for |
| 96 | * xyz.openbmc_project.Software.Activation DBus API. |
| 97 | */ |
| 98 | class Activation : public ActivationInherit |
| 99 | { |
| 100 | public: |
| 101 | /** @brief Constructs Activation Software Manager |
| 102 | * |
| 103 | * @param[in] bus - The Dbus bus object |
| 104 | * @param[in] path - The Dbus object path |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 105 | * @param[in] parent - Parent object. |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 106 | * @param[in] versionId - The software version id |
| 107 | * @param[in] activationStatus - The status of Activation |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 108 | */ |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 109 | Activation(sdbusplus::bus::bus& bus, const std::string& path, |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 110 | ItemUpdater& parent, |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 111 | std::string& versionId, |
| 112 | sdbusplus::xyz::openbmc_project::Software:: |
| 113 | server::Activation::Activations activationStatus) : |
| 114 | ActivationInherit(bus, path.c_str(), true), |
| 115 | bus(bus), |
| 116 | path(path), |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 117 | parent(parent), |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame] | 118 | versionId(versionId), |
| 119 | systemdSignals( |
| 120 | bus, |
| 121 | sdbusRule::type::signal() + |
| 122 | sdbusRule::member("JobRemoved") + |
| 123 | sdbusRule::path("/org/freedesktop/systemd1") + |
| 124 | sdbusRule::interface( |
| 125 | "org.freedesktop.systemd1.Manager"), |
| 126 | std::bind(std::mem_fn(&Activation::unitStateChange), |
| 127 | this, std::placeholders::_1)) |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 128 | { |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame] | 129 | // Enable systemd signals |
| 130 | subscribeToSystemdSignals(); |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 131 | // Set Properties. |
| 132 | activation(activationStatus); |
| 133 | // Emit deferred signal. |
| 134 | emit_object_added(); |
| 135 | } |
| 136 | |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 137 | /** @brief Overloaded Activation property setter function |
| 138 | * |
| 139 | * @param[in] value - One of Activation::Activations |
| 140 | * |
| 141 | * @return Success or exception thrown |
| 142 | */ |
| 143 | Activations activation(Activations value) override; |
| 144 | |
Leonel Gonzalez | e423368 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 145 | /** @brief Activation */ |
| 146 | using ActivationInherit::activation; |
| 147 | |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 148 | /** @brief Overloaded requestedActivation property setter function |
| 149 | * |
| 150 | * @param[in] value - One of Activation::RequestedActivations |
| 151 | * |
| 152 | * @return Success or exception thrown |
| 153 | */ |
| 154 | RequestedActivations requestedActivation(RequestedActivations value) |
| 155 | override; |
| 156 | |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame] | 157 | /** @brief Check if systemd state change is relevant to this object |
| 158 | * |
| 159 | * Instance specific interface to handle the detected systemd state |
| 160 | * change |
| 161 | * |
| 162 | * @param[in] msg - Data associated with subscribed signal |
| 163 | * |
| 164 | */ |
| 165 | void unitStateChange(sdbusplus::message::message& msg); |
| 166 | |
| 167 | /** |
| 168 | * @brief subscribe to the systemd signals |
| 169 | * |
| 170 | * This object needs to capture when it's systemd targets complete |
| 171 | * so it can keep it's state updated |
| 172 | * |
| 173 | */ |
| 174 | void subscribeToSystemdSignals(); |
| 175 | |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 176 | /** @brief Persistent sdbusplus DBus bus connection */ |
| 177 | sdbusplus::bus::bus& bus; |
| 178 | |
| 179 | /** @brief Persistent DBus object path */ |
| 180 | std::string path; |
| 181 | |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 182 | /** @brief Parent Object. */ |
| 183 | ItemUpdater& parent; |
| 184 | |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 185 | /** @brief Version id */ |
| 186 | std::string versionId; |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 187 | |
| 188 | /** @brief Persistent ActivationBlocksTransition dbus object */ |
| 189 | std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition; |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 190 | |
| 191 | /** @brief Persistent RedundancyPriority dbus object */ |
| 192 | std::unique_ptr<RedundancyPriority> redundancyPriority; |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame] | 193 | |
| 194 | /** @brief Used to subscribe to dbus systemd signals **/ |
| 195 | sdbusplus::bus::match_t systemdSignals; |
| 196 | |
| 197 | /** @brief Tracks whether the read-write volume has been created as |
| 198 | * part of the activation process. **/ |
| 199 | bool rwVolumeCreated = false; |
| 200 | |
| 201 | /** @brief Tracks whether the read-only volume has been created as |
| 202 | * part of the activation process. **/ |
| 203 | bool roVolumeCreated = false; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | } // namespace updater |
| 207 | } // namespace software |
| 208 | } // namespace phosphor |