use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class UpdateStoragePoolCommand method validate.
@Override
protected boolean validate() {
StoragePoolValidator spValidator = createStoragePoolValidator();
if (!validate(spValidator.exists())) {
return false;
}
// Name related validations
if (!StringUtils.equals(getOldStoragePool().getName(), getStoragePool().getName()) && !isStoragePoolUnique(getStoragePool().getName())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_POOL_NAME_ALREADY_EXIST);
}
if (!checkStoragePoolNameLengthValid()) {
return false;
}
List<StorageDomainStatic> poolDomains = storageDomainStaticDao.getAllForStoragePool(getStoragePool().getId());
if (getOldStoragePool().isLocal() && !getStoragePool().isLocal() && poolDomains.stream().anyMatch(sdc -> sdc.getStorageType() == StorageType.LOCALFS)) {
return failValidation(EngineMessage.ERROR_CANNOT_CHANGE_STORAGE_POOL_TYPE_WITH_LOCAL);
}
if (!getOldStoragePool().isLocal() && getStoragePool().isLocal()) {
List<Cluster> clusters = clusterDao.getAllForStoragePool(getStoragePool().getId());
if (clusters.size() > 1) {
return failValidation(EngineMessage.CLUSTER_CANNOT_ADD_MORE_THEN_ONE_HOST_TO_LOCAL_STORAGE);
}
List<VDS> hosts = vdsDao.getAllForStoragePool(getStoragePool().getId());
if (hosts.size() > 1) {
return failValidation(EngineMessage.VDS_CANNOT_ADD_MORE_THEN_ONE_HOST_TO_LOCAL_STORAGE);
}
}
if (!getOldStoragePool().getCompatibilityVersion().equals(getStoragePool().getCompatibilityVersion())) {
if (!isStoragePoolVersionSupported()) {
return failValidation(VersionSupport.getUnsupportedVersionMessage());
} else // decreasing of compatibility version is allowed under conditions
if (getStoragePool().getCompatibilityVersion().compareTo(getOldStoragePool().getCompatibilityVersion()) < 0) {
if (!poolDomains.isEmpty() && !isCompatibilityVersionChangeAllowedForDomains(poolDomains)) {
return false;
}
List<Network> networks = networkDao.getAllForDataCenter(getStoragePoolId());
for (Network network : networks) {
NetworkValidator validator = getNetworkValidator(network);
if (!getManagementNetworkUtil().isManagementNetwork(network.getId()) || !validator.canNetworkCompatibilityBeDecreased()) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_CANNOT_DECREASE_DATA_CENTER_COMPATIBILITY_VERSION);
}
}
} else if (!checkAllClustersLevel()) {
// Check all clusters has at least the same compatibility version.
return false;
}
}
return validate(spValidator.isNotLocalfsWithDefaultCluster()) && validate(allMacsInEveryClusterCanBeMigratedToAnotherPool());
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class VideoDeviceSettings method getVideoDeviceSettings.
private Map<String, Integer> getVideoDeviceSettings(VmBase vmBase) {
Version vmVersion = vmBase.getCustomCompatibilityVersion();
Supplier<Version> clusterVersionSupplier = () -> clusterUtils.getCompatibilityVersion(vmBase);
if (CompatibilityVersionUtils.getEffective(vmVersion, clusterVersionSupplier).greaterOrEquals(Version.v3_6)) {
if (vmBase.getDefaultDisplayType() == DisplayType.qxl) {
return vgamemVideoSettings.getQxlVideoDeviceSettings(vmBase);
} else {
return vgamemVideoSettings.getVgaVideoDeviceSettings();
}
} else {
return legacyVideoSettings.getVideoDeviceSettings(vmBase);
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class AddVdsCommandTest method makeTestVds.
private VDS makeTestVds(Guid vdsId) {
VDS newVdsData = new VDS();
newVdsData.setHostName("BUZZ");
newVdsData.setSshPort(22);
newVdsData.setSshUsername("root");
newVdsData.setSshKeyFingerprint("1234");
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 AddVdsCommandTest method setupCommonMock.
private void setupCommonMock(boolean glusterEnabled) throws Exception {
mockHostValidator();
doReturn(glusterEnabled).when(command).isGlusterSupportEnabled();
doReturn(true).when(command).validateCluster();
doReturn(sshClient).when(command).getSSHClient();
Version version = new Version("1.2.3");
Cluster cluster = new Cluster();
cluster.setCompatibilityVersion(version);
doReturn(cluster).when(command).getCluster();
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class NetworkFilterDaoTest method testGetAllSupportedNetworkFiltersByVersion.
@Test
public void testGetAllSupportedNetworkFiltersByVersion() {
final Version version = new Version("4.0");
final List<NetworkFilter> allNetworkFilter = dao.getAllSupportedNetworkFiltersByVersion(version);
assertNotNull(allNetworkFilter);
assertEquals(3, allNetworkFilter.size());
NetworkFilter expectedNetworkFilter = initOvirtNoFilter();
assertEquals(expectedNetworkFilter, allNetworkFilter.get(1));
expectedNetworkFilter = expectedNetworkFilter();
assertEquals(expectedNetworkFilter, allNetworkFilter.get(0));
}
Aggregations