Search in sources :

Example 1 with TransferImageStatusParameters

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

the class DownloadImageHandler method closeSession.

private void closeSession(ImageTransferPhase imageTransferPhase, AuditLogType auditLogType) {
    ImageTransfer updates = new ImageTransfer();
    updates.setPhase(imageTransferPhase);
    TransferImageStatusParameters parameters = new TransferImageStatusParameters();
    parameters.setDiskId(diskImage.getId());
    parameters.setUpdates(updates);
    if (auditLogType != null) {
        parameters.setAuditLogType(auditLogType);
    }
    Frontend.getInstance().runAction(ActionType.TransferImageStatus, parameters);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 2 with TransferImageStatusParameters

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

the class UploadImageHandler method finalizeImageUpload.

private void finalizeImageUpload() {
    if (getUploadState() == UploadState.ENGINE_PAUSE) {
        // $NON-NLS-1$
        log.info("Upload paused; stopping model execution");
        return;
    }
    ImageTransfer updates = new ImageTransfer();
    TransferImageStatusParameters statusParameters = new TransferImageStatusParameters(getCommandId(), updates);
    if (getUploadState() == UploadState.SUCCESS) {
        // $NON-NLS-1$
        setProgressStr("Finalizing success...");
        statusParameters.getUpdates().setPhase(ImageTransferPhase.FINALIZING_SUCCESS);
        raiseUploadFinishedEvent(ImageTransferPhase.FINALIZING_SUCCESS);
    } else if (getUploadState() == UploadState.CLIENT_ERROR) {
        // $NON-NLS-1$
        setProgressStr("Pausing due to client error");
        statusParameters.getUpdates().setPhase(ImageTransferPhase.PAUSED_SYSTEM);
        statusParameters.setDiskId(getDiskId());
        statusParameters.setAuditLogType(auditLogType);
    } else {
        // $NON-NLS-1$
        setProgressStr("Finalizing failure...");
        statusParameters.getUpdates().setPhase(ImageTransferPhase.FINALIZING_FAILURE);
        raiseUploadFinishedEvent(ImageTransferPhase.FINALIZING_FAILURE);
    }
    // $NON-NLS-1$
    log.info("Updating status to " + statusParameters.getUpdates().getPhase());
    Frontend.getInstance().runAction(ActionType.TransferImageStatus, statusParameters, result -> {
        if (!result.getReturnValue().getSucceeded()) {
            if (++failedFinalizationAttempts < MAX_FAILED_POLL_ATTEMPTS) {
                finalizeImageUpload();
            } else {
                setContinuePolling(false);
                // $NON-NLS-1$
                setProgressStr("Failed to update upload status on engine");
            }
        }
    });
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 3 with TransferImageStatusParameters

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

the class UploadImageHandler method initiateResumeUploadCheckStatus.

private void initiateResumeUploadCheckStatus(FrontendActionAsyncResult result) {
    AsyncQuery<String> asyncQuery = (AsyncQuery<String>) result.getState();
    if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
        ImageTransfer rv = result.getReturnValue().getActionReturnValue();
        if (rv.getBytesTotal() != getImageSize()) {
            if (rv.getBytesTotal() == 0) {
                // This upload was generated by the API.
                asyncQuery.getAsyncCallback().onSuccess(messages.uploadImageFailedToResumeUploadOriginatedInAPI());
            } else {
                asyncQuery.getAsyncCallback().onSuccess(messages.uploadImageFailedToResumeSizeMessage(rv.getBytesTotal(), getImageSize()));
            }
            return;
        }
        // Resumable uploads already have a command running on engine, so get its id and resume it.
        ImageTransfer updates = new ImageTransfer();
        updates.setPhase(ImageTransferPhase.RESUMING);
        TransferImageStatusParameters parameters = new TransferImageStatusParameters(rv.getId());
        parameters.setUpdates(updates);
        Frontend.getInstance().runAction(ActionType.TransferImageStatus, parameters, this::initiateResumeUploadStartTransfer);
    } else {
        setProgressStr(messages.uploadImageFailedToResumeMessage(result.getReturnValue().getDescription()));
    }
    asyncQuery.getAsyncCallback().onSuccess(null);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Example 4 with TransferImageStatusParameters

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

the class UploadImageModel method pauseUploads.

public static void pauseUploads(List<? extends Disk> disks) {
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Disk disk : disks) {
        ImageTransfer updates = new ImageTransfer();
        updates.setPhase(ImageTransferPhase.PAUSED_USER);
        TransferImageStatusParameters parameters = new TransferImageStatusParameters();
        parameters.setUpdates(updates);
        parameters.setDiskId(disk.getId());
        list.add(parameters);
    }
    Frontend.getInstance().runMultipleAction(ActionType.TransferImageStatus, list);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) ArrayList(java.util.ArrayList) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 5 with TransferImageStatusParameters

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

the class UploadImageModel method initiateResumeUpload.

private void initiateResumeUpload() {
    TransferImageStatusParameters parameters = new TransferImageStatusParameters();
    parameters.setDiskId(getDiskModel().getDisk().getId());
    startProgress();
    final UploadImageModel model = this;
    UploadImageManager.getInstance().resumeUpload(getImageFileUploadElement(), parameters, new AsyncQuery<>(errorMessage -> {
        model.stopProgress();
        if (errorMessage != null) {
            model.setMessage(errorMessage);
        } else {
            // Close dialog
            model.getCancelCommand().execute();
        }
    }));
}
Also used : DiskContentType(org.ovirt.engine.core.common.businessentities.storage.DiskContentType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ImageTransferPhase(org.ovirt.engine.core.common.businessentities.storage.ImageTransferPhase) Guid(org.ovirt.engine.core.compat.Guid) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) TransferType(org.ovirt.engine.core.common.businessentities.storage.TransferType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException) TransferDiskImageParameters(org.ovirt.engine.core.common.action.TransferDiskImageParameters) Response(com.google.gwt.http.client.Response) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) Model(org.ovirt.engine.ui.uicommonweb.models.Model) NewDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.NewDiskModel) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ValidationResult(org.ovirt.engine.ui.uicommonweb.validation.ValidationResult) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Logger(java.util.logging.Logger) Request(com.google.gwt.http.client.Request) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ReadOnlyDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.ReadOnlyDiskModel) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Element(com.google.gwt.dom.client.Element) VDS(org.ovirt.engine.core.common.businessentities.VDS) AbstractDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AbstractDiskModel) RequestCallback(com.google.gwt.http.client.RequestCallback) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters)

Aggregations

TransferImageStatusParameters (org.ovirt.engine.core.common.action.TransferImageStatusParameters)11 ImageTransfer (org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)10 ArrayList (java.util.ArrayList)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)4 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)4 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)3 Element (com.google.gwt.dom.client.Element)2 Request (com.google.gwt.http.client.Request)2 RequestBuilder (com.google.gwt.http.client.RequestBuilder)2 RequestCallback (com.google.gwt.http.client.RequestCallback)2 RequestException (com.google.gwt.http.client.RequestException)2 Response (com.google.gwt.http.client.Response)2 List (java.util.List)2 Logger (java.util.logging.Logger)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 AddDiskParameters (org.ovirt.engine.core.common.action.AddDiskParameters)2 TransferDiskImageParameters (org.ovirt.engine.core.common.action.TransferDiskImageParameters)2 StorageFormatType (org.ovirt.engine.core.common.businessentities.StorageFormatType)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2