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);
}
}
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;
}
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();
}
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);
}
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;
}
Aggregations