blob: 8986a071dd4ddaaf7c0f8dde66a6fb1dc83b64c2 [file] [log] [blame]
Adriana Kobylak9f89e2e2018-05-30 13:16:20 -05001#include "activation.hpp"
2#include "config.h"
3
4namespace phosphor
5{
6namespace software
7{
8namespace updater
9{
10
Adriana Kobylak3ce563a2018-06-06 16:41:15 -050011namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
12
Adriana Kobylak9f89e2e2018-05-30 13:16:20 -050013void Activation::flashWrite()
14{
15 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
16 SYSTEMD_INTERFACE, "StartUnit");
17 method.append("obmc-flash-bmc-ubirw.service", "replace");
18 bus.call_noreply(method);
19
20 auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service";
21 method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
22 SYSTEMD_INTERFACE, "StartUnit");
23 method.append(roServiceFile, "replace");
24 bus.call_noreply(method);
25
26 return;
27}
28
Adriana Kobylak3ce563a2018-06-06 16:41:15 -050029void Activation::onStateChanges(sdbusplus::message::message& msg)
30{
31 uint32_t newStateID{};
32 sdbusplus::message::object_path newStateObjPath;
33 std::string newStateUnit{};
34 std::string newStateResult{};
35
36 // Read the msg and populate each variable
37 msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
38
39 auto rwServiceFile = "obmc-flash-bmc-ubirw.service";
40 auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service";
41 auto ubootVarsServiceFile =
42 "obmc-flash-bmc-updateubootvars@" + versionId + ".service";
43
44 if (newStateUnit == rwServiceFile && newStateResult == "done")
45 {
46 rwVolumeCreated = true;
47 activationProgress->progress(activationProgress->progress() + 20);
48 }
49
50 if (newStateUnit == roServiceFile && newStateResult == "done")
51 {
52 roVolumeCreated = true;
53 activationProgress->progress(activationProgress->progress() + 50);
54 }
55
56 if (newStateUnit == ubootVarsServiceFile && newStateResult == "done")
57 {
58 ubootEnvVarsUpdated = true;
59 }
60
61 if (newStateUnit == rwServiceFile || newStateUnit == roServiceFile ||
62 newStateUnit == ubootVarsServiceFile)
63 {
64 if (newStateResult == "failed" || newStateResult == "dependency")
65 {
66 Activation::activation(
67 softwareServer::Activation::Activations::Failed);
68 }
69 else if ((rwVolumeCreated && roVolumeCreated) || // Volumes were created
70 (ubootEnvVarsUpdated)) // Environment variables were updated
71 {
72 Activation::activation(
73 softwareServer::Activation::Activations::Activating);
74 }
75 }
76
77 return;
78}
79
Adriana Kobylak9f89e2e2018-05-30 13:16:20 -050080} // namespace updater
81} // namespace software
82} // namepsace phosphor