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 | |
| 145 | /** @brief Overloaded requestedActivation property setter function |
| 146 | * |
| 147 | * @param[in] value - One of Activation::RequestedActivations |
| 148 | * |
| 149 | * @return Success or exception thrown |
| 150 | */ |
| 151 | RequestedActivations requestedActivation(RequestedActivations value) |
| 152 | override; |
| 153 | |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame^] | 154 | /** @brief Check if systemd state change is relevant to this object |
| 155 | * |
| 156 | * Instance specific interface to handle the detected systemd state |
| 157 | * change |
| 158 | * |
| 159 | * @param[in] msg - Data associated with subscribed signal |
| 160 | * |
| 161 | */ |
| 162 | void unitStateChange(sdbusplus::message::message& msg); |
| 163 | |
| 164 | /** |
| 165 | * @brief subscribe to the systemd signals |
| 166 | * |
| 167 | * This object needs to capture when it's systemd targets complete |
| 168 | * so it can keep it's state updated |
| 169 | * |
| 170 | */ |
| 171 | void subscribeToSystemdSignals(); |
| 172 | |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 173 | /** @brief Persistent sdbusplus DBus bus connection */ |
| 174 | sdbusplus::bus::bus& bus; |
| 175 | |
| 176 | /** @brief Persistent DBus object path */ |
| 177 | std::string path; |
| 178 | |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 179 | /** @brief Parent Object. */ |
| 180 | ItemUpdater& parent; |
| 181 | |
Gunnar Mills | 2ce7da2 | 2017-05-04 15:37:56 -0500 | [diff] [blame] | 182 | /** @brief Version id */ |
| 183 | std::string versionId; |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 184 | |
| 185 | /** @brief Persistent ActivationBlocksTransition dbus object */ |
| 186 | std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition; |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 187 | |
| 188 | /** @brief Persistent RedundancyPriority dbus object */ |
| 189 | std::unique_ptr<RedundancyPriority> redundancyPriority; |
Michael Tritz | bed88af | 2017-07-19 16:00:06 -0500 | [diff] [blame^] | 190 | |
| 191 | /** @brief Used to subscribe to dbus systemd signals **/ |
| 192 | sdbusplus::bus::match_t systemdSignals; |
| 193 | |
| 194 | /** @brief Tracks whether the read-write volume has been created as |
| 195 | * part of the activation process. **/ |
| 196 | bool rwVolumeCreated = false; |
| 197 | |
| 198 | /** @brief Tracks whether the read-only volume has been created as |
| 199 | * part of the activation process. **/ |
| 200 | bool roVolumeCreated = false; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 201 | }; |
| 202 | |
| 203 | } // namespace updater |
| 204 | } // namespace software |
| 205 | } // namespace phosphor |