Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 1 | #include "activation.hpp" |
| 2 | #include "config.h" |
| 3 | |
| 4 | namespace phosphor |
| 5 | { |
| 6 | namespace software |
| 7 | { |
| 8 | namespace updater |
| 9 | { |
| 10 | |
Adriana Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 11 | namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; |
| 12 | |
Adriana Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 13 | void 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 Kobylak | 3ce563a | 2018-06-06 16:41:15 -0500 | [diff] [blame] | 29 | void 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 Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 80 | } // namespace updater |
| 81 | } // namespace software |
Gunnar Mills | fa34e02 | 2018-09-04 10:05:45 -0500 | [diff] [blame] | 82 | } // namespace phosphor |