Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "item_updater.hpp" |
| 4 | |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 5 | #include "utils.hpp" |
| 6 | |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 7 | #include <filesystem> |
| 8 | #include <phosphor-logging/elog-errors.hpp> |
| 9 | #include <phosphor-logging/log.hpp> |
| 10 | #include <xyz/openbmc_project/Common/error.hpp> |
| 11 | |
Lei YU | fda15a3 | 2019-09-19 14:43:02 +0800 | [diff] [blame] | 12 | namespace |
| 13 | { |
Lei YU | 58c26e3 | 2019-09-27 17:52:06 +0800 | [diff] [blame] | 14 | constexpr auto MANIFEST_VERSION = "version"; |
| 15 | constexpr auto MANIFEST_EXTENDED_VERSION = "extended_version"; |
| 16 | } // namespace |
Lei YU | fda15a3 | 2019-09-19 14:43:02 +0800 | [diff] [blame] | 17 | |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 18 | namespace phosphor |
| 19 | { |
| 20 | namespace software |
| 21 | { |
| 22 | namespace updater |
| 23 | { |
| 24 | namespace server = sdbusplus::xyz::openbmc_project::Software::server; |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 25 | |
| 26 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; |
| 27 | using namespace phosphor::logging; |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 28 | using SVersion = server::Version; |
| 29 | using VersionPurpose = SVersion::VersionPurpose; |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 30 | |
| 31 | void ItemUpdater::createActivation(sdbusplus::message::message& m) |
| 32 | { |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 33 | namespace msg = sdbusplus::message; |
| 34 | namespace variant_ns = msg::variant_ns; |
| 35 | |
| 36 | sdbusplus::message::object_path objPath; |
| 37 | std::map<std::string, std::map<std::string, msg::variant<std::string>>> |
| 38 | interfaces; |
| 39 | m.read(objPath, interfaces); |
| 40 | |
| 41 | std::string path(std::move(objPath)); |
| 42 | std::string filePath; |
| 43 | auto purpose = VersionPurpose::Unknown; |
| 44 | std::string version; |
| 45 | |
| 46 | for (const auto& [interfaceName, propertyMap] : interfaces) |
| 47 | { |
| 48 | if (interfaceName == VERSION_IFACE) |
| 49 | { |
| 50 | for (const auto& [propertyName, propertyValue] : propertyMap) |
| 51 | { |
| 52 | if (propertyName == "Purpose") |
| 53 | { |
| 54 | // Only process the PSU images |
| 55 | auto value = SVersion::convertVersionPurposeFromString( |
| 56 | variant_ns::get<std::string>(propertyValue)); |
| 57 | |
| 58 | if (value == VersionPurpose::PSU) |
| 59 | { |
| 60 | purpose = value; |
| 61 | } |
| 62 | } |
Lei YU | f77189f | 2019-08-07 14:26:30 +0800 | [diff] [blame] | 63 | else if (propertyName == VERSION) |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 64 | { |
| 65 | version = variant_ns::get<std::string>(propertyValue); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | else if (interfaceName == FILEPATH_IFACE) |
| 70 | { |
| 71 | const auto& it = propertyMap.find("Path"); |
| 72 | if (it != propertyMap.end()) |
| 73 | { |
| 74 | filePath = variant_ns::get<std::string>(it->second); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | if ((filePath.empty()) || (purpose == VersionPurpose::Unknown)) |
| 79 | { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | // Version id is the last item in the path |
| 84 | auto pos = path.rfind("/"); |
| 85 | if (pos == std::string::npos) |
| 86 | { |
| 87 | log<level::ERR>("No version id found in object path", |
| 88 | entry("OBJPATH=%s", path.c_str())); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | auto versionId = path.substr(pos + 1); |
| 93 | |
| 94 | if (activations.find(versionId) == activations.end()) |
| 95 | { |
| 96 | // Determine the Activation state by processing the given image dir. |
Lei YU | 9102944 | 2019-08-01 15:57:31 +0800 | [diff] [blame] | 97 | AssociationList associations; |
Lei YU | 58c26e3 | 2019-09-27 17:52:06 +0800 | [diff] [blame] | 98 | auto activationState = Activation::Status::Ready; |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 99 | |
Lei YU | 9102944 | 2019-08-01 15:57:31 +0800 | [diff] [blame] | 100 | associations.emplace_back(std::make_tuple(ACTIVATION_FWD_ASSOCIATION, |
| 101 | ACTIVATION_REV_ASSOCIATION, |
Lei YU | 5e0dcb3 | 2019-08-02 18:04:34 +0800 | [diff] [blame] | 102 | PSU_INVENTORY_PATH_BASE)); |
Lei YU | 9102944 | 2019-08-01 15:57:31 +0800 | [diff] [blame] | 103 | |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 104 | fs::path manifestPath(filePath); |
| 105 | manifestPath /= MANIFEST_FILE; |
Lei YU | 58c26e3 | 2019-09-27 17:52:06 +0800 | [diff] [blame] | 106 | std::string extendedVersion = |
| 107 | Version::getValue(manifestPath, {MANIFEST_EXTENDED_VERSION}); |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 108 | |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 109 | auto activation = |
| 110 | createActivationObject(path, versionId, extendedVersion, |
| 111 | activationState, associations, filePath); |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 112 | activations.emplace(versionId, std::move(activation)); |
| 113 | |
| 114 | auto versionPtr = |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 115 | createVersionObject(path, versionId, version, purpose); |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 116 | versions.emplace(versionId, std::move(versionPtr)); |
| 117 | } |
| 118 | return; |
| 119 | } |
| 120 | |
Lei YU | a5c47bb | 2019-09-29 11:28:53 +0800 | [diff] [blame] | 121 | void ItemUpdater::erase(const std::string& versionId) |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 122 | { |
| 123 | auto it = versions.find(versionId); |
| 124 | if (it == versions.end()) |
| 125 | { |
| 126 | log<level::ERR>(("Error: Failed to find version " + versionId + |
| 127 | " in item updater versions map." |
| 128 | " Unable to remove.") |
| 129 | .c_str()); |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | versions.erase(versionId); |
| 134 | } |
| 135 | |
| 136 | // Removing entry in activations map |
| 137 | auto ita = activations.find(versionId); |
| 138 | if (ita == activations.end()) |
| 139 | { |
| 140 | log<level::ERR>(("Error: Failed to find version " + versionId + |
| 141 | " in item updater activations map." |
| 142 | " Unable to remove.") |
| 143 | .c_str()); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | activations.erase(versionId); |
| 148 | } |
| 149 | } |
| 150 | |
Lei YU | 9102944 | 2019-08-01 15:57:31 +0800 | [diff] [blame] | 151 | void ItemUpdater::createActiveAssociation(const std::string& path) |
| 152 | { |
| 153 | assocs.emplace_back( |
| 154 | std::make_tuple(ACTIVE_FWD_ASSOCIATION, ACTIVE_REV_ASSOCIATION, path)); |
| 155 | associations(assocs); |
| 156 | } |
| 157 | |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 158 | void ItemUpdater::addFunctionalAssociation(const std::string& path) |
Lei YU | 9102944 | 2019-08-01 15:57:31 +0800 | [diff] [blame] | 159 | { |
Lei YU | 9102944 | 2019-08-01 15:57:31 +0800 | [diff] [blame] | 160 | assocs.emplace_back(std::make_tuple(FUNCTIONAL_FWD_ASSOCIATION, |
| 161 | FUNCTIONAL_REV_ASSOCIATION, path)); |
| 162 | associations(assocs); |
| 163 | } |
| 164 | |
| 165 | void ItemUpdater::removeAssociation(const std::string& path) |
| 166 | { |
| 167 | for (auto iter = assocs.begin(); iter != assocs.end();) |
| 168 | { |
| 169 | if ((std::get<2>(*iter)).compare(path) == 0) |
| 170 | { |
| 171 | iter = assocs.erase(iter); |
| 172 | associations(assocs); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | ++iter; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 181 | std::unique_ptr<Activation> ItemUpdater::createActivationObject( |
| 182 | const std::string& path, const std::string& versionId, |
Lei YU | 58c26e3 | 2019-09-27 17:52:06 +0800 | [diff] [blame] | 183 | const std::string& extVersion, Activation::Status activationStatus, |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 184 | const AssociationList& assocs, const std::string& filePath) |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 185 | { |
| 186 | return std::make_unique<Activation>(bus, path, versionId, extVersion, |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 187 | activationStatus, assocs, this, |
| 188 | filePath); |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 189 | } |
| 190 | |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 191 | void ItemUpdater::createPsuObject(const std::string& psuInventoryPath, |
| 192 | const std::string& psuVersion) |
| 193 | { |
| 194 | auto versionId = utils::getVersionId(psuVersion); |
| 195 | auto path = std::string(SOFTWARE_OBJPATH) + "/" + versionId; |
| 196 | |
| 197 | auto it = activations.find(versionId); |
| 198 | if (it != activations.end()) |
| 199 | { |
| 200 | // The versionId is already created, associate the path |
| 201 | auto associations = it->second->associations(); |
| 202 | associations.emplace_back(std::make_tuple(ACTIVATION_FWD_ASSOCIATION, |
| 203 | ACTIVATION_REV_ASSOCIATION, |
| 204 | psuInventoryPath)); |
| 205 | it->second->associations(associations); |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 206 | psuPathActivationMap.emplace(psuInventoryPath, it->second); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 207 | } |
| 208 | else |
| 209 | { |
| 210 | // Create a new object for running PSU inventory |
| 211 | AssociationList associations; |
Lei YU | 58c26e3 | 2019-09-27 17:52:06 +0800 | [diff] [blame] | 212 | auto activationState = Activation::Status::Active; |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 213 | |
| 214 | associations.emplace_back(std::make_tuple(ACTIVATION_FWD_ASSOCIATION, |
| 215 | ACTIVATION_REV_ASSOCIATION, |
| 216 | psuInventoryPath)); |
| 217 | |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 218 | auto activation = createActivationObject( |
| 219 | path, versionId, "", activationState, associations, ""); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 220 | activations.emplace(versionId, std::move(activation)); |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 221 | psuPathActivationMap.emplace(psuInventoryPath, activations[versionId]); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 222 | |
| 223 | auto versionPtr = createVersionObject(path, versionId, psuVersion, |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 224 | VersionPurpose::PSU); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 225 | versions.emplace(versionId, std::move(versionPtr)); |
| 226 | |
| 227 | createActiveAssociation(path); |
| 228 | addFunctionalAssociation(path); |
| 229 | } |
| 230 | } |
| 231 | |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 232 | void ItemUpdater::removePsuObject(const std::string& psuInventoryPath) |
| 233 | { |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 234 | auto it = psuPathActivationMap.find(psuInventoryPath); |
| 235 | if (it == psuPathActivationMap.end()) |
| 236 | { |
| 237 | log<level::ERR>("No Activation found for PSU", |
| 238 | entry("PSUPATH=%s", psuInventoryPath.c_str())); |
| 239 | return; |
| 240 | } |
| 241 | const auto& activationPtr = it->second; |
| 242 | psuPathActivationMap.erase(psuInventoryPath); |
| 243 | |
| 244 | auto associations = activationPtr->associations(); |
| 245 | for (auto iter = associations.begin(); iter != associations.end();) |
| 246 | { |
| 247 | if ((std::get<2>(*iter)).compare(psuInventoryPath) == 0) |
| 248 | { |
| 249 | iter = associations.erase(iter); |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | ++iter; |
| 254 | } |
| 255 | } |
| 256 | if (associations.empty()) |
| 257 | { |
| 258 | // Remove the activation |
Lei YU | a5c47bb | 2019-09-29 11:28:53 +0800 | [diff] [blame] | 259 | erase(activationPtr->getVersionId()); |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 260 | } |
| 261 | else |
| 262 | { |
| 263 | // Update association |
| 264 | activationPtr->associations(associations); |
| 265 | } |
| 266 | } |
| 267 | |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 268 | std::unique_ptr<Version> ItemUpdater::createVersionObject( |
| 269 | const std::string& objPath, const std::string& versionId, |
| 270 | const std::string& versionString, |
| 271 | sdbusplus::xyz::openbmc_project::Software::server::Version::VersionPurpose |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 272 | versionPurpose) |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 273 | { |
| 274 | auto version = std::make_unique<Version>( |
Lei YU | 9930137 | 2019-09-29 16:27:12 +0800 | [diff] [blame] | 275 | bus, objPath, versionId, versionString, versionPurpose, |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 276 | std::bind(&ItemUpdater::erase, this, std::placeholders::_1)); |
| 277 | return version; |
| 278 | } |
| 279 | |
Lei YU | a2c2cd7 | 2019-08-09 15:54:10 +0800 | [diff] [blame] | 280 | void ItemUpdater::onPsuInventoryChangedMsg(sdbusplus::message::message& msg) |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 281 | { |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 282 | using Interface = std::string; |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 283 | Interface interface; |
| 284 | Properties properties; |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 285 | std::string psuPath = msg.get_path(); |
| 286 | |
| 287 | msg.read(interface, properties); |
Lei YU | a2c2cd7 | 2019-08-09 15:54:10 +0800 | [diff] [blame] | 288 | onPsuInventoryChanged(psuPath, properties); |
| 289 | } |
| 290 | |
| 291 | void ItemUpdater::onPsuInventoryChanged(const std::string& psuPath, |
| 292 | const Properties& properties) |
| 293 | { |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 294 | bool present; |
| 295 | std::string version; |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 296 | |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 297 | // Only present property is interested |
Lei YU | f77189f | 2019-08-07 14:26:30 +0800 | [diff] [blame] | 298 | auto p = properties.find(PRESENT); |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 299 | if (p == properties.end()) |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 300 | { |
| 301 | return; |
| 302 | } |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 303 | present = sdbusplus::message::variant_ns::get<bool>(p->second); |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 304 | |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 305 | if (present) |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 306 | { |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 307 | version = utils::getVersion(psuPath); |
| 308 | if (!version.empty()) |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 309 | { |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 310 | createPsuObject(psuPath, version); |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 311 | } |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 312 | } |
| 313 | else |
| 314 | { |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 315 | // Remove object or association |
| 316 | removePsuObject(psuPath); |
| 317 | } |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | void ItemUpdater::processPSUImage() |
| 321 | { |
| 322 | auto paths = utils::getPSUInventoryPath(bus); |
| 323 | for (const auto& p : paths) |
| 324 | { |
Lei YU | 5f3584d | 2019-08-27 16:28:53 +0800 | [diff] [blame] | 325 | auto service = utils::getService(bus, p.c_str(), ITEM_IFACE); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 326 | auto present = utils::getProperty<bool>(bus, service.c_str(), p.c_str(), |
Lei YU | f77189f | 2019-08-07 14:26:30 +0800 | [diff] [blame] | 327 | ITEM_IFACE, PRESENT); |
Lei YU | 5f3584d | 2019-08-27 16:28:53 +0800 | [diff] [blame] | 328 | auto version = utils::getVersion(p); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 329 | if (present && !version.empty()) |
| 330 | { |
| 331 | createPsuObject(p, version); |
| 332 | } |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 333 | // Add matches for PSU Inventory's property changes |
| 334 | psuMatches.emplace_back( |
Lei YU | dcaf893 | 2019-09-09 16:09:35 +0800 | [diff] [blame] | 335 | bus, MatchRules::propertiesChanged(p, ITEM_IFACE), |
Lei YU | a2c2cd7 | 2019-08-09 15:54:10 +0800 | [diff] [blame] | 336 | std::bind(&ItemUpdater::onPsuInventoryChangedMsg, this, |
Lei YU | bd3b007 | 2019-08-08 13:09:50 +0800 | [diff] [blame] | 337 | std::placeholders::_1)); |
Lei YU | ad90ad5 | 2019-08-06 11:19:28 +0800 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | |
Lei YU | 58c26e3 | 2019-09-27 17:52:06 +0800 | [diff] [blame] | 341 | void ItemUpdater::processStoredImage() |
| 342 | { |
| 343 | scanDirectory(IMG_DIR_BUILTIN); |
| 344 | scanDirectory(IMG_DIR_PERSIST); |
| 345 | } |
| 346 | |
| 347 | void ItemUpdater::scanDirectory(const fs::path& dir) |
| 348 | { |
| 349 | // The directory shall put PSU images in directories named with model |
| 350 | if (!fs::exists(dir)) |
| 351 | { |
| 352 | // Skip |
| 353 | return; |
| 354 | } |
| 355 | if (!fs::is_directory(dir)) |
| 356 | { |
| 357 | log<level::ERR>("The path is not a directory", |
| 358 | entry("PATH=%s", dir.c_str())); |
| 359 | return; |
| 360 | } |
| 361 | for (const auto& d : fs::directory_iterator(dir)) |
| 362 | { |
| 363 | // If the model in manifest does not match the dir name |
| 364 | // Log a warning and skip it |
| 365 | auto path = d.path(); |
| 366 | auto manifest = path / MANIFEST_FILE; |
| 367 | if (fs::exists(manifest)) |
| 368 | { |
| 369 | auto ret = Version::getValues( |
| 370 | manifest.string(), |
| 371 | {MANIFEST_VERSION, MANIFEST_EXTENDED_VERSION}); |
| 372 | auto version = ret[MANIFEST_VERSION]; |
| 373 | auto extVersion = ret[MANIFEST_EXTENDED_VERSION]; |
| 374 | auto info = Version::getExtVersionInfo(extVersion); |
| 375 | auto model = info["model"]; |
| 376 | if (path.stem() != model) |
| 377 | { |
| 378 | log<level::ERR>("Unmatched model", |
| 379 | entry("PATH=%s", path.c_str()), |
| 380 | entry("MODEL=%s", model.c_str())); |
| 381 | continue; |
| 382 | } |
| 383 | auto versionId = utils::getVersionId(version); |
| 384 | auto it = activations.find(versionId); |
| 385 | if (it == activations.end()) |
| 386 | { |
| 387 | // This is a version that is different than the running PSUs |
| 388 | auto activationState = Activation::Status::Ready; |
| 389 | auto purpose = VersionPurpose::PSU; |
| 390 | auto objPath = std::string(SOFTWARE_OBJPATH) + "/" + versionId; |
| 391 | |
| 392 | auto activation = createActivationObject( |
| 393 | objPath, versionId, extVersion, activationState, {}, path); |
| 394 | activations.emplace(versionId, std::move(activation)); |
| 395 | |
| 396 | auto versionPtr = |
| 397 | createVersionObject(objPath, versionId, version, purpose); |
| 398 | versions.emplace(versionId, std::move(versionPtr)); |
| 399 | } |
| 400 | else |
| 401 | { |
| 402 | // This is a version that a running PSU is using, set the path |
| 403 | // on the version object |
| 404 | it->second->path(path); |
| 405 | } |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | log<level::ERR>("No MANIFEST found", |
| 410 | entry("PATH=%s", path.c_str())); |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
Lei YU | 01539e7 | 2019-07-31 10:57:38 +0800 | [diff] [blame] | 415 | } // namespace updater |
| 416 | } // namespace software |
| 417 | } // namespace phosphor |