Search in sources :

Example 11 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class AbstractVmProviderProxy method chooseDcForCheckingIfGetNamesFromExternalProviderSupported.

private void chooseDcForCheckingIfGetNamesFromExternalProviderSupported() {
    Version chosenDataCenterVersion = null;
    Guid chosenDataCenterId = provider.getAdditionalProperties().getStoragePoolId();
    if (chosenDataCenterId == null) {
        // find data center with highest version
        for (StoragePool sp : storagePoolDao.getAllByStatus(StoragePoolStatus.Up)) {
            if (chosenDataCenterVersion == null || chosenDataCenterVersion.less(sp.getCompatibilityVersion())) {
                chosenDataCenterVersion = sp.getCompatibilityVersion();
                chosenDataCenterId = sp.getId();
            }
        }
        provider.getAdditionalProperties().setStoragePoolId(chosenDataCenterId);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Version(org.ovirt.engine.core.compat.Version) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with Version

use of org.ovirt.engine.core.compat.Version 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)

Example 13 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class UpdateClusterCommandTest method createClusterWithBadVersion.

private static Cluster createClusterWithBadVersion() {
    Cluster group = createNewCluster();
    group.setCompatibilityVersion(new Version(5, 0));
    return group;
}
Also used : Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 14 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class GetConfigurationValueQueryTest method assertQueryExecution.

private void assertQueryExecution(ConfigValues configValue, boolean isFiltered, boolean shouldSucceed) {
    // Mock the parameters
    Version version = RandomUtils.instance().pickRandom(Version.ALL);
    when(getQueryParameters().getVersion()).thenReturn(version.toString());
    when(getQueryParameters().getConfigValue()).thenReturn(configValue);
    when(getQueryParameters().isFiltered()).thenReturn(isFiltered);
    // Mock the config
    String expected = mockConfig(version, configValue);
    getQuery().executeQueryCommand();
    Object actual = getQuery().getQueryReturnValue().getReturnValue();
    if (shouldSucceed) {
        assertEquals("Got wrong expected value for " + configValue, expected, actual);
    } else {
        assertNull("Should get null result for " + configValue, actual);
    }
}
Also used : Version(org.ovirt.engine.core.compat.Version)

Example 15 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class GetProductVersionQueryTest method verifyVersionEqual.

private void verifyVersionEqual(Object returnValue, int major, int minor, int build) {
    Version version = (Version) returnValue;
    assertEquals(version.getMajor(), major);
    assertEquals(version.getMinor(), minor);
    assertEquals(version.getBuild(), build);
    assertEquals(0, version.getRevision());
}
Also used : 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