Search in sources :

Example 1 with MultipleDiskVmElementValidator

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);
}
Also used : MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator)

Example 2 with MultipleDiskVmElementValidator

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);
}
Also used : MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator)

Example 3 with MultipleDiskVmElementValidator

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);
}
Also used : MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator)

Example 4 with MultipleDiskVmElementValidator

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);
    }
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Singleton(javax.inject.Singleton) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Inject(javax.inject.Inject) MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) DiskImageDao(org.ovirt.engine.core.dao.DiskImageDao) Map(java.util.Map) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskVmElementDao(org.ovirt.engine.core.dao.DiskVmElementDao) Collectors(java.util.stream.Collectors) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) DiskHandler(org.ovirt.engine.core.bll.storage.disk.DiskHandler) List(java.util.List) DiskDao(org.ovirt.engine.core.dao.DiskDao) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) AuditLogType(org.ovirt.engine.core.common.AuditLogType) Collections(java.util.Collections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Guid(org.ovirt.engine.core.compat.Guid) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 5 with MultipleDiskVmElementValidator

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);
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) CommandExecutionStatus(org.ovirt.engine.core.compat.backendcompat.CommandExecutionStatus) EngineException(org.ovirt.engine.core.common.errors.EngineException) VmTemplateDao(org.ovirt.engine.core.dao.VmTemplateDao) VmNicDao(org.ovirt.engine.core.dao.network.VmNicDao) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) CinderDisksValidator(org.ovirt.engine.core.bll.validator.storage.CinderDisksValidator) Map(java.util.Map) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) Instance(javax.enterprise.inject.Instance) CreateEntity(org.ovirt.engine.core.common.validation.group.CreateEntity) VmWatchdogValidator(org.ovirt.engine.core.bll.validator.VmWatchdogValidator) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) ONLY_NOT_SHAREABLE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_NOT_SHAREABLE) Stream(java.util.stream.Stream) CreateAllTemplateDisksParameters(org.ovirt.engine.core.common.action.CreateAllTemplateDisksParameters) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) VmIconIdSizePair(org.ovirt.engine.core.common.queries.VmIconIdSizePair) QuotaSanityParameter(org.ovirt.engine.core.bll.quota.QuotaSanityParameter) QuotaStorageDependent(org.ovirt.engine.core.bll.quota.QuotaStorageDependent) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskProfileHelper(org.ovirt.engine.core.bll.profiles.DiskProfileHelper) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) Permission(org.ovirt.engine.core.common.businessentities.Permission) ONLY_ACTIVE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_ACTIVE) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Pair(org.ovirt.engine.core.common.utils.Pair) CompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CompatibilityVersionUtils) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) EndProcedure(org.ovirt.engine.core.common.action.ActionParametersBase.EndProcedure) SealVmTemplateParameters(org.ovirt.engine.core.common.action.SealVmTemplateParameters) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) CpuProfileHelper(org.ovirt.engine.core.bll.profiles.CpuProfileHelper) SnapshotsValidator(org.ovirt.engine.core.bll.snapshots.SnapshotsValidator) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) EngineError(org.ovirt.engine.core.common.errors.EngineError) VM(org.ovirt.engine.core.common.businessentities.VM) CommandCallback(org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback) StorageDomainDao(org.ovirt.engine.core.dao.StorageDomainDao) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) IconValidator(org.ovirt.engine.core.bll.validator.IconValidator) UpdateAllTemplateDisksParameters(org.ovirt.engine.core.common.action.UpdateAllTemplateDisksParameters) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) ScheduledFuture(java.util.concurrent.ScheduledFuture) Date(java.util.Date) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) Version(org.ovirt.engine.core.compat.Version) ManagedScheduledExecutorService(javax.enterprise.concurrent.ManagedScheduledExecutorService) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IconUtils(org.ovirt.engine.core.bll.utils.IconUtils) CopyVolumeType(org.ovirt.engine.core.common.businessentities.storage.CopyVolumeType) DiskVmElementDao(org.ovirt.engine.core.dao.DiskVmElementDao) Collectors(java.util.stream.Collectors) VmDao(org.ovirt.engine.core.dao.VmDao) DiskHandler(org.ovirt.engine.core.bll.storage.disk.DiskHandler) List(java.util.List) VmValidator(org.ovirt.engine.core.bll.validator.VmValidator) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) QuotaVdsDependent(org.ovirt.engine.core.bll.quota.QuotaVdsDependent) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) LockProperties(org.ovirt.engine.core.common.action.LockProperties) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) ThreadPools(org.ovirt.engine.core.utils.threadpool.ThreadPools) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) Function(java.util.function.Function) Phase(org.ovirt.engine.core.common.action.AddVmTemplateParameters.Phase) UpdateVmVersionParameters(org.ovirt.engine.core.common.action.UpdateVmVersionParameters) CommandCoordinatorUtil(org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExecutionHandler(org.ovirt.engine.core.bll.job.ExecutionHandler) StorageDomainStaticDao(org.ovirt.engine.core.dao.StorageDomainStaticDao) ImagesHandler(org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) Typed(javax.enterprise.inject.Typed) PermissionDao(org.ovirt.engine.core.dao.PermissionDao) QuotaStorageConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters) TimeUnit(java.util.concurrent.TimeUnit) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) MultipleDiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Aggregations

MultipleDiskVmElementValidator (org.ovirt.engine.core.bll.validator.storage.MultipleDiskVmElementValidator)6 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3 DiskHandler (org.ovirt.engine.core.bll.storage.disk.DiskHandler)3 DisksFilter (org.ovirt.engine.core.bll.storage.disk.image.DisksFilter)3 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 Guid (org.ovirt.engine.core.compat.Guid)3 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Function (java.util.function.Function)2 StringUtils (org.apache.commons.lang.StringUtils)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2