Search in sources :

Example 76 with Version

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

Example 77 with Version

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

Example 78 with Version

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

Example 79 with Version

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;
}
Also used : Version(org.ovirt.engine.core.compat.Version) ArrayList(java.util.ArrayList)

Example 80 with Version

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);
}
Also used : Matcher(java.util.regex.Matcher) 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