Search in sources :

Example 6 with UnitToGraphicsDeviceParamsBuilder

use of org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder in project ovirt-engine by oVirt.

the class InstanceTypeListModel method postInstanceTypeNameUniqueCheck.

private void postInstanceTypeNameUniqueCheck() {
    UnitVmModel model = (UnitVmModel) getWindow();
    VM vm = new VM();
    buildVmStatic(vm.getStaticData());
    vm.setVmDescription(model.getDescription().getEntity());
    AddVmTemplateParameters addInstanceTypeParameters = new AddVmTemplateParameters(vm, model.getName().getEntity(), model.getDescription().getEntity());
    addInstanceTypeParameters.setTemplateType(VmEntityType.INSTANCE_TYPE);
    addInstanceTypeParameters.setVmTemplateId(null);
    addInstanceTypeParameters.setPublicUse(true);
    addInstanceTypeParameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    addInstanceTypeParameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    addInstanceTypeParameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
    addInstanceTypeParameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        addInstanceTypeParameters.getVm().setDefaultDisplayType(DisplayType.none);
    }
    setVmWatchdogToParams(model, addInstanceTypeParameters);
    setRngDeviceToParams(model, addInstanceTypeParameters);
    BuilderExecutor.build(model, addInstanceTypeParameters, new UnitToGraphicsDeviceParamsBuilder());
    getWindow().startProgress();
    Frontend.getInstance().runAction(ActionType.AddVmTemplate, addInstanceTypeParameters, new UnitVmModelNetworkAsyncCallback(model, addInstanceTypeNetworkManager), this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) UnitVmModelNetworkAsyncCallback(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback) VM(org.ovirt.engine.core.common.businessentities.VM) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)

Example 7 with UnitToGraphicsDeviceParamsBuilder

use of org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder 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

UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)7 VM (org.ovirt.engine.core.common.businessentities.VM)4 UnitVmModel (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel)3 UpdateVmTemplateParameters (org.ovirt.engine.core.common.action.UpdateVmTemplateParameters)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 Guid (org.ovirt.engine.core.compat.Guid)2 UnitVmModelNetworkAsyncCallback (org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModelNetworkAsyncCallback)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 AddVmFromSnapshotParameters (org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters)1 AddVmParameters (org.ovirt.engine.core.common.action.AddVmParameters)1 AddVmPoolParameters (org.ovirt.engine.core.common.action.AddVmPoolParameters)1 AddVmTemplateParameters (org.ovirt.engine.core.common.action.AddVmTemplateParameters)1 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)1 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)1 VmPool (org.ovirt.engine.core.common.businessentities.VmPool)1 VmPoolType (org.ovirt.engine.core.common.businessentities.VmPoolType)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 VmIconUnitAndVmToParameterBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.VmIconUnitAndVmToParameterBuilder)1