Search in sources :

Example 1 with HostValidator

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

the class CreateBrickCommand method validate.

@Override
protected boolean validate() {
    Cluster cluster = getCluster();
    if (!cluster.supportsGlusterService()) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_PROVISIONING_NOT_SUPPORTED_BY_CLUSTER);
    }
    HostValidator validator = HostValidator.createInstance(getVds());
    if (!validate(validator.isUp())) {
        return false;
    }
    String deviceType;
    if (getParameters().getDisks() == null || getParameters().getDisks().isEmpty()) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DEVICE_REQUIRED);
        return false;
    } else {
        deviceType = getParameters().getDisks().get(0).getDevType();
    }
    for (StorageDevice device : getParameters().getDisks()) {
        // for performance reasons.
        if (!Objects.equals(deviceType, device.getDevType())) {
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DIFFERENT_STORAGE_DEVICE_TYPES_SELECTED);
            return false;
        }
        // Ensure that device is not already used by some other brick or LVM.
        if (!device.getCanCreateBrick()) {
            addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DEVICE_IS_ALREADY_IN_USE);
            addValidationMessageVariable("storageDevice", device.getName());
            return false;
        }
    }
    return true;
}
Also used : StorageDevice(org.ovirt.engine.core.common.businessentities.gluster.StorageDevice) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HostValidator(org.ovirt.engine.core.bll.validator.HostValidator)

Example 2 with HostValidator

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

the class AddVdsCommand method validate.

@Override
protected boolean validate() {
    T params = getParameters();
    setClusterId(params.getVdsStaticData().getClusterId());
    params.setVdsForUniqueId(null);
    // Check if this is a valid cluster
    boolean returnValue = validateCluster();
    if (returnValue) {
        HostValidator validator = getHostValidator();
        returnValue = validate(validator.nameNotEmpty()) && validate(validator.nameLengthIsLegal()) && validate(validator.hostNameIsValid()) && validate(validator.nameNotUsed()) && validate(validator.hostNameNotUsed()) && validate(validator.portIsValid()) && validate(validator.sshUserNameNotEmpty()) && validate(validator.validateSingleHostAttachedToLocalStorage()) && validate(validator.securityKeysExists()) && validate(validator.provisioningComputeResourceValid(params.isProvisioned(), params.getComputeResource())) && validate(validator.provisioningHostGroupValid(params.isProvisioned(), params.getHostGroup())) && validate(validator.passwordNotEmpty(params.isPending(), params.getAuthMethod(), params.getPassword())) && validate(validator.supportsDeployingHostedEngine(params.getHostedEngineDeployConfiguration()));
    }
    if (!(returnValue && isPowerManagementLegal(params.getVdsStaticData().isPmEnabled(), params.getFenceAgents(), getCluster().getCompatibilityVersion().toString(), true) && canConnect(params.getvds()))) {
        return false;
    }
    if (!validateNetworkProviderConfiguration(getParameters().getVdsStaticData().getOpenstackNetworkProviderId(), getParameters().getNetworkMappings())) {
        return false;
    }
    if (isGlusterSupportEnabled() && clusterHasNonInitializingServers()) {
        // allow simultaneous installation of hosts, but if a host has completed install, only
        // allow addition of another host if it can be peer probed to cluster.
        VDS upServer = glusterUtil.getUpServer(getClusterId());
        if (upServer == null) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_NO_GLUSTER_HOST_TO_PEER_PROBE);
        }
    }
    return true;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) HostValidator(org.ovirt.engine.core.bll.validator.HostValidator)

Example 3 with HostValidator

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

the class ExportOvaCommand method validate.

@Override
protected boolean validate() {
    if (getVm() == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_FOUND);
    }
    if (getParameters().getProxyHostId() == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_PROXY_HOST_MUST_BE_SPECIFIED);
    }
    HostValidator hostValidator = HostValidator.createInstance(getVds());
    if (!validate(hostValidator.hostExists())) {
        return false;
    }
    if (!validate(hostValidator.isUp())) {
        return false;
    }
    StoragePoolValidator spValidator = new StoragePoolValidator(getStoragePool());
    if (!validate(spValidator.exists())) {
        return false;
    }
    if (!validate(spValidator.isInStatus(StoragePoolStatus.Up))) {
        return false;
    }
    if (!getStoragePoolId().equals(getVds().getStoragePoolId())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_PROXY_HOST_NOT_IN_VM_DATA_CENTER);
    }
    if (!validate(validateTargetFolder())) {
        return false;
    }
    return true;
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) HostValidator(org.ovirt.engine.core.bll.validator.HostValidator)

Aggregations

HostValidator (org.ovirt.engine.core.bll.validator.HostValidator)3 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 StorageDevice (org.ovirt.engine.core.common.businessentities.gluster.StorageDevice)1