Search in sources :

Example 6 with CpuProfile

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());
}
Also used : CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos)

Example 7 with CpuProfile

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;
        }
    });
}
Also used : CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile)

Example 8 with CpuProfile

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;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 9 with CpuProfile

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());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) CpuProfileParameters(org.ovirt.engine.core.common.action.CpuProfileParameters)

Example 10 with CpuProfile

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));
}
Also used : CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Test(org.junit.Test)

Aggregations

CpuProfile (org.ovirt.engine.core.common.businessentities.profiles.CpuProfile)20 Guid (org.ovirt.engine.core.compat.Guid)5 VM (org.ovirt.engine.core.common.businessentities.VM)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Test (org.junit.Test)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 HashMap (java.util.HashMap)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 CpuProfileParameters (org.ovirt.engine.core.common.action.CpuProfileParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 Quota (org.ovirt.engine.core.common.businessentities.Quota)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 CpuQos (org.ovirt.engine.core.common.businessentities.qos.CpuQos)2 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 ImportVmFromExternalProviderParameters (org.ovirt.engine.core.common.action.ImportVmFromExternalProviderParameters)1 ImportVmFromOvaParameters (org.ovirt.engine.core.common.action.ImportVmFromOvaParameters)1