use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class DataCenterGuideModel method saveNewPosixStorage.
private void saveNewPosixStorage() {
StorageModel model = (StorageModel) getWindow();
PosixStorageModel posixModel = (PosixStorageModel) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
hostId = host.getId();
// Create storage connection.
StorageServerConnections connection = new StorageServerConnections();
connection.setConnection(path);
connection.setStorageType(posixModel.getType());
connection.setVfsType(posixModel.getVfsType().getEntity());
connection.setMountOptions(posixModel.getMountOptions().getEntity());
this.connection = connection;
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
actionTypes.add(ActionType.AddStorageServerConnection);
actionTypes.add(posixModel.getAddStorageDomainVdcAction());
parameters.add(new StorageServerConnectionParametersBase(this.connection, host.getId(), false));
StorageDomainManagementParameter parameter = new StorageDomainManagementParameter(storageDomain);
parameter.setVdsId(host.getId());
StoragePool dataCenter = model.getDataCenter().getSelectedItem();
parameter.setStoragePoolId(dataCenter.getId());
parameters.add(parameter);
IFrontendActionAsyncCallback callback1 = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
ActionReturnValue actionReturnValue = result.getReturnValue();
dataCenterGuideModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
dataCenterGuideModel.connection.setId((String) actionReturnValue.getActionReturnValue());
};
IFrontendActionAsyncCallback callback2 = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
ActionReturnValue actionReturnValue = result.getReturnValue();
dataCenterGuideModel.storageId = actionReturnValue.getActionReturnValue();
// Attach storage to data center as necessary.
StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
StoragePool selectedDataCenter = storageModel.getDataCenter().getSelectedItem();
if (!selectedDataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
dataCenterGuideModel.attachStorageToDataCenter(dataCenterGuideModel.storageId, selectedDataCenter.getId());
}
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
};
IFrontendActionAsyncCallback failureCallback = result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
dataCenterGuideModel.cleanConnection(dataCenterGuideModel.connection, dataCenterGuideModel.hostId);
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, false, dataCenterGuideModel.storageModel);
};
Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2 })), failureCallback, this);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class CommandAsyncTask method handleEndActionResult.
private void handleEndActionResult(CommandMultiAsyncTasks commandInfo, ActionReturnValue actionReturnValue, ExecutionContext context, boolean isTaskGroupSuccess) {
try {
ActionType actionType = getParameters().getDbAsyncTask().getActionType();
log.info("CommandAsyncTask::HandleEndActionResult [within thread]: endAction for action type '{}'" + " completed, handling the result.", actionType);
if (actionReturnValue == null || (!actionReturnValue.getSucceeded() && actionReturnValue.getEndActionTryAgain())) {
log.info("CommandAsyncTask::HandleEndActionResult [within thread]: endAction for action type" + " '{}' hasn't succeeded, not clearing tasks, will attempt again next polling.", actionType);
commandInfo.repoll();
} else {
log.info("CommandAsyncTask::HandleEndActionResult [within thread]: endAction for action type" + " '{}' {}succeeded, clearing tasks.", actionType, actionReturnValue.getSucceeded() ? "" : "hasn't ");
commandInfo.clearTasks();
synchronized (_lockObject) {
if (commandInfo.getAllCleared()) {
log.info("CommandAsyncTask::HandleEndActionResult [within thread]: Removing" + " CommandMultiAsyncTasks object for entity '{}'", commandInfo.getCommandId());
_multiTasksByCommandIds.remove(commandInfo.getCommandId());
}
}
}
} catch (RuntimeException ex) {
log.error("CommandAsyncTask::HandleEndActionResult [within thread]: an exception has been thrown", ex);
}
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class RemoveDiskModel method onRemove.
public void onRemove(final ICommandTarget target) {
boolean removeDisk = getLatch().getEntity();
ActionType actionType = removeDisk ? ActionType.RemoveDisk : ActionType.DetachDiskFromVm;
List<ActionParametersBase> parameterList = disksToRemove.stream().map(disk -> removeDisk ? new RemoveDiskParameters(disk.getId()) : new AttachDetachVmDiskParameters(new DiskVmElement(disk.getId(), vm.getId()))).collect(Collectors.toList());
startProgress();
Frontend.getInstance().runMultipleAction(actionType, parameterList, result -> {
stopProgress();
target.executeCommand(cancelCommand);
}, this);
}
Aggregations