blob: 1539f95c9d038339d4862052002f93531b11d032 [file] [log] [blame]
Saqib Khan7254f0e2017-04-10 21:45:37 -05001#include <string>
Adriana Kobylak5ba6b102017-05-19 09:41:27 -05002#include <experimental/filesystem>
Saqib Khan7254f0e2017-04-10 21:45:37 -05003#include <fstream>
Eddie James13fc66a2017-08-31 15:36:44 -05004#include <phosphor-logging/elog-errors.hpp>
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -05005#include <phosphor-logging/log.hpp>
Eddie James13fc66a2017-08-31 15:36:44 -05006#include "xyz/openbmc_project/Common/error.hpp"
Adriana Kobylakd6a549e2017-05-10 16:23:01 -05007#include <xyz/openbmc_project/Software/Version/server.hpp>
Saqib Khan167601b2017-06-18 23:33:46 -05008#include "version.hpp"
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05009#include "config.h"
10#include "item_updater.hpp"
Saqib Khana8ade7e2017-04-12 10:27:56 -050011#include "activation.hpp"
Michael Tritz60bc20f2017-07-29 23:32:21 -050012#include "serialize.hpp"
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050013
14namespace openpower
15{
16namespace software
17{
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050018namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050019{
20
Saqib Khana8ade7e2017-04-12 10:27:56 -050021// When you see server:: you know we're referencing our base class
22namespace server = sdbusplus::xyz::openbmc_project::Software::server;
Adriana Kobylak5ba6b102017-05-19 09:41:27 -050023namespace fs = std::experimental::filesystem;
Saqib Khana8ade7e2017-04-12 10:27:56 -050024
Eddie James13fc66a2017-08-31 15:36:44 -050025using namespace sdbusplus::xyz::openbmc_project::Common::Error;
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -050026using namespace phosphor::logging;
27
Saqib Khana8ade7e2017-04-12 10:27:56 -050028constexpr auto squashFSImage = "pnor.xz.squashfs";
Eddie James13fc66a2017-08-31 15:36:44 -050029constexpr auto CHASSIS_STATE_PATH = "/xyz/openbmc_project/state/chassis0";
30constexpr auto CHASSIS_STATE_OBJ = "xyz.openbmc_project.State.Chassis";
31constexpr auto CHASSIS_STATE_OFF =
32 "xyz.openbmc_project.State.Chassis.PowerState.Off";
33constexpr auto SYSTEMD_PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
Saqib Khana8ade7e2017-04-12 10:27:56 -050034
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050035void ItemUpdater::createActivation(sdbusplus::message::message& m)
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050036{
Patrick Williamse4290942017-06-16 05:43:08 -050037 using SVersion = server::Version;
38 using VersionPurpose = SVersion::VersionPurpose;
39 namespace msg = sdbusplus::message;
40 namespace variant_ns = msg::variant_ns;
41
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050042 sdbusplus::message::object_path objPath;
43 std::map<std::string,
Patrick Williamse4290942017-06-16 05:43:08 -050044 std::map<std::string, msg::variant<std::string>>> interfaces;
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050045 m.read(objPath, interfaces);
Patrick Williamse4290942017-06-16 05:43:08 -050046
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050047 std::string path(std::move(objPath));
Adriana Kobylak5ba6b102017-05-19 09:41:27 -050048 std::string filePath;
Patrick Williamse4290942017-06-16 05:43:08 -050049 auto purpose = VersionPurpose::Unknown;
Saqib Khance148702017-06-11 12:01:58 -050050 std::string version;
Adriana Kobylak5ba6b102017-05-19 09:41:27 -050051
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050052 for (const auto& intf : interfaces)
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -050053 {
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050054 if (intf.first == VERSION_IFACE)
55 {
56 for (const auto& property : intf.second)
57 {
58 if (property.first == "Purpose")
59 {
60 // Only process the Host and System images
Patrick Williamse4290942017-06-16 05:43:08 -050061 auto value = SVersion::convertVersionPurposeFromString(
62 variant_ns::get<std::string>(property.second));
63
64 if (value == VersionPurpose::Host ||
65 value == VersionPurpose::System)
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050066 {
Saqib Khance148702017-06-11 12:01:58 -050067 purpose = value;
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050068 }
69 }
Saqib Khance148702017-06-11 12:01:58 -050070 else if (property.first == "Version")
71 {
Patrick Williamse4290942017-06-16 05:43:08 -050072 version = variant_ns::get<std::string>(property.second);
Saqib Khance148702017-06-11 12:01:58 -050073 }
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050074 }
75 }
Adriana Kobylak5ba6b102017-05-19 09:41:27 -050076 else if (intf.first == FILEPATH_IFACE)
77 {
78 for (const auto& property : intf.second)
79 {
80 if (property.first == "Path")
81 {
Patrick Williamse4290942017-06-16 05:43:08 -050082 filePath = variant_ns::get<std::string>(property.second);
Adriana Kobylak5ba6b102017-05-19 09:41:27 -050083 }
84 }
85 }
86 }
Patrick Williamse4290942017-06-16 05:43:08 -050087 if ((filePath.empty()) || (purpose == VersionPurpose::Unknown))
Adriana Kobylak5ba6b102017-05-19 09:41:27 -050088 {
89 return;
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -050090 }
91
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050092 // Version id is the last item in the path
93 auto pos = path.rfind("/");
94 if (pos == std::string::npos)
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -050095 {
Adriana Kobylakd6a549e2017-05-10 16:23:01 -050096 log<level::ERR>("No version id found in object path",
97 entry("OBJPATH=%s", path));
98 return;
99 }
100
101 auto versionId = path.substr(pos + 1);
102
103 if (activations.find(versionId) == activations.end())
104 {
105 // Determine the Activation state by processing the given image dir.
106 auto activationState = server::Activation::Activations::Invalid;
Gunnar Mills3588acc2017-09-07 13:13:22 -0500107 AssociationList associations = {};
Adriana Kobylak5ba6b102017-05-19 09:41:27 -0500108 if (ItemUpdater::validateSquashFSImage(filePath) == 0)
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -0500109 {
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500110 activationState = server::Activation::Activations::Ready;
Gunnar Mills3588acc2017-09-07 13:13:22 -0500111 // Create an association to the host inventory item
112 associations.emplace_back(std::make_tuple(
113 ACTIVATION_FWD_ASSOCIATION,
114 ACTIVATION_REV_ASSOCIATION,
115 HOST_INVENTORY_PATH));
Adriana Kobylakb66ac3a2017-03-28 13:33:20 -0500116 }
117
Adriana Kobylak5ba6b102017-05-19 09:41:27 -0500118 fs::path manifestPath(filePath);
119 manifestPath /= MANIFEST_FILE;
Saqib Khan167601b2017-06-18 23:33:46 -0500120 std::string extendedVersion = (Version::getValue(manifestPath.string(),
121 std::map<std::string, std::string>
122 {{"extended_version", ""}})).begin()->second;
Gunnar Mills3edb84b2017-08-18 15:13:15 -0500123
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500124 activations.insert(std::make_pair(
125 versionId,
126 std::make_unique<Activation>(
127 bus,
128 path,
Saqib Khan81bac882017-06-08 12:17:01 -0500129 *this,
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500130 versionId,
131 extendedVersion,
Gunnar Mills3edb84b2017-08-18 15:13:15 -0500132 activationState,
133 associations)));
Saqib Khance148702017-06-11 12:01:58 -0500134 versions.insert(std::make_pair(
135 versionId,
136 std::make_unique<Version>(
137 bus,
138 path,
139 version,
140 purpose,
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500141 filePath,
142 *this)));
Saqib Khan00044f42017-07-10 17:24:43 -0500143 }
Saqib Khan3fb2d172017-08-07 12:14:03 -0500144 else
145 {
146 log<level::INFO>("Software Object with the same version already exists",
Gunnar Mills3fa70282017-08-18 15:30:42 -0500147 entry("VERSION_ID=%s", versionId));
Saqib Khan3fb2d172017-08-07 12:14:03 -0500148 }
Patrick Williams3accb322017-05-30 16:29:52 -0500149 return;
Adriana Kobylak2d8fa222017-03-15 12:34:32 -0500150}
151
Saqib Khan167601b2017-06-18 23:33:46 -0500152void ItemUpdater::processPNORImage()
Saqib Khan7254f0e2017-04-10 21:45:37 -0500153{
Saqib Khan4c5d7442017-07-18 00:43:52 -0500154 // Read pnor.toc from folders under /media/
155 // to get Active Software Versions.
Gunnar Mills3fa70282017-08-18 15:30:42 -0500156 for (const auto& iter : fs::directory_iterator(MEDIA_DIR))
Saqib Khan4c5d7442017-07-18 00:43:52 -0500157 {
158 auto activationState = server::Activation::Activations::Active;
159
160 static const auto PNOR_RO_PREFIX_LEN = strlen(PNOR_RO_PREFIX);
161
162 // Check if the PNOR_RO_PREFIX is the prefix of the iter.path
163 if (0 == iter.path().native().compare(0, PNOR_RO_PREFIX_LEN,
164 PNOR_RO_PREFIX))
165 {
166 auto pnorTOC = iter.path() / PNOR_TOC_FILE;
167 if (!fs::is_regular_file(pnorTOC))
168 {
169 log<level::ERR>("Failed to read pnorTOC\n",
170 entry("FileName=%s", pnorTOC.string()));
171 activationState = server::Activation::Activations::Invalid;
172 }
173 auto keyValues =
174 Version::getValue(pnorTOC,
175 {{ "version", "" },
176 { "extended_version", "" } });
177 auto& version = keyValues.at("version");
178 if (version.empty())
179 {
180 log<level::ERR>("Failed to read version from pnorTOC",
181 entry("FILENAME=%s", pnorTOC.string()));
182 activationState = server::Activation::Activations::Invalid;
183 }
184
185 auto& extendedVersion = keyValues.at("extended_version");
186 if (extendedVersion.empty())
187 {
188 log<level::ERR>("Failed to read extendedVersion from pnorTOC",
189 entry("FILENAME=%s", pnorTOC.string()));
190 activationState = server::Activation::Activations::Invalid;
191 }
192
193 // The versionId is extracted from the path
194 // for example /media/pnor-ro-2a1022fe
195 auto id = iter.path().native().substr(PNOR_RO_PREFIX_LEN);
196 auto purpose = server::Version::VersionPurpose::Host;
197 auto path = fs::path(SOFTWARE_OBJPATH) / id;
Gunnar Mills3588acc2017-09-07 13:13:22 -0500198 AssociationList associations = {};
Saqib Khan4c5d7442017-07-18 00:43:52 -0500199
Gunnar Mills3588acc2017-09-07 13:13:22 -0500200 if (activationState == server::Activation::Activations::Active)
201 {
202 // Create an association to the host inventory item
203 associations.emplace_back(std::make_tuple(
204 ACTIVATION_FWD_ASSOCIATION,
205 ACTIVATION_REV_ASSOCIATION,
206 HOST_INVENTORY_PATH));
Gunnar Mills3edb84b2017-08-18 15:13:15 -0500207
Gunnar Mills3588acc2017-09-07 13:13:22 -0500208 // Create an active association since this image is active
209 createActiveAssociation(path);
210 }
Gunnar Mills3edb84b2017-08-18 15:13:15 -0500211
Saqib Khan4c5d7442017-07-18 00:43:52 -0500212 // Create Activation instance for this version.
213 activations.insert(std::make_pair(
214 id,
215 std::make_unique<Activation>(
216 bus,
217 path,
218 *this,
219 id,
220 extendedVersion,
Gunnar Mills3edb84b2017-08-18 15:13:15 -0500221 activationState,
222 associations)));
Saqib Khan4c5d7442017-07-18 00:43:52 -0500223
224 // If Active, create RedundancyPriority instance for this version.
225 if (activationState == server::Activation::Activations::Active)
226 {
Michael Tritz36417922017-08-04 14:00:29 -0500227 uint8_t priority = std::numeric_limits<uint8_t>::max();
228 if (!restoreFromFile(id, priority))
Saqib Khan4c5d7442017-07-18 00:43:52 -0500229 {
Michael Tritz36417922017-08-04 14:00:29 -0500230 log<level::ERR>("Unable to restore priority from file.",
Gunnar Mills3fa70282017-08-18 15:30:42 -0500231 entry("VERSIONID=%s", id));
Saqib Khan4c5d7442017-07-18 00:43:52 -0500232 }
Michael Tritz36417922017-08-04 14:00:29 -0500233 activations.find(id)->second->redundancyPriority =
234 std::make_unique<RedundancyPriority>(
235 bus,
236 path,
237 *(activations.find(id)->second),
238 priority);
Saqib Khan4c5d7442017-07-18 00:43:52 -0500239 }
240
241 // Create Version instance for this version.
242 versions.insert(std::make_pair(
243 id,
244 std::make_unique<Version>(
245 bus,
246 path,
247 version,
248 purpose,
249 "",
250 *this)));
251 }
252 }
Saqib Khan167601b2017-06-18 23:33:46 -0500253 return;
Saqib Khan7254f0e2017-04-10 21:45:37 -0500254}
255
Adriana Kobylak5ba6b102017-05-19 09:41:27 -0500256int ItemUpdater::validateSquashFSImage(const std::string& filePath)
Saqib Khana8ade7e2017-04-12 10:27:56 -0500257{
Saqib Khan4c5d7442017-07-18 00:43:52 -0500258 auto file = fs::path(filePath) / squashFSImage;
259 if (fs::is_regular_file(file))
Saqib Khana8ade7e2017-04-12 10:27:56 -0500260 {
261 return 0;
262 }
263 else
264 {
265 log<level::ERR>("Failed to find the SquashFS image.");
266 return -1;
267 }
268}
269
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500270void ItemUpdater::removeReadOnlyPartition(std::string versionId)
Michael Tritzdd961b62017-05-17 14:07:03 -0500271{
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500272 auto serviceFile = "obmc-flash-bios-ubiumount-ro@" + versionId +
273 ".service";
274
275 // Remove the read-only partitions.
276 auto method = bus.new_method_call(
277 SYSTEMD_BUSNAME,
278 SYSTEMD_PATH,
279 SYSTEMD_INTERFACE,
280 "StartUnit");
281 method.append(serviceFile, "replace");
282 bus.call_noreply(method);
283}
284
285void ItemUpdater::removeReadWritePartition(std::string versionId)
286{
287 auto serviceFile = "obmc-flash-bios-ubiumount-rw@" + versionId +
Michael Tritzdd961b62017-05-17 14:07:03 -0500288 ".service";
289
290 // Remove the read-write partitions.
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500291 auto method = bus.new_method_call(
Michael Tritzdd961b62017-05-17 14:07:03 -0500292 SYSTEMD_BUSNAME,
293 SYSTEMD_PATH,
294 SYSTEMD_INTERFACE,
295 "StartUnit");
296 method.append(serviceFile, "replace");
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500297 bus.call_noreply(method);
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500298}
Michael Tritzdd961b62017-05-17 14:07:03 -0500299
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500300void ItemUpdater::removePreservedPartition()
301{
Michael Tritzdd961b62017-05-17 14:07:03 -0500302 // Remove the preserved partition.
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500303 auto method = bus.new_method_call(
Michael Tritzdd961b62017-05-17 14:07:03 -0500304 SYSTEMD_BUSNAME,
305 SYSTEMD_PATH,
306 SYSTEMD_INTERFACE,
307 "StartUnit");
308 method.append("obmc-flash-bios-ubiumount-prsv.service", "replace");
Adriana Kobylakd6a549e2017-05-10 16:23:01 -0500309 bus.call_noreply(method);
Michael Tritzdd961b62017-05-17 14:07:03 -0500310
311 return;
312}
313
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500314void ItemUpdater::reset()
315{
Gunnar Mills3fa70282017-08-18 15:30:42 -0500316 for (const auto& it : activations)
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500317 {
318 removeReadWritePartition(it.first);
Michael Tritz60bc20f2017-07-29 23:32:21 -0500319 removeFile(it.first);
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500320 }
321 removePreservedPartition();
322 return;
323}
324
Eddie James13fc66a2017-08-31 15:36:44 -0500325bool ItemUpdater::isVersionFunctional(std::string versionId)
326{
327 if (!fs::exists(PNOR_RO_ACTIVE_PATH))
328 {
329 return false;
330 }
331
332 fs::path activeRO = fs::read_symlink(PNOR_RO_ACTIVE_PATH);
333
334 if (!fs::is_directory(activeRO))
335 {
336 return false;
337 }
338
339 if (activeRO.string().find(versionId) == std::string::npos)
340 {
341 return false;
342 }
343
344 // active PNOR is the version we're checking
345 return true;
346}
347
348bool ItemUpdater::isChassisOn()
349{
350 auto mapperCall = bus.new_method_call(
351 MAPPER_BUSNAME,
352 MAPPER_PATH,
353 MAPPER_INTERFACE,
354 "GetObject");
355
356 mapperCall.append(CHASSIS_STATE_PATH,
357 std::vector<std::string>({CHASSIS_STATE_OBJ}));
358 auto mapperResponseMsg = bus.call(mapperCall);
359 if (mapperResponseMsg.is_method_error())
360 {
361 log<level::ERR>("Error in Mapper call");
362 elog<InternalFailure>();
363 }
364 using MapperResponseType = std::map<std::string, std::vector<std::string>>;
365 MapperResponseType mapperResponse;
366 mapperResponseMsg.read(mapperResponse);
367 if (mapperResponse.empty())
368 {
369 log<level::ERR>("Invalid Response from mapper");
370 elog<InternalFailure>();
371 }
372
373 auto method = bus.new_method_call((mapperResponse.begin()->first).c_str(),
374 CHASSIS_STATE_PATH,
375 SYSTEMD_PROPERTY_INTERFACE,
376 "Get");
377 method.append(CHASSIS_STATE_OBJ, "CurrentPowerState");
378 auto response = bus.call(method);
379 if (response.is_method_error())
380 {
381 log<level::ERR>("Error in fetching current Chassis State",
382 entry("MapperResponse=%s",
383 (mapperResponse.begin()->first).c_str()));
384 elog<InternalFailure>();
385 }
386 sdbusplus::message::variant<std::string> currentChassisState;
387 response.read(currentChassisState);
388 auto strParam =
389 sdbusplus::message::variant_ns::get<std::string>(currentChassisState);
390 return (strParam != CHASSIS_STATE_OFF);
391}
392
Saqib Khanb8e7f312017-08-12 10:24:10 -0500393void ItemUpdater::freePriority(uint8_t value, const std::string& versionId)
Saqib Khan81bac882017-06-08 12:17:01 -0500394{
395 //TODO openbmc/openbmc#1896 Improve the performance of this function
396 for (const auto& intf : activations)
397 {
Gunnar Mills3fa70282017-08-18 15:30:42 -0500398 if (intf.second->redundancyPriority)
Saqib Khan81bac882017-06-08 12:17:01 -0500399 {
Saqib Khanb8e7f312017-08-12 10:24:10 -0500400 if (intf.second->redundancyPriority.get()->priority() == value &&
401 intf.second->versionId != versionId)
Saqib Khan81bac882017-06-08 12:17:01 -0500402 {
Gunnar Mills3fa70282017-08-18 15:30:42 -0500403 intf.second->redundancyPriority.get()->priority(value + 1);
Saqib Khan81bac882017-06-08 12:17:01 -0500404 }
405 }
406 }
407}
408
Saqib Khan2af5c492017-07-17 16:15:13 -0500409bool ItemUpdater::isLowestPriority(uint8_t value)
410{
411 for (const auto& intf : activations)
412 {
Gunnar Mills3fa70282017-08-18 15:30:42 -0500413 if (intf.second->redundancyPriority)
Saqib Khan2af5c492017-07-17 16:15:13 -0500414 {
415 if (intf.second->redundancyPriority.get()->priority() < value)
416 {
417 return false;
418 }
419 }
420 }
421 return true;
422}
423
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500424void ItemUpdater::erase(std::string entryId)
425{
Eddie James13fc66a2017-08-31 15:36:44 -0500426 if (isVersionFunctional(entryId) && isChassisOn()) {
427 log<level::ERR>(("Error: Version " + entryId + \
428 " is currently active and running on the host." \
429 " Unable to remove.").c_str());
430 return;
431 }
Saqib Khanef8cd9f2017-08-16 14:20:30 -0500432 // Remove priority persistence file
433 removeFile(entryId);
434
Saqib Khan1e0aa5c2017-08-31 11:04:17 -0500435 // Removing read-only and read-write partitions
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500436 removeReadWritePartition(entryId);
437 removeReadOnlyPartition(entryId);
438
439 // Removing entry in versions map
440 auto it = versions.find(entryId);
441 if (it == versions.end())
442 {
443 log<level::ERR>(("Error: Failed to find version " + entryId + \
Gunnar Mills3fa70282017-08-18 15:30:42 -0500444 " in item updater versions map." \
445 " Unable to remove.").c_str());
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500446 return;
447 }
448 versions.erase(entryId);
449
450 // Removing entry in activations map
451 auto ita = activations.find(entryId);
452 if (ita == activations.end())
453 {
454 log<level::ERR>(("Error: Failed to find version " + entryId + \
Gunnar Mills3fa70282017-08-18 15:30:42 -0500455 " in item updater activations map." \
456 " Unable to remove.").c_str());
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -0500457 return;
458 }
459 activations.erase(entryId);
460}
461
Saqib Khan2cbfa032017-08-17 14:52:37 -0500462// TODO: openbmc/openbmc#1402 Monitor flash usage
463void ItemUpdater::freeSpace()
464{
465 std::size_t count = 0;
466 decltype(activations.begin()->second->redundancyPriority.get()->priority())
467 highestPriority = 0;
468 decltype(activations.begin()->second->versionId) highestPriorityVersion;
469 for (const auto& iter : activations)
470 {
471 if (iter.second.get()->activation() == server::Activation::Activations::Active)
472 {
473 count++;
474 if (iter.second->redundancyPriority.get()->priority() > highestPriority)
475 {
476 highestPriority = iter.second->redundancyPriority.get()->priority();
477 highestPriorityVersion = iter.second->versionId;
478 }
479 }
480 }
481 // Remove the pnor version with highest priority since the PNOR
482 // can't hold more than 2 versions.
483 if (count >= ACTIVE_PNOR_MAX_ALLOWED)
484 {
485 erase(highestPriorityVersion);
486 }
487}
488
Gunnar Mills9741cd12017-08-28 15:09:00 -0500489void ItemUpdater::createActiveAssociation(std::string path)
490{
491 assocs.emplace_back(std::make_tuple(ACTIVE_FWD_ASSOCIATION,
492 ACTIVE_REV_ASSOCIATION,
493 path));
494 associations(assocs);
495}
496
497void ItemUpdater::removeActiveAssociation(std::string path)
498{
499 for (auto iter = assocs.begin(); iter != assocs.end();)
500 {
501 if ((std::get<2>(*iter)).compare(path) == 0)
502 {
503 iter = assocs.erase(iter);
504 associations(assocs);
505 }
506 else
507 {
508 ++iter;
509 }
510 }
511}
512
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -0500513} // namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -0500514} // namespace software
515} // namespace openpower