Search in sources :

Example 51 with ValidationResult

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

the class GlusterBrickValidator method canStopOrCommitRemoveBrick.

public ValidationResult canStopOrCommitRemoveBrick(GlusterVolumeEntity volumeEntity, List<GlusterBrickEntity> paramBricks) {
    GlusterAsyncTask asyncTask = volumeEntity.getAsyncTask();
    if (asyncTask == null || asyncTask.getType() != GlusterTaskType.REMOVE_BRICK) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_INVALID_TASK_TYPE);
    }
    if (paramBricks.isEmpty()) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_BRICKS_REQUIRED);
    }
    List<GlusterBrickEntity> bricksForTask = getGlusterBrickDao().getGlusterVolumeBricksByTaskId(asyncTask.getTaskId());
    if (paramBricks.size() != bricksForTask.size() || !areBricksInTheList(volumeEntity, paramBricks, bricksForTask)) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_REMOVE_BRICKS_PARAMS_INVALID, String.format("$validBricks [%s]", getValidBrickNames(bricksForTask)));
    }
    return ValidationResult.VALID;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 52 with ValidationResult

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

the class NetworkAttachmentIpConfigurationValidator method validateIpv6Configuration.

private ValidationResult validateIpv6Configuration(NetworkAttachment networkAttachment) {
    final IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
    if (!ipConfiguration.hasIpv6PrimaryAddressSet()) {
        return ValidationResult.VALID;
    }
    IpV6Address ipv6Address = ipConfiguration.getIpv6PrimaryAddress();
    String networkName = networkAttachment.getNetworkName();
    String nicName = networkAttachment.getNicName();
    if (ipv6Address.getBootProtocol() == null) {
        return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_MISSING_BOOT_PROTOCOL, networkName, nicName);
    }
    Ipv6BootProtocol bootProtocol = ipv6Address.getBootProtocol();
    if (bootProtocol == Ipv6BootProtocol.STATIC_IP) {
        if (!validStaticIpv6AddressDetails(ipv6Address)) {
            return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_STATIC_BOOT_PROTOCOL_MISSING_IP_ADDRESS_DETAILS, networkName, nicName);
        }
    } else {
        if (!isEmptyIpv6AddressDetails(ipv6Address)) {
            return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_INCOMPATIBLE_BOOT_PROTOCOL_AND_IP_ADDRESS_DETAILS, ReplacementUtils.createSetVariableString(VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(VAR_INTERFACE_NAME, nicName), ReplacementUtils.createSetVariableString(VAR_BOOT_PROTOCOL, bootProtocol.getDisplayName()));
        }
    }
    return ValidationResult.VALID;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) IpV6Address(org.ovirt.engine.core.common.businessentities.network.IpV6Address) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 53 with ValidationResult

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

the class MultipleVmsValidator method vmNotHavingPluggedDiskSnapshots.

/**
 * @return ValidationResult indicating whether there are plugged disk snapshots
 */
public ValidationResult vmNotHavingPluggedDiskSnapshots(EngineMessage message) {
    List<String> vmPluggedDiskSnapshotsInfo = null;
    for (VM vm : vms) {
        List<DiskImage> pluggedDiskSnapshots = DbFacade.getInstance().getDiskImageDao().getAttachedDiskSnapshotsToVm(vm.getId(), Boolean.TRUE);
        if (!pluggedDiskSnapshots.isEmpty()) {
            if (vmPluggedDiskSnapshotsInfo == null) {
                vmPluggedDiskSnapshotsInfo = new LinkedList<>();
            }
            List<String> pluggedDiskSnapshotAliases = new LinkedList<>();
            for (BaseDisk disk : pluggedDiskSnapshots) {
                pluggedDiskSnapshotAliases.add(disk.getDiskAlias());
            }
            vmPluggedDiskSnapshotsInfo.add(String.format("%s / %s", vm.getName(), StringUtils.join(pluggedDiskSnapshotAliases, ",")));
        }
    }
    if (vmPluggedDiskSnapshotsInfo != null) {
        return new ValidationResult(message, String.format("$disksInfo %s", String.format(StringUtils.join(vmPluggedDiskSnapshotsInfo, "%n"))));
    }
    return ValidationResult.VALID;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LinkedList(java.util.LinkedList)

Example 54 with ValidationResult

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

the class NetworkAttachmentValidator method networkExists.

public ValidationResult networkExists() {
    Guid networkId = attachment.getNetworkId();
    String networkName = attachment.getNetworkName();
    // User did not specify neither id nor name.
    if (networkId == null && networkName == null) {
        return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_NETWORK_ID_OR_NAME_IS_NOT_SET);
    }
    // User specified id, for which completors did not find Network record.
    if (networkId != null && networkName == null) {
        EngineMessage engineMessage = EngineMessage.NETWORK_HAVING_ID_NOT_EXISTS;
        return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, networkId.toString()));
    }
    // User specified name, for which completors did not find Network record.
    if (networkId == null && networkName != null) {
        EngineMessage engineMessage = EngineMessage.NETWORK_HAVING_NAME_NOT_EXISTS;
        return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, networkName));
    }
    return ValidationResult.VALID;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage)

Example 55 with ValidationResult

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

the class NetworkValidator method qosExistsInDc.

/**
 * @return An error iff the QoS entity attached to the network isn't null, but doesn't exist in the database or
 *         belongs to the wrong DC.
 */
public ValidationResult qosExistsInDc() {
    HostNetworkQosValidator qosValidator = new HostNetworkQosValidator(getDbFacade().getHostNetworkQosDao().get(network.getQosId()));
    ValidationResult res = qosValidator.qosExists();
    return (res == ValidationResult.VALID) ? qosValidator.consistentDataCenter() : res;
}
Also used : 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