Search in sources :

Example 6 with RemoveImageParameters

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

the class RemoveDiskCommand method buildRemoveImageParameters.

private RemoveImageParameters buildRemoveImageParameters(DiskImage diskImage) {
    RemoveImageParameters result = new RemoveImageParameters(diskImage.getImageId());
    result.setTransactionScopeOption(TransactionScopeOption.Suppress);
    result.setDiskImage(diskImage);
    result.setParentCommand(ActionType.RemoveDisk);
    result.setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getDiskId()));
    result.setParentParameters(getParameters());
    result.setRemoveFromSnapshots(true);
    result.setStorageDomainId(getParameters().getStorageDomainId());
    result.setForceDelete(getParameters().getForceDelete());
    if (diskImage.getStorageIds().size() > 1) {
        result.setDbOperationScope(ImageDbOperationScope.MAPPING);
    }
    return result;
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 7 with RemoveImageParameters

use of org.ovirt.engine.core.common.action.RemoveImageParameters 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 8 with RemoveImageParameters

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

the class RemoveAllVmImagesCommand method buildRemoveImageParameters.

private RemoveImageParameters buildRemoveImageParameters(DiskImage image) {
    RemoveImageParameters result = new RemoveImageParameters(image.getImageId());
    boolean parentExists = isExecutedAsChildCommand();
    result.setParentCommand(parentExists ? getParameters().getParentCommand() : getActionType());
    result.setParentParameters(parentExists ? getParameters().getParentParameters() : getParameters());
    result.setDiskImage(image);
    result.setEntityInfo(getParameters().getEntityInfo());
    result.setForceDelete(getParameters().getForceDelete());
    result.setShouldLockImage(false);
    return result;
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters)

Example 9 with RemoveImageParameters

use of org.ovirt.engine.core.common.action.RemoveImageParameters 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)

Aggregations

RemoveImageParameters (org.ovirt.engine.core.common.action.RemoveImageParameters)9 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)7 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)6 Guid (org.ovirt.engine.core.compat.Guid)4 HashSet (java.util.HashSet)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1 Instance (javax.enterprise.inject.Instance)1 Typed (javax.enterprise.inject.Typed)1 Inject (javax.inject.Inject)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1