Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 1 | #include "activation.hpp" |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 2 | #include "item_updater.hpp" |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 3 | |
| 4 | namespace phosphor |
| 5 | { |
| 6 | namespace software |
| 7 | { |
| 8 | namespace updater |
| 9 | { |
| 10 | |
| 11 | namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; |
| 12 | |
| 13 | auto Activation::activation(Activations value) -> |
| 14 | Activations |
| 15 | { |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 16 | |
| 17 | if (value != softwareServer::Activation::Activations::Active) |
| 18 | { |
| 19 | redundancyPriority.reset(nullptr); |
| 20 | } |
| 21 | |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 22 | if (value == softwareServer::Activation::Activations::Activating) |
| 23 | { |
| 24 | if (!activationBlocksTransition) |
| 25 | { |
| 26 | activationBlocksTransition = |
| 27 | std::make_unique<ActivationBlocksTransition>( |
| 28 | bus, |
| 29 | path); |
| 30 | } |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 31 | |
| 32 | //TODO openbmc/openbmc#1756 - Add Logic for Code Update |
| 33 | if (!redundancyPriority) |
| 34 | { |
| 35 | redundancyPriority = |
| 36 | std::make_unique<RedundancyPriority>( |
| 37 | bus, |
| 38 | path, |
| 39 | *this, |
| 40 | 0); |
| 41 | } |
| 42 | |
| 43 | activationBlocksTransition.reset(nullptr); |
| 44 | return softwareServer::Activation::activation( |
| 45 | softwareServer::Activation::Activations::Active); |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 46 | } |
| 47 | else |
| 48 | { |
| 49 | activationBlocksTransition.reset(nullptr); |
| 50 | } |
| 51 | return softwareServer::Activation::activation(value); |
| 52 | } |
| 53 | |
| 54 | auto Activation::requestedActivation(RequestedActivations value) -> |
| 55 | RequestedActivations |
| 56 | { |
| 57 | if ((value == softwareServer::Activation::RequestedActivations::Active) && |
| 58 | (softwareServer::Activation::requestedActivation() != |
| 59 | softwareServer::Activation::RequestedActivations::Active)) |
| 60 | { |
| 61 | if ((softwareServer::Activation::activation() == |
| 62 | softwareServer::Activation::Activations::Ready) || |
| 63 | (softwareServer::Activation::activation() == |
| 64 | softwareServer::Activation::Activations::Failed)) |
| 65 | { |
| 66 | Activation::activation( |
| 67 | softwareServer::Activation::Activations::Activating); |
| 68 | |
| 69 | } |
| 70 | } |
| 71 | return softwareServer::Activation::requestedActivation(value); |
| 72 | } |
| 73 | |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 74 | uint8_t RedundancyPriority::priority(uint8_t value) |
| 75 | { |
| 76 | parent.parent.freePriority(value); |
| 77 | return softwareServer::RedundancyPriority::priority(value); |
| 78 | } |
| 79 | |
Saqib Khan | b077470 | 2017-05-23 16:02:41 -0500 | [diff] [blame] | 80 | } // namespace updater |
| 81 | } // namespace software |
| 82 | } // namespace phosphor |