Search in sources :

Example 1 with UnitToGraphicsDeviceParamsBuilder

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

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

the class VmListModel method getUpdateVmParameters.

public VmManagementParametersBase getUpdateVmParameters(boolean applyCpuChangesLater) {
    UnitVmModel model = (UnitVmModel) getWindow();
    VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getcurrentVm());
    setVmWatchdogToParams(model, updateVmParams);
    updateVmParams.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    updateVmParams.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    updateVmParams.setBalloonEnabled(balloonEnabled(model));
    updateVmParams.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    updateVmParams.setApplyChangesLater(applyCpuChangesLater);
    updateVmParams.setUpdateNuma(model.isNumaChanged());
    updateVmParams.setAffinityLabels(model.getLabelList().getSelectedItems());
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        updateVmParams.getVmStaticData().setDefaultDisplayType(DisplayType.none);
    }
    BuilderExecutor.build(new Pair<>((UnitVmModel) getWindow(), getSelectedItem()), updateVmParams, new VmIconUnitAndVmToParameterBuilder());
    setRngDeviceToParams(model, updateVmParams);
    BuilderExecutor.build(model, updateVmParams, new UnitToGraphicsDeviceParamsBuilder());
    return updateVmParams;
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmIconUnitAndVmToParameterBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmIconUnitAndVmToParameterBuilder)

Example 3 with UnitToGraphicsDeviceParamsBuilder

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

the class VmSnapshotListModel method onCloneVM.

private void onCloneVM() {
    UnitVmModel model = (UnitVmModel) getWindow();
    CloneVmFromSnapshotModelBehavior behavior = (CloneVmFromSnapshotModelBehavior) model.getBehavior();
    Snapshot snapshot = getSelectedItem();
    if (snapshot == null) {
        cancel();
        return;
    }
    if (!model.validate()) {
        return;
    }
    VM vm = behavior.getVm();
    // Save changes.
    buildVmOnClone(model, vm);
    vm.setUseHostCpuFlags(model.getHostCpu().getEntity());
    vm.setDiskMap(behavior.getVm().getDiskMap());
    HashMap<Guid, DiskImage> imageToDestinationDomainMap = model.getDisksAllocationModel().getImageToDestinationDomainMap();
    AddVmFromSnapshotParameters parameters = new AddVmFromSnapshotParameters(vm.getStaticData(), snapshot.getId());
    parameters.setDiskInfoDestinationMap(imageToDestinationDomainMap);
    parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    parameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
    BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
    if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
        parameters.setVmId(new Guid(model.getVmId().getEntity()));
    }
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.AddVmFromSnapshot, parameters, result -> {
        VmSnapshotListModel vmSnapshotListModel = (VmSnapshotListModel) result.getState();
        vmSnapshotListModel.getWindow().stopProgress();
        ActionReturnValue returnValueBase = result.getReturnValue();
        if (returnValueBase != null && returnValueBase.getSucceeded()) {
            vmSnapshotListModel.cancel();
            vmSnapshotListModel.updateActionAvailability();
        }
    }, this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) AddVmFromSnapshotParameters(org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 4 with UnitToGraphicsDeviceParamsBuilder

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

the class VmBaseListModel method saveNewVm.

private void saveNewVm(final UnitVmModel model) {
    if (model.getProgress() != null) {
        return;
    }
    model.startProgress();
    VM vm = getcurrentVm();
    if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
        vm.setId(new Guid(model.getVmId().getEntity()));
    }
    vm.setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
    AddVmParameters parameters = new AddVmParameters(vm);
    parameters.setDiskInfoDestinationMap(model.getDisksAllocationModel().getImageToDestinationDomainMap());
    parameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    parameters.setBalloonEnabled(balloonEnabled(model));
    parameters.setCopyTemplatePermissions(model.getCopyPermissions().getEntity());
    parameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    parameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    parameters.setVmLargeIcon(IconUtils.filterPredefinedIcons(model.getIcon().getEntity().getIcon()));
    parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
    setVmWatchdogToParams(model, parameters);
    setRngDeviceToParams(model, parameters);
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        parameters.getVmStaticData().setDefaultDisplayType(DisplayType.none);
    }
    BuilderExecutor.build(model, parameters, new UnitToGraphicsDeviceParamsBuilder());
    if (!StringHelper.isNullOrEmpty(model.getVmId().getEntity())) {
        parameters.setVmId(new Guid(model.getVmId().getEntity()));
    }
    Frontend.getInstance().runAction(model.getProvisioning().getEntity() ? ActionType.AddVmFromTemplate : ActionType.AddVm, parameters, createUnitVmModelNetworkAsyncCallback(vm, model), this);
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters)

Example 5 with UnitToGraphicsDeviceParamsBuilder

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

the class PoolListModel method savePoolPostValidation.

public void savePoolPostValidation() {
    final PoolModel model = (PoolModel) getWindow();
    VmPool pool = getCurrentPool();
    setConfirmWindow(null);
    // Save changes.
    pool.setName(model.getName().getEntity());
    pool.setVmPoolDescription(model.getDescription().getEntity());
    pool.setClusterId(model.getSelectedCluster().getId());
    pool.setComment(model.getComment().getEntity());
    pool.setStateful(model.getPoolStateful().getEntity());
    pool.setPrestartedVms(model.getPrestartedVms().getEntity());
    pool.setMaxAssignedVmsPerUser(model.getMaxAssignedVmsPerUser().getEntity());
    pool.setAutoStorageSelect(model.getDisksAllocationModel().getDiskAllocationTargetEnabled().getEntity());
    EntityModel<VmPoolType> poolTypeSelectedItem = model.getPoolType().getSelectedItem();
    pool.setVmPoolType(poolTypeSelectedItem.getEntity());
    if (model.getSpiceProxyEnabled().getEntity()) {
        pool.setSpiceProxy(model.getSpiceProxy().getEntity());
    }
    VM vm = buildVmOnSave(model);
    vm.setVmInit(model.getVmInitModel().buildCloudInitParameters(model));
    vm.setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
    vm.setStateless(false);
    vm.setInstanceTypeId(model.getInstanceTypes().getSelectedItem().getId());
    AddVmPoolParameters param = new AddVmPoolParameters(pool, vm, model.getNumOfDesktops().getEntity());
    param.setStorageDomainId(Guid.Empty);
    param.setDiskInfoDestinationMap(model.getDisksAllocationModel().getImageToDestinationDomainMap());
    param.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
    param.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
    param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    param.setRngDevice(model.getIsRngEnabled().getEntity() ? model.generateRngDevice() : null);
    param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
    param.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
    if (model.getIsHeadlessModeEnabled().getEntity()) {
        param.getVmStaticData().setDefaultDisplayType(DisplayType.none);
    }
    BuilderExecutor.build(model, param, new UnitToGraphicsDeviceParamsBuilder());
    param.getVmStaticData().setUseHostCpuFlags(model.getHostCpu().getEntity());
    param.getVmStaticData().setCpuPinning(model.getCpuPinning().getEntity());
    if (model.getQuota().getSelectedItem() != null) {
        vm.setQuotaId(model.getQuota().getSelectedItem().getId());
    }
    model.startProgress();
    if (model.getIsNew()) {
        if (model.getIcon().getEntity().isCustom()) {
            param.setVmLargeIcon(model.getIcon().getEntity().getIcon());
        }
        Frontend.getInstance().runAction(ActionType.AddVmPool, param, result -> {
            cancel();
            stopProgress();
        }, this);
    } else {
        Frontend.getInstance().runAction(ActionType.UpdateVmPool, param, result -> {
            cancel();
            stopProgress();
        }, this);
    }
}
Also used : UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) VM(org.ovirt.engine.core.common.businessentities.VM) VmPoolType(org.ovirt.engine.core.common.businessentities.VmPoolType) AddVmPoolParameters(org.ovirt.engine.core.common.action.AddVmPoolParameters)

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