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" |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 4 | #include "item_updater.hpp" |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 5 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 6 | namespace phosphor |
| 7 | { |
| 8 | namespace software |
| 9 | { |
| 10 | namespace updater |
| 11 | { |
| 12 | |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 13 | namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; |
| 14 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 15 | void Activation::flashWrite() |
| 16 | { |
| 17 | auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, |
| 18 | SYSTEMD_INTERFACE, "StartUnit"); |
| 19 | method.append("obmc-flash-bmc-ubirw.service", "replace"); |
| 20 | bus.call_noreply(method); |
| 21 | |
| 22 | auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service"; |
| 23 | method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, |
| 24 | SYSTEMD_INTERFACE, "StartUnit"); |
| 25 | method.append(roServiceFile, "replace"); |
| 26 | bus.call_noreply(method); |
| 27 | |
| 28 | return; |
| 29 | } |
| 30 | |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 31 | void Activation::onStateChanges(sdbusplus::message::message& msg) |
| 32 | { |
| 33 | uint32_t newStateID{}; |
| 34 | sdbusplus::message::object_path newStateObjPath; |
| 35 | std::string newStateUnit{}; |
| 36 | std::string newStateResult{}; |
| 37 | |
| 38 | // Read the msg and populate each variable |
| 39 | msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult); |
| 40 | |
| 41 | auto rwServiceFile = "obmc-flash-bmc-ubirw.service"; |
| 42 | auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service"; |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 43 | auto flashId = parent.versions.find(versionId)->second->path(); |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 44 | auto ubootVarsServiceFile = |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 45 | "obmc-flash-bmc-updateubootvars@" + flashId + ".service"; |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 46 | |
| 47 | if (newStateUnit == rwServiceFile && newStateResult == "done") |
| 48 | { |
| 49 | rwVolumeCreated = true; |
| 50 | activationProgress->progress(activationProgress->progress() + 20); |
| 51 | } |
| 52 | |
| 53 | if (newStateUnit == roServiceFile && newStateResult == "done") |
| 54 | { |
| 55 | roVolumeCreated = true; |
| 56 | activationProgress->progress(activationProgress->progress() + 50); |
| 57 | } |
| 58 | |
| 59 | if (newStateUnit == ubootVarsServiceFile && newStateResult == "done") |
| 60 | { |
| 61 | ubootEnvVarsUpdated = true; |
| 62 | } |
| 63 | |
| 64 | if (newStateUnit == rwServiceFile || newStateUnit == roServiceFile || |
| 65 | newStateUnit == ubootVarsServiceFile) |
| 66 | { |
| 67 | if (newStateResult == "failed" || newStateResult == "dependency") |
| 68 | { |
| 69 | Activation::activation( |
| 70 | softwareServer::Activation::Activations::Failed); |
| 71 | } |
Adriana Kobylak | b824b2f | 2020-05-14 14:57:53 -0500 | [diff] [blame] | 72 | else if (rwVolumeCreated && roVolumeCreated) // Volumes were created |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 73 | { |
Adriana Kobylak | b824b2f | 2020-05-14 14:57:53 -0500 | [diff] [blame] | 74 | if (!ubootEnvVarsUpdated) |
| 75 | { |
| 76 | activationProgress->progress(90); |
| 77 | |
| 78 | // Set the priority which triggers the service that updates the |
| 79 | // environment variables. |
| 80 | if (!Activation::redundancyPriority) |
| 81 | { |
| 82 | Activation::redundancyPriority = |
| 83 | std::make_unique<RedundancyPriority>(bus, path, *this, |
| 84 | 0); |
| 85 | } |
| 86 | } |
| 87 | else // Environment variables were updated |
| 88 | { |
| 89 | Activation::onFlashWriteSuccess(); |
| 90 | } |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
| 94 | return; |
| 95 | } |
| 96 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 97 | } // namespace updater |
| 98 | } // namespace software |
Gunnar Mills | fa34e02 | 2018-09-04 10:05:45 -0500 | [diff] [blame] | 99 | } // namespace phosphor |