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