Search in sources :

Example 21 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster 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 22 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class CreateGlusterVolumeCommand method validate.

@Override
protected boolean validate() {
    if (!super.validate()) {
        return false;
    }
    Cluster cluster = getCluster();
    if (cluster == null) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CLUSTER_IS_NOT_VALID);
        return false;
    }
    if (!cluster.supportsGlusterService()) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CLUSTER_DOES_NOT_SUPPORT_GLUSTER);
        return false;
    }
    if (getVolume().getVolumeType().isDispersedType()) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_CREATION_OF_DISPERSE_VOLUME_NOT_SUPPORTED);
        return false;
    }
    if (volumeNameExists(getVolume().getName())) {
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_VOLUME_NAME_ALREADY_EXISTS);
        addValidationMessageVariable("volumeName", getVolume().getName());
        return false;
    }
    if (getVolume().getIsArbiter()) {
        if (!GlusterFeatureSupported.glusterArbiterVolumeSupported(getCluster().getCompatibilityVersion())) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_ARBITER_VOLUME_NOT_SUPPORTED);
        }
        if (!getVolume().getVolumeType().isReplicatedType() || getVolume().getReplicaCount() != 3) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_ARBITER_VOLUME_SHOULD_BE_REPLICA_3_VOLUME);
        }
    }
    return validateBricks(getVolume());
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 23 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class VdsNotRespondingTreatmentCommand method shouldFencingBeSkipped.

private boolean shouldFencingBeSkipped(VDS vds) {
    // check if fencing in cluster is enabled
    Cluster cluster = clusterDao.get(vds.getClusterId());
    if (cluster != null && !cluster.getFencingPolicy().isFencingEnabled()) {
        AuditLogable alb = createAuditLogableForHost(vds);
        auditLogDirector.log(alb, AuditLogType.VDS_ALERT_FENCE_DISABLED_BY_CLUSTER_POLICY);
        return true;
    }
    // check if connectivity is not broken
    if (isConnectivityBrokenThresholdReached(getVds())) {
        return true;
    }
    // fencing will be executed
    return false;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 24 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class VdsNotRespondingTreatmentCommand method isConnectivityBrokenThresholdReached.

private boolean isConnectivityBrokenThresholdReached(VDS vds) {
    Cluster cluster = clusterDao.get(vds.getClusterId());
    int percents = 0;
    boolean result = false;
    if (cluster.getFencingPolicy().isSkipFencingIfConnectivityBroken()) {
        List<VDS> hosts = vdsDao.getAllForCluster(cluster.getId());
        double hostsNumber = hosts.size();
        double hostsWithBrokenConnectivityNumber = hosts.stream().filter(h -> h.getStatus() == VDSStatus.Connecting || h.getStatus() == VDSStatus.NonResponsive).count();
        percents = (int) ((hostsWithBrokenConnectivityNumber / hostsNumber) * 100);
        result = percents >= cluster.getFencingPolicy().getHostsWithBrokenConnectivityThreshold();
    }
    if (result) {
        logAlert(vds, percents);
    }
    return result;
}
Also used : ClusterDao(org.ovirt.engine.core.dao.ClusterDao) NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) LockProperties(org.ovirt.engine.core.common.action.LockProperties) HashMap(java.util.HashMap) HostValidator(org.ovirt.engine.core.bll.validator.HostValidator) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) ThreadUtils(org.ovirt.engine.core.utils.ThreadUtils) VdsDao(org.ovirt.engine.core.dao.VdsDao) Map(java.util.Map) SetStoragePoolStatusParameters(org.ovirt.engine.core.common.action.SetStoragePoolStatusParameters) PreviousHostedEngineHost(org.ovirt.engine.core.bll.hostedengine.PreviousHostedEngineHost) FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Pair(org.ovirt.engine.core.common.utils.Pair) Config(org.ovirt.engine.core.common.config.Config) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) MonitoringStrategyFactory(org.ovirt.engine.core.vdsbroker.monitoring.MonitoringStrategyFactory) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) VdsCommand(org.ovirt.engine.core.bll.VdsCommand) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) HostLocking(org.ovirt.engine.core.bll.HostLocking) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) VDS(org.ovirt.engine.core.common.businessentities.VDS) VDS(org.ovirt.engine.core.common.businessentities.VDS) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 25 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class GetAvailableStoragePoolVersionsQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    if (getParameters().getId() != null) {
        ArrayList<Version> result = new ArrayList<>();
        StoragePool storagePool = storagePoolDao.get(getParameters().getId());
        if (storagePool != null) {
            List<Cluster> clusters = clusterDao.getAllForStoragePool(storagePool.getId(), getUserID(), getParameters().isFiltered());
            for (Version supportedVer : Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels)) {
                // decrease version
                if (supportedVer.compareTo(storagePool.getCompatibilityVersion()) < 0) {
                    continue;
                }
                boolean versionOk = true;
                // check all clusters are not grater than this ver
                for (Cluster cluster : clusters) {
                    if (supportedVer.compareTo(cluster.getCompatibilityVersion()) > 0) {
                        versionOk = false;
                        break;
                    }
                }
                if (versionOk) {
                    result.add(supportedVer);
                }
            }
        }
        getQueryReturnValue().setReturnValue(result);
    } else {
        getQueryReturnValue().setReturnValue(new ArrayList<>(Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels)));
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Version(org.ovirt.engine.core.compat.Version) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HashSet(java.util.HashSet)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)346 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)80 Guid (org.ovirt.engine.core.compat.Guid)77 VDS (org.ovirt.engine.core.common.businessentities.VDS)54 List (java.util.List)50 VM (org.ovirt.engine.core.common.businessentities.VM)36 HashMap (java.util.HashMap)35 Map (java.util.Map)33 HashSet (java.util.HashSet)30 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)30 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)28 Version (org.ovirt.engine.core.compat.Version)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)26 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)26 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)25 Set (java.util.Set)24 QueryType (org.ovirt.engine.core.common.queries.QueryType)23 Collections (java.util.Collections)22 Frontend (org.ovirt.engine.ui.frontend.Frontend)22