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