Search in sources :

Example 6 with InstanceType

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

the class GetInstanceTypeQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    InstanceType instance;
    GetVmTemplateParameters params = getParameters();
    if (params.getName() != null) {
        instance = vmTemplateDao.getInstanceTypeByName(params.getName(), getUserID(), getParameters().isFiltered());
    } else {
        instance = vmTemplateDao.getInstanceType(getParameters().getId(), getUserID(), getParameters().isFiltered());
    }
    getQueryReturnValue().setReturnValue(instance);
}
Also used : GetVmTemplateParameters(org.ovirt.engine.core.common.queries.GetVmTemplateParameters) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

Example 7 with InstanceType

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

the class VmManagementCommandBase method updateParametersVmFromInstanceType.

protected void updateParametersVmFromInstanceType() {
    InstanceType instanceType = getInstanceType();
    VmStatic vmStatic = getParameters().getVmStaticData();
    if (instanceType != null) {
        vmStatic.setMemSizeMb(instanceType.getMemSizeMb());
        vmStatic.setNumOfSockets(instanceType.getNumOfSockets());
        vmStatic.setCpuPerSocket(instanceType.getCpuPerSocket());
        vmStatic.setThreadsPerCpu(instanceType.getThreadsPerCpu());
        vmStatic.setAutoStartup(instanceType.isAutoStartup());
        if (FeatureSupported.isMigrationSupported(getCluster().getArchitecture(), getEffectiveCompatibilityVersion())) {
            vmStatic.setMigrationSupport(instanceType.getMigrationSupport());
        }
        vmStatic.setNumOfIoThreads(instanceType.getNumOfIoThreads());
        vmStatic.setMigrationDowntime(instanceType.getMigrationDowntime());
        vmStatic.setPriority(instanceType.getPriority());
        vmStatic.setTunnelMigration(instanceType.getTunnelMigration());
        List<VmDevice> vmDevices = getVmDeviceUtils().getMemoryBalloons(instanceType.getId());
        vmStatic.setMinAllocatedMem(instanceType.getMinAllocatedMem());
        if (vmDevices.isEmpty()) {
            getParameters().setBalloonEnabled(false);
        } else if (osRepository.isBalloonEnabled(getParameters().getVmStaticData().getOsId(), getEffectiveCompatibilityVersion())) {
            getParameters().setBalloonEnabled(true);
        }
        vmStatic.setMigrationPolicyId(instanceType.getMigrationPolicyId());
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

Example 8 with InstanceType

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

the class BackendInstanceTypeGraphicsConsolesResource method list.

@Override
public GraphicsConsoles list() {
    GraphicsConsoles consoles = new GraphicsConsoles();
    InstanceType entity = loadEntity();
    BackendGraphicsConsoleHelper.list(this, guid).entrySet().forEach(graphicsInfo -> consoles.getGraphicsConsoles().add(addLinks(populate(VmMapper.map(graphicsInfo, null), entity))));
    return consoles;
}
Also used : GraphicsConsoles(org.ovirt.engine.api.model.GraphicsConsoles) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

Example 9 with InstanceType

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

the class AbstractVmPopupWidget method initListBoxEditors.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void initListBoxEditors() {
    // General tab
    dataCenterWithClusterEditor = new GroupedListModelListBoxEditor<>(new GroupedListModelListBox<DataCenterWithCluster>(new NameRenderer<>()) {

        @Override
        public String getModelLabel(DataCenterWithCluster model) {
            return model.getCluster().getName();
        }

        @Override
        public String getGroupLabel(DataCenterWithCluster model) {
            return messages.hostDataCenter(model.getDataCenter().getName());
        }

        public Comparator<DataCenterWithCluster> getComparator() {
            return Comparator.comparing((DataCenterWithCluster d) -> d.getDataCenter().getName(), Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).thenComparing(d -> d.getCluster().getName(), Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
        }
    });
    quotaEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<Quota>() {

        @Override
        public String getReplacementStringNullSafe(Quota data) {
            return data.getQuotaName();
        }

        @Override
        public String getDisplayStringNullSafe(Quota data) {
            return typeAheadNameDescriptionTemplateNullSafe(data.getQuotaName(), data.getDescription());
        }
    }, new ModeSwitchingVisibilityRenderer());
    baseTemplateEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<VmTemplate>() {

        @Override
        public String getReplacementStringNullSafe(VmTemplate data) {
            return data.getName();
        }

        @Override
        public String getDisplayStringNullSafe(VmTemplate data) {
            return typeAheadNameDescriptionTemplateNullSafe(data.getName(), data.getDescription());
        }
    }, new ModeSwitchingVisibilityRenderer());
    templateWithVersionEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<TemplateWithVersion>() {

        @Override
        public String getReplacementStringNullSafe(TemplateWithVersion templateWithVersion) {
            return getFirstColumn(templateWithVersion) + // $NON-NLS-1$
            " | " + getSecondColumn(templateWithVersion);
        }

        @Override
        public String getDisplayStringNullSafe(TemplateWithVersion templateWithVersion) {
            return typeAheadNameDescriptionTemplateNullSafe(getFirstColumn(templateWithVersion), getSecondColumn(templateWithVersion));
        }

        private String getFirstColumn(TemplateWithVersion templateWithVersion) {
            return templateWithVersion.getBaseTemplate().getName();
        }

        private String getSecondColumn(TemplateWithVersion templateWithVersion) {
            final VmTemplate versionTemplate = templateWithVersion.getTemplateVersion();
            final String versionName = versionTemplate.getTemplateVersionName() == null ? // $NON-NLS-1$
            "" : // $NON-NLS-1$
            versionTemplate.getTemplateVersionName() + " ";
            return templateWithVersion.isLatest() ? constants.latest() : // $NON-NLS-1$
            versionName + "(" + versionTemplate.getTemplateVersionNumber() + // $NON-NLS-1$
            ")";
        }
    }, new ModeSwitchingVisibilityRenderer(), new SuggestionMatcher.ContainsSuggestionMatcher());
    oSTypeEditor = new ListModelListBoxEditor<>(new AbstractRenderer<Integer>() {

        @Override
        public String render(Integer object) {
            return AsyncDataProvider.getInstance().getOsName(object);
        }
    }, new ModeSwitchingVisibilityRenderer());
    vmTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<VmType>(), new ModeSwitchingVisibilityRenderer());
    instanceTypesEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<InstanceType>() {

        @Override
        public String getReplacementStringNullSafe(InstanceType data) {
            return data.getName();
        }

        @Override
        public String getDisplayStringNullSafe(InstanceType data) {
            return typeAheadNameDescriptionTemplateNullSafe(data.getName(), data.getDescription());
        }
    }, new ModeSwitchingVisibilityRenderer());
    emulatedMachine = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {

        @Override
        public String getDisplayStringNullSafe(String data) {
            if (data == null || data.trim().isEmpty()) {
                data = getDefaultEmulatedMachineLabel();
            }
            return typeAheadNameTemplateNullSafe(data);
        }
    }, false, new ModeSwitchingVisibilityRenderer(), constants.clusterDefaultOption());
    customCpu = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {

        @Override
        public String getDisplayStringNullSafe(String data) {
            if (data == null || data.trim().isEmpty()) {
                data = getDefaultCpuTypeLabel();
            }
            return typeAheadNameTemplateNullSafe(data);
        }
    }, false, new ModeSwitchingVisibilityRenderer(), constants.clusterDefaultOption());
    numOfSocketsEditor = new ListModelListBoxEditor<>(new ModeSwitchingVisibilityRenderer());
    numOfSocketsEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(numOfSocketsEditor);
    corePerSocketEditor = new ListModelListBoxEditor<>(new ModeSwitchingVisibilityRenderer());
    corePerSocketEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(corePerSocketEditor);
    initThreadsPerCore();
    // Pools
    poolTypeEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<VmPoolType>>() {

        @Override
        public String renderNullSafe(EntityModel<VmPoolType> object) {
            return object.getTitle();
        }
    }, new ModeSwitchingVisibilityRenderer());
    timeZoneEditor = new ListModelListBoxOnlyEditor<>(new NullSafeRenderer<TimeZoneModel>() {

        @Override
        public String renderNullSafe(TimeZoneModel timeZone) {
            if (timeZone.isDefault()) {
                return messages.defaultTimeZoneCaption(timeZone.getDisplayValue());
            } else {
                return timeZone.getDisplayValue();
            }
        }
    }, new ModeSwitchingVisibilityRenderer());
    EnableableFormLabel label = new EnableableFormLabel();
    label.setText(constants.timeZoneVm());
    timeZoneEditorWithInfo = new EntityModelWidgetWithInfo(label, timeZoneEditor);
    timeZoneEditorWithInfo.setExplanation(templates.italicText(constants.timeZoneInfo()));
    // Console tab
    displayTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<DisplayType>(), new ModeSwitchingVisibilityRenderer());
    graphicsTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<UnitVmModel.GraphicsTypes>());
    usbSupportEditor = new ListModelListBoxEditor<>(new EnumRenderer<UsbPolicy>(), new ModeSwitchingVisibilityRenderer());
    consoleDisconnectActionEditor = new ListModelListBoxEditor<>(new EnumRenderer<ConsoleDisconnectAction>(), new ModeSwitchingVisibilityRenderer());
    numOfMonitorsEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Integer>() {

        @Override
        public String renderNullSafe(Integer object) {
            return object.toString();
        }
    }, new ModeSwitchingVisibilityRenderer());
    numOfMonitorsEditor.hideLabel();
    vncKeyboardLayoutEditor = new ListModelListBoxEditor<>(new VncKeyMapRenderer(), new ModeSwitchingVisibilityRenderer());
    // Host Tab
    // $NON-NLS-1$
    specificHost = new EntityModelRadioButtonEditor("runVmOnHostGroup", new ModeSwitchingVisibilityRenderer());
    isAutoAssignEditor = // $NON-NLS-1$
    new EntityModelRadioButtonEditor("runVmOnHostGroup", new ModeSwitchingVisibilityRenderer());
    defaultHostEditor = new ListModelMultipleSelectListBoxEditor<>(new NameRenderer<VDS>(), new ModeSwitchingVisibilityRenderer());
    defaultHostEditor.hideLabel();
    migrationModeEditor = new ListModelListBoxEditor<>(new EnumRenderer<MigrationSupport>(), new ModeSwitchingVisibilityRenderer());
    migrationModeEditor.hideLabel();
    overrideMigrationDowntimeEditor = new EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
    migrationDowntimeEditor = new IntegerEntityModelTextBoxOnlyEditor(new ModeSwitchingVisibilityRenderer());
    overrideMigrationPolicyEditor = new EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
    migrationPolicyEditor = new ListModelListBoxOnlyEditor<>(new NameRenderer<MigrationPolicy>(), new ModeSwitchingVisibilityRenderer());
    autoConvergeEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.autoConverge(), constants.dontAutoConverge(), constants.inheritFromCluster()), new ModeSwitchingVisibilityRenderer());
    migrateCompressedEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.compress(), constants.dontCompress(), constants.inheritFromCluster()), new ModeSwitchingVisibilityRenderer());
    // Resource Allocation
    provisioningThinEditor = // $NON-NLS-1$
    new EntityModelRadioButtonEditor("provisioningGroup", new ModeSwitchingVisibilityRenderer());
    provisioningCloneEditor = // $NON-NLS-1$
    new EntityModelRadioButtonEditor("provisioningGroup", new ModeSwitchingVisibilityRenderer());
    // Boot Options Tab
    firstBootDeviceEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<BootSequence>>() {

        @Override
        public String renderNullSafe(EntityModel<BootSequence> object) {
            return object.getTitle();
        }
    }, new ModeSwitchingVisibilityRenderer());
    secondBootDeviceEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<BootSequence>>() {

        @Override
        public String renderNullSafe(EntityModel<BootSequence> object) {
            return object.getTitle();
        }
    }, new ModeSwitchingVisibilityRenderer());
    cdImageEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<RepoImage>() {

        @Override
        public String renderNullSafe(RepoImage object) {
            // For old ISO images from an ISO domain the image name is empty
            if (StringHelper.isNullOrEmpty(object.getRepoImageName())) {
                return object.getRepoImageId();
            }
            return object.getRepoImageName();
        }
    }, new ModeSwitchingVisibilityRenderer());
    cdImageEditor.hideLabel();
    cpuProfilesEditor = new ListModelListBoxEditor<>(new NameRenderer<CpuProfile>());
    cpuSharesAmountSelectionEditor = new ListModelListBoxOnlyEditor<>(new EnumRenderer<UnitVmModel.CpuSharesAmount>(), new ModeSwitchingVisibilityRenderer());
    numaTuneMode = new ListModelListBoxEditor<>(new EnumRenderer(), new ModeSwitchingVisibilityRenderer());
    providersEditor = new ListModelListBoxEditor<>(new NameRenderer<Provider<OpenstackNetworkProviderProperties>>());
    providersEditor.setLabel(constants.providerLabel());
}
Also used : ListModelTypeAheadChangeableListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) NullSafeRenderer(org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer) DataCenterWithCluster(org.ovirt.engine.ui.uicommonweb.models.vms.DataCenterWithCluster) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) EntityModelDetachableWidgetWithLabel(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelDetachableWidgetWithLabel) BooleanRendererWithNullText(org.ovirt.engine.ui.common.widget.renderer.BooleanRendererWithNullText) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) BootSequence(org.ovirt.engine.core.common.businessentities.BootSequence) VmPoolType(org.ovirt.engine.core.common.businessentities.VmPoolType) EnableableFormLabel(org.ovirt.engine.ui.common.widget.label.EnableableFormLabel) TimeZoneModel(org.ovirt.engine.ui.uicommonweb.models.vms.TimeZoneModel) VncKeyMapRenderer(org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer) GroupedListModelListBox(org.ovirt.engine.ui.common.widget.editor.GroupedListModelListBox) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) EntityModelWidgetWithInfo(org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo) Quota(org.ovirt.engine.core.common.businessentities.Quota) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) IntegerEntityModelTextBoxOnlyEditor(org.ovirt.engine.ui.common.widget.editor.generic.IntegerEntityModelTextBoxOnlyEditor) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)

Example 10 with InstanceType

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

the class PoolModelBehaviorBase method setupWindowModelFrom.

protected void setupWindowModelFrom(final VmBase vmBase) {
    if (vmBase != null) {
        updateQuotaByCluster(vmBase.getQuotaId(), vmBase.getQuotaName());
        // Copy VM parameters from template.
        buildModel(vmBase, (source, destination) -> {
            setSelectedOSType(vmBase, getModel().getSelectedCluster().getArchitecture());
            getModel().getVmType().setSelectedItem(vmBase.getVmType());
            getModel().getUsbPolicy().setSelectedItem(vmBase.getUsbPolicy());
            getModel().getIsRunAndPause().setEntity(false);
            boolean hasCd = !StringHelper.isNullOrEmpty(vmBase.getIsoPath());
            getModel().getCdImage().setIsChangeable(hasCd);
            getModel().getCdAttached().setEntity(hasCd);
            updateTimeZone(vmBase.getTimeZone());
            if (!vmBase.getId().equals(Guid.Empty)) {
                getModel().getStorageDomain().setIsChangeable(true);
                initDisks();
            } else {
                getModel().getStorageDomain().setIsChangeable(false);
                getModel().setIsDisksAvailable(false);
                getModel().setDisks(null);
            }
            getModel().getProvisioning().setEntity(false);
            initStorageDomains();
            InstanceType selectedInstanceType = getModel().getInstanceTypes().getSelectedItem();
            int instanceTypeMinAllocatedMemory = selectedInstanceType != null ? selectedInstanceType.getMinAllocatedMem() : 0;
            // do not update if specified on template or instance type
            if (vmBase.getMinAllocatedMem() == 0 && instanceTypeMinAllocatedMemory == 0) {
                updateMinAllocatedMemory();
            }
            getModel().getAllowConsoleReconnect().setEntity(vmBase.isAllowConsoleReconnect());
            toggleAutoSetVmHostname();
            getModel().getVmInitModel().init(vmBase);
            getModel().getVmInitEnabled().setEntity(vmBase.getVmInit() != null);
            if (getModel().getSelectedCluster() != null) {
                updateCpuProfile(getModel().getSelectedCluster().getId(), vmBase.getCpuProfileId());
            }
            getModel().getCpuSharesAmount().setEntity(vmBase.getCpuShares());
            updateCpuSharesSelection();
            // A workaround for setting the current saved CustomCompatibilityVersion value after
            // it was reset by getTemplateWithVersion event
            getModel().getCustomCompatibilityVersion().setSelectedItem(getSavedCurrentCustomCompatibilityVersion());
            setCustomCompatibilityVersionChangeInProgress(false);
            getModel().updateResumeBehavior();
        });
    }
}
Also used : InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

Aggregations

InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)10 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)3 Quota (org.ovirt.engine.core.common.businessentities.Quota)2 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)2 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)2 Guid (org.ovirt.engine.core.compat.Guid)2 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)2 UnitVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)2 AbstractRenderer (com.google.gwt.text.shared.AbstractRenderer)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 GraphicsConsoles (org.ovirt.engine.api.model.GraphicsConsoles)1 Vm (org.ovirt.engine.api.model.Vm)1 BootSequence (org.ovirt.engine.core.common.businessentities.BootSequence)1