Search in sources :

Example 11 with ServerCpu

use of org.ovirt.engine.core.common.businessentities.ServerCpu 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 12 with ServerCpu

use of org.ovirt.engine.core.common.businessentities.ServerCpu in project ovirt-engine by oVirt.

the class ClusterModel method initCPU.

private void initCPU() {
    if (!isCPUinitialized && getIsEdit()) {
        isCPUinitialized = true;
        getCPU().setSelectedItem(null);
        for (ServerCpu a : getCPU().getItems()) {
            if (Objects.equals(a.getCpuName(), getEntity().getCpuName())) {
                getCPU().setSelectedItem(a);
                break;
            }
        }
    }
}
Also used : ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu)

Example 13 with ServerCpu

use of org.ovirt.engine.core.common.businessentities.ServerCpu in project ovirt-engine by oVirt.

the class ClusterModel method populateCPUList.

private void populateCPUList(List<ServerCpu> cpus, boolean canChangeArchitecture) {
    // disable CPU Architecture-Type filtering
    getArchitecture().getSelectedItemChangedEvent().removeListener(this);
    ServerCpu oldSelectedCpu = getCPU().getSelectedItem();
    ArchitectureType oldSelectedArch = getArchitecture().getSelectedItem();
    getCPU().setItems(cpus);
    initSupportedArchitectures();
    getCPU().setSelectedItem(oldSelectedCpu != null ? Linq.firstOrNull(cpus, new Linq.ServerCpuPredicate(oldSelectedCpu.getCpuName())) : null);
    if (getCPU().getSelectedItem() == null || !isCPUinitialized) {
        initCPU();
    }
    if (getIsEdit()) {
        if (!canChangeArchitecture) {
            getArchitecture().setItems(new ArrayList<>(Collections.singletonList(getEntity().getArchitecture())));
        }
        if (oldSelectedArch != null) {
            getArchitecture().setSelectedItem(oldSelectedArch);
        } else {
            if (getEntity() != null) {
                getArchitecture().setSelectedItem(getEntity().getArchitecture());
            } else {
                getArchitecture().setSelectedItem(ArchitectureType.undefined);
            }
        }
    } else {
        getArchitecture().setSelectedItem(ArchitectureType.undefined);
    }
    // enable CPU Architecture-Type filtering
    initCpuArchTypeFiltering();
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu)

Example 14 with ServerCpu

use of org.ovirt.engine.core.common.businessentities.ServerCpu in project ovirt-engine by oVirt.

the class ClusterModel method initSupportedArchitectures.

private void initSupportedArchitectures() {
    Collection<ArchitectureType> archsWithSupportingCpus = new HashSet<>();
    archsWithSupportingCpus.add(ArchitectureType.undefined);
    for (ServerCpu cpu : getCPU().getItems()) {
        if (cpu != null) {
            archsWithSupportingCpus.add(cpu.getArchitecture());
        }
    }
    getArchitecture().setItems(archsWithSupportingCpus);
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) HashSet(java.util.HashSet)

Example 15 with ServerCpu

use of org.ovirt.engine.core.common.businessentities.ServerCpu in project ovirt-engine by oVirt.

the class ClusterModel method filterCpuTypeByArchitecture.

private void filterCpuTypeByArchitecture() {
    final ArchitectureType selectedArchitecture = getArchitecture().getSelectedItem();
    final FilteredListModel.Filter<ServerCpu> filter = selectedArchitecture == null || selectedArchitecture.equals(ArchitectureType.undefined) ? cpu -> cpu == null || cpu.getLevel() > 0 : cpu -> cpu != null && selectedArchitecture.equals(cpu.getArchitecture()) && cpu.getLevel() > 0;
    getCPU().filterItems(filter);
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) FilteredListModel(org.ovirt.engine.ui.uicommonweb.models.FilteredListModel)

Aggregations

ServerCpu (org.ovirt.engine.core.common.businessentities.ServerCpu)22 Version (org.ovirt.engine.core.compat.Version)8 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)7 ArrayList (java.util.ArrayList)6 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 List (java.util.List)5 Arrays (java.util.Arrays)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)4 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Set (java.util.Set)3 TreeSet (java.util.TreeSet)3 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)3 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 Guid (org.ovirt.engine.core.compat.Guid)3