Search in sources :

Example 36 with ValidationResult

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

the class VmNicMacsUtilsTest method testValidateThereIsEnoughOfFreeMacsPositive.

@Test
public void testValidateThereIsEnoughOfFreeMacsPositive() {
    when(macPoolMock.getAvailableMacsCount()).thenReturn(1);
    final ValidationResult actual = underTest.validateThereIsEnoughOfFreeMacs(singletonList(vmNetworkInterfaceMock), macPoolMock, ALWAYS_TRUE);
    assertThat(actual, isValid());
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 37 with ValidationResult

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

the class AbstractSyncLunsCommandTest method testValidateVdsDoesNotExist.

@Test
public void testValidateVdsDoesNotExist() {
    when(hostValidator.hostExists()).thenReturn(new ValidationResult(EngineMessage.VDS_INVALID_SERVER_ID));
    assertFalse(command.validateVds());
    ValidateTestUtils.assertValidationMessages("", command, EngineMessage.VDS_INVALID_SERVER_ID);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 38 with ValidationResult

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

the class AbstractSyncLunsCommandTest method validateVdsIsNotUp.

@Test
public void validateVdsIsNotUp() {
    when(hostValidator.hostExists()).thenReturn(ValidationResult.VALID);
    when(hostValidator.isUp()).thenReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL));
    assertFalse(command.validateVds());
    ValidateTestUtils.assertValidationMessages("", command, EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 39 with ValidationResult

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

the class RemoveSnapshotCommand method validateSnapshotDisksArePlugged.

private boolean validateSnapshotDisksArePlugged() {
    Map<Guid, Disk> vmDisks = diskDao.getAllForVm(getVmId()).stream().collect(Collectors.toMap(Disk::getId, Function.identity()));
    // If there is an unattached disk, it will not be included in vmDisks, hence it is
    // retrieved by the diskDao. This is less likely to happen as it is not possible
    // to unattach disks with snapshots.
    String unpluggedDisks = getSourceImages().stream().map(DiskImage::getId).map(vmDiskId -> vmDisks.getOrDefault(vmDiskId, diskDao.get(vmDiskId))).filter(disk -> !disk.getPlugged()).map(Disk::getDiskAlias).collect(Collectors.joining(System.lineSeparator()));
    if (!unpluggedDisks.isEmpty()) {
        return validate(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_SNAPSHOT_HAS_UNPLUGGED_OR_UNATTACHED_DISKS, String.format("$diskAliases %s", unpluggedDisks)));
    }
    return true;
}
Also used : LockMessagesMatchUtil(org.ovirt.engine.core.bll.LockMessagesMatchUtil) StringUtils(org.apache.commons.lang.StringUtils) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) SnapshotDao(org.ovirt.engine.core.dao.SnapshotDao) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmTemplateDao(org.ovirt.engine.core.dao.VmTemplateDao) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) Map(java.util.Map) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Instance(javax.enterprise.inject.Instance) RemoveMemoryVolumesParameters(org.ovirt.engine.core.common.action.RemoveMemoryVolumesParameters) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) Collectors(java.util.stream.Collectors) ConcurrentChildCommandsExecutionCallback(org.ovirt.engine.core.bll.ConcurrentChildCommandsExecutionCallback) ONLY_NOT_SHAREABLE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_NOT_SHAREABLE) List(java.util.List) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) VmValidator(org.ovirt.engine.core.bll.validator.VmValidator) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) QuotaStorageDependent(org.ovirt.engine.core.bll.quota.QuotaStorageDependent) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) LockProperties(org.ovirt.engine.core.common.action.LockProperties) Guid(org.ovirt.engine.core.compat.Guid) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) Function(java.util.function.Function) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) CommandCoordinatorUtil(org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil) Inject(javax.inject.Inject) DiskImageDao(org.ovirt.engine.core.dao.DiskImageDao) OvfManager(org.ovirt.engine.core.utils.ovf.OvfManager) ONLY_ACTIVE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_ACTIVE) RemoveSnapshotSingleDiskParameters(org.ovirt.engine.core.common.action.RemoveSnapshotSingleDiskParameters) VmCommand(org.ovirt.engine.core.bll.VmCommand) Pair(org.ovirt.engine.core.common.utils.Pair) DisableInPrepareMode(org.ovirt.engine.core.bll.DisableInPrepareMode) ImagesHandler(org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) EndProcedure(org.ovirt.engine.core.common.action.ActionParametersBase.EndProcedure) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) Typed(javax.enterprise.inject.Typed) 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) DiskDao(org.ovirt.engine.core.dao.DiskDao) Collections(java.util.Collections) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 40 with ValidationResult

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

the class NetworkPolicyUnit method validatePassthroughVnics.

private ValidationResult validatePassthroughVnics(Guid vmId, VDS host, List<VmNetworkInterface> vnics) {
    VfScheduler vfScheduler = Injector.get(VfScheduler.class);
    List<String> problematicVnics = vfScheduler.validatePassthroughVnics(vmId, host.getId(), vnics);
    if (!problematicVnics.isEmpty()) {
        String vnicsString = StringUtils.join(problematicVnics, ", ");
        log.warn("host {} doesn't contain suitable virtual functions for VM nics {}", host.getName(), vnicsString);
        return new ValidationResult(EngineMessage.VAR__DETAIL__NO_SUITABLE_VF, String.format("$vnicNames %1$s", vnicsString));
    }
    return ValidationResult.VALID;
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) VfScheduler(org.ovirt.engine.core.bll.network.host.VfScheduler)

Aggregations

ValidationResult (org.ovirt.engine.core.bll.ValidationResult)239 Test (org.junit.Test)132 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)49 Guid (org.ovirt.engine.core.compat.Guid)40 ArrayList (java.util.ArrayList)31 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)31 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Network (org.ovirt.engine.core.common.businessentities.network.Network)21 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)19 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)16 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)12 List (java.util.List)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 HashSet (java.util.HashSet)10 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)10 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)9 StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)7 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)7