use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method setVmLeasesAvailability.
private void setVmLeasesAvailability() {
TModel model = getModel();
if (model.getSelectedCluster() == null) {
return;
}
Version compVer = model.getSelectedCluster().getCompatibilityVersion();
if (model.getCustomCompatibilityVersion().getSelectedItem() != null) {
compVer = model.getCustomCompatibilityVersion().getSelectedItem();
}
boolean vmLeasesSupported = AsyncDataProvider.getInstance().isVmLeasesFeatureSupported(compVer);
if (!vmLeasesSupported) {
model.getLease().setIsChangeable(false, constants.vmLeasesSupported());
} else {
model.getLease().setIsChangeable(model.getIsHighlyAvailable().getEntity());
if (!model.getIsHighlyAvailable().getEntity()) {
model.getLease().setChangeProhibitionReason(constants.vmLeasesNotSupportedWithoutHA());
}
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class VmWatchdogValidatorTest method isModelCompatibleWithOsTest.
private void isModelCompatibleWithOsTest(Matcher<ValidationResult> matcher, VmWatchdogType watchDogModel) {
Version version = new Version();
VmWatchdog vmWatchdog = new VmWatchdog();
vmWatchdog.setModel(watchDogModel);
VmWatchdogValidator.VmWatchdogClusterDependentValidator validator = spy(new VmWatchdogValidator.VmWatchdogClusterDependentValidator(0, vmWatchdog, version));
OsRepository osRepository = mock(OsRepository.class);
when(validator.getOsRepository()).thenReturn(osRepository);
when(osRepository.getVmWatchdogTypes(anyInt(), any())).thenReturn(WATCHDOG_MODELS);
assertThat(validator.isValid(), matcher);
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class BackendVmsResource method copyRngDeviceFromTemplateOrInstanceType.
// TODO: Move user input and template/instance-type merging code to backed
private void copyRngDeviceFromTemplateOrInstanceType(AddVmParameters params, VmStatic vmStatic, Cluster cluster, Guid templateId, Guid instanceTypeId) {
List<VmRngDevice> devices = VmHelper.getRngDevicesForEntity(this, instanceTypeId != null ? instanceTypeId : templateId);
if (devices != null && !devices.isEmpty()) {
final VmRngDevice rngDevice = devices.get(0);
final Version effectiveVersion = CommonCompatibilityVersionUtils.getEffective(vmStatic.getCustomCompatibilityVersion(), cluster.getCompatibilityVersion(), null);
rngDevice.updateSourceByVersion(effectiveVersion);
boolean supported = EnumSet.of(RngUtils.RngValidationResult.VALID, RngUtils.RngValidationResult.UNSUPPORTED_URANDOM_OR_RANDOM).contains(RngUtils.validate(cluster, rngDevice));
if (shouldCopyDevice(supported, templateId, instanceTypeId)) {
params.setUpdateRngDevice(true);
params.setRngDevice(rngDevice);
}
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class BackendDataCentersResourceTest method getVersions.
protected List<Version> getVersions() {
Version version = mock(Version.class);
when(version.getMajor()).thenReturn(2);
when(version.getMinor()).thenReturn(3);
List<Version> versions = new ArrayList<>();
versions.add(version);
return versions;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class OS method fromPackageVersionString.
public static OS fromPackageVersionString(String packageVersionString) {
if (packageVersionString == null) {
return new OS();
}
String[] os = packageVersionString.split(OS_DELIMITER, 3);
if (os.length < 2) {
return new OS();
}
final String name = os[0].trim();
final Matcher versionMatcher = versionPattern.matcher(os[1].trim());
final Version version;
if (versionMatcher.find()) {
if (name != null && name.toLowerCase().startsWith("fedora")) {
int major = extractVersionPart(versionMatcher.group());
int minor = extractVersionPart(os[2].trim());
version = new Version(major, minor);
} else {
version = new Version(versionMatcher.group());
}
} else if (os.length == 3 && os[2].contains("el6")) {
version = new Version(6, -1);
} else if (os.length == 3 && os[2].contains("el7")) {
version = new Version(7, -1);
} else {
version = new Version();
}
final String fullVersion = StringUtils.join(Arrays.copyOfRange(os, 1, os.length), OS_DELIMITER);
return new OS(name, version, fullVersion);
}
Aggregations