Search in sources :

Example 1 with UpdateVmTemplateParameters

use of org.ovirt.engine.core.common.action.UpdateVmTemplateParameters in project ovirt-engine by oVirt.

the class InstanceTypeListModel method onEditInstanceType.

private void onEditInstanceType() {
    UnitVmModel model = (UnitVmModel) getWindow();
    if (!model.validateInstanceTypePart()) {
        return;
    }
    VmTemplate instanceType = (VmTemplate) Cloner.clone(selectedItem);
    instanceType.setTemplateType(VmEntityType.INSTANCE_TYPE);
    buildVmStatic(instanceType);
    instanceType.setDescription(model.getDescription().getEntity());
    UpdateVmTemplateParameters updateInstanceTypeParameters = new UpdateVmTemplateParameters(instanceType);
    updateInstanceTypeParameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    updateInstanceTypeParameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    updateInstanceTypeParameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
    updateInstanceTypeParameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        updateInstanceTypeParameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
    }
    setVmWatchdogToParams(model, updateInstanceTypeParameters);
    setRngDeviceToParams(model, updateInstanceTypeParameters);
    BuilderExecutor.build(model, updateInstanceTypeParameters, new UnitToGraphicsDeviceParamsBuilder());
    getWindow().startProgress();
    Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, updateInstanceTypeParameters, new UnitVmModelNetworkAsyncCallback(model, addInstanceTypeNetworkManager, instanceType.getId()), this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) UnitVmModelNetworkAsyncCallback(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback) 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 2 with UpdateVmTemplateParameters

use of org.ovirt.engine.core.common.action.UpdateVmTemplateParameters in project ovirt-engine by oVirt.

the class UpdateClusterCommand method updateTemplates.

private boolean updateTemplates() {
    for (VmTemplate template : templatesLockedForUpdate) {
        // the object was loaded in before command execution started and thus the value may be outdated
        template.setClusterCompatibilityVersion(getCluster().getCompatibilityVersion());
        UpdateVmTemplateParameters parameters = new UpdateVmTemplateParameters(template);
        // Locking by UpdateVmTemplate is disabled since templates are already locked in #getExclusiveLocks method.
        parameters.setLockProperties(LockProperties.create(LockProperties.Scope.None));
        parameters.setClusterLevelChangeFromVersion(oldCluster.getCompatibilityVersion());
        updateRngDeviceIfNecessary(template.getId(), template.getCustomCompatibilityVersion(), parameters);
        updateResumeBehavior(template);
        final ActionReturnValue result = runInternalAction(ActionType.UpdateVmTemplate, parameters, cloneContextAndDetachFromParent());
        if (!result.getSucceeded()) {
            List<String> params = new ArrayList<>();
            params.add("$action Update");
            params.add("$type Template");
            params.add(parseErrorMessage(result.getValidationMessages()));
            List<String> messages = Backend.getInstance().getErrorsTranslator().translateErrorText(params);
            failedUpgradeEntities.put(template.getName(), getFailedMessage(messages));
        }
    }
    return true;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) ArrayList(java.util.ArrayList)

Example 3 with UpdateVmTemplateParameters

use of org.ovirt.engine.core.common.action.UpdateVmTemplateParameters 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)

Aggregations

UpdateVmTemplateParameters (org.ovirt.engine.core.common.action.UpdateVmTemplateParameters)3 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)2 UnitVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)2 ArrayList (java.util.ArrayList)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 UnitVmModelNetworkAsyncCallback (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback)1