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" |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 8 | |
| 9 | namespace openpower |
| 10 | { |
| 11 | namespace software |
| 12 | { |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 13 | namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 14 | { |
| 15 | |
| 16 | using ActivationInherit = sdbusplus::server::object::object< |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 17 | sdbusplus::xyz::openbmc_project::Software::server::ExtendedVersion, |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 18 | sdbusplus::xyz::openbmc_project::Software::server::Activation>; |
Adriana Kobylak | ea9626f | 2017-04-05 15:37:40 -0500 | [diff] [blame] | 19 | using ActivationBlocksTransitionInherit = sdbusplus::server::object::object< |
| 20 | sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>; |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 21 | using RedundancyPriorityInherit = sdbusplus::server::object::object< |
| 22 | sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>; |
| 23 | |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame^] | 24 | namespace sdbusRule = sdbusplus::bus::match::rules; |
| 25 | |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 26 | /** @class RedundancyPriority |
| 27 | * @brief OpenBMC RedundancyPriority implementation |
| 28 | * @details A concrete implementation for |
| 29 | * xyz.openbmc_project.Software.RedundancyPriority DBus API. |
| 30 | */ |
| 31 | class 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 Khan | 2021b4c | 2017-06-07 14:37:36 -0500 | [diff] [blame] | 49 | |
| 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 Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 57 | }; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 58 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 59 | /** @class ActivationBlocksTransition |
| 60 | * @brief OpenBMC ActivationBlocksTransition implementation. |
| 61 | * @details A concrete implementation for |
| 62 | * xyz.openbmc_project.Software.ActivationBlocksTransition DBus API. |
| 63 | */ |
| 64 | class 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 Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 77 | /** @class Activation |
| 78 | * @brief OpenBMC activation software management implementation. |
| 79 | * @details A concrete implementation for |
| 80 | * xyz.openbmc_project.Software.Activation DBus API. |
| 81 | */ |
| 82 | class 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 Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 89 | * @param[in] versionId - The software version id |
| 90 | * @param[in] extVersion - The extended version |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 91 | * @param[in] activationStatus - The status of Activation |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 92 | */ |
Adriana Kobylak | bc37a4c | 2017-04-10 09:45:36 -0500 | [diff] [blame] | 93 | Activation(sdbusplus::bus::bus& bus, const std::string& path, |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 94 | std::string& versionId, |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 95 | std::string& extVersion, |
| 96 | sdbusplus::xyz::openbmc_project::Software:: |
| 97 | server::Activation::Activations activationStatus) : |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 98 | ActivationInherit(bus, path.c_str(), true), |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 99 | bus(bus), |
| 100 | path(path), |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame^] | 101 | 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 Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 111 | { |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame^] | 112 | // Enable systemd signals |
| 113 | subscribeToSystemdSignals(); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 114 | // Set Properties. |
| 115 | extendedVersion(extVersion); |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 116 | activation(activationStatus); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 117 | // Emit deferred signal. |
| 118 | emit_object_added(); |
| 119 | } |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 120 | |
| 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 Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame^] | 138 | /** @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 Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 157 | /** @brief Persistent sdbusplus DBus bus connection */ |
| 158 | sdbusplus::bus::bus& bus; |
| 159 | |
| 160 | /** @brief Persistent DBus object path */ |
| 161 | std::string path; |
| 162 | |
Adriana Kobylak | bc37a4c | 2017-04-10 09:45:36 -0500 | [diff] [blame] | 163 | /** @brief Version id */ |
| 164 | std::string versionId; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 165 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 166 | /** @brief Persistent ActivationBlocksTransition dbus object */ |
| 167 | std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition; |
Saqib Khan | 942df8a | 2017-06-01 14:09:27 -0500 | [diff] [blame] | 168 | |
| 169 | /** @brief Persistent RedundancyPriority dbus object */ |
| 170 | std::unique_ptr<RedundancyPriority> redundancyPriority; |
Michael Tritz | 9d25b60 | 2017-06-14 14:41:43 -0500 | [diff] [blame^] | 171 | |
| 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 Kobylak | ea9626f | 2017-04-05 15:37:40 -0500 | [diff] [blame] | 182 | }; |
| 183 | |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 184 | } // namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 185 | } // namespace software |
| 186 | } // namespace openpower |