Search in sources :

Example 21 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class AddDiskCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    createNewDiskId();
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getDiskInfo().getId()));
    ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm());
    switch(getParameters().getDiskInfo().getDiskStorageType()) {
        case IMAGE:
            createDiskBasedOnImage();
            break;
        case LUN:
            createDiskBasedOnLun();
            break;
        case CINDER:
            createDiskBasedOnCinder();
            break;
    }
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 22 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class CreateSnapshotFromTemplateCommand method removeImage.

private void removeImage() {
    RemoveImageParameters removeImageParams = new RemoveImageParameters(getParameters().getDestinationImageId());
    removeImageParams.setStorageDomainId(getDestinationStorageDomainId());
    removeImageParams.setDbOperationScope(ImageDbOperationScope.NONE);
    removeImageParams.setShouldLockImage(false);
    removeImageParams.setEntityInfo(new EntityInfo(VdcObjectType.Disk, getDestinationDiskImage().getId()));
    ActionReturnValue returnValue = runInternalActionWithTasksContext(ActionType.RemoveImage, removeImageParams);
    if (!returnValue.getSucceeded()) {
        addAuditLogOnRemoveFailure();
    }
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 23 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class CopyImageGroupCommand method revertTasks.

@Override
protected void revertTasks() {
    if (getParameters().getRevertDbOperationScope() != null) {
        Guid destImageId = getParameters().getDestinationImageId();
        RemoveImageParameters removeImageParams = new RemoveImageParameters(destImageId);
        if (getParameters().getParentCommand() == ActionType.AddVmFromSnapshot) {
            removeImageParams.setParentParameters(getParameters());
            removeImageParams.setParentCommand(ActionType.CopyImageGroup);
        } else {
            removeImageParams.setParentParameters(removeImageParams);
            removeImageParams.setParentCommand(ActionType.RemoveImage);
            removeImageParams.setStorageDomainId(getParameters().getStorageDomainId());
            removeImageParams.setDbOperationScope(getParameters().getRevertDbOperationScope());
            removeImageParams.setShouldLockImage(getParameters().isShouldLockImageOnRevert());
        }
        removeImageParams.setEntityInfo(new EntityInfo(VdcObjectType.Disk, getDestinationImageId()));
        // Setting the image as the monitored entity, so there will not be dependency
        ActionReturnValue returnValue = checkAndPerformRollbackUsingCommand(ActionType.RemoveImage, removeImageParams, null);
        if (returnValue.getSucceeded()) {
            // Starting to monitor the tasks - RemoveImage is an internal command
            // which adds the taskId on the internal task ID list
            startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
        }
    }
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 24 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class DestroyImageCommand method executeCommand.

@Override
protected void executeCommand() {
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId()));
    VDSReturnValue vdsReturnValue = null;
    try {
        vdsReturnValue = runVdsCommand(VDSCommandType.DestroyImage, createVDSParameters());
    } catch (EngineException e) {
        log.error("Failed to delete image {}/{}", getParameters().getImageGroupId(), getParameters().getImageList().stream().findFirst().get(), e);
        if (!getParameters().isLiveMerge()) {
            throw e;
        }
    }
    if (vdsReturnValue != null && vdsReturnValue.getCreationInfo() != null) {
        Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
        Guid result = createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId());
        getTaskIdList().add(result);
        log.info("Successfully started task to remove orphaned volumes resulting from live merge");
    } else {
        log.info("Retrying deleting image {}/{}", getParameters().getImageGroupId(), getParameters().getImageList().stream().findFirst().get());
        MergeStatusReturnValue returnValue = new MergeStatusReturnValue(VmBlockJobType.COMMIT, new HashSet<>(getParameters().getImageList()));
        getReturnValue().setActionReturnValue(returnValue);
        // At this point, we know that this command was executed during live merge and it is safe to do
        // the casting in the next line.
        ((RemoveSnapshotSingleDiskParameters) getParameters().getParentParameters()).setNextCommandStep(RemoveSnapshotSingleDiskStep.DESTROY_IMAGE);
    }
    setSucceeded(true);
    setCommandStatus(CommandStatus.SUCCEEDED);
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) RemoveSnapshotSingleDiskParameters(org.ovirt.engine.core.common.action.RemoveSnapshotSingleDiskParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) MergeStatusReturnValue(org.ovirt.engine.core.common.action.MergeStatusReturnValue)

Example 25 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class ImportRepoImageCommand method setupParameters.

private void setupParameters() {
    getParameters().setImageGroupID(Guid.newGuid());
    getParameters().setDestinationImageId(Guid.newGuid());
    if (getParameters().getImportAsTemplate()) {
        getParameters().setVmSnapshotId(Guid.newGuid());
    }
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Aggregations

EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)33 Guid (org.ovirt.engine.core.compat.Guid)14 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)6 MoveOrCopyImageGroupParameters (org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)5 RemoveImageParameters (org.ovirt.engine.core.common.action.RemoveImageParameters)5 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Test (org.junit.Test)3 RunVmParams (org.ovirt.engine.core.common.action.RunVmParams)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Disk (org.ovirt.engine.api.model.Disk)2 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)2 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Instance (javax.enterprise.inject.Instance)1 Typed (javax.enterprise.inject.Typed)1