Search in sources :

Example 36 with ActionType

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

the class ColdMergeSnapshotSingleDiskCommand method performNextOperation.

@Override
public boolean performNextOperation(int completedChildCount) {
    // Upon recovery or after invoking a new child command, our map may be missing an entry
    syncChildCommandList(getParameters());
    Guid currentChildId = getCurrentChildId(getParameters());
    if (currentChildId != null) {
        getParameters().setCommandStep(getParameters().getNextCommandStep());
    }
    log.info("Command '{}' id '{}' executing step '{}'", getActionType(), getCommandId(), getParameters().getCommandStep());
    Pair<ActionType, ? extends ActionParametersBase> nextCommand = null;
    switch(getParameters().getCommandStep()) {
        case PREPARE_MERGE:
            nextCommand = new Pair<>(ActionType.PrepareMerge, buildColdMergeParameters(getImage(), getDestinationDiskImage()));
            getParameters().setNextCommandStep(RemoveSnapshotSingleDiskStep.MERGE);
            break;
        case MERGE:
            nextCommand = new Pair<>(ActionType.ColdMerge, buildColdMergeParameters(getImage(), getDestinationDiskImage()));
            getParameters().setNextCommandStep(RemoveSnapshotSingleDiskStep.FINALIZE_MERGE);
            break;
        case FINALIZE_MERGE:
            nextCommand = new Pair<>(ActionType.FinalizeMerge, buildColdMergeParameters(getImage(), getDestinationDiskImage()));
            getParameters().setNextCommandStep(RemoveSnapshotSingleDiskStep.DESTROY_IMAGE);
            break;
        case DESTROY_IMAGE:
            nextCommand = buildDestroyCommand(ActionType.DestroyImage, getActionType(), Collections.singletonList(getDestinationImageId()));
            getParameters().setNextCommandStep(RemoveSnapshotSingleDiskStep.COMPLETE);
            break;
        case COMPLETE:
            setCommandStatus(CommandStatus.SUCCEEDED);
            break;
    }
    persistCommandIfNeeded();
    if (nextCommand != null) {
        runInternalActionWithTasksContext(nextCommand.getFirst(), nextCommand.getSecond());
        // Add the child, but wait, it's a race!  child will start, task may spawn, get polled, and we won't have the child id
        return true;
    } else {
        return false;
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) Guid(org.ovirt.engine.core.compat.Guid)

Example 37 with ActionType

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

the class OptionsModel method onSave.

private void onSave() {
    EditOptionsModel model = (EditOptionsModel) getWindow();
    UserProfileParameters params = new UserProfileParameters();
    ActionType action = ActionType.AddUserProfile;
    if (getUserProfile() != null) {
        action = ActionType.UpdateUserProfile;
        params.setUserProfile(getUserProfile());
    }
    params.getUserProfile().setSshPublicKey(model.getPublicKey().getEntity());
    model.startProgress(null);
    Frontend.getInstance().runAction(action, params, result -> {
        EditOptionsModel editOptionsModel = (EditOptionsModel) result.getState();
        editOptionsModel.stopProgress();
        cancel();
    }, model);
}
Also used : UserProfileParameters(org.ovirt.engine.core.common.action.UserProfileParameters) ActionType(org.ovirt.engine.core.common.action.ActionType)

Example 38 with ActionType

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

the class ActionTypeTest method testAuditLogTypeValueUniqueness.

@Test
public void testAuditLogTypeValueUniqueness() {
    BitSet bitset = new BitSet(bitSetSize);
    Set<Integer> nonUniqueValues = new TreeSet<>();
    for (ActionType at : ActionType.values()) {
        if (bitset.get(at.getValue())) {
            nonUniqueValues.add(at.getValue());
        } else {
            bitset.set(at.getValue());
        }
    }
    assertTrue("ActionType contains the following non unique values: " + nonUniqueValues, nonUniqueValues.isEmpty());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) TreeSet(java.util.TreeSet) BitSet(java.util.BitSet) Test(org.junit.Test)

Example 39 with ActionType

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

the class BackendVmResource method start.

@Override
public Response start(Action action) {
    RunVmParams params;
    ActionType actionType;
    if (action.isSetVm()) {
        Vm vm = action.getVm();
        actionType = ActionType.RunVmOnce;
        params = createRunVmOnceParams(vm, action.isSetVolatile() && action.isVolatile());
    } else {
        actionType = ActionType.RunVm;
        params = new RunVmParams(guid);
    }
    if (action.isSetPause() && action.isPause()) {
        params.setRunAndPause(true);
    }
    boolean useSysprep = action.isSetUseSysprep() && action.isUseSysprep();
    boolean useCloudInit = action.isSetUseCloudInit() && action.isUseCloudInit();
    if (useSysprep && useCloudInit) {
        Fault fault = new Fault();
        fault.setReason(localize(Messages.CANT_USE_SYSPREP_AND_CLOUD_INIT_SIMULTANEOUSLY));
        return Response.status(Response.Status.CONFLICT).entity(fault).build();
    }
    if (useSysprep) {
        params.setInitializationType(InitializationType.Sysprep);
    } else if (useCloudInit) {
        params.setInitializationType(InitializationType.CloudInit);
    } else {
        params.setInitializationType(InitializationType.None);
    }
    return doAction(actionType, params, action);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) Vm(org.ovirt.engine.api.model.Vm) Fault(org.ovirt.engine.api.model.Fault) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams)

Example 40 with ActionType

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_twoItems_failure.

@Test
public void testTransmitOperationList_twoItems_failure() {
    List<VdcOperation<?, ?>> testList = new ArrayList<>();
    ActionParametersBase testParameters = new ActionParametersBase();
    VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, testParameters, mockOperationCallbackList1);
    VdcOperation<ActionType, ActionParametersBase> testOperation2 = new VdcOperation<>(ActionType.ActivateVds, testParameters, mockOperationCallbackList1);
    List<ActionParametersBase> testParameterList = createActionParameterList(testParameters, 2);
    testList.add(testOperation1);
    testList.add(testOperation2);
    testProvider.transmitOperationList(testList);
    verify(mockService).runMultipleActions(eq(ActionType.ActivateVds), (ArrayList<ActionParametersBase>) eq(testParameterList), eq(false), eq(true), actionCallbackList.capture());
    // $NON-NLS-1$
    Exception testException = new Exception("Failure");
    actionCallbackList.getValue().onFailure(testException);
    verify(mockOperationCallbackList1).onFailure(eq(testList), eq(testException));
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Aggregations

ActionType (org.ovirt.engine.core.common.action.ActionType)58 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)37 ArrayList (java.util.ArrayList)31 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)24 Test (org.junit.Test)23 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)16 Guid (org.ovirt.engine.core.compat.Guid)15 List (java.util.List)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)11 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)10 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)10 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)9 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)9 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)9 Arrays (java.util.Arrays)7 HashSet (java.util.HashSet)7 Set (java.util.Set)7