Search in sources :

Example 6 with ServerCpu

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

the class RunOnceModel method updateSystemTabLists.

private void updateSystemTabLists() {
    Guid clusterId = vm.getClusterId();
    if (clusterId != null) {
        // update emulated machine list
        AsyncDataProvider.getInstance().getEmulatedMachinesByClusterID(new AsyncQuery<>(emulatedSet -> {
            if (emulatedSet != null) {
                String oldVal = getEmulatedMachine().getSelectedItem();
                getEmulatedMachine().setItems(new TreeSet<>(emulatedSet));
                // even if converted - needed as fallback
                getEmulatedMachine().setSelectedItem(oldVal);
                convertEmulatedMachineField();
            }
        }), clusterId);
        AsyncDataProvider.getInstance().getClusterById(new AsyncQuery<>(cluster -> {
            if (cluster != null) {
                // update cpu names list
                if (cluster.getCpuName() != null) {
                    AsyncDataProvider.getInstance().getSupportedCpuList(new AsyncQuery<>(returnValue -> {
                        if (returnValue != null) {
                            List<String> cpuList = new ArrayList<>();
                            for (ServerCpu cpu : returnValue) {
                                cpuList.add(cpu.getVdsVerbData());
                            }
                            String oldVal = getCustomCpu().getSelectedItem();
                            getCustomCpu().setItems(cpuList);
                            // replace 'cluster cpu' with the explicit run-time value
                            if (StringHelper.isNullOrEmpty(oldVal) && !cpuList.isEmpty()) {
                                getCustomCpu().setSelectedItem(cpuList.get(cpuList.size() - 1));
                            } else {
                                getCustomCpu().setSelectedItem(oldVal);
                            }
                        }
                    }), cluster.getCpuName());
                }
            }
        }), clusterId);
    }
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) ImagesDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.ImagesDataProvider) InitializationType(org.ovirt.engine.core.common.businessentities.InitializationType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) RunVmOnceParams(org.ovirt.engine.core.common.action.RunVmOnceParams) NoTrimmingWhitespacesValidation(org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) Linq(org.ovirt.engine.ui.uicommonweb.Linq) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) I18NExtraNameOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) MatchFieldsValidator(org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) VmInit(org.ovirt.engine.core.common.businessentities.VmInit) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) Guid(org.ovirt.engine.core.compat.Guid)

Example 7 with ServerCpu

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

the class CpuFlagsManagerHandler method isCpuUpdatable.

public boolean isCpuUpdatable(String cpuName, Version ver) {
    final CpuFlagsManager cpuFlagsManager = managersDictionary.get(ver);
    ServerCpu server = null;
    if (cpuFlagsManager != null) {
        server = cpuFlagsManager.getServerCpuByName(cpuName);
    }
    int serverLevel = (server != null) ? server.getLevel() : 0;
    return serverLevel != 0;
}
Also used : ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu)

Example 8 with ServerCpu

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

the class VdsArchitectureHelper method getArchitecture.

/**
 * Gets the architecture type of the given host using its cpu flags, if not found, return the cluster architecture
 * @param host
 *            The host
 * @return
 *            The host architecture type
 */
public ArchitectureType getArchitecture(VdsStatic host) {
    Cluster cluster = clusterDao.get(host.getClusterId());
    VdsDynamic vdsDynamic = vdsDynamicDao.get(host.getId());
    if (vdsDynamic != null) {
        ServerCpu cpu = cpuFlagsManagerHandler.findMaxServerCpuByFlags(vdsDynamic.getCpuFlags(), cluster.getCompatibilityVersion());
        if (cpu != null && cpu.getArchitecture() != null) {
            return cpu.getArchitecture();
        }
    }
    // take architecture from the cluster if it is null on the host level or host is not yet saved in db
    log.info("Failed to get architecture type from host information for host '{}'. Using cluster '{}'" + " architecture value instead.", host.getName(), cluster.getName());
    return cluster.getArchitecture();
}
Also used : VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 9 with ServerCpu

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

the class HandleVdsCpuFlagsOrClusterChangedCommand method executeCommand.

@Override
protected void executeCommand() {
    String clusterCpuName = getVds().getClusterCpuName();
    Cluster grp = clusterDao.get(getVds().getClusterId());
    ServerCpu sc = getCpuFlagsManagerHandler().findMaxServerCpuByFlags(getVds().getCpuFlags(), getVds().getClusterCompatibilityVersion());
    if (sc == null) {
        // operational
        if (!StringUtils.isEmpty(getVds().getCpuFlags())) {
            foundCPU = false;
        } else {
            _hasFlags = false;
        }
        log.error("Could not find server cpu for server '{}' ({}), flags: '{}'", getVds().getName(), getVdsId(), getVds().getCpuFlags());
    }
    // Checks whether the host and the cluster have the same architecture
    if (_hasFlags && foundCPU) {
        if (grp.getArchitecture() != ArchitectureType.undefined && sc.getArchitecture() != grp.getArchitecture()) {
            architectureMatch = false;
            addCustomValue("VdsArchitecture", sc.getArchitecture().name());
            addCustomValue("ClusterArchitecture", grp.getArchitecture().name());
            SetNonOperationalVdsParameters tempVar = new SetNonOperationalVdsParameters(getVdsId(), NonOperationalReason.ARCHITECTURE_INCOMPATIBLE_WITH_CLUSTER);
            runInternalAction(ActionType.SetNonOperationalVds, tempVar, ExecutionHandler.createInternalJobContext(getContext()));
        } else {
            // if cluster doesn't have cpu then get the cpu from the vds
            if (StringUtils.isEmpty(clusterCpuName)) {
                // update group with the cpu name
                grp.setCpuName(sc.getCpuName());
                grp.setArchitecture(sc.getArchitecture());
                updateMigrateOnError(grp);
                // use suppress in order to update group even if action fails
                // (out of the transaction)
                ManagementNetworkOnClusterOperationParameters tempVar = new ManagementNetworkOnClusterOperationParameters(grp);
                tempVar.setTransactionScopeOption(TransactionScopeOption.Suppress);
                tempVar.setIsInternalCommand(true);
                runInternalAction(ActionType.UpdateCluster, tempVar);
                clusterCpuName = sc.getCpuName();
            }
        }
    }
    // If the host CPU name is not found by the CpuFlagsManagerHandler class, report an error
    if (architectureMatch) {
        List<String> missingFlags = getCpuFlagsManagerHandler().missingServerCpuFlags(clusterCpuName, getVds().getCpuFlags(), getVds().getClusterCompatibilityVersion());
        if (!StringUtils.isEmpty(getVds().getCpuFlags()) && (!foundCPU || missingFlags != null)) {
            if (missingFlags != null) {
                addCustomValue("CpuFlags", StringUtils.join(missingFlags, ", "));
                if (missingFlags.contains("nx")) {
                    auditLogDirector.log(this, AuditLogType.CPU_FLAGS_NX_IS_MISSING);
                }
            }
            SetNonOperationalVdsParameters tempVar2 = new SetNonOperationalVdsParameters(getVdsId(), NonOperationalReason.CPU_TYPE_INCOMPATIBLE_WITH_CLUSTER);
            runInternalAction(ActionType.SetNonOperationalVds, tempVar2, ExecutionHandler.createInternalJobContext(getContext()));
        } else {
            // if no need to change to non operational then don't log the command
            setCommandShouldBeLogged(false);
        }
    }
    setSucceeded(true);
}
Also used : SetNonOperationalVdsParameters(org.ovirt.engine.core.common.action.SetNonOperationalVdsParameters) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 10 with ServerCpu

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

the class CPUMapper method map.

@Mapping(from = ServerCpu.class, to = Cpu.class)
public static Cpu map(ServerCpu entity, Cpu template) {
    Cpu model = template != null ? template : new Cpu();
    model.setName(entity.getCpuName());
    model.setLevel(entity.getLevel());
    model.setArchitecture(map(entity.getArchitecture(), null));
    return model;
}
Also used : Cpu(org.ovirt.engine.api.model.Cpu) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu)

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