use of org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator in project ovirt-engine by oVirt.
the class RunVmValidatorTest method mockPassDiscardSupport.
private void mockPassDiscardSupport(ValidationResult validationResult) {
doReturn(Collections.emptyList()).when(runVmValidator).getVmDisks();
doReturn(Collections.emptyMap()).when(runVmValidator).getVmDiskVmElementMap();
MultipleDiskVmElementValidator multipleDiskVmElementValidator = mock(MultipleDiskVmElementValidator.class);
doReturn(multipleDiskVmElementValidator).when(runVmValidator).createMultipleDiskVmElementValidator(any());
when(multipleDiskVmElementValidator.isPassDiscardSupportedForDestSds(any())).thenReturn(validationResult);
}
use of org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator in project ovirt-engine by oVirt.
the class MoveOrCopyDiskCommandTest method mockPassDiscardSupportedForDestSd.
private void mockPassDiscardSupportedForDestSd(ValidationResult validationResult, ImageOperation imageOperation) {
command.getParameters().setOperation(imageOperation);
MultipleDiskVmElementValidator multipleDiskVmElementValidator = mock(MultipleDiskVmElementValidator.class);
doReturn(multipleDiskVmElementValidator).when(command).createMultipleDiskVmElementValidator();
when(multipleDiskVmElementValidator.isPassDiscardSupportedForDestSd(any())).thenReturn(validationResult);
}
use of org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator in project ovirt-engine by oVirt.
the class AddVmTemplateCommandTest method mockPassDiscardSupportedForDestSds.
private void mockPassDiscardSupportedForDestSds(ValidationResult validationResult) {
cmd.diskInfoDestinationMap = Collections.emptyMap();
MultipleDiskVmElementValidator multipleDiskVmElementValidator = mock(MultipleDiskVmElementValidator.class);
doReturn(multipleDiskVmElementValidator).when(cmd).createMultipleDiskVmElementValidator(any());
when(multipleDiskVmElementValidator.isPassDiscardSupportedForDestSds(any())).thenReturn(validationResult);
}
use of org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator in project ovirt-engine by oVirt.
the class BlockStorageDiscardFunctionalityHelper method logIfDisksWithIllegalPassDiscardExist.
public void logIfDisksWithIllegalPassDiscardExist(Guid vmId) {
Collection<DiskImage> disks = DisksFilter.filterImageDisks(diskDao.getAllForVm(vmId));
Collection<DiskVmElement> diskVmElements = diskVmElementDao.getAllForVm(vmId);
Map<Disk, DiskVmElement> diskToDiskVmElement = diskHandler.getDiskToDiskVmElementMap(disks, diskVmElements);
Map<Guid, Guid> diskIdToDestSdId = disks.stream().collect(Collectors.toMap(DiskImage::getId, diskImage -> diskImage.getStorageIds().get(0)));
MultipleDiskVmElementValidator multipleDiskVmElementValidator = new MultipleDiskVmElementValidator(diskToDiskVmElement);
Collection<Guid> disksWithoutSupportForPassDiscard = multipleDiskVmElementValidator.getDisksWithoutSupportForPassDiscard(diskIdToDestSdId);
if (!disksWithoutSupportForPassDiscard.isEmpty()) {
AuditLogable auditLog = new AuditLogableImpl();
auditLog.addCustomValue("DisksIds", disksWithoutSupportForPassDiscard.stream().map(Guid::toString).collect(Collectors.joining(", ")));
auditLogDirector.log(auditLog, AuditLogType.DISKS_WITH_ILLEGAL_PASS_DISCARD_EXIST);
}
}
use of org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator in project ovirt-engine by oVirt.
the class AddVmTemplateCommand method isPassDiscardSupportedForImagesDestSds.
protected ValidationResult isPassDiscardSupportedForImagesDestSds() {
Map<Disk, DiskVmElement> diskToDiskVmElement = diskHandler.getDiskToDiskVmElementMap(getVm().getId(), diskInfoDestinationMap);
Map<Guid, Guid> diskIdToDestSdId = diskInfoDestinationMap.values().stream().collect(Collectors.toMap(DiskImage::getId, diskImage -> diskImage.getStorageIds().get(0)));
MultipleDiskVmElementValidator multipleDiskVmElementValidator = createMultipleDiskVmElementValidator(diskToDiskVmElement);
return multipleDiskVmElementValidator.isPassDiscardSupportedForDestSds(diskIdToDestSdId);
}
Aggregations