use of org.ovirt.engine.core.common.businessentities.network.NetworkInterface in project ovirt-engine by oVirt.
the class SyncMacsOfDbNicsWithSnapshot method reallocateMacsWhichCouldntBeAddedToMacPool.
private void reallocateMacsWhichCouldntBeAddedToMacPool(List<String> macsFailedToBeAdded, List<? extends NetworkInterface> snapshotedNics) {
if (macsFailedToBeAdded.isEmpty()) {
return;
}
// not to ruin original for error reporting.
List<String> macsFailedToBeAddedCopy = new ArrayList<>(macsFailedToBeAdded);
try {
List<Pair<String, String>> macReplacements = new ArrayList<>();
for (NetworkInterface vmInterface : snapshotedNics) {
String originalMacAddress = vmInterface.getMacAddress();
if (macsFailedToBeAddedCopy.contains(originalMacAddress)) {
macsFailedToBeAddedCopy.remove(originalMacAddress);
String replacingMac = macPool.allocateNewMac();
vmInterface.setMacAddress(replacingMac);
macReplacements.add(new Pair<>(originalMacAddress, replacingMac));
}
}
auditLogPerformedReplacements(macReplacements);
} catch (EngineException ex) {
if (EngineError.MAC_POOL_NO_MACS_LEFT.equals(ex.getErrorCode())) {
auditLogImpossibilityToReplaceDuplicateMacs(macsFailedToBeAdded);
}
throw ex;
}
}
Aggregations