Search in sources :

Example 16 with VmTemplate

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

the class TemplateImportInterfaceListModel method onEntityChanged.

@Override
protected void onEntityChanged() {
    super.onEntityChanged();
    if (getEntity() != null) {
        VmTemplate template = (VmTemplate) getEntity();
        setItems(template.getInterfaces());
    } else {
        setItems(null);
    }
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 17 with VmTemplate

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

the class TemplateListModel method createVMFromTemplate.

private void createVMFromTemplate() {
    VmTemplate template = getSelectedItem();
    final List<UICommand> commands = new ArrayList<>();
    // $NON-NLS-1$
    commands.add(UICommand.createDefaultOkUiCommand("OnSaveVm", this));
    // $NON-NLS-1$
    commands.add(UICommand.createCancelUiCommand("Cancel", this));
    AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(withVmInit -> setupNewVmModel(new UnitVmModel(new NewVmFromTemplateModelBehavior(withVmInit), TemplateListModel.this), withVmInit.getVmType(), commands)), template.getId());
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Inject(com.google.inject.Inject) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionType(org.ovirt.engine.core.common.action.ActionType) VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) List(java.util.List) VersionNameUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VersionNameUnitToVmBaseBuilder) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) VmModelBehaviorBase(org.ovirt.engine.ui.uicommonweb.models.vms.VmModelBehaviorBase) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmTemplateManagementParameters(org.ovirt.engine.core.common.action.VmTemplateManagementParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) TemplateVmModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) IconCache(org.ovirt.engine.ui.uicommonweb.models.vms.IconCache) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) NewVmFromTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewVmFromTemplateModelBehavior) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) NewVmFromTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewVmFromTemplateModelBehavior) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 18 with VmTemplate

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

the class TemplateListModel method edit.

private void edit() {
    VmTemplate template = getSelectedItem();
    if (getWindow() != null) {
        return;
    }
    // populating VMInit
    AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(result -> vmInitLoaded(result)), template.getId());
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Inject(com.google.inject.Inject) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionType(org.ovirt.engine.core.common.action.ActionType) VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) List(java.util.List) VersionNameUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VersionNameUnitToVmBaseBuilder) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) VmModelBehaviorBase(org.ovirt.engine.ui.uicommonweb.models.vms.VmModelBehaviorBase) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmTemplateManagementParameters(org.ovirt.engine.core.common.action.VmTemplateManagementParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) TemplateVmModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) IconCache(org.ovirt.engine.ui.uicommonweb.models.vms.IconCache) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) NewVmFromTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.NewVmFromTemplateModelBehavior) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 19 with VmTemplate

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

the class ImportTemplateModel method createSearchPattern.

private String createSearchPattern(Collection<VmTemplate> templates) {
    // $NON-NLS-1$
    String vmt_guidKey = "_VMT_ID =";
    // $NON-NLS-1$
    String orKey = " or ";
    StringBuilder searchPattern = new StringBuilder();
    // $NON-NLS-1$
    searchPattern.append("Template: ");
    for (VmTemplate template : templates) {
        searchPattern.append(vmt_guidKey);
        searchPattern.append(template.getId().toString());
        searchPattern.append(orKey);
        searchPattern.append(vmt_guidKey);
        searchPattern.append(template.getBaseTemplateId().toString());
        searchPattern.append(orKey);
    }
    return searchPattern.substring(0, searchPattern.length() - orKey.length());
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 20 with VmTemplate

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

the class ImportTemplateModel method init.

public void init(final Collection<VmTemplate> externalTemplates, final Guid storageDomainId) {
    Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(createSearchPattern(externalTemplates), SearchType.VmTemplate), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

        @Override
        public void onSuccess(QueryReturnValue returnValue) {
            UIConstants constants = ConstantsManager.getInstance().getConstants();
            List<VmTemplate> vmtList = returnValue.getReturnValue();
            List<ImportTemplateData> templateDataList = new ArrayList<>();
            for (VmTemplate template : externalTemplates) {
                ImportTemplateData templateData = new ImportTemplateData(template);
                boolean templateExistsInSystem = vmtList.contains(template);
                templateData.setExistsInSystem(templateExistsInSystem);
                if (templateExistsInSystem) {
                    templateData.enforceClone(constants.importTemplateThatExistsInSystemMustClone());
                } else if (!template.isBaseTemplate() && findAnyVmTemplateById(vmtList, template.getBaseTemplateId()) == null) {
                    templateData.enforceClone(constants.importTemplateWithoutBaseMustClone());
                }
                templateDataList.add(templateData);
            }
            setItems(templateDataList);
            withDataCenterLoaded(storageDomainId, r -> doInit());
        }

        private VmTemplate findAnyVmTemplateById(List<VmTemplate> vmtList, Guid templateId) {
            for (VmTemplate vmt : vmtList) {
                if (templateId.equals(vmt.getId())) {
                    return vmt;
                }
            }
            return null;
        }
    }));
}
Also used : AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

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