Search in sources :

Example 56 with Version

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

the class ConfigureLocalStorageModel method dataCenterVersion_SelectedItemChanged.

private void dataCenterVersion_SelectedItemChanged() {
    Version version = getDataCenter().getVersion().getSelectedItem();
    // Keep in sync version for data center and cluster.
    getCluster().getVersion().setSelectedItem(version);
}
Also used : Version(org.ovirt.engine.core.compat.Version)

Example 57 with Version

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

the class ConfigureLocalStorageModel method setDefaultNames8.

private void setDefaultNames8() {
    VDS host = context.host;
    List<StoragePool> dataCenters = context.dataCenterList;
    List<Cluster> clusters = context.clusterList;
    // $NON-NLS-1$
    setCommonName(host.getName().replace('.', '-') + "-Local");
    StoragePool candidate = null;
    // Check if current settings suitable for local setup (in case just SD creation failed - re-using the same
    // setup)
    boolean useCurrentSettings = false;
    if (host.getStoragePoolId() != null) {
        StoragePool tempCandidate = context.hostDataCenter;
        if (isLocalDataCenterEmpty(tempCandidate)) {
            candidate = tempCandidate;
            useCurrentSettings = true;
        } else {
            if (tempCandidate != null && tempCandidate.isLocal()) {
                setMessage(ConstantsManager.getInstance().getConstants().noteLocalStorageAlreadyConfiguredForThisHostMsg() + " " + host.getStoragePoolName() + " " + // $NON-NLS-1$ //$NON-NLS-2$
                ConstantsManager.getInstance().getConstants().withLocalStorageDomainMsg());
            }
        }
    }
    // Check if there is other DC suitable for re-use
    if (candidate == null) {
        for (StoragePool dataCenter : dataCenters) {
            // Need to check if the new DC is without host.
            if (isLocalDataCenterEmpty(dataCenter) && context.localStorageHostByDataCenterMap.get(dataCenter) == null) {
                candidate = dataCenter;
                break;
            }
        }
    }
    ArrayList<String> names;
    // In case we found a suitable candidate for re-use:
    if (candidate != null) {
        getDataCenter().setDataCenterId(candidate.getId());
        getDataCenter().getName().setEntity(candidate.getName());
        getDataCenter().getDescription().setEntity(candidate.getdescription());
        Version version = candidate.getCompatibilityVersion();
        getDataCenter().getVersion().setSelectedItem(version);
        getCluster().getVersion().setSelectedItem(version);
        setCandidateDataCenter(candidate);
        // If we use current settings there is no need to create cluster.
        if (useCurrentSettings) {
            getCluster().setClusterId(host.getClusterId());
            getCluster().getName().setEntity(host.getClusterName());
            Cluster cluster = context.hostCluster;
            if (cluster != null) {
                getCluster().getDescription().setEntity(cluster.getDescription());
                ServerCpu cpu = new ServerCpu();
                cpu.setCpuName(cluster.getCpuName());
                getCluster().getCPU().setSelectedItem(cpu);
            }
            setCandidateCluster(cluster);
        } else // Use different cluster
        {
            // Check the DC cluster list (for re-use)
            clusters = context.clusterListByDataCenterMap.get(candidate);
            // No clusters available - pick up new name.
            if (clusters == null || clusters.isEmpty()) {
                names = new ArrayList<>();
                List<Cluster> listClusters = context.clusterList;
                for (Cluster cluster : listClusters) {
                    names.add(cluster.getName());
                }
                getCluster().getName().setEntity(availableName(names));
            } else {
                // Use the DC cluster.
                Cluster cluster = Linq.firstOrNull(clusters);
                getCluster().setClusterId(cluster.getId());
                getCluster().getName().setEntity(cluster.getName());
                getCluster().getDescription().setEntity(cluster.getDescription());
                cluster = Linq.firstOrNull(context.clusterList, new Linq.IdPredicate<>(getCluster().getClusterId()));
                if (cluster != null) {
                    ServerCpu cpu = new ServerCpu();
                    cpu.setCpuName(cluster.getCpuName());
                    getCluster().getCPU().setSelectedItem(cpu);
                }
                setCandidateCluster(cluster);
            }
        }
    } else {
        // Didn't found DC to re-use, so we select new names.
        names = new ArrayList<>();
        for (StoragePool dataCenter : dataCenters) {
            names.add(dataCenter.getName());
        }
        getDataCenter().getName().setEntity(availableName(names));
        // Choose a Data Center version corresponding to the host.
        if (!StringHelper.isNullOrEmpty(host.getSupportedClusterLevels())) {
            // The supported_cluster_levels are sorted.
            // $NON-NLS-1$
            String[] array = host.getSupportedClusterLevels().split("[,]", -1);
            Version maxVersion = null;
            for (int i = 0; i < array.length; i++) {
                Version vdsVersion = new Version(array[i]);
                for (Version version : getDataCenter().getVersion().getItems()) {
                    if (version.equals(vdsVersion) && version.compareTo(maxVersion) > 0) {
                        maxVersion = version;
                    }
                }
            }
            if (maxVersion != null) {
                getDataCenter().getVersion().setSelectedItem(maxVersion);
                getCluster().getVersion().setSelectedItem(maxVersion);
            }
        }
        names = new ArrayList<>();
        if (clusters != null) {
            for (Cluster cluster : clusters) {
                names.add(cluster.getName());
            }
        }
        getCluster().getName().setEntity(availableName(names));
    }
    // Choose default CPU name to match host.
    List<ServerCpu> serverCpus = (List<ServerCpu>) getCluster().getCPU().getItems();
    if (host.getCpuName() != null) {
        getCluster().getCPU().setSelectedItem(Linq.firstOrNull(serverCpus, new Linq.ServerCpuPredicate(host.getCpuName().getCpuName())));
    } else {
        getCluster().getCPU().setSelectedItem(serverCpus.isEmpty() ? null : serverCpus.get(0));
    }
    // Always choose a available storage name.
    List<StorageDomain> storages = context.storageList;
    names = new ArrayList<>();
    for (StorageDomain storageDomain : storages) {
        names.add(storageDomain.getStorageName());
    }
    getFormattedStorageName().setEntity(availableName(names));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) Version(org.ovirt.engine.core.compat.Version) ArrayList(java.util.ArrayList) List(java.util.List)

Example 58 with Version

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

the class TryBackToAllSnapshotsOfVmCommand method validateMemoryTakenInSupportedVersion.

private boolean validateMemoryTakenInSupportedVersion() {
    VM vmFromSnapshot = null;
    try {
        vmFromSnapshot = ovfHelper.readVmFromOvf(getDstSnapshot().getVmConfiguration()).getVm();
    } catch (OvfReaderException e) {
        // should never happen since the OVF was created by us
        log.error("Failed to parse a given ovf configuration: {}", e.getMessage());
        return false;
    }
    Version originalClusterVersion = vmFromSnapshot.getClusterCompatibilityVersionOrigin();
    if (Version.getLowest().greater(originalClusterVersion)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_MEMORY_TOO_OLD, String.format("$Cv %s", originalClusterVersion != null ? originalClusterVersion : "N/A"));
    }
    return true;
}
Also used : Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 59 with Version

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

the class CustomMapSqlParameterSourceTest method testAddValueVersion.

@Test
public void testAddValueVersion() {
    Version verision = new Version(this.random.nextInt(), this.random.nextInt());
    paramSource.addValue(paramName, verision);
    assertEquals("wrong value returned from parameter source", verision.toString(), paramSource.getValue(paramName));
}
Also used : Version(org.ovirt.engine.core.compat.Version) Test(org.junit.Test)

Example 60 with Version

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

the class LibvirtVmXmlBuilder method writeClusterVersionMetadata.

private void writeClusterVersionMetadata() {
    Version version = vm.getCompatibilityVersion();
    writer.writeStartElement("clusterVersion");
    writer.writeRaw(String.valueOf(version.getMajor()) + "." + String.valueOf(version.getMinor()));
    writer.writeEndElement();
}
Also used : 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