| 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 | } | 
|  | 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 Kobylak | 9f89e2e | 2018-05-30 13:16:20 -0500 | [diff] [blame] | 81 | } // namespace updater | 
|  | 82 | } // namespace software | 
| Gunnar Mills | fa34e02 | 2018-09-04 10:05:45 -0500 | [diff] [blame] | 83 | } // namespace phosphor |