Search in sources :

Example 21 with VmTemplate

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

the class TemplateGeneralModel method updateProperties.

private void updateProperties() {
    VmTemplate template = getEntity();
    super.updateProperties(template.getId());
    setName(template.getName());
    setTemplateId(template.getId().toString());
    setDescription(template.getDescription());
    // $NON-NLS-1$
    setQuotaName(template.getQuotaName() != null ? template.getQuotaName() : "");
    setQuotaAvailable(template.getQuotaEnforcementType() != null && !template.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
    setHostCluster(template.getClusterName());
    // $NON-NLS-1$
    setDefinedMemory(template.getMemSizeMb() + " MB");
    setIsHighlyAvailable(template.isAutoStartup());
    setPriority(AsyncDataProvider.getInstance().priorityToString(template.getPriority()));
    setMonitorCount(template.getNumOfMonitors());
    setAllowConsoleReconnect(template.isAllowConsoleReconnect());
    setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(template.getNumOfCpus(), template.getNumOfSockets(), template.getCpuPerSocket(), template.getThreadsPerCpu()));
    setOS(AsyncDataProvider.getInstance().getOsName(template.getOsId()));
    Translator translator = EnumTranslator.getInstance();
    setOptimizedForSystemProfile(translator.translate(template.getVmType()));
    setDefaultDisplayType(translator.translate(template.getDefaultDisplayType()));
    setOrigin(translator.translate(template.getOrigin()));
    setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(template.getOsId()));
    if (template.getVmInit() != null) {
        setDomain(template.getVmInit().getDomain());
    }
    setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(template.getOsId()));
    setTimeZone(template.getTimeZone());
    setHasUsbPolicy(true);
    setUsbPolicy(translator.translate(template.getUsbPolicy()));
    setIsStateless(template.isStateless());
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator)

Example 22 with VmTemplate

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

the class StorageTemplateListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    super.syncSearch();
    GetVmTemplatesFromStorageDomainParameters tempVar = new GetVmTemplatesFromStorageDomainParameters(getEntity().getId(), true);
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetVmTemplatesFromStorageDomain, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<VmTemplate> templates = returnValue.getReturnValue();
        Collections.sort(templates, new LexoNumericNameableComparator<>());
        setItems(templates);
        setIsEmpty(templates.size() == 0);
    }));
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Frontend(org.ovirt.engine.ui.frontend.Frontend) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GetVmTemplatesFromStorageDomainParameters(org.ovirt.engine.core.common.queries.GetVmTemplatesFromStorageDomainParameters) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) Collections(java.util.Collections) ArrayList(java.util.ArrayList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) ArrayList(java.util.ArrayList) GetVmTemplatesFromStorageDomainParameters(org.ovirt.engine.core.common.queries.GetVmTemplatesFromStorageDomainParameters)

Example 23 with VmTemplate

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

the class ImportTemplatePopupView method initMainTable.

@Override
protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    AbstractCheckboxColumn<Object> cloneTemplateColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportTemplateData) model).getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

        @Override
        public Boolean getValue(Object model) {
            return ((ImportTemplateData) model).getClone().getEntity();
        }

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportTemplateData) model).getClone().getIsChangable();
        }
    };
    // $NON-NLS-1$
    table.addColumn(cloneTemplateColumn, constants.cloneVM(), "50px");
    AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return ((ImportTemplateData) object).getTemplate().getName();
        }
    };
    // $NON-NLS-1$
    table.addColumn(nameColumn, constants.nameTemplate(), "150px");
    AbstractTextColumn<Object> versionNameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            VmTemplate template = ((ImportTemplateData) object).getTemplate();
            if (template.isBaseTemplate()) {
                // $NON-NLS-1$
                return "";
            }
            return // $NON-NLS-1$
            StringFormat.format(// $NON-NLS-1$
            "%s (%s)", // $NON-NLS-1$
            template.getTemplateVersionName() != null ? template.getTemplateVersionName() : "", template.getTemplateVersionNumber());
        }
    };
    // $NON-NLS-1$
    table.addColumn(versionNameColumn, constants.versionTemplate(), "150px");
    AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {

        @Override
        protected OriginType getRawValue(Object object) {
            return ((ImportTemplateData) object).getTemplate().getOrigin();
        }
    };
    // $NON-NLS-1$
    table.addColumn(originColumn, constants.originTemplate(), "100px");
    AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return messages.megabytes(String.valueOf(((ImportTemplateData) object).getTemplate().getMemSizeMb()));
        }
    };
    // $NON-NLS-1$
    table.addColumn(memoryColumn, constants.memoryTemplate(), "100px");
    AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getNumOfCpus());
        }
    };
    // $NON-NLS-1$
    table.addColumn(cpuColumn, constants.cpusTemplate(), "50px");
    AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getClusterArch());
        }
    };
    // $NON-NLS-1$
    table.addColumn(archColumn, constants.architectureTemplate(), "50px");
    AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getDiskList().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksTemplate(), "50px");
    isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            return ((ImportTemplateData) object).isExistsInSystem() ? resources.logNormalImage() : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isObjectInSystemColumn, constants.templateInSetup(), "60px");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) ImageResource(com.google.gwt.resources.client.ImageResource) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 24 with VmTemplate

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

the class NewPoolModelBehavior method templateWithVersion_SelectedItemChanged.

@Override
public void templateWithVersion_SelectedItemChanged() {
    super.templateWithVersion_SelectedItemChanged();
    VmTemplate template = getModel().getTemplateWithVersion().getSelectedItem() != null ? getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion() : null;
    if (template == null) {
        return;
    }
    setupWindowModelFrom(template);
    doChangeDefaultHost(template.getDedicatedVmForVdsList());
    updateRngDevice(template.getId());
    getModel().getCustomPropertySheet().deserialize(template.getCustomProperties());
    if (getModel().getVmType().getSelectedItem() == VmType.HighPerformance && !clusterHasPpcArchitecture()) {
        getModel().getHostCpu().setEntity(true);
    }
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 25 with VmTemplate

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

the class NewPoolModelBehavior method postDataCenterWithClusterSelectedItemChanged.

@Override
public void postDataCenterWithClusterSelectedItemChanged() {
    super.postDataCenterWithClusterSelectedItemChanged();
    final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
    StoragePool dataCenter = getModel().getSelectedDataCenter();
    if (dataCenter == null) {
        return;
    }
    AsyncDataProvider.getInstance().getTemplateListByDataCenter(asyncQuery(templatesByDataCenter -> {
        List<VmTemplate> properArchitectureTemplates = AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templatesByDataCenter, dataCenterWithCluster.getCluster().getArchitecture());
        List<VmTemplate> templatesWithoutBlank = new ArrayList<>();
        for (VmTemplate template : properArchitectureTemplates) {
            final boolean isBlankOrVersionOfBlank = template.getId().equals(Guid.Empty) || template.getBaseTemplateId().equals(Guid.Empty);
            if (!isBlankOrVersionOfBlank) {
                templatesWithoutBlank.add(template);
            }
        }
        // CustomCompatibilityVersion won't be reset by a selected template.
        if (templatesWithoutBlank.isEmpty()) {
            setCustomCompatibilityVersionChangeInProgress(false);
        }
        initTemplateWithVersion(templatesWithoutBlank, null, false);
    }), dataCenter.getId());
    instanceTypeManager.updateAll();
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmType(org.ovirt.engine.core.common.businessentities.VmType) Guid(org.ovirt.engine.core.compat.Guid) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) NewPoolInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.NewPoolInstanceTypeManager) NewPoolNameLengthValidation(org.ovirt.engine.ui.uicommonweb.validation.NewPoolNameLengthValidation) List(java.util.List) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)149 ArrayList (java.util.ArrayList)42 Guid (org.ovirt.engine.core.compat.Guid)40 Test (org.junit.Test)30 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)23 HashMap (java.util.HashMap)22 List (java.util.List)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)16 Map (java.util.Map)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)13 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)9 Collection (java.util.Collection)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)8