Search in sources :

Example 1 with ChangeVMClusterParameters

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

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

the class BackendVmResource method update.

@Override
public Vm update(Vm incoming) {
    validateParameters(incoming);
    if (incoming.isSetCluster() && (incoming.getCluster().isSetId() || incoming.getCluster().isSetName())) {
        Guid clusterId = lookupClusterId(incoming);
        if (!clusterId.toString().equals(get().getCluster().getId())) {
            performAction(ActionType.ChangeVMCluster, // TODO: change 'null' to 'incoming.getVmCompa...' when REST support is added
            new ChangeVMClusterParameters(clusterId, guid, null));
        }
    }
    if (!isFiltered()) {
        if (incoming.isSetPlacementPolicy()) {
            parent.validateAndUpdateHostsInPlacementPolicy(incoming.getPlacementPolicy());
        }
    } else {
        incoming.setPlacementPolicy(null);
    }
    QueryType queryType = isNextRunRequested() ? QueryType.GetVmNextRunConfiguration : QueryType.GetVmByVmId;
    Vm vm = performUpdate(incoming, new QueryIdResolver<>(queryType, IdQueryParameters.class), ActionType.UpdateVm, new UpdateParametersProvider());
    if (vm != null) {
        DisplayHelper.adjustDisplayData(this, vm, false);
        removeRestrictedInfo(vm);
    }
    return vm;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Vm(org.ovirt.engine.api.model.Vm) ChangeVMClusterParameters(org.ovirt.engine.core.common.action.ChangeVMClusterParameters) Guid(org.ovirt.engine.core.compat.Guid) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 3 with ChangeVMClusterParameters

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

the class MigrateVmCommand method updateVmAfterMigrationToDifferentCluster.

private void updateVmAfterMigrationToDifferentCluster() {
    if (getParameters().getTargetClusterId() == null || getVm().getClusterId().equals(getParameters().getTargetClusterId())) {
        return;
    }
    ChangeVMClusterParameters params = new ChangeVMClusterParameters(getParameters().getTargetClusterId(), getVmId(), getVm().getCustomCompatibilityVersion());
    setSucceeded(backend.runInternalAction(ActionType.ChangeVMCluster, params).getSucceeded());
}
Also used : ChangeVMClusterParameters(org.ovirt.engine.core.common.action.ChangeVMClusterParameters)

Aggregations

ChangeVMClusterParameters (org.ovirt.engine.core.common.action.ChangeVMClusterParameters)3 Guid (org.ovirt.engine.core.compat.Guid)2 Vm (org.ovirt.engine.api.model.Vm)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1