Search in sources :

Example 11 with UnitVmModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.

the class TemplateListModel method postNameUniqueCheck.

public void postNameUniqueCheck() {
    final UnitVmModel model = (UnitVmModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    VmTemplate selectedItem;
    if (model.getBehavior().isExistingTemplateBehavior()) {
        selectedItem = ((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate();
    } else {
        selectedItem = ((ExistingBlankTemplateModelBehavior) model.getBehavior()).getVmTemplate();
    }
    final VmTemplate template = (VmTemplate) Cloner.clone(selectedItem);
    final String iconForParameters = IconCache.getInstance().getIcon(selectedItem.getLargeIconId()).equals(model.getIcon().getEntity().getIcon()) ? null : IconUtils.filterPredefinedIcons(model.getIcon().getEntity().getIcon());
    // Save changes.
    buildTemplateOnSave(model, template);
    template.setCreatedByUserId(selectedItem.getCreatedByUserId());
    model.startProgress();
    template.setVmInit(model.getVmInitModel().buildCloudInitParameters(model));
    UpdateVmTemplateParameters parameters = new UpdateVmTemplateParameters(template);
    parameters.setVmLargeIcon(iconForParameters);
    parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    setVmWatchdogToParams(model, parameters);
    BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
    parameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    setVmRngDeviceToParams(model, parameters);
    parameters.setBalloonEnabled(balloonEnabled(model));
    parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        parameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
    }
    Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, parameters, result -> {
        TemplateListModel localModel = (TemplateListModel) result.getState();
        localModel.postUpdateVmTemplate(result.getReturnValue());
    }, this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 12 with UnitVmModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.

the class TemplateListModel method executeCommand.

@Override
public void executeCommand(UICommand command) {
    super.executeCommand(command);
    if (command == getEditCommand()) {
        edit();
    } else if (command == getRemoveCommand()) {
        remove();
    } else if (command == getExportCommand()) {
        export();
    } else if (command == getCreateVmFromTemplateCommand()) {
        createVMFromTemplate();
    } else if ("Cancel".equals(command.getName())) {
        // $NON-NLS-1$
        cancel();
    } else if ("OnExport".equals(command.getName())) {
        // $NON-NLS-1$
        onExport();
    } else if ("OnSave".equals(command.getName())) {
        // $NON-NLS-1$
        onSave();
    } else if ("OnSaveVm".equals(command.getName())) {
        // $NON-NLS-1$
        onSaveVm();
    } else if ("postNameUniqueCheck".equals(command.getName())) {
        // $NON-NLS-1$
        postNameUniqueCheck();
        setConfirmWindow(null);
    } else if ("OnRemove".equals(command.getName())) {
        // $NON-NLS-1$
        onRemove();
    } else if ("OnExportNoTemplates".equals(command.getName())) {
        // $NON-NLS-1$
        doExport();
    } else if ("CancelConfirmation".equals(command.getName())) {
        // $NON-NLS-1$
        cancelConfirmation();
    } else if ("SaveOrUpdateVM".equals(command.getName())) {
        // $NON-NLS-1$
        UnitVmModel model = (UnitVmModel) getWindow();
        if (!model.validate()) {
            return;
        }
        saveOrUpdateVM(model);
    }
}
Also used : UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 13 with UnitVmModel

use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.

the class VmBaseListModel method displayHighPerformanceConfirmationPopup.

protected void displayHighPerformanceConfirmationPopup() {
    final UnitVmModel model = (UnitVmModel) getWindow();
    if (model == null || model.getProgress() != null) {
        return;
    }
    VmHighPerformanceConfigurationModel confirmModel = new VmHighPerformanceConfigurationModel();
    // Handle CPU Pinning topology
    final boolean isVmAssignedToSpecificHosts = !model.getIsAutoAssign().getEntity();
    final boolean isVmCpuPinningSet = model.getCpuPinning().getIsChangable() && model.getCpuPinning().getEntity() != null && !model.getCpuPinning().getEntity().isEmpty();
    confirmModel.addRecommendationForCpuPinning(isVmAssignedToSpecificHosts, isVmCpuPinningSet);
    // Handle NUMA
    final boolean isVmVirtNumaSet = model.getNumaEnabled().getEntity() && model.getNumaNodeCount().getEntity() > 0;
    final boolean isVmVirtNumaPinned = model.getVmNumaNodes() != null && !model.getVmNumaNodes().isEmpty() && model.getVmNumaNodes().stream().filter(x -> !x.getVdsNumaNodeList().isEmpty()).count() > 0;
    confirmModel.addRecommendationForVirtNumaSetAndPinned(isVmVirtNumaSet, isVmVirtNumaPinned);
    // Handle Huge Pages
    KeyValueModel keyValue = model.getCustomPropertySheet();
    // $NON-NLS-1$
    final boolean isVmHugePagesSet = keyValue != null && keyValue.getUsedKeys().contains("hugepages");
    confirmModel.addRecommendationForHugePages(isVmHugePagesSet);
    // Handle KSM (Kernel Same Page Merging)
    confirmModel.addRecommendationForKsm(model.getSelectedCluster().isEnableKsm(), model.getSelectedCluster().getName());
    // If there are recommendations to display and it is not a Pool VM then display the popup
    if (!confirmModel.getRecommendationsList().isEmpty() && !model.isVmAttachedToPool()) {
        confirmModel.setTitle(ConstantsManager.getInstance().getConstants().configurationChangesForHighPerformanceVmTitle());
        confirmModel.setHelpTag(HelpTag.configuration_changes_for_high_performance_vm);
        // $NON-NLS-1$
        confirmModel.setHashName("configuration_changes_for_high_performance_vm");
        confirmModel.getCommands().add(// $NON-NLS-1$
        new UICommand("SaveOrUpdateVM", VmBaseListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
        confirmModel.getCommands().add(// $NON-NLS-1$
        UICommand.createCancelUiCommand("CancelConfirmation", VmBaseListModel.this));
        setConfirmWindow(null);
        setConfirmWindow(confirmModel);
    } else {
        saveOrUpdateVM(model);
    }
}
Also used : ExportVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportVmModel) FullUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.FullUnitToVmBaseBuilder) FrontendActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult) VmType(org.ovirt.engine.core.common.businessentities.VmType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters) 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) VmInterfaceCreatingManager(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceCreatingManager) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) StringHelper(org.ovirt.engine.core.compat.StringHelper) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) List(java.util.List) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) 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) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) HasDiskWindow(org.ovirt.engine.ui.uicommonweb.models.vms.HasDiskWindow) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) UnitVmModelNetworkAsyncCallback(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) ExportOvaModel(org.ovirt.engine.ui.uicommonweb.models.vms.ExportOvaModel) BalloonEnabled(org.ovirt.engine.ui.uicommonweb.models.vms.BalloonEnabled) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmBasedWidgetSwitchModeCommand(org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand) IconUtils(org.ovirt.engine.ui.uicommonweb.IconUtils) VM(org.ovirt.engine.core.common.businessentities.VM) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmSpecificUnitToVmBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmSpecificUnitToVmBuilder) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Aggregations

UnitVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)13 VM (org.ovirt.engine.core.common.businessentities.VM)6 UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)6 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 UpdateVmTemplateParameters (org.ovirt.engine.core.common.action.UpdateVmTemplateParameters)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 VmBasedWidgetSwitchModeCommand (org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 ActionType (org.ovirt.engine.core.common.action.ActionType)3 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VmType (org.ovirt.engine.core.common.businessentities.VmType)3 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)3 VmWatchdogType (org.ovirt.engine.core.common.businessentities.VmWatchdogType)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 Guid (org.ovirt.engine.core.compat.Guid)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3