use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class UpdateVmTemplateInterfaceCommand method validate.
@Override
protected boolean validate() {
if (!super.validate()) {
return false;
}
if (!validate(linkedToTemplate())) {
return false;
}
List<VmNic> interfaces = vmNicDao.getAllForTemplate(getParameters().getVmTemplateId());
if (!validate(templateExists())) {
return false;
}
// Interface oldIface = interfaces.First(i => i.id ==
// AddVmInterfaceParameters.Interface.id);
VmNic oldIface = interfaces.stream().filter(i -> i.getId().equals(getParameters().getInterface().getId())).findFirst().orElse(null);
if (oldIface == null) {
addValidationMessage(EngineMessage.VM_INTERFACE_NOT_EXIST);
return false;
}
if (!updateVnicForBackwardCompatibility(oldIface)) {
return false;
}
// not relevant for instance types - will be checked when a VM will be created out of it
if (getVmTemplate().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
Version clusterCompatibilityVersion = getCluster().getCompatibilityVersion();
VmNicValidator nicValidator = new VmNicValidator(getParameters().getInterface(), clusterCompatibilityVersion, getVmTemplate().getOsId());
if (!validate(nicValidator.isCompatibleWithOs()) || !validate(nicValidator.profileValid(getVmTemplate().getClusterId())) || !validate(nicValidator.typeMatchesProfile()) || !validate(nicValidator.passthroughIsLinked())) {
return false;
}
if (!checkPciAndIdeLimit(oldIface, new ArrayList<>(interfaces), clusterCompatibilityVersion)) {
return false;
}
}
if (!StringUtils.equals(oldIface.getName(), getInterfaceName()) && !interfaceNameUnique(interfaces)) {
return false;
}
return true;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class GlusterGeoRepUtil method getEligibilityPredicates.
public Map<GlusterGeoRepNonEligibilityReason, Predicate<GlusterVolumeEntity>> getEligibilityPredicates(final GlusterVolumeEntity masterVolume) {
Map<GlusterGeoRepNonEligibilityReason, Predicate<GlusterVolumeEntity>> eligibilityPredicates = new HashMap<>();
final List<Guid> existingSessionSlavesIds = getSessionSlaveVolumeIds();
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_BE_UP, slaveVolume -> slaveVolume.getStatus() == GlusterStatus.UP);
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_AND_MASTER_VOLUMES_SHOULD_NOT_BE_IN_SAME_CLUSTER, slaveVolume -> !masterVolume.getClusterId().equals(slaveVolume.getClusterId()));
final Predicate<GlusterVolumeEntity> nonNullSlaveSizePredicate = slaveVolume -> slaveVolume.getAdvancedDetails().getCapacityInfo() != null;
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_TO_BE_AVAILABLE, nonNullSlaveSizePredicate);
final Predicate<GlusterVolumeEntity> nonNullMasterSizePredicate = slaveVolume -> masterVolume.getAdvancedDetails().getCapacityInfo() != null;
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.MASTER_VOLUME_SIZE_TO_BE_AVAILABLE, nonNullMasterSizePredicate);
Predicate<GlusterVolumeEntity> masterSlaveSizePredicate = slaveVolume -> {
boolean eligible = nonNullSlaveSizePredicate.test(slaveVolume) && nonNullMasterSizePredicate.test(masterVolume);
if (eligible) {
eligible = slaveVolume.getAdvancedDetails().getCapacityInfo().getTotalSize() >= masterVolume.getAdvancedDetails().getCapacityInfo().getTotalSize();
}
return eligible;
};
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SIZE_SHOULD_BE_GREATER_THAN_MASTER_VOLUME_SIZE, masterSlaveSizePredicate);
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_SHOULD_NOT_BE_SLAVE_OF_ANOTHER_GEO_REP_SESSION, slaveVolume -> !existingSessionSlavesIds.contains(slaveVolume.getId()));
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_CLUSTER_AND_MASTER_CLUSTER_COMPATIBILITY_VERSIONS_DO_NOT_MATCH, slaveVolume -> {
ClusterDao clusterDao = getClusterDao();
Version slaveCompatibilityVersion = clusterDao.get(slaveVolume.getClusterId()).getCompatibilityVersion();
Version masterCompatibilityVersion = clusterDao.get(masterVolume.getClusterId()).getCompatibilityVersion();
return masterCompatibilityVersion.equals(slaveCompatibilityVersion);
});
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.NO_UP_SLAVE_SERVER, slaveVolume -> {
Guid slaveUpserverId = getUpServerId(slaveVolume.getClusterId());
return slaveUpserverId != null;
});
eligibilityPredicates.put(GlusterGeoRepNonEligibilityReason.SLAVE_VOLUME_TO_BE_EMPTY, slaveVolume -> {
Guid slaveUpserverId = getUpServerId(slaveVolume.getClusterId());
return slaveUpserverId != null && checkEmptyGlusterVolume(slaveUpserverId, slaveVolume.getName());
});
return eligibilityPredicates;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class SlaValidatorTest method makeTestVds.
private VDS makeTestVds(Guid vdsId) {
VDS newVdsData = new VDS();
newVdsData.setHostName("BUZZ");
newVdsData.setVdsName("BAR");
newVdsData.setClusterCompatibilityVersion(new Version("1.2.3"));
newVdsData.setClusterId(Guid.newGuid());
newVdsData.setId(vdsId);
return newVdsData;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class BackendApiResourceTest method setUpGetUserBySessionExpectations.
protected void setUpGetUserBySessionExpectations() {
QueryReturnValue returnValue = new QueryReturnValue();
returnValue.setSucceeded(true);
DbUser dbUser = new DbUser();
dbUser.setId(Guid.Empty);
returnValue.setReturnValue(dbUser);
when(backend.runQuery(eq(QueryType.GetUserBySessionId), eqParams(QueryParametersBase.class, new String[0], new Object[0]))).thenReturn(returnValue);
QueryReturnValue productVersionQueryResult = new QueryReturnValue();
productVersionQueryResult.setSucceeded(true);
productVersionQueryResult.setReturnValue(new Version(MAJOR, MINOR, BUILD, REVISION));
when(backend.runQuery(eq(QueryType.GetProductVersion), getProductVersionParams())).thenReturn(productVersionQueryResult);
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class AbstractVmPopupWidget method updateUrandomLabel.
private void updateUrandomLabel(UnitVmModel model) {
final Version effectiveVersion = model.getCompatibilityVersion();
if (effectiveVersion == null) {
return;
}
final String urandomSourceLabel = effectiveVersion.greaterOrEquals(VmRngDevice.Source.FIRST_URANDOM_VERSION) ? constants.rngSourceUrandom() : constants.rngSourceRandom();
rngSourceUrandom.setLabel(urandomSourceLabel);
}
Aggregations