blob: 0a455c32cbeaa97588d4b0681b5aa031540df6bc [file] [log] [blame]
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -05001#include "activation.hpp"
Adriana Kobylak692b5552017-04-17 14:02:58 -05002#include "config.h"
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -05003
4namespace openpower
5{
6namespace software
7{
8namespace updater
9{
10
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -050011namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
12
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050013auto Activation::activation(Activations value) ->
14 Activations
15{
Adriana Kobylak99c8c0e2017-04-17 13:39:11 -050016 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 Kobylakbefe5ce2017-04-05 15:57:44 -050031}
32
33auto Activation::requestedActivation(RequestedActivations value) ->
34 RequestedActivations
35{
Adriana Kobylak692b5552017-04-17 14:02:58 -050036 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 Kobylak99c8c0e2017-04-17 13:39:11 -050053 return softwareServer::Activation::requestedActivation(value);
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050054}
55
56} // namespace updater
57} // namespace software
58} // namespace openpower
59