blob: 9f799635543074ed8f76b801129b7094bc342025 [file] [log] [blame]
Saqib Khan35e83f32017-05-22 11:37:32 -05001#include <fstream>
Gunnar Millsec1b41c2017-05-02 12:20:36 -05002#include <string>
Gunnar Mills2ce7da22017-05-04 15:37:56 -05003#include <phosphor-logging/log.hpp>
Gunnar Millsec1b41c2017-05-02 12:20:36 -05004#include "config.h"
Gunnar Mills2ce7da22017-05-04 15:37:56 -05005#include "item_updater.hpp"
6#include "xyz/openbmc_project/Software/Version/server.hpp"
Saqib Khan35e83f32017-05-22 11:37:32 -05007#include <experimental/filesystem>
Saqib Khan705f1bf2017-06-09 23:58:38 -05008#include "version.hpp"
Saqib Khan5d532672017-08-09 10:44:50 -05009#include "serialize.hpp"
Gunnar Millsec1b41c2017-05-02 12:20:36 -050010
11namespace phosphor
12{
13namespace software
14{
15namespace updater
16{
17
Gunnar Mills2ce7da22017-05-04 15:37:56 -050018// When you see server:: you know we're referencing our base class
19namespace server = sdbusplus::xyz::openbmc_project::Software::server;
Michael Tritz0129d922017-08-10 19:33:46 -050020namespace control = sdbusplus::xyz::openbmc_project::Control::server;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050021
22using namespace phosphor::logging;
Saqib Khan35e83f32017-05-22 11:37:32 -050023namespace fs = std::experimental::filesystem;
24
Gunnar Mills9a782242017-08-22 16:23:15 -050025const std::vector<std::string> bmcImages = { "image-kernel",
26 "image-rofs",
27 "image-rwfs",
28 "image-u-boot" };
Gunnar Mills2ce7da22017-05-04 15:37:56 -050029
Patrick Williamse75d10f2017-05-30 16:56:32 -050030void ItemUpdater::createActivation(sdbusplus::message::message& msg)
Gunnar Millsec1b41c2017-05-02 12:20:36 -050031{
Saqib Khan84a0e692017-06-28 17:27:01 -050032
33 using SVersion = server::Version;
34 using VersionPurpose = SVersion::VersionPurpose;
Gunnar Mills9a782242017-08-22 16:23:15 -050035 using VersionClass = phosphor::software::manager::Version;
Saqib Khan84a0e692017-06-28 17:27:01 -050036 namespace mesg = sdbusplus::message;
37 namespace variant_ns = mesg::variant_ns;
38
39 mesg::object_path objPath;
40 auto purpose = VersionPurpose::Unknown;
Saqib Khan705f1bf2017-06-09 23:58:38 -050041 std::string version;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050042 std::map<std::string,
Patrick Williamse75d10f2017-05-30 16:56:32 -050043 std::map<std::string,
Saqib Khan84a0e692017-06-28 17:27:01 -050044 mesg::variant<std::string>>> interfaces;
Patrick Williamse75d10f2017-05-30 16:56:32 -050045 msg.read(objPath, interfaces);
Gunnar Mills2ce7da22017-05-04 15:37:56 -050046 std::string path(std::move(objPath));
Saqib Khan19177d32017-06-20 08:11:49 -050047 std::string filePath;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050048
49 for (const auto& intf : interfaces)
50 {
Saqib Khan705f1bf2017-06-09 23:58:38 -050051 if (intf.first == VERSION_IFACE)
Gunnar Mills2ce7da22017-05-04 15:37:56 -050052 {
Saqib Khan705f1bf2017-06-09 23:58:38 -050053 for (const auto& property : intf.second)
Gunnar Mills2ce7da22017-05-04 15:37:56 -050054 {
Saqib Khan705f1bf2017-06-09 23:58:38 -050055 if (property.first == "Purpose")
Gunnar Mills2ce7da22017-05-04 15:37:56 -050056 {
Saqib Khan84a0e692017-06-28 17:27:01 -050057 auto value = SVersion::convertVersionPurposeFromString(
Gunnar Mills9a782242017-08-22 16:23:15 -050058 variant_ns::get<std::string>(property.second));
Saqib Khan84a0e692017-06-28 17:27:01 -050059 if (value == VersionPurpose::BMC ||
60 value == VersionPurpose::System)
61 {
62 purpose = value;
63 }
Saqib Khan705f1bf2017-06-09 23:58:38 -050064 }
65 else if (property.first == "Version")
66 {
Saqib Khan84a0e692017-06-28 17:27:01 -050067 version = variant_ns::get<std::string>(property.second);
Gunnar Mills2ce7da22017-05-04 15:37:56 -050068 }
69 }
70 }
Saqib Khan19177d32017-06-20 08:11:49 -050071 else if (intf.first == FILEPATH_IFACE)
72 {
73 for (const auto& property : intf.second)
74 {
75 if (property.first == "Path")
76 {
Saqib Khan84a0e692017-06-28 17:27:01 -050077 filePath = variant_ns::get<std::string>(property.second);
Saqib Khan19177d32017-06-20 08:11:49 -050078 }
79 }
80 }
Gunnar Mills2ce7da22017-05-04 15:37:56 -050081 }
Saqib Khan705f1bf2017-06-09 23:58:38 -050082 if (version.empty() ||
Saqib Khan19177d32017-06-20 08:11:49 -050083 filePath.empty() ||
Saqib Khan84a0e692017-06-28 17:27:01 -050084 purpose == VersionPurpose::Unknown)
Saqib Khan705f1bf2017-06-09 23:58:38 -050085 {
86 return;
87 }
Gunnar Mills2ce7da22017-05-04 15:37:56 -050088
89 // Version id is the last item in the path
90 auto pos = path.rfind("/");
91 if (pos == std::string::npos)
92 {
93 log<level::ERR>("No version id found in object path",
94 entry("OBJPATH=%s", path));
Patrick Williamse75d10f2017-05-30 16:56:32 -050095 return;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050096 }
97
98 auto versionId = path.substr(pos + 1);
99
Patrick Williamse75d10f2017-05-30 16:56:32 -0500100 if (activations.find(versionId) == activations.end())
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500101 {
Saqib Khan35e83f32017-05-22 11:37:32 -0500102 // Determine the Activation state by processing the given image dir.
103 auto activationState = server::Activation::Activations::Invalid;
Gunnar Mills9a782242017-08-22 16:23:15 -0500104 ItemUpdater::ActivationStatus result =
105 ItemUpdater::validateSquashFSImage(filePath);
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500106 AssociationList associations = {};
107
Saqib Khan35e83f32017-05-22 11:37:32 -0500108 if (result == ItemUpdater::ActivationStatus::ready)
109 {
110 activationState = server::Activation::Activations::Ready;
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500111 // Create an association to the BMC inventory item
112 associations.emplace_back(std::make_tuple(
113 ACTIVATION_FWD_ASSOCIATION,
114 ACTIVATION_REV_ASSOCIATION,
115 bmcInventoryPath));
Saqib Khan35e83f32017-05-22 11:37:32 -0500116 }
Gunnar Millsb60add12017-08-24 16:41:42 -0500117
Saqib Khan35e83f32017-05-22 11:37:32 -0500118 activations.insert(std::make_pair(
Saqib Khan705f1bf2017-06-09 23:58:38 -0500119 versionId,
120 std::make_unique<Activation>(
121 bus,
122 path,
Saqib Khan4c1aec02017-07-06 11:46:13 -0500123 *this,
Saqib Khan35e83f32017-05-22 11:37:32 -0500124 versionId,
Gunnar Millsb60add12017-08-24 16:41:42 -0500125 activationState,
126 associations)));
Saqib Khan705f1bf2017-06-09 23:58:38 -0500127 versions.insert(std::make_pair(
128 versionId,
Gunnar Mills9a782242017-08-22 16:23:15 -0500129 std::make_unique<VersionClass>(
Saqib Khan705f1bf2017-06-09 23:58:38 -0500130 bus,
131 path,
132 version,
133 purpose,
Eddie James9440f492017-08-30 11:34:16 -0500134 filePath)));
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500135 }
Saqib Khan7b5010f2017-08-09 10:03:11 -0500136 else
137 {
138 log<level::INFO>("Software Object with the same version already exists",
Gunnar Mills9a782242017-08-22 16:23:15 -0500139 entry("VERSION_ID=%s", versionId));
Saqib Khan7b5010f2017-08-09 10:03:11 -0500140 }
Patrick Williamse75d10f2017-05-30 16:56:32 -0500141 return;
Gunnar Millsec1b41c2017-05-02 12:20:36 -0500142}
143
Saqib Khanba239882017-05-26 08:41:54 -0500144void ItemUpdater::processBMCImage()
145{
Gunnar Mills88e8a322017-09-13 11:09:28 -0500146 using VersionClass = phosphor::software::manager::Version;
147 // Read os-release from /etc/ to get the functional BMC version
148 auto functionalVersion = VersionClass::getBMCVersion(OS_RELEASE_FILE);
149
Saqib Khan1eef62d2017-08-10 15:29:34 -0500150 // Read os-release from folders under /media/ to get
151 // BMC Software Versions.
152 for(const auto& iter : fs::directory_iterator(MEDIA_DIR))
153 {
154 auto activationState = server::Activation::Activations::Active;
Saqib Khan6fab70d2017-09-07 00:13:50 -0500155 static const auto BMC_RO_PREFIX_LEN = strlen(BMC_ROFS_PREFIX);
Saqib Khan1eef62d2017-08-10 15:29:34 -0500156
157 // Check if the BMC_RO_PREFIXis the prefix of the iter.path
158 if (0 == iter.path().native().compare(0, BMC_RO_PREFIX_LEN,
Saqib Khan6fab70d2017-09-07 00:13:50 -0500159 BMC_ROFS_PREFIX))
Saqib Khan1eef62d2017-08-10 15:29:34 -0500160 {
161 auto osRelease = iter.path() / OS_RELEASE_FILE;
162 if (!fs::is_regular_file(osRelease))
163 {
164 log<level::ERR>("Failed to read osRelease\n",
165 entry("FileName=%s", osRelease.string()));
166 activationState = server::Activation::Activations::Invalid;
167 }
Gunnar Mills88e8a322017-09-13 11:09:28 -0500168 auto version = VersionClass::getBMCVersion(osRelease);
Saqib Khan1eef62d2017-08-10 15:29:34 -0500169 if (version.empty())
170 {
171 log<level::ERR>("Failed to read version from osRelease",
172 entry("FILENAME=%s", osRelease.string()));
173 activationState = server::Activation::Activations::Invalid;
174 }
175 // The versionId is extracted from the path
176 // for example /media/ro-2a1022fe
177 auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN);
178 auto purpose = server::Version::VersionPurpose::BMC;
179 auto path = fs::path(SOFTWARE_OBJPATH) / id;
180
Gunnar Mills88e8a322017-09-13 11:09:28 -0500181 // Create functional association if this is the functional version
182 if (version.compare(functionalVersion) == 0)
183 {
184 createFunctionalAssociation(path);
185 }
186
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500187 AssociationList associations = {};
188
189 if (activationState == server::Activation::Activations::Active)
190 {
191 // Create an association to the BMC inventory item
192 associations.emplace_back(std::make_tuple(
193 ACTIVATION_FWD_ASSOCIATION,
194 ACTIVATION_REV_ASSOCIATION,
195 bmcInventoryPath));
196
197 // Create an active association since this image is active
198 createActiveAssociation(path);
199 }
200
Saqib Khan1eef62d2017-08-10 15:29:34 -0500201 // Create Activation instance for this version.
202 activations.insert(std::make_pair(
203 id,
204 std::make_unique<Activation>(
205 bus,
206 path,
207 *this,
208 id,
209 server::Activation::Activations::Active,
210 associations)));
211
212 // If Active, create RedundancyPriority instance for this version.
213 if (activationState == server::Activation::Activations::Active)
214 {
215 uint8_t priority = std::numeric_limits<uint8_t>::max();
216 if (!restoreFromFile(id, priority))
217 {
218 log<level::ERR>("Unable to restore priority from file.",
219 entry("VERSIONID=%s", id));
220 }
221 activations.find(id)->second->redundancyPriority =
222 std::make_unique<RedundancyPriority>(
Saqib Khanba239882017-05-26 08:41:54 -0500223 bus,
224 path,
Saqib Khan1eef62d2017-08-10 15:29:34 -0500225 *(activations.find(id)->second),
226 priority);
227 }
228
229 // Create Version instance for this version.
230 versions.insert(std::make_pair(
231 id,
232 std::make_unique<
233 phosphor::software::manager::Version>(
234 bus,
235 path,
236 version,
237 purpose,
Eddie James9440f492017-08-30 11:34:16 -0500238 "")));
Saqib Khan1eef62d2017-08-10 15:29:34 -0500239 }
240 }
Saqib Khanba239882017-05-26 08:41:54 -0500241 return;
242}
243
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500244void ItemUpdater::erase(std::string entryId)
245{
Eddie James6d873712017-09-01 11:29:07 -0500246 // Find entry in versions map
247 auto it = versions.find(entryId);
248 if (it != versions.end())
249 {
250 if (it->second->isFunctional())
251 {
252 log<level::ERR>(("Error: Version " + entryId + \
253 " is currently running on the BMC." \
254 " Unable to remove.").c_str());
255 return;
256 }
257
258 // Delete ReadOnly partitions if it's not active
259 removeReadOnlyPartition(entryId);
260 removeFile(entryId);
261 }
262 else
263 {
264 // Delete ReadOnly partitions even if we can't find the version
265 removeReadOnlyPartition(entryId);
266 removeFile(entryId);
267
268 log<level::ERR>(("Error: Failed to find version " + entryId + \
269 " in item updater versions map." \
270 " Unable to remove.").c_str());
271 return;
272 }
Saqib Khan1eef62d2017-08-10 15:29:34 -0500273
274 // Remove the priority environment variable.
275 auto serviceFile = "obmc-flash-bmc-setenv@" + entryId + ".service";
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);
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500283
284 // Removing entry in versions map
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500285 this->versions.erase(entryId);
286
287 // Removing entry in activations map
288 auto ita = activations.find(entryId);
289 if (ita == activations.end())
290 {
291 log<level::ERR>(("Error: Failed to find version " + entryId + \
Gunnar Mills9a782242017-08-22 16:23:15 -0500292 " in item updater activations map." \
293 " Unable to remove.").c_str());
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500294 return;
295 }
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500296
297 this->activations.erase(entryId);
298}
299
Michael Tritzbc1bf3a2017-09-18 16:38:23 -0500300void ItemUpdater::deleteAll()
301{
302 std::vector<std::string> deletableVersions;
303
304 for (const auto& versionIt : versions)
305 {
306 if (!versionIt.second->isFunctional())
307 {
308 deletableVersions.push_back(versionIt.first);
309 }
310 }
311
312 for (const auto& deletableIt : deletableVersions)
313 {
314 ItemUpdater::erase(deletableIt);
315 }
316
317 // Remove any volumes that do not match current versions.
318 auto method = bus.new_method_call(
319 SYSTEMD_BUSNAME,
320 SYSTEMD_PATH,
321 SYSTEMD_INTERFACE,
322 "StartUnit");
323 method.append("obmc-flash-bmc-cleanup.service", "replace");
324 bus.call_noreply(method);
325}
326
Saqib Khan35e83f32017-05-22 11:37:32 -0500327ItemUpdater::ActivationStatus ItemUpdater::validateSquashFSImage(
Gunnar Mills9a782242017-08-22 16:23:15 -0500328 const std::string& filePath)
Saqib Khan35e83f32017-05-22 11:37:32 -0500329{
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500330 bool invalid = false;
Saqib Khan35e83f32017-05-22 11:37:32 -0500331
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500332 for (auto& bmcImage : bmcImages)
Saqib Khan35e83f32017-05-22 11:37:32 -0500333 {
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500334 fs::path file(filePath);
335 file /= bmcImage;
336 std::ifstream efile(file.c_str());
337 if (efile.good() != 1)
338 {
339 log<level::ERR>("Failed to find the BMC image.",
Gunnar Mills9a782242017-08-22 16:23:15 -0500340 entry("IMAGE=%s", bmcImage.c_str()));
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500341 invalid = true;
342 }
Saqib Khan35e83f32017-05-22 11:37:32 -0500343 }
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500344
345 if (invalid)
Saqib Khan35e83f32017-05-22 11:37:32 -0500346 {
Saqib Khan35e83f32017-05-22 11:37:32 -0500347 return ItemUpdater::ActivationStatus::invalid;
348 }
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500349
350 return ItemUpdater::ActivationStatus::ready;
Saqib Khan35e83f32017-05-22 11:37:32 -0500351}
352
Saqib Khanb9da6632017-09-13 09:48:37 -0500353void ItemUpdater::freePriority(uint8_t value, const std::string& versionId)
Saqib Khan4c1aec02017-07-06 11:46:13 -0500354{
355 //TODO openbmc/openbmc#1896 Improve the performance of this function
356 for (const auto& intf : activations)
357 {
Gunnar Mills9a782242017-08-22 16:23:15 -0500358 if (intf.second->redundancyPriority)
Saqib Khan4c1aec02017-07-06 11:46:13 -0500359 {
Saqib Khanb9da6632017-09-13 09:48:37 -0500360 if (intf.second->redundancyPriority.get()->priority() == value &&
361 intf.second->versionId != versionId)
Saqib Khan4c1aec02017-07-06 11:46:13 -0500362 {
Gunnar Mills9a782242017-08-22 16:23:15 -0500363 intf.second->redundancyPriority.get()->priority(value + 1);
Saqib Khan4c1aec02017-07-06 11:46:13 -0500364 }
365 }
366 }
367}
368
Michael Tritz37a59042017-07-12 13:44:53 -0500369void ItemUpdater::reset()
370{
371 // Mark the read-write partition for recreation upon reboot.
372 auto method = bus.new_method_call(
373 SYSTEMD_BUSNAME,
374 SYSTEMD_PATH,
375 SYSTEMD_INTERFACE,
376 "StartUnit");
Michael Tritz0129d922017-08-10 19:33:46 -0500377 method.append("obmc-flash-bmc-setenv@rwreset\\x3dtrue.service", "replace");
Michael Tritz37a59042017-07-12 13:44:53 -0500378 bus.call_noreply(method);
379
380 log<level::INFO>("BMC factory reset will take effect upon reboot.");
381
382 return;
383}
384
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500385void ItemUpdater::removeReadOnlyPartition(std::string versionId)
386{
387 auto serviceFile = "obmc-flash-bmc-ubiro-remove@" + versionId +
388 ".service";
389
390 // Remove the read-only partitions.
391 auto method = bus.new_method_call(
392 SYSTEMD_BUSNAME,
393 SYSTEMD_PATH,
394 SYSTEMD_INTERFACE,
395 "StartUnit");
396 method.append(serviceFile, "replace");
397 bus.call_noreply(method);
398}
399
Michael Tritz0129d922017-08-10 19:33:46 -0500400bool ItemUpdater::fieldModeEnabled(bool value)
401{
402 // enabling field mode is intended to be one way: false -> true
403 if (value && !control::FieldMode::fieldModeEnabled())
404 {
405 control::FieldMode::fieldModeEnabled(value);
406
407 auto method = bus.new_method_call(
408 SYSTEMD_BUSNAME,
409 SYSTEMD_PATH,
410 SYSTEMD_INTERFACE,
411 "StartUnit");
412 method.append("obmc-flash-bmc-setenv@fieldmode\\x3dtrue.service",
Gunnar Mills9a782242017-08-22 16:23:15 -0500413 "replace");
Michael Tritz0129d922017-08-10 19:33:46 -0500414 bus.call_noreply(method);
415
416 method = bus.new_method_call(
417 SYSTEMD_BUSNAME,
418 SYSTEMD_PATH,
419 SYSTEMD_INTERFACE,
420 "StopUnit");
421 method.append("usr-local.mount", "replace");
422 bus.call_noreply(method);
423
424 std::vector<std::string> usrLocal = {"usr-local.mount"};
425
426 method = bus.new_method_call(
427 SYSTEMD_BUSNAME,
428 SYSTEMD_PATH,
429 SYSTEMD_INTERFACE,
430 "MaskUnitFiles");
431 method.append(usrLocal, false, true);
432 bus.call_noreply(method);
433 }
434
435 return control::FieldMode::fieldModeEnabled();
436}
437
438void ItemUpdater::restoreFieldModeStatus()
439{
440 std::ifstream input("/run/fw_env");
441 std::string envVar;
442 std::getline(input, envVar);
443
Gunnar Mills9a782242017-08-22 16:23:15 -0500444 if (envVar.find("fieldmode=true") != std::string::npos)
Michael Tritz0129d922017-08-10 19:33:46 -0500445 {
446 ItemUpdater::fieldModeEnabled(true);
447 }
448}
449
Gunnar Millsb60add12017-08-24 16:41:42 -0500450void ItemUpdater::setBMCInventoryPath()
451{
452 //TODO: openbmc/openbmc#1786 - Get the BMC path by looking for objects
453 // that implement the BMC inventory interface
454 auto depth = 0;
455 auto mapperCall = bus.new_method_call(MAPPER_BUSNAME,
456 MAPPER_PATH,
457 MAPPER_INTERFACE,
458 "GetSubTreePaths");
459
460 mapperCall.append(CHASSIS_INVENTORY_PATH);
461 mapperCall.append(depth);
462
463 // TODO: openbmc/openbmc#2226 - Add Inventory Item filter when
464 // mapper is fixed.
465 std::vector<std::string> filter = {};
466 mapperCall.append(filter);
467
468 auto response = bus.call(mapperCall);
469 if (response.is_method_error())
470 {
471 log<level::ERR>("Error in mapper GetSubTreePath");
472 return;
473 }
474
475 using ObjectPaths = std::vector<std::string>;
476 ObjectPaths result;
477 response.read(result);
478
479 if (result.empty())
480 {
481 log<level::ERR>("Invalid response from mapper");
482 return;
483 }
484
485 for (auto& iter : result)
486 {
487 const auto& path = iter;
488 if (path.substr(path.find_last_of('/') + 1).compare("bmc") == 0)
489 {
490 bmcInventoryPath = path;
491 return;
492 }
493 }
494}
495
Gunnar Millsf10b2322017-09-21 15:31:55 -0500496void ItemUpdater::createActiveAssociation(const std::string& path)
Gunnar Millsded875d2017-08-28 16:44:52 -0500497{
498 assocs.emplace_back(std::make_tuple(ACTIVE_FWD_ASSOCIATION,
499 ACTIVE_REV_ASSOCIATION,
500 path));
501 associations(assocs);
502}
503
Gunnar Mills88e8a322017-09-13 11:09:28 -0500504void ItemUpdater::createFunctionalAssociation(const std::string& path)
505{
506 assocs.emplace_back(std::make_tuple(FUNCTIONAL_FWD_ASSOCIATION,
507 FUNCTIONAL_REV_ASSOCIATION,
508 path));
509 associations(assocs);
510}
511
Gunnar Millsf10b2322017-09-21 15:31:55 -0500512void ItemUpdater::removeActiveAssociation(const std::string& path)
Gunnar Millsded875d2017-08-28 16:44:52 -0500513{
514 for (auto iter = assocs.begin(); iter != assocs.end();)
515 {
Gunnar Mills88e8a322017-09-13 11:09:28 -0500516 // Since there could be multiple associations to the same path,
517 // only remove ones that have an active forward association.
518 if ((std::get<0>(*iter)).compare(ACTIVE_FWD_ASSOCIATION) == 0 &&
519 (std::get<2>(*iter)).compare(path) == 0)
Gunnar Millsded875d2017-08-28 16:44:52 -0500520 {
521 iter = assocs.erase(iter);
522 associations(assocs);
523 }
524 else
525 {
526 ++iter;
527 }
528 }
529}
530
Saqib Khanb9da6632017-09-13 09:48:37 -0500531bool ItemUpdater::isLowestPriority(uint8_t value)
532{
533 for (const auto& intf : activations)
534 {
535 if(intf.second->redundancyPriority)
536 {
537 if (intf.second->redundancyPriority.get()->priority() < value)
538 {
539 return false;
540 }
541 }
542 }
543 return true;
544}
545
Gunnar Millsec1b41c2017-05-02 12:20:36 -0500546} // namespace updater
547} // namespace software
548} // namespace phosphor