Search in sources :

Example 1 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer 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 ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer in project ovirt-engine by oVirt.

the class DownloadImageHandler method start.

public void start() {
    Frontend.getInstance().runAction(ActionType.TransferDiskImage, createInitParams(), result -> {
        if (result.getReturnValue().getSucceeded()) {
            Guid transferId = result.getReturnValue().getActionReturnValue();
            Frontend.getInstance().runQuery(QueryType.GetImageTransferById, new IdQueryParameters(transferId), new AsyncQuery<QueryReturnValue>(returnValue -> {
                ImageTransfer imageTransfer = returnValue.getReturnValue();
                initiateDownload(imageTransfer);
            }));
        }
    }, this);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ImageTransferPhase(org.ovirt.engine.core.common.businessentities.storage.ImageTransferPhase) Predicate(java.util.function.Predicate) Guid(org.ovirt.engine.core.compat.Guid) TransferImageStatusParameters(org.ovirt.engine.core.common.action.TransferImageStatusParameters) Frame(com.google.gwt.user.client.ui.Frame) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) TransferType(org.ovirt.engine.core.common.businessentities.storage.TransferType) Logger(java.util.logging.Logger) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) RootPanel(com.google.gwt.user.client.ui.RootPanel) ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) TransferDiskImageParameters(org.ovirt.engine.core.common.action.TransferDiskImageParameters) Style(com.google.gwt.dom.client.Style) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) AuditLogType(org.ovirt.engine.core.common.AuditLogType) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer 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 4 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer 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 5 with ImageTransfer

use of org.ovirt.engine.core.common.businessentities.storage.ImageTransfer 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)

Aggregations

ImageTransfer (org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)22 TransferImageStatusParameters (org.ovirt.engine.core.common.action.TransferImageStatusParameters)9 Date (java.util.Date)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 Guid (org.ovirt.engine.core.compat.Guid)3 ArrayList (java.util.ArrayList)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 AsyncQuery (org.ovirt.engine.ui.frontend.AsyncQuery)2 Scheduler (com.google.gwt.core.client.Scheduler)1 Style (com.google.gwt.dom.client.Style)1 Frame (com.google.gwt.user.client.ui.Frame)1 RootPanel (com.google.gwt.user.client.ui.RootPanel)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Logger (java.util.logging.Logger)1 Test (org.junit.Test)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1