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;
}
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());
}
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;
}
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;
}
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)));
}
}
Aggregations