Search in sources :

Example 6 with ImageTransfer

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

the class TransferImageCommand method stopImageTransferSession.

private boolean stopImageTransferSession(ImageTransfer entity) {
    if (entity.getImagedTicketId() == null) {
        log.warn("Failed to stop image transfer session. Ticket does not exist for image '{}'", entity.getDiskId());
        return false;
    }
    if (!removeImageTicketFromDaemon(entity.getImagedTicketId(), entity.getVdsId())) {
        return false;
    }
    if (!removeImageTicketFromProxy(entity.getImagedTicketId())) {
        return false;
    }
    ImageTransfer updates = new ImageTransfer();
    updateEntity(updates, true);
    return true;
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)

Example 7 with ImageTransfer

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

the class TransferImageCommand method startImageTransferSession.

/**
 * Start the ovirt-image-daemon session
 */
protected void startImageTransferSession() {
    if (!initializeVds()) {
        log.error("Could not find a suitable host for image data transfer");
        updateEntityPhaseToPausedBySystem(AuditLogType.TRANSFER_IMAGE_PAUSED_BY_SYSTEM_MISSING_HOST);
        return;
    }
    Guid imagedTicketId = Guid.newGuid();
    // Create the signed ticket first because we can just throw it away if we fail to start the image
    // transfer session.  The converse would require us to close the transfer session on failure.
    String signedTicket = createSignedTicket(getVds(), imagedTicketId);
    if (signedTicket == null) {
        log.error("Failed to create a signed image ticket");
        updateEntityPhaseToPausedBySystem(AuditLogType.TRANSFER_IMAGE_PAUSED_BY_SYSTEM_FAILED_TO_CREATE_TICKET);
        return;
    }
    long timeout = getHostTicketLifetime();
    if (!addImageTicketToDaemon(imagedTicketId, timeout)) {
        log.error("Failed to add image ticket to ovirt-imageio-daemon");
        updateEntityPhaseToPausedBySystem(AuditLogType.TRANSFER_IMAGE_PAUSED_BY_SYSTEM_FAILED_TO_ADD_TICKET_TO_DAEMON);
        return;
    }
    if (!addImageTicketToProxy(imagedTicketId, signedTicket)) {
        log.error("Failed to add image ticket to ovirt-imageio-proxy");
        updateEntityPhaseToPausedBySystem(AuditLogType.TRANSFER_IMAGE_PAUSED_BY_SYSTEM_FAILED_TO_ADD_TICKET_TO_PROXY);
        return;
    }
    ImageTransfer updates = new ImageTransfer();
    updates.setVdsId(getVdsId());
    updates.setImagedTicketId(imagedTicketId);
    updates.setProxyUri(getProxyUri() + IMAGES_PATH);
    updates.setDaemonUri(getImageDaemonUri(getVds().getHostName()) + IMAGES_PATH);
    updates.setSignedTicket(signedTicket);
    updateEntity(updates);
    setNewSessionExpiration(timeout);
    updateEntityPhase(ImageTransferPhase.TRANSFERRING);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with ImageTransfer

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

the class TransferImageCommand method proceedCommandExecution.

public void proceedCommandExecution(Guid childCmdId) {
    ImageTransfer entity = imageTransferDao.get(getCommandId());
    if (entity == null || entity.getPhase() == null) {
        log.error("Image transfer status entity corrupt or missing from database" + " for image transfer command '{}'", getCommandId());
        setCommandStatus(CommandStatus.FAILED);
        return;
    }
    if (entity.getDiskId() != null) {
        // Make the disk id available for all states below.  If the transfer is still
        // initializing, this may be set below in the INITIALIZING block instead.
        setImageGroupId(entity.getDiskId());
    }
    // Check conditions for pausing the transfer (ie UI is MIA)
    long ts = System.currentTimeMillis() / 1000;
    if (stopTransferIfNecessary(entity, ts)) {
        return;
    }
    executeStateHandler(entity, ts, childCmdId);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer)

Example 9 with ImageTransfer

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

the class TransferImageCommand method executeCommand.

@Override
protected void executeCommand() {
    log.info("Creating ImageTransfer entity for command '{}'", getCommandId());
    ImageTransfer entity = new ImageTransfer(getCommandId());
    entity.setCommandType(getActionType());
    entity.setPhase(ImageTransferPhase.INITIALIZING);
    entity.setType(getParameters().getTransferType());
    entity.setActive(false);
    entity.setLastUpdated(new Date());
    entity.setBytesTotal(getParameters().getTransferSize());
    imageTransferDao.save(entity);
    if (isImageProvided()) {
        handleImageIsReadyForTransfer();
    } else {
        if (getParameters().getTransferType() == TransferType.Download) {
            failValidation(EngineMessage.ACTION_TYPE_FAILED_IMAGE_NOT_SPECIFIED_FOR_DOWNLOAD);
            setSucceeded(false);
            return;
        }
        log.info("Creating {} image", getImageType());
        createImage();
    }
    setActionReturnValue(getCommandId());
    setSucceeded(true);
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) Date(java.util.Date)

Example 10 with ImageTransfer

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

the class TransferImageCommand method pollTransferStatus.

private void pollTransferStatus(final StateContext context) {
    if (context.entity.getVdsId() == null || context.entity.getImagedTicketId() == null || !FeatureSupported.getImageTicketSupported(vdsDao.get(context.entity.getVdsId()).getClusterCompatibilityVersion())) {
        // Old engines update the transfer status in UploadImageHandler::updateBytesSent.
        return;
    }
    ImageTicketInformation ticketInfo;
    try {
        ticketInfo = (ImageTicketInformation) runVdsCommand(VDSCommandType.GetImageTicket, new GetImageTicketVDSCommandParameters(context.entity.getVdsId(), context.entity.getImagedTicketId())).getReturnValue();
    } catch (EngineException e) {
        log.error("Could not get image ticket '{}' from vdsm", context.entity.getImagedTicketId(), e);
        updateEntityPhaseToPausedBySystem(AuditLogType.TRANSFER_IMAGE_PAUSED_BY_SYSTEM_MISSING_TICKET);
        return;
    }
    ImageTransfer upToDateImageTransfer = updateTransferStatusWithTicketInformation(context.entity, ticketInfo);
    if (getParameters().getTransferType() == TransferType.Download) {
        finalizeDownloadIfNecessary(context, upToDateImageTransfer);
    }
}
Also used : ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) GetImageTicketVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImageTicketVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) ImageTicketInformation(org.ovirt.engine.core.common.businessentities.storage.ImageTicketInformation)

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