Search in sources :

Example 46 with ActionReturnValue

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

the class AddDataCenterRM method rollback4.

private void rollback4() {
    Enlistment enlistment = context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    ActionReturnValue returnValue = context.changeVDSClusterReturnValue;
    if (returnValue != null && returnValue.getSucceeded()) {
        // Remove cluster.
        if (enlistmentContext.getClusterId() != null) {
            Frontend.getInstance().runAction(ActionType.RemoveCluster, new ClusterParametersBase(enlistmentContext.getClusterId()), result -> rollback5());
        }
    } else {
        context.enlistment = null;
        enlistment.done();
    }
}
Also used : ClusterParametersBase(org.ovirt.engine.core.common.action.ClusterParametersBase) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) Enlistment(org.ovirt.engine.ui.uicompat.Enlistment)

Example 47 with ActionReturnValue

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

the class AddStorageDomainRM method prepare6.

private void prepare6() {
    ActionReturnValue returnValue = context.addLocalStorageDomainReturnValue;
    if (returnValue == null || !returnValue.getSucceeded()) {
        StorageServerConnectionParametersBase parameter = new StorageServerConnectionParametersBase(context.connection, context.host.getId(), false);
        parameter.setCorrelationId(getCorrelationId());
        Frontend.getInstance().runAction(ActionType.DisconnectStorageServerConnection, parameter, result -> {
            ActionReturnValue returnValue1 = result.getReturnValue();
            context.removeStorageServerConnectionReturnValue = returnValue1;
            prepare7();
        });
    } else {
        prepare7();
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)

Example 48 with ActionReturnValue

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

the class AddStorageDomainRM method prepare2.

private void prepare2() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    ActionReturnValue returnValue = context.activateVdsReturnValue;
    if (returnValue == null || !returnValue.getSucceeded()) {
        context.enlistment = null;
        enlistment.forceRollback();
    } else {
        prepare3();
    }
}
Also used : PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 49 with ActionReturnValue

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

the class AddStorageDomainRM method prepare4.

private void prepare4() {
    if (timer != null) {
        timer.cancel();
        timer = null;
    }
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext();
    HostListModel<?> model = enlistmentContext.getModel();
    ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow();
    if (context.host.getStatus() != VDSStatus.Up) {
        prepare3();
    } else {
        // Add storage domain.
        StorageServerConnections connection = new StorageServerConnections();
        connection.setConnection(configureModel.getStorage().getPath().getEntity());
        connection.setStorageType(StorageType.LOCALFS);
        context.connection = connection;
        StorageServerConnectionParametersBase parameters = new StorageServerConnectionParametersBase(connection, context.host.getId(), false);
        parameters.setCorrelationId(getCorrelationId());
        Frontend.getInstance().runAction(ActionType.AddStorageServerConnection, parameters, result -> {
            ActionReturnValue returnValue = result.getReturnValue();
            context.addStorageServerConnectionReturnValue = returnValue;
            prepare5();
        });
    }
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)

Example 50 with ActionReturnValue

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

the class AddStorageDomainRM method prepare7.

private void prepare7() {
    PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment;
    ActionReturnValue returnValue = context.removeStorageServerConnectionReturnValue;
    context.enlistment = null;
    // ReturnValue not equals null means remove connection occurred.
    if (returnValue != null) {
        // Don't rollback.
        enlistment.done();
    } else {
        enlistment.prepared();
    }
}
Also used : PreparingEnlistment(org.ovirt.engine.ui.uicompat.PreparingEnlistment) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Aggregations

ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)293 ArrayList (java.util.ArrayList)57 Guid (org.ovirt.engine.core.compat.Guid)55 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)50 Test (org.junit.Test)37 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)27 ActionType (org.ovirt.engine.core.common.action.ActionType)26 EngineException (org.ovirt.engine.core.common.errors.EngineException)25 VDS (org.ovirt.engine.core.common.businessentities.VDS)23 HashSet (java.util.HashSet)16 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 ExecutionException (java.util.concurrent.ExecutionException)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)13 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)12 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)12 List (java.util.List)11 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11