Search in sources :

Example 26 with Version

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

the class SnapshotModel method setOldClusterVersionOfSnapshotWithMemory.

public void setOldClusterVersionOfSnapshotWithMemory(VM vm) {
    if (!isVMWithMemoryCompatible(vm)) {
        // message regarding old cluster snapshot will be shown
        Version originalClusterVersion = vm.getClusterCompatibilityVersionOrigin();
        originalClusterVersion = (originalClusterVersion == null) ? Version.v3_6 : originalClusterVersion;
        oldClusterVersionOfSnapshotWithMemory = originalClusterVersion;
    } else {
        oldClusterVersionOfSnapshotWithMemory = null;
    }
}
Also used : Version(org.ovirt.engine.core.compat.Version)

Example 27 with Version

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

the class ExistingVmModelBehavior method loadDataCenter.

private void loadDataCenter() {
    // Preinitialize the VM compatibility version because it's needed during init
    Version newCustomCompatibilityVersion = ((ExistingVmModelBehavior) getModel().getBehavior()).getVm().getStaticData().getCustomCompatibilityVersion();
    if (newCustomCompatibilityVersion != null) {
        getModel().getCustomCompatibilityVersion().setItems(Collections.singletonList(newCustomCompatibilityVersion), newCustomCompatibilityVersion);
    }
    AsyncDataProvider.getInstance().getDataCenterById(asyncQuery(dataCenter -> {
        if (dataCenter != null) {
            final List<StoragePool> dataCenters = new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter }));
            initClusters(dataCenters);
        } else {
            ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) getModel().getBehavior();
            VM currentVm = behavior.vm;
            Cluster cluster = new Cluster();
            cluster.setId(currentVm.getClusterId());
            cluster.setName(currentVm.getClusterName());
            cluster.setCompatibilityVersion(currentVm.getClusterCompatibilityVersion());
            cluster.setStoragePoolId(currentVm.getStoragePoolId());
            DataCenterWithCluster dataCenterWithCluster = new DataCenterWithCluster(null, cluster);
            getModel().getDataCenterWithClustersList().setItems(Arrays.asList(dataCenterWithCluster));
            getModel().getDataCenterWithClustersList().setSelectedItem(dataCenterWithCluster);
            behavior.initTemplate();
            behavior.updateCdImage();
        }
    }), vm.getStoragePoolId());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) Map(java.util.Map) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) EnumSet(java.util.EnumSet) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmActionByVmOriginTypeValidator(org.ovirt.engine.core.common.validation.VmActionByVmOriginTypeValidator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) CommonCompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CommonCompatibilityVersionUtils) ExistingVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingVmInstanceTypeManager) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ArrayList(java.util.ArrayList) List(java.util.List)

Example 28 with Version

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

the class ExistingVmModelBehavior method isHotSetCpuSupported.

public boolean isHotSetCpuSupported() {
    Cluster selectedCluster = getModel().getSelectedCluster();
    Version compatibilityVersion = getModel().getCompatibilityVersion();
    boolean hotplugCpuSupported = Boolean.parseBoolean(((Map<String, String>) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.HotPlugCpuSupported, compatibilityVersion.getValue())).get(selectedCluster.getArchitecture().name()));
    return getVm().getStatus() == VMStatus.Up && hotplugCpuSupported;
}
Also used : Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 29 with Version

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

the class GetAllSupportedNetworkFiltersByVersionQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    Version version = getParameters().getVersion();
    Collection<NetworkFilter> networkFilters = networkFilterDao.getAllSupportedNetworkFiltersByVersion(version);
    getQueryReturnValue().setReturnValue(networkFilters);
}
Also used : Version(org.ovirt.engine.core.compat.Version) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter)

Example 30 with Version

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

the class RunVmCommand method guestToolsVersionTreatment.

/**
 * If vds version greater then vm's and vm not running with cd and there is appropriate RhevAgentTools image -
 * add it to vm as cd.
 */
private String guestToolsVersionTreatment() {
    boolean attachCd = false;
    String selectedToolsVersion = "";
    String selectedToolsClusterVersion = "";
    Guid isoDomainId = getActiveIsoDomainId();
    if (osRepository.isWindows(getVm().getVmOsId()) && null != isoDomainId) {
        // get cluster version of the vm tools
        Version vmToolsClusterVersion = null;
        if (getVm().getHasAgent()) {
            Version clusterVer = getVm().getPartialVersion();
            if (new Version("4.4").equals(clusterVer)) {
                vmToolsClusterVersion = new Version("2.1");
            } else {
                vmToolsClusterVersion = clusterVer;
            }
        }
        // Fetch cached Iso files from active Iso domain.
        List<RepoImage> repoFilesMap = getIsoDomainListSynchronizer().getCachedIsoListByDomainId(isoDomainId, ImageFileType.ISO);
        Version bestClusterVer = null;
        int bestToolVer = 0;
        for (RepoImage map : repoFilesMap) {
            String fileName = StringUtils.defaultString(map.getRepoImageId(), "");
            Matcher matchToolPattern = Pattern.compile(IsoDomainListSynchronizer.REGEX_TOOL_PATTERN).matcher(fileName);
            if (matchToolPattern.find()) {
                // Get cluster version and tool version of Iso tool.
                Version clusterVer = new Version(matchToolPattern.group(IsoDomainListSynchronizer.TOOL_CLUSTER_LEVEL));
                int toolVersion = Integer.parseInt(matchToolPattern.group(IsoDomainListSynchronizer.TOOL_VERSION));
                if (clusterVer.compareTo(getVm().getCompatibilityVersion()) <= 0) {
                    if ((bestClusterVer == null) || (clusterVer.compareTo(bestClusterVer) > 0)) {
                        bestToolVer = toolVersion;
                        bestClusterVer = clusterVer;
                    } else if (clusterVer.equals(bestClusterVer) && toolVersion > bestToolVer) {
                        bestToolVer = toolVersion;
                        bestClusterVer = clusterVer;
                    }
                }
            }
        }
        if (bestClusterVer != null && (vmToolsClusterVersion == null || vmToolsClusterVersion.compareTo(bestClusterVer) < 0 || (vmToolsClusterVersion.equals(bestClusterVer) && getVm().getHasAgent() && getVm().getGuestAgentVersion().getBuild() < bestToolVer))) {
            // Vm has no tools or there are new tools
            selectedToolsVersion = Integer.toString(bestToolVer);
            selectedToolsClusterVersion = bestClusterVer.toString();
            attachCd = true;
        }
    }
    if (attachCd) {
        String rhevToolsPath = String.format("%1$s%2$s_%3$s.iso", IsoDomainListSynchronizer.getGuestToolsSetupIsoPrefix(), selectedToolsClusterVersion, selectedToolsVersion);
        String isoDir = (String) runVdsCommand(VDSCommandType.IsoDirectory, new IrsBaseVDSCommandParameters(getVm().getStoragePoolId())).getReturnValue();
        rhevToolsPath = isoDir + File.separator + rhevToolsPath;
        return rhevToolsPath;
    }
    return null;
}
Also used : IrsBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Version(org.ovirt.engine.core.compat.Version) Matcher(java.util.regex.Matcher) Guid(org.ovirt.engine.core.compat.Guid)

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