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;
}
}
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);
}
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());
}
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);
}
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));
}
Aggregations