Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 3 | #include "activation.hpp" |
| 4 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 5 | namespace phosphor |
| 6 | { |
| 7 | namespace software |
| 8 | { |
| 9 | namespace updater |
| 10 | { |
| 11 | |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 12 | namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; |
| 13 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 14 | void 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 Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 30 | void 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 | } |
Adriana Kobylak | b824b2f | 2020-05-14 14:57:53 -0500 | [diff] [blame] | 70 | else if (rwVolumeCreated && roVolumeCreated) // Volumes were created |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 71 | { |
Adriana Kobylak | b824b2f | 2020-05-14 14:57:53 -0500 | [diff] [blame] | 72 | if (!ubootEnvVarsUpdated) |
| 73 | { |
| 74 | activationProgress->progress(90); |
| 75 | |
| 76 | // Set the priority which triggers the service that updates the |
| 77 | // environment variables. |
| 78 | if (!Activation::redundancyPriority) |
| 79 | { |
| 80 | Activation::redundancyPriority = |
| 81 | std::make_unique<RedundancyPriority>(bus, path, *this, |
| 82 | 0); |
| 83 | } |
| 84 | } |
| 85 | else // Environment variables were updated |
| 86 | { |
| 87 | Activation::onFlashWriteSuccess(); |
| 88 | } |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
| 92 | return; |
| 93 | } |
| 94 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 95 | } // namespace updater |
| 96 | } // namespace software |
Gunnar Mills | fa34e02 | 2018-09-04 10:05:45 -0500 | [diff] [blame] | 97 | } // namespace phosphor |