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