Search in sources :

Example 96 with ValidationResult

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

the class ValidateVmMacsQueryTest method testExecuteQueryCommand.

@Test
public void testExecuteQueryCommand() {
    final VM vm1 = createVm(VM_ID1);
    final VM vm2 = createVm(VM_ID2);
    vms.add(vm1);
    vms.add(vm2);
    when(vmMacsValidation.validate(vm2)).thenReturn(new ValidationResult(EngineMessage.Unassigned, REPLACEMENT1, REPLACEMENT2));
    getQuery().executeQueryCommand();
    final QueryReturnValue queryReturnValue = getQuery().getQueryReturnValue();
    final Map<Guid, List<List<String>>> actual = queryReturnValue.getReturnValue();
    assertValidVmInOutput(actual, VM_ID1);
    assertInvalidVmInOutput(actual, VM_ID2, VALIDATION_MESSAGES);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test) AbstractQueryTest(org.ovirt.engine.core.bll.AbstractQueryTest)

Example 97 with ValidationResult

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

the class ExportOvaCommand method validateTargetFolder.

private ValidationResult validateTargetFolder() {
    AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("target_directory", getParameters().getDirectory()), new Pair<>("validate_only", "True")).logFileDirectory(CreateOvaCommand.CREATE_OVA_LOG_DIRECTORY).logFilePrefix("ovirt-export-ova-validate-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.EXPORT_OVA_PLAYBOOK);
    boolean succeeded = false;
    try {
        succeeded = ansibleExecutor.runCommand(command).getAnsibleReturnCode() == AnsibleReturnCode.OK;
    } catch (IOException | InterruptedException e) {
        log.error("Invalid target for OVA (directory={}, host={}): {}", getParameters().getDirectory(), getVdsName(), e.getMessage());
        log.debug("Exception", e);
    }
    return succeeded ? ValidationResult.VALID : new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_INVALID_OVA_DESTINATION_FOLDER, String.format("$vdsName %s", getVdsName()), String.format("$directory %s", getParameters().getDirectory()));
}
Also used : AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) IOException(java.io.IOException) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 98 with ValidationResult

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

the class HostValidator method hostStatusLegalForSetupNetworks.

private ValidationResult hostStatusLegalForSetupNetworks() {
    VDSStatus hostStatus = host.getStatus();
    boolean hostStatusLegalForSetupNetworks = LEGAL_STATUSES.contains(hostStatus) || hostStatus == VDSStatus.Installing && internalExecution;
    if (!hostStatusLegalForSetupNetworks) {
        logger.error("Unable to setup network: operation can only be done when Host status is one of: {};" + " current status is {}", LEGAL_STATUSES_STR, hostStatus);
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL, ReplacementUtils.replaceWith(VAR_HOST_STATUS, LEGAL_STATUSES, ",", LEGAL_STATUSES.size()));
    }
    return ValidationResult.VALID;
}
Also used : VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 99 with ValidationResult

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

the class HostValidator method validate.

public ValidationResult validate() {
    ValidationResult vr = ValidationResult.VALID;
    vr = skipValidation(vr) ? vr : hostExist();
    vr = skipValidation(vr) ? vr : hostStatusLegalForSetupNetworks();
    return vr;
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 100 with ValidationResult

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

the class NicLabelValidator method validNewOrModifiedLabels.

public ValidationResult validNewOrModifiedLabels() {
    ValidationResult vr = ValidationResult.VALID;
    Iterator<NicLabel> iterator = params.getLabels().iterator();
    while (iterator.hasNext() && vr.isValid()) {
        NicLabel nicLabel = iterator.next();
        vr = skipValidation(vr) ? vr : validateCoherentNicIdentification(nicLabel);
        vr = skipValidation(vr) ? vr : nicActuallyExistsOrReferencesNewBond(nicLabel);
        vr = skipValidation(vr) ? vr : labelBeingAttachedToNonVlanNonSlaveInterface(nicLabel);
        vr = skipValidation(vr) ? vr : labelBeingAttachedToValidBond(nicLabel);
    }
    return vr;
}
Also used : NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

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