Search in sources :

Example 1 with CountMacUsageDifference

use of org.ovirt.engine.core.bll.snapshots.CountMacUsageDifference in project ovirt-engine by oVirt.

the class MacsUsedAcrossWholeSystem method calculateAllMacsUsedInVmAndItsSnapshot.

private Stream<String> calculateAllMacsUsedInVmAndItsSnapshot(List<? extends VmNic> vmInterfaces, List<? extends VmNic> snapshotInterfaces) {
    CountMacUsageDifference countMacUsageDifference = new CountMacUsageDifference(macAddressesOfInterfaces(snapshotInterfaces), macAddressesOfInterfaces(vmInterfaces));
    Stream<String> macsDuplicatedByNumberOfTimesTheyAreUsed = countMacUsageDifference.maxUsage().entrySet().stream().flatMap(entry -> LongStream.range(0, entry.getValue()).boxed().map(e -> entry.getKey()));
    return macsDuplicatedByNumberOfTimesTheyAreUsed;
}
Also used : CountMacUsageDifference(org.ovirt.engine.core.bll.snapshots.CountMacUsageDifference) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) LongStream(java.util.stream.LongStream) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) Singleton(javax.inject.Singleton) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) VmDao(org.ovirt.engine.core.dao.VmDao) VmNicDao(org.ovirt.engine.core.dao.network.VmNicDao) Inject(javax.inject.Inject) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Stream(java.util.stream.Stream) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) SnapshotsManager(org.ovirt.engine.core.bll.snapshots.SnapshotsManager) Map(java.util.Map) Optional(java.util.Optional) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) CountMacUsageDifference(org.ovirt.engine.core.bll.snapshots.CountMacUsageDifference)

Example 2 with CountMacUsageDifference

use of org.ovirt.engine.core.bll.snapshots.CountMacUsageDifference in project ovirt-engine by oVirt.

the class UpdateVmInterfaceCommand method initMacPoolData.

void initMacPoolData() {
    macShouldBeChanged = !StringUtils.equals(oldIface.getMacAddress(), getMacAddress());
    countMacUsageDifference = new CountMacUsageDifference(snapshotsManager.macsInStatelessSnapshot(getVmId()), macsWhichShouldExistAfterCommandIsFinished());
}
Also used : CountMacUsageDifference(org.ovirt.engine.core.bll.snapshots.CountMacUsageDifference)

Aggregations

CountMacUsageDifference (org.ovirt.engine.core.bll.snapshots.CountMacUsageDifference)2 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 LongStream (java.util.stream.LongStream)1 Stream (java.util.stream.Stream)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 SnapshotsManager (org.ovirt.engine.core.bll.snapshots.SnapshotsManager)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)1 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)1 Guid (org.ovirt.engine.core.compat.Guid)1 ClusterDao (org.ovirt.engine.core.dao.ClusterDao)1 VmDao (org.ovirt.engine.core.dao.VmDao)1 VmNicDao (org.ovirt.engine.core.dao.network.VmNicDao)1