Search in sources :

Example 96 with Version

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;
}
Also used : Version(org.ovirt.engine.core.compat.Version) ArrayList(java.util.ArrayList) VmNicValidator(org.ovirt.engine.core.bll.validator.VmNicValidator) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 97 with Version

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;
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Backend(org.ovirt.engine.core.bll.Backend) Predicate(java.util.function.Predicate) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) GlusterVolumeVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeVDSParameters) GlusterGeoRepDao(org.ovirt.engine.core.dao.gluster.GlusterGeoRepDao) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Inject(javax.inject.Inject) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) Map(java.util.Map) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) Version(org.ovirt.engine.core.compat.Version) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) HashMap(java.util.HashMap) Version(org.ovirt.engine.core.compat.Version) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepNonEligibilityReason(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepNonEligibilityReason) Guid(org.ovirt.engine.core.compat.Guid) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) Predicate(java.util.function.Predicate)

Example 98 with Version

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;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) Version(org.ovirt.engine.core.compat.Version)

Example 99 with Version

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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Version(org.ovirt.engine.core.compat.Version) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 100 with Version

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);
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version)

Aggregations

Version (org.ovirt.engine.core.compat.Version)102 ArrayList (java.util.ArrayList)24 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)20 Guid (org.ovirt.engine.core.compat.Guid)20 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)17 Map (java.util.Map)16 List (java.util.List)15 HashSet (java.util.HashSet)14 VDS (org.ovirt.engine.core.common.businessentities.VDS)14 HashMap (java.util.HashMap)13 ServerCpu (org.ovirt.engine.core.common.businessentities.ServerCpu)12 VM (org.ovirt.engine.core.common.businessentities.VM)11 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)11 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)11 Arrays (java.util.Arrays)10 MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)10 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)10 Collection (java.util.Collection)9 Collections (java.util.Collections)9 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)9