Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 1 | #include "activation.hpp" |
Adriana Kobylak | 692b555 | 2017-04-17 14:02:58 -0500 | [diff] [blame^] | 2 | #include "config.h" |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 3 | |
| 4 | namespace openpower |
| 5 | { |
| 6 | namespace software |
| 7 | { |
| 8 | namespace updater |
| 9 | { |
| 10 | |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 11 | namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; |
| 12 | |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 13 | auto Activation::activation(Activations value) -> |
| 14 | Activations |
| 15 | { |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 16 | if (value == softwareServer::Activation::Activations::Activating) |
| 17 | { |
| 18 | if (!activationBlocksTransition) |
| 19 | { |
| 20 | activationBlocksTransition = |
| 21 | std::make_unique<ActivationBlocksTransition>( |
| 22 | bus, |
| 23 | path); |
| 24 | } |
| 25 | } |
| 26 | else |
| 27 | { |
| 28 | activationBlocksTransition.reset(nullptr); |
| 29 | } |
| 30 | return softwareServer::Activation::activation(value); |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | auto Activation::requestedActivation(RequestedActivations value) -> |
| 34 | RequestedActivations |
| 35 | { |
Adriana Kobylak | 692b555 | 2017-04-17 14:02:58 -0500 | [diff] [blame^] | 36 | if ((value == softwareServer::Activation::RequestedActivations::Active) && |
| 37 | (softwareServer::Activation::requestedActivation() != |
| 38 | softwareServer::Activation::RequestedActivations::Active)) |
| 39 | { |
| 40 | constexpr auto ubimountService = "obmc-flash-bios-ubimount@"; |
| 41 | auto ubimountServiceFile = std::string(ubimountService) + |
| 42 | versionId + |
| 43 | ".service"; |
| 44 | auto method = bus.new_method_call( |
| 45 | SYSTEMD_BUSNAME, |
| 46 | SYSTEMD_PATH, |
| 47 | SYSTEMD_INTERFACE, |
| 48 | "StartUnit"); |
| 49 | method.append(ubimountServiceFile, |
| 50 | "replace"); |
| 51 | bus.call_noreply(method); |
| 52 | } |
Adriana Kobylak | 99c8c0e | 2017-04-17 13:39:11 -0500 | [diff] [blame] | 53 | return softwareServer::Activation::requestedActivation(value); |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } // namespace updater |
| 57 | } // namespace software |
| 58 | } // namespace openpower |
| 59 | |