Search in sources :

Example 1 with VmManagementParametersBase

use of org.ovirt.engine.core.common.action.VmManagementParametersBase 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 2 with VmManagementParametersBase

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

the class VmListModel method updateExistingVm.

private void updateExistingVm(final boolean applyCpuChangesLater) {
    final UnitVmModel model = (UnitVmModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    // runEditVM: should be true if Cluster hasn't changed or if
    // Cluster has changed and Editing it in the Backend has succeeded:
    VM selectedItem = getSelectedItem();
    Guid oldClusterID = selectedItem.getClusterId();
    Guid newClusterID = model.getSelectedCluster().getId();
    if (!oldClusterID.equals(newClusterID)) {
        ChangeVMClusterParameters parameters = new ChangeVMClusterParameters(newClusterID, getcurrentVm().getId(), model.getCustomCompatibilityVersion().getSelectedItem());
        model.startProgress();
        Frontend.getInstance().runAction(ActionType.ChangeVMCluster, parameters, result -> {
            final VmListModel<Void> vmListModel = (VmListModel<Void>) result.getState();
            ActionReturnValue returnValueBase = result.getReturnValue();
            if (returnValueBase != null && returnValueBase.getSucceeded()) {
                VM vm = vmListModel.getcurrentVm();
                VmManagementParametersBase updateVmParams = vmListModel.getUpdateVmParameters(applyCpuChangesLater);
                Frontend.getInstance().runAction(ActionType.UpdateVm, updateVmParams, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, vm.getId()), vmListModel);
            } else {
                vmListModel.getWindow().stopProgress();
            }
        }, this);
    } else {
        model.startProgress();
        VmManagementParametersBase updateVmParams = getUpdateVmParameters(applyCpuChangesLater);
        Frontend.getInstance().runAction(ActionType.UpdateVm, updateVmParams, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, getcurrentVm().getId()), this);
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) ChangeVMClusterParameters(org.ovirt.engine.core.common.action.ChangeVMClusterParameters) Guid(org.ovirt.engine.core.compat.Guid) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase)

Example 3 with VmManagementParametersBase

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

the class UpdateVmPoolCommand method updatePoolVms.

private void updatePoolVms(List<VM> vmsInPool) {
    // new latest value
    boolean isUpdatedPoolLatest = getParameters().getVmStaticData().isUseLatestVersion();
    vmTemplateHandler.lockVmTemplateInTransaction(getParameters().getVmStaticData().getVmtGuid(), getCompensationContext());
    for (VM vm : vmsInPool) {
        VmManagementParametersBase updateParams = new VmManagementParametersBase(vm);
        updateParams.getVmStaticData().setUseLatestVersion(isUpdatedPoolLatest);
        if (!isUpdatedPoolLatest) {
            updateParams.getVmStaticData().setVmtGuid(getParameters().getVmStaticData().getVmtGuid());
        }
        ActionReturnValue result = runInternalActionWithTasksContext(ActionType.UpdateVm, updateParams, getLock());
        getTaskIdList().addAll(result.getInternalVdsmTaskIdList());
        setSucceeded(getSucceeded() && result.getSucceeded());
    }
    vmTemplateHandler.unlockVmTemplate(getParameters().getVmStaticData().getVmtGuid());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase)

Example 4 with VmManagementParametersBase

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

the class UpdateVmTemplateCommand method updateVmsOfInstanceType.

/**
 * only in case of InstanceType update, update all vms that are bound to it
 */
private void updateVmsOfInstanceType() {
    if (!isInstanceType()) {
        return;
    }
    // get vms from db
    List<VM> vmsToUpdate = vmDao.getVmsListByInstanceType(getVmTemplateId());
    for (VM vm : vmsToUpdate) {
        VmManagementParametersBase params = new VmManagementParametersBase(vm);
        params.setApplyChangesLater(true);
        runInternalAction(ActionType.UpdateVm, params);
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase)

Example 5 with VmManagementParametersBase

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

the class ProcessDownVmCommand method createUpdateVmParameters.

private VmManagementParametersBase createUpdateVmParameters() {
    // clear non updateable fields got from config
    getVm().setExportDate(null);
    getVm().setOvfVersion(null);
    VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
    updateVmParams.setUpdateWatchdog(true);
    updateVmParams.setSoundDeviceEnabled(false);
    updateVmParams.setBalloonEnabled(false);
    updateVmParams.setVirtioScsiEnabled(false);
    updateVmParams.setClearPayload(true);
    updateVmParams.setUpdateRngDevice(true);
    for (GraphicsType graphicsType : GraphicsType.values()) {
        updateVmParams.getGraphicsDevices().put(graphicsType, null);
    }
    for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
        switch(device.getType()) {
            case WATCHDOG:
                updateVmParams.setWatchdog(new VmWatchdog(device));
                break;
            case SOUND:
                updateVmParams.setSoundDeviceEnabled(true);
                break;
            case BALLOON:
                updateVmParams.setBalloonEnabled(true);
                break;
            case CONTROLLER:
                if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
                    updateVmParams.setVirtioScsiEnabled(true);
                }
                break;
            case DISK:
                if (VmPayload.isPayload(device.getSpecParams())) {
                    updateVmParams.setVmPayload(new VmPayload(device));
                }
                break;
            case CONSOLE:
                updateVmParams.setConsoleEnabled(true);
                break;
            case RNG:
                updateVmParams.setRngDevice(new VmRngDevice(device));
                break;
            case GRAPHICS:
                updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
                break;
            default:
        }
    }
    // clear these fields as these are non updatable
    getVm().getManagedVmDeviceMap().clear();
    getVm().getUnmanagedDeviceList().clear();
    return updateVmParams;
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Aggregations

VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)12 VM (org.ovirt.engine.core.common.businessentities.VM)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)2 ArrayList (java.util.ArrayList)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 ChangeDiskCommandParameters (org.ovirt.engine.core.common.action.ChangeDiskCommandParameters)1 ChangeVMClusterParameters (org.ovirt.engine.core.common.action.ChangeVMClusterParameters)1 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)1 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)1 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)1 VmPayload (org.ovirt.engine.core.common.businessentities.VmPayload)1 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)1 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)1 Guid (org.ovirt.engine.core.compat.Guid)1 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)1 UnitToGraphicsDeviceParamsBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder)1 VmIconUnitAndVmToParameterBuilder (org.ovirt.engine.ui.uicommonweb.builders.vm.VmIconUnitAndVmToParameterBuilder)1