use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class CpuProfilesListModelTable method initTable.
@Override
public void initTable() {
getTable().enableColumnResizing();
AbstractTextColumn<CpuProfile> nameColumn = new AbstractTextColumn<CpuProfile>() {
@Override
public String getValue(CpuProfile object) {
return object.getName();
}
};
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.profileNameLabel(), "200px");
nameColumn.makeSortable();
AbstractTextColumn<CpuProfile> descriptionColumn = new AbstractTextColumn<CpuProfile>() {
@Override
public String getValue(CpuProfile object) {
return object.getDescription();
}
};
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.profileDescriptionLabel(), "200px");
descriptionColumn.makeSortable();
AbstractTextColumn<CpuProfile> qosColumn = new AbstractTextColumn<CpuProfile>() {
@Override
public String getValue(CpuProfile object) {
String name = constants.unlimitedQos();
if (object.getQosId() != null) {
CpuQos cpuQos = getModel().getQos(object.getQosId());
if (cpuQos != null) {
name = cpuQos.getName();
}
}
return name;
}
};
// $NON-NLS-1$
getTable().addColumn(qosColumn, constants.cpuQosName(), "200px");
qosColumn.makeSortable();
// Add selection listener
getModel().getSelectedItemChangedEvent().addListener((ev, sender, args) -> updatePermissionPanel());
getModel().getItemsChangedEvent().addListener((ev, sender, args) -> updatePermissionPanel());
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class CpuProfilesListModelTable method updatePermissionPanel.
private void updatePermissionPanel() {
final CpuProfile cpuProfile = getModel().getSelectedItem();
Scheduler.get().scheduleDeferred(() -> {
if (permissionPanelVisible && cpuProfile == null) {
tableContainer.clear();
tableContainer.add(getContainer());
permissionPanelVisible = false;
} else if (!permissionPanelVisible && cpuProfile != null) {
tableContainer.clear();
tableContainer.add(getContainer());
tableContainer.add(permissionContainer);
permissionPanelVisible = true;
}
});
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class ChangeVmClusterValidator method validate.
protected boolean validate() {
VM vm = parentCommand.getVm();
if (vm == null) {
parentCommand.addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_FOUND);
return false;
} else {
targetCluster = clusterDao.get(targetClusterId);
if (targetCluster == null) {
parentCommand.addValidationMessage(EngineMessage.VM_CLUSTER_IS_NOT_VALID);
return false;
}
// Check that the target cluster is in the same data center.
if (!targetCluster.getStoragePoolId().equals(vm.getStoragePoolId())) {
parentCommand.addValidationMessage(EngineMessage.VM_CANNOT_MOVE_TO_CLUSTER_IN_OTHER_STORAGE_POOL);
return false;
}
if (vmCompatibilityVersion == null) {
vmCompatibilityVersion = targetCluster.getCompatibilityVersion();
}
List<VmNic> interfaces = vmNicDao.getAllForVm(vm.getId());
if (!validateDestinationClusterContainsNetworks(interfaces)) {
return false;
}
// Check if VM static parameters are compatible for new cluster.
ValidationResult isCpuSocketsValid = VmValidator.validateCpuSockets(vm.getStaticData(), vmCompatibilityVersion);
if (!isCpuSocketsValid.isValid()) {
return parentCommand.validate(isCpuSocketsValid);
}
// Check if the display type is supported
if (!parentCommand.validate(vmHandler.isGraphicsAndDisplaySupported(vm.getOs(), vmDeviceUtils.getGraphicsTypesOfEntity(vm.getId()), vm.getDefaultDisplayType(), vmCompatibilityVersion))) {
return false;
}
if (vmDeviceUtils.hasVirtioScsiController(vm.getId())) {
// Verify OS compatibility
if (!parentCommand.validate(vmHandler.isOsTypeSupportedForVirtioScsi(vm.getOs(), vmCompatibilityVersion))) {
return false;
}
}
// A existing VM cannot be changed into a cluster without a defined architecture
if (targetCluster.getArchitecture() == ArchitectureType.undefined) {
return parentCommand.failValidation(EngineMessage.ACTION_TYPE_FAILED_CLUSTER_UNDEFINED_ARCHITECTURE);
} else if (targetCluster.getArchitecture() != vm.getClusterArch()) {
return parentCommand.failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_CLUSTER_DIFFERENT_ARCHITECTURES);
}
// Cluster must have a cpu profile
List<CpuProfile> cpuProfiles = cpuProfileDao.getAllForCluster(targetClusterId, parentCommand.getUserId(), true, ActionGroup.ASSIGN_CPU_PROFILE);
if (cpuProfiles.isEmpty()) {
return parentCommand.failValidation(EngineMessage.ACTION_TYPE_CPU_PROFILE_EMPTY);
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class AddClusterCommand method addDefaultCpuProfile.
private void addDefaultCpuProfile() {
CpuProfile cpuProfile = CpuProfileHelper.createCpuProfile(getParameters().getCluster().getId(), getParameters().getCluster().getName());
CpuProfileParameters cpuProfileAddParameters = new CpuProfileParameters(cpuProfile);
cpuProfileAddParameters.setAddPermissions(true);
cpuProfileAddParameters.setParametersCurrentUser(getCurrentUser());
cpuProfileAddParameters.setSessionId(getContext().getEngineContext().getSessionId());
ActionReturnValue addCpuProfileReturnValue = backend.runAction(ActionType.AddCpuProfile, cpuProfileAddParameters);
cpuProfile.setId(addCpuProfileReturnValue.getActionReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.profiles.CpuProfile in project ovirt-engine by oVirt.
the class EntityDaoImplTest method testGetEntityNameByIdAndTypeForCpuProfile.
@Test
public void testGetEntityNameByIdAndTypeForCpuProfile() {
CpuProfile cpuProfile = cpuProfileDao.get(FixturesTool.CPU_PROFILE_1);
assertNotNull(cpuProfile);
String name = cpuProfile.getName();
assertEquals(name, underTest.getEntityNameByIdAndType(FixturesTool.CPU_PROFILE_1, VdcObjectType.CpuProfile));
}
Aggregations